:root {
  color-scheme: dark;
  --bg: #121614;
  --panel: #1c2420;
  --panel-alt: #24302a;
  --border: #334038;
  --text: #f6f3ec;
  --muted: #a7b0a8;
  --primary: #0c6e46;
  --primary-hover: #095838;
  --success: #047857;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --topbar: #161c19;
  --chat-bg: #171e1b;
  --chat-bar: #1e2823;
  --draft-bg: #24281c;
  --input-bg: #121614;
  --inset: #18211c;
  --hover: #2c3a33;
  --toast-bg: #101410;
  --warn-text: #fde68a;
  --ok-text: #a7f3d0;
  --link: #86efac;
  --gold: #fbbf24;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 12px 28px rgba(0, 0, 0, 0.18);
  --chat-width: 560px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3efe6;
  --panel: #fffdf8;
  --panel-alt: #f7f3ea;
  --border: #e4dccf;
  --text: #1c1915;
  --muted: #6d655c;
  --topbar: #fffdf8;
  --chat-bg: #fbf8f2;
  --chat-bar: #f4efe4;
  --draft-bg: #fff8e8;
  --input-bg: #fffdf8;
  --inset: #f7f3ea;
  --hover: #efe8db;
  --toast-bg: #1c1915;
  --warn-text: #92400e;
  --ok-text: #065f46;
  --link: #0c6e46;
  --gold: #b45309;
  --shadow: 0 1px 2px rgba(70, 50, 20, 0.04), 0 12px 32px rgba(70, 50, 20, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Microsoft YaHei", "Noto Sans SC", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.55;
}

header.topbar {
  background: var(--topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  flex-shrink: 0;
  min-height: 56px;
}

.page-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.nav-btn {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 9px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-btn:hover { background: var(--hover); }

.nav-btn.active {
  background: transparent;
  border-bottom-color: var(--link);
  color: var(--link);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: block;
  flex-shrink: 0;
  border-radius: 10px;
}
.brand-name { display: flex; flex-direction: column; line-height: 1; }
.brand-name h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.brand-name span {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.badge.prod {
  border-color: var(--success);
  color: #34d399;
}

.badge.demo {
  border-color: var(--warning);
  color: var(--gold);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.menu-wrap { position: relative; }

.settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  z-index: 40;
}

.settings-menu-head { padding: 8px 10px 10px; }
.settings-menu-title { font-weight: 700; font-size: 16.5px; }
.settings-menu-sub { margin-top: 2px; font-size: 15px; color: var(--muted); }
.settings-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

.settings-menu-item {
  color: var(--text);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: transparent;
  border-color: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 500;
}

.settings-menu-item:hover { background: var(--hover); }
.settings-menu-aside { color: var(--muted); font-size: 15px; font-weight: 500; }

.account-chip {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--primary);
  color: #f6f1e6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.account-menu { width: min(280px, calc(100vw - 24px)); }
.account-menu .settings-menu.is-inline {
  position: static;
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
.account-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
}
.account-menu-head .settings-menu-title { overflow-wrap: anywhere; }

button, select, input, textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  max-width: 100%;
}

input, select, textarea { min-width: 0; }

button:focus-visible, summary:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 3px;
}

button {
  cursor: pointer;
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  transition: background 0.15s;
}

button:hover {
  background: var(--primary-hover);
}

button.secondary {
  background: var(--panel-alt);
  border-color: var(--border);
  color: var(--text);
}

button.secondary:hover {
  background: var(--hover);
}

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

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6px minmax(0, var(--chat-width));
  overflow: hidden;
}
.dashboard-pane { order: 1; }
.chat-resizer { order: 2; }
.chat-pane { order: 3; }

.chat-resizer {
  cursor: col-resize;
  background: var(--border);
}

.chat-resizer:hover,
.chat-resizer.dragging { background: var(--primary); }

/* Right pane: Chat & Draft Confirmation Gate */
.chat-pane {
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.privacy-bar {
  padding: 10px 14px;
  background: var(--chat-bar);
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.privacy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; }
.login-card h2 { margin: 18px 0 8px; font-size: 16px; }
.login-card p { color: var(--muted); margin: 0 0 14px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 14px; }
.login-card input {
  font: inherit;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}
.login-error { color: var(--danger); min-height: 1.2em; }
.chat-thread {
  flex: 1;
  min-height: 0;
  display: flex;
}
.chat-messages {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-minimap {
  position: relative;
  width: 22px;
  flex: 0 0 22px;
  border-left: 1px solid var(--primary);
  background: transparent;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
}
.chat-minimap-bar {
  position: absolute;
  left: 4px;
  height: 1px;
  border-radius: 1px;
  background: #c5c8cc;
  opacity: 0.7;
  pointer-events: none;
}
:root[data-theme="dark"] .chat-minimap-bar { background: #8b948f; }
.chat-minimap-bar.active { background: #1c1915; opacity: 1; }
:root[data-theme="dark"] .chat-minimap-bar.active { background: #f4efe4; }

.msg {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 16.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  max-width: 92%;
  overflow-wrap: anywhere;
}

.msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
}

.msg.pending {
  opacity: 0.72;
  font-style: italic;
}

.msg-meta {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.drafts-drawer {
  max-height: 44%;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  background: var(--draft-bg);
  padding: 10px 14px;
}

.draft-card {
  background: var(--panel);
  border: 1px solid var(--warning);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  font-size: 15.5px;
}

.draft-card h4 {
  color: var(--gold);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.draft-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.draft-fields label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 14.5px;
  color: var(--muted);
}

.draft-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--input-bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-templates {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-templates button {
  font-size: 14px;
  padding: 3px 7px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  resize: vertical;
  height: 112px;
  min-height: 112px;
  max-height: 280px;
  line-height: 1.5;
}

/* Right pane: Dashboard */
.dashboard-pane {
  min-width: 0;
  min-height: 0;
  container: dashboard / inline-size;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page { display: none; flex-direction: column; gap: 18px; min-width: 0; }
.page.active { display: flex; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.kpi-card .label {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-card .value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.kpi-card .sub {
  font-size: 14.5px;
  color: var(--muted);
  margin-top: 5px;
}

.section-card {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

details.section-card > summary {
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.section-header h3 {
  font-size: 18px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 540px), 1fr));
  gap: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  white-space: normal;
}

.alert-box {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15.5px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
}

.alert-box.warn {
  border-color: var(--warning);
  color: var(--warn-text);
  background: rgba(245, 158, 11, 0.12);
}

.alert-box.ok {
  border-color: var(--success);
  color: var(--ok-text);
  background: rgba(16, 185, 129, 0.12);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  background: var(--inset);
  border-radius: 8px;
  margin-bottom: 12px;
}

.inline-form label {
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 14.5px;
  color: var(--muted);
}
.inline-form label[hidden] { display: none; }
#newFacilityFields, [data-new-facility] {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}
#newFacilityFields[hidden], [data-new-facility][hidden] { display: none; }

.inline-form input, .inline-form select, .inline-form textarea,
.form-grid input, .form-grid select, .form-grid textarea,
.draft-fields input, .draft-fields select, .draft-fields textarea {
  width: 100%;
}

.two-col > *, .form-grid > *, .draft-fields > *, .kpi-grid > * {
  min-width: 0;
}

.template-info,
.mode-note {
  width: 100%;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.template-info a {
  color: var(--link);
}

.template-info .unofficial {
  color: var(--gold);
}

.mode-note {
  color: var(--warn-text);
  border-color: rgba(245, 158, 11, 0.4);
}

.debt-preview {
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  font-size: 15px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
}

.debt-preview table td,
.debt-preview table th {
  padding: 4px 6px;
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-alt);
  font-size: 15.5px;
}

.profile-item.active {
  border-color: var(--success);
}

.profile-item .meta {
  color: var(--muted);
  font-size: 14.5px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 6px;
  background: var(--panel-alt);
}

.task-item.done span {
  text-decoration: line-through;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 560px;
  max-width: 95vw;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
}

.modal h3 {
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 15px;
  color: var(--muted);
}

.alert-box.danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.repay-short {
  font-size: 15px;
  color: #fca5a5;
  margin: 4px 0;
}

#fundingAlerts .alert-box {
  margin-bottom: 10px;
  line-height: 1.6;
}

.debt-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.debt-summary-item {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.debt-summary-label {
  font-size: 15px;
  color: var(--muted);
}

.debt-summary-value {
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 2px;
}

.debt-summary-dim {
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
}

.debt-summary-sub {
  font-size: 14.5px;
  color: var(--muted);
}

.month-remain { margin-top: 8px; font-size: 15px; color: var(--muted); }
.month-remain strong { display: block; font-size: 26px; font-weight: 700; line-height: 1.2; color: var(--text); }
.month-remain.due strong { color: var(--gold); }

.debt-summary-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
  margin-top: 6px;
}

.debt-summary-bar span {
  display: block;
  height: 100%;
  background: #10b981;
}

.repay-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
  gap: 10px;
}

.repay-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.repay-card.overdue {
  border-left-color: var(--danger);
}

.repay-card.today,
.repay-card.soon {
  border-left-color: var(--warning);
}

.repay-card.week {
  border-left-color: var(--primary);
}

.repay-card-head {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  color: var(--muted);
}

.repay-card.overdue .repay-urgency {
  color: #fca5a5;
  font-weight: 600;
}

.repay-card.today .repay-urgency,
.repay-card.soon .repay-urgency {
  color: var(--gold);
  font-weight: 600;
}

.repay-name {
  font-weight: 600;
  font-size: 16.5px;
}

.repay-period {
  font-weight: 400;
  font-size: 15px;
  color: var(--muted);
}

.repay-amount {
  font-size: 22px;
  font-weight: 700;
}

.repay-split {
  font-size: 15px;
  color: var(--muted);
}

.repay-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.repay-actions select {
  flex: 1 1 100%;
}

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--toast-bg);
  border: 1px solid var(--primary);
  color: #f8fafc;
  font-size: 16px;
  display: none;
  z-index: 100;
}

/* Multi-currency, FX, transfers, monthly cashflow */
.fx-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 15.5px; }
.fx-title { font-weight: 600; }
.fx-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-alt); }
.fx-chip.missing { border-color: #f59e0b; color: var(--gold); }
.fx-meta { color: var(--muted); font-size: 14px; }
.fx-chip button, #fxRefreshBtn { padding: 1px 6px; font-size: 14px; }
.acc-tag { display: inline-block; padding: 0 5px; border-radius: 4px; font-size: 13.5px; background: var(--hover); color: var(--text); }
.cashflow-totals { display: flex; flex-wrap: wrap; gap: 14px; font-size: 16px; margin-bottom: 8px; }
.cashflow-cats { margin-top: 8px; font-size: 15px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cat-chip { padding: 1px 7px; border-radius: 10px; background: var(--panel-alt); border: 1px solid var(--border); color: var(--text); }

/* Repayment cards grouped by bank */
#repayCards { display: flex; flex-direction: column; gap: 10px; }
.bank-group { border: 1px solid var(--border); border-left: 4px solid var(--bank-color); border-radius: 10px; background: color-mix(in srgb, var(--bank-color) 6%, transparent); }
.bank-group-head { width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 9px 12px; background: color-mix(in srgb, var(--bank-color) 14%, transparent); border: 0; border-radius: 8px 8px 0 0; color: var(--text); text-align: left; cursor: pointer; font-size: 16px; }
.bank-group.collapsed .bank-group-head { border-radius: 8px; }
.bank-group-head:hover { background: color-mix(in srgb, var(--bank-color) 22%, transparent); }
.bank-caret { width: 12px; color: var(--muted); }
.bank-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bank-color); }
.bank-name { font-weight: 700; font-size: 17px; }
.bank-meta { color: var(--muted); }
.bank-meta strong { color: var(--text); }
.bank-next { margin-left: auto; color: var(--muted); font-size: 15px; }
.bank-next.repay-urgency-overdue { color: #fca5a5; font-weight: 600; }
.bank-next.repay-urgency-today, .bank-next.repay-urgency-soon { color: var(--gold); font-weight: 600; }
.bank-short { color: #fca5a5; font-size: 15px; font-weight: 600; }
.bank-group-body { padding: 10px; }
.bank-group.collapsed .bank-group-body { display: none; }
.bank-group .repay-card { border-top: 2px solid color-mix(in srgb, var(--bank-color) 60%, transparent); }

/* Credit cards */
.stk-table td { vertical-align: top; }
.broker-card { margin: 10px 0; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.broker-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.broker-card-head h4 { margin: 0; font-size: 18px; }
.broker-split { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 12px; }
.broker-part { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--panel-alt); }
.broker-part .label { color: var(--muted); font-size: 15px; }
.broker-part .value { font-size: 22px; font-weight: 700; margin: 4px 0 8px; }
.holding-line { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 6px 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.holding-line .stk-actions, .holding-trades { grid-column: 1 / -1; }
@media (max-width: 800px) { .broker-split { grid-template-columns: 1fr; } }
.stk-up { color: #f87171; }
.stk-down { color: #34d399; }
.stk-closed { opacity: 0.55; }
.stk-broker { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 8px; font-size: 14px; background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.stk-subtotal td { border-top: 1px dashed var(--border); background: rgba(59, 130, 246, 0.06); }
.stk-actions { white-space: nowrap; }
.stk-actions .cc-mini { margin: 0 2px 2px 0; }
.stk-details > td { background: var(--panel-alt); }
.cc-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 12px; margin-top: 10px; }
.cc-card { min-width: 0; overflow-x: auto; border: 1px solid var(--border); border-top: 4px solid var(--bank-color); border-radius: 10px; padding: 10px 12px; background: linear-gradient(160deg, color-mix(in srgb, var(--bank-color) 16%, var(--panel-alt)) 0%, var(--panel-alt) 55%); font-size: 15.5px; display: flex; flex-direction: column; gap: 6px; }
.cc-head { display: flex; align-items: center; gap: 8px; }
.cc-name { font-weight: 700; font-size: 17px; }
.cc-last4 { color: var(--muted); font-weight: 500; font-size: 15px; }
.cc-owed { margin-left: auto; }
.cc-owed strong { font-size: 19px; }
.cc-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.cc-bar span { display: block; height: 100%; background: var(--bank-color); }
.cc-bar.warn span { background: #f59e0b; }
.cc-bar.danger span { background: #ef4444; }
.cc-sub, .cc-dim { color: var(--muted); font-size: 15px; }
.cc-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; justify-content: space-between; }
.cc-alert { color: #fca5a5; font-weight: 600; }
.cc-badge { padding: 0 6px; border-radius: 4px; font-size: 14px; background: var(--hover); }
.cc-badge.unpaid { background: color-mix(in srgb, #f59e0b 25%, transparent); color: var(--gold); }
.cc-badge.partial { background: color-mix(in srgb, #3b82f6 25%, transparent); color: #93c5fd; }
.cc-badge.paid { background: color-mix(in srgb, #10b981 25%, transparent); color: #6ee7b7; }
.cc-mini { padding: 2px 7px; font-size: 14px; }
.cc-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; align-items: end; }
.cc-quick label { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 14px; color: var(--muted); }
.cc-quick input, .cc-quick select, .cc-quick button { width: 100%; min-width: 0; box-sizing: border-box; padding: 6px 8px; font-size: 16px; }
.cc-quick button, .cc-quick .cc-span, .cc-fx-note { grid-column: 1 / -1; }
.cc-fx-note { margin: 0; font-size: 14px; color: var(--muted); }
.cc-edit-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.cc-edit-actions button { width: auto; }
.bill-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.bill-amt { font-weight: 700; }
.bill-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
@media (max-width: 640px) {
  .cc-quick, .bill-row { grid-template-columns: 1fr; }
  .cc-quick button { grid-column: auto; }
}
.cc-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.cc-details table { font-size: 14.5px; }

.chart-ranges { display: flex; gap: 6px; }
.chart-ranges button { padding: 4px 10px; }
.chart-ranges button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chart-series { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chart-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--inset);
  font-size: 16px;
  cursor: pointer;
}
.chart-toggle input { accent-color: var(--primary); }
.chart-swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.balance-chart { position: relative; }
#balanceChart svg { width: 100%; height: auto; display: block; }
.chart-tip {
  position: absolute;
  z-index: 2;
  min-width: 160px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--toast-bg);
  color: #f8fafc;
  font-size: 15px;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.chart-tip strong { font-variant-numeric: tabular-nums; }

.kpi-card { box-shadow: var(--shadow); }
.brand h1 { letter-spacing: -0.02em; }
.nav-btn.active { box-shadow: none; }

.today-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  padding: 22px 22px 18px;
  border-radius: 18px;
  background:
    radial-gradient(1200px 180px at 0% 0%, rgba(12, 110, 70, 0.18), transparent 55%),
    var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.today-hero .eyebrow {
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--link);
  font-weight: 700;
}
.today-hero h2 {
  margin-top: 6px;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -0.03em;
  font-weight: 700;
}
.today-hero p { margin-top: 8px; color: var(--muted); max-width: 68ch; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fine-print { color: var(--muted); font-size: 16px; margin-top: 6px; }
#chatExpandBtn { display: none; }
body.chat-collapsed { --chat-width: 0px; }
body.chat-collapsed .chat-pane,
body.chat-collapsed .chat-resizer { display: none; }
body.chat-collapsed .workspace { grid-template-columns: 1fr; }
body.chat-collapsed #chatExpandBtn { display: inline-flex; }

@media (max-width: 860px) {
  header.topbar { flex-wrap: wrap; gap: 8px 14px; }
  header.topbar .brand, header.topbar .topbar-controls { flex-shrink: 0; }
  .page-nav { order: 3; flex: 1 0 100%; width: 100%; }
  .workspace { grid-template-columns: 1fr; }
  .chat-resizer { display: none; }
  .chat-pane { display: none; }
  body:not(.chat-collapsed) .chat-pane {
    display: flex;
    position: fixed;
    z-index: 30;
    inset: calc(var(--topbar-height, 106px) + 8px) 10px 10px;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
  }
  #chatExpandBtn { display: inline-flex; }
  .today-hero { flex-direction: column; align-items: flex-start; }
  .today-hero h2 { font-size: 26px; }
  .cc-list { grid-template-columns: 1fr; }
  .dashboard-pane { padding: 14px; }
}

/* Account records use the full dashboard width, including with the assistant open. */
.accounts-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 4px 2px 2px;
}

.accounts-page-header h2 {
  font-size: 30px;
  line-height: 1.3;
  letter-spacing: -0.03em;
}

.accounts-page-header > div:first-child {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  min-width: 0;
  gap: 6px 24px;
}
.accounts-page-header .fine-print { margin-top: 0; }

.accounts-toolbar,
.form-panel-actions,
.ledger-pagination > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.accounts-toolbar button { min-height: 42px; }
.accounts-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.accounts-card, .ledger-card, .transfer-card { padding: 12px 18px 10px; }
.accounts-card .section-header h3,
.ledger-card .section-header h3,
.transfer-card .section-header h3 { font-size: 20px; line-height: 1.4; }
.accounts-card .section-header,
.ledger-card .section-header,
.transfer-card .section-header { margin-bottom: 10px; }
.section-header .fine-print, .ledger-pagination .fine-print { margin-top: 0; }

.account-form-panel {
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.accounts-card .account-form-panel:not([open]),
.ledger-card .account-form-panel:not([open]) { display: none; }

.account-form-panel > summary {
  width: fit-content;
  max-width: 100%;
  color: var(--link);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.account-form-panel[open] > summary { margin-bottom: 14px; }
.account-form-panel > p { margin: 0 0 14px; }
.account-form-panel .inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  align-items: end;
  gap: 14px 16px;
  margin: 0;
  padding: 0;
  background: transparent;
}

.account-form-panel .inline-form label { font-size: 16px; gap: 6px; }
.account-form-panel .inline-form input,
.account-form-panel .inline-form select { min-height: 44px; background: var(--panel); }
.account-form-panel .form-panel-actions,
.account-form-panel .inline-form > .fine-print { grid-column: 1 / -1; }
.account-form-panel .form-panel-actions { justify-content: flex-end; padding-top: 2px; }
.account-form-panel .inline-form > .fine-print { margin: 0; }
.table-scroll { min-width: 0; max-width: 100%; overflow-x: auto; }
.responsive-record-table { table-layout: fixed; font-size: 16px; }
.responsive-record-table th, .responsive-record-table td {
  padding: 6px 12px;
  line-height: 1.4;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
}

.responsive-record-table th {
  padding-top: 8px;
  padding-bottom: 8px;
  background: var(--panel-alt);
  font-size: 15px;
}

.responsive-record-table th:first-child { border-radius: 7px 0 0 7px; }
.responsive-record-table th:last-child { border-radius: 0 7px 7px 0; }
.responsive-record-table tbody tr:last-child td { border-bottom: 0; }
.adaptive-table:not(.is-records) tbody tr:hover > td,
.responsive-record-table:not(.is-records) tbody tr:hover > td {
  background: color-mix(in srgb, var(--primary) 9%, var(--panel));
}
.account-table th:nth-child(1) { width: 36%; }
.account-table th:nth-child(2) { width: 25%; }
.account-table th:nth-child(3) { width: 22%; }
.account-table th:nth-child(4) { width: 17%; }
.ledger-table th:nth-child(1) { width: 13%; }
.ledger-table th:nth-child(2) { width: 25%; }
.ledger-table th:nth-child(3) { width: 16%; }
.ledger-table th:nth-child(4) { width: 15%; }
.ledger-table th:nth-child(5) { width: 18%; }
.ledger-table th:nth-child(6) { width: 13%; }
.transfer-table th:nth-child(1) { width: 13%; }
.transfer-table th:nth-child(2) { width: 12%; }
.transfer-table th:nth-child(3), .transfer-table th:nth-child(4) { width: 23%; }
.transfer-table th:nth-child(5) { width: 14%; }
.transfer-table th:nth-child(6) { width: 15%; }

.account-name { font-weight: 600; font-size: 17px; }
.cell-secondary { margin-top: 3px; color: var(--muted); font-size: 14.5px; font-weight: 400; line-height: 1.4; }
.account-purpose { font-size: 15px; line-height: 1.6; }
.responsive-record-table .amount-cell { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.responsive-record-table td.amount-cell { white-space: nowrap; overflow-wrap: normal; }
.responsive-record-table .amount-cell .cell-secondary { white-space: normal; }
.responsive-record-table .actions-cell { text-align: right; }
.money-in { color: var(--link); }
.money-out { color: #fda4a4; }
:root[data-theme="light"] .money-out { color: #a33f2a; }
.entry-type {
  display: inline-block;
  max-width: 100%;
  padding: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
}
.entry-status { display: block; margin-top: 4px; color: var(--muted); font-size: 14.5px; font-weight: 400; }
.ledger-table td { padding-top: 5px; padding-bottom: 5px; line-height: 1.3; }
.ledger-table .cell-secondary { margin-top: 2px; font-size: 14px; line-height: 1.3; }
.ledger-table .entry-type { line-height: 1.3; }
.record-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: 6px; }
.record-actions button, .row-more > summary {
  padding: 5px 9px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
  white-space: nowrap;
}
.record-actions > .secondary { background: transparent; color: var(--link); }
.record-actions > .secondary:hover { background: var(--hover); }
.row-more { min-width: 0; }
.row-more > summary { cursor: pointer; background: transparent; color: var(--link); list-style: none; }
.row-more > summary::-webkit-details-marker { display: none; }
.row-more > summary:hover { background: var(--hover); color: var(--text); }
.row-more[open] > summary { margin-bottom: 6px; }
.row-more button { display: block; }
.ledger-toolbar { margin: 0 0 16px; }
.ledger-heading-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px 16px; min-width: 0; max-width: 100%; }
.ledger-heading-controls .ledger-toolbar { margin: 0; }
.ledger-heading-controls .fine-print { margin: 0; white-space: nowrap; }
.ledger-filters { display: flex; flex-wrap: wrap; gap: 10px; }
.ledger-filters select { min-width: 150px; max-width: 100%; min-height: 42px; background: var(--panel); }
.ledger-pagination { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
button:disabled { opacity: 0.45; cursor: default; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@container dashboard (max-width: 760px) {
  .accounts-page-header { align-items: flex-start; }
  .accounts-page-header h2 { font-size: 26px; }
  .accounts-toolbar { width: 100%; }
  .ledger-heading-controls { width: 100%; justify-content: space-between; }
  .ledger-heading-controls .ledger-filters { flex: 1 1 100%; }
  .accounts-card, .ledger-card, .transfer-card { padding: 18px 16px 14px; }
  .ledger-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); }
  .ledger-filters select { width: 100%; min-width: 0; }
  .responsive-record-table { display: block; }
  .responsive-record-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .responsive-record-table tbody { display: grid; gap: 12px; }
  .responsive-record-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 14px 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  }
  .responsive-record-table tbody tr:hover {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
    background: color-mix(in srgb, var(--primary) 9%, var(--panel));
    box-shadow: 0 8px 22px color-mix(in srgb, var(--text) 12%, transparent);
  }
  .responsive-record-table td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .responsive-record-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
  }
  .responsive-record-table td.amount-cell { text-align: right; }
  .responsive-record-table td.actions-cell { text-align: right; }
  .responsive-record-table td[colspan] { grid-column: 1 / -1; white-space: normal; }
  .responsive-record-table td[colspan]::before { display: none; }
  .responsive-record-table .record-actions button,
  .responsive-record-table .row-more > summary { min-height: 40px; padding: 7px 10px; }
  .account-table td:nth-child(1) { order: 0; }
  .account-table td:nth-child(2) { order: 1; }
  .account-table td:nth-child(3) { order: 2; }
  .account-table td:nth-child(4) { order: 3; }
  .ledger-table td:nth-child(2) { order: 0; }
  .ledger-table td:nth-child(5) { order: 1; }
  .ledger-table td:nth-child(3) { order: 2; }
  .ledger-table td:nth-child(1) { order: 3; text-align: right; }
  .ledger-table td:nth-child(4) { order: 4; }
  .ledger-table td:nth-child(6) { order: 5; }
  .transfer-table td:nth-child(3) { order: 0; }
  .transfer-table td:nth-child(4) { order: 1; }
  .transfer-table td:nth-child(1) { order: 2; }
  .transfer-table td:nth-child(2) { order: 3; }
  .transfer-table td:nth-child(5) { order: 4; text-align: left; }
  .transfer-table td:nth-child(6) { order: 5; }
  .section-header > div { min-width: 0; max-width: 100%; flex-wrap: wrap; }
  .inline-form > label { flex: 1 1 100%; }
}

@container dashboard (max-width: 420px) {
  .accounts-card, .ledger-card, .transfer-card { padding: 16px 12px 12px; }
  .responsive-record-table tbody tr { padding: 12px; gap: 12px; }
  .account-form-panel .inline-form { grid-template-columns: minmax(0, 1fr); }
  .account-form-panel { padding: 10px; }
  .accounts-toolbar button { flex: 1 1 auto; padding-left: 10px; padding-right: 10px; }
  .ledger-pagination > div { width: 100%; justify-content: flex-end; }
}

@container dashboard (max-width: 340px) {
  .responsive-record-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  .responsive-record-table td.amount-cell,
  .responsive-record-table td.actions-cell,
  .ledger-table td:nth-child(1) { text-align: left; }
  .responsive-record-table .record-actions { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .form-grid, .draft-fields { grid-template-columns: minmax(0, 1fr); }
  .form-grid > *, .draft-fields > * { grid-column: 1 / -1 !important; }
  .modal { padding: 16px; }
  .chat-input-row { flex-wrap: wrap; }
  .chat-input-row textarea { flex-basis: 100%; }
}

/* Whole-app layout: calm surfaces, optional editors, and records sized to their pane. */
body { font-size: 16px; }
.dashboard-pane { scroll-behavior: smooth; }
.page { min-width: 0; }
.accounts-page-header > div:first-child { display: block; }
.accounts-page-header h2 { font-size: 28px; }
.accounts-page-header .fine-print { margin-top: 5px; max-width: 72ch; }
.section-card { padding: 20px; }
.section-header h3 { font-size: 20px; line-height: 1.4; }
.section-header .fine-print { max-width: 65ch; font-size: 14px; }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.kpi-card { padding: 18px 20px; box-shadow: none; }
.kpi-card .value { font-size: clamp(26px, 3vw, 32px); overflow-wrap: anywhere; }
.debt-summary-item { min-width: 0; padding: 14px 16px; }
.debt-summary-value { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.editor-panel, #addCardBox, #addStockBox {
  margin: 14px 0; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel-alt); scroll-margin-top: 16px;
}
.editor-panel > summary, #addCardBox > summary, #addStockBox > summary,
.cc-entry > summary, .strategy-card summary, .schedule-cell summary {
  cursor: pointer; color: var(--link); font-size: 15px; font-weight: 600;
}
.editor-panel[open] > summary, .cc-entry[open] > summary { margin-bottom: 14px; }
.inline-form { gap: 14px; padding: 14px; }
.editor-panel .inline-form, #addCardForm, #stockForm {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  align-items: end; margin: 0; padding: 8px 0 0; background: transparent;
}
.editor-panel .inline-form > div, .editor-panel .inline-form > label[style*="100%"],
.editor-panel .mode-note, .editor-panel .template-info { grid-column: 1 / -1; }
.editor-panel .inline-form > div { flex-wrap: wrap; }
.editor-panel input, .editor-panel select, #addCardForm input, #addCardForm select,
#stockForm input, #stockForm select { background: var(--panel); min-height: 44px; }
.editor-panel button[type="submit"] { min-height: 44px; }
.loan-editors { display: grid; gap: 0; margin-bottom: 16px; }
.life-stack { display: grid; gap: 20px; }
.plan-card { margin-top: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-alt); }
.plan-heading, .task-item { display: flex; gap: 12px; flex-wrap: wrap; }
.plan-heading { justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.plan-heading > div, .task-item > div { min-width: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.task-item > span { flex: 1 1 240px; min-width: 0; }
.task-item button { min-height: 36px; }
.cc-list { gap: 16px; align-items: start; }
.cc-card { overflow: visible; background: var(--panel); border-top-width: 3px; padding: 18px; gap: 12px; }
.cc-card.details-open { grid-column: 1 / -1; }
.cc-head { flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.cc-name { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.cc-owed { margin-left: 0; font-variant-numeric: tabular-nums; }
.cc-sub, .cc-dim { font-size: 14px; }
.cc-row { gap: 8px 16px; }
.cc-entry { border-top: 1px solid var(--border); padding-top: 12px; }
.cc-entry > summary { padding: 4px 0; }
.cc-quick { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); padding-top: 6px; }
.cc-quick input, .cc-quick select, .cc-quick button { min-height: 44px; }
.cc-actions { gap: 8px; }
.cc-mini { padding: 5px 9px; min-height: 36px; line-height: 1.5; }
.cc-details { padding-top: 12px; border-top: 1px solid var(--border); }
.cc-details .cc-dim { margin-bottom: 10px !important; }
.cc-details table + .cc-dim { margin-top: 24px !important; }
.cc-badge.paid { color: var(--ok-text); }
.cc-alert { color: var(--danger); }
.stk-actions { white-space: normal; }
.stk-broker { background: var(--hover); color: var(--link); margin: 4px 0; }
:root[data-theme="light"] .stk-up { color: #b42332; }
:root[data-theme="light"] .stk-down { color: #08734a; }
.chart-ranges { flex-wrap: wrap; }
#balanceChart svg { max-height: 340px; }
.chart-toggle { max-width: 100%; font-size: 14px; white-space: normal; overflow-wrap: anywhere; }
.chart-toggle input, .chart-swatch { flex-shrink: 0; }
.bank-group-head { overflow-wrap: anywhere; }
.bank-meta, .bank-next { min-width: 0; }
.bill-row > * { min-width: 0; overflow-wrap: anywhere; }
.fx-chip { flex-wrap: wrap; max-width: 100%; }
.simulator-header { gap: 16px; margin-bottom: 16px; }
.simulator-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.simulator-controls label { font-size: 14px; color: var(--muted); }
.simulation-assumptions:empty { display: none; }
.simulation-assumptions { padding: 12px 14px; margin-bottom: 14px; background: var(--draft-bg); color: var(--warn-text); border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.simulation-assumptions summary { cursor: pointer; }
.simulation-assumptions ul { padding-left: 20px; margin-top: 10px; }
.simulation-assumptions li + li { margin-top: 8px; }
.strategy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.strategy-card { border: 1px solid var(--border); border-radius: 10px; padding: 18px; background: var(--panel-alt); min-width: 0; }
.strategy-card h4 { font-size: 16px; }
.strategy-metrics { display: flex; flex-wrap: wrap; gap: 18px 30px; margin: 16px 0; }
.strategy-metrics span { display: block; font-size: 14px; color: var(--muted); }
.strategy-metrics strong { font-size: 22px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.strategy-card ol { padding-left: 22px; margin-top: 12px; }
.strategy-card li { padding: 6px 0; font-size: 14px; }
.strategy-card li span + span { display: block; color: var(--muted); }
.strategy-conclusion { margin-top: 14px; color: var(--muted); font-size: 14px; }
.strategy-conclusion strong { color: var(--link); }
.schedule-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.adaptive-table { table-layout: fixed; font-size: 15px; }
.adaptive-table th, .adaptive-table td { white-space: normal; overflow-wrap: anywhere; padding: 12px 10px; vertical-align: top; }
.adaptive-table th { background: var(--panel-alt); font-size: 14px; }
.adaptive-table td { font-variant-numeric: tabular-nums; }
.adaptive-table td button { margin: 2px; }
.adaptive-table .record-actions { justify-content: flex-start; }
.loan-table th:first-child { width: 27%; }
.loan-table th:nth-child(2) { width: 13%; }
.loan-table th:nth-child(3) { width: 18%; }
.loan-table th:nth-child(4) { width: 15%; }
.loan-table th:nth-child(5) { width: 17%; }
.loan-table th:last-child { width: 10%; }
.adaptive-table.is-records { display: block; width: 100%; }
.adaptive-table.is-records > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.adaptive-table.is-records > tbody { display: grid; gap: 12px; }
.adaptive-table.is-records > tbody > tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 20px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; }
.adaptive-table.is-records > tbody > tr:hover {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: color-mix(in srgb, var(--primary) 9%, var(--panel));
  box-shadow: 0 8px 22px color-mix(in srgb, var(--text) 12%, transparent);
}
.cc-card,
.broker-card,
.repay-card,
.debt-summary-item,
.kpi-card,
.plan-card,
.strategy-card,
.bank-group {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.broker-card:hover,
.debt-summary-item:hover,
.kpi-card:hover,
.plan-card:hover,
.strategy-card:hover {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: color-mix(in srgb, var(--primary) 9%, var(--panel));
  box-shadow: 0 8px 22px color-mix(in srgb, var(--text) 12%, transparent);
}
.cc-card:hover,
.repay-card:hover,
.bank-group:hover {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 45%, var(--border)), 0 8px 22px color-mix(in srgb, var(--text) 12%, transparent);
}
.cc-card:hover { background: color-mix(in srgb, var(--primary) 9%, var(--panel)); }
.repay-card:hover { background: color-mix(in srgb, var(--primary) 9%, var(--panel-alt)); }
.adaptive-table.is-records > tbody > tr > td { display: block; padding: 0; border: 0; min-width: 0; white-space: normal; }
.adaptive-table.is-records > tbody > tr > td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-bottom: 4px; }
.adaptive-table.is-records > tbody > tr > td[colspan] { grid-column: 1 / -1; }
.adaptive-table.is-records > tbody > tr > td[colspan]::before { display: none; }
.adaptive-table.is-narrow > tbody > tr { grid-template-columns: minmax(0, 1fr); }
.modal { overflow-wrap: anywhere; }
.modal-heading { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; position: sticky; top: -20px; margin: -20px -20px 16px; padding: 16px 20px; background: var(--panel); border-bottom: 1px solid var(--border); z-index: 2; }
.modal-heading h3 { margin: 0; font-size: 20px; }
.modal-heading button { flex-shrink: 0; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; width: 100%; }
.modal-actions button { flex: 1 1 130px; min-height: 44px; }
.modal .form-grid > *, .modal form > div { min-width: 0; flex-wrap: wrap; }
.modal .inline-form { width: 100%; }
.toast { max-width: calc(100vw - 32px); overflow-wrap: anywhere; }
@container dashboard (max-width: 700px) {
  .section-card { padding: 16px; }
  .cc-card { padding: 14px; }
  .section-header { align-items: flex-start; }
  .section-header > div { flex-wrap: wrap; }
  .bill-row { grid-template-columns: minmax(0, 1fr) auto; }
  .bank-next { flex-basis: 100%; margin-left: 0; }
  .simulator-controls { width: 100%; }
  .simulator-controls label { flex-basis: 100%; }
  .strategy-card { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .dashboard-pane { scroll-behavior: auto; }
  * { transition: none !important; }
}
@media (max-width: 860px) {
  .page-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
  }
  .page-nav .nav-btn {
    min-width: 0;
    padding: 10px 8px;
    font-size: 15px;
    line-height: 1.3;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
  }
  .page-nav .nav-btn.active {
    background: var(--hover);
    border-color: var(--link);
    color: var(--link);
  }
}
@media (max-width: 480px) {
  .modal-heading { top: -16px; margin: -16px -16px 16px; padding: 14px 16px; }
}

/* Shown on the active page until the first data load finishes */
body.app-loading .page.active::before {
  content: '正在加载…';
  display: block;
  padding: 10px 2px;
  color: var(--muted, #888);
  font-size: 14px;
}

/* Phones: let the document be the only scroller, with the top bar sticky. A fixed-height body with an
   inner scrolling pane lets iOS Safari/Chrome scroll the page itself under the browser toolbars, which
   pushes the tab bar out of reach of taps. Desktop keeps the two-pane layout. */
@media (max-width: 860px) {
  html { scroll-padding-top: calc(var(--topbar-height, 106px) + 8px); }
  body { height: auto; min-height: 100vh; overflow: visible; }
  header.topbar { position: sticky; top: 0; z-index: 20; }
  .workspace { overflow: visible; min-height: auto; }
  .dashboard-pane { overflow: visible; min-height: auto; }
}
