/*
 * Park+ operator panel.
 *
 * One stylesheet, no build step, no CDN: cPanel shared hosting gets a file
 * upload. Everything is in here so the page has no inline <style> and keeps
 * working under a Content-Security-Policy without 'unsafe-inline' -- that
 * header is the deploy agent's and this code assumes it is not there yet.
 * For the same reason there are no @font-face rules and no url() to a
 * foreign host: script-src 'self' is already in force and a stylesheet that
 * needs a third party would either break or force the policy open.
 *
 * Designed for a cashier's screen: dense tables, large hit targets on the
 * action buttons, and state carried by BOTH colour and text, because the
 * booth monitor is usually bad and some operators are colour blind.
 *
 * LIGHT ONLY. There is no dark palette here, and no media query that
 * follows the operating system's colour preference. The owner's
 * workstation reports a dark preference and the panel is still required to
 * be light, so following that preference would mean shipping the one
 * appearance that is not allowed. A booth monitor in
 * daylight is also the worst place for a dark interface: a light ground
 * with ink text keeps its contrast when the sun is on the glass.
 *
 * The visual system is two ideas held together:
 *   - the SHELL is airy. Soft blue-grey ground, white surfaces floating on
 *     it, small radii, shadows instead of heavy borders. Chrome should feel
 *     calm because the operator stares at it all shift.
 *   - the DATA is dense. Tables get no card padding, no boxed rows and no
 *     rounded chrome -- just hairline rules and a solid rule under the
 *     header, like a printed receipt. Someone reconciling a shift wants the
 *     most rows per screen, not the prettiest rows.
 */

:root {
  /* Ground and surfaces. The page is tinted so that a white card reads as
     a raised object without needing a dark border around it. */
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f5f8fa;

  /* Two rule weights, deliberately. --line is the hairline between table
     rows and around calm chrome; --line-strong is reserved for the rule
     that closes a table header, where the eye needs a real stop. */
  --line: #e3e9ef;
  --line-strong: #cbd6e0;

  /* Interactive borders are darker than decorative ones on purpose. A
     hairline is enough to separate two rows, but WCAG 1.4.11 wants 3:1 for
     the edge of a control you have to find, and #e3e9ef against white is
     1.5:1 -- nowhere near. #748798 clears 3:1 against the white sheet, the
     zebra stripe and the page ground alike, which matters because a button
     can sit on any of the three. */
  --line-field: #748798;

  --text: #15232f;
  --text-dim: #5a6b7a;

  /* Mediterranean blue is the only accent. --accent is safe as text on
     white (5.2:1) and as a background under white text; --accent-deep is
     for text sitting on an accent tint, where --accent alone would only
     just clear 4.5:1 and leaves no margin for a cheap panel. */
  --accent: #1c6fb8;
  --accent-deep: #11395e;
  --accent-soft: #eaf2fa;

  --ok: #12754a;
  --ok-soft: #e6f4ec;
  --warn: #7a5209;
  --warn-soft: #fdf0db;
  --danger: #b4342f;
  --danger-soft: #fbeae9;
  /* "Info" is the accent family rather than a sixth hue: five competing
     status colours in one table is how a tone stops meaning anything. The
     word in the chip is what carries the state; the colour only sorts. */
  --info: #1c6fb8;
  --info-soft: #eaf2fa;

  --radius: 8px;
  --radius-m: 6px;
  /* Shadows are tinted with the ink colour, not black. Pure black over a
     blue-grey ground goes muddy. */
  --shadow-1: 0 1px 2px rgba(21, 35, 47, .05), 0 1px 3px rgba(21, 35, 47, .07);
  --shadow-2: 0 8px 24px rgba(21, 35, 47, .12);

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
.link { color: var(--accent); }
code { font-family: var(--mono); font-size: .92em; }

/* One focus ring for the whole panel, drawn OUTSIDE the element so it is
   never clipped by a parent with overflow:hidden. :focus-visible rather
   than :focus so a mouse click on a button does not leave a ring behind,
   which is what makes people ask for focus styles to be removed. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip {
  position: absolute; left: -9999px;
}
.skip:focus {
  left: 8px; top: 8px; z-index: 50;
  background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 6px;
}

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

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

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 20px;
}

.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 8px; }
.brand__mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: var(--radius-m);
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: var(--shadow-1);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__text small { color: var(--text-dim); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 18px; flex: 1; overflow-y: auto; }
.nav__group { display: flex; flex-direction: column; gap: 1px; }
.nav__group-title {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-dim); padding: 0 10px 6px;
}
.nav__item {
  display: block; padding: 8px 10px; border-radius: var(--radius-m);
  color: var(--text); text-decoration: none; font-size: 14px;
}
.nav__item:hover { background: var(--accent-soft); color: var(--accent-deep); }
/* The active item is filled, not merely tinted: on a washed-out booth
   monitor a tint can disappear entirely, and "where am I" is the one
   question the sidebar exists to answer. */
.nav__item.is-active { background: var(--accent); color: #fff; }
.nav__item.is-active:hover { background: var(--accent-deep); color: #fff; }

.whoami { border-top: 1px solid var(--line); padding-top: 14px; font-size: 13px; }
.whoami__name { font-weight: 600; }
.whoami__role { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.whoami__link { font-size: 13px; margin-bottom: 8px; }

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

/* ---------------------------------------------------------- header ---- */

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 22px;
}
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.page-head__sub { margin: 5px 0 0; color: var(--text-dim); font-size: 14px; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

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

/* A card is a white sheet on the tinted ground. The hairline is there for
   printing and for forced-colours mode; on screen the shadow does the
   separating, which is why the border is this light. */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  margin-bottom: 18px;
  overflow: hidden;
}
.card__title {
  margin: 0; padding: 12px 16px; font-size: 13px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim);
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.card__body { padding: 16px; }
.card__foot { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ---------------------------------------------------------- stats ----- */

.stats {
  display: grid; gap: 14px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius); padding: 13px 15px;
  box-shadow: var(--shadow-1);
}
/* The stripe is a second channel, never the only one -- every stat renders
   its label and value as words regardless of tone. */
.stat--neutral { border-left-color: var(--line-strong); }
.stat--ok { border-left-color: var(--ok); }
.stat--warn { border-left-color: var(--warn); }
.stat--danger { border-left-color: var(--danger); }
.stat--info { border-left-color: var(--info); }
.stat__label { font-size: 12px; color: var(--text-dim); }
.stat__value {
  font-size: 23px; font-weight: 650; margin: 2px 0;
  font-variant-numeric: tabular-nums;
}
.stat__hint { font-size: 12px; color: var(--text-dim); }

/* ---------------------------------------------------------- table ----- */

/* Receipt density. ~35px rows: 8px of padding either side of a 13px line.
   Anything taller and a shift's worth of sessions stops fitting on one
   screen, which is the whole job this page does. */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.table th, .table td {
  text-align: left; padding: 8px 10px; line-height: 1.4;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
/* A solid rule closes the header. The header row is the only place in a
   table that gets more than a hairline. */
.table th {
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 600; white-space: nowrap;
  background: var(--surface);
  border-bottom: 2px solid var(--line-strong);
}
.table tbody tr:nth-child(even) { background: var(--surface-2); }
.table tbody tr:hover { background: var(--accent-soft); }
.table tbody tr:last-child td { border-bottom: 0; }

/* A table inside a card loses the card's padding and runs to the sheet
   edges. Boxing rows inside a 16px gutter wastes a column of screen and
   makes the table look like a widget rather than a ledger. */
.card__body > .table-wrap { margin-left: -16px; margin-right: -16px; }
.card__body > .table-wrap:first-child { margin-top: -16px; }
.card__body > .table-wrap:last-child { margin-bottom: -16px; }
.card__body > .table-wrap > .table th:first-child,
.card__body > .table-wrap > .table td:first-child { padding-left: 16px; }
.card__body > .table-wrap > .table th:last-child,
.card__body > .table-wrap > .table td:last-child { padding-right: 16px; }

.empty { color: var(--text-dim); margin: 0; padding: 8px 0; }

.dl { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 8px 18px; margin: 0; }
.dl dt { color: var(--text-dim); font-size: 13px; }
.dl dd { margin: 0; font-size: 14px; }

/* ---------------------------------------------------------- chips ----- */

/* Every chip prints a WORD. The tint sorts them at a glance; the word is
   what the operator reads out on the phone. Nothing here is colour-only,
   so a colour-blind operator loses speed and never loses meaning. */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-dim);
}
.badge--neutral { border-color: var(--line-strong); background: var(--surface-2); color: var(--text-dim); }
.badge--ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.badge--warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.badge--danger { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.badge--info { color: var(--accent-deep); border-color: var(--info); background: var(--info-soft); }

/* Plates and money are monospaced with tabular figures so a column of them
   lines up digit under digit -- the reason someone can spot a wrong kurus
   in a settlement without reading every row. */
.plate {
  font-family: var(--mono); font-weight: 650; letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
.money {
  font-family: var(--mono); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* A negative amount is signed in the text as well as coloured. */
.money--out { color: var(--danger); }
.muted { color: var(--text-dim); }
.lede { font-size: 16px; margin-top: 0; }

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

.form { display: flex; flex-direction: column; gap: 12px; }
.form--inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--text-dim); }
.field input, .field select, .field textarea, .input {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-field); border-radius: var(--radius-m);
  padding: 8px 10px; font: inherit; font-size: 14px; min-width: 0;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
  border-color: var(--accent);
}
/* aria-invalid is the fact; the red border is the echo of it. */
.field input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.input--money {
  font-family: var(--mono); text-align: right;
  font-variant-numeric: tabular-nums;
}

.fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 0; background: var(--surface-2);
}
.fieldset legend { font-size: 12px; color: var(--text-dim); padding: 0 6px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

/* Buttons stay roomy while the tables get tight. These are the targets a
   cashier hits in a hurry, often on a touch screen. */
.btn {
  display: inline-block; border: 1px solid var(--line-field); border-radius: var(--radius-m);
  padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn--secondary { background: var(--surface); border-color: var(--accent); color: var(--accent-deep); }
.btn--secondary:hover { background: var(--accent-soft); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.92); }
.btn--ghost { background: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------- notes ----- */

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash {
  padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); font-size: 14px;
  box-shadow: var(--shadow-1);
}
/* The message itself says what happened; the stripe and tint only make it
   findable on a busy page. */
.flash--ok { border-left: 3px solid var(--ok); background: var(--ok-soft); }
.flash--warn { border-left: 3px solid var(--warn); background: var(--warn-soft); }
.flash--error { border-left: 3px solid var(--danger); background: var(--danger-soft); }

.notes { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-dim); }
.notes--info { color: var(--text-dim); }
.notes--warn { color: var(--warn); }
.notes--danger { color: var(--danger); }
.notes li { margin-bottom: 4px; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; }
.pager__label { color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- map ------- */

.sitemap { display: grid; grid-template-columns: 1fr 280px; gap: 16px; min-height: 420px; }
.sitemap__plane {
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); min-height: 420px;
  box-shadow: var(--shadow-1);
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--line-strong) 70%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line-strong) 70%, transparent) 1px, transparent 1px);
  background-size: 40px 40px;
}
.sitemap__pin {
  position: absolute; transform: translate(-50%, -50%);
  background: none; border: 0; padding: 6px; cursor: pointer;
}
.sitemap__dot {
  display: block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--accent);
}
.sitemap__pin:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sitemap__panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; font-size: 13.5px;
  box-shadow: var(--shadow-1);
}

.popup { display: flex; flex-direction: column; gap: 5px; max-width: 320px; }
.popup__title { font-size: 15px; word-break: break-word; }
.popup__code { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.popup__row { display: flex; gap: 8px; }
.popup__label { color: var(--text-dim); min-width: 68px; }
.popup__value { word-break: break-word; }
.popup__status {
  align-self: flex-start; font-size: 12px; padding: 1px 8px;
  border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text-dim);
}
.popup__link { font-size: 13px; }

/* ---------------------------------------------------------- auth ------ */

.body--auth { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.auth {
  width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px;
  box-shadow: var(--shadow-2);
}
.auth__brand { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 15px; }
.auth__title { margin: 0 0 4px; font-size: 20px; }
.auth__form { margin-top: 14px; }
.auth__note { color: var(--text-dim); font-size: 12.5px; margin: 16px 0 0; }

/* ---------------------------------------------------------- narrow ---- */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; flex-direction: column;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 10px 16px; }
  .main { padding: 16px; }
  .sitemap { grid-template-columns: 1fr; }
}

/* Phone. The tables are the point of the panel, so they keep their rules
   and lose only their gutters -- a horizontal scroll inside .table-wrap is
   better than a wrapped, unreadable cell. */
@media (max-width: 600px) {
  html, body { font-size: 14px; }
  .main { padding: 12px 12px 48px; }
  .page-head { flex-direction: column; gap: 10px; }
  .page-head h1 { font-size: 19px; }
  .card__body { padding: 12px; }
  .card__body > .table-wrap { margin-left: -12px; margin-right: -12px; }
  .card__body > .table-wrap:first-child { margin-top: -12px; }
  .card__body > .table-wrap:last-child { margin-bottom: -12px; }
  .card__body > .table-wrap > .table th:first-child,
  .card__body > .table-wrap > .table td:first-child { padding-left: 12px; }
  .card__body > .table-wrap > .table th:last-child,
  .card__body > .table-wrap > .table td:last-child { padding-right: 12px; }
  .table { font-size: 12.5px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .form--inline, .filters { gap: 8px; }
  .btn { padding: 9px 14px; }
}

/* ---------------------------------------------------------------------
 * The map, when assets/map-gl.mjs has upgraded the schematic.
 *
 * .sitemap keeps its own height so the page does not jump when the
 * schematic is replaced by the canvas -- a map that resizes the page
 * underneath the operator's cursor is how a click lands on the wrong site.
 * ------------------------------------------------------------------- */
.sitemap { min-height: 460px; position: relative; }
.sitemap.map--gl { padding: 0; background: none; border: 0; }
.sitemap.map--gl .maplibregl-canvas { border-radius: var(--radius-m, 8px); }

/* A pin that says how much room is left, so the map reads without clicks. */
.mapdot {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(21, 35, 47, .35);
  font: 700 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  color: #fff;
  cursor: pointer;
  /* The number is free spaces; colour is the same fact at a glance, so
     the map is still readable to someone who cannot separate red from
     green. Never colour alone. These three are deep enough to carry white
     label text at 4.5:1 and still read as green/amber/red on a pale map. */
  background: #12754a;
}
.mapdot[data-load="busy"] { background: #a1660c; }
.mapdot[data-load="full"] { background: #b4342f; }

/* MapLibre's own popup chrome, matched to the panel rather than left
   looking like a different application pasted onto the page. The colours
   are set explicitly because maplibre-gl.css ships its own and we do not
   want the panel's appearance to depend on which version is vendored. */
.maplibregl-popup-content {
  padding: 12px 14px;
  border-radius: var(--radius-m, 8px);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
  font-family: inherit;
}
.maplibregl-popup-content .popup__title { display: block; margin-bottom: 4px; }
