:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9e0e7;
  --text: #1e2933;
  --muted: #6b7785;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #0f8a5f;
  --warning: #b45309;
  --danger: #b42318;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

body:not([data-role="admin"]) .admin-only,
body:not([data-role="admin"]) .records-summary {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .08);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: #102a43;
  color: #fff;
  font-weight: 800;
  border-radius: 8px;
  margin-bottom: 16px;
}

h1, h2 { margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 16px; margin-bottom: 14px; }
p { margin: 8px 0 0; color: var(--muted); }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #344054;
}

input, select, textarea, button {
  font: inherit;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

textarea { resize: vertical; }

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 650;
}

button.primary, .login-panel button {
  background: var(--primary);
  color: #fff;
}

button.primary:hover, .login-panel button:hover {
  background: var(--primary-dark);
}

button.success {
  background: var(--success);
  color: #fff;
}

button.success:hover {
  background: #0b7651;
}

button.secondary {
  background: #e8eef7;
  color: #17324d;
}

.error-text { color: var(--danger); min-height: 20px; }

.paid-order-toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-weight: 750;
  box-shadow: 0 16px 36px rgba(15, 23, 42, .24);
}

.paid-toast-title {
  line-height: 1.45;
}

.paid-toast-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.paid-toast-actions button {
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
}

.paid-toast-actions button:first-child {
  background: #2563eb;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #102a43;
  color: #fff;
  padding: 18px 14px;
}

.logo {
  font-size: 18px;
  font-weight: 800;
  padding: 10px 12px 22px;
}

.nav {
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
  background: transparent;
  color: #d8e4f2;
}

.nav.active, .nav:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.nav.ghost {
  margin-top: 28px;
  color: #b8c7d9;
}

.nav.ghost.sound-toggle {
  margin-top: 28px;
  color: #dbeafe;
  background: rgba(37, 99, 235, .18);
}

.nav.ghost.sound-toggle.enabled {
  color: #bbf7d0;
  background: rgba(15, 138, 95, .18);
}

.nav.ghost.sound-toggle + .nav.ghost {
  margin-top: 8px;
}

.content {
  padding: 24px;
  overflow-x: hidden;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.quote-title-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.top-save-actions {
  display: grid;
  grid-template-columns: repeat(2, 150px);
  gap: 10px;
  align-items: center;
}

.top-save-actions button {
  min-height: 40px;
  white-space: nowrap;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.panel-heading button {
  white-space: nowrap;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr);
  gap: 16px;
}

.quote-search-panel {
  padding: 14px 16px;
}

.quote-search-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, .9fr);
  gap: 16px;
  align-items: center;
}

.quote-search-head h2 {
  margin-bottom: 4px;
}

.quote-search-head p,
.search-dialog-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.quote-search-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
}

.wide-label { margin-top: 12px; }

.totals {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: baseline;
  border-bottom: 1px solid #edf1f5;
  padding-bottom: 9px;
}

.metric-row span { color: var(--muted); }
.metric-row strong { font-size: 24px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips span {
  background: #edf4ff;
  color: #174ea6;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}


.records-table {
  width: max(100%, 1520px);
  min-width: 1520px;
  table-layout: fixed;
}

.records-table.show-follow {
  width: max(100%, 1580px);
  min-width: 1580px;
}

.records-table th,
.records-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.records-table th:nth-child(1),
.records-table td:nth-child(1) { width: 52px; }
.records-table th:nth-child(2),
.records-table td:nth-child(2) { width: 252px; }
.records-table th:nth-child(3),
.records-table td:nth-child(3) { width: 340px; white-space: normal; }
.records-table th:nth-child(4),
.records-table td:nth-child(4) { width: 164px; }
.records-table th:nth-child(5),
.records-table td:nth-child(5) { width: 132px; }
.records-table th:nth-child(6),
.records-table td:nth-child(6) { width: 74px; }
.records-table th:nth-child(7),
.records-table td:nth-child(7) { width: 78px; }
.records-table th:nth-child(8),
.records-table td:nth-child(8) { width: 120px; }
.records-table th:nth-child(9),
.records-table td:nth-child(9) { width: 200px; }
.records-table th:nth-child(10),
.records-table td:nth-child(10) { width: 104px; }
.records-table .follow-column { display: none; }
.records-table.show-follow .follow-column { display: table-cell; }
.records-table.show-follow th:nth-child(5),
.records-table.show-follow td:nth-child(5) { width: 78px; }
.records-table.show-follow th:nth-child(6),
.records-table.show-follow td:nth-child(6) { width: 132px; }
.records-table.show-follow th:nth-child(7),
.records-table.show-follow td:nth-child(7) { width: 74px; }
.records-table.show-follow th:nth-child(8),
.records-table.show-follow td:nth-child(8) { width: 78px; }
.records-table.show-follow th:nth-child(9),
.records-table.show-follow td:nth-child(9) { width: 120px; }
.records-table.show-follow th:nth-child(10),
.records-table.show-follow td:nth-child(10) { width: 200px; }
.records-table.show-follow th:nth-child(11),
.records-table.show-follow td:nth-child(11) { width: 104px; }


th, td {
  border-bottom: 1px solid #edf1f5;
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: #475467;
  font-weight: 700;
  background: #f8fafc;
}

td input, td select {
  padding: 7px 8px;
}

.input-table {
  width: auto;
  min-width: 520px;
  table-layout: fixed;
}

.input-table th,
.input-table td {
  padding: 6px 7px;
}

.input-table th:first-child,
.input-table td:first-child {
  width: 70px;
  font-weight: 700;
}

.input-table th:nth-child(2),
.input-table td:nth-child(2),
.input-table th:nth-child(4),
.input-table td:nth-child(4) {
  width: 70px;
}

.input-table th:nth-child(3),
.input-table td:nth-child(3) {
  width: 82px;
}

.input-table th:nth-child(5),
.input-table td:nth-child(5),
.input-table th:nth-child(6),
.input-table td:nth-child(6),
.input-table th:nth-child(7),
.input-table td:nth-child(7) {
  width: 92px;
}

.input-table .level-cell input {
  width: 38px;
  max-width: 38px;
  text-align: center;
}

.input-table [data-field="currentPoints"] {
  width: 50px;
  max-width: 50px;
  text-align: center;
}

.input-table [data-field],
.input-table [data-edit-field] {
  height: 30px;
  padding: 4px 6px;
  text-align: center;
}

.input-table [data-edit-field="currentLevel"],
.input-table [data-edit-field="targetLevel"] {
  width: 38px;
  max-width: 38px;
}

.input-table [data-edit-field="currentPoints"] {
  width: 50px;
  max-width: 50px;
}

.task-save-layout {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr);
  gap: 28px;
  align-items: start;
}

.task-save-actions {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 14px;
  padding-right: 12px;
}

.task-save-actions button {
  width: min(260px, 100%);
  padding: 15px 18px;
  font-size: 16px;
  font-weight: 800;
}

.task-save-actions .save-notice {
  width: min(300px, 100%);
  text-align: right;
  margin: 0;
}

.copy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.quote-copy-heading {
  align-items: flex-start;
}

.quote-save-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.quote-save-actions button {
  min-width: 132px;
  white-space: nowrap;
}

.save-notice {
  min-height: 22px;
  margin: -4px 0 12px;
  color: var(--success);
  font-size: 13px;
  font-weight: 650;
}

.save-notice[data-tone="error"] {
  color: var(--danger);
}

.copy-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.copy-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.copy-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dispatch-btn {
  padding: 7px 12px;
}

.dispatch-variables {
  display: grid;
  grid-template-columns: minmax(100px, 130px) minmax(160px, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.dispatch-variables label {
  color: var(--muted);
  font-size: 12px;
}

.dispatch-variables input {
  margin-top: 5px;
}

.dispatch-variables input[type="number"] {
  text-align: center;
}

.bot-settings-panel {
  margin-top: 16px;
}

.bot-settings-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) max-content;
  align-items: end;
  gap: 12px;
  margin-top: 16px;
}

.bot-status {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
}

.bot-status[data-state="ready"] {
  color: var(--success);
  border-color: #86efac;
  background: #f0fdf4;
}

.bot-status[data-state="waiting"] {
  color: #a16207;
  border-color: #facc15;
  background: #fefce8;
}

.bot-bind-tip {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.copy-heading label {
  display: block;
  font-weight: 650;
}

.copy-btn {
  padding: 7px 10px;
  white-space: nowrap;
  font-size: 13px;
}

.copy-box textarea {
  min-height: 112px;
}

.detail-copy-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 14px 0;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  margin: 12px 0 4px;
}

.detail-copy-grid textarea {
  width: 100%;
  white-space: pre-wrap;
}

.search-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.search-dialog-head h2 {
  margin-bottom: 5px;
}

.quote-search-results {
  display: grid;
  gap: 10px;
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 4px;
}

.quote-search-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.quote-search-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.quote-search-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.quote-search-card p {
  margin: 7px 0 0;
  line-height: 1.45;
}

.quote-search-card button {
  align-self: stretch;
}

.empty-result {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.quote-edit-body {
  max-height: 88vh;
  overflow-y: auto;
}

.quote-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.quote-edit-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.quote-edit-table {
  margin-bottom: 12px;
}

.quote-edit-table input {
  width: 100%;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px;
  gap: 12px;
  margin-bottom: 12px;
}

.record-filters {
  grid-template-columns: minmax(320px, 1fr) 150px 150px 150px minmax(360px, auto);
}

.record-search-box {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 104px;
  gap: 8px;
}

.status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.status-check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  white-space: nowrap;
}

.status-check input {
  width: auto;
  margin: 0;
}

.closed-by-readonly {
  color: var(--muted);
  font-weight: 650;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  background: #eef2f6;
  color: #344054;
}

.status-badge.paid { background: #e6f4ee; color: var(--success); }
.status-badge.unpaid { background: #fff3e7; color: var(--warning); }
.status-badge.done { background: #e8eef7; color: #174ea6; }

.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  width: 100%;
  justify-content: flex-start;
}

.row-actions button {
  padding: 6px 7px;
  background: #eef2f6;
}

.row-actions button.danger {
  background: #fee4e2;
  color: var(--danger);
}

.row-index {
  width: 52px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

td .inline-input {
  min-width: 0;
}

.records-table input,
.records-table select {
  width: 100%;
}

td .taobao-input {
  width: 100%;
}

td .customer-input {
  width: 100%;
}

td .money-input {
  width: 54px;
  min-width: 0;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.records-table td:nth-child(7) .money-input {
  width: 66px;
}

td .note-input {
  min-width: 0;
  width: 100%;
}

.order-text-cell {
  display: -webkit-box;
  width: 100%;
  min-height: 38px;
  max-height: 38px;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 19px;
  color: #1f2937;
}

.time-edit {
  display: flex;
  gap: 4px;
  align-items: center;
}

.time-edit input {
  min-width: 0;
  width: 100%;
  padding-left: 7px;
  padding-right: 7px;
}

.time-edit button {
  padding: 7px 7px;
  background: #eef2f6;
  white-space: nowrap;
}

#recordsBody td {
  padding: 8px 5px;
}

#recordsBody tr[data-row-id] {
  height: 58px;
}

#recordsBody td {
  height: 58px;
  vertical-align: middle;
}

#recordsBody input,
#recordsBody select,
#recordsBody button {
  min-height: 34px;
}


#recordsBody .row-actions {
  gap: 5px;
}

#recordsBody .row-actions select {
  min-width: 92px;
  width: 92px;
  padding-left: 7px;
  padding-right: 22px;
}

#recordsBody .row-actions button {
  width: 44px;
  min-width: 44px;
  padding: 6px 0;
  text-align: center;
}

#recordsBody tr[data-row-id] {
  cursor: default;
}

#recordsBody tr[data-row-id]:hover {
  background: #f9fbfd;
}

#recordsBody .row-actions select.status-active {
  border-color: #2563eb;
  background: #eaf2ff;
  color: #174ea6;
  font-weight: 800;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .12);
}

.records-summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #edf1f5;
}

.summary-item {
  background: #f8fafc;
  border: 1px solid #e4eaf0;
  border-radius: 6px;
  padding: 10px 12px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.summary-item strong {
  font-size: 17px;
  color: var(--text);
}

.summary-item.highlight {
  background: #ecfdf3;
  border-color: #abefc6;
}

.summary-item.highlight strong {
  color: var(--success);
}

.records-pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.records-pager button {
  min-width: 78px;
}

.records-pager button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

#settingsForm {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.settings-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(80px, 1fr));
  gap: 10px;
}

.settings-basic {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.season-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.season-task-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.season-mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.season-mode-tabs button {
  border: 1px solid transparent !important;
  border-radius: 6px;
  background: #fff !important;
  color: var(--text) !important;
  font-weight: 800;
  min-height: 40px;
}

.season-mode-tabs button:hover,
.season-mode-tabs button:focus,
.season-mode-tabs button:active {
  background: #e8eef8 !important;
  color: var(--text) !important;
}

.season-mode-tabs button.active {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .2);
}

.season-mode-tabs button.active:hover,
.season-mode-tabs button.active:focus,
.season-mode-tabs button.active:active {
  background: #1d4ed8 !important;
  color: #fff !important;
  border-color: #1d4ed8 !important;
}

.season-task-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #fff;
}

.season-task-block h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.season-stage-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.season-stage-cards label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.season-stage-cards strong {
  color: var(--blue);
}

.compact-season-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.season-package-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

.season-rule-grid,
.season-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.season-rule-card,
.season-preview-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
}

.season-rule-card h4,
.season-preview-card h4 {
  margin: 0 0 10px;
}

.season-rule-card label {
  margin-bottom: 8px;
}

.season-preview-card {
  display: grid;
  gap: 6px;
  color: var(--text);
}

.season-preview-card span {
  font-size: 13px;
}

.season-task-library {
  margin-top: 16px;
}

.season-task-library-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

.season-task-library-head h3 {
  margin: 0;
}

.season-task-library-head span {
  color: var(--muted);
  font-size: 13px;
}

.season-task-table {
  min-width: 980px;
}

.season-task-table th,
.season-task-table td {
  white-space: nowrap;
}

.season-task-table input,
.season-task-table select {
  min-width: 72px;
}

.season-stage-config-grid {
  display: grid;
  gap: 14px;
}

.season-stage-config {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.season-stage-config > summary,
.season-task-branch > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.season-stage-config > summary::-webkit-details-marker,
.season-task-branch > summary::-webkit-details-marker {
  display: none;
}

.season-stage-config > summary {
  padding: 12px 14px;
  background: #f8fafc;
  font-weight: 800;
}

.season-stage-config > summary strong,
.season-task-branch > summary strong {
  color: var(--muted);
  font-size: 13px;
}

.season-stage-config-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.season-stage-fields,
.season-side-group-fields {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.season-task-branch {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.season-task-branch > summary {
  padding: 10px 12px;
  background: #f8fafc;
  font-weight: 700;
}

.season-side-branches {
  display: grid;
  gap: 10px;
}

.season-side-group-fields {
  padding: 10px 12px 0;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 37px;
}

.checkbox-line input {
  width: auto;
  min-width: 0;
}

.compact-task-wrap {
  padding: 10px 12px 12px;
}

.compact-task-table {
  min-width: 720px;
}

.season-task-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 140px 140px;
  gap: 10px;
  margin-bottom: 10px;
}

.season-task-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.progress-stage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.progress-stage-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.progress-stage-card.muted {
  opacity: .55;
}

.progress-stage-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.progress-stage-card-head select {
  min-width: 112px;
}

.progress-stage-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.season-side-group-option {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.season-task-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: #f8fafc;
  margin: 0;
}

.season-task-main {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.season-task-meta {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.muted-empty {
  color: var(--muted);
  margin: 0;
}

.season-stage-picker {
  display: grid;
  grid-template-columns: repeat(5, max-content);
  gap: 10px;
  align-items: center;
  min-height: 40px;
}

.season-stage-picker span {
  color: var(--muted);
  font-size: 13px;
}

.season-stage-picker label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
}

.season-wide {
  grid-column: span 2;
}

.season-save-actions {
  margin-top: 14px;
}

.settings-group-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.settings-group-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.test-pricing-group {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.setting-toggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-weight: 800;
}

.setting-toggle input {
  width: auto;
}

.test-caps {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.test-segment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.test-stage-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.test-stage-card h4 {
  margin: 0 0 10px;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(760px, calc(100vw - 32px));
}

#quoteSearchDialog {
  width: min(940px, calc(100vw - 32px));
}

#quoteEditDialog {
  width: min(1120px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(15, 23, 42, .45);
}

.dialog-body {
  padding: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.detail-item {
  background: #f8fafc;
  border: 1px solid #edf1f5;
  border-radius: 6px;
  padding: 10px;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.dialog-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dialog-top-actions button {
  min-height: 40px;
  white-space: nowrap;
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px;
  }
  .logo { display: none; }
  .nav { width: auto; white-space: nowrap; margin: 0; }
  .content { padding: 16px; }
  .two-col, .copy-grid, #settingsForm, .task-save-layout, .quote-search-head, .quote-search-controls, .quote-edit-grid, .quote-edit-summary, .record-search-box, .season-form-grid, .season-stage-cards, .season-package-actions, .season-rule-grid, .season-preview-grid, .season-stage-fields, .season-side-group-fields, .progress-stage-grid, .season-task-tools, .season-task-picker, .season-mode-tabs { grid-template-columns: 1fr; }
  .task-save-actions {
    min-height: auto;
    align-items: stretch;
    padding-right: 0;
  }
  .task-save-actions button,
  .task-save-actions .save-notice {
    width: 100%;
    text-align: left;
  }
  .form-grid, .form-grid.compact, .settings-basic { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .season-stage-picker { grid-template-columns: repeat(2, max-content); }
  .season-wide { grid-column: span 1; }
  .records-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .page-title { flex-direction: column; }
  .top-save-actions {
    width: 100%;
    min-width: 0;
    grid-template-columns: 1fr 1fr;
  }
  .form-grid, .form-grid.compact, .settings-basic, .filters, .record-filters, .detail-grid, .season-stage-picker { grid-template-columns: 1fr; }
  .quote-search-card { grid-template-columns: 1fr; }
  .records-summary { grid-template-columns: 1fr; }
}

/* Record filter grouping and status colors */
.record-filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  background: #fbfcfe;
}
.record-filter-row {
  display: grid;
  gap: 10px;
  align-items: center;
}
.record-filter-row-main {
  grid-template-columns: minmax(360px, 1fr) minmax(180px, 240px);
}
.record-filter-row-meta {
  grid-template-columns: 150px 150px minmax(180px, 240px) minmax(360px, 1fr);
  padding-top: 10px;
  border-top: 1px solid #edf1f5;
}
.status-badge.paid,
.status-select.status-paid { background: #e7f8ef; color: #067647; border-color: #9ddfbd; }
.status-badge.unpaid,
.status-select.status-unpaid { background: #fff1f0; color: #b42318; border-color: #fecdca; }
.status-badge.active,
.status-select.status-active { background: #eaf2ff; color: #174ea6; border-color: #84adff; }
.status-badge.done,
.status-select.status-done { background: #edf7ed; color: #2e7d32; border-color: #a8d5a2; }
.status-badge.canceled,
.status-select.status-canceled { background: #f2f4f7; color: #667085; border-color: #d0d5dd; }
.status-select.status-default { background: #fff; color: #344054; border-color: #d7e0ea; }
.status-select {
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
@media (max-width: 900px) {
  .record-filter-row-main,
  .record-filter-row-meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .bot-settings-grid { grid-template-columns: 1fr; }
  .dispatch-variables { grid-template-columns: 1fr; }
  .copy-heading { align-items: flex-start; }
  .copy-actions { flex-wrap: wrap; justify-content: flex-end; }
}

.flow-duration { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 8px; border-radius: 6px; background: #f2f4f7; color: #475467; font-weight: 700; white-space: nowrap; }
.flow-timeline { margin: 14px 0; padding: 12px; border: 1px solid #e4eaf0; border-radius: 8px; background: #fbfcfe; }
.flow-timeline h3 { margin: 0 0 10px; font-size: 14px; }
.flow-steps { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 8px; }
.flow-step { padding: 8px; border-radius: 6px; background: #fff; border: 1px solid #edf1f5; }
.flow-step span { display: block; color: #667085; font-size: 12px; margin-bottom: 4px; }
.flow-step strong { font-size: 13px; color: #1f2937; }
.flow-timeline p { margin: 10px 0 0; color: #475467; font-weight: 800; }

.flow-row {
  display: grid;
  grid-template-columns: 110px minmax(160px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: #fff;
}

.flow-row span {
  color: #64748b;
  font-size: 12px;
}

.flow-row strong {
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.flow-row.is-done {
  border-color: #93c5fd;
  background: #eff6ff;
}

.flow-row.is-done strong {
  color: #1d4ed8;
}

.flow-row.flow-total {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.flow-row.flow-total strong {
  color: #15803d;
}


.flow-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.flow-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: #fff;
}

.flow-row span {
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
}

.flow-row strong {
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.quote-edit-flow .flow-steps {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.quote-edit-flow .flow-row.flow-total {
  grid-column: span 1;
}

.source-cell {
  display: grid;
  grid-template-columns: 74px 160px;
  gap: 8px;
  align-items: center;
}

.source-cell select,
.source-cell input {
  width: 100%;
}

.records-table .source-cell input {
  font-variant-numeric: tabular-nums;
}

.records-table .source-cell select {
  min-width: 74px;
}

.records-table .source-cell input {
  min-width: 0;
  width: 160px;
}


.delete-cell {
  text-align: center;
  padding-left: 8px;
  padding-right: 14px;
}

.delete-cell button {
  width: 56px;
  min-width: 56px;
  padding: 6px 0;
  background: #fee4e2;
  color: var(--danger);
}

.follow-select {
  width: 68px;
  min-width: 68px;
  padding-left: 7px;
  padding-right: 20px;
  font-weight: 800;
}
.follow-select.follow-pending { background: #fff7ed; color: #b45309; border-color: #fed7aa; }
.follow-select.follow-done { background: #ecfdf3; color: #067647; border-color: #a6f4c5; }
.follow-select.follow-alert { background: #fff1f3; color: #c01048; border-color: #fda4af; }

/* order records spacing tune */
.records-table th:nth-child(5),
.records-table td:nth-child(5),
.records-table.show-follow th:nth-child(6),
.records-table.show-follow td:nth-child(6) {
  text-align: center;
}

/* order records final column layout */
.records-table {
  width: max(100%, 1548px);
  min-width: 1548px;
}

.records-table.show-follow {
  width: max(100%, 1620px);
  min-width: 1620px;
}

.records-table th:nth-child(1),
.records-table td:nth-child(1) { width: 52px; }
.records-table th:nth-child(2),
.records-table td:nth-child(2) { width: 252px; }
.records-table th:nth-child(3),
.records-table td:nth-child(3) { width: 340px; white-space: normal; }
.records-table th:nth-child(4),
.records-table td:nth-child(4) { width: 170px; }
.records-table th:nth-child(5),
.records-table td:nth-child(5) { width: 0; }
.records-table th:nth-child(6),
.records-table td:nth-child(6) { width: 154px; text-align: center; }
.records-table th:nth-child(7),
.records-table td:nth-child(7) { width: 74px; }
.records-table th:nth-child(8),
.records-table td:nth-child(8) { width: 78px; }
.records-table th:nth-child(9),
.records-table td:nth-child(9) { width: 130px; }
.records-table th:nth-child(10),
.records-table td:nth-child(10) { width: 220px; }
.records-table th:nth-child(11),
.records-table td:nth-child(11) { width: 76px; }

.records-table.show-follow th:nth-child(5),
.records-table.show-follow td:nth-child(5) { width: 78px; }
.records-table.show-follow th:nth-child(6),
.records-table.show-follow td:nth-child(6) { width: 154px; text-align: center; }
.records-table.show-follow th:nth-child(7),
.records-table.show-follow td:nth-child(7) { width: 74px; }
.records-table.show-follow th:nth-child(8),
.records-table.show-follow td:nth-child(8) { width: 78px; }
.records-table.show-follow th:nth-child(9),
.records-table.show-follow td:nth-child(9) { width: 130px; }
.records-table.show-follow th:nth-child(10),
.records-table.show-follow td:nth-child(10) { width: 220px; }
.records-table.show-follow th:nth-child(11),
.records-table.show-follow td:nth-child(11) { width: 76px; }

.flow-duration {
  max-width: 100%;
  justify-content: center;
}
/* end order records final column layout */
