:root {
  /* Palette and proportions in the style of the SB Admin Pro dashboard look */
  --primary: #0061f2;
  --secondary: #6900c7;
  --bg: #f2f6fc;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --border: #e0e5ec;
  --text: #69707a;
  --heading: #363d47;
  --text-muted: #a2acba;
  --accent: var(--primary);
  --accent-ink: #ffffff;
  --accent-soft: #e0ebfd;
  --series: #0061f2;
  --good: #00ac69;
  --good-soft: #d7f2e6;
  --warn: #c47e00;
  --warn-soft: #fdf1d8;
  --bad: #e81500;
  --bad-soft: #fcdedb;
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --nav-h: 3.625rem;
  --side-w: 15rem;
  --radius: .35rem;
  --shadow: 0 .15rem 1.75rem 0 rgba(33, 40, 50, .15);
  --shadow-sm: 0 .125rem .25rem 0 rgba(33, 40, 50, .2);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --surface: #1b212a;
    --surface-2: #222934;
    --border: #2f3744;
    --text: #b9c1cc;
    --heading: #e8ecf1;
    --text-muted: #8590a0;
    --primary: #3d8bff;
    --accent-ink: #ffffff;
    --accent-soft: #1c2c47;
    --series: #4b93ff;
    --good: #3fcf91;
    --good-soft: #14302a;
    --warn: #f0b544;
    --warn-soft: #33290f;
    --bad: #ff6b5c;
    --bad-soft: #3a1c1a;
    --gradient: linear-gradient(135deg, #0050c8 0%, #5600a4 100%);
    --shadow: 0 .15rem 1.25rem 0 rgba(0, 0, 0, .45);
    --shadow-sm: 0 .125rem .25rem 0 rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 "Metropolis", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--heading); font-weight: 500; }
h1 { font-size: 1.75rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }

/* ---- App shell: top bar, side navigation, content ---- */
.topnav {
  position: fixed; inset: 0 0 auto 0; height: var(--nav-h); z-index: 40;
  display: flex; align-items: center; gap: 8px; padding: 0 16px 0 8px;
  background: var(--surface); box-shadow: 0 .15rem 1.75rem 0 rgba(31, 45, 65, .15);
}
.topnav .brand { font-weight: 600; font-size: 1.05rem; color: var(--heading); display: flex; align-items: center; gap: 10px; padding: 0 8px; white-space: nowrap; }
.topnav .brand:hover { text-decoration: none; }
.topnav .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.topnav .user { display: flex; align-items: center; gap: 10px; color: var(--heading); font-size: .9rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gradient); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.layout { display: flex; min-height: 100vh; padding-top: var(--nav-h); }
.sidebar {
  position: fixed; top: var(--nav-h); bottom: 0; left: 0; width: var(--side-w); z-index: 30;
  background: var(--surface); box-shadow: .15rem 0 1.75rem 0 rgba(33, 40, 50, .15);
  display: flex; flex-direction: column; transition: transform .15s ease-in-out;
}
.nav { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.nav-heading { font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); padding: 22px 16px 8px; }
.nav a { display: flex; align-items: center; gap: 14px; color: var(--heading); padding: 10px 16px; font-size: .95rem; position: relative; }
.nav a .ico { color: var(--text-muted); }
.nav a:hover { color: var(--primary); text-decoration: none; }
.nav a:hover .ico, .nav a.active .ico { color: var(--primary); }
.nav a.active { color: var(--primary); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.whoami { background: var(--surface-2); padding: 12px 16px; font-size: .8rem; border-top: 1px solid var(--border); }
.whoami .who { color: var(--heading); font-size: .95rem; font-weight: 500; }
.main { flex: 1; min-width: 0; margin-left: var(--side-w); padding: 0 24px 60px; transition: margin .15s ease-in-out; }
body.side-hidden .sidebar { transform: translateX(-100%); }
body.side-hidden .main { margin-left: 0; }
.side-backdrop { display: none; }
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; padding: 0 12px 40px; }
  body.side-open .sidebar { transform: none; }
  body.side-open .side-backdrop { display: block; position: fixed; inset: var(--nav-h) 0 0 0; background: rgba(0, 0, 0, .35); z-index: 25; }
  .topnav .user .name { display: none; }
}

/* ---- Page header: gradient band; the first card overlaps it ---- */
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 -24px 24px; padding: 32px 24px 28px; background: var(--gradient); color: rgba(255, 255, 255, .75);
}
.page-head h1 { color: #fff; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .sub { color: rgba(255, 255, 255, .75); margin-top: 6px; }
.page-head .sub a { color: #fff; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .5); }
.page-head:has(+ .card, + .grid, + form.grid, + .board) { padding-bottom: 88px; margin-bottom: 0; }
.page-head + .card, .page-head + .grid, .page-head + form.grid, .page-head + .board { margin-top: -56px; position: relative; }
.page-head .btn { background: rgba(255, 255, 255, .15); border-color: transparent; color: #fff; }
.page-head .btn:hover { background: rgba(255, 255, 255, .25); }
.page-head .btn.primary { background: #fff; color: var(--primary); }
.page-head .btn.danger { color: #ffd2cc; }
.page-head .badge { background: rgba(255, 255, 255, .18); color: #fff; border-color: transparent; font-size: .8rem; }
@media (max-width: 991px) { .page-head { margin: 0 -12px 16px; padding: 24px 12px 20px; } .page-head:has(+ .card, + .grid, + form.grid, + .board) { padding-bottom: 72px; } }

.card { background: var(--surface); border: 1px solid rgba(33, 40, 50, .08); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card > h2:first-child { margin: -20px -20px 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--primary); font-size: 1rem; border-radius: var(--radius) var(--radius) 0 0; }
.card + .card { margin-top: 24px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* Stat cards: coloured left border like the theme's dashboard cards */
.stat { border-left: .25rem solid var(--primary); }
.grid-4 > .stat:nth-child(2) { border-left-color: var(--secondary); }
.grid-4 > .stat:nth-child(3) { border-left-color: var(--good); }
.grid-4 > .stat:nth-child(4) { border-left-color: #00cfd5; }
.stat .label { color: var(--primary); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.grid-4 > .stat:nth-child(2) .label { color: var(--secondary); }
.grid-4 > .stat:nth-child(3) .label { color: var(--good); }
.grid-4 > .stat:nth-child(4) .label { color: #00a7ac; }
.stat .value { font-size: 1.6rem; font-weight: 600; margin-top: 4px; color: var(--heading); font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--text-muted); font-size: .8rem; margin-top: 2px; }
.stat.hero .value { color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--heading); padding: .5rem 1rem; border-radius: var(--radius); cursor: pointer; font: inherit; font-size: .9rem; font-weight: 500; white-space: nowrap;
  transition: background .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #0055d4; box-shadow: var(--shadow-sm); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .25rem .6rem; font-size: .78rem; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .72rem; color: var(--heading); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
td { color: var(--text); }
td b { color: var(--heading); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
tr.highlight td { background: var(--accent-soft); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .2em .65em; border-radius: 10rem; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); white-space: nowrap; text-transform: capitalize; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--primary); border-color: transparent; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.empty { color: var(--text-muted); padding: 18px; text-align: center; }

form .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
form fieldset { border: 0; padding: 0; margin: 0 0 18px; }
form legend { font-weight: 600; margin-bottom: 10px; padding: 0; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--heading); font-weight: 500; }
label.field.wide { grid-column: 1 / -1; }
label.check { display: flex; gap: 8px; align-items: center; font-size: .875rem; color: var(--heading); }
input, select, textarea {
  font: inherit; font-size: .9rem; font-weight: 400; color: var(--heading); background: var(--surface); border: 1px solid #c5ccd6;
  border-radius: var(--radius); padding: .55rem .85rem; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #80b0f9; box-shadow: 0 0 0 .25rem rgba(0, 97, 242, .25); }
.search { max-width: 320px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar > * { width: auto; }

.tabs { display: flex; gap: 4px; margin: -56px 0 24px; position: relative; overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 8px; }
.page-head:has(+ .tabs) { padding-bottom: 88px; margin-bottom: 0; }
.tabs a { padding: 14px 16px; color: var(--text); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; font-size: .9rem; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--primary); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: var(--surface); border-radius: var(--radius); padding: 12px; min-height: 120px; box-shadow: var(--shadow); border-top: .25rem solid var(--primary); }
.column h3 { display: flex; justify-content: space-between; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--heading); }
.job-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; cursor: pointer; }
.job-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.job-card .t { font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--text-muted); font-size: 12px; white-space: nowrap; min-width: 120px; }
.timeline .body { white-space: pre-wrap; flex: 1; }

.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; display: flex; gap: 8px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--accent-soft); color: var(--text); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 20, .55); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 760px; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast { pointer-events: none; position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 6px; z-index: 60; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: #fff; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 14px; cursor: pointer; font: inherit; color: var(--text-muted); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.month-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 700px) { .month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--text-muted); font-size: 11px; }
.chart .series { fill: none; stroke: var(--series); stroke-width: 2; }
.chart .area { fill: var(--series); opacity: .10; }
.chart .ref-line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .ref-label { fill: var(--text-muted); font-size: 11px; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 6px; padding: 6px 9px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); }

.report-only { display: none; }
@media print {
  .sidebar, .no-print, .toast { display: none !important; }
  .main { padding: 0; }
  .report-only { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* ---- Utilities & auth ---- */
.hidden { display: none !important; }
.mt { margin-top: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
.hint { font-size: 11px; color: var(--text-muted); }
.overdue { color: var(--bad); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.btn.big { padding: 12px 16px; font-size: 15px; justify-content: center; }
.big-code { font-size: 20px; padding: 12px; background: var(--surface-2); border-radius: 6px; text-align: center; user-select: all; }
.modal.wide { max-width: 980px; }
.modal-body { max-height: 70vh; overflow-y: auto; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--gradient); }
.auth-card { box-shadow: 0 1rem 3rem rgba(0, 0, 0, .25); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { margin-bottom: 12px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 18px; color: var(--heading); }
.qr { display: flex; justify-content: center; background: #fff; padding: 10px; border-radius: 8px; }
.steps { padding-left: 18px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 4px 0; }
.tasks { list-style: none; padding: 0; margin: 0; }
.tasks li { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.tasks li label { flex: 1; }
.tasks li.done label { text-decoration: line-through; color: var(--text-muted); }
.note-form { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: start; }
@media (max-width: 700px) { .note-form { grid-template-columns: 1fr; } }
.issues { list-style: none; padding: 0; margin: 6px 0; }
.issues li { padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.issues li.error { background: var(--bad-soft); color: var(--bad); }
.issues li.warning { background: var(--warn-soft); color: var(--warn); }
.issues li a { color: inherit; }
.rec-name { font-size: 18px; font-weight: 650; margin-bottom: 10px; }
.calc-grid { align-items: start; }
details summary { cursor: pointer; color: var(--accent); }
.sigpad { user-select: none; -webkit-user-select: none; position: relative; border: 1px dashed var(--border); border-radius: 8px; overflow: hidden; background: #fff; touch-action: none; }
.sigpad canvas { display: block; touch-action: none; }
.sigpad .btn { position: absolute; top: 6px; right: 6px; }
.sig-img { max-width: 100%; background: #fff; border-radius: 6px; }
.cert-host { overflow-x: auto; }
table.method td { padding: 7px 10px; }
table.method tr.key td { background: var(--accent-soft); font-size: 15px; }
@media (max-width: 1200px) { .calc-grid.grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .calc-grid.grid-3 { grid-template-columns: minmax(0, 1fr); } }
table.method td.num { white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.timeline li.voided .body { text-decoration: line-through; opacity: .6; }
.timeline li.voided .badges { text-decoration: none; }
.tl-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.event-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: start; }
.event-row:last-child { border-bottom: 0; }
.event-row .t { font-weight: 600; color: var(--heading); font-variant-numeric: tabular-nums; }
.event-row.voided .what { text-decoration: line-through; opacity: .6; }
.event-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--text-muted); }
.event-dot.clock_in, .event-dot.clock_out { background: var(--good); }
.event-dot.job_start, .event-dot.job_finish { background: var(--primary); }
.gap-row { padding: 6px 0 6px 82px; color: var(--text-muted); font-size: .8rem; border-bottom: 1px dashed var(--border); }
.week td.num a { color: inherit; }
.sig-box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; max-width: 360px; }
.sig-box img { max-width: 100%; display: block; }
@media print { .sheet-actions { display: none; } }
.mb { margin-bottom: 24px; }
.inv-lines input { min-width: 0; }
.inv-lines td:first-child input { min-width: 260px; }
.inv-lines .num-in { width: 110px; text-align: right; }
code.mono { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.po-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin-top: 10px; }
.po-box .po { font-size: 1.5rem; font-weight: 700; color: var(--primary); letter-spacing: .03em; }
.cost-sum { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.cost-sum > div { display: flex; flex-direction: column; }
.cost-sum b { font-size: 1.15rem; color: var(--heading); font-variant-numeric: tabular-nums; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.bar-cell { min-width: 140px; }
.bar { height: 8px; border-radius: 0 4px 4px 0; background: var(--primary); }
.bar.neg-bar { background: var(--bad); }
.rank { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; background: var(--surface-2); font-size: .75rem; font-weight: 700; margin-right: 6px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
td.num { white-space: nowrap; }

.version-warning { position: sticky; top: 0; z-index: 100; background: #b42318; color: #fff; padding: 10px 16px; font-size: .9rem; text-align: center; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: .8rem; margin: 14px 0; }
.or-line::before, .or-line::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.passkey-btn { width: 100%; justify-content: center; }
.btn.big { white-space: normal; text-align: center; }
