:root {
  color: #202833;
  background: #eef2f5;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 16px;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #d7dee7;
  --line-strong: #bfccd9;
  --text: #202833;
  --muted: #667789;
  --blue: #2563eb;
  --blue-soft: #e8f1ff;
  --teal: #0f766e;
  --teal-soft: #e7f5f2;
  --amber: #b45309;
  --amber-soft: #fff4df;
  --red: #b42318;
  --shadow: 0 10px 28px rgba(32, 40, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background:
    radial-gradient(circle at 18% 0%, rgba(16, 185, 129, 0.10), transparent 32%),
    radial-gradient(circle at 82% 4%, rgba(37, 99, 235, 0.10), transparent 30%),
    linear-gradient(180deg, #f8fafc 0, var(--bg) 210px),
    var(--bg);
}

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

button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: #243447;
  border-radius: 6px;
  min-height: 36px;
  padding: 8px 13px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

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

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

button:hover {
  background: #f5f8fb;
  border-color: #9fb0c2;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.18);
}

button.primary:hover {
  background: #1d4ed8;
}

button.danger {
  border-color: #f0b4a8;
  color: var(--red);
  background: #fffafa;
}

button.ghost {
  border-color: transparent;
  background: transparent;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
}

.brand {
  display: grid;
  gap: 3px;
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
}

.nav button.active,
.tabs button.active {
  background: var(--blue-soft);
  border-color: #8cb4ff;
  color: #1e40af;
  font-weight: 700;
}

.main {
  width: min(1480px, calc(100vw - 56px));
  margin: 0 auto;
  padding: 26px 0 36px;
}

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

.toolbar h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: 0;
}

.actions,
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: #425466;
  font-size: 14px;
  font-weight: 600;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 40px;
  padding: 9px 10px;
  background: #ffffff;
  color: #172033;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 3px solid rgba(37, 99, 235, 0.12);
  border-color: #6ea0ff;
}

.field textarea {
  min-height: 74px;
  resize: vertical;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 22px 0 12px;
  color: #1f2937;
  font-weight: 700;
  font-size: 15px;
}

.section-title::before {
  content: "";
  width: 7px;
  height: 18px;
  border-radius: 4px;
  background: var(--teal);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f9fbfd);
  padding: 15px 15px 14px;
  min-height: 112px;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--teal);
}

.metric:nth-child(2n)::before {
  background: var(--blue);
}

.metric:nth-child(3n)::before {
  background: #7c3aed;
}

.metric:nth-child(4n)::before {
  background: #d97706;
}

.metric .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric .value {
  margin-top: 10px;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.metric .subvalue {
  margin-top: 7px;
  color: #667789;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric.warn {
  background: var(--amber-soft);
  border-color: #fdba74;
}

.metric.warn::before {
  background: var(--amber);
}

.charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 4px;
}

.chart-box {
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  min-width: 980px;
}

.table th,
.table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 10px;
  text-align: left;
  white-space: nowrap;
}

.table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  z-index: 1;
}

.table tbody tr:hover {
  background: #f8fbff;
}

.table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.notice {
  border: 1px solid #c9d8ee;
  background: #eef4ff;
  padding: 13px 15px;
  border-radius: 6px;
  color: #294466;
}

.danger-zone {
  border-color: #fed7d7;
  background: #fffafa;
}

.hidden {
  display: none;
}

@media (max-width: 1260px) {
  body {
    min-width: 980px;
  }

  .main {
    width: min(1180px, calc(100vw - 36px));
  }

  .metric-grid,
  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---- New Card Layout ---- */

.field-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-inline label {
  color: #425466;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.field-inline input {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  min-height: 36px;
  padding: 6px 10px;
  background: #ffffff;
  color: #172033;
  font-size: 14px;
}

.field-inline input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ledger-columns {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.ledger-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---- Card Base ---- */

.ledger-card {
  background: #ffffff;
  border: none;
  border-radius: 12px;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.04),
    0 4px 16px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 200ms ease;
}

.ledger-card:hover {
  box-shadow:
    0 1px 2px rgba(0,0,0,0.06),
    0 8px 24px rgba(0,0,0,0.10);
}

/* ---- Card Headers - Colored per column ---- */

.card-header {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 12px 18px;
  border-bottom: none;
  color: #ffffff;
}

/* Column 1: 入库 — Emerald */
.ledger-columns .ledger-card:nth-child(1) .card-header {
  background: linear-gradient(135deg, #059669, #10b981);
}
.ledger-columns .ledger-card:nth-child(1) {
  border-top: 3px solid #059669;
}
.ledger-columns .ledger-card:nth-child(1) .card-inputs {
  background: #fafdfb;
}

/* Column 2: 出库 — Amber */
.ledger-columns .ledger-card:nth-child(2) .card-header {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}
.ledger-columns .ledger-card:nth-child(2) {
  border-top: 3px solid #d97706;
}
.ledger-columns .ledger-card:nth-child(2) .card-inputs {
  background: #fefdf8;
}

/* Column 3: 销售 — Violet */
.ledger-columns .ledger-card:nth-child(3) .card-header {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
}
.ledger-columns .ledger-card:nth-child(3) {
  border-top: 3px solid #7c3aed;
}
.ledger-columns .ledger-card:nth-child(3) .card-inputs {
  background: #fdfaff;
}

/* Column 4: 支付 — Rose */
.ledger-columns .ledger-card:nth-child(4) .card-header {
  background: linear-gradient(135deg, #e11d48, #f43f5e);
}
.ledger-columns .ledger-card:nth-child(4) {
  border-top: 3px solid #e11d48;
}
.ledger-columns .ledger-card:nth-child(4) .card-inputs {
  background: #fefafa;
}

/* Column 5: 现金与应收 — Blue */
.ledger-columns .ledger-card:nth-child(5) .card-header {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
}
.ledger-columns .ledger-card:nth-child(5) {
  border-top: 3px solid #2563eb;
}
.ledger-columns .ledger-card:nth-child(5) .card-inputs {
  background: #fafcfe;
}

/* Bottom: 销售 — Violet */
.card-sales .card-header {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
}
.card-sales {
  border-top: 3px solid #7c3aed;
}
.card-sales .card-inputs {
  background: #fdfaff;
}

/* Bottom: 备注 — Slate */
.card-notes .card-header {
  background: linear-gradient(135deg, #475569, #64748b);
}
.card-notes {
  border-top: 3px solid #475569;
}
.card-notes .card-inputs {
  background: #fafbfc;
}

/* ---- Card Inputs ---- */

.card-inputs {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card-inputs .field label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-inputs .field input,
.card-inputs .field textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  background: #ffffff;
  color: #172033;
  font-size: 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.card-inputs .field input:hover,
.card-inputs .field textarea:hover {
  border-color: #cbd5e1;
}

.card-inputs .field input:focus,
.card-inputs .field textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.card-inputs textarea {
  min-height: 80px;
  resize: vertical;
}

/* ---- Card Total (bottom of each column) ---- */

.card-total {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}

.card-total .total-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.05em;
  width: 100%;
}

.card-total .total-value {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.card-total .total-sub {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

.card-total.warn {
  background: #fffbeb;
  border-top-color: #fde68a;
}

.card-total.warn .total-value {
  color: #b45309;
}

/* ---- Payment Items ---- */

.payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
}

.payment-label {
  grid-column: 1 / -1;
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  background: #ffffff;
  color: #172033;
  font-size: 14px;
  transition: border-color 150ms ease;
}

.payment-amount {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  background: #ffffff;
  color: #172033;
  font-size: 14px;
  transition: border-color 150ms ease;
}

.payment-label:focus,
.payment-amount:focus {
  outline: none;
  border-color: #e11d48;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.08);
}

.remove-payment {
  width: 30px;
  height: 30px;
  min-height: auto;
  padding: 0;
  border: 1px solid #fecdd3;
  border-radius: 50%;
  background: #fff1f2;
  color: #e11d48;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: all 150ms ease;
}

.remove-payment:hover {
  background: #fecdd3;
  border-color: #e11d48;
}

.add-payment {
  margin: 4px 18px 0;
  padding: 8px 0;
  border: 2px dashed #e2e8f0;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
}

.add-payment:hover {
  border-color: #e11d48;
  color: #e11d48;
  background: #fff1f2;
}

/* ---- Bottom Cards ---- */

.card-sales .card-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.card-notes .card-inputs {
  padding: 14px 18px;
}

.card-notes textarea {
  min-height: 132px;
}

/* ---- Toolbar polish ---- */

.toolbar {
  margin-bottom: 20px;
}

.toolbar h2 {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
}

button {
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
}

button.primary {
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  font-weight: 700;
}

button.primary:hover {
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

/* Daily entry v1: dense ledger layout, with VND as the primary value. */
:root {
  --vnd: #16803c;
  --rmb: #2563b8;
  --ledger-ink: #172033;
  --ledger-surface: #ffffff;
  --ledger-subtle: #f6f8fa;
  --ledger-warn: #ba1a1a;
}

.entry-toolbar {
  align-items: flex-start;
  margin-bottom: 12px;
}

.toolbar-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.entry-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field-inline input {
  width: 122px;
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--ledger-ink);
  font-variant-numeric: tabular-nums;
}

.field-inline input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  border-radius: 3px;
}

.rate-control input {
  width: 64px;
  text-align: right;
}

.entry-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.entry-status-bar strong {
  color: var(--ledger-ink);
  font-size: 13px;
}

.status-difference {
  border-color: #efb3b3;
  background: #fff3f3;
}

.status-difference strong,
.check-item.status-difference strong,
.check-item.status-difference em {
  color: var(--ledger-warn);
}

.status-match {
  border-color: #b8d9c1;
  background: #f4fbf5;
}

.status-match strong,
.check-item.status-match strong {
  color: var(--vnd);
}

.entry-form {
  display: grid;
  gap: 12px;
}

.entry-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ledger-surface);
  box-shadow: 0 4px 16px rgba(32, 40, 51, 0.045);
}

.entry-section .section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.entry-section .section-heading h3 {
  margin: 0;
  color: var(--ledger-ink);
  font-size: 18px;
}

.entry-section .section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.flow-table {
  overflow: hidden;
  border: 1px solid #e1e7ed;
  border-radius: 6px;
}

.flow-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.55fr) minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #e7ecf0;
}

.flow-row:last-child {
  border-bottom: 0;
}

.flow-row > span,
.flow-row > strong {
  color: var(--ledger-ink);
  font-size: 14px;
  font-weight: 700;
}

.flow-head {
  padding-top: 8px;
  padding-bottom: 8px;
  background: var(--ledger-subtle);
}

.flow-head strong:first-of-type {
  color: var(--vnd);
}

.flow-head strong:last-of-type {
  color: var(--ledger-warn);
}

.flow-total {
  background: #fbfcfd;
}

.sales-grid,
.balance-grid {
  display: grid;
  gap: 12px;
}

.sales-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.balance-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.money-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.money-field > label,
.field-label-line label {
  color: #425466;
  font-size: 13px;
  font-weight: 700;
}

.field-label-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.carry-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.money-control {
  min-width: 0;
}

.money-control-row {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  background: #ffffff;
}

.money-control-row:focus-within {
  border-color: #5c8fd0;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.money-control-row input {
  width: min(100%, 230px);
  min-width: 0;
  flex: 1 1 180px;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 8px 9px;
  background: transparent;
  color: var(--ledger-ink);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.money-control-row input:focus {
  outline: none;
}

.money-unit {
  flex: 0 0 auto;
  padding: 0 9px 0 2px;
  color: var(--vnd);
  font-size: 11px;
  font-weight: 750;
}

.rmb-hint {
  display: block;
  min-height: 16px;
  padding: 3px 8px 0;
  color: var(--rmb);
  font-size: 11px;
  text-align: right;
}

.clear-field {
  flex: 0 0 auto;
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 20px;
  line-height: 1;
}

.clear-field:hover {
  color: var(--red);
  background: transparent;
}

.compact-money .money-control-row input {
  width: min(100%, 220px);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.check-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid #dbe3ea;
  border-radius: 6px;
  background: var(--ledger-subtle);
  color: var(--muted);
  font-size: 12px;
}

.check-item strong {
  color: var(--muted);
  font-size: 12px;
}

.check-item em {
  margin-left: auto;
  color: var(--muted);
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.note-section textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 10px;
  color: var(--ledger-ink);
}

.note-section textarea:focus {
  outline: 3px solid rgba(37, 99, 235, 0.12);
  border-color: #5c8fd0;
}

@media (max-width: 860px) {
  body {
    min-width: 0;
  }

  .topbar {
    height: auto;
    min-height: 70px;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    flex-wrap: wrap;
  }

  .nav {
    max-width: 100%;
    overflow-x: auto;
  }

  .main {
    width: calc(100vw - 24px);
    padding: 18px 0 28px;
  }

  .entry-toolbar,
  .entry-toolbar-actions {
    align-items: stretch;
  }

  .entry-toolbar,
  .entry-toolbar-actions {
    flex-direction: column;
  }

  .entry-toolbar-actions > *,
  .field-inline {
    width: 100%;
  }

  .entry-toolbar-actions button {
    min-height: 44px;
  }

  .entry-status-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .flow-row,
  .sales-grid,
  .balance-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .flow-head {
    display: none;
  }

  .flow-row {
    gap: 7px;
  }

  .flow-row > span,
  .flow-row > strong {
    padding-bottom: 2px;
  }

  .entry-section {
    padding: 12px;
  }

  .entry-section .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .money-control-row input,
  .compact-money .money-control-row input {
    width: 100%;
  }
}

/* Stitch reference geometry: the reference keeps the ledger rail vertical at
   tablet width, then becomes a compact horizontal rail only on phones. */
.side-nav {
  width: clamp(120px, 20vw, 320px);
}

.content-shell {
  margin-left: clamp(120px, 20vw, 320px);
}

.content-shell .topbar {
  padding: 0 clamp(14px, 1.875vw, 30px);
}

.topbar-left,
.topbar-right {
  gap: clamp(8px, 1.375vw, 22px);
}

.topbar-left h1 {
  font-size: clamp(18px, 1.82vw, 29px);
}

.side-brand {
  padding-inline: clamp(4px, .625vw, 10px);
}

.side-brand strong {
  font-size: clamp(18px, 1.94vw, 31px);
}

.side-brand span {
  font-size: clamp(8px, .82vw, 13px);
}

.side-link {
  min-height: clamp(40px, 3.625vw, 58px);
  padding-inline: clamp(8px, 1.125vw, 18px);
  gap: clamp(7px, .875vw, 14px);
  font-size: clamp(12px, .94vw, 15px);
}

.main {
  padding: clamp(14px, 1.875vw, 30px);
}

.dashboard-group.group-green .metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric.featured {
  color: #ffffff;
  background: var(--stitch-navy);
  border-color: var(--stitch-navy);
}

.metric.featured .label,
.metric.featured .value,
.metric.featured .subvalue {
  color: #ffffff;
}

.metric.featured .subvalue {
  color: #b7c8de;
}

.metric.featured .metric-bar {
  background: #40566b;
}

.metric.featured .metric-bar span {
  background: var(--stitch-amber);
}

.overview-reconciliation {
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid #e1e3e4;
  border-radius: 4px;
  background: #ffffff;
}

.reconciliation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 30px;
  background: #e7e8e9;
}

.reconciliation-heading strong {
  color: var(--stitch-navy-deep);
  font-size: 15px;
}

.reconciliation-heading button {
  min-height: 34px;
  border-radius: 3px;
  background: #ffffff;
  color: var(--stitch-navy-deep);
}

.reconciliation-table {
  width: 100%;
  border-collapse: collapse;
}

.reconciliation-table th,
.reconciliation-table td {
  padding: 14px 30px;
  border-bottom: 1px solid #e1e3e4;
  text-align: left;
}

.reconciliation-table th {
  color: #44474c;
  background: #f3f4f5;
  font-size: 13px;
  font-weight: 700;
}

.reconciliation-table td {
  color: #191c1d;
  font-size: 15px;
}

.reconciliation-table .num {
  text-align: right;
  font-family: var(--stitch-mono);
  font-variant-numeric: tabular-nums;
}

.entry-status {
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
}

.entry-status.ready {
  border-color: #b7dfbb;
  color: #398c46;
  background: #eef8ef;
}

.entry-status.pending {
  border-color: #f0c7c7;
  color: var(--stitch-red);
  background: #fff0f0;
}

@media (max-width: 720px) {
  .side-nav {
    position: sticky;
    inset: 0 0 auto;
    width: 100%;
    height: auto;
    padding: 12px;
  }

  .content-shell {
    margin-left: 0;
  }

  .reconciliation-heading,
  .reconciliation-table th,
  .reconciliation-table td {
    padding-inline: 14px;
  }

  .reconciliation-table {
    min-width: 700px;
  }

  .overview-reconciliation {
    overflow-x: auto;
  }
}

/* ---- Stitch visual shell: direct product UI translation ---- */
:root {
  --stitch-navy: #1a2b3c;
  --stitch-navy-deep: #041627;
  --stitch-bg: #f8f9fa;
  --stitch-line: #c4c6cd;
  --stitch-green: #4caf50;
  --stitch-amber: #feae2c;
  --stitch-red: #ba1a1a;
  --stitch-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

body {
  min-width: 0;
  background: var(--stitch-bg);
  color: #191c1d;
  background-image: none;
}

.app-shell {
  min-height: 100vh;
}

.side-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 256px;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 18px;
  background: var(--stitch-navy);
  color: #ffffff;
}

.side-brand {
  display: grid;
  gap: 3px;
  padding: 0 10px;
  margin-bottom: 42px;
}

.side-brand strong {
  font-size: 31px;
  line-height: 1.1;
  font-weight: 800;
}

.side-brand span {
  color: #8192a7;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
}

.side-links {
  display: grid;
  gap: 8px;
}

.side-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  min-height: 58px;
  padding: 12px 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9fb1c5;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
}

.side-link:hover {
  border: 0;
  background: #233b52;
  color: #ffffff;
}

.side-link.active {
  background: var(--stitch-amber);
  color: #291800;
}

.side-icon {
  width: 20px;
  color: currentColor;
  font-size: 21px;
  line-height: 1;
  text-align: center;
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid #294157;
  color: #ffffff;
}

.side-user strong,
.side-user small {
  display: block;
}

.side-user strong { font-size: 12px; }
.side-user small { margin-top: 3px; color: #8192a7; font-size: 10px; }

.user-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid #9fb1c5;
  border-radius: 50%;
  color: #ffffff;
  font-size: 19px;
}

.content-shell {
  min-height: 100vh;
  margin-left: 256px;
}

.content-shell .topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  height: 80px;
  padding: 0 30px;
  background: #ffffff;
  border-bottom: 1px solid var(--stitch-line);
  box-shadow: none;
  backdrop-filter: none;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 22px;
}

.topbar-left h1 {
  margin: 0;
  color: var(--stitch-navy-deep);
  font-size: 29px;
  line-height: 1;
  font-weight: 800;
}

.topbar-control,
.rate-readout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #74777d;
  font-size: 12px;
  white-space: nowrap;
}

.topbar-control input,
.rate-readout input {
  width: 116px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--stitch-line);
  border-radius: 4px;
  background: #ffffff;
  color: #191c1d;
  font-family: var(--stitch-mono);
  font-size: 13px;
}

.rate-readout input { width: 70px; text-align: right; }
.topbar-control input:focus,
.rate-readout input:focus { outline: 2px solid rgba(26, 43, 60, .16); border-color: var(--stitch-navy); }

.sync-state {
  color: #44474c;
  font-size: 13px;
  white-space: nowrap;
}

.topbar-save {
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 5px;
  background: var(--stitch-navy-deep) !important;
  border-color: var(--stitch-navy-deep) !important;
  box-shadow: none !important;
}

.main {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 30px;
}

.entry-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  color: #74777d;
  font-size: 12px;
}

.entry-actions > div { display: flex; gap: 8px; }
.entry-actions button { min-height: 34px; padding: 6px 12px; }
.entry-actions.read-only-notice {
  padding: 10px 12px;
  border: 1px solid #d8e0e7;
  border-radius: 5px;
  color: var(--stitch-navy);
  background: #f5f8fa;
}

.entry-form.read-only input:disabled,
.entry-form.read-only textarea:disabled {
  color: #30343a;
  background: #f3f4f5;
  border-color: #dfe1e3;
  opacity: 1;
  cursor: default;
}

.entry-form.read-only .clear-field { display: none; }

.entry-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.entry-section,
.panel {
  border: 1px solid var(--stitch-line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: none;
}

.entry-section {
  padding: 18px;
}

.entry-section .section-heading {
  min-height: 32px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e1e3e4;
}

.entry-section .section-heading h3 {
  color: var(--stitch-navy-deep);
  font-size: 22px;
  font-weight: 800;
}

.entry-section .section-heading h3::before {
  display: inline-block;
  width: 4px;
  height: 22px;
  margin-right: 10px;
  vertical-align: -2px;
  background: var(--stitch-navy);
  content: "";
}

.entry-section .section-heading span { color: #74777d; font-size: 12px; }

.flow-table {
  border: 1px solid #e1e3e4;
  border-radius: 5px;
  overflow: hidden;
}

.flow-row { border-bottom-color: #e1e3e4; }
.flow-head { background: #f3f4f5; }
.flow-head strong:first-of-type { color: #267a37; background: #eef8ef; }
.flow-head strong:last-of-type { color: var(--stitch-red); background: #fff0f0; }
.flow-total { background: #f8f9fa; }

.money-control-row { border-color: #c4c6cd; border-radius: 4px; }
.compact-label { display: none; }
.money-control-row input { font-family: var(--stitch-mono); font-size: 18px; color: #191c1d; }
.money-unit { color: var(--stitch-navy); }
.rmb-hint { color: #74777d; font-size: 11px; }

.flow-row .compact-money:nth-child(2) .money-unit,
.flow-row .compact-money:nth-child(2) .rmb-hint { color: var(--stitch-green); }
.flow-row .compact-money:nth-child(3) .money-unit,
.flow-row .compact-money:nth-child(3) .rmb-hint { color: var(--stitch-red); }

.sales-section .money-field:nth-child(2) .money-unit,
.sales-section .money-field:nth-child(2) .rmb-hint { color: var(--stitch-green); }
.sales-section .money-field:nth-child(3) .money-unit,
.sales-section .money-field:nth-child(3) .rmb-hint { color: var(--stitch-red); }

.balance-grid .money-unit,
.balance-grid .rmb-hint { color: #1976d2; }

.balance-grid .money-field { padding: 14px; border: 1px solid #e1e3e4; border-radius: 5px; background: #ffffff; }
.balance-grid .money-field:nth-child(2) { border: 2px solid rgba(26, 43, 60, .2); }

.check-item { border-color: #e1e3e4; border-radius: 4px; background: #f3f4f5; }
.note-section textarea { border-color: #c4c6cd; border-radius: 4px; }

.dashboard-intro {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
  color: #74777d;
}

.dashboard-panel {
  padding: 0;
  border: 0;
  background: transparent;
}

.dashboard-section-switch {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 22px;
  padding: 4px;
  border: 1px solid #e1e3e4;
  border-radius: 4px;
  background: #f3f4f5;
}
.dashboard-section-switch button { min-height: 34px; border: 0; border-radius: 3px; background: transparent; color: #74777d; }
.dashboard-section-switch button.active { color: var(--stitch-navy-deep); background: #fff; box-shadow: 0 1px 3px rgba(4, 22, 39, .1); }

.dashboard-intro strong { color: var(--stitch-navy-deep); font-size: 18px; }
.dashboard-tabs { margin-bottom: 16px; }
.dashboard-tabs button { border-radius: 4px; }

.dashboard-group { margin-bottom: 28px; }
.flow-overview-note { margin: -8px 0 16px; color: #74777d; font-size: 12px; }
.flow-overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.flow-overview-card { overflow: hidden; border: 1px solid #e1e3e4; border-top: 4px solid var(--stitch-green); border-radius: 7px; background: #fff; }
.flow-overview-card.out { border-top-color: var(--stitch-red); }
.flow-overview-total { padding: 20px 22px 18px; border-bottom: 1px solid #e7e8e9; }
.flow-overview-total span { display: block; color: #44474c; font-size: 13px; }
.flow-overview-total strong { display: block; margin-top: 14px; color: var(--stitch-navy-deep); font-family: var(--stitch-mono); font-size: 22px; }
.flow-overview-total small { display: block; margin-top: 7px; color: #74777d; font-size: 11px; }
.flow-overview-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.flow-overview-details > div { padding: 16px 22px; }
.flow-overview-details > div + div { border-left: 1px solid #e7e8e9; }
.flow-overview-details span { display: block; color: #44474c; font-size: 13px; }
.flow-overview-details strong { display: block; margin-top: 9px; color: var(--stitch-navy-deep); font-family: var(--stitch-mono); font-size: 17px; }
.flow-overview-details small { display: block; margin-top: 7px; color: #74777d; font-size: 11px; }
.flow-overview-card.in .flow-overview-total strong,
.flow-overview-card.in .flow-overview-details strong { color: #267a37; }
.flow-overview-card.out .flow-overview-total strong,
.flow-overview-card.out .flow-overview-details strong { color: var(--stitch-red); }
.comparison-row { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; color: #74777d; font-size: 10px; }
.comparison-row strong { color: inherit; font-family: var(--stitch-mono); font-size: 10px; }
.flow-overview-card .comparison-row { margin: 0; padding: 10px 22px 5px; }
.comparison-bar, .metric-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e7e8e9; }
.comparison-bar { margin: 0 22px 12px; }
.comparison-bar span, .metric-bar span { display: block; height: 100%; border-radius: inherit; }
.flow-overview-card.in .comparison-bar span { background: var(--stitch-green); }
.flow-overview-card.out .comparison-bar span { background: var(--stitch-red); }
.flow-coverage { padding: 9px 22px; color: #74777d; background: #f5f6f7; font-size: 10px; }
.group-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  color: var(--stitch-navy-deep);
  font-size: 22px;
  font-weight: 800;
}

.group-title::before { width: 4px; height: 34px; background: var(--stitch-navy); content: ""; }
.group-title.green::before { background: var(--stitch-green); }
.group-title.amber::before { background: var(--stitch-amber); }
.group-title.navy::before,
.group-title.balances::before { background: #1976d2; }

.metric-grid { gap: 16px; margin-bottom: 0; }
.metric {
  min-height: 154px;
  padding: 24px 24px 18px;
  border: 1px solid #e1e3e4;
  border-radius: 9px;
  background: #ffffff;
  box-shadow: none;
}

.metric.inflow { border-top: 4px solid var(--stitch-green); }
.metric.outflow { border-top: 4px solid var(--stitch-red); }
.metric.balance { border-top: 4px solid #1976d2; }
.metric.inflow .value { color: #267a37; }
.metric.outflow .value { color: var(--stitch-red); }
.metric.balance .value { color: #155fa0; }

.metric::before { display: none; }
.metric .label { color: #44474c; font-size: 14px; font-weight: 500; }
.metric .value {
  margin-top: 22px;
  color: var(--stitch-navy-deep);
  font-family: var(--stitch-mono);
  font-size: 21px;
  line-height: 1.1;
  font-weight: 600;
  white-space: nowrap;
}

.metric-unit { margin-left: 6px; color: #74777d; font-family: inherit; font-size: 10px; font-weight: 400; }
.metric .subvalue { margin-top: 8px; color: #74777d; font-family: var(--stitch-mono); font-size: 12px; font-weight: 400; }
.metric-bar { margin-top: 5px; }
.metric.inflow .metric-bar span { background: var(--stitch-green); }
.metric.outflow .metric-bar span { background: var(--stitch-red); }
.metric.warn .metric-bar span { background: var(--stitch-red); }
.metric.warn .value { color: var(--stitch-red); }
.metric.balance { border-color: rgba(25, 118, 210, .35); }

.dashboard-group.group-navy .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-group.group-neutral .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-group.group-balances .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.charts { margin-top: 28px; }
.chart-box { border-color: #e1e3e4; border-radius: 7px; box-shadow: none; }

.entry-footer {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 20px;
  color: #ffffff;
  background: var(--stitch-navy);
  border-radius: 5px;
  box-shadow: 0 12px 24px rgba(4, 22, 39, .22);
  font-size: 11px;
}

.footer-status { padding-right: 18px; border-right: 1px solid #40566b; }
.footer-status.status-difference { color: #ffb955; }
.footer-status.status-match { color: #8edb95; }
.footer-status.status-unverified { color: #d5dce4; }

@media (max-width: 860px) {
  .side-nav {
    position: sticky;
    inset: 0 0 auto;
    width: 100%;
    height: auto;
    padding: 12px;
  }
  .side-brand { display: flex; align-items: baseline; justify-content: space-between; margin: 0 6px 10px; padding: 0; }
  .side-brand strong { font-size: 21px; }
  .side-brand span { font-size: 9px; }
  .side-links { display: flex; gap: 4px; overflow-x: auto; }
  .side-link { flex: 0 0 auto; width: auto; min-height: 40px; padding: 8px 12px; gap: 6px; font-size: 12px; }
  .side-icon { font-size: 16px; }
  .side-user { display: none; }
  .content-shell { margin-left: 0; }
  .content-shell .topbar { position: static; height: auto; min-height: 72px; padding: 14px 16px; align-items: flex-start; flex-wrap: wrap; }
  .topbar-left, .topbar-right { gap: 10px; flex-wrap: wrap; }
  .topbar-left h1 { font-size: 21px; }
  .sync-state { display: none; }
  .main { padding: 16px 12px 28px; }
  .topbar-control input { width: 108px; }
  .entry-actions { align-items: flex-start; flex-direction: column; }
  .entry-actions > div { width: 100%; justify-content: flex-end; }
  .entry-footer { position: static; margin: 0 12px 14px; justify-content: space-between; }
  .metric-grid, .dashboard-group:nth-of-type(3) .metric-grid { grid-template-columns: 1fr; }
  .metric .value { font-size: 23px; }
}

/* Final Stitch reference overrides. Keep the rail vertical at the 640px
   daily-entry reference width; collapse it only for phone-sized screens. */
.side-nav { width: clamp(120px, 20vw, 320px); }
.content-shell { margin-left: clamp(120px, 20vw, 320px); }
.content-shell .topbar { padding-inline: clamp(14px, 1.875vw, 30px); }
.topbar-left, .topbar-right { gap: clamp(8px, 1.375vw, 22px); }
.topbar-left h1 { font-size: clamp(18px, 1.82vw, 29px); }
.side-brand { padding-inline: clamp(4px, .625vw, 10px); }
.side-brand strong { font-size: clamp(18px, 1.94vw, 31px); }
.side-brand span { font-size: clamp(8px, .82vw, 13px); }
.side-link {
  min-height: clamp(40px, 3.625vw, 58px);
  padding-inline: clamp(8px, 1.125vw, 18px);
  gap: clamp(7px, .875vw, 14px);
  font-size: clamp(12px, .94vw, 15px);
}
.main { padding: clamp(14px, 1.875vw, 30px); }
.dashboard-group.group-green .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric.featured { color: #fff; background: var(--stitch-navy); border-color: var(--stitch-navy); }
.metric.featured .label, .metric.featured .value { color: #fff; }
.metric.featured .subvalue { color: #b7c8de; }
.metric.featured .metric-bar { background: #40566b; }
.metric.featured .metric-bar span { background: var(--stitch-amber); }
.metric.warn { background: #fff; border-color: #e1e3e4; }
.metric.warn .value { color: var(--stitch-red); }
.overview-reconciliation {
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid #e1e3e4;
  border-radius: 4px;
  background: #fff;
}
.reconciliation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 30px;
  background: #e7e8e9;
}
.reconciliation-heading strong { color: var(--stitch-navy-deep); font-size: 15px; }
.reconciliation-heading button { min-height: 34px; border-radius: 3px; background: #fff; color: var(--stitch-navy-deep); }
.reconciliation-table { width: 100%; border-collapse: collapse; }
.reconciliation-table th, .reconciliation-table td { padding: 14px 30px; border-bottom: 1px solid #e1e3e4; text-align: left; }
.reconciliation-table th { color: #44474c; background: #f3f4f5; font-size: 13px; font-weight: 700; }
.reconciliation-table td { color: #191c1d; font-size: 15px; }
.reconciliation-table .num { text-align: right; font-family: var(--stitch-mono); font-variant-numeric: tabular-nums; }
.entry-status { display: inline-block; padding: 4px 8px; border: 1px solid; border-radius: 2px; font-size: 11px; font-weight: 700; }
.entry-status.ready { border-color: #b7dfbb; color: #398c46; background: #eef8ef; }
.entry-status.pending { border-color: #f0c7c7; color: var(--stitch-red); background: #fff0f0; }

@media (min-width: 521px) and (max-width: 860px) {
  .side-nav { position: fixed; inset: 0 auto 0 0; width: clamp(120px, 20vw, 320px); height: 100vh; padding: 18px 10px; }
  .side-brand { display: grid; margin: 0 0 28px; padding-inline: 4px; }
  .side-links { display: grid; gap: 5px; }
  .side-link { width: 100%; min-height: 40px; padding: 8px 7px; }
  .side-user { display: flex; }
  .content-shell { margin-left: clamp(120px, 20vw, 320px); }
  .content-shell .topbar { position: sticky; height: 80px; padding: 0 14px; flex-wrap: nowrap; }
  .topbar-left, .topbar-right { flex-wrap: nowrap; }
  .topbar-left h1 { white-space: nowrap; font-size: 18px; }
  .topbar-control input { width: 92px; font-size: 10px; }
  .rate-readout input { width: 52px; }
  .main { width: auto; padding: 14px; }
  .entry-actions { flex-direction: row; align-items: center; }
  .entry-footer { position: fixed; margin: 0; }
  .flow-row { grid-template-columns: minmax(82px, .55fr) minmax(0, 1fr) minmax(0, 1fr); }
  .flow-head { display: grid; }
  .sales-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .balance-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry-section { padding: 12px; }
  .entry-section .section-heading { align-items: baseline; flex-direction: row; gap: 8px; }
  .entry-section .section-heading h3 { font-size: 18px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-group.group-green .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-group.group-neutral .metric-grid,
  .dashboard-group.group-balances .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  body { min-width: 0; padding-bottom: 72px; }
  .side-nav {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    height: 72px;
    padding: 0;
    background: #ffffff;
    border-top: 1px solid #e1e3e4;
  }
  .side-brand, .side-user { display: none; }
  .side-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; height: 100%; overflow: visible; }
  .side-link {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 72px;
    padding: 6px 2px;
    gap: 3px;
    color: #74777d;
    background: transparent;
    border-radius: 0;
    font-size: 10px;
  }
  .side-link.active { color: var(--stitch-navy-deep); background: #f3f4f5; }
  .side-link.active .side-icon { color: #ffffff; background: var(--stitch-navy); }
  .side-icon { min-width: 38px; padding: 3px 10px; border-radius: 999px; font-size: 18px; }
  .content-shell { margin-left: 0; }
  .content-shell .topbar {
    position: sticky;
    top: 0;
    min-height: 64px;
    padding: 10px 14px;
    background: rgba(248, 249, 250, .97);
  }
  .topbar-left { width: calc(100% - 96px); }
  .topbar-left h1 { width: 100%; font-size: 20px; }
  .topbar-control, .rate-readout { font-size: 10px; }
  .topbar-control input { width: 112px; }
  .topbar-right { margin-left: auto; }
  .topbar-save { min-height: 36px; padding: 7px 12px; }
  .main { width: 100%; padding: 14px 12px 24px; }
  .entry-actions { margin-bottom: 12px; }
  .entry-actions > span { font-size: 11px; }
  .entry-section { padding: 14px 12px; }
  .entry-section .section-heading { align-items: flex-start; flex-direction: column; }
  .entry-section .section-heading h3 { font-size: 19px; }
  .flow-head { display: none; }
  .flow-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px 0;
  }
  .flow-row > span, .flow-row > strong { grid-column: 1 / -1; }
  .compact-label { display: block; margin-bottom: 5px; color: #74777d; font-size: 11px; }
  .money-control-row input { font-size: 15px; }
  .sales-grid, .balance-grid, .check-grid { grid-template-columns: 1fr; }
  .metric-grid,
  .dashboard-group.group-green .metric-grid,
  .dashboard-group.group-navy .metric-grid,
  .dashboard-group.group-neutral .metric-grid,
  .dashboard-group.group-balances .metric-grid { grid-template-columns: 1fr; }
  .dashboard-group { margin-bottom: 24px; }
  .metric { min-height: 142px; }
  .entry-footer { display: none; }
}

/* Stitch history and data-management pages. */
.history-page,
.io-page { color: var(--stitch-navy-deep); }

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.history-view-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid #e1e3e4;
  border-radius: 4px;
  background: #f3f4f5;
}

.history-view-switch button { min-height: 34px; border: 0; border-radius: 3px; background: transparent; color: #74777d; }
.history-view-switch button.active { color: var(--stitch-navy-deep); background: #ffffff; box-shadow: 0 1px 3px rgba(4, 22, 39, .1); }
.history-month { display: flex; align-items: center; gap: 10px; color: #74777d; font-size: 12px; }
.history-month input { min-height: 38px; padding: 7px 10px; border: 1px solid #c4c6cd; border-radius: 3px; background: #fff; color: var(--stitch-navy-deep); }

.history-calendar { overflow: hidden; border: 1px solid #e1e3e4; border-radius: 5px; background: #fff; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-weekdays { background: #f3f4f5; border-bottom: 1px solid #e1e3e4; }
.calendar-weekdays span { padding: 12px 8px; color: #44474c; text-align: center; font-size: 12px; font-weight: 700; }
.calendar-day {
  position: relative;
  min-height: 116px;
  padding: 12px;
  border: 0;
  border-right: 1px solid #edeeef;
  border-bottom: 1px solid #edeeef;
  border-radius: 0;
  background: #fff;
  color: #191c1d;
  text-align: left;
}
.calendar-day:hover:not(:disabled) { z-index: 1; background: #f8f9fa; box-shadow: inset 0 0 0 1px #c4c6cd; }
.calendar-day.outside { background: #f8f9fa; }
.calendar-day:disabled { cursor: default; opacity: .42; }
.calendar-day > span { font-family: var(--stitch-mono); font-size: 14px; }
.calendar-day i { position: absolute; right: 14px; bottom: 14px; width: 8px; height: 8px; border-radius: 50%; background: #c4c6cd; }
.calendar-day small { position: absolute; left: 12px; bottom: 10px; color: #9a9da3; font-size: 10px; }
.calendar-day.match i { background: var(--stitch-green); }
.calendar-day.difference { background: #fff3f3; }
.calendar-day.difference i { width: 12px; height: 12px; background: var(--stitch-red); box-shadow: 0 0 0 5px rgba(186, 26, 26, .12); }
.calendar-day.unverified i { background: #9a9da3; }
.calendar-legend { display: flex; justify-content: flex-end; gap: 20px; padding: 13px 18px; color: #74777d; font-size: 11px; }
.calendar-legend .match { color: var(--stitch-green); }
.calendar-legend .difference { color: var(--stitch-red); }
.calendar-legend .unverified { color: #74777d; }

.history-table-wrap { overflow-x: auto; border: 1px solid #e1e3e4; border-radius: 5px; background: #fff; }
.history-table { min-width: 1050px; }
.history-table th { background: #f3f4f5; }
.history-row-actions { display: flex; gap: 5px; }
.history-row-actions button { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.history-status { display: inline-flex; align-items: center; white-space: nowrap; padding: 5px 9px; border: 1px solid; border-radius: 999px; font-size: 11px; font-weight: 700; }
.history-status.match { border-color: #cce8d0; color: #2f8a3e; background: #f2faf3; }
.history-status.difference { border-color: #efb3b3; color: var(--stitch-red); background: #fff3f3; }
.history-status.unverified { border-color: #d9dde2; color: #74777d; background: #f8f9fa; }
.history-mobile-view { display: none; }

.io-heading { margin-bottom: 26px; }
.io-heading h2 { margin: 0 0 8px; font-size: 28px; }
.io-heading p, .io-card p, .io-security p { margin: 0; color: #74777d; line-height: 1.6; }
.io-security { display: flex; gap: 16px; margin-bottom: 28px; padding: 18px 22px; border-left: 5px solid var(--stitch-navy); background: #e7e8e9; }
.io-security > span { font-size: 20px; }
.io-security strong { display: block; margin-bottom: 4px; }
.io-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, .72fr); gap: 22px; }
.io-side-stack { display: grid; gap: 22px; }
.io-card { padding: 28px; border: 1px solid #e1e3e4; border-radius: 5px; background: #fff; }
.io-card-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid #e7e8e9; }
.io-card-heading > span { display: grid; place-items: center; width: 48px; height: 48px; color: #fff; background: var(--stitch-navy); font-size: 24px; }
.io-card-heading h3 { margin: 0 0 3px; font-size: 20px; }
.io-card-heading p { font-size: 12px; }
.io-action-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding: 20px; border: 1px solid #e1e3e4; background: #f8f9fa; }
.io-action-row strong { display: block; margin-bottom: 6px; }
.io-action-row p { max-width: 420px; font-size: 12px; }
.io-action-row button { flex: 0 0 126px; min-height: 48px; }
.io-card button.primary { background: var(--stitch-navy-deep); border-color: var(--stitch-navy-deep); box-shadow: none; }
.merge-card > p { margin-bottom: 18px; font-size: 12px; }
.io-card .wide { width: 100%; min-height: 46px; }
.restore-card textarea { width: 100%; min-height: 108px; padding: 12px; border: 1px dashed #b7bcc3; border-radius: 4px; resize: vertical; }
.io-warning { margin: 12px 0; padding: 10px 12px; color: #9b2c25; background: #fff2f0; border: 1px solid #f0c7c2; font-size: 11px; }
.io-footer { display: flex; gap: 30px; margin-top: 28px; padding-top: 20px; border-top: 1px solid #e1e3e4; color: #74777d; font-size: 12px; }
.io-footer span:first-child { color: #2f8a3e; }

.analysis-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 20px; }
.analysis-heading span { color: #74777d; font-size: 11px; }
.analysis-heading h2 { margin: 4px 0 0; color: var(--stitch-navy-deep); font-size: 28px; }
.analysis-heading > p { max-width: 520px; margin: 0; color: #74777d; text-align: right; font-size: 12px; line-height: 1.6; }
.analysis-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.analysis-kpi { min-height: 120px; padding: 20px; border: 1px solid #e1e3e4; border-top: 4px solid var(--stitch-navy); border-radius: 5px; background: #fff; }
.analysis-kpi.income { border-top-color: var(--stitch-green); }
.analysis-kpi.payment { border-top-color: var(--stitch-red); }
.analysis-kpi.cash { border-top-color: #1976d2; }
.analysis-kpi span, .balance-snapshot span { display: block; color: #74777d; font-size: 12px; }
.analysis-kpi strong { display: block; margin-top: 18px; color: var(--stitch-navy-deep); font-family: var(--stitch-mono); font-size: 18px; white-space: nowrap; }
.analysis-kpi small { display: block; margin-top: 7px; color: #1976d2; font-size: 11px; }
.analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.analysis-chart { min-width: 0; height: 330px; padding: 20px; border: 1px solid #e1e3e4; border-radius: 5px; background: #fff; }
.analysis-chart > div { margin-bottom: 12px; }
.analysis-chart h3 { margin: 0 0 5px; color: var(--stitch-navy-deep); font-size: 16px; }
.analysis-chart p { margin: 0; color: #74777d; font-size: 11px; }
.analysis-chart canvas { width: 100% !important; height: 245px !important; }
.analysis-bottom { display: grid; grid-template-columns: minmax(330px, .8fr) minmax(0, 1.2fr); gap: 16px; margin-top: 16px; }
.cash-flow-card { padding: 25px; color: #fff; border-radius: 5px; background: var(--stitch-navy); }
.cash-flow-card > span { color: #b7c8de; font-size: 12px; }
.cash-flow-card strong { display: block; margin-top: 14px; font-family: var(--stitch-mono); font-size: 28px; }
.cash-flow-card small { display: block; margin-top: 7px; color: #8edb95; }
.cash-flow-card p { margin: 20px 0 0; padding-top: 14px; border-top: 1px solid #40566b; color: #b7c8de; font-size: 11px; line-height: 1.6; }
.balance-snapshot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid #e1e3e4; border-radius: 5px; background: #e1e3e4; }
.balance-snapshot > div { padding: 22px; background: #fff; }
.balance-snapshot strong { display: block; margin-top: 14px; color: var(--stitch-navy-deep); font-family: var(--stitch-mono); font-size: 17px; }
.analysis-balance-snapshot { margin-top: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.asset-allocation-card { min-width: 0; padding: 22px; border: 1px solid #e1e3e4; border-radius: 5px; background: #fff; }
.asset-allocation-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.asset-allocation-heading h3 { margin: 0 0 5px; color: var(--stitch-navy-deep); font-size: 16px; }
.asset-allocation-heading p { margin: 0; color: #74777d; font-size: 10px; }
.asset-allocation-heading > strong { color: var(--stitch-navy-deep); font-family: var(--stitch-mono); font-size: 14px; white-space: nowrap; }
.asset-allocation-body { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 20px; margin-top: 16px; }
.asset-chart { height: 145px; }
.asset-legend { display: grid; gap: 10px; }
.asset-legend > div { display: grid; grid-template-columns: 9px 42px 50px minmax(0, 1fr); align-items: center; gap: 7px; }
.asset-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--asset-color); }
.asset-legend span, .asset-legend small { color: #74777d; font-size: 10px; }
.asset-legend strong { color: var(--stitch-navy-deep); font-family: var(--stitch-mono); font-size: 13px; }
.asset-legend small { text-align: right; font-family: var(--stitch-mono); }
.asset-empty { padding: 40px 0; color: #74777d; text-align: center; }

@media (max-width: 860px) {
  .io-grid { grid-template-columns: 1fr; }
  .calendar-day { min-height: 92px; padding: 8px; }
  .analysis-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-grid { grid-template-columns: 1fr; }
  .analysis-balance-snapshot { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .history-toolbar { justify-content: flex-end; }
  .history-view-switch, .history-desktop-view { display: none; }
  .history-mobile-view { display: block; }
  .history-month span { display: none; }
  .history-mobile-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 10px 0 22px; }
  .history-mobile-heading div { display: grid; gap: 3px; }
  .history-mobile-heading strong { font-size: 36px; }
  .history-mobile-heading span { color: #74777d; font-size: 12px; }
  .history-mobile-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto 12px;
    align-items: center;
    width: 100%;
    min-height: 112px;
    margin-bottom: 12px;
    padding: 16px 13px 16px 18px;
    border: 1px solid #e7e8e9;
    border-left: 6px solid #c4c6cd;
    border-radius: 8px;
    background: #fff;
    text-align: left;
    box-shadow: 0 2px 8px rgba(4, 22, 39, .04);
  }
  .history-mobile-row.match { border-left-color: var(--stitch-green); }
  .history-mobile-row.difference { border-color: #efb3b3; border-left-color: var(--stitch-red); background: #fff3f3; }
  .mobile-date { display: grid; gap: 6px; padding-right: 12px; border-right: 1px solid #e7e8e9; }
  .mobile-date strong { font-family: var(--stitch-mono); font-size: 19px; }
  .mobile-date span { width: fit-content; padding: 2px 5px; color: #74777d; background: #f3f4f5; font-size: 10px; }
  .mobile-amount { display: grid; gap: 6px; padding-left: 14px; }
  .mobile-amount span { color: #74777d; font-size: 11px; }
  .mobile-amount strong { font-family: var(--stitch-mono); font-size: 13px; font-weight: 500; }
  .history-mobile-row .history-status { padding: 5px 7px; font-size: 10px; }
  .history-mobile-row > b { color: #b7bcc3; font-size: 24px; }
  .history-empty { padding: 40px 20px; color: #74777d; text-align: center; }

  .io-heading h2 { font-size: 24px; }
  .io-heading p { font-size: 12px; }
  .io-security { padding: 14px; }
  .io-grid, .io-side-stack { gap: 14px; }
  .io-card { padding: 18px 14px; }
  .io-card-heading { margin-bottom: 16px; padding-bottom: 14px; }
  .io-card-heading > span { width: 40px; height: 40px; }
  .io-card-heading h3 { font-size: 19px; }
  .io-action-row { align-items: stretch; flex-direction: column; padding: 15px; }
  .io-action-row button { flex-basis: auto; width: 100%; }
  .io-footer { flex-direction: column; gap: 6px; }
  .dashboard-section-switch { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .analysis-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .analysis-heading h2 { font-size: 22px; }
  .analysis-heading > p { text-align: left; }
  .analysis-kpis { gap: 10px; }
  .analysis-kpi { min-height: 112px; padding: 15px 12px; }
  .analysis-kpi strong { margin-top: 14px; font-size: 13px; white-space: normal; }
  .analysis-chart { height: 300px; padding: 15px 10px; }
  .analysis-chart canvas { height: 220px !important; }
  .analysis-bottom { grid-template-columns: 1fr; }
  .cash-flow-card strong { font-size: 21px; }
  .flow-overview-grid { grid-template-columns: 1fr; }
  .group-title { font-size: 19px; }
  .flow-overview-total strong { font-size: 18px; }
  .flow-overview-details { grid-template-columns: 1fr; }
  .flow-overview-details > div + div { border-left: 0; border-top: 1px solid #e7e8e9; }
  .asset-allocation-heading { flex-direction: column; gap: 8px; }
  .asset-allocation-body { grid-template-columns: 120px minmax(0, 1fr); gap: 12px; }
  .asset-chart { height: 120px; }
  .asset-legend > div { grid-template-columns: 9px 34px 44px minmax(0, 1fr); gap: 5px; }
  .asset-legend small { font-size: 9px; }
  .balance-snapshot { grid-template-columns: 1fr 1fr; }
  .balance-snapshot > div { padding: 15px 12px; }
  .balance-snapshot strong { font-size: 13px; }
}
