/* iHawk Call Manager. Phone first; plain and readable in sunlight. */
:root {
  --bg: #f4f6f7; --surface: #fff; --fg: #17202a; --muted: #5b6670; --line: #dde2e6;
  --accent: #0b5c7a; --accent-soft: #e2f0f5; --on-accent: #fff;
  --ok: #2f8a4a; --warn: #a86400; --bad: #b3261e;
  --s-open: #6b7280; --s-assigned: #7c4dbd; --s-accepted: #1f6fd1; --s-way: #c27a00; --s-site: #0e7c86;
  --s-spare: #8a5a00; --s-submitted: #5a6b00; --s-done: #2f8a4a; --s-cant: #b3261e; --s-closed: #1d4f33;
  --wa: #1a7f4b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161b; --surface: #192028; --fg: #e7ecf0; --muted: #9aa6b0; --line: #2b3540;
    --accent: #5cb8d8; --accent-soft: #16303b; --on-accent: #0b1a20;
    --ok: #5cc27a; --warn: #e2a640; --bad: #f08a82;
    --s-open: #9aa3ad; --s-assigned: #b391e6; --s-accepted: #6aa8f0; --s-way: #e2a640; --s-site: #4fc6cf;
    --s-spare: #d9a54a; --s-submitted: #b8c95a; --s-done: #5cc27a; --s-cant: #f08a82; --s-closed: #8fd3a8;
    --wa: #3fbf7a; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: 16px; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
p { margin: 0 0 .5rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.brand { font-weight: 800; text-decoration: none; color: var(--fg); }
.brand span { font-weight: 500; color: var(--muted); }
.nav { display: flex; flex-wrap: wrap; gap: 4px 14px; flex: 1; }
.nav a { text-decoration: none; font-weight: 600; font-size: .95rem; }
.who { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--muted); margin-left: auto; }

.page { max-width: 1280px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.narrow { max-width: 440px; width: 100%; margin: 24px auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
.card.accent { border: 2px solid var(--accent); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.row-gap.spaced { justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); }
.grow { flex: 1 1 160px; min-width: 0; }
.head-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.head-row h1 { flex: 1 1 auto; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.spare-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 8px; }
details summary { cursor: pointer; padding: 6px 0; }
details[open] summary { margin-bottom: 6px; }

.btn { display: inline-block; text-align: center; background: var(--accent); color: var(--on-accent); border: 1.5px solid var(--accent); border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.big { padding: 14px 20px; font-size: 1.05rem; width: 100%; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; width: 100%; margin: 8px 0; }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.copy-row { display: flex; gap: 8px; }
.inline { display: inline; }

.flash { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--accent-soft); margin: 0; }
.flash.error { border-color: var(--bad); color: var(--bad); background: var(--surface); }
.flash.warn { border-color: var(--warn); color: var(--warn); background: var(--surface); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; }
.tile b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .85rem; }
.tile.bad b { color: var(--bad); } .tile.warn b { color: var(--warn); }

.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; align-items: start; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.stage h2 { display: flex; align-items: center; gap: 8px; font-size: .95rem; margin: 0; }
.stage .count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--s-open)); }
.empty { color: var(--muted); font-size: .85rem; margin: 0; }
.call { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-left: 4px solid var(--c, var(--s-open)); border-radius: 8px; padding: 8px 10px; text-decoration: none; color: var(--fg); background: var(--bg); }
.call .row { display: flex; justify-content: space-between; gap: 8px; }
.call .sub { color: var(--muted); font-size: .82rem; }
.age { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.age.late { color: var(--bad); font-weight: 700; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1.5px solid var(--c, var(--s-open)); color: var(--c, var(--s-open)); white-space: nowrap; }
.s-open { --c: var(--s-open); } .s-assigned { --c: var(--s-assigned); } .s-accepted { --c: var(--s-accepted); }
.s-on_the_way { --c: var(--s-way); } .s-on_site { --c: var(--s-site); } .s-waiting_spares { --c: var(--s-spare); }
.s-work_submitted { --c: var(--s-submitted); } .s-field_done { --c: var(--s-done); } .s-cannot_fix { --c: var(--s-cant); }
.s-closed { --c: var(--s-closed); }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; }
.plain { margin: 0; padding-left: 1.1rem; }
.note { background: var(--accent-soft); border-radius: 6px; padding: 6px 8px; margin-top: 4px; white-space: pre-wrap; }
.history { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: .92rem; }
.parsed { border: 1px dashed var(--accent); border-radius: 8px; padding: 10px; background: var(--accent-soft); }
.parsed ul { margin: 4px 0; padding-left: 1.1rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.gallery a { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--muted); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.gallery .doc { aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; font-weight: 700; }
#scan-video { width: 100%; max-width: 420px; border-radius: 8px; }

.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl thead th { border-top: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tbl.num td:not(:first-child) { font-variant-numeric: tabular-nums; text-align: right; }
.tbl tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.tbl tr.muted td { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.search { display: flex; gap: 6px; flex: 1 1 260px; max-width: 420px; }
.pill.urgent { --c: var(--bad); color: var(--bad); border-color: var(--bad); align-self: flex-start; }
.warn-text { color: var(--warn); }
.pill.repeat { --c: var(--warn); color: var(--warn); border-color: var(--warn); }
.hints li { margin: 4px 0; }
.hints .do { font-weight: 600; }
.stage.s-office { --c: var(--accent); }

/* ---------- FARES: engineer home, clock, team ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.home { display: flex; flex-direction: column; gap: 14px; max-width: 520px; width: 100%; margin: 0 auto; }
.geo-form { margin: 0; }
.hbtn { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 4px; width: 100%; min-height: 104px;
  padding: 18px 18px; text-align: left; font: inherit; color: var(--fg); text-decoration: none; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; }
.hbtn .hb-t { font-size: 1.45rem; font-weight: 800; line-height: 1.2; }
.hbtn .hb-s { font-size: .92rem; color: var(--muted); }
.hbtn:hover { border-color: var(--accent); }
.hbtn.clock-off { border: 2px dashed var(--muted); }
.hbtn.clock-on { border: 2px solid var(--ok); background: var(--accent-soft); }
.hbtn.clock-on .hb-t { color: var(--ok); }
.hbtn.clock-done { cursor: default; border-style: solid; }
.hbtn.clock-done .hb-t { color: var(--muted); }
.hbtn.soon { cursor: default; opacity: .65; }
.hbtn.soon:hover { border-color: var(--line); }
.hbtn.small-btn { min-height: 0; padding: 12px 18px; }
.hbtn.small-btn .hb-t { font-size: 1rem; color: var(--accent); }
.hbtn:disabled { opacity: .7; cursor: progress; }
.badge { position: absolute; top: 14px; right: 16px; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px;
  background: var(--bad); color: #fff; font-weight: 800; font-size: .95rem; display: grid; place-items: center;
  font-variant-numeric: tabular-nums; }
.chip { display: inline-block; font-size: .78rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1.5px solid currentColor; white-space: nowrap; }
.chip.st-in_area { color: var(--ok); }
.chip.st-outside, .chip.st-no_base { color: var(--warn); }
.chip.st-no_location, .chip.st-none { color: var(--bad); }
.call.is-new { border-left-color: var(--s-assigned); background: var(--surface); }
.call .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); margin-right: 6px; vertical-align: middle; }
.head-row form.row-gap { flex-wrap: nowrap; }
.head-row form.row-gap input[type=date] { width: auto; }

/* ---------- FARES: expenses ---------- */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); }
.num { text-align: right; }
.tabs-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs-row .tab { padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 999px; text-decoration: none; font-weight: 700; color: var(--fg); background: var(--surface); }
.tabs-row .tab.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ledger-tbl tr.day-start td { border-top: 2px solid var(--line); }
.kind { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: 4px; }
.pill.t-open { color: var(--s-open); } .pill.t-submitted { color: var(--s-accepted); } .pill.t-verified { color: var(--s-assigned); }
.pill.t-approved { color: var(--s-done); } .pill.t-returned { color: var(--s-cant); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.badge.warn-badge { background: var(--warn); }
fieldset.place { gap: 4px; }
.hbtn .row-gap.spaced { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; color: var(--fg); }

/* ---------- FARES: attendance ---------- */
.tbl.att tr.off td { background: var(--bg); color: var(--muted); }
.chip.st-off { color: var(--muted); }
.mark-form { flex-wrap: nowrap; gap: 4px; }
.mark-form select, .mark-form input { width: auto; padding: 5px 6px; font-size: .85rem; }
.mark-form .btn { padding: 5px 10px; }
.warn-text { color: var(--warn); }
.my-att { align-self: flex-end; margin-top: -8px; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mini-grid:empty { display: none; }
.login-help { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 700px) { .staff-nav a:not(:first-child) { display: none; } }   /* on phones, Home lists everything */

/* ---------- phones: tables marked "cards" show one card per row ---------- */
@media (max-width: 700px) {
  .tbl-wrap:has(> .tbl.cards) { border: 0; background: none; overflow: visible; }
  .tbl.cards, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards thead { display: none; }
  .tbl.cards tr { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 10px; padding: 8px 12px; background: var(--surface); }
  .tbl.cards td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: right; white-space: normal; }
  .tbl.cards td::before { content: attr(data-label); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 600; color: var(--muted); font-size: .82rem; text-align: left; flex: 0 0 auto; }
  .tbl.cards td:first-child { font-weight: 700; font-size: 1.02rem; justify-content: flex-start; text-align: left; padding-bottom: 6px; }
  .tbl.cards td:first-child::before, .tbl.cards td[colspan]::before, .tbl.cards td:not([data-label])::before { content: none; }
  .tbl.cards td[colspan] { justify-content: flex-start; text-align: left; }
  .tbl.cards td:empty { display: none; }
  .tbl.cards tr.off td { background: none; }
  .tbl.cards tr.off { background: var(--bg); }
  .tbl.cards .mark-form { flex-wrap: wrap; justify-content: flex-end; }
}

/* ---------- spares stock ---------- */
.count-list { display: flex; flex-direction: column; gap: 6px; }
.count-row { flex-direction: row; justify-content: space-between; align-items: center; gap: 10px; font-weight: 500; }
.count-row input { width: 90px; flex: 0 0 90px; }
.stock-req { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
/* ---------- sign-in: who are you? ---------- */
.who-page { max-width: 760px; width: 100%; margin: 12px auto; display: flex; flex-direction: column; gap: 12px; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.who-btn { min-height: 92px; }
.who-btn .hb-t { font-size: 1.25rem; }
.narrow-form { max-width: 420px; margin-top: 8px; }
