/* Garage Hub - CrowsNest-like look: dark green header, pill tabs, white cards, big tiles, green table heads.
   System fonts only (works offline; no external fonts). */
:root {
  --brand: #1d4d36; --brand-2: #2e6b4c; --brand-ink: #ffffff; --accent: #3f9a6b;
  --page: #eef2ef; --card: #ffffff; --ink: #17201b; --muted: #5f6b64; --line: #d6ddd8; --hover: #f2f6f3;
  --thead: #2e6b4c; --thead-ink: #ffffff;
  --ok: #1f8a4c; --ok-bg: #dcf1e3; --warn: #9a6400; --warn-bg: #fdf0cf; --bad: #b42d27; --bad-bg: #fbe1df;
  --info: #2f5fb3; --info-bg: #e1eafa; --grey: #6b736e; --grey-bg: #eceeed; --purple: #6a3fa0; --purple-bg: #ece2f8;
  --r: 12px;
  /* chart tokens: same palette as the garage dashboard (cmapi/garage/report.py) */
  --series-1: #2a78d6; --grid: #e1e0d9; --axis: #c3c2b7;
  font-family: "Times New Roman", Times, serif;
}
:root[data-theme="dark"] {
  --brand: #12301f; --brand-2: #1f4a33; --page: #0f1411; --card: #18201b; --ink: #e6ece8; --muted: #9aa69f;
  --line: #2c3a31; --hover: #202a24; --thead: #1f4a33;
  --ok: #6fd49a; --ok-bg: #173826; --warn: #f2c25b; --warn-bg: #3d3115; --bad: #ff8a80; --bad-bg: #44201d;
  --info: #8fb2f5; --info-bg: #1d2a44; --grey: #a5ada8; --grey-bg: #272d29; --purple: #c6a5f0; --purple-bg: #31254a;
  --series-1: #3987e5; --grid: #2c2c2a; --axis: #383835;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }

.top { background: var(--brand); color: var(--brand-ink); display: flex; justify-content: space-between; align-items: center;
       padding: 12px 20px; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { background: var(--brand-ink); color: var(--brand); font-weight: 800; border-radius: 8px; padding: 4px 7px; font-size: 13px; }
.brand h1 { font-size: 21px; font-weight: 700; letter-spacing: .01em; }
.badge-testing { background: #f2b33d; color: #2b1d00; font-weight: 800; font-size: 11px; letter-spacing: .08em; padding: 3px 8px; border-radius: 999px; }
.top-right { display: flex; gap: 12px; align-items: center; }
.today { opacity: .85; }
.top .ghost { color: var(--brand-ink); border-color: rgba(255,255,255,.4); }

/* burger menu (two sections) */
.menu-wrap { position: relative; }
.burger { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 6px 14px;
          border: 1px solid rgba(255,255,255,.45); background: transparent; color: var(--brand-ink); font-weight: 600; }
.burger[aria-expanded="true"] { background: rgba(255,255,255,.15); }
.burger-icon { display: inline-flex; flex-direction: column; gap: 3px; }
.burger-icon span { display: block; width: 16px; height: 2px; background: currentColor; border-radius: 1px; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); width: 300px; background: var(--card); color: var(--ink);
        border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 30px rgba(0,0,0,.25); padding: 8px; z-index: 70; }
.menu h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 8px 4px; }
.menu a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.menu a:hover, .menu a:focus-visible { background: var(--hover); }
.menu a[aria-current="page"] { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.menu a.sec { font-weight: 700; }
.menu .sub { padding-left: 22px; font-size: 13px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.section-bar { padding: 12px 20px 0; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.section-title { font-size: 15px; color: var(--muted); font-weight: 700; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 16px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
main { padding: 14px 20px 30px; }
.foot { color: var(--muted); font-size: 12px; padding: 0 20px 24px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 14px; }
.card h3 { font-size: 16px; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card h3 small { color: var(--muted); font-weight: 500; font-size: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; border-top: 5px solid var(--accent); }
.tile b { display: block; font-size: 32px; line-height: 1.1; font-weight: 800; }
.tile span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tile small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile.bad { border-top-color: var(--bad); } .tile.bad b { color: var(--bad); }
.tile.warn { border-top-color: var(--warn); } .tile.warn b { color: var(--warn); }
.tile.ok { border-top-color: var(--ok); } .tile.ok b { color: var(--ok); }
.tile.info { border-top-color: var(--info); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.toolbar label { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }
button.btn, .ghost { border-radius: 999px; padding: 6px 14px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
button.btn.primary { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
button.btn.danger { color: var(--bad); border-color: var(--bad); }
.ghost { background: transparent; }
input, select, textarea { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 5px 8px; }
textarea { width: 100%; min-height: 60px; }

table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: var(--thead); color: var(--thead-ink); font-weight: 600; position: sticky; top: 0; z-index: 1; }
tbody tr.click:hover { background: var(--hover); cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); padding: 10px 0; }
.scroll { overflow: auto; max-height: 70vh; }

.pill { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.s-OVERDUE { background: var(--bad-bg); color: var(--bad); }
.s-DUE_SOON { background: var(--warn-bg); color: var(--warn); }
.s-IN_DATE { background: var(--ok-bg); color: var(--ok); }
.s-UNKNOWN { background: var(--grey-bg); color: var(--grey); }
.s-BOOKED { background: var(--info-bg); color: var(--info); }
.s-PLANNED { background: var(--info-bg); color: var(--info); }
.s-IN_PROGRESS { background: var(--warn-bg); color: var(--warn); }
.s-DONE { background: var(--ok-bg); color: var(--ok); }
.s-CANCELLED { background: var(--grey-bg); color: var(--grey); text-decoration: line-through; }
.flag { color: var(--warn); font-weight: 700; font-size: 11px; }

/* availability board */
.board-wrap { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.board { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.board th, .board td { border-bottom: 1px solid var(--line); padding: 3px 4px; }
.board thead th { text-align: center; font-size: 12px; }
.board thead th.today-col { background: var(--accent); }
.board .stick { position: sticky; left: 0; background: var(--card); z-index: 2; min-width: 190px; max-width: 240px; }
.board thead .stick { background: var(--thead); z-index: 3; }
.board tr.div-row td { background: var(--brand-2); color: #fff; font-weight: 700; }
.board tr.div-row td.stick { background: var(--brand-2); }
.board tr.pool-row td { background: var(--hover); font-weight: 700; }
.board tr.pool-row td.stick { background: var(--hover); }
.board tr.tot td { font-size: 11.5px; text-align: center; background: var(--grey-bg); }
.board tr.tot td.stick { text-align: left; background: var(--grey-bg); }
.board .reg { font-weight: 700; font-family: "Times New Roman", Times, serif; }
.cell { width: 34px; min-width: 34px; height: 24px; border-radius: 5px; border: 1px solid transparent; font-size: 11px; font-weight: 700; padding: 0; }
.cell.none { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.cell.off { background: transparent; color: var(--muted); cursor: default; }
.cell.src-import { opacity: .82; }
.cell.src-booking, .cell.src-hold { border-style: dashed; border-color: currentColor; }
.c-AVAILABLE { background: var(--ok-bg); color: var(--ok); }
.c-NO_DRIVER { background: #e7f5dc; color: #47750f; }
.c-VOR_BREAKDOWN, .c-VOR_DAMAGE, .c-VOR_UNKNOWN { background: var(--bad-bg); color: var(--bad); }
.c-WORKSHOP_PLANNED { background: var(--info-bg); color: var(--info); }
.c-AWAITING_PARTS { background: var(--warn-bg); color: var(--warn); }
.c-COMPLIANCE_HOLD { background: var(--purple-bg); color: var(--purple); }
.c-OFF_HIRE, .c-NOT_APPLICABLE, .c-DISPOSED { background: var(--grey-bg); color: var(--grey); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; margin: 8px 0; }
.legend span.cell { display: inline-flex; align-items: center; justify-content: center; }
.pct-bad { color: var(--bad); font-weight: 700; } .pct-warn { color: var(--warn); font-weight: 700; } .pct-ok { color: var(--ok); font-weight: 700; }
.code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin: 8px 0; }
.code-grid button { text-align: left; border-radius: 8px; padding: 6px 8px; border: 2px solid transparent; }
.code-grid button[aria-pressed="true"] { border-color: var(--ink); }

/* compliance calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--card); }
.cal .dow { background: var(--thead); color: #fff; font-size: 12px; padding: 5px 8px; font-weight: 600; }
.cal .day { min-height: 104px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 4px 5px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal .day.out { background: var(--page); opacity: .7; }
.cal .day.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .dn { font-weight: 700; font-size: 12px; display: flex; justify-content: space-between; }
.chip { display: block; width: 100%; text-align: left; border: 0; border-radius: 4px; padding: 1px 5px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { font-size: 11px; color: var(--muted); }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week .wday { background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-height: 140px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.week .wday.is-today { border-color: var(--accent); border-width: 2px; }
.week h4 { margin: 0 0 4px; font-size: 12px; color: var(--muted); }

.strip { display: flex; gap: 2px; flex-wrap: wrap; }
.strip .cell { width: 26px; min-width: 26px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 50; overflow: auto; }
.modal-box { background: var(--card); border-radius: var(--r); width: min(640px, 100%); padding: 16px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.modal-head, .drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--card); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0,0,0,.2); padding: 16px 18px; overflow: auto; z-index: 40; }
.form { display: grid; grid-template-columns: 140px 1fr; gap: 8px 10px; align-items: center; margin: 8px 0; }
.form label { color: var(--muted); font-size: 12.5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 3px 10px; font-size: 13px; margin-bottom: 10px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--page); padding: 8px 16px; border-radius: 999px; z-index: 60; }
.toast.err { background: var(--bad); color: #fff; }
.note-box { background: var(--warn-bg); color: var(--ink); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 10px; }

/* unconfirmed-assumption marker (text, not colour only) */
.unconf { display: inline-block; margin-left: 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
          letter-spacing: .04em; color: var(--warn); border: 1px dashed var(--warn); border-radius: 999px; padding: 0 6px;
          text-decoration: none; vertical-align: middle; white-space: nowrap; }
.unconf:hover, .unconf:focus-visible { background: var(--warn-bg); }
/* bookings in the compliance calendar: outlined + "BK" label */
.chip.bk { background: transparent; border: 1.5px solid var(--info); color: var(--info); }
.chip.bk b { font-size: 10px; margin-right: 3px; }
.chip.bk.s-DONE { border-style: dashed; opacity: .75; }
/* parent groups on the board */
.board tr.group-row td { background: var(--brand); color: #fff; font-weight: 700; }
.board tr.group-row td.stick { background: var(--brand); }
.board tr.pool-row.sub td.stick { padding-left: 18px; }
.board tr.tot.group-tot td { background: var(--ok-bg); font-weight: 700; }
.board tr.tot.group-tot td.stick { background: var(--ok-bg); }
tr.grp td { font-weight: 700; background: var(--hover); }
td.indent { padding-left: 22px; }
/* charts (single series, palette tokens, hover tooltip, table view) */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; }
.chart .hit:hover + .bar { opacity: .8; }
.chart .value-label { fill: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.tooltip { position: absolute; pointer-events: none; background: var(--card); color: var(--ink); border: 1px solid var(--line);
           border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.15); white-space: nowrap; display: none; z-index: 5; }
.tooltip b { font-variant-numeric: tabular-nums; }
.placeholder { border: 2px dashed var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--card); }
.placeholder h4 { margin: 0 0 4px; }
.soon { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--info); border: 1px solid var(--info); border-radius: 999px; padding: 0 8px; }
th.sortable { cursor: pointer; }
th[aria-sort="ascending"]::after { content: " \25B2"; font-size: 10px; }
th[aria-sort="descending"]::after { content: " \25BC"; font-size: 10px; }

@media (max-width: 900px) {
  .menu { position: fixed; left: 12px; right: 12px; width: auto; top: 64px; }
}
@media (max-width: 700px) {
  .form { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr; }
  .cal .day { min-height: 60px; }
}

/* shared KPI week selector (week.js) and workshop tabs (maint.js), maintenance-manager */
.week-sel { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.week-sel select { max-width: 320px; }
.week-sel button[disabled] { opacity: .45; cursor: default; }
.week-range { margin-left: 4px; }
.note-box.banner { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; margin-bottom: 8px; }
.dayc { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; border-top-width: 4px; }
.dayc b, .dayc span, .dayc small { display: block; }
.dayc span { font-weight: 700; }
.dayc small { color: var(--muted); font-size: 11.5px; }
.dayc.ok { border-top-color: var(--ok); } .dayc.ok span { color: var(--ok); }
.dayc.bad { border-top-color: var(--bad); } .dayc.bad span { color: var(--bad); }
