/* ============================================================================
   GARAGE SYSTEM — the look

   Taken from the workshop itself, not from another app: graphite for the
   steel and the shadow under a ramp, hi-vis amber for anything you act on,
   and the yellow of a number plate kept strictly for registrations so a plate
   always reads as a plate. Light ground, because this is read on a phone held
   under strip lights and in daylight through the shutter door.
   ========================================================================== */
:root {
  color-scheme: light;

  --floor:    #EDEFF1;   /* the page — swept concrete under strip lights */
  --surface:  #FFFFFF;
  --surface-2:#F3F5F7;
  --surface-3:#E7EBEE;

  --graphite: #16191C;   /* steel in shadow — the header, the strongest text */
  --ink:      #16191C;
  --ink-2:    #49535B;
  --ink-3:    #5E6A72;   /* 4.9:1 on the floor — measured, not guessed */

  --line:     #D7DCE0;
  --line-2:   #C3CBD1;

  --hiviz:    #E8730C;   /* the action colour — hi-vis, the one bold thing */
  --hiviz-2:  #CB6208;
  --hiviz-on: #FFFFFF;
  --hiviz-soft:#FDEFE0;

  --plate:    #F2CF00;   /* a UK plate. Registrations only. */
  --plate-ink:#121212;

  --good:     #11674A;  --good-soft:#DFF0E8;
  --warn:     #8A5406;  --warn-soft:#FBEEDA;
  --crit:     #A3271C;  --crit-soft:#FAE5E3;

  --r:      12px;
  --r-sm:   8px;
  --rail-h: 64px;
  --shadow: 0 1px 2px rgba(22,25,28,.06), 0 10px 28px rgba(22,25,28,.06);

  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body:    Barlow, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono:    ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; max-width: 100%; overflow-x: hidden; }
/* Taps never zoom — a mechanic double-taps a button, not the page. */
html, body { touch-action: pan-x pan-y; }
body {
  background: var(--floor); color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------- gate */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 22px;
  background:
    radial-gradient(1100px 520px at 50% -8%, #2A3137 0%, transparent 62%),
    var(--graphite);
}
.gatecard {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 18px; padding: 28px 24px calc(26px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 24px 60px rgba(0,0,0,.42);
}
/* Three bars — the lift arms of a two-post ramp, rising. */
.mark { display: flex; align-items: flex-end; gap: 4px; height: 26px; margin-bottom: 16px; }
.mark span { width: 7px; border-radius: 2px; background: var(--hiviz); }
.mark span:nth-child(1) { height: 12px; opacity: .45; }
.mark span:nth-child(2) { height: 19px; opacity: .72; }
.mark span:nth-child(3) { height: 26px; }
.gatecard h1 {
  font-family: var(--display); font-size: 34px; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase; margin: 0 0 4px;
}
.gatecard .muted { margin: 0 0 20px; color: var(--ink-3); font-size: 14.5px; }
.gatecard label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3); margin: 14px 0 6px;
}
.gatecard input {
  width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line-2);
  border-radius: var(--r-sm); background: var(--surface-2);
}
.gatecard input:focus { outline: 2px solid var(--hiviz); outline-offset: 1px; border-color: transparent; }
.gatecard .hint { font-size: 12.5px; color: var(--ink-3); margin: 8px 0 0; }
.err { color: var(--crit); font-size: 13.5px; margin: 14px 0 0; }

/* ----------------------------------------------------------------- shell */
.app { min-height: 100%; }
.top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  background: var(--graphite); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 11px) max(15px, env(safe-area-inset-right))
           11px max(15px, env(safe-area-inset-left));
}
.top h2 {
  margin: 0; font-family: var(--display); font-size: 23px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase;
}
.top .sp { flex: 1; }
.top .chip {
  background: rgba(255,255,255,.14); border-radius: 999px; padding: 5px 11px;
  font-size: 12px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.body {
  padding: 16px max(14px, env(safe-area-inset-right))
           calc(var(--rail-h) + env(safe-area-inset-bottom, 0px) + 20px)
           max(14px, env(safe-area-inset-left));
}

/* bottom bar */
.rail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex;
  background: rgba(255,255,255,.96); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 5px max(4px, env(safe-area-inset-left)) calc(5px + env(safe-area-inset-bottom, 0px))
           max(4px, env(safe-area-inset-right));
  box-shadow: 0 -2px 14px rgba(22,25,28,.06);
}
.nav {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: none; padding: 7px 2px; border-radius: 10px;
  font-size: 10.5px; font-weight: 600; color: var(--ink-3);
  transition: color .12s ease, transform .09s ease;
}
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
           stroke-linecap: round; stroke-linejoin: round; }
.nav span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.nav.on { color: var(--hiviz); }
.nav.on svg { stroke-width: 2.2; }
.nav:active { transform: scale(.93); }

/* ------------------------------------------------------------------ parts */
.sect {
  font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); margin: 22px 0 9px;
}
.sect:first-child { margin-top: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
}
.pad { padding: 15px 16px; }
.muted { color: var(--ink-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: 14.5px; font-weight: 600; color: var(--ink);
  transition: transform .09s ease, background-color .12s ease, border-color .12s ease;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--hiviz); outline-offset: 2px; }
.btn.p { background: var(--hiviz); border-color: var(--hiviz); color: var(--hiviz-on); }
.btn.p:hover { background: var(--hiviz-2); border-color: var(--hiviz-2); }
.btn.dark { background: var(--graphite); border-color: var(--graphite); color: #fff; }
.btn.ghost { background: rgba(255,255,255,.14); border-color: transparent; color: #fff; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.big { width: 100%; min-height: 50px; margin-top: 20px; font-size: 16px;
           background: var(--hiviz); border-color: var(--hiviz); color: var(--hiviz-on); }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* the registration plate — the one place the yellow is allowed */
.plate {
  display: inline-block; background: var(--plate); color: var(--plate-ink);
  border: 1.5px solid rgba(0,0,0,.42); border-radius: 4px; padding: 3px 9px;
  font-family: var(--mono); font-weight: 700; font-size: 13.5px; letter-spacing: .055em;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.18); white-space: nowrap;
}
.plate.lg { font-size: 17px; padding: 5px 12px; }

/* numbers that sit in a column */
.fig { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ the ramps */
.ramps { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); }
.ramp {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 15px 16px; display: flex; flex-direction: column;
  gap: 10px; min-width: 0; text-align: left; width: 100%;
}
.ramp .head { display: flex; align-items: center; gap: 9px; min-width: 0;
  /* explicit, because a <button> does not reliably stretch its children:
     on a short free card the badge sat against the name instead of the edge */
  width: 100%; }
/* A plate is the size of a plate. In a flex column it would stretch the full
   width of the card and stop looking like one. */
.ramp > .plate { align-self: flex-start; }
.ramp .name {
  font-family: var(--display); font-size: 19px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase;
}
.ramp .state {
  margin-left: auto; font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 999px;
}
.ramp.free  { border-style: dashed; background: var(--surface-2); box-shadow: none; }
.ramp.free  .state { background: var(--surface-3); color: var(--ink-3); }
.ramp.busy  { border-left: 3px solid var(--hiviz); }
.ramp.busy  .state { background: var(--hiviz-soft); color: var(--hiviz-2); }
.ramp .car  { font-size: 15.5px; font-weight: 600; min-width: 0; overflow: hidden;
              text-overflow: ellipsis; white-space: nowrap; }
.ramp .sub  { font-size: 13px; color: var(--ink-3); }
.ramp .foot { display: flex; align-items: baseline; gap: 10px; margin-top: auto; padding-top: 4px; }
.ramp .run  { font-family: var(--display); font-size: 25px; font-weight: 700;
              font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ stat tiles */
.tiles { display: grid; gap: 11px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles > * { min-width: 0; }
@media (max-width: 359px) { .tiles { grid-template-columns: minmax(0, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line-2);
  border-radius: var(--r); padding: 13px 15px; box-shadow: var(--shadow); min-width: 0;
}
.tile .k {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .v {
  font-family: var(--display); font-size: clamp(22px, 6.4vw, 28px); font-weight: 700;
  letter-spacing: .3px; font-variant-numeric: tabular-nums; margin-top: 2px;
  overflow-wrap: anywhere;
}
.tile .s { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.tile.hiviz { border-left-color: var(--hiviz); } .tile.hiviz .v { color: var(--hiviz-2); }
.tile.good  { border-left-color: var(--good);  } .tile.good  .v { color: var(--good); }
.tile.warn  { border-left-color: var(--warn);  } .tile.warn  .v { color: var(--warn); }
.tile.crit  { border-left-color: var(--crit);  } .tile.crit  .v { color: var(--crit); }

/* ----------------------------------------------------------------- lists */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
        box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 15px;
  border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left;
  min-height: 56px; transition: background-color .12s ease;
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--surface-2); }
.row .main { flex: 1; min-width: 0; }
/* Title over sub-line. They are spans, so without block they ran together on
   one line and collided with the figure on the right. */
.row .t, .row .s { display: block; }
.row .t { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-family: var(--mono); font-size: 14px; font-weight: 700;
            font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .go { color: var(--ink-3); font-size: 18px; flex: none; }

.flag {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 7px; border-radius: 5px; white-space: nowrap;
}
.flag.ok   { background: var(--good-soft); color: var(--good); }
.flag.warn { background: var(--warn-soft); color: var(--warn); }
.flag.crit { background: var(--crit-soft); color: var(--crit); }
.flag.open { background: var(--hiviz-soft); color: var(--hiviz-2); }

.empty {
  background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r);
  padding: 30px 20px; text-align: center; color: var(--ink-3); font-size: 14px;
}
.empty b { display: block; font-size: 15.5px; color: var(--ink-2); margin-bottom: 4px; }

/* ----------------------------------------------------------------- forms */
.field { margin-bottom: 13px; }
.field label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-2);
  border-radius: var(--r-sm); background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--hiviz); outline-offset: 1px; border-color: transparent;
}
.field.reg input {
  background: var(--plate); color: var(--plate-ink); font-family: var(--mono);
  font-weight: 700; font-size: 17px; letter-spacing: .05em; text-align: center;
  text-transform: uppercase; border-color: rgba(0,0,0,.4);
}
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ---------------------------------------------------------------- sheets */
.sheetwrap {
  position: fixed; inset: 0; z-index: 70; background: rgba(12,14,16,.5);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease-out;
}
@media (min-width: 760px) { .sheetwrap { align-items: center; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--floor); border-radius: 18px 18px 0 0;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 50px rgba(0,0,0,.35);
  animation: rise .24s cubic-bezier(.22,.68,.36,1);
}
@media (min-width: 760px) { .sheet { border-radius: 18px; } }
.sheet .grab { width: 38px; height: 4px; border-radius: 99px; background: var(--line-2); margin: 9px auto 2px; }
.sheet .head {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  padding: 12px 18px 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 11px;
}
.sheet .head h3 {
  margin: 0; flex: 1; min-width: 0; font-family: var(--display); font-size: 21px;
  font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sheet .x {
  width: 38px; height: 38px; flex: none; border: 0; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-2); font-size: 17px;
}
.sheet .inner { padding: 16px 18px 0; }
.acts { display: grid; gap: 9px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.acts .wide { grid-column: 1 / -1; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(26px); opacity: .4 } to { transform: none; opacity: 1 } }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--rail-h) + env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%); z-index: 90; max-width: 90vw;
  background: var(--graphite); color: #fff; padding: 11px 17px; border-radius: 10px;
  font-size: 13.5px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  animation: toastin .2s cubic-bezier(.22,.68,.36,1);
}
@keyframes toastin { from { transform: translate(-50%, 12px); opacity: 0 }
                     to   { transform: translate(-50%, 0);    opacity: 1 } }

/* ------------------------------------------------------------- wide view
   A desk is not a big phone. On a monitor the job is density: the whole
   workshop at a glance, the ramps and the money in the same eyeful, without
   scrolling and without a quarter of the screen left empty. */
@media (min-width: 860px) {
  /* auto then 1fr: without it the sidebar, which spans both rows at 100vh,
     stretched the header row to 160px. */
  .app { display: grid; grid-template-columns: 228px minmax(0, 1fr);
         grid-template-rows: auto 1fr; min-height: 100vh; }
  .top { grid-column: 2; }
  .body { grid-column: 2; padding: 22px 26px 40px; max-width: none; }

  /* the sidebar carries the identity, not just the links */
  .rail {
    position: sticky; top: 0; grid-row: 1 / 3; grid-column: 1; align-self: start;
    height: 100vh; flex-direction: column; justify-content: flex-start; gap: 2px;
    background: var(--graphite);
    background-image: linear-gradient(180deg, #1B1F23 0%, #121518 100%);
    border-top: 0; border-right: 0; padding: 0 12px 16px; box-shadow: none;
  }
  .rail::before {
    content: 'GARAGE SYSTEM';
    display: block; width: 100%; padding: 24px 13px 20px;
    font-family: var(--display); font-size: 17px; font-weight: 700;
    letter-spacing: .16em; color: #fff; opacity: .92;
  }
  .nav {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    width: 100%; padding: 11px 13px; font-size: 14.5px; border-radius: 9px;
    color: rgba(255,255,255,.62);
  }
  .nav:hover { background: rgba(255,255,255,.07); color: #fff; }
  .nav.on { background: var(--hiviz); color: #fff; }
  .nav.on svg { stroke-width: 2.1; }
  .nav:active { transform: none; }

  /* a header with some weight to it, and room for the date */
  .top {
    padding: 18px 26px; border-bottom: 1px solid var(--line);
    background: var(--surface); color: var(--ink);
  }
  .top h2 { font-size: 26px; color: var(--ink); }
  .top .chip { background: var(--surface-3); color: var(--ink-2); }
  .top .btn.ghost { background: var(--surface-2); border-color: var(--line-2); color: var(--ink); }

  /* four across, not two giant ones */
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
  .tile { padding: 15px 17px; }
  .tile .v { font-size: 30px; }

  /* the ramps and what needs you, side by side */
  .deck { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 26px; align-items: start; }
  .deck .sect:first-child { margin-top: 0; }
  .ramps { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
}

/* On a really wide monitor, stop the text running away from the eye but let
   the ramp cards keep using the room. */
@media (min-width: 1500px) {
  .body { max-width: 1480px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------ the finish
   Depth, not decoration. Cards sit a little off the floor, the hi-vis is
   used where something can be done, and state reads before the words do. */

/* the phone header: a touch of steel instead of a flat slab. Phone only —
   on the desk the header is light, and this gradient made its title
   dark-on-dark and invisible. */
@media (max-width: 859px) {
  .top { background-image: linear-gradient(180deg, #1D2226 0%, #16191C 100%); }
}
.deck { margin-top: 22px; }

.tile, .ramp, .rows, .card {
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 1px 2px rgba(22,25,28,.05), 0 8px 24px rgba(22,25,28,.06);
}
.tile { position: relative; overflow: hidden; }
.tile .v .of { font-size: .55em; color: var(--ink-3); font-weight: 600; }

/* a busy ramp glows a little — you can see the floor is working */
.ramp.busy {
  background: linear-gradient(180deg, #FFFFFF 0%, #FFFAF4 100%);
  border-left-width: 4px;
}
.ramp.busy .run { color: var(--ink); }
.ramp { transition: transform .12s ease, box-shadow .12s ease; cursor: pointer; }
.ramp:hover { transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(22,25,28,.06), 0 14px 30px rgba(22,25,28,.1); }
.ramp:active { transform: scale(.985); }
.ramp.free:hover { border-color: var(--hiviz); }
.ramp.free .sub::before { content: '+ '; color: var(--hiviz); font-weight: 700; }

/* a status dot so a row's mood reads before its words */
.row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--line-2); }
.row .dot.crit { background: var(--crit); box-shadow: 0 0 0 4px var(--crit-soft); }
.row .dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }

/* "all clear" is good news, not an empty box */
.calm {
  background: var(--good-soft); border: 1px solid rgba(17,103,74,.18); border-radius: var(--r);
  padding: 16px 17px; color: var(--good); font-size: 13.5px;
}
.calm b { display: block; font-size: 15px; margin-bottom: 2px; }

/* On a phone the deck is one column, and the short list of what needs doing
   goes above the ramp cards — two tall cards would otherwise push it below
   the fold. On the desk they sit side by side, so order does not matter. */
.deck > section { min-width: 0; }
@media (max-width: 859px) {
  .deck { display: flex; flex-direction: column; }
  .deck > section:last-child { order: -1; margin-bottom: 4px; }
}

@media (prefers-reduced-motion: reduce) { .ramp:hover { transform: none; } }
