/* Layout: fixed left rail of registers (sidebar) + working desk; folders drawn as manila tabs. */
:root {
  --bg: #F2F4F3; --surface: #FFFFFF; --sunk: #E8ECEB; --ink: #17212A; --muted: #586570; --line: #D5DCDB;
  --accent: #0D6876; --accent-ink: #FFFFFF; --accent-soft: #DCEDEF;
  --folder: #C48526; --folder-soft: #F5E6CA;
  --ok: #2B7A4B; --ok-soft: #DCEFE2; --warn: #A86300; --warn-soft: #FAEACD; --bad: #B0281F; --bad-soft: #F7DDDA; --info: #37589C; --info-soft: #E0E6F4;
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161B; --surface: #172028; --sunk: #0C1115; --ink: #E4EAED; --muted: #93A1AC; --line: #283540;
    --accent: #4DB0BF; --accent-ink: #062428; --accent-soft: #15383E;
    --folder: #DFA449; --folder-soft: #382C18;
    --ok: #6CC690; --ok-soft: #163222; --warn: #E6A84A; --warn-soft: #382A13; --bad: #EF8A80; --bad-soft: #3B1C19; --info: #8EA8E2; --info-soft: #1B263E;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.2; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-size: .86em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .row2, .row3 { grid-template-columns: 1fr; } }

/* Boot + auth */
.boot { min-height: 100vh; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); }
.boot-mark { font: 700 1.6rem var(--f-display); color: var(--accent); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; gap: 14px; align-items: center; }
.auth-brand h1 { font-size: 1.4rem; }
.auth-brand p { color: var(--muted); font-size: .85rem; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--line); }
.auth-tab { flex: 1; background: none; border: 0; padding: 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.auth-tab.is-on { color: var(--ink); border-color: var(--accent); }
.auth-foot { font-size: .8rem; color: var(--muted); }
.seal { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 700 .95rem var(--f-display); flex: none; }

/* Fields + buttons */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
input, select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; min-width: 0; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form-msg { font-size: .88rem; min-height: 1.2em; color: var(--bad); }
.form-msg.ok { color: var(--ok); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 6px; padding: 8px 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .9rem; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.btn.bad { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.warn { color: var(--warn); border-color: var(--warn); background: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: .8rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; text-align: left; }
.linkbtn:hover { text-decoration: underline; }

/* App frame */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 20px; padding: 20px 14px 20px max(14px, env(safe-area-inset-left, 0px)); background: var(--surface); border-right: 1px solid var(--line); }
.nav-brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.nav-brand strong { font-family: var(--f-display); display: block; }
.nav-brand small { color: var(--muted); font-size: .76rem; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-list button { text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.nav-list button:hover { background: var(--sunk); color: var(--ink); }
.nav-list button.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count { background: var(--warn); color: var(--surface); border-radius: 10px; font-size: .72rem; padding: 1px 7px; }
.nav-user { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 6px 0; display: flex; flex-direction: column; gap: 10px; }
.nav-user strong { display: block; font-size: .9rem; }
.nav-user small { color: var(--muted); font-size: .78rem; }
.nav-user-actions { display: flex; gap: 6px; }
.main { padding: 28px max(16px, env(safe-area-inset-right, 0px)) 60px 32px; display: flex; flex-direction: column; gap: 24px; min-width: 0; outline: none; }
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-list { flex-direction: row; overflow-x: auto; width: 100%; order: 3; }
  .nav-list button { white-space: nowrap; }
  .nav-user { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center; }
  .nav-user > div:first-child { display: none; }
  .main { padding: 20px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
}

/* Page pieces */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-body { padding: 16px 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.kpi { background: var(--surface); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi b { font: 600 1.45rem var(--f-display); font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: .8rem; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--sunk); }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }

.pill { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap; background: var(--sunk); color: var(--muted); }
.pill.Pending, .pill.Draft, .pill.Ongoing { background: var(--warn-soft); color: var(--warn); }
.pill.Approved, .pill.Completed { background: var(--ok-soft); color: var(--ok); }
.pill.Rejected { background: var(--bad-soft); color: var(--bad); }
.pill.Returned, .pill.On-hold { background: var(--info-soft); color: var(--info); }
.pill.Urgent { background: var(--bad-soft); color: var(--bad); }

.bars { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.bar { display: grid; grid-template-columns: 18px 1fr 42px; gap: 8px; align-items: center; font-size: .78rem; }
.bar i { display: block; height: 7px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.bar i > s { display: block; height: 100%; border-radius: 4px; background: var(--accent); text-decoration: none; }
.bar.fin i > s { background: var(--folder); }
.bar.over i > s { background: var(--bad); }
.bar em { font-style: normal; color: var(--muted); font-weight: 600; }
.bar span { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 36px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; color: var(--muted); }
.empty h3 { color: var(--ink); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.list-item > div { min-width: 0; }
.list-item .t { font-weight: 600; overflow-wrap: anywhere; }
.list-item .s { color: var(--muted); font-size: .82rem; }

/* Project cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.pcard { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; cursor: pointer; display: flex; flex-direction: column; gap: 12px; }
.pcard:hover { border-color: var(--accent); }
.pcard-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pcard h3 { overflow-wrap: anywhere; }
.pcard .meta { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); gap: 8px; flex-wrap: wrap; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.is-on { color: var(--ink); border-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 5px 12px; font-size: .84rem; cursor: pointer; font-weight: 500; }
.chip.is-on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { width: auto; min-width: 180px; }

/* Folders: manila tabs */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px 14px; }
.folder { position: relative; background: var(--folder-soft); border: 1px solid var(--folder); border-radius: 0 8px 8px 8px; padding: 22px 14px 14px; text-align: left; cursor: pointer; margin-top: 12px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.folder::before { content: ""; position: absolute; top: -12px; left: -1px; width: 46%; height: 12px; background: var(--folder-soft); border: 1px solid var(--folder); border-bottom: 0; border-radius: 6px 6px 0 0; }
.folder:hover, .folder.is-on { background: var(--folder); color: var(--surface); }
.folder:hover::before, .folder.is-on::before { background: var(--folder); }
.folder b { font-weight: 600; }
.folder small { font-size: .78rem; opacity: .85; }

/* Noting sheet */
.noting { border-left: 3px solid var(--ok); background: var(--ok-soft); border-radius: 0 6px 6px 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.note { display: flex; flex-direction: column; gap: 2px; }
.note .who { font-size: .8rem; color: var(--muted); }
.note p { white-space: pre-wrap; overflow-wrap: anywhere; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .9rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.files { display: flex; flex-direction: column; gap: 6px; }
.file { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); min-width: 0; }
.file .ic { font: 600 .66rem var(--f-mono); background: var(--bad-soft); color: var(--bad); padding: 3px 5px; border-radius: 3px; flex: none; }
.file a { overflow-wrap: anywhere; font-weight: 500; }
.file .s { margin-left: auto; color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* Charts */
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr max-content; gap: 8px 12px; align-items: center; font-size: .86rem; }
.hbar i { display: block; height: 14px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.hbar i > s { display: block; height: 100%; background: var(--folder); text-decoration: none; }
.gauge { display: flex; flex-direction: column; gap: 14px; }
.gauge-row { display: flex; flex-direction: column; gap: 6px; }
.gauge-row header { display: flex; justify-content: space-between; font-size: .88rem; }
.gauge-row header b { font: 600 1.15rem var(--f-display); font-variant-numeric: tabular-nums; }
.gauge-row i { display: block; height: 12px; background: var(--sunk); border-radius: 6px; overflow: hidden; }
.gauge-row i > s { display: block; height: 100%; background: var(--accent); text-decoration: none; }
.gauge-row.fin i > s { background: var(--folder); }
.gauge-row.over i > s { background: var(--bad); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(10, 16, 20, .5); display: grid; place-items: center; z-index: 50; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.sheet { width: min(640px, 100%); max-height: 100%; overflow: auto; background: var(--surface); border-radius: 12px; border: 1px solid var(--line); }
.sheet.wide { width: min(900px, 100%); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sheet-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: minmax(0, 3fr) 80px 90px 120px 110px 32px; gap: 6px; align-items: center; }
.line .amt { text-align: right; font-variant-numeric: tabular-nums; font-size: .88rem; }
@media (max-width: 700px) { .line { grid-template-columns: 1fr 1fr 1fr; } .line > :first-child { grid-column: 1 / -1; } }
.hint { font-size: .82rem; color: var(--muted); }
.toast { position: fixed; bottom: max(20px, env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 8px; z-index: 60; font-size: .9rem; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: rise .16s ease-out; } @keyframes rise { from { transform: translateY(8px); opacity: .6; } } }
.rowbtn { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; color: inherit; font: inherit; }
.rowbtn:hover { background: var(--sunk); }
.rowside { text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; }