/* ==========================================================================
   AFOLINE Finance — control room
   Sora (display) · Inter (body) · JetBrains Mono (figures)
   ========================================================================== */

:root {
  --ink:        #0B1220;
  --ink-2:      #131C30;
  --ink-3:      #1D2942;
  --blue:       #2D7FFF;
  --blue-soft:  #E8F0FF;
  --violet:     #7C3AED;
  --teal:       #1FE3D0;
  --paper:      #F5F7FB;
  --card:       #FFFFFF;
  --line:       #E4E9F2;
  --line-soft:  #EFF2F7;
  --text:       #0F172A;
  --muted:      #64748B;
  --faint:      #94A3B8;
  --good:       #0EA47A;
  --good-bg:    #E6F7F1;
  --warn:       #D97706;
  --warn-bg:    #FEF3E2;
  --bad:        #DC2626;
  --bad-bg:     #FEECEC;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px -12px rgba(15,23,42,.12);
  --sidebar: 248px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: 'Sora', sans-serif; margin: 0; letter-spacing: -.02em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono, .fig {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- auth ---------------------------------------------------- */

.auth-body {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 15% -10%, rgba(45,127,255,.30), transparent 60%),
    radial-gradient(760px 420px at 95% 105%, rgba(124,58,237,.26), transparent 62%),
    var(--ink);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 34px 30px 30px;
  box-shadow: 0 30px 70px -22px rgba(2,8,23,.6);
}
.auth-brand {
  font-family: 'Sora', sans-serif; font-weight: 700;
  font-size: 15px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink); display: flex; align-items: center; gap: 9px; margin-bottom: 26px;
}
.auth-brand em { font-style: normal; font-weight: 500; color: var(--faint); letter-spacing: .1em; }
.auth-brand .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--teal));
}
.auth-card h1 { font-size: 25px; margin-bottom: 6px; }
.auth-lead { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.install-next { color: var(--muted); font-size: 14px; padding-left: 18px; margin: 0 0 22px; }
.install-next li { margin-bottom: 7px; }
.install-next code {
  background: var(--paper); padding: 1px 5px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--ink);
}

/* ---------- forms --------------------------------------------------- */

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: 6px;
}
.field small { display: block; margin-top: 5px; color: var(--faint); font-size: 12px; }

input[type=text], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: inherit; font-size: 14px; color: var(--text);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
input[type=number], input.fig { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45,127,255,.14);
}
input[readonly] { background: var(--paper); color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1E6BE8; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--faint); }
.btn-danger { background: #fff; border-color: var(--line); color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---------- shell --------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar);
  background: var(--ink); color: #fff;
  padding: 22px 14px; position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
}
/* The owner nav is long. Let it scroll on a short screen while the brand and
   the sign-out block stay put. min-height:0 is what allows a flex child to
   shrink below its content height and actually scroll. */
.sidebar .brand,
.sidebar .foot { flex: 0 0 auto; }
.sidebar nav {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.22) transparent;
  margin-right: -6px; padding-right: 6px;
}
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.22); border-radius: 999px;
}
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar .brand {
  font-family: 'Sora', sans-serif; font-weight: 700; font-size: 14px;
  letter-spacing: .16em; text-transform: uppercase;
  display: flex; align-items: center; gap: 9px; padding: 0 10px; margin-bottom: 26px;
}
.sidebar .brand em { font-style: normal; font-weight: 500; color: #64748B; letter-spacing: .1em; }
.sidebar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--teal));
}
.nav-group {
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: #475569; padding: 0 10px; margin: 20px 0 8px;
}
.nav-group:first-of-type { margin-top: 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: #CBD5E1; font-size: 14px; font-weight: 500;
  margin-bottom: 2px; transition: background .13s, color .13s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.on { background: var(--blue); color: #fff; }
.sidebar nav a i { width: 17px; text-align: center; font-size: 13px; opacity: .95; }
.sidebar .foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.09); }
.sidebar .foot .who { font-size: 13px; font-weight: 600; }
.sidebar .foot .out { font-size: 12px; color: #64748B; }
.sidebar .foot .out:hover { color: #fff; }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.topbar h1 { font-size: 26px; }
.topbar .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.topbar .actions { display: flex; gap: 9px; flex-shrink: 0; }

.mobile-bar { display: none; }

/* ---------- cards --------------------------------------------------- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 20px;
}
.card > header {
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card > header h2 { font-size: 15px; font-weight: 600; }
.card > header .hint { font-size: 12px; color: var(--faint); }
.card .body { padding: 18px; }
.card .body.flush { padding: 0; }

/* ---------- KPI ----------------------------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px 16px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line);
}
.kpi.is-good::after { background: var(--good); }
.kpi.is-warn::after { background: var(--warn); }
.kpi.is-bad::after  { background: var(--bad); }
.kpi.is-blue::after { background: var(--blue); }
.kpi .lbl {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 7px;
}
.kpi .val { font-family: 'JetBrains Mono', monospace; font-size: 25px; font-weight: 700; letter-spacing: -.03em; }
.kpi .val.neg { color: var(--bad); }
.kpi .val.pos { color: var(--good); }
.kpi .note { font-size: 12px; color: var(--faint); margin-top: 5px; }

/* ---------- revenue position track (signature) ---------------------- */

.track-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; gap: 16px; }
.track-now {
  font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700;
  letter-spacing: -.03em; line-height: 1.1;
}
.track-cap { font-size: 12px; color: var(--muted); }

.track {
  position: relative; height: 14px; border-radius: 999px;
  background: var(--line-soft); border: 1px solid var(--line); overflow: hidden;
}
.track .fill {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--violet));
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.track .tick {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--ink); opacity: .55; z-index: 2;
}

.track-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.track-key { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; }
.track-key > i { color: var(--line); font-size: 13px; margin-top: 3px; }
.track-key.passed > i { color: var(--good); }
.track-key b { display: block; font-weight: 600; font-size: 13px; }
.track-key span {
  display: block; font-size: 14px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.track-key small { display: block; font-size: 12px; color: var(--faint); }
.track-key.passed small { color: var(--good); }

/* ---------- capacity meters (signature) ----------------------------- */

.meters { display: grid; gap: 15px; }
.meter { display: grid; grid-template-columns: 200px 1fr 122px; gap: 14px; align-items: center; }
.meter .name { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; }
.meter .name i { width: 16px; text-align: center; color: var(--faint); font-size: 13px; }
.meter .bar { height: 9px; border-radius: 999px; background: var(--line-soft); overflow: hidden; position: relative; }
.meter .bar > i {
  display: block; height: 100%; border-radius: 999px; background: var(--blue);
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.meter.s-ok   .bar > i { background: var(--good); }
.meter.s-idle .bar > i { background: var(--faint); }
.meter.s-full .bar > i { background: var(--violet); }
.meter.s-near .bar > i { background: var(--warn); }
.meter.s-over .bar > i { background: var(--bad); }
.meter .read { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--muted); text-align: right; }
.meter .read b { color: var(--text); font-weight: 700; }
.meter.tight .name::after {
  content: 'TIGHTEST'; font-family: 'Inter', sans-serif; font-size: 9px; font-weight: 700;
  letter-spacing: .1em; color: var(--ink); background: var(--teal);
  padding: 2px 6px; border-radius: 4px;
}

/* ---------- alerts -------------------------------------------------- */

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--r-sm); font-size: 14px;
  margin-bottom: 10px; border: 1px solid transparent;
}
.alert i { margin-top: 2px; flex-shrink: 0; }
.alert-bad  { background: var(--bad-bg);  color: #991B1B; border-color: #FBD5D5; }
.alert-warn { background: var(--warn-bg); color: #92400E; border-color: #FBE3BF; }
.alert-info { background: var(--blue-soft); color: #1E3A8A; border-color: #D3E3FF; }
.alert-ok   { background: var(--good-bg); color: #065F46; border-color: #C6EFE0; }

.flash { position: sticky; top: 0; z-index: 20; margin-bottom: 16px; }

/* ---------- tables -------------------------------------------------- */

.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); background: var(--paper);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #FAFBFE; }
table.tbl td.n, table.tbl th.n { text-align: right; }
table.tbl td.n {
  font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.tbl td.strong { font-weight: 700; }
table.tbl tr.total td { background: var(--paper); font-weight: 700; border-top: 2px solid var(--line); }
table.tbl .neg { color: var(--bad); }
table.tbl .pos { color: var(--good); }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
}
.pill-good { background: var(--good-bg); color: #065F46; }
.pill-warn { background: var(--warn-bg); color: #92400E; }
.pill-bad  { background: var(--bad-bg);  color: #991B1B; }
.pill-neutral { background: var(--paper); color: var(--muted); }
.pill-blue { background: var(--blue-soft); color: #1E3A8A; }

/* ---------- settings grid ------------------------------------------- */

.setgrid { display: grid; grid-template-columns: 1fr 150px; gap: 12px 16px; align-items: center; }
.setgrid .lbl { font-size: 14px; }
.setgrid .lbl small { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }
.setgrid input { text-align: right; }
.setgrid input.assume { background: #FFFDF0; border-color: #F3E5A8; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.note-block {
  background: var(--paper); border-left: 3px solid var(--blue);
  padding: 13px 15px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 13px; color: var(--muted); line-height: 1.6;
}
.note-block strong { color: var(--text); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty i { font-size: 30px; color: var(--line); display: block; margin-bottom: 12px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 14px; margin: 0 0 16px; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* ---------- table scroll affordance --------------------------------- */

.tbl-scroll { position: relative; }
.tbl-scroll::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 26px;
  pointer-events: none; opacity: 0; transition: opacity .2s;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.95));
}
.tbl-scroll.can-scroll::after { opacity: 1; }


/* ---------- stacked tables ------------------------------------------
   A table gets .stack from app.js when it is too wide for the viewport.
   Each row then reads as a small card: the first cell titles it and every
   other cell shows its column header beside the value.
   -------------------------------------------------------------------- */

table.tbl.stack { display: block; }
table.tbl.stack thead { display: none; }
table.tbl.stack tbody,
table.tbl.stack tfoot { display: block; }
table.tbl.stack tr {
  display: block; border: 1px solid var(--line); border-radius: 10px;
  margin: 0 0 10px; padding: 4px 0; background: #fff;
}
table.tbl.stack tr:hover { background: #fff; }
table.tbl.stack tr.total { border-color: var(--blue); background: var(--blue-soft); }
table.tbl.stack tr.total:hover { background: var(--blue-soft); }
table.tbl.stack td {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 13px; border: none; text-align: left; white-space: normal;
}
table.tbl.stack td[data-label]::before {
  content: attr(data-label);
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); flex: 0 0 auto; max-width: 52%;
}
table.tbl.stack td.rowhead {
  justify-content: flex-start; font-family: 'Sora', sans-serif;
  font-size: 15px; font-weight: 600;
  padding: 11px 13px 9px; border-bottom: 1px solid var(--line-soft); margin-bottom: 3px;
}
table.tbl.stack td.rowhead::before { display: none; }
table.tbl.stack td.acts {
  justify-content: stretch; gap: 8px; padding-top: 10px;
  border-top: 1px solid var(--line-soft); margin-top: 3px;
}
table.tbl.stack td.acts::before { display: none; }
table.tbl.stack td.acts > *,
table.tbl.stack td.acts form { flex: 1; }
table.tbl.stack td.acts .btn { width: 100%; }
table.tbl.stack td.blank { display: none; }
table.tbl.stack td input[type=number],
table.tbl.stack td input[type=text] {
  width: 140px !important; text-align: right; flex: 0 0 auto;
}
table.tbl.stack td.rowhead input[type=text] {
  width: 100% !important; text-align: left; font-size: 15px; font-weight: 600;
}
.tbl-scroll:has(table.stack)::after { display: none; }

/* On a tablet there is room for two cards side by side. */
@media (min-width: 640px) {
  table.tbl.stack tbody {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
    padding: 0 2px;
  }
  table.tbl.stack tbody tr { margin: 0; }
  table.tbl.stack tfoot tr { margin-top: 10px; }
}

/* ---------- bottom tab bar (phones only) ---------------------------- */

.tabbar { display: none; }

/* =====================================================================
   TABLET  —  700px to 1023px   ·   icon rail, no drawer needed
   ===================================================================== */

@media (min-width: 700px) and (max-width: 1023px) {
  :root { --sidebar: 90px; }

  .sidebar { padding: 18px 8px; align-items: center; }
  .sidebar .brand { justify-content: center; margin-bottom: 20px; padding: 0; }
  .sidebar .brand span.dot { width: 13px; height: 13px; }
  .sidebar .brand,
  .sidebar .brand em { font-size: 0; }
  .sidebar .nav-group { font-size: 0; margin: 14px 0 6px; padding: 0; }
  .sidebar .nav-group::before {
    content: ''; display: block; height: 1px; background: rgba(255,255,255,.1); margin: 0 8px;
  }
  .sidebar nav { width: 100%; }
  .sidebar nav a {
    flex-direction: column; justify-content: center; align-items: center;
    padding: 9px 2px; gap: 5px; min-height: 54px;
    font-size: 10px; font-weight: 600; letter-spacing: .02em; text-align: center;
  }
  .sidebar nav a i { font-size: 17px; width: auto; }
  .sidebar .foot { width: 100%; text-align: center; padding: 12px 4px 0; }
  .sidebar .foot .who { font-size: 10px; line-height: 1.3; }
  .sidebar .foot .out { font-size: 10px; display: block; margin-top: 6px; }

  .main { padding: 22px 22px 50px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .track-keys { grid-template-columns: repeat(3, 1fr); }
  .meter { grid-template-columns: 170px 1fr 112px; }
}

@media (min-width: 820px) and (max-width: 1023px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpi .val { font-size: 21px; }
}

/* =====================================================================
   PHONE  —  under 700px   ·   drawer + bottom tabs + stacked tables
   ===================================================================== */

@media (max-width: 699px) {
  .shell { display: block; }

  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60; height: 100dvh; width: 270px;
    transform: translateX(-100%); transition: transform .22s ease;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ''; position: fixed; inset: 0; background: rgba(2,8,23,.55); z-index: 50;
  }

  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--ink); color: #fff;
    padding: calc(11px + env(safe-area-inset-top)) 16px 11px;
    position: sticky; top: 0; z-index: 40;
  }
  .mobile-bar .brand {
    font-family: 'Sora', sans-serif; font-weight: 700; font-size: 13px;
    letter-spacing: .14em; text-transform: uppercase;
    display: flex; align-items: center; gap: 8px;
  }
  .mobile-bar .brand .dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--teal));
  }
  .mobile-bar .who { font-size: 12px; color: #94A3B8; }

  .main { padding: 16px 14px calc(84px + env(safe-area-inset-bottom)); }

  .topbar { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .topbar h1 { font-size: 21px; }
  .topbar .actions { flex-direction: column; }
  .topbar .actions .btn { width: 100%; }

  /* ---- bottom tabs ---- */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: rgba(255,255,255,.97); backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 9px 2px 8px; min-height: 54px;
    background: none; border: none; cursor: pointer;
    color: var(--faint); font-family: inherit; font-size: 10px; font-weight: 600;
    letter-spacing: .02em; text-decoration: none;
  }
  .tabbar a i, .tabbar button i { font-size: 17px; }
  .tabbar a.on { color: var(--blue); }
  .tabbar a:hover { text-decoration: none; }

  /* ---- cards & type ---- */
  .card { border-radius: var(--r); margin-bottom: 14px; }
  .card > header { padding: 13px 14px; flex-wrap: wrap; gap: 4px; }
  .card > header h2 { font-size: 14px; }
  .card > header .hint { font-size: 11px; }
  .card .body { padding: 14px; }

  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
  .kpi { padding: 12px 13px; }
  .kpi .lbl { font-size: 10px; margin-bottom: 5px; }
  .kpi .val { font-size: 19px; }
  .kpi .note { font-size: 11px; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 14px; }

  /* ---- position track ---- */
  .track-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .track-head > div:last-child { text-align: left !important; }
  .track-now { font-size: 22px; }
  .track-keys { grid-template-columns: 1fr; gap: 9px; margin-top: 16px; }
  .track-key { align-items: center; gap: 10px; }
  .track-key > div { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .track-key b { display: inline; }
  .track-key span { display: inline; font-size: 13px; }
  .track-key small { display: inline; }

  /* ---- capacity meters ---- */
  .meter {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name read" "bar bar";
    gap: 7px 10px;
  }
  .meter .name { grid-area: name; font-size: 13px; }
  .meter .read { grid-area: read; text-align: right; font-size: 12px; }
  .meter .bar  { grid-area: bar; }
  .meter.tight .name::after { font-size: 8px; padding: 2px 5px; }

  /* ---- forms ---- */
  input[type=text], input[type=password], input[type=number],
  input[type=date], select, textarea { font-size: 16px; padding: 11px 12px; }
  .field > span { font-size: 11px; }
  .btn { min-height: 44px; padding: 11px 16px; }
  .btn-sm { min-height: 38px; padding: 8px 12px; font-size: 13px; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .field, .inline-form .btn { width: 100%; min-width: 0 !important; }

  .setgrid { grid-template-columns: 1fr 118px; gap: 11px 12px; }
  .setgrid .lbl { font-size: 13px; }
  .setgrid .lbl small { font-size: 11px; }

  .alert { font-size: 13px; padding: 10px 12px; }
  .note-block { font-size: 12px; padding: 12px 13px; }
  .legend { font-size: 11px; gap: 10px; }

  .tbl-scroll::after { display: none; }
}

/* The settings page is long; keep Save reachable without scrolling to the end. */
@media (max-width: 1023px) {
  .save-bar {
    position: sticky; bottom: 0; z-index: 30; margin-bottom: 0;
    border-radius: var(--r) var(--r) 0 0;
    box-shadow: 0 -6px 20px -10px rgba(15,23,42,.28);
  }
  .save-bar .body { padding: 12px 14px; }
  .save-bar .legend { display: none; }
  .save-bar .btn { width: 100%; }
}
@media (max-width: 699px) {
  .save-bar { bottom: calc(54px + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr; }
  .setgrid { grid-template-columns: 1fr 104px; }
  .tabbar a, .tabbar button { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .sidebar, .mobile-bar, .tabbar, .topbar .actions, .btn { display: none !important; }
  .main { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ==========================================================================
   v2 components
   ========================================================================== */

.subhead {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.subhead small { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); }

.sidebar .foot .role { font-size: 11px; color: #64748B; margin-bottom: 4px; }

/* ---------- segmented filters ---------- */
.segbar {
  display: flex; gap: 4px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 4px; margin-bottom: 14px; overflow-x: auto;
}
.segbar.wrap { flex-wrap: wrap; }
.segbar a {
  flex: 1; min-width: 76px; text-align: center; padding: 8px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
/* With many labels, equal-width tabs squash the text into its neighbour.
   Letting each take its own width and wrap keeps them readable. */
.segbar.wrap a { flex: 0 0 auto; }
.segbar a:hover { background: var(--paper); text-decoration: none; }
.segbar a.on { background: var(--ink); color: #fff; }

/* ---------- month stepper ---------- */
.monthnav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 16px;
}
.monthnav b { font-family: 'Sora', sans-serif; font-size: 14px; }

/* ---------- today panels ---------- */
.panels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.panel-head i { margin-right: 7px; }
.panel-head a { font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.panel-body { padding: 10px 14px 13px; }
.pline {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 5px 0; font-size: 13px; color: var(--muted);
}
.pline b {
  font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700;
  color: var(--text); white-space: nowrap;
}
.pline.stack { display: block; }
.pline.stack b {
  display: block; white-space: normal; font-size: 13px; margin-top: 2px; line-height: 1.4;
}
.pline b small { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 11px; color: var(--faint); }
.pline.f-bad b  { color: var(--bad); }
.pline.f-warn b { color: var(--warn); }
.panel.p-bad  { border-top: 3px solid var(--bad); }
.panel.p-warn { border-top: 3px solid var(--warn); }
.panel.p-ok   { border-top: 3px solid var(--good); }

/* ---------- team mode ---------- */
body.staff .main { max-width: 720px; margin: 0 auto; }

.punch-card { overflow: hidden; }
.punch {
  width: 100%; border: none; border-radius: var(--r); cursor: pointer;
  padding: 26px 18px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: inherit; color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
}
.punch b { font-family: 'Sora', sans-serif; font-size: 21px; font-weight: 700; }
.punch small { font-size: 13px; opacity: .85; font-family: 'JetBrains Mono', monospace; }
.punch .dotpulse {
  width: 11px; height: 11px; border-radius: 50%; background: #fff; margin-bottom: 4px;
  box-shadow: 0 0 0 0 rgba(255,255,255,.75); animation: pulse 2s infinite;
}
@keyframes pulse {
  70%  { box-shadow: 0 0 0 14px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}
.punch-state { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.punch-time { font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 700; margin-top: 5px; }

/* ---------- job cards ---------- */
.jobcard {
  border: 1px solid var(--line); border-radius: var(--r); padding: 14px;
  margin-bottom: 11px; background: #fff;
}
.jobcard.late  { border-left: 4px solid var(--bad); }
.jobcard.stuck { border-left: 4px solid var(--warn); background: #FFFDF6; }
.jobcard.slim { padding: 12px 13px; }
.jobtitle { font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 600; line-height: 1.35; }
.jobtitle .qty { font-family: 'JetBrains Mono', monospace; color: var(--muted); font-weight: 500; }
.jobmeta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 5px; font-size: 12px; color: var(--muted); }
.jobmeta .late-tag { color: var(--bad); font-weight: 700; }
.jobblock {
  margin-top: 9px; font-size: 12px; color: #92400E; background: var(--warn-bg);
  padding: 7px 10px; border-radius: var(--r-sm);
}
.jobacts { display: flex; gap: 8px; margin-top: 12px; }
.jobacts .btn { flex: 1; }
.jobacts form { flex: 1; display: flex; }
.jobacts form .btn { width: 100%; }
.stuck-form { margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--line-soft); }
.daygroup {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 16px 0 8px;
}
.daygroup:first-child { margin-top: 0; }

/* ---------- attendance grid ---------- */
.attrow { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: center; margin-bottom: 12px; }
.attname b { display: block; font-size: 14px; }
.attname small { font-size: 11px; color: var(--faint); font-family: 'JetBrains Mono', monospace; }
.attgrid { display: flex; flex-wrap: wrap; gap: 4px; }
.attday {
  width: 38px; height: 42px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--paper); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; cursor: pointer; font-family: inherit; padding: 0;
}
.attgrid.tight { gap: 3px; }
.attgrid.tight .attday { width: 26px; height: 26px; }
.attday .dnum { font-size: 11px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.attday .ddow { font-size: 9px; color: var(--faint); }
.attday .dtime { font-size: 8px; color: var(--faint); font-family: 'JetBrains Mono', monospace; }
.attday.s-present { background: var(--good); border-color: var(--good); color: #fff; }
.attday.s-leave   { background: var(--blue); border-color: var(--blue); color: #fff; }
.attday.s-half    { background: var(--warn); border-color: var(--warn); color: #fff; }
.attday.s-absent  { background: var(--bad);  border-color: var(--bad);  color: #fff; }
.attday.s-holiday { background: #CBD5E1; border-color: #CBD5E1; }
.attday.s-sun     { background: #fff; border-style: dashed; }
.attday.s-future  { background: #fff; opacity: .5; }
.attday.s-present .ddow, .attday.s-leave .ddow,
.attday.s-half .ddow, .attday.s-absent .ddow { color: rgba(255,255,255,.8); }
.attday.s-present .dtime { color: rgba(255,255,255,.85); }

/* [hidden] must win over the display rule below, or the sheet shows on load. */
.attsheet[hidden] { display: none; }
.attsheet {
  position: fixed; inset: 0; z-index: 70; background: rgba(2,8,23,.5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.attsheet-inner {
  background: #fff; border-radius: var(--r-lg); padding: 18px; width: 100%; max-width: 380px;
  margin-bottom: env(safe-area-inset-bottom);
}
.attsheet-inner h3 { font-size: 15px; margin-bottom: 12px; }
.attsheet-inner .btn { margin-bottom: 7px; justify-content: flex-start; }
.att-present { border-left: 4px solid var(--good); }
.att-leave   { border-left: 4px solid var(--blue); }
.att-half    { border-left: 4px solid var(--warn); }
.att-absent  { border-left: 4px solid var(--bad); }
.att-holiday { border-left: 4px solid #CBD5E1; }

/* ---------- projects ---------- */
.projgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card.proj.overdue { border-color: #FBD5D5; }
.projmeta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.projmeta i { margin-right: 5px; color: var(--faint); }
.projmeta .late-tag { color: var(--bad); font-weight: 600; }
.progbar { height: 7px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.progbar > i { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.progtext { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.checks { display: flex; flex-direction: column; gap: 2px; }
.checkbtn {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: none; border: none; padding: 7px 4px; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--text); border-radius: 6px;
}
.checkbtn:hover { background: var(--paper); }
.checkbtn i { color: var(--line); font-size: 15px; }
.checkbtn.on i { color: var(--good); }
.checkbtn.on span { color: var(--faint); text-decoration: line-through; }
.projacts { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- client health ---------- */
.healthrow {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px;
}
.healthrow.h-good { border-left: 4px solid var(--good); }
.healthrow.h-warn { border-left: 4px solid var(--warn); }
.healthrow.h-bad  { border-left: 4px solid var(--bad); }
.hname { font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 600; }
.hmeta { font-size: 12px; color: var(--muted); margin-top: 3px; font-family: 'JetBrains Mono', monospace; }
.hflags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hflags span {
  font-size: 11px; background: var(--warn-bg); color: #92400E;
  padding: 3px 8px; border-radius: 999px;
}
.hflags span.ok { background: var(--good-bg); color: #065F46; }
.hright { text-align: right; flex-shrink: 0; }
.hscore { font-family: 'JetBrains Mono', monospace; font-size: 27px; font-weight: 700; letter-spacing: -.03em; }
.hword { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.h-good .hscore { color: var(--good); }
.h-warn .hscore { color: var(--warn); }
.h-bad  .hscore { color: var(--bad); }

/* ---------- pop-up sheets ----------
   These live inside table cells, which clip anything wider than the column.
   Lifting them out of the flow keeps them readable at any width.            */
.stuck-form { text-align: left; margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--line-soft); }

.pay-form[hidden], .pw-form[hidden] { display: none; }
.pay-form, .pw-form {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 80; width: 380px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 40px); overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; text-align: left;
  box-shadow: 0 30px 70px -20px rgba(2,8,23,.55);
}
/* A shared backdrop element. Using ::before on the form itself paints over
   the form's own background, which tints the card grey. */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 75; background: rgba(2,8,23,.5);
}
.sheet-backdrop[hidden] { display: none; }
.pay-form .field, .pw-form .field { margin-bottom: 14px; }
/* These sheets sit inside table cells that set white-space: nowrap, which
   would otherwise stop their text wrapping. */
.pay-form, .pw-form { white-space: normal; overflow-wrap: anywhere; text-align: left; }
.pay-form *, .pw-form * { white-space: normal; }
.pay-form select, .pw-form select, .pay-form input, .pw-form input { width: 100%; }

/* ---------- switch ---------- */
.switch { display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
  width: 40px; height: 23px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .15s;
}
.switch span::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
  border-radius: 50%; background: #fff; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- responsive additions ---------- */
@media (max-width: 1023px) {
  .panels { grid-template-columns: repeat(2, 1fr); }
  .projgrid { grid-template-columns: 1fr; }
}
@media (max-width: 699px) {
  .panels { grid-template-columns: 1fr; gap: 10px; }
  .attrow { grid-template-columns: 1fr; gap: 6px; }
  .attgrid.tight .attday { width: 32px; height: 32px; }
  .segbar a { min-width: 68px; font-size: 12px; padding: 9px 8px; }
  .healthrow { flex-direction: column; gap: 10px; }
  .hright { text-align: left; display: flex; align-items: center; gap: 12px; }
  .hword { margin-bottom: 0; }
  .monthnav b { font-size: 13px; }
  .punch { padding: 30px 18px; }
  .punch b { font-size: 24px; }
}

/* ---------- services ---------- */
.card.svc.dim { opacity: .62; }
.svcnums {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.svcnums > div {
  background: var(--paper); border-radius: var(--r-sm); padding: 9px 11px;
}
.svcnums span {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.svcnums b {
  font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; letter-spacing: -.02em;
}
.svcnums b.neg { color: var(--bad); }
.svcacts { margin-top: 12px; }
.svcedit {
  margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--line-soft);
}
.alert form { margin-left: auto; flex-shrink: 0; }

/* ---------- remove a person ---------- */
.del-form { border-color: #FBD5D5; }
.delhead {
  font-family: 'Sora', sans-serif; font-size: 14px; font-weight: 600;
  color: #991B1B; margin-bottom: 6px;
}
.delnote { font-size: 12px; color: #7F1D1D; margin: 0 0 10px; line-height: 1.5; }
.delnote em { font-style: normal; font-weight: 600; }

/* ==========================================================================
   Projects — quicker to work through
   ========================================================================== */

details.more { margin-bottom: 14px; }
details.more > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--blue);
  list-style: none; padding: 6px 0;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '+ '; font-weight: 700; }
details.more[open] > summary::before { content: '– '; }

.checkrow { display: flex; align-items: center; gap: 4px; }
.checkrow > form { flex: 1; }
.xbtn {
  border: none; background: none; color: var(--faint); font-size: 18px; line-height: 1;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.xbtn:hover { background: var(--bad-bg); color: var(--bad); }

.filestrip { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-top: 13px; }
.filechip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--text); max-width: 100%;
}
.filechip:hover { border-color: var(--blue); text-decoration: none; }
.filechip i { color: var(--faint); font-size: 12px; }
details.filechip { display: block; border-radius: var(--r-sm); padding: 0; }
details.filechip > summary {
  display: flex; align-items: center; gap: 7px; padding: 7px 11px; cursor: pointer;
  list-style: none; font-size: 12px; font-weight: 500;
}
details.filechip > summary::-webkit-details-marker { display: none; }
.notebody {
  padding: 0 11px 11px; font-size: 13px; color: var(--muted); line-height: 1.6;
  white-space: normal;
}

/* ==========================================================================
   Say it — the AI task composer
   ========================================================================== */

.card.aibox { border-color: #D3E3FF; }
.card.aibox > header h2 i { color: var(--blue); margin-right: 6px; }
.airow { display: flex; gap: 8px; align-items: stretch; }
.airow input[type=text] { flex: 1; font-size: 15px; }
.airow .btn { flex: 0 0 auto; }
.airow .mic { width: 46px; padding: 0; justify-content: center; }
.airow .mic.on { background: var(--bad); border-color: var(--bad); color: #fff; animation: micpulse 1.4s infinite; }
@keyframes micpulse { 50% { opacity: .65; } }
.aihint { font-size: 12px; color: var(--faint); margin-top: 9px; line-height: 1.6; }
.aistatus { margin-top: 12px; font-size: 13px; padding: 9px 12px; border-radius: var(--r-sm); background: var(--paper); }
.aistatus.busy { background: var(--blue-soft); color: #1E3A8A; }
.aistatus.warn { background: var(--warn-bg); color: #92400E; }
.aistatus.bad  { background: var(--bad-bg);  color: #991B1B; }

.airow-card {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px; margin-bottom: 10px; background: #fff;
}
.airow-card > input[type=text] { font-weight: 600; margin-bottom: 10px; }
.airow-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; }
.airow-grid label {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.airow-grid select, .airow-grid input { margin-top: 4px; font-size: 14px; padding: 8px 10px; }

/* ==========================================================================
   The floating assistant
   ========================================================================== */

.orb {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--blue), var(--violet)); color: #fff;
  font-size: 21px; box-shadow: 0 12px 30px -8px rgba(45,127,255,.65);
  display: flex; align-items: center; justify-content: center;
}
.orb:active { transform: scale(.95); }
.orb-off { background: linear-gradient(135deg, #94A3B8, #64748B); box-shadow: none; }
.orb-ring {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(45,127,255,.4); animation: orbring 2.6s ease-out infinite;
}
.orb-off .orb-ring { display: none; }
@keyframes orbring {
  0% { transform: scale(.9); opacity: .8; }
  70%, 100% { transform: scale(1.35); opacity: 0; }
}

.orbpanel {
  position: fixed; right: 22px; bottom: 92px; z-index: 91;
  width: 380px; max-width: calc(100vw - 32px);
  max-height: min(620px, calc(100vh - 130px));
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 30px 70px -18px rgba(2,8,23,.5);
  display: flex; flex-direction: column; overflow: hidden;
}
.orbpanel[hidden] { display: none; }
.orbhead {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.orbhead b { font-family: 'Sora', sans-serif; font-size: 15px; display: block; }
.orbhead small { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }
.orbx { border: none; background: none; font-size: 22px; line-height: 1; color: var(--faint); cursor: pointer; padding: 0 4px; }

.orbbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 16px; }
.orbmsg {
  font-size: 14px; line-height: 1.55; padding: 10px 13px; border-radius: 13px;
  margin-bottom: 9px; max-width: 88%; white-space: pre-wrap;
}
.orbmsg.bot { background: var(--paper); color: var(--text); border-bottom-left-radius: 4px; }
/* Static markup carries its own indentation; only AI replies need pre-wrap. */
.orbmsg.flow { white-space: normal; }
.orbmsg.me {
  background: var(--blue); color: #fff; margin-left: auto; border-bottom-right-radius: 4px;
}
.orbmsg.thinking { color: var(--muted); font-style: italic; }
.orbmsg.err { background: var(--bad-bg); color: #991B1B; }
.orbmsg a { color: var(--blue); }

.orbchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.orbchips button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 12px; font-size: 12px; font-family: inherit; color: var(--muted); cursor: pointer;
}
.orbchips button:hover { border-color: var(--blue); color: var(--blue); }

.orbprop {
  border: 1px solid #D3E3FF; background: var(--blue-soft); border-radius: var(--r-sm);
  padding: 12px; margin-bottom: 10px;
}
.orbprop b { font-size: 14px; display: block; }
.orbpropmeta { font-size: 12px; color: #1E3A8A; margin: 5px 0 10px; }
.orbprop button {
  width: 100%; padding: 9px; border: none; border-radius: 7px;
  background: var(--blue); color: #fff; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}

.orbfoot {
  display: flex; gap: 8px; align-items: center; padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
}
.orbfoot input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 15px;
}
.orbmic, .orbsend {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; font-size: 15px;
}
.orbsend { background: var(--blue); color: #fff; border-color: var(--blue); }
.orbmic.on { background: var(--bad); border-color: var(--bad); color: #fff; animation: micpulse 1.4s infinite; }
.orbmic:disabled, .orbsend:disabled, .orbfoot input:disabled { opacity: .45; cursor: not-allowed; }
.orbspeak {
  display: flex; align-items: center; gap: 7px; padding: 0 14px 12px;
  font-size: 12px; color: var(--muted);
}
.orbspeak input { width: auto; }

@media (max-width: 699px) {
  .orb { right: 16px; bottom: calc(70px + env(safe-area-inset-bottom)); width: 54px; height: 54px; }
  .orbpanel {
    right: 8px; left: 8px; width: auto;
    bottom: calc(132px + env(safe-area-inset-bottom));
    max-height: calc(100vh - 200px);
  }
  body.orb-open .tabbar { display: none; }
  body.orb-open .orb { bottom: 16px; }
  body.orb-open .orbpanel { bottom: 80px; max-height: calc(100vh - 110px); }
}

/* ==========================================================================
   Installable app, toasts and task alerts
   ========================================================================== */

.installbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 22px; z-index: 88;
  display: flex; align-items: center; gap: 16px;
  background: var(--ink); color: #fff;
  padding: 12px 14px 12px 18px; border-radius: 14px;
  box-shadow: 0 18px 44px -14px rgba(2,8,23,.7);
  max-width: calc(100vw - 32px);
}
.installbar[hidden] { display: none; }
.installbar b { display: block; font-family: 'Sora', sans-serif; font-size: 14px; }
.installbar small { display: block; font-size: 11px; color: #94A3B8; margin-top: 2px; }
.installacts { display: flex; gap: 8px; flex-shrink: 0; }
.installacts button {
  border: none; border-radius: 8px; padding: 9px 14px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600;
}
#installNo { background: rgba(255,255,255,.12); color: #CBD5E1; }
#installYes { background: var(--blue); color: #fff; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed; right: 18px; top: 18px; z-index: 95;
  display: flex; flex-direction: column; gap: 9px;
  max-width: calc(100vw - 36px); width: 360px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 13px; box-shadow: 0 16px 40px -14px rgba(2,8,23,.4);
  font-size: 14px; color: var(--text); text-decoration: none;
  opacity: 0; transform: translateY(-8px); transition: opacity .25s, transform .25s;
  pointer-events: auto;
}
.toast.go { opacity: 1; transform: none; }
.toast:hover { text-decoration: none; }
.toast > i { margin-top: 2px; color: var(--faint); flex-shrink: 0; }
.toast > span { flex: 1; line-height: 1.45; }
.toast > button {
  border: none; background: none; color: var(--faint); font-size: 18px; line-height: 1;
  cursor: pointer; padding: 0 2px; flex-shrink: 0;
}
.toast.t-task { border-left: 4px solid var(--blue); }
.toast.t-task > i { color: var(--blue); }
.toast.t-ok { border-left: 4px solid var(--good); }
.toast.t-ok > i { color: var(--good); }

/* a quiet dot on the tab when something new landed */
.tabbar a.has-new { position: relative; }
.tabbar a.has-new::after {
  content: ''; position: absolute; top: 7px; right: calc(50% - 16px);
  width: 8px; height: 8px; border-radius: 50%; background: var(--blue);
  box-shadow: 0 0 0 2px #fff;
}

@media (max-width: 699px) {
  .toasts { right: 8px; left: 8px; top: 8px; width: auto; }
  .installbar {
    left: 8px; right: 8px; transform: none; max-width: none;
    bottom: calc(70px + env(safe-area-inset-bottom));
    flex-direction: column; align-items: stretch; gap: 10px; padding: 14px;
  }
  .installacts button { flex: 1; }
}

/* In an installed window there is no browser chrome, so give the bar back
   the space the notch would have taken. */
@media (display-mode: standalone) {
  .mobile-bar { padding-top: calc(14px + env(safe-area-inset-top)); }
  .installbar { display: none !important; }
}

/* ---------- keep me signed in ---------- */
.keepme {
  display: flex; align-items: center; gap: 9px; margin: -4px 0 16px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.keepme input { width: auto; margin: 0; }

/* ==========================================================================
   Projects — quantities, health and money
   ========================================================================== */

.card.monthstart > .body {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.card.monthstart b { font-family: 'Sora', sans-serif; font-size: 15px; display: block; }
.card.monthstart small { font-size: 12px; color: var(--muted); }

.card.proj.h-late   { border-left: 4px solid var(--bad); }
.card.proj.h-behind { border-left: 4px solid var(--warn); }
.card.proj.h-ontrack,
.card.proj.h-ahead  { border-left: 4px solid var(--good); }
.card.proj.h-done   { border-left: 4px solid var(--line); }

.progwrap { margin-bottom: 12px; }
.progbar { position: relative; overflow: visible; }
.progbar > i { position: relative; z-index: 1; }
.nowmark {
  position: absolute; top: -4px; bottom: -4px; width: 2px; z-index: 2;
  background: var(--ink); opacity: .45; border-radius: 2px;
}
.behindnote { color: var(--warn); font-weight: 600; margin-left: 6px; }

/* ---------- a deliverable row ---------- */
.delrow {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 2px; border-bottom: 1px solid var(--line-soft);
}
.delrow:last-child { border-bottom: none; }
.delmain { flex: 1; min-width: 0; }
.deltitle { font-size: 14px; display: block; }
.delrow.is-done .deltitle { color: var(--faint); text-decoration: line-through; }
.delmeta { font-size: 11px; color: var(--faint); font-family: 'JetBrains Mono', monospace; }
.delcount { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.delcount form { display: flex; }
.delnum {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--muted);
  min-width: 42px; text-align: center;
}
.delnum b { color: var(--text); font-weight: 700; }
.stepbtn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 16px; line-height: 1; cursor: pointer;
  font-family: inherit;
}
.stepbtn.add { border-color: var(--blue); color: var(--blue); font-weight: 700; }
.stepbtn:disabled { opacity: .35; cursor: not-allowed; }
.stepbtn:not(:disabled):hover { background: var(--paper); }
.delcount .checkbtn { width: auto; padding: 5px 8px; }

/* ---------- the money block ---------- */
.projmoney {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.projmoney > div { background: var(--paper); border-radius: var(--r-sm); padding: 9px 11px; }
.projmoney span {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.projmoney b { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; }
.projmoney .tot { background: var(--blue-soft); }
.projmoney b.neg { color: var(--bad); }

/* ---------- the client link ---------- */
.sharebox { display: flex; gap: 8px; align-items: center; }
.sharebox input {
  flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 12px;
  background: var(--paper);
}

@media (max-width: 699px) {
  .delrow { flex-wrap: wrap; gap: 8px; }
  .delmain { flex: 1 1 100%; }
  .delcount { margin-left: auto; }
  .card.monthstart > .body { flex-direction: column; align-items: stretch; }
}

.moneynote {
  font-size: 11px; color: var(--faint); line-height: 1.55; margin: 8px 0 0;
}

/* A single-quantity deliverable gets a real box, not just an icon, so it is
   still obvious if the icon font fails to load. */
.delcount .checkbtn {
  width: 30px; height: 30px; padding: 0; border-radius: 8px;
  border: 1.5px solid var(--line); background: #fff;
  display: grid; place-items: center;
}
.delcount .checkbtn i { font-size: 13px; color: var(--faint); }
.delcount .checkbtn.on { background: var(--good); border-color: var(--good); }
.delcount .checkbtn.on i { color: #fff; }
.delcount .checkbtn.on::after { content: ''; }
.delcount .checkbtn:not(.on):hover { border-color: var(--blue); }

.seenbtn {
  border: none; background: none; cursor: pointer; padding: 3px 5px;
  color: var(--line); font-size: 12px;
}
.seenbtn.on { color: var(--blue); }
.seendot { color: var(--blue); font-size: 11px; margin-left: 4px; }

/* ---------- invoices ---------- */
.agerow {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px;
}
.agerow > div { background: var(--paper); border-radius: var(--r-sm); padding: 11px 13px; }
.agerow span {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.agerow b { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; }
.agerow > div.warn { background: var(--warn-soft); }
.agerow > div.warn b { color: var(--warn); }
.agerow > div.bad { background: var(--bad-soft); }
.agerow > div.bad b { color: var(--bad); }

.doctot {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px; margin: 12px 0;
}
.doctot > div { background: var(--paper); border-radius: var(--r-sm); padding: 9px 11px; }
.doctot span {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.doctot b { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; }
.doctot .tot { background: var(--blue-soft); }

.card.doc.is-cancelled { opacity: .62; }

.lineRow {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 2px; border-bottom: 1px solid var(--line-soft);
}
.lineRow:last-of-type { border-bottom: none; }
.lineMain { flex: 1; min-width: 0; }
.lineMain b { display: block; font-size: 14px; font-weight: 600; }
.lineMain small { font-size: 11px; color: var(--faint); font-family: 'JetBrains Mono', monospace; }
.lineAmt { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; flex-shrink: 0; }

@media (max-width: 699px) {
  .lineRow { flex-wrap: wrap; }
  .lineMain { flex: 1 1 100%; }
}

/* ==========================================================================
   The one-screen invoice editor
   ========================================================================== */

.invedit { padding-bottom: 92px; }

.invtop { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.invcol { min-width: 0; }

.numbox {
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; font-family: 'JetBrains Mono', monospace; font-size: 13px;
}
.numbox b { color: var(--blue); }
.numbox small { font-family: 'Inter', sans-serif; color: var(--faint); font-size: 11px; margin-left: auto; }

.addbar { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; }
.addbar select {
  min-width: 210px; max-width: 320px; padding: 9px 11px; font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff;
  font-family: inherit; color: var(--text);
}

.linetbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.linetbl { width: 100%; border-collapse: collapse; min-width: 780px; }
.linetbl th {
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.linetbl td { padding: 6px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.linetbl input, .linetbl select {
  width: 100%; padding: 8px 9px; font-size: 13px; border: 1px solid var(--line);
  border-radius: 7px; font-family: inherit; background: #fff; color: var(--text);
}
.linetbl input:focus, .linetbl select:focus { outline: none; border-color: var(--blue); }
.linetbl .c-item { min-width: 180px; }
.linetbl .c-desc { min-width: 150px; }
.linetbl .c-sac  { width: 84px; }
.linetbl .c-qty  { width: 78px; }
.linetbl .c-rate { width: 110px; }
.linetbl .c-disc { width: 128px; }
.linetbl .c-amt  { width: 108px; text-align: right; white-space: nowrap; }
.linetbl .c-x    { width: 34px; }
.linetbl .lamt { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; }
.linetbl th.c-amt { text-align: right; }

.discpair { display: flex; gap: 4px; }
.discpair input { flex: 1; min-width: 0; }
.discpair select { width: 54px; flex-shrink: 0; padding-left: 6px; padding-right: 4px; }
.discpair.right { justify-content: flex-end; max-width: 150px; margin-left: auto; }

.totwrap {
  display: flex; gap: 30px; margin-top: 20px; padding-top: 18px;
  border-top: 1px solid var(--line); align-items: flex-start;
}
.totnote { flex: 1; font-size: 12px; color: var(--muted); line-height: 1.6; min-width: 0; }
.tottbl { width: 330px; flex-shrink: 0; border-collapse: collapse; font-size: 13.5px; }
.tottbl td { padding: 6px 0; }
.tottbl td.r { text-align: right; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.tottbl tr.off td { color: var(--good); }
.tottbl tr.rule td { border-top: 1px solid var(--line); padding-top: 10px; }
.tottbl tr.grand td {
  border-top: 2px solid var(--ink); padding-top: 10px;
  font-family: 'Sora', sans-serif; font-weight: 700; font-size: 16px;
}
.tottbl tr.grand td.r { font-family: 'JetBrains Mono', monospace; }
.tottbl tr.tdsrow td { color: var(--muted); font-size: 12px; }
.tottbl tr.netrow td { border-top: 1px solid var(--line); padding-top: 7px; font-weight: 700; }
.tottbl .offamt { font-size: 11.5px; color: var(--good); margin-top: 3px; min-height: 14px; }
.tottbl input, .tottbl select {
  padding: 6px 8px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; background: #fff; color: var(--text);
}

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  padding: 12px 22px; display: flex; gap: 9px; justify-content: flex-end;
  box-shadow: 0 -6px 20px -12px rgba(2,8,23,.3);
}

@media (min-width: 1024px) {
  .savebar { left: var(--nav-w, 214px); }
}
@media (max-width: 1023px) {
  .invtop { grid-template-columns: 1fr; gap: 0; }
  .savebar { padding: 11px 14px; bottom: 0; }
}
@media (max-width: 699px) {
  .invedit { padding-bottom: 150px; }
  .totwrap { flex-direction: column; gap: 16px; }
  .tottbl { width: 100%; }
  .savebar {
    bottom: calc(64px + env(safe-area-inset-bottom));
    flex-wrap: wrap; padding: 10px 12px;
  }
  .savebar .btn { flex: 1; justify-content: center; }
  .addbar select { min-width: 100%; }
}

/* The assistant orb must not sit on top of Save & issue. */
body.has-savebar .orb,
body.has-savebar .assistant-orb,
body.has-savebar .ai-orb { bottom: 88px; }
@media (max-width: 699px) {
  body.has-savebar .orb,
  body.has-savebar .assistant-orb,
  body.has-savebar .ai-orb { bottom: calc(136px + env(safe-area-inset-bottom)); }
}

.logorow { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; }
.logorow > div:last-child { flex: 1; min-width: 220px; }
.logobox {
  width: 168px; height: 84px; border: 1px dashed var(--line); border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--paper); flex-shrink: 0; padding: 8px;
}
.logobox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logobox span { font-size: 11px; color: var(--faint); }
