:root {
  --navy: #0f2747;
  --sidebar: #0c2341;
  --sidebar-2: #10294a;
  --emerald: #059669;
  --emerald-dark: #047857;
  --teal: #0f766e;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #172b4d;
  --muted: #64748b;
  --line: #e6edf5;
  --red: #e11d48;
  --blue: #2563eb;
  --shadow: 0 10px 30px rgba(15, 39, 71, .05);
  --radius: 14px;
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; }
a { color: var(--emerald); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: -.03em; }
h2 { font-size: 16px; }
h3 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 268px; flex: 0 0 268px; background: linear-gradient(180deg, #0d2748 0%, #0a1c33 100%);
  color: #d5deea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px;
}
.brand { display: flex; gap: 12px; align-items: center; color: white; padding: 6px 8px 18px; }
.brand strong { display: block; font-size: 14px; }
.brand small { color: #93a4b8; font-size: 11px; }
.brand-logo, .brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--emerald); color: white; font-weight: 800;
}
.brand-logo svg { width: 22px; height: 22px; }
.nav { display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.nav-link, .submenu a {
  display: flex; align-items: center; gap: 10px; color: #c9d4e3; border-radius: 12px;
  padding: 10px 12px; border: 0; background: transparent; width: 100%; text-align: left; cursor: pointer;
}
.nav-link svg { width: 18px; height: 18px; }
.nav-link.active, .nav-link:hover, .submenu a:hover, .submenu a.active { background: rgba(255,255,255,.06); color: white; }
.nav-link.active { background: var(--emerald); color: white; }
.nav-parent { justify-content: space-between; }
.nav-parent span { display: flex; gap: 10px; align-items: center; }
.chev { width: 16px; height: 16px; transition: transform .2s; }
.nav-parent.open .chev { transform: rotate(180deg); }
.submenu { display: none; padding: 0 0 8px 18px; }
.submenu.open { display: flex; flex-direction: column; }
.submenu a { font-size: 13px; padding: 8px 12px; }
.side-user { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 14px 8px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.side-user strong, .side-user small { display: block; }
.side-user small { color: #93a4b8; }
.avatar, .avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #1d4ed8; color: white; font-weight: 700;
}
.workspace { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 0; }
.crumbs { color: var(--muted); font-weight: 600; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.today { display: flex; align-items: center; gap: 8px; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; }
.today svg, .icon-btn svg { width: 18px; height: 18px; }
.icon-btn, .avatar-btn { border: 0; background: white; border-radius: 12px; width: 40px; height: 40px; display: grid; place-items: center; position: relative; cursor: pointer; box-shadow: var(--shadow); }
.icon-btn em { position: absolute; top: 4px; right: 4px; background: var(--red); color: white; border-radius: 99px; font-style: normal; font-size: 10px; min-width: 16px; height: 16px; display: grid; place-items: center; }
.content { padding: 18px 28px 40px; }
.page-intro { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 16px; }
.page-intro p, .muted { color: var(--muted); }
.crumb { font-size: 12px; margin-bottom: 4px; }
.small { font-size: 12px; }

.stat-grid, .dash-mid, .dash-bot, .balance-grid, .detail-grid, .report-grid { display: grid; gap: 16px; }
.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid.three { grid-template-columns: repeat(3, 1fr); }
.dash-mid { grid-template-columns: minmax(0, 1.4fr) minmax(240px, .8fr) minmax(220px, .72fr); margin-top: 16px; }
.dash-bot { grid-template-columns: minmax(0, 1.55fr) minmax(280px, .85fr); margin-top: 16px; }
.balance-grid, .detail-grid { grid-template-columns: 1fr 1fr; }
.report-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card, .stat, .report-card {
  background: var(--surface); border: 1px solid rgba(15, 39, 71, .06); border-radius: var(--radius); box-shadow: var(--shadow);
}
.stat { display: flex; gap: 14px; align-items: center; padding: 18px; }
.stat span, .card-head a { color: var(--muted); font-size: 13px; }
.stat strong { display: block; font-size: 22px; letter-spacing: -.03em; margin: 2px 0; }
.stat-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.green { background: #e7f8f1; color: var(--emerald); }
.stat-icon.red { background: #fdecef; color: var(--red); }
.stat-icon.blue { background: #e8f1fd; color: var(--blue); }
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--emerald); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--muted); }
.neg { color: var(--red); }
.card { padding: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.pill { background: #f1f5f9; color: var(--muted); border-radius: 999px; padding: 6px 10px; font-size: 12px; }
.quote-card { position: relative; overflow: hidden; min-height: 280px; border-radius: var(--radius); color: white; padding: 18px; }
.quote-card p { position: relative; z-index: 1; font-size: 18px; font-weight: 700; line-height: 1.45; text-shadow: 0 8px 24px rgba(0,0,0,.25); }
.quote-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.pos-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.pos-mini li { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; }
.tone { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.tone svg { width: 16px; height: 16px; }
.tone.green { background: #e7f8f1; color: #059669; }
.tone.blue { background: #e8f1fd; color: #2563eb; }
.tone.orange { background: #fff4e5; color: #d97706; }
.tone.purple { background: #f3e8ff; color: #7c3aed; }
.tone.teal { background: #e6fffb; color: #0f766e; }
.tone.red { background: #fdecef; color: #e11d48; }
.tone.navy { background: #e8eef8; color: #0f2747; }
.tone.slate { background: #f1f5f9; color: #475569; }
.legend-row { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; margin-top: 8px; }
.dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; }
.dot.green { background: #10b981; }
.dot.red { background: #fb7185; }
.donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 8px; align-items: center; }
.dist-list { list-style: none; margin: 0; padding: 0; }
.dist-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.table-wrap { overflow: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.grid td { padding: 12px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.grid tr:hover td { background: #fafcff; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kind.income { color: var(--emerald); font-weight: 700; }
.kind.expense { color: var(--red); font-weight: 700; }
.kind.transfer { color: var(--blue); font-weight: 700; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.badge.ok { background: #e7f8f1; color: #047857; }
.badge.warn { background: #fff7ed; color: #c2410c; }
.badge.bad { background: #fff1f2; color: #be123c; }
.badge.muted { background: #f1f5f9; color: #475569; }
.chip { background: #f8fafc; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; font-size: 12px; }
.name-cell { display: flex; align-items: center; gap: 8px; }
.actions, .btn-row { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.actions form { margin: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 12px; color: var(--muted); font-size: 13px; }
.pager-links { display: flex; gap: 6px; }
.page-btn { min-width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: white; border: 1px solid var(--line); color: var(--text); }
.page-btn.current { background: var(--emerald); color: white; border-color: var(--emerald); }
.page-btn.disabled { pointer-events: none; opacity: .4; }

.filters, .period-switch { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.period-switch a, .tabs a { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; color: var(--text); }
.period-switch a.on, .tabs a.on { background: var(--navy); color: white; border-color: var(--navy); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select, .form-card input, .form-card select, .form-card textarea, label input, label select, label textarea {
  width: 100%; background: white; border: 1px solid #dbe3ee; border-radius: 12px; padding: 10px 12px; outline: none;
}
.filters input:focus, .filters select:focus, .form-card input:focus, .form-card select:focus, .form-card textarea:focus { border-color: #86efac; box-shadow: 0 0 0 4px rgba(5,150,105,.12); }
.filters label.grow { flex: 1; min-width: 220px; position: relative; }
.filters label.grow svg { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; color: var(--muted); }
.filters label.grow input { padding-left: 34px; }
.btn { border: 1px solid var(--line); background: white; border-radius: 12px; padding: 10px 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-weight: 700; color: var(--text); }
.btn.primary { background: var(--emerald); border-color: var(--emerald); color: white; }
.btn.primary:hover { background: var(--emerald-dark); }
.btn.danger { color: var(--red); border-color: #fecdd3; }
.btn.tiny { padding: 6px 10px; }
.btn.ghost { width: 100%; justify-content: center; }
.btn svg { width: 16px; height: 16px; }
.form-card { display: grid; gap: 14px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
.inline { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.inline input { width: auto; }
fieldset { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 0 0 12px; }
.facts div { display: grid; gap: 2px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-weight: 700; }
.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.alert.ok { background: #ecfdf5; color: #065f46; }
.alert.bad { background: #fff1f2; color: #9f1239; }
.alert.warn { background: #fff7ed; color: #9a3412; }
.empty, .empty-card { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty-card { background: white; border-radius: var(--radius); margin: 40px auto; max-width: 520px; }
.footnote { color: var(--muted); font-size: 12px; margin-top: 12px; }
.summary-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.summary-row span { display: grid; }
.summary-row small { color: var(--muted); }
.report-card { padding: 16px; display: grid; gap: 6px; color: var(--text); min-height: 140px; }
.report-card svg { width: 22px; height: 22px; color: var(--emerald); }
.report-card span { color: var(--muted); font-size: 13px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.perm-grid h3 { grid-column: 1 / -1; }
.assumptions { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.timeline, .link-list { margin: 8px 0 0; padding-left: 18px; }
.pop { position: relative; }
.pop summary { list-style: none; }
.pop summary::-webkit-details-marker { display: none; }
.pop-panel { position: absolute; right: 0; top: 48px; width: 260px; background: white; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 12px; z-index: 5; display: grid; gap: 8px; }
.backdrop { display: none; }
.auth-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top, #e8fff4, var(--bg) 45%); }
.auth-card, .install-card { width: min(440px, calc(100% - 32px)); background: white; border-radius: 20px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.stack { display: grid; gap: 12px; }
.install-stats { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.print-body { background: #eef2f6; }
.print-toolbar { display: flex; gap: 8px; padding: 16px; }
.sheet { width: min(900px, 100%); margin: 0 auto 24px; background: white; padding: 32px; }
.letterhead { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--navy); padding-bottom: 12px; margin-bottom: 16px; }
.letter-title { text-align: right; }
.letter-title strong { display: block; color: var(--navy); font-size: 18px; }
table.plain { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
.plain th, .plain td { border-bottom: 1px solid #e5e7eb; padding: 8px; text-align: left; }
.signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 36px; text-align: center; }
.signs span { display: block; color: var(--muted); }
.signs strong { display: block; margin-top: 56px; border-top: 1px solid #cbd5e1; padding-top: 6px; }
.print-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.print-note, .print-summary { color: #475569; font-size: 12px; }
.narrow { max-width: 520px; }

@media (max-width: 1100px) {
  .stat-grid, .report-grid, .dash-mid, .dash-bot, .balance-grid, .detail-grid, .form-grid, .facts, .perm-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
  .donut-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; z-index: 20; transform: translateX(-105%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 15; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .stat-grid, .report-grid, .dash-mid, .dash-bot, .balance-grid, .detail-grid, .form-grid, .facts, .print-cols, .signs { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .page-intro { flex-direction: column; align-items: flex-start; }
  .today { display: none; }
}
@media print {
  .no-print { display: none !important; }
  body.print-body { background: white; }
  .sheet { width: auto; margin: 0; padding: 0; }
}
