:root {
  --blue: #1f4e78;
  --blue-2: #2f75b5;
  --light-blue: #d9e1f2;
  --sheet: #f8fbfd;
  --soft-gray: #f2f2f2;
  --line: #c7d2df;
  --text: #18222d;
  --muted: #66717d;
  --green: #008000;
  --red: #c00000;
  --pink: #f9d6e2;
  --cyan: #b8f9f9;
  --sky: #8fcbef;
  --mint: #a9f7d9;
  --shadow: 0 10px 30px rgba(31, 78, 120, .12);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: #e9eef4; }
body { margin: 0; min-height: 100vh; color: var(--text); font-family: Cambria, Georgia, serif; background: linear-gradient(135deg, #edf2f7, #dfe8f1); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); text-align: center; padding: 36px; }
.brand-mark { width: 74px; height: 74px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 18px; background: var(--blue); color: white; font-size: 42px; font-weight: 700; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; color: var(--blue); }
.login-card p { color: var(--muted); }
.stack-form { display: grid; gap: 15px; margin-top: 26px; text-align: left; }
label { display: grid; gap: 6px; font-size: 14px; color: #34495e; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #b8c7d6; border-radius: 7px; background: white; padding: 10px 12px; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(47,117,181,.13); }
textarea { resize: vertical; min-height: 84px; }
.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; background: var(--blue); color: white; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.topbar h1 { margin: 1px 0 0; font-size: 25px; }
.eyebrow { font-family: Arial, sans-serif; font-size: 11px; letter-spacing: .16em; font-weight: 800; opacity: .8; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-pill { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 7px 12px; font-family: Arial, sans-serif; font-size: 13px; }
.icon-btn { border: 0; background: rgba(255,255,255,.14); color: inherit; width: 38px; height: 38px; border-radius: 9px; font-size: 22px; }
.main-nav { position: fixed; left: 0; top: 76px; bottom: 0; width: 190px; padding: 18px 12px; background: #eef3f8; border-right: 1px solid #cbd7e2; z-index: 10; }
.nav-btn { width: 100%; border: 0; background: transparent; text-align: left; padding: 13px 14px; margin: 3px 0; border-radius: 8px; color: #385064; font-weight: 700; }
.nav-btn.active { background: var(--blue); color: white; box-shadow: 0 6px 14px rgba(31,78,120,.2); }
.content { margin-left: 190px; padding: 22px; }
.view-section { max-width: 1500px; margin: 0 auto; }
.excel-panel { background: var(--sheet); border: 1px solid #ccd7e2; border-radius: 9px; box-shadow: 0 5px 16px rgba(31,78,120,.08); overflow: hidden; }
.toolbar { display: flex; align-items: end; gap: 10px; padding: 12px; margin-bottom: 16px; }
.toolbar label { min-width: 115px; }
.toolbar input { min-width: 250px; }
.toolbar-spacer { flex: 1; }
.wrap { flex-wrap: wrap; }
.btn { border: 1px solid transparent; border-radius: 7px; padding: 10px 14px; font-weight: 800; white-space: nowrap; }
.btn.primary { background: var(--blue); color: white; }
.btn.success { background: #e7f5e7; color: #006b00; border-color: #9bd39b; }
.btn.danger { background: #fff0f0; color: #a00000; border-color: #e4aaaa; }
.btn.secondary { background: var(--soft-gray); color: #44515e; border-color: #c9d0d7; }
.btn.warning { background: #fff7dd; color: #7f5a00; border-color: #ead08b; }
.btn.small { padding: 6px 9px; font-size: 13px; }
.btn.wide { width: 100%; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { min-height: 112px; padding: 14px 16px; border-radius: 8px; border: 1px solid #cbd6e0; background: white; box-shadow: 0 4px 12px rgba(0,0,0,.05); }
.kpi:nth-child(1) { background: var(--mint); }
.kpi:nth-child(2) { background: var(--pink); }
.kpi:nth-child(3) { background: var(--cyan); }
.kpi:nth-child(4) { background: var(--sky); }
.kpi:nth-child(5) { background: var(--light-blue); }
.kpi-label { font-size: 13px; color: #425264; font-weight: 800; }
.kpi-value { margin-top: 12px; font-size: clamp(22px, 2vw, 31px); font-weight: 800; color: #14283a; }
.kpi-sub { margin-top: 5px; font-size: 12px; color: #526271; }
.dashboard-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; align-items: start; }
.span-2 { grid-row: span 2; }
.section-title { background: var(--blue); color: white; font-weight: 800; padding: 10px 13px; letter-spacing: .025em; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.table-wrap { overflow: auto; max-width: 100%; }
.excel-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.excel-table th { position: sticky; top: 0; z-index: 1; background: var(--light-blue); color: #1d3448; text-align: left; font-weight: 800; border-bottom: 1px solid #9fb2c5; padding: 9px 10px; white-space: nowrap; }
.excel-table td { padding: 8px 10px; border-bottom: 1px solid #e0e7ee; background: rgba(255,255,255,.7); vertical-align: middle; }
.excel-table tbody tr:hover td { background: #eef6fd; }
.excel-table .number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.excel-table .income { color: var(--green); font-weight: 700; }
.excel-table .expense { color: var(--red); font-weight: 700; }
.excel-table .total-row td { background: var(--soft-gray); font-weight: 800; border-top: 2px solid var(--blue); }
.excel-table .current-month td { background: #eaf3fb; font-weight: 700; }
.actions { display: flex; gap: 5px; justify-content: flex-end; white-space: nowrap; }
.badge { display: inline-block; border-radius: 999px; padding: 4px 8px; font-family: Arial, sans-serif; font-size: 11px; font-weight: 800; }
.badge.posted { background: #e4f5e4; color: #0b6b0b; }
.badge.planned, .badge.planned_date_missing { background: #fff3cd; color: #755600; }
.badge.date_missing { background: #ffe1e1; color: #9a1010; }
.margin-top { margin-top: 16px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.empty { text-align: center; padding: 28px; color: var(--muted); }
.subnav { display: flex; gap: 6px; padding: 10px; margin-bottom: 16px; }
.subnav-btn { border: 0; border-radius: 7px; padding: 9px 14px; background: transparent; color: #486174; font-weight: 800; }
.subnav-btn.active { background: var(--blue); color: white; }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid #d7e0e8; }
.modal { border: 0; padding: 0; border-radius: 12px; width: min(680px, calc(100% - 24px)); max-height: calc(100vh - 30px); box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.modal::backdrop { background: rgba(12, 28, 42, .55); backdrop-filter: blur(2px); }
.modal-card { margin: 0; }
.modal-header { display: flex; justify-content: space-between; align-items: center; background: var(--blue); color: white; padding: 15px 18px; }
.modal-header h2 { margin: 2px 0 0; }
.modal-body { padding: 18px; max-height: calc(100vh - 180px); overflow: auto; background: var(--sheet); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 13px 18px; background: white; border-top: 1px solid #d7e0e8; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.checkbox-row input { width: auto; }
.check-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; border: 1px solid #cbd7e2; border-radius: 7px; padding: 10px; max-height: 200px; overflow: auto; background: white; }
.toast { position: fixed; right: 18px; top: 92px; z-index: 100; max-width: min(420px, calc(100% - 36px)); padding: 12px 16px; border-radius: 8px; background: #193d5d; color: white; box-shadow: var(--shadow); }
.toast.error { background: #9a2222; }
.toast.success { background: #1f6f3b; }
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(150px,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .span-2 { grid-row: auto; }
}
@media (max-width: 760px) {
  body { background: #eef3f8; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .topbar { height: 64px; padding: 8px 14px; }
  .topbar h1 { font-size: 20px; }
  .user-pill { display: none; }
  .main-nav { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: auto; height: calc(64px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); padding: 5px 5px env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid #cbd7e2; box-shadow: 0 -4px 18px rgba(0,0,0,.12); }
  .nav-btn { text-align: center; padding: 8px 4px; margin: 0; font-size: 18px; }
  .nav-btn span { display: block; font-size: 10px; margin-top: 2px; }
  .content { margin-left: 0; padding: 10px; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .toolbar label, .toolbar input, .toolbar select { min-width: calc(50% - 6px); flex: 1; }
  .toolbar-spacer { display: none; }
  .toolbar .btn { flex: 1; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .kpi { min-height: 95px; padding: 11px; }
  .kpi-value { font-size: 21px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .check-list { grid-template-columns: 1fr; }
  .modal { width: calc(100% - 12px); max-height: calc(100vh - 12px); }
  .modal-body { max-height: calc(100vh - 160px); }
  .excel-table { min-width: 760px; }
  #accountsSummaryTable, #categoriesSummaryTable, #monthlyTable { min-width: 540px; }
}
