/* OCAIL owner dashboard.
   Layout and type: dark sidebar, cream page, IBM Plex Sans / Plex Mono, yellow active item.
   Chart colours are the validated default data-viz palette: Shift A = slot 1 (blue), Shift B = slot 2
   (orange), as on the Excel Dashboard tab; sleeper types take slots 3-6 so they never read as a shift.
   Target is neutral ink, dashed. Status colours (good / critical) always come with an arrow and a word. */
:root {
  color-scheme: light;
  --page: #f4f2ec;
  --surface: #fcfcfb;
  --row-alt: #f8f5e6;
  --head: #efede6;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --line: #0b0b0b;
  --border: rgba(11, 11, 11, 0.14);
  --wash: #ebe8de;
  --side: #1b1b1a;
  --side-ink: #f0efec;
  --side-muted: #a5a39b;
  --accent: #f6d66b;
  --accent-ink: #1b1b1a;
  --shift-a: #2a78d6;
  --shift-b: #eb6834;
  --combined: #52514e;
  --target: #898781;
  --type-1: #1baf7a;
  --type-2: #eda100;
  --type-3: #e87ba4;
  --type-4: #008300;
  --good: #006300;
  --critical: #c0392f;
  --warn-ink: #9a5b00;
  --warn-ring: #e7a35a;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f0f0e;
    --surface: #1a1a19;
    --row-alt: #20201e;
    --head: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #989690;
    --grid: #2c2c2a;
    --axis: #383835;
    --line: #f0efec;
    --border: rgba(255, 255, 255, 0.14);
    --wash: #262624;
    --side: #0a0a0a;
    --shift-a: #3987e5;
    --shift-b: #d95926;
    --combined: #c3c2b7;
    --type-1: #199e70;
    --type-2: #c98500;
    --type-3: #d55181;
    --type-4: #008300;
    --good: #0ca30c;
    --critical: #e66767;
    --warn-ink: #f0b46b;
    --warn-ring: #9a5b00;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f0f0e;
  --surface: #1a1a19;
  --row-alt: #20201e;
  --head: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #989690;
  --grid: #2c2c2a;
  --axis: #383835;
  --line: #f0efec;
  --border: rgba(255, 255, 255, 0.14);
  --wash: #262624;
  --side: #0a0a0a;
  --shift-a: #3987e5;
  --shift-b: #d95926;
  --combined: #c3c2b7;
  --type-1: #199e70;
  --type-2: #c98500;
  --type-3: #d55181;
  --type-4: #008300;
  --good: #0ca30c;
  --critical: #e66767;
  --warn-ink: #f0b46b;
  --warn-ring: #9a5b00;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 15px/1.45 var(--sans); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: inherit; }
.muted, .sub { color: var(--muted); }
.sub { font-size: 13px; margin: 2px 0 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, td.n { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button, select, input { font: inherit; color: inherit; }

/* ── Shell ───────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink); padding: 24px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
}
.brand { padding: 0 10px; display: grid; gap: 2px; }
.brand strong { font-size: 19px; font-weight: 700; letter-spacing: 0.01em; }
.brand span { color: var(--side-muted); font-size: 13px; }
.nav { display: grid; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; text-decoration: none;
  color: var(--side-ink); font-size: 15.5px; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, 0.07); }
.nav a.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: 0.85; }
.nav kbd, .nav .badge { margin-left: auto; }
kbd {
  font: 500 11px/1 var(--mono); padding: 4px 6px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.28);
  color: var(--side-muted);
}
.nav a.active kbd { border-color: rgba(0, 0, 0, 0.35); color: var(--accent-ink); }
.badge { font: 600 12px/1 var(--mono); background: #f3e3c3; color: #6b4a00; padding: 4px 8px; border-radius: 999px; }
.flags-link .ico { color: var(--accent); }
.nav a.active.flags-link .ico { color: var(--accent-ink); }
.who-am-i { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.12); display: grid; gap: 4px; font-size: 13px; }
.who-am-i span { color: var(--side-muted); }
button.link { background: none; border: 0; padding: 4px 0 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; color: var(--side-ink); text-align: left; }

.main { padding: 28px 40px 56px; max-width: 1280px; width: 100%; }

/* ── Page head ───────────────────────────────────────────────────────────── */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 18px; }
.crumb { font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
.crumb a { text-underline-offset: 3px; }
.headline { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.big { font-size: 52px; font-weight: 700; line-height: 1; letter-spacing: -0.01em; }
.hero-sub { font-size: 19px; color: var(--ink-2); }
.actions { display: flex; gap: 10px; flex: none; }
.btn {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 20px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--wash); }
.btn.solid { background: var(--ink); color: var(--page); border-color: var(--ink); }
.btn.solid:hover { opacity: 0.9; }
.btn:disabled { cursor: progress; opacity: 0.75; }
.btn .spin { display: inline-block; }
.btn.busy .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.busy .spin { animation: none; } html { scroll-behavior: auto; } }

.banner { border: 1.5px solid var(--warn-ring); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.banner.bad { border-color: var(--critical); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; padding: 20px 24px; }
section.card, .charts, #bills { margin-bottom: 18px; }
.section-head { margin-bottom: 4px; }
#bills .section-head { margin: 8px 0 12px; }

.now { display: grid; grid-template-columns: minmax(220px, 1.1fr) minmax(0, 2fr); gap: 20px 28px; margin-bottom: 18px; }
.eyebrow { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.now h2 { font-size: 24px; margin: 2px 0 4px; }
.now-main .muted { font-size: 14px; }
.now-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.fig .label { font-size: 14px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.fig .label .name { color: var(--muted); }
.fig .value { font-size: 30px; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.fig .value small { font-size: 16px; font-weight: 400; color: var(--ink-2); }
.fig .status { margin-top: 4px; }
.now-links { grid-column: 1 / -1; display: flex; gap: 28px; flex-wrap: wrap; font-weight: 500; padding-top: 4px; }
.now-links a { text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.key { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.status { font-size: 14px; font-weight: 600; }
.status.good { color: var(--good); }
.status.bad { color: var(--critical); }
.status.none { color: var(--muted); font-weight: 500; }

/* ── Filters ─────────────────────────────────────────────────────────────── */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.field select {
  appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23777' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 40px 12px 16px; min-width: 200px; cursor: pointer;
}
.summary { color: var(--ink-2); font-size: 14px; padding-left: 6px; font-family: var(--mono); }

/* ── Register table ──────────────────────────────────────────────────────── */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
  background: var(--head); color: var(--ink-2); font-weight: 600; text-align: right; padding: 12px 12px; white-space: nowrap;
  border-bottom: 1.5px solid var(--line); font-size: 13.5px; vertical-align: bottom;
}
th small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
td { padding: 11px 12px; text-align: right; vertical-align: top; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th.l, td.l { text-align: left; }
tbody tr:nth-child(even) td { background: var(--row-alt); }
td.date { font-weight: 600; }
td.who { font-weight: 600; letter-spacing: 0.01em; }
td .under { display: block; font-size: 12px; color: var(--muted); font-family: var(--mono); }
td.remark { white-space: normal; min-width: 180px; width: 32%; text-align: left; color: var(--ink-2); font-size: 13px; }
th, td { padding-left: 10px; padding-right: 10px; }
td.off { color: var(--muted); }
.chip {
  display: inline-block; border: 1.5px solid var(--warn-ring); color: var(--warn-ink); border-radius: 999px;
  padding: 1px 9px; font: 600 12px/1.5 var(--sans); white-space: nowrap;
}
.chip.ok { border-color: var(--good); color: var(--good); }
.chip.none { border-color: var(--grid); color: var(--muted); }
tr.total td { font-weight: 600; border-top: 1.5px solid var(--line); border-bottom: 0; background: var(--head) !important; }
.card table th { position: static; }
.card:not(.table-card) table { font-size: 13px; }
.card:not(.table-card) th { background: var(--head); border-bottom: 1px solid var(--axis); padding: 8px 10px; }
.card:not(.table-card) td { padding: 7px 10px; }

/* ── Charts ──────────────────────────────────────────────────────────────── */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart { position: relative; height: 280px; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }

/* ── Breakdowns ──────────────────────────────────────────────────────────── */
.mini-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 10px 0 16px; }
.mini { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--page); }
.mini .value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.mini .value.muted { color: var(--muted); }
.mini .of { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── Bills ───────────────────────────────────────────────────────────────── */
.bills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.bill h4 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.bill .net { font-size: 30px; font-weight: 600; margin: 6px 0 2px; }
.bill .check { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.bill .check.good { color: var(--good); }
.bill .check.bad { color: var(--critical); }
.bill .section td { color: var(--muted); text-align: left; font-weight: 600; background: transparent !important; padding-top: 14px; }
.bill .muted { font-size: 13px; margin-bottom: 12px; }
.bill .notes { font-size: 13px; color: var(--muted); margin-top: 10px; }

.foot { font-size: 12px; color: var(--muted); margin-top: 24px; }
.empty { text-align: center; color: var(--ink-2); padding: 64px 16px; grid-column: 1 / -1; }

.toast {
  position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: var(--page); padding: 12px 16px;
  border-radius: 12px; font-size: 14px; max-width: 420px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

/* ── Login ───────────────────────────────────────────────────────────────── */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--side); }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 24px; }
.login-card .brand { color: var(--side-ink); padding: 0; }
.login-card .brand span { color: var(--side-muted); }
.login-card form { background: var(--surface); border-radius: 16px; padding: 28px; border: 1.5px solid var(--line); }
.login-card h1 { font-size: 24px; }
.login-card .muted { font-size: 14px; margin: 6px 0 20px; }
.login-card label { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 14px;
}
.login-card input:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
.login-card .btn { width: 100%; justify-content: center; }
.error { color: var(--critical); font-size: 13px; margin: -4px 0 12px; }

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  .app { display: block; }
  .side, .actions, .filters .field, .now-links, details, .toast, #flags { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { break-inside: avoid; border-width: 1px; }
  body { background: #fff; }
}

/* ── Phones: each register row becomes a small card ─────────────────────── */
@media (max-width: 700px) {
  #t-register thead { display: none; }
  #t-register table, #t-register tbody { display: block; }
  #t-register tr { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--grid); }
  #t-register tr:nth-child(even) { background: var(--row-alt); }
  #t-register td { border: 0; padding: 0; background: transparent !important; text-align: left; white-space: normal; }
  #t-register td:nth-child(1) { grid-column: 1 / -1; order: 0; }
  #t-register td:nth-child(1):empty { display: none; }
  #t-register td:nth-child(2) { order: 1; color: var(--ink-2); }
  #t-register td:nth-child(3) { order: 2; }
  #t-register td:nth-child(9) { order: 3; text-align: right; }
  #t-register td:nth-child(8) { order: 4; grid-column: 1 / -1; }
  #t-register td:nth-child(8) .under { display: inline; margin-left: 6px; }
  #t-register td:nth-child(10) { order: 5; grid-column: 1 / -1; color: var(--ink-2); }
  #t-register td:nth-child(10):not(.off)::after { content: " breakdown minutes"; font-family: var(--sans); }
  #t-register td:nth-child(10).off, #t-register td:nth-child(n+4):nth-child(-n+7), #t-register td:nth-child(11) { display: none; }
  #t-register td.remark { order: 6; grid-column: 1 / -1; min-width: 0; width: auto; }
  #t-register td.remark:empty { display: none; }
  #t-register tr.total { background: var(--head); }
}

/* ── Narrow screens: the sidebar becomes a top bar ──────────────────────── */
@media (max-width: 900px) {
  html { scroll-padding-top: 72px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: auto; z-index: 5; padding: 12px 16px; flex-direction: row; align-items: center; gap: 16px; }
  .brand span, .who-am-i, kbd { display: none; }
  .nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .nav a { padding: 8px 10px; font-size: 14px; white-space: nowrap; }
  .nav .ico { display: none; }
  .main { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; justify-content: center; }
  .big { font-size: 40px; }
  .now { grid-template-columns: minmax(0, 1fr); }
  .now-figs, .mini-figs, .charts, .bills { grid-template-columns: minmax(0, 1fr); }
  .field, .field select { width: 100%; min-width: 0; }
  .chart { height: 250px; }
}
