:root {
  --bg: #eef3f2; --surface: #ffffff; --surface-2: #f6f9f8; --line: #e3eae8; --line-2: #d3dedb;
  --ink: #0f1f1d; --ink-2: #4a5b58; --ink-3: #7a8a87;
  --brand: #0b5c5c; --brand-600: #0e6f6e; --brand-50: #e6f2f0; --brand-100: #cfe7e3; --accent: #7fd4c1;
  --good: #137a47; --good-bg: #e4f5eb; --warn: #9a5b00; --warn-bg: #fdf1dc; --bad: #b42318; --bad-bg: #fde8e6; --info-bg: #e8f0fb; --info: #1d4f91;
  --radius: 16px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(16,40,36,.04), 0 4px 16px rgba(16,40,36,.04);
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1514; --surface: #121f1e; --surface-2: #172726; --line: #22403c; --line-2: #2c4c48;
    --ink: #e8f1ef; --ink-2: #b2c3c0; --ink-3: #7f9592;
    --brand: #2fa79a; --brand-600: #3dbbad; --brand-50: #12302d; --brand-100: #1a413d; --accent: #7fd4c1;
    --good: #5fd39a; --good-bg: #123323; --warn: #f2b54a; --warn-bg: #33270f; --bad: #ff8a80; --bad-bg: #3a1714; --info-bg: #14243b; --info: #8fb8f0;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-600); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; } h2 { font-size: 19px; font-weight: 600; } h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.boot { display: grid; place-items: center; height: 100vh; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--brand-100); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 84px 1fr; min-height: 100vh; max-width: 1480px; margin: 0 auto; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 0; background: var(--surface); border-right: 1px solid var(--line); }
.rail .logo { width: 44px; height: 44px; margin-bottom: 18px; }
.rail a { position: relative; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: var(--ink-2); }
.rail a:hover { background: var(--surface-2); text-decoration: none; }
.rail a.on { background: var(--brand-50); color: var(--brand); }
.rail a.on::before { content: ''; position: absolute; left: -18px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand); }
.rail a .tip { position: absolute; left: 58px; white-space: nowrap; background: var(--ink); color: var(--surface); font-size: 12px; padding: 4px 8px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 5; }
.rail a:hover .tip { opacity: 1; }
.rail .spacer { flex: 1; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-100); color: var(--brand); display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; }
.main { min-width: 0; padding: 0 32px 48px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 26px 0 22px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.topbar h1 { flex: 1; min-width: 0; }
.topbar .crumbs { display: block; font-size: 13px; font-weight: 500; color: var(--ink-3); margin-bottom: 4px; }
.tabbar { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .main { padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { padding: 18px 0 14px; margin-bottom: 16px; }
  h1 { font-size: 22px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink-3); padding: 4px 8px; border-radius: 10px; flex: 1; }
  .tabbar a.on { color: var(--brand); }
  .tabbar a:hover { text-decoration: none; }
}

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h2, .card-h h3 { flex: 1; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: 1fr; } .grid { gap: 14px; } .card { padding: 16px; } }
@media (max-width: 420px) { .g4 { grid-template-columns: 1fr 1fr; gap: 10px; } }
.stack > * + * { margin-top: 12px; } .stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .grow { flex: 1; min-width: 0; }

.stat { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.stat .top { padding: 18px 20px 16px; }
.stat .label { color: var(--ink-2); font-weight: 500; font-size: 14px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.stat .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface-2); padding: 11px 20px; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--line); }
.stat.hl { background: linear-gradient(135deg, var(--surface) 30%, var(--brand-50)); border-color: var(--brand-100); }
@media (max-width: 420px) { .stat .value { font-size: 21px; } .stat .top { padding: 14px; } .stat .foot { padding: 9px 14px; } }

.banner { display: flex; align-items: center; gap: 16px; background: var(--brand); color: #fff; border-radius: var(--radius); padding: 18px 22px; flex-wrap: wrap; position: relative; overflow: hidden; }
.banner::after { content: ''; position: absolute; right: 180px; top: -30px; width: 90px; height: 90px; transform: rotate(45deg); border-radius: 18px; background: rgba(255,255,255,.07); }
.banner .ico { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.14); display: grid; place-items: center; flex: none; }
.banner h3 { color: #fff; font-size: 17px; } .banner p { margin: 2px 0 0; opacity: .85; font-size: 14px; }
.banner .btn { background: #fff; color: #0b5c5c; border-color: #fff; position: relative; z-index: 1; }
.banner.warn { background: #8a4b00; }
@media (max-width: 560px) { .banner { padding: 18px; } .banner::after { display: none; } .banner > .btn { width: 100%; } } .banner.bad { background: #9b1c14; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 500 14px var(--font); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: var(--surface-2); text-decoration: none; } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-600); }
.btn.danger { color: var(--bad); } .btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; } .btn.lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; } .btn[disabled] { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--brand-600); font: 500 13px var(--font); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); } .pill.brand { background: var(--brand-50); color: var(--brand); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.plain::before { display: none; }

/* forms */
label.f { display: block; } label.f > span { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
label.f > small, .hint { display: block; font-size: 12px; color: var(--ink-3); margin-top: 5px; }
input, select, textarea { width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 15px var(--font); outline: none; transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.money-in { position: relative; } .money-in::before { content: '$'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); } .money-in input { padding-left: 24px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); } .fields .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }

/* big choice cards used in the wizards */
.choices { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.choice { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 16px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--surface); cursor: pointer; font: inherit; color: inherit; transition: border-color .12s, background .12s; }
.choice:hover { border-color: var(--brand-600); }
.choice.on { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-100); }
.choice b { font-weight: 600; } .choice .muted { font-size: 13px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 8px; font: 500 13px var(--font); color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 6px 13px; font: 500 13px var(--font); color: var(--ink-2); cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* wizard */
.wizard { max-width: 760px; margin: 0 auto; }
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); } .steps i.on { background: var(--brand); }
.wizard .q { font-size: 22px; font-weight: 600; margin-bottom: 4px; } .wizard .q + .muted { margin-bottom: 20px; }
.wizard-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }

/* tables & lists */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; } .t td.r, .t th.r { text-align: right; }
.t tr.click { cursor: pointer; } .t tr.click:hover td { background: var(--surface-2); }
.scroll-x { overflow-x: auto; }
.list > * { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); } .list > *:last-child { border-bottom: 0; }
.empty { text-align: center; padding: 34px 16px; color: var(--ink-3); } .empty .ico { width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 14px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; }
.empty h3 { color: var(--ink); margin-bottom: 4px; }

/* properties */
.prop { display: block; color: inherit; } .prop:hover { text-decoration: none; border-color: var(--brand-100); }
.prop .thumb { height: 92px; border-radius: 12px; margin-bottom: 14px; background: linear-gradient(135deg, var(--brand) 0%, #2a8d84 60%, var(--accent) 140%); display: flex; align-items: flex-end; padding: 10px 12px; color: #fff; }
.unit-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); flex-wrap: wrap; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--ink-3); font-weight: 500; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--brand); } .tabs a:hover { text-decoration: none; color: var(--ink); }

/* messages */
.thread { display: flex; flex-direction: column-reverse; gap: 10px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); border-bottom-right-radius: 6px; }
.bubble:not(.me) { border-bottom-left-radius: 6px; }
.bubble .meta { font-size: 11px; opacity: .7; margin-top: 4px; }
.composer { display: flex; gap: 10px; margin-top: 14px; align-items: flex-end; } .composer textarea { min-height: 46px; height: 46px; }

/* meters (admin usage) */
.meter { height: 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 8px; background: var(--brand); }
.meter.warn > i { background: #d98b06; } .meter.bad > i { background: var(--bad); }

/* charts */
.chart { position: relative; } .chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--brand); } .chart .bar:hover, .chart .bar.hover { fill: var(--brand-600); }
.chart .grid-l { stroke: var(--line); stroke-width: 1; } .chart text { fill: var(--ink-3); font: 11px var(--font); }
.chart .tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); padding: 6px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(8,20,18,.45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 18px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s ease-out; }
.modal h2 { margin-bottom: 4px; } .modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@media (max-width: 560px) { .overlay { place-items: end center; padding: 0; } .modal { border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: calc(22px + env(safe-area-inset-bottom)); } }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { transform: translateY(12px); opacity: 0; } }
#toasts { position: fixed; top: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: pop .2s; max-width: 380px; }
.toast.err { background: var(--bad); color: #fff; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, #2a8d84 0%, transparent 60%), linear-gradient(160deg, #0a3d3c, #0b5c5c 60%, #164e4a); }
.auth .card { width: 100%; max-width: 420px; padding: 32px; border: 0; }
.auth .logo { width: 48px; height: 48px; margin-bottom: 18px; }
.auth h1 { font-size: 24px; margin-bottom: 6px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; margin: 18px 0; } .divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* agreement doc */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 44px; font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; }
@media (max-width: 560px) { .doc { padding: 22px 18px; } }
.sigpad { width: 100%; height: 160px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: var(--surface-2); touch-action: none; display: block; }
.sig img { max-height: 70px; background: #fff; border-radius: 6px; }
.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; background: var(--info-bg); color: var(--info); } .notice.warn { background: var(--warn-bg); color: var(--warn); } .notice.good { background: var(--good-bg); color: var(--good); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 14px; } .kv dt { color: var(--ink-3); } .kv dd { margin: 0; font-weight: 500; }
.proof-img { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }

@media print {
  .rail, .tabbar, .topbar .btn, .tabs, .no-print { display: none !important; }
  body.print-agreement .topbar, body.print-agreement #view > .stack-lg > :not(#tab) { display: none !important; }
  body.print-agreement { color: #000; }
  body.print-agreement .card { border: 0; box-shadow: none; padding: 0; background: none; }
  body.print-agreement .sig img { max-height: 60px; }
  body.print-agreement .grid.g3 { grid-template-columns: 1fr 1fr; }
  @page { margin: 0; }                 /* removes the browser's URL/date header and footer */
  body.print-agreement .main { padding: 18mm 18mm !important; }
  .shell { display: block; } .main { padding: 0; } body { background: #fff; } .doc { border: 0; padding: 0; }
}
.print-only { display: none; }
@media print { .print-only { display: grid !important; } }
