/* Layout: the app sits in a container; container queries switch it between the computer layout (sidebar) and the phone layout (bottom tabs), so the Phone switch and a real phone both get the phone layout. */
:root {
  --bg: #F3F4F7; --surface: #FFFFFF; --surface2: #F7F8FA; --fg: #141A2B; --muted: #596075; --faint: #8A90A2; --line: #E1E4EB; --line2: #EDEFF3;
  --ink: #1F2A44; --ink2: #2B3A5E; --bone: #F4F1E8; --kiln: #D08A2E; --ember: #EDB04A; --canopy: #2E7D4F; --link: #1F2A44; --accent-text: #A8661A;
  --c-bg: #E3E8F4; --c-fg: #2B3A5E; --a-bg: #FDF0DA; --a-fg: #8A5200; --in-bg: #DDF0E4; --in-fg: #1E5E3A; --out-bg: #F1E4F5; --out-fg: #6B2C7A; --it-bg: #DCEFF1; --it-fg: #0F5862;
  --bad-bg: #FBE4DE; --bad-fg: #9E2F18; --ok-bg: #DDF0E4; --ok-fg: #1E5E3A; --warn-bg: #FFF8EC; --warn-line: #F1D9AE; --ai-bg: #EEEAFB; --ai-fg: #4B3A9A;
  --stage: #E4E7EE; --shadow: 0 10px 30px rgba(20, 26, 43, .10);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1322; --surface: #161E33; --surface2: #1B2440; --fg: #E8EBF2; --muted: #A2AABD; --faint: #7D869C; --line: #27314B; --line2: #212A42; --link: #F0C16E; --accent-text: #EDB04A;
  --c-bg: #24304F; --c-fg: #C9D4F0; --a-bg: #3A2E17; --a-fg: #F3C77A; --in-bg: #18382A; --in-fg: #96DDB2; --out-bg: #36223F; --out-fg: #E2B5F0; --it-bg: #12363B; --it-fg: #8FD6DE;
  --bad-bg: #44231D; --bad-fg: #F6A994; --ok-bg: #18382A; --ok-fg: #96DDB2; --warn-bg: #2E2616; --warn-line: #5A4724; --ai-bg: #2A2550; --ai-fg: #C9BEFF;
  --stage: #0A0E1A; --shadow: 0 10px 30px rgba(0, 0, 0, .35); color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0E1322; --surface: #161E33; --surface2: #1B2440; --fg: #E8EBF2; --muted: #A2AABD; --faint: #7D869C; --line: #27314B; --line2: #212A42; --link: #F0C16E; --accent-text: #EDB04A;
  --c-bg: #24304F; --c-fg: #C9D4F0; --a-bg: #3A2E17; --a-fg: #F3C77A; --in-bg: #18382A; --in-fg: #96DDB2; --out-bg: #36223F; --out-fg: #E2B5F0; --it-bg: #12363B; --it-fg: #8FD6DE;
  --bad-bg: #44231D; --bad-fg: #F6A994; --ok-bg: #18382A; --ok-fg: #96DDB2; --warn-bg: #2E2616; --warn-line: #5A4724; --ai-bg: #2A2550; --ai-fg: #C9BEFF;
  --stage: #0A0E1A; --shadow: 0 10px 30px rgba(0, 0, 0, .35); color-scheme: dark }

* { box-sizing: border-box }
html, body { height: 100% }
body { background: var(--stage); color: var(--fg); font: 500 14px/1.5 var(--font); margin: 0 }
button, input, select, textarea { font: inherit; color: inherit }
a { color: var(--link) }
h1, h2, h3 { margin: 0; text-wrap: balance; letter-spacing: -.01em }
:focus-visible { outline: 2px solid var(--kiln); outline-offset: 2px }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }

/* top strip with the computer / phone switch */
.proto-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: #0B0F1A; color: #DDE2EE; font-size: 13px }
.proto-bar b { color: #fff }
.seg { display: inline-flex; background: #1C2335; border-radius: 999px; padding: 3px }
.seg button { border: 0; background: transparent; color: #C4CAD8; padding: 6px 14px; border-radius: 999px; font-weight: 700; cursor: pointer; min-height: 32px }
.seg button[aria-pressed="true"] { background: var(--bone); color: #1F2A44 }

#root { height: 100%; display: flex; flex-direction: column }
.proto-bar { flex: none }
.stagewrap { padding: 0; display: flex; justify-content: center; flex: 1; min-height: 0 }
.stagewrap.phone { overflow: auto; align-items: flex-start }
.stagewrap.phone { padding: 24px 16px 40px }
.device { width: 100%; container-type: inline-size; container-name: app; background: var(--bg); height: 100%; position: relative; overflow: hidden }
.scroller { height: 100%; overflow-y: auto; overflow-x: hidden }
.stagewrap.phone .device { width: 390px; max-width: 100%; height: 844px; flex: none; border-radius: 36px; border: 10px solid #0B0F1A; box-shadow: 0 30px 60px rgba(0, 0, 0, .35) }

/* app shell */
.app { display: flex; min-height: 100% }
.side { width: 248px; flex: none; background: var(--ink); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; align-self: flex-start; height: calc(100vh - 52px); overflow-y: auto }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; background: none; border: 0; color: inherit; cursor: pointer; text-align: left }
.brand b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.02em }
.brand small { display: block; font-size: 12px; font-weight: 600; color: #A7AEC0 }
.brand small span { color: var(--ember) }
.nav { display: flex; flex-direction: column; gap: 3px }
.nav button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #C9CFDC; background: none; border: 0; font-weight: 600; font-size: 14px; cursor: pointer; text-align: left; min-height: 44px }
.nav button:hover { background: var(--ink2); color: #fff }
.nav button[aria-current="page"] { background: var(--bone); color: var(--ink) }
.nav .count { margin-left: auto; background: var(--kiln); color: #1F2A44; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 7px }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--ink2) }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--kiln); color: #1F2A44; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none }
.main { flex: 1; min-width: 0; padding: 28px 36px 60px; display: flex; flex-direction: column; gap: 22px }
.tabbar { display: none }
.mhead { display: none }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .05em; text-transform: uppercase }
.h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center }
.grow { flex: 1; min-width: 0 }
.cols { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start }
.cols > * { min-width: 0 }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; min-width: 0 }
.card h2 { font-size: 17px; font-weight: 800 }
.cardhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap }
.muted { color: var(--muted) }
.small { font-size: 12px }
.tnum { font-variant-numeric: tabular-nums }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 14px; border-radius: 10px; padding: 9px 15px; min-height: 44px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--fg); text-decoration: none; white-space: nowrap }
.btn:hover { border-color: var(--kiln) }
.btn.pri { background: var(--ink); color: #fff; border-color: var(--ink) }
:root[data-theme="dark"] .btn.pri { background: var(--bone); color: #1F2A44; border-color: var(--bone) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.pri { background: var(--bone); color: #1F2A44; border-color: var(--bone) } }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13px }
.btn.ghost { border-color: transparent; background: transparent }
.btn:disabled { opacity: .5; cursor: not-allowed }
.link { background: none; border: 0; padding: 0; color: var(--link); font-weight: 700; cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 3px }
.icon { width: 18px; height: 18px; flex: none }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: var(--surface2); color: var(--muted) }
.k-c { background: var(--c-bg); color: var(--c-fg) } .k-a { background: var(--a-bg); color: var(--a-fg) } .k-in { background: var(--in-bg); color: var(--in-fg) } .k-out { background: var(--out-bg); color: var(--out-fg) } .k-it { background: var(--it-bg); color: var(--it-fg) }
.bad { background: var(--bad-bg); color: var(--bad-fg) } .ok { background: var(--ok-bg); color: var(--ok-fg) } .ai { background: var(--ai-bg); color: var(--ai-fg) }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer; color: var(--fg) }
.kpi:hover { border-color: var(--kiln) }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums }
.kpi .v small { font-size: 16px; color: var(--faint) }
.up { color: var(--canopy); font-weight: 700 } .down { color: #B4541E; font-weight: 700 }
:root[data-theme="dark"] .up { color: #7FD3A0 } :root[data-theme="dark"] .down { color: #F0A070 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .up { color: #7FD3A0 } :root:not([data-theme="light"]) .down { color: #F0A070 } }

.list { display: flex; flex-direction: column }
.li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line2) }
.li:first-child { border-top: 0 }
.li .t { font-weight: 700 }
.li .d { font-size: 13px; color: var(--muted) }
.when { min-width: 96px; justify-content: center }

.ftype { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: 10px; font-weight: 800; flex: none }
.f-pdf { background: var(--bad-bg); color: var(--bad-fg) } .f-doc { background: var(--c-bg); color: var(--c-fg) } .f-xls { background: var(--ok-bg); color: var(--ok-fg) } .f-img { background: var(--a-bg); color: var(--a-fg) }

table { width: 100%; border-collapse: collapse; font-size: 14px }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px; font-weight: 700 }
td { padding: 11px 8px; border-top: 1px solid var(--line2); vertical-align: middle }
.scrollx { overflow-x: auto }
tr.click { cursor: pointer } tr.click:hover td { background: var(--surface2) }

.tabs { display: flex; flex-wrap: wrap; gap: 8px }
.tabs button { min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer }
.tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink) }
:root[data-theme="dark"] .tabs button[aria-pressed="true"] { background: var(--bone); color: #1F2A44 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabs button[aria-pressed="true"] { background: var(--bone); color: #1F2A44 } }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; color: var(--muted); min-width: 0 }
.field input, .field select, .field textarea { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; background: var(--surface); color: var(--fg); width: 100% }
.field textarea { min-height: 80px; resize: vertical }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; min-height: 44px; width: 300px; max-width: 100%; position: relative }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 14px; font-weight: 600; min-height: 42px }
.results { position: absolute; top: 48px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 20; max-height: 360px; overflow-y: auto; padding: 6px }
.results button { display: flex; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; align-items: center }
.results button:hover { background: var(--surface2) }

/* calendar */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px }
.dow { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 4px }
.day { min-height: 98px; padding: 6px; border: 1px solid var(--line2); border-radius: 10px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer; min-width: 0; color: var(--fg) }
.day:hover { border-color: var(--kiln) }
.day.out { background: var(--surface2) } .day.out .n { color: var(--faint) }
.day.sel { border: 2px solid var(--ink) }
:root[data-theme="dark"] .day.sel { border-color: var(--ember) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .day.sel { border-color: var(--ember) } }
.day.today .n { background: var(--kiln); color: #1F2A44; border-radius: 999px; padding: 0 7px }
.day .n { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; align-self: flex-start }
.ev { font-size: 11.5px; font-weight: 600; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.ev.done { text-decoration: line-through; opacity: .6 }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block }
.filters label { cursor: pointer; padding: 7px 12px }
.filters input { margin: 0 }

/* documents */
.doclayout { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap }
.sites { flex: 0 0 250px; padding: 14px }
.sites button.site { display: flex; width: 100%; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; font-weight: 700; text-align: left; color: var(--fg) }
.sites button.lib { display: flex; width: 100%; gap: 8px; align-items: center; padding: 7px 10px 7px 30px; border-radius: 8px; border: 0; background: none; cursor: pointer; text-align: left; font-weight: 600; color: var(--muted) }
.sites button:hover { background: var(--surface2) }
.sites button[aria-current="true"] { background: var(--c-bg); color: var(--c-fg) }
.banner { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 14px; background: var(--ai-bg); color: var(--ai-fg) }
.banner b { color: var(--ai-fg) }

/* document page and reader */
.paper { background: #FFFFFF; color: #2A2F3D; border-radius: 6px; padding: 30px 30px; box-shadow: 0 2px 10px rgba(20, 26, 43, .14); font-family: Georgia, 'Times New Roman', serif; font-size: 13px; line-height: 1.7; display: flex; flex-direction: column; gap: 10px }
.paper .hl { background: #FDF0DA; outline: 2px solid #D08A2E; border-radius: 3px }
.check { padding: 12px; border-radius: 10px; background: var(--warn-bg); border: 1px solid var(--warn-line); display: flex; flex-direction: column; gap: 6px }
.check.done { background: var(--surface2); border-color: var(--line) }
.quote { font-size: 12px; color: var(--muted) }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; font-size: 14px }
.kv span { color: var(--muted) }

/* modal and toast */
.scrim { position: absolute; inset: 0; background: rgba(10, 14, 26, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50 }
.device { position: relative }
.modal { background: var(--surface); border-radius: 18px; width: 620px; max-width: 100%; max-height: calc(100% - 32px); overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow) }
.modal h2 { font-size: 20px; font-weight: 800 }
.steps { display: flex; flex-direction: column; gap: 8px }
.step { display: flex; gap: 10px; align-items: center; font-weight: 600 }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--kiln); flex: none }
@media (prefers-reduced-motion: no-preference) { .spin { animation: sp .8s linear infinite } }
@keyframes sp { to { transform: rotate(360deg) } }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; background: var(--surface2) }
.drop.over { border-color: var(--kiln) }
.toasts { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: max-content; max-width: calc(100% - 32px) }
.toast { background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow) }
.empty { padding: 26px; text-align: center; color: var(--muted) }

/* bars */
.bar { height: 12px; border-radius: 6px; background: var(--surface2); overflow: hidden }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--kiln) }
.bar.prev { height: 6px } .bar.prev i { background: #B9BFCD }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted) }
.legend span { display: flex; align-items: center; gap: 6px }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block }
svg text { fill: var(--muted) }
svg .gl { stroke: var(--line2) }

/* ---------------- phone layout (container narrower than 760 px) ---------------- */
@container app (max-width: 760px) {
  .side { display: none }
  .main { padding: 16px 16px 24px; gap: 16px; flex: 1 }
  .app { flex-direction: column; min-height: 100% }
  .mhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 10px 16px; border-bottom: 1px solid var(--line) }
  .mhead .brand b { font-size: 17px }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: sticky; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)) }
  .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 2px; min-height: 52px; cursor: pointer; position: relative }
  .tabbar button[aria-current="page"] { color: var(--fg) }
  .tabbar button[aria-current="page"] .icon { color: var(--kiln) }
  .tabbar .count { position: absolute; top: 2px; right: 18%; background: var(--kiln); color: #1F2A44; font-size: 10px; font-weight: 800; border-radius: 999px; padding: 0 5px }
  .h1 { font-size: 24px }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px }
  .kpi .v { font-size: 22px }
  .card { padding: 16px }
  .li { flex-wrap: wrap }
  .li .grow { flex-basis: calc(100% - 110px) }
  .when { min-width: 0 }
  .search { width: 100% }
  .head .row { width: 100% }
  .grid2 { grid-template-columns: 1fr }
  .kv { grid-template-columns: 110px minmax(0, 1fr) }
  .sites { flex: 1 1 100% }
  .day { min-height: 54px; padding: 4px; gap: 2px; align-items: center }
  .day .ev { display: none }
  .day .dots { display: flex }
  .month { gap: 3px }
  .modal { padding: 18px }
  .toasts { bottom: 90px }
  .banner .grow { flex-basis: 100% }
  .hide-phone { display: none !important }
}
.dots { display: none; gap: 3px; flex-wrap: wrap; justify-content: center }

.lockhero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 28px 16px }
.icon.big { width: 44px; height: 44px; color: var(--kiln) }

/* ---------------------------------------------------------------- sign-in and setup banner (boot.js) */
.sc-loading { padding: 24px; font-family: var(--font); color: var(--muted); }
.sc-signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); font-family: var(--font); }
.sc-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 24px; text-align: center; box-shadow: var(--shadow); color: var(--fg); }
.sc-card img { border-radius: 18px; }
.sc-card h1 { margin: 12px 0 4px; font-size: 26px; font-weight: 800; }
.sc-sub { margin: 0 0 20px; color: var(--muted); }
.sc-err { background: var(--bad-bg); color: var(--bad-fg); border-radius: 10px; padding: 10px 12px; text-align: left; }
.sc-btn { display: block; padding: 13px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; text-decoration: none; }
.sc-btn:focus-visible { outline: 3px solid var(--ember); outline-offset: 2px; }
.sc-hint { margin: 14px 0 0; font-size: 14px; color: var(--faint); }
.sc-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 16px; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); color: var(--fg); font: 14px/1.4 var(--font); }
.sc-banner .sc-who { margin-left: auto; color: var(--muted); }
.sc-banner form { margin: 0; }
.sc-banner button { font: inherit; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
