:root {
  --bg-primary: #FFFFFF; --bg-secondary: #F5F5F7; --bg-tertiary: #E8E8ED; --bg-elevated: rgba(255,255,255,.72);
  --text-primary: #1D1D1F; --text-secondary: #6E6E73; --text-tertiary: #86868B;
  --border-light: rgba(0,0,0,.06); --border-medium: rgba(0,0,0,.12);
  --accent: #0A5C4A; --accent-hover: #084A3B; --accent-light: rgba(10,92,74,.09); --accent-lighter: rgba(10,92,74,.04);
  --success: #34C759; --warning: #FF9500; --error: #FF3B30; --info: #5AC8FA;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.03);
  --shadow-md: 0 4px 6px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.03);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.06), 0 4px 10px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 50px rgba(0,0,0,.08), 0 8px 20px rgba(0,0,0,.05);
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px; --radius-full: 9999px;
  --zoho: #0A5C4A; --manual: #B45309; --calc: #4B5563;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text-primary); background: var(--bg-secondary); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }
.icon { width: 18px; height: 18px; stroke-width: 1.75; flex: none; }
.icon-sm { width: 15px; height: 15px; stroke-width: 1.75; }
.muted { color: var(--text-secondary); }
.tiny { font-size: 12px; color: var(--text-tertiary); }
.mono { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ── Login ─────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, rgba(10,92,74,.10), transparent 60%), var(--bg-secondary); }
.login-card { width: 100%; max-width: 400px; background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); padding: 36px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: -.02em; }
.brand-title { font-weight: 700; letter-spacing: -.01em; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--text-tertiary); letter-spacing: .02em; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-secondary); letter-spacing: .02em; }
.input, select.input, textarea.input { width: 100%; padding: 10px 14px; font-size: 14px; font-family: inherit; color: var(--text-primary); background: var(--bg-primary); border: 1px solid var(--border-medium); border-radius: var(--radius-sm); outline: none; transition: all .2s ease; }
.input:hover { border-color: rgba(0,0,0,.2); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.error-box { background: rgba(255,59,48,.08); color: #D70015; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: var(--radius-full); padding: 9px 18px; font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; cursor: pointer; transition: all .2s ease; border: 1px solid transparent; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: scale(1.02); box-shadow: 0 4px 12px rgba(10,92,74,.3); }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { background: var(--bg-primary); color: var(--text-primary); border-color: var(--border-medium); font-weight: 500; }
.btn-secondary:hover { background: var(--bg-tertiary); }
.btn-ghost { background: transparent; color: var(--text-secondary); font-weight: 500; padding: 7px 12px; }
.btn-ghost:hover { background: rgba(0,0,0,.05); color: var(--text-primary); }
.btn-danger { background: rgba(255,59,48,.1); color: #D70015; }
.btn-danger:hover { background: rgba(255,59,48,.18); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn .icon { width: 16px; height: 16px; }

/* ── Layout ────────────────────────────────────────────── */
.app { display: flex; height: 100vh; }
.sidebar { width: 268px; flex: none; background: var(--bg-secondary); border-right: 1px solid var(--border-light); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar .brand { margin: 4px 8px 16px; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); padding: 14px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text-secondary); cursor: pointer; transition: all .15s ease; text-decoration: none; }
.nav-item:hover { background: rgba(0,0,0,.04); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-item .icon { opacity: .7; }
.nav-item.active .icon { opacity: 1; }
.nav-item .pill { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: var(--radius-full); background: rgba(255,59,48,.12); color: #D70015; }
.nav-item .pill.ok { background: rgba(52,199,89,.14); color: #248A3D; }
.main { flex: 1; overflow-y: auto; padding: 32px 40px 80px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.topbar .title-block { display: flex; flex-direction: column; gap: 4px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.week-picker { display: flex; align-items: center; gap: 6px; background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: var(--radius-full); padding: 4px 6px; box-shadow: var(--shadow-sm); margin: 0 8px 8px; }
.week-picker button { border: none; background: transparent; width: 30px; height: 30px; border-radius: var(--radius-full); display: grid; place-items: center; cursor: pointer; color: var(--text-secondary); }
.week-picker button:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.week-picker .wk { flex: 1; text-align: center; font-size: 13px; font-weight: 600; letter-spacing: -.01em; cursor: pointer; }
.week-picker input[type=date] { position: absolute; opacity: 0; width: 0; height: 0; }
.user-box { margin-top: auto; padding: 12px; border-top: 1px solid var(--border-light); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: var(--radius-full); background: var(--accent-light); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-box .who { flex: 1; min-width: 0; }
.user-box .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Cards / stats ─────────────────────────────────────── */
.card { background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 24px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head .sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.stat .label { font-size: 12.5px; font-weight: 500; color: var(--text-tertiary); letter-spacing: .02em; margin-bottom: 6px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .change { font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--radius-full); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.badge-success { background: rgba(52,199,89,.12); color: #248A3D; }
.badge-warning { background: rgba(255,149,0,.12); color: #C93400; }
.badge-error { background: rgba(255,59,48,.12); color: #D70015; }
.badge-info { background: var(--accent-light); color: var(--accent); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ── Tables ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-light); border-radius: var(--radius-md); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-tertiary); border-bottom: 1px solid var(--border-light); background: var(--bg-secondary); white-space: nowrap; }
.table td { padding: 6px 12px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--accent-lighter); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.label { font-weight: 500; white-space: nowrap; }
.table tfoot td { background: var(--bg-secondary); font-weight: 600; border-top: 1px solid var(--border-medium); }
.cell { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; width: 100%; }
.cell input { width: 100%; min-width: 72px; max-width: 150px; padding: 6px 8px; font: inherit; font-variant-numeric: tabular-nums; text-align: right; border: 1px solid transparent; background: rgba(180,83,9,.05); border-radius: 6px; outline: none; transition: all .15s ease; color: var(--text-primary); }
.cell input[type=text], .cell input[type=date] { text-align: left; min-width: 120px; max-width: none; }
.cell input:hover { border-color: var(--border-medium); }
.cell input:focus { border-color: var(--manual); box-shadow: 0 0 0 3px rgba(180,83,9,.12); background: #fff; }
.cell.saving input { background: rgba(255,149,0,.12); }
.cell input.wide { min-width: 220px; }
.z { color: var(--zoho); font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.z:hover { background: var(--accent-light); }
.z.ovr { color: var(--manual); text-decoration: underline dotted; }
.z.empty { color: var(--text-tertiary); font-weight: 400; }
.z.unmapped { color: #C93400; font-weight: 500; font-size: 12px; cursor: help; }
.calc { color: var(--calc); font-weight: 600; }
.flag { color: #D70015; background: rgba(255,59,48,.1); border-radius: 6px; padding: 3px 7px; }
.money::before { content: '₦'; color: var(--text-tertiary); margin-right: 2px; font-weight: 400; }
.src { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.src.zoho { background: var(--zoho); } .src.manual { background: var(--manual); } .src.calc { background: var(--calc); }
.section-note { font-size: 12.5px; color: var(--text-secondary); background: var(--bg-secondary); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; }
.section-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.remarks { margin-top: 14px; }
.remarks textarea { min-height: 64px; resize: vertical; background: rgba(180,83,9,.04); }
.cash-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 16px; padding: 14px 16px; background: var(--bg-secondary); border-radius: var(--radius-md); }
.cash-box .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); font-weight: 600; }
.cash-box .v { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.row-tools { opacity: 0; transition: opacity .15s; }
tr:hover .row-tools { opacity: 1; }
.iconbtn { border: none; background: transparent; cursor: pointer; color: var(--text-tertiary); padding: 4px; border-radius: 6px; display: inline-grid; place-items: center; }
.iconbtn:hover { background: rgba(0,0,0,.06); color: var(--text-primary); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 10px; border-radius: var(--radius-full); background: var(--accent-light); color: var(--accent); font-size: 12px; font-weight: 500; }
.chip button { border: none; background: transparent; color: inherit; cursor: pointer; padding: 0; line-height: 1; font-size: 14px; }
.chip.warn { background: rgba(255,149,0,.12); color: #C93400; }
.progress { height: 6px; border-radius: 3px; background: var(--bg-tertiary); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }

/* ── Tabs ──────────────────────────────────────────────── */
.tabs { display: inline-flex; gap: 2px; background: var(--bg-tertiary); padding: 3px; border-radius: var(--radius-full); margin-bottom: 24px; flex-wrap: wrap; }
.tab { border: none; background: transparent; padding: 7px 16px; border-radius: var(--radius-full); font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: all .2s ease; }
.tab.active { background: var(--bg-primary); color: var(--text-primary); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ── Popover / modal / toast ───────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.3); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn .2s ease; padding: 16px; }
.modal { background: var(--bg-primary); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; padding: 28px; animation: slideUp .3s cubic-bezier(.16,1,.3,1); }
.modal.wide { max-width: 860px; }
.modal h3 { margin-bottom: 6px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }
.toast-host { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 1100; }
.toast { background: #1D1D1F; color: #fff; padding: 10px 16px; border-radius: var(--radius-md); font-size: 13px; box-shadow: var(--shadow-lg); animation: slideUp .25s cubic-bezier(.16,1,.3,1); display: flex; align-items: center; gap: 10px; }
.toast.err { background: #D70015; }
.toast.ok { background: var(--accent); }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--bg-tertiary); padding: 1px 6px; border-radius: 4px; }
pre.log { background: #1D1D1F; color: #E8E8ED; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; padding: 14px 16px; border-radius: var(--radius-md); max-height: 360px; overflow: auto; white-space: pre-wrap; margin: 0; }
.empty { text-align: center; padding: 48px 24px; color: var(--text-tertiary); }
.empty .icon { width: 44px; height: 44px; stroke-width: 1.25; margin-bottom: 12px; opacity: .6; }
.list-search { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 50; max-height: 260px; overflow: auto; }
.suggest div { padding: 8px 12px; cursor: pointer; font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
.suggest div:hover { background: var(--accent-lighter); }
.suggest small { color: var(--text-tertiary); }
.toc { position: sticky; top: 0; z-index: 5; background: var(--bg-elevated); backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--border-light); border-radius: var(--radius-full); padding: 6px 10px; display: flex; gap: 4px; overflow-x: auto; margin-bottom: 24px; }
.toc a { white-space: nowrap; font-size: 12.5px; padding: 5px 11px; border-radius: var(--radius-full); color: var(--text-secondary); }
.toc a:hover { background: rgba(0,0,0,.05); color: var(--text-primary); }
.toc a.hot { color: #D70015; }
.mobile-bar { display: none; }

@media (max-width: 900px) {
  .app { flex-direction: column; height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-light); max-height: 45vh; }
  .main { padding: 20px 16px 60px; }
  .modal { padding: 20px; }
}
@media print {
  .sidebar, .actions, .toc, .toast-host, .row-tools, .week-picker { display: none !important; }
  .app { display: block; } .main { padding: 0; overflow: visible; }
  .card { break-inside: avoid; box-shadow: none; }
  .cell input { border: none; background: transparent; }
  body { background: #fff; }
}
