:root {
  color-scheme: light;
  --navy: #14213d;
  --navy-soft: #1d3157;
  --blue: #3156bc;
  --blue-dark: #2446a6;
  --ink: #182238;
  --muted: #6b7890;
  --line: #e4e9f1;
  --canvas: #f3f5f9;
  --white: #fff;
  --green: #18734e;
  --red: #b64040;
  --amber: #99600c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; overflow-y: auto; padding: 18px 13px 12px; background: var(--navy); color: #dbe5ff; }
.brand { display: flex; align-items: center; gap: 11px; margin: 3px 7px 22px; color: #fff; text-decoration: none; font-size: 17px; font-weight: 760; letter-spacing: -.3px; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; background: #3156bc; font-size: 22px; }
.brand small { display: block; margin-top: 3px; color: #9aadd8; font-size: 10px; font-weight: 450; letter-spacing: 0; }
.nav-group { margin: 0 0 15px; }
.nav-heading { padding: 0 11px 6px; color: #8396c1; font-size: 9px; font-weight: 750; letter-spacing: 1.1px; text-transform: uppercase; }
.navigation button { display: flex; align-items: center; gap: 10px; width: 100%; margin: 2px 0; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: #cbd6f3; text-align: left; transition: background .15s, color .15s; }
.navigation button:hover, .navigation button.active { background: #2a3e6c; color: #fff; }
.nav-icon { display: grid; width: 20px; place-items: center; color: #a9bbe7; font-size: 15px; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 14px 8px 4px; color: #a9b8d7; font-size: 10px; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #53c28d; box-shadow: 0 0 0 3px #53c28d22; }
.main-area { min-width: 0; }
.topbar { position: sticky; z-index: 4; top: 0; display: flex; height: 66px; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: #ffffffed; backdrop-filter: blur(12px); }
.topbar-context { display: flex; flex-direction: column; gap: 2px; }
.topbar-context strong { font-size: 13px; font-weight: 680; }
.eyebrow { color: #8995aa; font-size: 9px; font-weight: 760; letter-spacing: 1.1px; }
.topbar-actions { display: flex; align-items: center; gap: 13px; }
.data-badge { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 20px; background: #fff; color: #66738a; font-size: 11px; }
.data-badge span { color: #35a873; font-size: 8px; }
.avatar-button { display: grid; width: 33px; height: 33px; place-items: center; border: 0; border-radius: 50%; background: #e8edfb; color: #2446a6; font-weight: 750; }
.mobile-menu { display: none; border: 0; background: transparent; color: var(--navy); font-size: 19px; }
.page-content { width: min(100%, 1480px); min-height: calc(100vh - 66px); margin: 0 auto; padding: 27px 30px 44px; }
.auth-required .sidebar .navigation { opacity: .48; }
.auth-required .sidebar .navigation button { cursor: not-allowed; }
.auth-gate { width: min(100%, 680px); margin: min(12vh, 100px) auto; padding: clamp(24px, 5vw, 48px); border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: 0 18px 48px #14213d12; }
.auth-gate > .brand-mark { width: 48px; height: 48px; margin-bottom: 20px; color: #fff; font-size: 26px; }
.auth-gate h1 { margin: 10px 0; color: var(--navy); font-size: clamp(28px, 5vw, 40px); letter-spacing: -1px; }
.auth-gate > p { max-width: 520px; color: var(--muted); line-height: 1.65; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 21px; }
.page-heading h1 { margin: 0 0 5px; font-size: 25px; font-weight: 740; letter-spacing: -.7px; }
.page-heading p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.5; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; padding: 9px 13px; border: 1px solid transparent; border-radius: 8px; background: var(--blue-dark); color: #fff; font-weight: 650; transition: background .15s, transform .15s; }
.button:hover { background: #1c398c; transform: translateY(-1px); }
.button.secondary { border-color: #dbe2ed; background: #fff; color: #35425a; }
.button.secondary:hover { background: #f6f8fb; }
.button.danger { background: #b64040; }
.button.small { min-height: 31px; padding: 6px 9px; font-size: 12px; }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.card { margin-bottom: 15px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: 0 2px 7px #15274805; }
.card h2, .card h3 { margin: 0; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title-row h2, .card-title-row h3 { font-size: 15px; font-weight: 700; }
.muted, .field-hint { color: var(--muted); }
.small-text { font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 15px; }
.metric-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { overflow: hidden; margin: 9px 0 7px; font-size: clamp(18px, 2vw, 25px); font-weight: 760; letter-spacing: -.6px; text-overflow: ellipsis; white-space: nowrap; }
.metric-note { color: var(--muted); font-size: 11px; }
.status { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 20px; background: #e7f6ee; color: var(--green); font-size: 10px; font-weight: 670; white-space: nowrap; }
.status.warn { background: #fff3df; color: var(--amber); }
.status.danger { background: #fdecec; color: var(--red); }
.status.neutral { background: #edf1f7; color: #59667d; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, 1fr); gap: 15px; }
.chart-bars { display: flex; height: 172px; align-items: end; gap: 13px; padding: 15px 4px 0; border-bottom: 1px solid var(--line); }
.chart-column { display: flex; height: 100%; flex: 1; flex-direction: column; align-items: center; justify-content: end; gap: 7px; color: var(--muted); font-size: 10px; }
.chart-column .bar-pair { display: flex; width: 100%; height: 132px; align-items: end; justify-content: center; gap: 4px; }
.chart-bar { width: min(30%, 18px); min-height: 3px; border-radius: 5px 5px 0 0; background: #5272ce; }
.chart-bar.expense { background: #d8e0f7; }
.progress-track { height: 8px; overflow: hidden; margin: 12px 0 7px; border-radius: 9px; background: #edf0f5; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: #4a69c8; }
.budget-row { margin: 17px 0; }
.budget-row:first-of-type { margin-top: 10px; }
.budget-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.notice-card { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 9px; padding: 12px; border: 1px solid #f0dfb9; border-radius: 9px; background: #fff8e8; color: #78571a; line-height: 1.45; }
.notice-card.info { border-color: #dbe5fa; background: #f5f8ff; color: #405987; }
.notice-icon { font-size: 16px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 12px 9px; border-bottom: 1px solid #edf0f4; text-align: left; font-size: 12px; white-space: nowrap; }
th { color: #778398; font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.amount-positive { color: var(--green); font-weight: 700; }
.amount-negative { color: var(--red); font-weight: 700; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.icon-button { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #657187; font-size: 16px; }
.icon-button:hover { border-color: #c4d0e5; color: var(--blue-dark); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 13px; }
.toolbar input, .toolbar select, .form-control { min-height: 38px; padding: 8px 10px; border: 1px solid #dfe5ef; border-radius: 8px; outline: 0; background: #fff; color: var(--ink); }
.toolbar input:focus, .toolbar select:focus, .form-control:focus { border-color: #7b96dc; box-shadow: 0 0 0 3px #3156bc16; }
.toolbar input[type="search"] { min-width: min(260px, 100%); flex: 1; }
.empty-state { padding: 36px 15px; color: var(--muted); text-align: center; }
.empty-icon { margin-bottom: 10px; color: #9babc7; font-size: 27px; }
.empty-state strong { display: block; margin-bottom: 5px; color: #36435b; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-field { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { color: #445169; font-size: 11px; font-weight: 680; }
.form-field .form-control { width: 100%; }
.form-field textarea.form-control { min-height: 90px; resize: vertical; }
.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: none; align-items: center; justify-content: center; overflow-y: auto; padding: 20px; background: #0c1935a6; backdrop-filter: blur(3px); }
.modal-backdrop.visible { display: flex; }
.modal-card { width: min(100%, 560px); max-height: min(88vh, 780px); overflow: auto; border: 1px solid #e6eaf1; border-radius: 16px; background: #fff; box-shadow: 0 24px 80px #06112a45; animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-header { position: sticky; z-index: 1; top: 0; display: flex; align-items: flex-start; justify-content: space-between; padding: 19px 21px 14px; border-bottom: 1px solid #edf0f4; background: #fff; }
.modal-header h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.3px; }
.modal-header .icon-button { border: 0; font-size: 23px; }
.modal-body { padding: 18px 21px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 21px 19px; border-top: 1px solid #edf0f4; }
.modal-copy { margin: 0; color: #58667c; line-height: 1.6; }
.loading-overlay { position: fixed; z-index: 30; inset: 0; display: none; align-items: center; justify-content: center; background: #101d35a8; backdrop-filter: blur(4px); }
.loading-overlay.visible { display: flex; }
.loading-card { display: flex; width: min(280px, calc(100vw - 40px)); flex-direction: column; align-items: center; gap: 11px; padding: 25px 22px 23px; border: 1px solid #ffffff80; border-radius: 16px; background: #fff; box-shadow: 0 20px 70px #08132e50; }
.loading-mark { color: var(--blue); font-size: 29px; }
.loading-card strong { color: var(--navy); font-size: 15px; }
.loading-message { color: var(--muted); font-size: 12px; text-align: center; }
.spinner { width: 27px; height: 27px; border: 3px solid #e2e8f4; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.report-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.report-tile { padding: 13px; border-radius: 9px; background: #f5f7fb; }
.report-tile span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.report-tile strong { font-size: 15px; }
.file-input { padding: 11px; border: 1px dashed #bbc8de; border-radius: 9px; background: #f8faff; }
.mobile-nav-open .sidebar { box-shadow: 0 12px 35px #06112a2b; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-content { padding-right: 22px; padding-left: 22px; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: relative; z-index: 5; height: auto; max-height: 0; overflow: hidden; padding: 0 12px; transition: max-height .2s, padding .2s; }
  .mobile-nav-open .sidebar { max-height: 68vh; overflow-y: auto; padding: 12px; }
  .brand { margin: 0 6px 12px; }
  .sidebar-footer { display: none; }
  .nav-group { margin-bottom: 10px; }
  .navigation button { width: auto; min-width: max-content; }
  .navigation { display: flex; flex-direction: column; }
  .topbar { height: 58px; padding: 0 14px; }
  .topbar-context { flex-direction: row; align-items: center; gap: 10px; }
  .topbar-context .eyebrow { display: none; }
  .mobile-menu { display: inline-grid; place-items: center; }
  .data-badge { padding: 6px 8px; font-size: 10px; }
  .page-content { min-height: calc(100vh - 58px); padding: 19px 14px 34px; }
  .page-heading { display: block; }
  .heading-actions { margin-top: 13px; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .metric-grid { gap: 8px; }
  .metric-card { padding: 13px; }
  .metric-label { font-size: 10px; }
  .metric-value { font-size: 19px; }
  .card { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .report-summary { grid-template-columns: 1fr; }
  .topbar-actions { gap: 7px; }
  .page-heading h1 { font-size: 22px; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .heading-actions, .toolbar, .row-actions, .button, .icon-button, .loading-overlay, .modal-backdrop { display: none !important; }
  .app-shell { display: block; }
  .page-content { width: 100%; padding: 0; }
  .card, .metric-card { break-inside: avoid; border-color: #d7dce5; box-shadow: none; }
  .table-wrap { overflow: visible; }
  td, th { white-space: normal; }
}
