/* Job Cards: a field tool for electricians. Large targets, high contrast, honest status. */

@font-face { font-family: 'Barlow'; font-weight: 400; font-style: normal; font-display: swap; src: url(/fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-style: normal; font-display: swap; src: url(/fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-style: normal; font-display: swap; src: url(/fonts/barlow-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-style: normal; font-display: swap; src: url(/fonts/barlow-condensed-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-style: normal; font-display: swap; src: url(/fonts/barlow-condensed-latin-700-normal.woff2) format('woff2'); }

:root {
  color-scheme: light dark;
  --enamel: #e8ecef;        /* switchboard enamel: the page behind everything */
  --band: #ffffff;          /* full-width working bands */
  --ink: #12202e;
  --steel: #566676;         /* secondary text, borders on controls */
  --rule: #cfd7de;
  --live: #1456b8;          /* primary action */
  --live-ink: #ffffff;
  --earth-green: #1e9e4a;
  --earth-yellow: #f2c400;
  --amber: #d98200;
  --fault: #c62828;
  --focus: #1456b8;
  --font-body: 'Barlow', 'Roboto', system-ui, sans-serif;
  --font-display: 'Barlow Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif;
  --nav-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --enamel: #0e1923;
    --band: #16242f;
    --ink: #e9eff4;
    --steel: #9fb0bf;
    --rule: #2b3d4c;
    --live: #4d8ff0;
    --live-ink: #06111c;
    --amber: #f0a030;
    --fault: #ff6b63;
    --focus: #8ab6ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--enamel); color: var(--ink);
  font: 400 17px/1.45 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--live); }

/* ---- frame ------------------------------------------------------------ */

.top {
  position: sticky; top: 0; z-index: 20; background: var(--band);
  padding: env(safe-area-inset-top) 0 0;
}
.top__row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px; }
.top__back { margin-left: -8px; }
.top__title { flex: 1; margin: 0; font: 700 26px/1.1 var(--font-display); letter-spacing: 0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top__stripe { height: 5px; background: repeating-linear-gradient(135deg, var(--earth-green) 0 10px, var(--earth-yellow) 10px 20px); }

main { padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
main:focus { outline: none; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  background: var(--band); border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--steel); text-decoration: none; font-weight: 600; font-size: 15px;
}
.nav a[aria-current='page'] { color: var(--ink); box-shadow: inset 0 3px 0 var(--earth-yellow); }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav__badge { position: absolute; margin-left: 22px; margin-top: -26px; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--fault); color: #fff; font-size: 12px; font-weight: 600; text-align: center; line-height: 20px; }

/* ---- pilot lamp: the sync status ------------------------------------- */

.status { display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; text-align: right; cursor: pointer; }
.status__text { font-size: 14px; line-height: 1.2; font-weight: 500; max-width: 150px; }
.lamp { flex: none; width: 16px; height: 16px; border-radius: 50%; background: var(--steel); border: 2px solid rgba(0, 0, 0, 0.25); }
.lamp--ok { background: var(--earth-green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--earth-green) 30%, transparent), 0 0 10px var(--earth-green); }
.lamp--wait { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 30%, transparent), 0 0 10px var(--amber); }
.lamp--fault { background: var(--fault); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fault) 30%, transparent), 0 0 10px var(--fault); }
.lamp--busy { animation: lamp-pulse 1s ease-in-out infinite; }
@keyframes lamp-pulse { 50% { opacity: 0.35; } }

/* ---- text blocks ------------------------------------------------------ */

.band { background: var(--band); padding: 16px; border-bottom: 1px solid var(--rule); }
.gap { height: 12px; }
.band h2, .heading { margin: 0 0 8px; font: 700 22px/1.15 var(--font-display); letter-spacing: 0.01em; }
.heading { padding: 20px 16px 8px; margin: 0; }
.muted { color: var(--steel); }
.small { font-size: 14px; }
.empty { padding: 32px 16px; color: var(--steel); }
.empty strong { display: block; color: var(--ink); font: 700 22px/1.2 var(--font-display); margin-bottom: 4px; }
.num { font-variant-numeric: tabular-nums; }

/* ---- job list --------------------------------------------------------- */

.jobs { list-style: none; margin: 0; padding: 0; background: var(--band); }
.job { display: block; position: relative; padding: 14px 16px 14px 24px; border-bottom: 1px solid var(--rule); text-decoration: none; color: inherit; min-height: 72px; }
.job::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--steel); }
.job--open::before { background: var(--live); }
.job--progress::before { background: var(--amber); }
.job--done::before { background: var(--earth-green); }
.job--cancelled::before { background: var(--rule); }
.job__head { display: flex; align-items: baseline; gap: 10px; }
.job__no { font: 700 30px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.job__client { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job__state { font-size: 14px; font-weight: 600; color: var(--steel); white-space: nowrap; }
.job__addr, .job__when { margin: 2px 0 0; color: var(--steel); font-size: 15px; }
.job__draft { display: inline-block; margin-top: 6px; padding: 2px 8px; border: 2px solid var(--amber); border-radius: 4px; font-size: 14px; font-weight: 600; }

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

.field { margin: 0 0 16px; }
.field:last-child { margin-bottom: 0; }
.field > label, .label { display: block; margin-bottom: 6px; font-weight: 600; }
.hint { margin: 4px 0 0; color: var(--steel); font-size: 14px; }
.input, .select, .textarea {
  width: 100%; min-height: 52px; padding: 10px 12px; font-size: 18px;
  background: var(--band); border: 2px solid var(--steel); border-radius: 6px;
}
.textarea { min-height: 180px; resize: vertical; line-height: 1.4; }
.input:disabled, .textarea:disabled, .select:disabled { opacity: 1; border-color: var(--rule); background: var(--enamel); }
.row { display: flex; gap: 12px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
.row > .row__fixed { flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 18px; border: 2px solid var(--live); border-radius: 6px;
  background: var(--live); color: var(--live-ink); font-weight: 600; font-size: 18px; text-decoration: none; cursor: pointer;
}
.btn--quiet { background: transparent; color: var(--live); }
.btn--stamp { background: var(--earth-yellow); border-color: var(--earth-yellow); color: #12202e; }
.btn--danger { background: transparent; border-color: var(--fault); color: var(--fault); }
.btn--block { display: flex; width: 100%; }
.btn--small { min-height: 44px; padding: 6px 12px; font-size: 16px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--link { border: 0; background: none; color: var(--live); min-height: 44px; padding: 6px 8px; }
.icon-btn { flex: none; width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: inherit; border-radius: 6px; cursor: pointer; }
.icon-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.stepper { display: flex; align-items: center; gap: 0; }
.stepper button { width: 52px; height: 52px; font-size: 26px; font-weight: 600; background: var(--band); border: 2px solid var(--steel); cursor: pointer; }
.stepper button:first-child { border-radius: 6px 0 0 6px; }
.stepper button:last-child { border-radius: 0 6px 6px 0; }
.stepper output { min-width: 56px; height: 52px; display: flex; align-items: center; justify-content: center; border-block: 2px solid var(--steel); font: 700 26px var(--font-display); font-variant-numeric: tabular-nums; }

.choice { display: flex; gap: 12px; align-items: center; padding: 12px; border: 2px solid var(--steel); border-radius: 6px; margin-bottom: 10px; cursor: pointer; font-weight: 600; min-height: 56px; }
.choice input { width: 24px; height: 24px; accent-color: var(--live); flex: none; }
.choice:has(input:checked) { border-color: var(--earth-green); box-shadow: inset 0 0 0 2px var(--earth-green); }

/* ---- lists inside forms ---------------------------------------------- */

.lines { list-style: none; margin: 0 0 12px; padding: 0; }
.line { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.line__main { flex: 1; min-width: 0; }
.line__qty { font: 700 22px var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.line__sub { color: var(--steel); font-size: 14px; }
.flag { display: inline-block; padding: 0 6px; border: 1.5px solid var(--amber); border-radius: 4px; font-size: 13px; font-weight: 600; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 12px; }
.thumb { position: relative; aspect-ratio: 1; background: var(--enamel); border: 1px solid var(--rule); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__tag { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; background: rgba(18, 32, 46, 0.85); color: #fff; font-size: 12px; font-weight: 600; }
.thumb__x { position: absolute; top: 2px; right: 2px; width: 40px; height: 40px; background: rgba(18, 32, 46, 0.85); color: #fff; border: 0; border-radius: 50%; font-size: 22px; cursor: pointer; }

.note { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.note audio { width: 100%; margin-top: 6px; }
.rec { display: flex; align-items: center; gap: 12px; }
.rec__dot { width: 14px; height: 14px; border-radius: 50%; background: var(--fault); animation: lamp-pulse 1s ease-in-out infinite; }
.rec__time { font: 700 26px var(--font-display); font-variant-numeric: tabular-nums; }

.sig { display: block; width: 100%; height: 160px; background: #fff; border: 2px solid var(--steel); border-radius: 6px; touch-action: none; }

.actions { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 10; display: flex; gap: 12px; padding: 12px 16px; background: var(--band); border-top: 1px solid var(--rule); }
.actions .btn { flex: 1; }
.savestate { padding: 8px 16px; font-size: 14px; color: var(--steel); background: var(--band); border-bottom: 1px solid var(--rule); }

.banner { padding: 12px 16px; background: color-mix(in srgb, var(--amber) 18%, var(--band)); border-bottom: 2px solid var(--amber); font-weight: 500; }
.banner--fault { background: color-mix(in srgb, var(--fault) 14%, var(--band)); border-color: var(--fault); }

/* ---- sheet (add material) -------------------------------------------- */

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(8, 16, 24, 0.55); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 88vh; overflow: auto; background: var(--band); border-radius: 14px 14px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet__head h2 { margin: 0; font: 700 24px var(--font-display); }
.pick { list-style: none; margin: 8px 0 12px; padding: 0; max-height: 36vh; overflow: auto; border-top: 1px solid var(--rule); }
.pick button { width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.pick button[aria-pressed='true'] { background: color-mix(in srgb, var(--earth-yellow) 28%, transparent); }
.pick__have { font: 700 20px var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pick__have--low { color: var(--fault); }

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

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 80px + env(safe-area-inset-bottom)); z-index: 50; padding: 14px 16px; background: var(--ink); color: var(--enamel); border-radius: 8px; font-weight: 600; text-align: center; }
.login { max-width: 420px; margin: 0 auto; padding: 32px 16px; }
.login h1 { font: 700 40px/1 var(--font-display); margin: 0 0 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.kv dt { color: var(--steel); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.issue { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.stat { font: 700 40px/1 var(--font-display); font-variant-numeric: tabular-nums; }

@media (min-width: 720px) {
  main, .top__row, .top__stripe, .actions, .savestate { max-width: 720px; margin-inline: auto; }
  .top { background: var(--band); }
  .nav { justify-content: center; }
  .nav a { max-width: 240px; }
}
@media (prefers-reduced-motion: reduce) {
  .lamp--busy, .rec__dot { animation: none; }
}
