﻿/* TWOSTAR AUTRONICS â€” ERP console. Hand-written CSS: no build step, no Node. */

:root {
    --bg:        #0e1116;
    --surface:   #161b22;
    --surface-2: #1c232c;
    --line:      #2a323d;
    --text:      #e6edf3;
    --muted:     #8b98a8;
    --accent:    #ffab2d;
    --accent-dk: #b3730f;
    --ok:        #3fb950;
    --warn:      #d29922;
    --danger:    #f85149;
    --info:      #58a6ff;
    /* What a thing IS, as opposed to what it needs. Deliberately none of the
       five above: state owns amber, green, red and blue, and a kind that
       borrowed one of them would read as a warning. */
    --veh:       #3fb0a5;   /* vehicle — the whole car */
    --gbx:       #9b8cf0;   /* standalone gearbox — the mechanical internals */
    --mec:       #e07bc0;   /* mechatronic unit — the electronic brain */
    --radius:    10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 "Segoe UI", Roboto, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

.sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    padding: 20px 18px;
    border-bottom: 1px solid var(--line);
}
.brand strong { display: block; font-size: 16px; letter-spacing: .06em; color: var(--accent); }
.brand span   { display: block; font-size: 11px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }

/* --------------------------------------------- the date and time -- */

/* Under the brand, in the same place on every screen. The page head is
   where each screen puts its own buttons, and a clock that moves about
   depending on the page is one nobody learns to glance at. */
.nowbar {
    padding: 12px 18px 14px;
    border-bottom: 1px solid var(--line);
}
.nowbar .t {
    font-size: 21px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
}
.nowbar .d {
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: .02em;
}

.nav { padding: 12px 10px; flex: 1; }
.nav a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 3px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 500;
    text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent); color: #171003; font-weight: 600; }
.nav a.active .pill { background: rgba(0,0,0,.22); color: #171003; }

.pill {
    background: var(--surface-2);
    color: var(--muted);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
}

.nav-section {
    padding: 14px 12px 5px;
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #5d6977;
    font-weight: 700;
}

.whoami {
    border-top: 1px solid var(--line);
    padding: 14px 16px;
    font-size: 13px;
}
.whoami .name { font-weight: 600; }
.whoami .role { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }

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

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.page-head p  { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

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

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.kpis   { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.card > h2 {
    margin: 0;
    padding: 14px 18px;
    font-size: 14px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}
.card-body { padding: 16px 18px; }

/* --- job panels ------------------------------------------------------
   A job card shows one section open — the stage it is actually sitting in —
   and folds the other seven into title bars. Everything stays on the page and
   one click away; only the work of the moment is in front of you. */
.panel-now { border-left: 3px solid var(--accent); }

.panel-folded > summary {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 11px 18px;
    font-size: 13px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.panel-folded > summary::-webkit-details-marker { display: none; }

/* The twisty, drawn rather than relying on the browser's own marker, which
   different browsers put in different places and size differently. */
.panel-folded > summary::before {
    content: "▸";
    font-size: 11px;
    line-height: 1;
    color: var(--muted);
}
.panel-folded[open] > summary::before { content: "▾"; }
.panel-folded[open] > summary { border-bottom: 1px solid var(--line); }
.panel-folded > summary:hover { color: var(--text); }
.panel-folded > summary .small { text-transform: none; letter-spacing: 0; }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.kpi .sub   { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.accent .value  { color: var(--accent); }
.kpi.danger .value  { color: var(--danger); }
.kpi.ok .value      { color: var(--ok); }
.kpi.info .value    { color: var(--info); }

/* Money moving the two directions, coloured wherever it is listed: money in is
   green (a credit), money out is red (a debit). .dr already exists for debits. */
.cr { color: var(--ok); }

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

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
    text-align: left;
    padding: 10px 14px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

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

/* --------------------------------------------------------------- badges */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--line);
}
.badge.ok      { background: rgba(63,185,80,.14);  color: var(--ok);     border-color: rgba(63,185,80,.35); }
.badge.warn    { background: rgba(210,153,34,.14); color: var(--warn);   border-color: rgba(210,153,34,.35); }
.badge.danger  { background: rgba(248,81,73,.14);  color: var(--danger); border-color: rgba(248,81,73,.35); }
.badge.info    { background: rgba(88,166,255,.14); color: var(--info);   border-color: rgba(88,166,255,.35); }
.badge.accent  { background: rgba(255,171,45,.14); color: var(--accent); border-color: rgba(255,171,45,.35); }

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

.flash {
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid;
}
.flash.success { background: rgba(63,185,80,.10); border-color: rgba(63,185,80,.4);  color: #7ee787; }
.flash.error   { background: rgba(248,81,73,.10); border-color: rgba(248,81,73,.4);  color: #ff9c94; }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
}
.alert-list li:last-child { border-bottom: 0; }
.alert-list .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.alert-list .critical .dot { background: var(--danger); }
.alert-list .warn .dot     { background: var(--warn); }
.alert-list .info .dot     { background: var(--info); }

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

label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 5px; }

input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
    width: 100%;
    padding: 9px 11px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* System-assigned values: visible, clearly not editable. */
input[readonly], input:disabled, select:disabled {
    background: var(--surface-2);
    color: var(--muted);
    cursor: not-allowed;
}
textarea { resize: vertical; min-height: 70px; }

.field { margin-bottom: 12px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #171003; }
.btn.primary:hover { background: #ffbd57; }
.btn.danger  { background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.45); color: #ff9c94; }
.btn.ok      { background: rgba(63,185,80,.12); border-color: rgba(63,185,80,.45); color: #7ee787; }
.btn.sm { padding: 5px 11px; font-size: 12px; }
.btn.block { display: block; width: 100%; }

.inline-form { display: inline-block; margin: 0 2px 0 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- login */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1100px 520px at 50% -10%, rgba(255,171,45,.13), transparent 70%),
        var(--bg);
}
.login-box { width: 100%; max-width: 420px; }
.login-box .brand { border: 0; padding: 0 0 22px; text-align: center; }
.login-box .brand strong { font-size: 22px; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.login-hint code { color: var(--accent); background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }

/* --------------------------------------------------------------- misc */

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono  { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; }
.stack > * + * { margin-top: 16px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ------------------------------------------------- document entry forms */

/* Compact inputs for the line-item grid. */
.line-table input, .line-table select { padding: 6px 8px; font-size: 13px; }
.line-table td { padding: 6px 8px; }
.line-table th { padding: 8px; }
.line-table .w-qty  { width: 90px; }
.line-table .w-rate { width: 110px; }
.line-table .w-amt  { width: 120px; }
.line-table .w-tax  { width: 80px; }

.totals { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.totals li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--line);
}
.totals li:last-child { border-bottom: 0; }
.totals .label { color: var(--muted); }
.totals .value { font-variant-numeric: tabular-nums; font-weight: 600; }
.totals li.grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.totals li.grand .value { font-size: 20px; color: var(--accent); }

.dr { color: #ff9c94; }
.cr { color: #7ee787; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.tabs a:hover { color: var(--text); border-color: var(--muted); text-decoration: none; }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: #171003; }

.filter-bar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.filter-bar .field { margin-bottom: 0; }
.filter-bar input, .filter-bar select { width: auto; min-width: 150px; }

.balance-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------------------------------------------------------- hrms: calendar */

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}
.cal-head {
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
    padding-bottom: 4px;
}
.cal-day {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 6px;
    min-height: 74px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cal-day.empty { background: transparent; border-color: transparent; }
.cal-day .n { font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-day .s { font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.cal-day .t { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }

.cal-day.st-PRESENT  { background: rgba(63,185,80,.16);  border-color: rgba(63,185,80,.4); }
.cal-day.st-LATE     { background: rgba(255,171,45,.16); border-color: rgba(255,171,45,.45); }
.cal-day.st-HALF_DAY { background: rgba(88,166,255,.14); border-color: rgba(88,166,255,.4); }
.cal-day.st-ABSENT   { background: rgba(248,81,73,.15);  border-color: rgba(248,81,73,.4); }
.cal-day.st-LEAVE    { background: rgba(163,113,247,.16); border-color: rgba(163,113,247,.45); }
.cal-day.st-HOLIDAY,
.cal-day.st-WEEKOFF  { background: var(--surface); border-style: dashed; }
.cal-day .flag { font-size: 9px; color: var(--accent); font-weight: 700; }

/* -------------------------------------------------------------- hrms: qr */

.qr-card {
    background: #fff;
    border-radius: 10px;
    padding: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.qr-card svg { display: block; width: 100%; height: auto; }

.label-sheet {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}
.label {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: var(--surface);
    text-align: center;
    break-inside: avoid;
}
.label .qr-card { padding: 10px; margin-bottom: 10px; }
.label .code { font-family: Consolas, monospace; font-weight: 700; font-size: 14px; }
.label .who  { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------ hrms: scan */

#scan-view {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #000;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}
.scan-actions .btn { font-size: 15px; padding: 13px 22px; }

/* -------------------------------------------------- service: job board */

.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(230px, 1fr);
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    align-items: start;
}
.board-col {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-height: 120px;
}
.board-col > header {
    padding: 11px 13px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
}
.board-col > .body { padding: 10px; display: flex; flex-direction: column; gap: 9px; }

.job-card {
    display: block;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--muted);
    border-radius: 8px;
    padding: 10px 11px;
    text-decoration: none;
    color: var(--text);
}
.job-card:hover { border-color: var(--muted); text-decoration: none; }
.job-card.p-HIGH, .job-card.p-URGENT { border-left-color: var(--danger); }
.job-card.overdue { border-left-color: var(--danger); background: rgba(248,81,73,.09); }
.job-card .no  { font-family: Consolas, monospace; font-size: 11px; color: var(--muted); }
.job-card .subj{ font-weight: 700; font-size: 14px; margin: 2px 0; }
.job-card .meta{ font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------- service: stage rail */

.rail { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.rail-step {
    flex: 1 1 90px;
    padding: 8px 6px;
    border: 1px solid var(--line);
    border-radius: 7px;
    text-align: center;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface);
}
.rail-step.done    { background: rgba(63,185,80,.16); border-color: rgba(63,185,80,.4); color: #7ee787; }
.rail-step.current { background: var(--accent); border-color: var(--accent); color: #171003; }

.panel-locked { opacity: .55; }

/* ------------------------------------------------------------------ print */

@media print {
    .sidebar, .page-head, .filter-bar, .flash, .btn, .tabs { display: none !important; }
    body { background: #fff; color: #000; }
    .main { padding: 0; }
    .label, .card { border-color: #999; background: #fff; color: #000; }
    .label .who { color: #444; }
}

/* ------------------------------------------- the scanner: how it ended --

   Three buttons rather than a dropdown. Somebody holding a phone in one hand
   at a bench should not have to open a list to say the obvious thing.        */

.status-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-opt {
    position: relative; display: block; text-align: center; cursor: pointer;
    padding: 12px 8px; border-radius: 8px; font-weight: 600; font-size: 13px;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.status-opt input { position: absolute; opacity: 0; pointer-events: none; }
.status-opt:has(input:checked).s-completed     { background: var(--ok);     border-color: var(--ok);     color: #07240d; }
.status-opt:has(input:checked).s-not_completed { background: var(--danger); border-color: var(--danger); color: #2b0806; }
.status-opt:has(input:checked).s-on_hold       { background: var(--warn);   border-color: var(--warn);   color: #241a02; }
.status-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }

/* --------------------------------------------------------- on a phone --

   The sidebar used to become a full-width block on a narrow screen, which
   meant scrolling past twenty menu links to reach the page. It is now a
   drawer that slides over the page and is shut again by tapping anywhere.

   Held open by a checkbox rather than script, so the menu works on a handset
   with an old browser and a bad signal in a workshop, before anything has
   finished loading.                                                        */

.topbar, .nav-scrim, .nav-close { display: none; }

@media (max-width: 860px) {

    /* ------------------------------------------------ the bar on top -- */

    .topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 40;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        padding: 10px 14px;
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
    }
    /* The same clock where the sidebar cannot be seen. Time only: there is
   no room for the date beside a shop name and a staff name, and the
   date is the half somebody already knows. */
.topbar-now {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex: 0 0 auto;
}

.topbar-name {
        font-weight: 700;
        font-size: 13px;
        letter-spacing: .05em;
        color: var(--accent);
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .topbar-who {
        font-size: 11px;
        color: var(--muted);
        white-space: nowrap;
    }

    /* A thumb needs something to hit, not a 16px glyph. */
    .nav-button {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        width: 42px;
        height: 42px;
        margin: -6px 0 -6px -6px;
        padding: 0 9px;
        border-radius: 8px;
        cursor: pointer;
        flex: 0 0 auto;
    }
    .nav-button span {
        display: block;
        height: 2px;
        background: var(--text);
        border-radius: 2px;
    }
    .nav-button:active { background: var(--surface-2); }

    /* ------------------------------------------------- the drawer ----- */

    .shell { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 270px;
        max-width: 84vw;
        flex: none;
        height: 100%;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .18s ease-out;
        box-shadow: 0 0 40px rgba(0, 0, 0, .5);
        padding-top: env(safe-area-inset-top, 0px);
    }

    .nav-toggle:checked ~ .shell .sidebar { transform: translateX(0); }

    /* Tapping the page behind it puts the menu away. Present but invisible
       rather than absent, so it fades instead of appearing all at once —
       display cannot be animated. */
    .nav-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 50;
        background: rgba(0, 0, 0, .55);
        opacity: 0;
        pointer-events: none;
        transition: opacity .18s ease-out;
    }
    .nav-toggle:checked ~ .nav-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    .nav-close {
        display: block;
        position: absolute;
        top: 8px;
        right: 10px;
        width: 38px;
        height: 38px;
        line-height: 36px;
        text-align: center;
        font-size: 26px;
        color: var(--muted);
        cursor: pointer;
        border-radius: 8px;
        z-index: 1;
    }
    .nav-close:active { background: var(--surface-2); }

    /* Room for the thumb, and room for the close button beside the name. */
    .brand { padding-right: 54px; }
    .nav a { padding: 12px 12px; margin-bottom: 2px; }

    /* ------------------------------------------------- the page ------- */

    .main { padding: 16px 14px 48px; }

    .page-head { align-items: flex-start; gap: 10px; margin-bottom: 14px; }
    .page-head h1 { font-size: 20px; }
    .page-head > div:first-child { min-width: 0; }

    /* Actions belong under the title on a narrow screen, not squeezed
       beside it into two words per line. */
    .page-head .btn-row,
    .page-head form { width: 100%; }
    .page-head .btn-row .btn { flex: 1 1 auto; text-align: center; }

    /* A table on a phone scrolls sideways inside its own box. The page
       itself must never move sideways — that is how a form gets lost off
       the edge of the screen. */
    .table-wrap { -webkit-overflow-scrolling: touch; }
    table { font-size: 12.5px; }
    th, td { white-space: nowrap; }

    .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
    .grid.kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
    .kpi .value { font-size: 20px; }

    .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .tabs a, .tabs button { white-space: nowrap; }

    .filter-bar { flex-wrap: wrap; }

    /* The shift log: the hour and its work stack rather than sitting in
       two narrow columns. */
    .shift-slot { flex-direction: column; gap: 6px; }
    .shift-hour { flex: none; }
}

@media (max-width: 520px) {
    /* Two form boxes side by side on a 360px screen is two boxes nobody can
       type in. Below this, one field to a row. */
    .field-row { grid-template-columns: 1fr; }

    .grid.kpis { grid-template-columns: repeat(2, 1fr); }

    .main { padding: 14px 11px 40px; }
    .card-body { padding: 12px; }
    .page-head h1 { font-size: 18px; }
}

/* ------------------------------------------------------- touch screens --

   Not a width, but whether the thing pointing at the screen is a finger.
   A 28px button is fine for a mouse and a coin-toss for a thumb.          */

@media (hover: none) and (pointer: coarse) {
    .btn, .nav a, summary.btn, .tabs a {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .btn.sm { min-height: 34px; }

    /* iOS zooms the whole page in when a field under 16px takes focus, and
       leaves it zoomed. This is the only thing that stops it. */
    input, select, textarea { font-size: 16px; }

    /* Hover styling sticks on a touch screen until something else is
       tapped, which reads as a selection that is not there. */
    .nav a:hover { background: none; color: var(--muted); }
    .nav a.active:hover { background: var(--accent); color: #171003; }
}

/* --- job board ------------------------------------------------------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-col { min-width: 220px; flex: 1 0 220px; }
.board-head {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: 8px 4px; display: flex; justify-content: space-between;
  border-bottom: 2px solid var(--line);
}
.board-head .count { font-weight: 700; color: var(--ink); }
.board-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 6px; padding: 10px; margin-top: 8px;
}
.board-card:hover { border-color: var(--muted); }
.board-card.urgent { border-left-color: #b3261e; }
.board-empty { color: var(--muted); text-align: center; padding: 16px 0; font-size: 13px; }

/* --- stage rail ------------------------------------------------------ */
.stage-rail { display: flex; flex-wrap: wrap; gap: 6px; }
.rung {
  font-size: 11.5px; padding: 4px 10px; border-radius: 20px;
  background: var(--sunk, #eee); color: var(--muted); white-space: nowrap;
}
.rung.done { background: #e4f1e9; color: #10693a; }
.rung.now  { background: #14181c; color: #fff; font-weight: 600; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.photo-strip { display: flex; flex-wrap: wrap; gap: 12px; }

/* A gate reason: standing state, not a failure that just happened. */
.gate-note {
  margin-top: 12px; padding: 10px 12px; border-radius: 6px;
  background: #f8eedc; border-left: 3px solid #8a5b06; color: #6b4705; font-size: 13.5px;
}

/* --- overview tabs --------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 9px 16px; text-decoration: none; color: var(--muted); font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.tab:hover { color: var(--ink, #14181c); }
.tab.active { color: #f0a020; border-bottom-color: #f0a020; font-weight: 600; }

/* ------------------------------------------------------- the scan tag */

.qr-body { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.qr-art {
    flex: 0 0 auto;
    padding: 8px;
    background: #fff;                 /* the code needs white quiet zone, in either theme */
    border: 1px solid var(--line);
    border-radius: 8px;
    line-height: 0;
}
.qr-art svg { display: block; }
.qr-text { flex: 1 1 260px; min-width: 0; }
.qr-text p { overflow-wrap: anywhere; }

/* ------------------------------------------------ intake: the camera */

.shot-progress { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.shot-count { font-size: 26px; font-weight: 800; line-height: 1.1; }
.shot-bar {
    flex: 1 1 180px; height: 8px; border-radius: 99px;
    background: var(--line); overflow: hidden;
}
.shot-bar span { display: block; height: 100%; background: var(--ok); }

.shot-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.shot {
    border: 1px solid var(--line); border-radius: 11px;
    background: var(--surface); overflow: hidden;
}
/* Off-screen rather than display:none, so the label still opens it and the
   keyboard can still reach it. */
.shot-input {
    position: absolute; width: 1px; height: 1px;
    opacity: 0; overflow: hidden; clip: rect(0 0 0 0);
}
.shot-face {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 16px 10px; min-height: 132px;
    text-align: center; cursor: pointer; position: relative;
}
.shot-input:focus-visible + .shot-face { outline: 2px solid var(--accent); outline-offset: -3px; }
.shot-face:hover { background: rgba(127,127,127,.06); }
.shot-cam { color: var(--muted); line-height: 0; }
.shot-name { font-size: 12.5px; font-weight: 700; }
.shot-state { font-size: 10.5px; color: var(--muted); }
.shot-face img {
    width: 100%; height: 90px; object-fit: cover;
    border-radius: 7px; border: 1px solid var(--line);
}
.shot.done { border-color: var(--ok); }
.shot.done .shot-state { color: var(--ok); }
.shot-tick {
    position: absolute; top: 20px; right: 14px;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--ok); color: #fff;
    font-size: 13px; font-weight: 700; line-height: 22px;
}
/* Its photograph is on its way up.

   The picture itself is already showing — it was put there from the phone's
   own copy the moment it was taken — so this marks the tile without hiding it.
   Only this tile refuses a tap, and only until its own upload lands. */
.shot.sending { pointer-events: none; }
.shot.sending .shot-state { color: var(--accent); }
.shot.sending::after {
    content: '';
    position: absolute; left: 0; right: 0; top: 0; height: 3px;
    border-radius: 9px 9px 0 0;
    background: linear-gradient(90deg,
        transparent 0%, var(--accent) 50%, transparent 100%);
    background-size: 220% 100%;
    animation: shotGo 1.1s linear infinite;
}
@keyframes shotGo {
    from { background-position: 120% 0 }
    to   { background-position: -120% 0 }
}

/* It did not arrive. Said on the tile as well as in the banner, because the
   banner scrolls away and the tile is what somebody is looking at. */
.shot.failed { border-color: var(--danger); }
.shot.failed .shot-state { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
    .shot.sending::after { animation: none; background: var(--accent); }
}

@media (max-width: 520px) {
    .shot-grid { grid-template-columns: repeat(2, 1fr); }
}


/* ------------------------------------------- HR: the month register */

.month-grid { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.month-grid th, .month-grid td { padding: 0; }
.month-grid th.who, .month-grid td.who {
    text-align: left; padding: 7px 12px 7px 0; min-width: 150px;
    position: sticky; left: 0; background: var(--surface); z-index: 1;
}
.month-grid thead th {
    padding: 5px 0; text-align: center; font-weight: 700;
    border-bottom: 1px solid var(--line); color: var(--muted);
}
.month-grid thead th .dnum { display: block; font-size: 11.5px; color: var(--text); }
.month-grid thead th .dday { display: block; font-size: 9px; letter-spacing: .04em; }
.month-grid thead th.sun .dnum, .month-grid td.day.sun { color: var(--danger); }
.month-grid thead th.today .dnum { color: var(--accent); }

.month-grid td.day { text-align: center; border-bottom: 1px solid var(--line); }
.month-grid td.day a, .month-grid td.day span {
    display: block; width: 24px; height: 26px; line-height: 26px;
    margin: 2px auto; border-radius: 5px; font-weight: 700; text-decoration: none;
    color: var(--muted);
}
.month-grid td.day a:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.month-grid td.s-present  a, .month-grid td.s-present  span { background: rgba(63,185,80,.16);  color: var(--ok); }
.month-grid td.s-half_day a, .month-grid td.s-half_day span { background: rgba(255,171,45,.16); color: var(--accent); }
.month-grid td.s-absent   a, .month-grid td.s-absent   span { background: rgba(248,81,73,.16);  color: var(--danger); }
.month-grid td.s-on_leave a, .month-grid td.s-on_leave span { background: rgba(139,152,168,.16); }
/* Late is carried by an underline as well as the tint, so it survives being
   printed in black and white and being looked at by anyone colour-blind. */
.month-grid td.late a, .month-grid td.late span {
    text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px;
}
.month-grid td.today { box-shadow: inset 0 0 0 1px var(--accent); }
.month-grid td.num, .month-grid th.num {
    text-align: center; padding: 0 6px; min-width: 30px;
    border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
}

/* ------------------------------------------------ HR: the file */

.bio-gap { border-left: 3px solid var(--accent); padding-left: 9px; }

/* -------------------------------------------- HR: the wall calendar */

.cal-wrap { overflow-x: auto; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 720px; }
.cal th {
    padding: 7px 4px; font-size: 10px; font-weight: 700;
    letter-spacing: .07em; text-transform: uppercase;
    color: var(--muted); border-bottom: 1px solid var(--line);
}
.cal th.sun { color: var(--danger); }
.cal td.cal-day {
    border: 1px solid var(--line); vertical-align: top;
    height: 96px; padding: 0; width: 14.28%;
}
.cal td.blank { background: var(--sunk, rgba(127,127,127,.05)); border-color: transparent; }
.cal td.ahead { opacity: .4; }
.cal td.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal td.chosen { box-shadow: inset 0 0 0 2px var(--ok); }
.cal td.cal-day > a, .cal td.cal-day > span {
    display: block; height: 100%; padding: 6px 7px;
    text-decoration: none; color: var(--text);
}
.cal td.cal-day > a:hover { background: rgba(127,127,127,.08); }
.cal .cal-num { display: block; font-size: 13px; font-weight: 700; }
.cal td.sun .cal-num { color: var(--danger); }

.cal .cal-tally { display: flex; gap: 3px; margin: 4px 0 3px; flex-wrap: wrap; }
.cal .cal-tally .t {
    min-width: 19px; text-align: center; border-radius: 4px;
    font-size: 10.5px; font-weight: 700; padding: 1px 4px;
}
.cal .cal-tally .p { background: rgba(63,185,80,.18);  color: var(--ok); }
.cal .cal-tally .h { background: rgba(255,171,45,.18); color: var(--accent); }
.cal .cal-tally .a { background: rgba(248,81,73,.18);  color: var(--danger); }
.cal .cal-tally .l { background: rgba(139,152,168,.18); color: var(--muted); }

.cal .cal-names { display: block; font-size: 9.5px; line-height: 1.45; }
.cal .cal-names .n { display: inline-block; margin-right: 5px; white-space: nowrap; }
.cal .cal-names .s-absent   { color: var(--danger); }
.cal .cal-names .s-half_day { color: var(--accent); }
.cal .cal-names .s-on_leave { color: var(--muted); }
.cal .cal-late {
    display: block; margin-top: 3px; font-size: 9px;
    letter-spacing: .04em; color: var(--accent); font-weight: 700;
}

@media (max-width: 640px) {
    .cal td.cal-day { height: 78px; }
    .cal .cal-names { font-size: 8.5px; }
}

/* ------------------------------------------------ staff: the shift log */

.shift-slot {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 12px 0; border-bottom: 1px solid var(--line);
}
.shift-slot:last-child { border-bottom: 0; }
.shift-hour { flex: 0 0 108px; padding-top: 2px; }
.shift-hour strong { display: block; font-size: 13px; }
.shift-body { flex: 1 1 auto; min-width: 0; }
.shift-slot.filled .shift-hour strong { color: var(--ok); }

.shift-entry {
    border-left: 3px solid var(--line); padding: 2px 0 2px 11px; margin-bottom: 10px;
}
.shift-entry:last-child { margin-bottom: 10px; }

.shift-add summary { display: inline-block; cursor: pointer; list-style: none; }
.shift-add summary::-webkit-details-marker { display: none; }
.shift-add[open] summary { margin-bottom: 4px; }
/* A number typed straight into a table cell. */
.tiny-num {
    width: 62px; text-align: right; padding: 4px 6px;
    font-size: 12px; font-variant-numeric: tabular-nums;
}
/* The row currently opened for editing. */
tr.picked > td { background: rgba(255,171,45,.10); }
tr.picked > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* ------------------------------------------ what kind of thing it is -- */

/* Built like the badges so it sits naturally beside them, but kept to its own
   three colours. The tint is the same construction the state badges use: the
   colour at a tenth for the ground, a third for the edge, full strength for
   the words.

   Never used as a row tint, a card border or a background. Colour on a card in
   this ERP already means priority or overdue, and two colour systems arguing
   on one card is worse than neither. */
.kindchip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    white-space: nowrap;
    vertical-align: baseline;
}
.kindchip.veh { color: var(--veh); background: rgba(63,176,165,.13);  border-color: rgba(63,176,165,.34); }
.kindchip.gbx { color: var(--gbx); background: rgba(155,140,240,.15); border-color: rgba(155,140,240,.36); }
.kindchip.mec { color: var(--mec); background: rgba(224,123,192,.14); border-color: rgba(224,123,192,.34); }

/* The permanent ID in the same colour as the kind it belongs to. The prefix
   already encodes it — TSA-VEH-, TSA-GBX-, TSA-MEC- — so this is the same fact
   said in a way that does not have to be read. */
.kindid { font-weight: 700; }
.kindid.veh { color: var(--veh); }
.kindid.gbx { color: var(--gbx); }
.kindid.mec { color: var(--mec); }
a.kindid { text-decoration: none; }
a.kindid:hover, a.kindid:focus-visible { text-decoration: underline; }

/* Inside a dense table the ground is more noise than help; the word alone in
   its colour is enough to sort a long list by eye. */
td .kindchip, .kind-plain {
    background: none;
    border-color: transparent;
    padding-left: 0;
}