:root {
  --shell-bg: #f3f5f2;
  --sidebar-bg: #173c32;
  --sidebar-muted: #9eb4a8;
  --sidebar-active: #285447;
  --ink: #1d2b25;
  --muted-ink: #748078;
  --border: #e4e9e4;
  --surface: #fff;
  --accent: #28694f;
  --accent-soft: #eaf3ed;
  --expense: #b5524a;
  --income: #347b50;
}

[hidden] { display: none !important; }
body { background: var(--shell-bg); color: var(--ink); }
.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
  max-width: 1680px;
  margin: 0 auto;
  background: var(--shell-bg);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 560px;
  padding: 22px 15px 16px;
  color: #f4f7f4;
  background: var(--sidebar-bg);
  box-shadow: -8px 0 28px rgba(19, 47, 37, .08);
  z-index: 20;
}
.sidebar .brand { gap: 11px; padding: 0 7px 22px; color: #fff; text-decoration: none; }
.sidebar .brand-mark {
  width: 43px; height: 43px; border: 1px solid rgba(255,255,255,.17);
  border-radius: 13px; color: #173c32; background: #e4bd70;
  box-shadow: none; font-size: 23px;
}
.sidebar .brand strong { font-size: 18px; }
.sidebar .brand small { color: #adc1b5; font-size: 10px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 7px 0 16px; }
.nav-caption { margin: 12px 12px 7px; color: #9eb4a8; font-size: 9px; font-weight: 800; }
.nav-caption-spaced { margin-top: 21px; }
.nav-item {
  width: 100%; min-height: 42px; display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent; border-radius: 10px; padding: 8px 10px;
  color: #d7e3dc; background: transparent; text-align: right;
  font-size: 11px; font-weight: 700; transition: background .16s ease, color .16s ease;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.075); }
.nav-item.is-active { color: #fff; border-color: rgba(219, 239, 223, .12); background: var(--sidebar-active); }
.nav-item.is-group-active { color: #fff; }
.nav-icon { width: 22px; flex: 0 0 auto; color: #a9c5b4; font-size: 16px; text-align: center; }
.nav-item.is-active .nav-icon { color: #edcc83; }
.nav-label-text { flex: 1; }
.nav-balance { color: #aec4b7; font-size: 9px; font-weight: 600; white-space: nowrap; }
.nav-children {
  display: grid; gap: 2px; margin: 2px 0 8px 10px; padding: 3px 12px 3px 0;
  border-right: 1px solid rgba(205, 225, 211, .2);
}
.nav-item.nav-child { min-height: 35px; padding: 6px 9px; color: #bdcec3; font-size: 10px; }
.nav-item.nav-child.is-active { color: #fff; background: rgba(255,255,255,.1); }
.nav-child-dot { width: 5px; height: 5px; flex: 0 0 auto; border-radius: 50%; background: #81a894; }
.nav-child.is-active .nav-child-dot { background: #edcc83; }
.sidebar-footer { padding-top: 13px; border-top: 1px solid rgba(223, 239, 227, .13); }
.storage-label { display: flex; align-items: center; gap: 8px; margin: 0 4px 10px; color: #c3d3c8; font-size: 9px; }
.storage-label .status-dot { width: 6px; height: 6px; background: #73c18a; box-shadow: 0 0 0 3px rgba(115,193,138,.12); }
.sidebar-action {
  width: 100%; min-height: 34px; margin-top: 5px; border: 1px solid rgba(221,238,226,.13);
  border-radius: 8px; padding: 6px 9px; color: #d7e3dc; background: rgba(255,255,255,.035);
  text-align: right; font-size: 9px; font-weight: 700;
}
.sidebar-action:hover { color: #fff; background: rgba(255,255,255,.09); }
.sidebar-footer > small { display: block; margin: 9px 4px 0; color: #94aea0; font-size: 8px; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.workspace-header {
  position: sticky; top: 0; z-index: 10; min-height: 96px; display: flex; align-items: center;
  justify-content: space-between; gap: 18px; padding: 17px 30px;
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}
.header-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.workspace-header .eyebrow { margin-bottom: 1px; color: #a17b36; font-size: 9px; }
.workspace-header h1 { margin: 0; color: #1b3026; font-size: 20px; font-weight: 800; }
.header-subtitle { margin: 3px 0 0; color: #818b83; font-size: 10px; }
.workspace-header .button { min-height: 40px; white-space: nowrap; }
.menu-toggle { display: none; }
.content-page { width: 100%; flex: 1; margin: 0 auto; padding: 25px 30px 32px; }
.workspace-footer {
  display: flex; justify-content: space-between; gap: 12px; padding: 13px 30px;
  border-top: 1px solid var(--border); color: #87918a; background: #fff; font-size: 9px;
}
.workspace-footer span:first-child { color: var(--accent); font-weight: 800; }

.report-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 17px; }
.report-stat {
  position: relative; min-width: 0; min-height: 132px; display: flex; flex-direction: column;
  justify-content: center; gap: 5px; padding: 17px 19px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  box-shadow: 0 3px 10px rgba(30, 55, 39, .025);
}
.report-stat::after { position: absolute; inset: auto -25px -50px auto; width: 120px; height: 120px; border-radius: 50%; background: currentColor; content: ''; opacity: .035; }
.report-stat-primary { color: #28694f; border-color: #d8e6db; background: linear-gradient(125deg,#fff,#f3f8f2); }
.report-stat-income { color: var(--income); }
.report-stat-expense { color: var(--expense); }
.report-stat-neutral { color: #53677a; }
.report-stat-icon { position: absolute; top: 15px; left: 16px; width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; color: inherit; background: rgba(62, 129, 83, .09); font-size: 16px; }
.report-stat-label { color: #69766d; font-size: 10px; font-weight: 700; }
.report-stat > strong { color: #23382d; font-size: clamp(17px, 2vw, 23px); font-weight: 800; letter-spacing: -.02em; }
.report-stat > small { color: #8a948d; font-size: 9px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(285px, .85fr); gap: 15px; align-items: start; }
.panel {
  min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); box-shadow: 0 3px 12px rgba(30,55,39,.025);
}
.report-panel, .detail-panel { padding: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-heading .eyebrow { margin-bottom: 2px; font-size: 8px; }
.panel-heading h2 { margin: 0; color: #293a30; font-size: 14px; font-weight: 800; }
.panel-badge, .month-name { padding: 5px 8px; border-radius: 7px; color: #6c7d70; background: #f1f5f1; font-size: 8px; font-weight: 700; white-space: nowrap; }
.branch-summary-panel { grid-row: span 2; }
.branch-reports { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.branch-report { min-width: 0; padding: 12px; border: 1px solid #e8ede7; border-radius: 11px; background: #fbfcfa; }
.branch-report-heading { display: flex; justify-content: space-between; align-items: center; gap: 7px; padding-bottom: 10px; border-bottom: 1px solid #edf0ec; }
.branch-report-heading small { color: #8a968e; font-size: 8px; }
.branch-report-heading h3 { margin: 2px 0 0; color: #31483a; font-size: 11px; }
.branch-report-heading > strong { color: var(--accent); font-size: 12px; white-space: nowrap; }
.branch-report-children { display: grid; gap: 8px; padding-top: 10px; }
.branch-report-child { display: flex; justify-content: space-between; gap: 8px; color: #69756e; font-size: 9px; }
.branch-report-child strong { color: #33463a; font-weight: 700; white-space: nowrap; }
.main-rollup-report { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 13px; padding: 11px 12px; border-radius: 9px; color: #7a867d; background: #f4f7f3; font-size: 8px; }
.main-rollup-report span { display: flex; flex-direction: column; gap: 3px; }
.main-rollup-report > span[aria-hidden] { color: #9caa9f; font-size: 14px; font-weight: 800; }
.main-rollup-report span strong { color: #40594a; font-size: 9px; }
.main-rollup-report > strong { color: var(--accent); font-size: 9px; }
.month-panel { padding-bottom: 16px; }
.month-total { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 17px 0 13px; color: #6c7970; font-size: 10px; }
.month-total strong { color: #284c38; font-size: 16px; }
.month-bar { height: 9px; display: flex; gap: 3px; overflow: hidden; border-radius: 10px; background: #f0f3ef; }
.month-bar-income, .month-bar-expense, .month-bar-advance { flex: 0 0 auto; border-radius: 10px; }
.month-bar-income { background: #4c9a67; }
.month-bar-expense { background: #cc766b; }
.month-bar-advance { background: #d3a44d; }
.month-legend { display: grid; gap: 8px; margin-top: 13px; }
.month-legend span { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 7px; color: #7a867e; font-size: 9px; }
.month-legend strong { color: #46564b; font-size: 9px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.income-dot { background: #4c9a67; }
.expense-dot { background: #cc766b; }
.transfer-dot { background: #5783a1; }
.advance-dot { background: #d3a44d; }
.month-count { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid #edf0ec; color: #89938c; font-size: 8px; }
.recent-panel { grid-column: 2; }

.advance-list { display: grid; gap: 8px; }
.advance-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf0ec; }
.advance-row:last-child { border-bottom: 0; }
.advance-copy { min-width: 0; }
.advance-copy strong, .advance-copy small { display: block; }
.advance-copy strong { color: #34443a; font-size: 10px; }
.advance-copy small { margin-top: 3px; color: #88928b; font-size: 8px; line-height: 1.6; }
.advance-remaining { flex: 0 0 auto; color: #986d24; font-size: 10px; white-space: nowrap; }

.vault-page-stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; margin-bottom: 15px; }
.child-panel { margin-bottom: 15px; }
.child-vault-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.child-vault-card {
  width: 100%; min-width: 0; display: flex; align-items: center; gap: 10px;
  border: 1px solid #e6ebe6; border-radius: 10px; padding: 11px;
  color: inherit; background: #fbfcfa; text-align: right; transition: .15s ease;
}
.child-vault-card:hover { border-color: #b4cbb9; background: #f5f9f4; transform: translateY(-1px); }
.child-vault-icon { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; color: var(--accent); background: #e9f2eb; font-size: 14px; }
.child-vault-copy { flex: 1; min-width: 0; }
.child-vault-copy strong, .child-vault-copy small { display: block; }
.child-vault-copy strong { color: #2d4034; font-size: 10px; }
.child-vault-copy small { margin-top: 2px; color: #88938b; font-size: 8px; }
.child-vault-balance { color: var(--accent); font-size: 10px; font-weight: 800; white-space: nowrap; }
.child-vault-arrow { color: #9aa79d; font-size: 13px; }
.activity-panel { padding-bottom: 9px; }
.activity-hint { margin: -5px 0 10px; color: #849087; font-size: 9px; line-height: 1.7; }
.movement-list { overflow: hidden; }
.movement-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 3px; border-bottom: 1px solid #edf0ed; }
.movement-row:last-child { border-bottom: 0; }
.movement-main { min-width: 0; display: flex; align-items: center; gap: 9px; }
.movement-icon { width: 31px; height: 31px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; font-size: 14px; font-weight: 800; }
.movement-icon.deposit { color: #35784d; background: #eaf4eb; }
.movement-icon.withdrawal { color: #ab5149; background: #f8edeb; }
.movement-description { min-width: 0; }
.movement-description strong { display: block; overflow: hidden; color: #34443a; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.movement-description small { display: block; margin-top: 3px; color: #88928b; font-size: 8px; }
.movement-side { display: flex; align-items: center; gap: 8px; }
.movement-amount { white-space: nowrap; font-size: 10px; font-weight: 800; }
.movement-amount.deposit { color: var(--income); }
.movement-amount.withdrawal { color: var(--expense); }
.delete-movement { border: 0; border-radius: 6px; padding: 5px 7px; color: #a05c54; background: transparent; font-size: 8px; }
.delete-movement:hover { background: #faefed; }
.empty-state { padding: 28px 12px; color: #869188; text-align: center; }
.empty-icon { width: 34px; height: 34px; display: grid; place-items: center; margin: 0 auto 8px; border-radius: 10px; color: #61806a; background: #eff5ef; font-size: 15px; }
.empty-state strong { display: block; color: #5e6d62; font-size: 10px; }
.empty-state p { margin: 4px 0 0; font-size: 8px; }
.direct-totals { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 10px; margin-top: 6px; padding: 11px 3px 3px; border-top: 1px solid #edf0ec; }
.direct-totals span { display: flex; gap: 5px; color: #849087; font-size: 8px; }
.direct-totals strong { color: #4b5e50; }

.sidebar-backdrop { display: none; }
.menu-toggle { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 9px; color: #476151; background: #fff; font-size: 15px; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 248px minmax(0,1fr); }
  .content-page { padding-right: 22px; padding-left: 22px; }
  .workspace-header { padding-right: 22px; padding-left: 22px; }
  .report-stat-grid { gap: 10px; }
  .report-stat { padding-right: 14px; padding-left: 14px; }
  .dashboard-grid { grid-template-columns: minmax(0,1fr) minmax(260px,.85fr); }
}

@media (max-width: 880px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed; right: 0; top: 0; width: min(292px, calc(100vw - 42px)); height: 100dvh;
    min-height: 0; transform: translateX(105%); transition: transform .22s ease;
    box-shadow: -12px 0 32px rgba(15,35,27,.2);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 19; display: block; border: 0;
    background: rgba(15,30,23,.4); opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .menu-toggle { display: grid; place-items: center; flex: 0 0 auto; }
  .workspace-header { min-height: 82px; padding: 13px 18px; }
  .content-page { padding: 18px; }
  .workspace-footer { padding-right: 18px; padding-left: 18px; }
  .dashboard-grid { grid-template-columns: minmax(0,1fr) minmax(245px,.8fr); gap: 11px; }
  .report-panel, .detail-panel { padding: 14px; }
}

@media (max-width: 640px) {
  .workspace-header { min-height: 75px; padding: 11px 13px; }
  .workspace-header h1 { font-size: 16px; }
  .header-subtitle { max-width: 250px; font-size: 8px; }
  .workspace-header .button { min-height: 36px; gap: 5px; padding: 0 9px; font-size: 9px; }
  .content-page { padding: 13px; }
  .report-stat-grid { grid-template-columns: 1fr; gap: 8px; }
  .report-stat { min-height: 94px; padding: 13px 15px; }
  .report-stat > strong { font-size: 19px; }
  .report-stat-icon { top: 12px; left: 12px; width: 28px; height: 28px; }
  .dashboard-grid { grid-template-columns: minmax(0,1fr); }
  .branch-summary-panel, .recent-panel { grid-column: auto; grid-row: auto; }
  .branch-reports { grid-template-columns: 1fr; }
  .main-rollup-report { justify-content: flex-start; }
  .vault-page-stats { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .child-vault-grid { grid-template-columns: 1fr; }
  .panel-heading h2 { font-size: 12px; }
  .workspace-footer { padding: 11px 13px; font-size: 8px; }
  .workspace-footer span:last-child { text-align: left; }
}

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