/* MMG Fuel Tracker — one stylesheet, two surfaces.
   Kiosk: dark "pump display" — charcoal panel, Martin-red accent, huge
   touch targets, all inputs >= 16px (prevents iOS Safari focus zoom).
   Admin: quiet, light, dense-but-legible utility tables. */

:root {
  --ink: #1c2430;
  --ink-soft: #5b6675;
  --paper: #f6f7f9;
  --panel: #ffffff;
  --line: #dde2e9;
  --asphalt: #1a1b1e;
  --brand-red: #d7212a;
  --brand-red-deep: #a3141c;
  --silver: #9a9ea5;
  --pump-bg: #16181d;
  --pump-panel: #21242c;
  --pump-line: #383d49;
  --pump-text: #f3f4f6;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --ok: #1b6e3c;
  --ok-bg: #e8f5ec;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
/* Author display rules (.btn, .a2hs, ...) outrank the UA's [hidden] rule;
   without this, the hidden attribute silently stops working. */
[hidden] { display: none !important; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); }
.mono { font-family: var(--mono); }

/* ---------- shared bits ---------- */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: var(--radius);
  padding: 10px 18px; font-size: 16px; font-weight: 600; cursor: pointer;
  text-decoration: none; text-align: center; line-height: 1.3;
}
.btn-primary { background: var(--brand-red); border-color: var(--brand-red-deep); color: #fff; }
.btn-primary:hover { background: #e8353c; }
.btn-secondary { background: transparent; border-color: currentColor; color: inherit; }
.btn-ghost { background: transparent; color: inherit; opacity: .85; }
.btn-ghost:hover { opacity: 1; text-decoration: underline; }
.btn-big { width: 100%; padding: 16px; font-size: 18px; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 2px; }

.alert {
  background: var(--danger-bg); color: var(--danger); border: 1px solid currentColor;
  border-radius: var(--radius); padding: 10px 14px; font-size: 16px;
}
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-warn { background: #fff7e0; color: #7a5900; }
.alert-inline { color: var(--danger); font-size: 14px; }
.hint { color: var(--ink-soft); font-size: 14px; }

/* The signature element: store-code chips, cut like dealer plate tags. */
.chip {
  display: inline-block; font-family: var(--mono); font-size: 12.5px; font-weight: 700;
  background: #2b2e33; color: #fff; padding: 2px 9px 2px 12px; margin: 1px 3px 1px 0;
  clip-path: polygon(6px 0, 100% 0, 100% 100%, 6px 100%, 0 50%);
  letter-spacing: .04em;
}
.chip-all { background: var(--brand-red-deep); }
.tag {
  display: inline-block; font-size: 12.5px; border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 9px; margin: 1px 3px 1px 0; color: var(--ink-soft);
}
.tag-muted { background: var(--line); }

/* ---------- kiosk ---------- */
body.kiosk { background: var(--pump-bg); color: var(--pump-text); }
.kiosk-shell {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px calc(16px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.kiosk-card {
  width: 100%; max-width: 420px; background: var(--pump-panel);
  border: 1px solid var(--pump-line); border-top: 4px solid var(--brand-red);
  border-radius: 14px; padding: 28px 24px;
}
.brand { text-align: center; margin-bottom: 22px; }
.brand h1 { margin: 10px 0 2px; font-size: 26px; letter-spacing: .01em; }
.brand h1 em, .admin-logo em { font-style: normal; color: var(--brand-red); }
.brand-sub { margin: 0; color: #9aa3b2; font-size: 14px; letter-spacing: .12em; text-transform: uppercase; }
.brand-gauge {
  display: inline-block; width: 46px; height: 25px;
  border: 3px solid var(--brand-red); border-bottom: none; border-radius: 46px 46px 0 0;
  position: relative;
}
.brand-gauge::after {
  content: ""; position: absolute; left: 50%; bottom: 0; width: 3px; height: 17px;
  background: var(--silver); transform-origin: bottom center; transform: rotate(35deg);
}
.brand-gauge.sm { width: 26px; height: 14px; border-width: 2px; }
.brand-gauge.sm::after { height: 9px; width: 2px; }

.kiosk label { display: block; font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.pin-input {
  width: 100%; font-size: 32px; font-family: var(--mono); letter-spacing: .5em;
  text-align: center; padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--pump-line); background: var(--pump-bg); color: var(--pump-text);
  margin-bottom: 6px;
}
.kiosk .hint { color: #9aa3b2; margin: 6px 0 16px; }
.kiosk .alert { margin-bottom: 16px; }
.welcome { font-size: 18px; margin: 0 0 18px; }
.hub-actions { display: grid; gap: 12px; }
.hub-actions .btn-secondary { color: var(--pump-text); }
.signout { margin-top: 26px; text-align: center; }
.signout .btn { color: #9aa3b2; }
.stub-title { margin-top: 0; }

/* ---------- admin ---------- */
.admin-header {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  background: var(--asphalt); color: #fff; padding: 10px 22px;
}
.admin-logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 9px; }
.admin-logo .brand-gauge { border-color: var(--brand-red); }
.admin-logo .brand-gauge::after { background: #fff; }
.admin-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.admin-nav a { color: #dbe4f0; text-decoration: none; padding: 6px 11px; border-radius: 7px; font-size: 15px; }
.admin-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.admin-nav a.disabled { opacity: .45; cursor: default; }
.admin-session { display: flex; align-items: center; gap: 10px; color: #dbe4f0; font-size: 14px; }
.admin-session .btn { color: #fff; }

.admin-main { max-width: 1080px; margin: 0 auto; padding: 26px 22px 60px; }
.admin-main h1 { margin: 0 0 18px; font-size: 24px; }
.admin-main h2 { font-size: 17px; margin: 30px 0 10px; }
.narrow { max-width: 640px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }

.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 15px; vertical-align: top; }
.table th { background: var(--paper); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.table tr:last-child td { border-bottom: none; }
.row-inactive td { opacity: .55; }
.cell-sub { color: var(--ink-soft); font-size: 13px; }
.cell-diff pre { max-width: 340px; overflow-x: auto; font-size: 12px; background: var(--paper); padding: 6px; border-radius: 6px; }

.filter-bar { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar input[type="search"] { min-width: 260px; }

.stack { display: grid; gap: 18px; }
.stack > label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
.stack > label.check-inline, fieldset > label.check-inline { display: flex; align-items: center; }
.stack .hint { font-weight: 400; }
input, select, textarea {
  font: inherit; font-size: 16px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input[type="checkbox"] { width: auto; accent-color: var(--asphalt); transform: scale(1.15); }
.check-inline { display: flex; align-items: center; gap: 9px; font-weight: 400; font-size: 15px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 9px; }
legend { font-weight: 700; font-size: 14px; padding: 0 6px; }
.preset-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.preset-row .btn { border: 1px solid var(--line); }
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 7px; }
.field-row { display: flex; gap: 8px; align-items: center; }
.pin-field { max-width: 110px; font-size: 18px; letter-spacing: .2em; }
.form-actions { display: flex; gap: 12px; }

.stat-row { display: flex; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 22px; min-width: 150px; }
.stat-num { display: block; font-size: 30px; font-weight: 800; color: var(--asphalt); }
.stat-label { color: var(--ink-soft); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 640px) {
  .admin-header { padding: 10px 14px; }
  .admin-main { padding: 18px 14px 50px; }
  .table th, .table td { padding: 8px 8px; font-size: 14px; }
}


/* ---------- Martin branding + danger zone ---------- */
.brand-logo { display: block; margin: 0 auto 6px; width: min(230px, 78%); max-width: 100%; height: auto; }
.admin-logo .brand-logo-sm { height: 26px; width: auto; display: block; }
.admin-logo { gap: 12px; }
.admin-logo em { color: var(--brand-red); font-style: normal; font-size: 13px;
  text-transform: uppercase; letter-spacing: .14em; align-self: flex-end; padding-bottom: 2px; }

.btn-danger { background: #fff; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.danger-zone { border-color: #f0c3c0; margin-top: 30px; }
.danger-zone legend { color: var(--danger); }


/* ---------- add-to-home-screen hint ---------- */
.a2hs {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; z-index: 20;
  background: var(--pump-panel); border: 1px solid var(--pump-line);
  border-left: 4px solid var(--brand-red); border-radius: 12px;
  padding: 10px 12px; color: var(--pump-text); font-size: 14px;
  max-width: 440px; margin: 0 auto;
}
.a2hs img { border-radius: 7px; flex-shrink: 0; }
.a2hs span { flex: 1; }
.a2hs .btn-ghost { color: #9aa3b2; font-size: 18px; padding: 2px 8px; }

.form-lock { border: 0; padding: 0; margin: 0; }
.form-lock:disabled { opacity: .6; }

/* ---------- kiosk capture + review ---------- */
.kiosk-card.wide { max-width: 560px; }
.screen-title { margin: 0 0 8px; font-size: 21px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.capture-stack, .detail-stack { display: grid; gap: 10px; margin-top: 12px; }
.capture-stack label, .detail-stack label { font-size: 15px; font-weight: 600; display: grid; gap: 5px; }
.kiosk input, .kiosk select {
  background: var(--pump-bg); color: var(--pump-text); border: 1px solid var(--pump-line);
}
.kiosk input[type="file"] { padding: 12px 11px; }
.capture-store { margin: 0; font-size: 15px; }
.photo-preview { max-width: 100%; max-height: 220px; border-radius: 10px; border: 1px solid var(--pump-line); justify-self: start; }
.back-link { display: block; text-align: center; margin-top: 18px; color: #9aa3b2; }

.review-filters { display: flex; gap: 8px; margin: 10px 0 14px; flex-wrap: wrap; }
.review-filters select, .review-filters input { flex: 1; min-width: 110px; }
.receipt-rows { display: grid; gap: 8px; }
.receipt-row {
  display: block; text-decoration: none; color: var(--pump-text);
  background: var(--pump-bg); border: 1px solid var(--pump-line); border-radius: 10px;
  padding: 10px 12px;
}
.receipt-row:hover { border-color: var(--silver); }
.receipt-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.receipt-sub { display: block; color: #9aa3b2; font-size: 13px; margin-top: 4px; }
.receipt-meta { color: #9aa3b2; font-size: 13.5px; margin: 2px 0 10px; }

.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.badge-pending { background: #3a3f4b; color: #cfd5df; }
.badge-processed { background: #173d26; color: #7ede9f; }
.badge-needs_review { background: #4a3a10; color: #f2c14b; }
.badge-failed { background: #4a1714; color: #ff9d96; }

.receipt-photo summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }
.receipt-photo img { max-width: 100%; border-radius: 10px; border: 1px solid var(--pump-line); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .detail-grid { grid-template-columns: 1fr; } }
.conf-low { color: var(--brand-red); font-weight: 800; cursor: help; }


/* ---------- reports ---------- */
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.report-filters { align-items: end; }
.report-filters input[type="search"] { min-width: 160px; }
.range-label { display: grid; gap: 3px; font-size: 12.5px; color: var(--ink-soft); }
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.btn-link-danger { background: none; border: none; color: var(--danger); cursor: pointer; font: inherit; font-size: 14px; padding: 0; text-decoration: underline; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(12, 14, 18, .72);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-box {
  background: var(--panel); border-radius: 12px; max-width: min(680px, 94vw);
  max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
}
.modal-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.modal-bar .btn-ghost { font-size: 20px; color: var(--ink-soft); }
.modal-box img { display: block; max-width: 100%; max-height: calc(92vh - 54px); object-fit: contain; margin: 0 auto; }

.alt-signin { text-align: center; margin: 16px 0 0; font-size: 14px; }
.alt-signin a { color: #9aa3b2; }
.alt-signin a:hover { color: var(--pump-text); }

.report-filters { margin-bottom: 14px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; max-width: 620px; }
.date-pair { display: flex; align-items: center; gap: 6px; }
.date-sep { color: var(--ink-soft); }
@media (max-width: 560px) { .filter-grid { grid-template-columns: 1fr; } }
.badge-link { text-decoration: none; }
.badge-link:hover .badge { outline: 2px solid currentColor; }

.utilization-frame { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; overflow-x: auto; }

.filter-grid-3 { grid-template-columns: 1fr 1fr auto; max-width: 720px; align-items: end; }
.labeled-filter { display: grid; gap: 3px; }
.mini-label { font-size: 11.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.clear-filters { align-self: end; white-space: nowrap; }
@media (max-width: 560px) { .filter-grid-3 { grid-template-columns: 1fr; } .filter-grid-3 > span:empty { display: none; } }
