:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #68726c;
  --line: #dfe5e0;
  --surface: #ffffff;
  --canvas: #f5f7f4;
  --green: #0b7a45;
  --green-dark: #075c35;
  --green-pale: #e8f5ed;
  --amber: #9d6506;
  --amber-pale: #fff4da;
  --red: #b63232;
  --sidebar: #f9faf8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  min-width: 320px;
}

button, a { font: inherit; }
button { letter-spacing: 0; }

.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 18px 20px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  padding: 0 10px 28px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  font-weight: 900;
  transform: skew(-8deg);
}

.brand-name { font-size: 22px; font-weight: 900; }

nav { display: grid; gap: 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 6px;
  color: #48524c;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.nav-item.active, .nav-item:hover { background: #e9efea; color: var(--ink); }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 3px 8px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-foot strong { grid-column: 2; color: var(--ink); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); margin-top: 4px; }

main {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.topbar, .section-heading, .summary, .connection-row, footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar { margin-bottom: 24px; }
h1, h2, p { margin: 0; }
h1 { font-size: 27px; line-height: 1.15; letter-spacing: 0; }
h2 { font-size: 18px; line-height: 1.25; letter-spacing: 0; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 850; margin-bottom: 5px; }
.muted { color: var(--muted); font-size: 13px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.refresh-time { color: var(--muted); font-size: 12px; }
.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 20px;
}
.icon-button:hover { border-color: #aeb9b1; }
.icon-button:disabled { opacity: .5; cursor: wait; }

.setup-banner {
  min-height: 72px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--amber-pale);
  border: 1px solid #eed898;
  padding: 14px 18px;
  margin-bottom: 28px;
}

.setup-banner p { color: #6e5a2d; margin-top: 3px; font-size: 13px; }
.banner-icon { font-size: 20px; color: var(--amber); }
.mode-badge { color: var(--amber); font-size: 11px; font-weight: 900; }

.summary {
  padding: 20px 0 30px;
  border-bottom: 1px solid var(--line);
  align-items: flex-end;
}
.cash-total { font-size: 46px; font-variant-numeric: tabular-nums; margin: 2px 0 5px; }
.verdict { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.verdict-dot { width: 12px; height: 12px; border-radius: 50%; background: #9aa49d; }
.verdict small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; }
.verdict strong { font-size: 13px; }
.verdict[data-state="covered"] .verdict-dot { background: var(--green); }
.verdict[data-state="covered"] strong { color: var(--green-dark); }
.verdict[data-state="warning"] .verdict-dot { background: var(--red); }
.verdict[data-state="warning"] strong { color: var(--red); }

.account-band, .connections, .readiness { padding: 30px 0; border-bottom: 1px solid var(--line); }
.section-heading { margin-bottom: 18px; align-items: flex-end; }
.account-list { border-top: 1px solid var(--line); }
.empty-state { padding: 28px 0; display: grid; gap: 5px; color: var(--muted); }
.empty-state strong { color: var(--ink); }
.account-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) 120px 140px 140px;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.account-row:last-child { border-bottom: 0; }
.account-name { display: grid; gap: 3px; }
.account-name span, .account-label { color: var(--muted); font-size: 12px; }
.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 760; }
.below-floor { color: var(--red); }

.connection-list { border-top: 1px solid var(--line); }
.connection-row { min-height: 76px; border-bottom: 1px solid var(--line); }
.source-icon {
  flex: 0 0 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-weight: 900;
}
.source-icon.bank { background: var(--green-pale); color: var(--green); }
.source-icon.qbo { background: #e7f0fa; color: #1766a7; }
.source-icon.mail { background: #f5ece5; color: #9e531e; }
.connection-copy { flex: 1; display: grid; gap: 3px; }
.connection-copy span, .connection-status { color: var(--muted); font-size: 12px; }
.connection-status { width: 116px; font-weight: 700; }
.connection-status.connected { color: var(--green); }

.action-button {
  min-width: 126px;
  min-height: 38px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: white;
  padding: 0 16px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}
.action-button:hover { background: var(--green-dark); border-color: var(--green-dark); }
.action-button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.action-button:disabled { opacity: .45; cursor: not-allowed; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.checklist li { display: grid; grid-template-columns: 28px 1fr; gap: 9px; align-items: start; }
.checklist li > span { width: 26px; height: 26px; border: 1px solid #b9c3bc; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 850; }
.checklist div { display: grid; gap: 4px; }
.checklist small { color: var(--muted); line-height: 1.35; }
.checklist li.complete > span { color: white; background: var(--green); border-color: var(--green); }

footer { color: var(--muted); font-size: 12px; padding-top: 22px; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(430px, calc(100vw - 48px));
  padding: 13px 16px;
  background: var(--ink);
  color: white;
  border-radius: 6px;
  box-shadow: 0 14px 36px rgba(23, 32, 28, .2);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8e2e2e; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px 18px; flex-direction: row; align-items: center; gap: 18px; }
  .brand { padding: 0; }
  nav { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  main { width: min(100% - 28px, 720px); padding-top: 22px; }
  .setup-banner { grid-template-columns: 30px 1fr; }
  .mode-badge { grid-column: 2; }
  .summary { align-items: flex-start; }
  .cash-total { font-size: 38px; }
  .account-row { grid-template-columns: 1fr 1fr; padding: 14px 0; }
  .amount { text-align: left; }
  .connection-row { display: grid; grid-template-columns: 38px 1fr; padding: 16px 0; }
  .connection-status, .action-button { grid-column: 2; width: 100%; }
  .checklist { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .topbar, .summary, .section-heading, footer { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .cash-total { font-size: 34px; }
  .verdict { min-width: 0; }
  .account-row { grid-template-columns: 1fr; gap: 6px; }
  .checklist { grid-template-columns: 1fr; }
  footer { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
