:root {
  --navy-950: #0b1f33;
  --navy-900: #102a43;
  --navy-800: #183b56;
  --navy-700: #2a4d69;
  --gold-500: #c99532;
  --gold-100: #fff4d6;
  --ink: #17222d;
  --muted: #637083;
  --line: #d9e2ec;
  --surface: #ffffff;
  --canvas: #f3f6f9;
  --success: #16835b;
  --success-bg: #e8f7f0;
  --warning: #9a5b00;
  --warning-bg: #fff3d6;
  --danger: #b42318;
  --danger-bg: #feeceb;
  --shadow: 0 16px 44px rgba(16, 42, 67, .09);
  --radius: 18px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: var(--navy-800); text-underline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .55rem; color: var(--navy-950); font-size: clamp(2rem, 7vw, 3rem); line-height: 1.06; letter-spacing: -.035em; }
h2 { margin-bottom: .5rem; color: var(--navy-950); font-size: 1.35rem; line-height: 1.2; }
small { display: block; color: var(--muted); }

.site-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 9px max(18px, env(safe-area-inset-left)); border-bottom: 1px solid rgba(217,226,236,.9); background: rgba(255,255,255,.95); backdrop-filter: blur(12px); }
.brand { display: flex; min-width: 0; gap: 12px; align-items: center; color: var(--navy-950); text-decoration: none; }
.brand-logo { display: block; width: clamp(136px, 31vw, 188px); height: auto; flex: 0 1 auto; }
.brand-app-name { display: none; padding-left: 12px; border-left: 1px solid var(--line); color: var(--navy-800); font-size: .74rem; font-weight: 800; line-height: 1.2; letter-spacing: .04em; text-transform: uppercase; }
.header-user { display: flex; align-items: center; gap: 12px; font-size: .83rem; }
.header-user form { margin: 0; }
.user-name { display: none; font-weight: 700; }

.admin-nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px max(18px, calc((100vw - 1180px) / 2)); border-bottom: 1px solid var(--line); background: white; scrollbar-width: none; }
.admin-nav a { flex: 0 0 auto; padding: 9px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 700; }
.admin-nav a.active { color: var(--navy-950); background: var(--gold-100); }

.page-shell { width: min(100% - 28px, 1120px); margin: 0 auto; padding: 28px 0 64px; }
.site-footer { padding: 22px; color: var(--muted); text-align: center; font-size: .75rem; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--gold-500); font-size: .74rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.hero-card, .form-card, .state-card, .confirmation-card, .admin-card, .notice-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.hero-card { overflow: hidden; padding: clamp(28px, 7vw, 58px); background: linear-gradient(145deg, white 58%, #edf3f8); }
.hero-card > p { max-width: 620px; color: var(--muted); font-size: 1.05rem; }
.notice-card { margin-top: 16px; padding: 20px 22px; box-shadow: none; }
.notice-card p { margin: 4px 0 0; color: var(--muted); }
.steps { display: grid; gap: 10px; margin: 28px 0; }
.steps div { display: grid; grid-template-columns: 36px 1fr; gap: 0 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.75); }
.steps div > span { grid-row: 1 / 3; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: white; background: var(--navy-900); font-weight: 800; }

.vehicle-banner { position: relative; overflow: hidden; padding: 26px 24px; border-radius: var(--radius) var(--radius) 0 0; color: white; background: linear-gradient(135deg, var(--navy-950), var(--navy-800)); }
.vehicle-banner::after { content: ""; position: absolute; right: -60px; bottom: -100px; width: 240px; height: 240px; border: 34px solid rgba(201,149,50,.16); border-radius: 50%; }
.vehicle-banner h1 { position: relative; z-index: 1; margin: 0; color: white; }
.vehicle-banner p { position: relative; z-index: 1; margin: 4px 0 0; color: #dbe8f2; }
.status-dot { position: absolute; top: 23px; right: 24px; z-index: 2; width: 12px; height: 12px; border: 3px solid rgba(255,255,255,.35); border-radius: 50%; background: #53d59f; box-shadow: 0 0 0 7px rgba(83,213,159,.13); }
.status-dot.status-return { background: var(--gold-500); box-shadow: 0 0 0 7px rgba(201,149,50,.13); }
.identity-strip { display: flex; justify-content: space-between; align-items: center; padding: 13px 20px; border: 1px solid var(--line); border-top: 0; background: #f8fafc; }
.identity-strip span { color: var(--muted); font-size: .8rem; }
.identity-strip strong { text-align: right; font-size: .9rem; }
.vehicle-banner + .form-card, .identity-strip + .form-card { border-top-left-radius: 0; border-top-right-radius: 0; }

.form-card { padding: clamp(22px, 5vw, 34px); }
.narrow-card { max-width: 520px; margin: 30px auto; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.section-heading h2 { margin: 0; }
.metric { min-width: 112px; padding: 10px 12px; border-radius: 12px; background: var(--canvas); text-align: right; }
.metric strong { display: block; color: var(--navy-950); font-size: .98rem; }
.metric small { font-size: .68rem; }
.trip-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 22px; }
.trip-summary span { padding: 7px 10px; border-radius: 999px; color: var(--navy-800); background: #edf4f8; font-size: .78rem; font-weight: 700; }

form label, fieldset legend { display: block; margin-bottom: 7px; color: var(--navy-950); font-size: .85rem; font-weight: 760; }
input, select, textarea { width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid #b9c6d3; border-radius: 10px; color: var(--ink); background: white; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(201,149,50,.15); }
textarea { resize: vertical; }
form > label:not(:first-child), form > fieldset, form > .number-field, form > .button, form > .exception-panel { margin-top: 17px; }
.number-field { position: relative; }
.number-field input { min-height: 70px; padding-right: 58px; font-size: 1.7rem; font-weight: 800; letter-spacing: .02em; }
.number-field span { position: absolute; right: 17px; top: 50%; color: var(--muted); transform: translateY(-50%); font-weight: 750; }
.code-input { min-height: 72px; text-align: center; font-size: 2rem; font-weight: 850; letter-spacing: .25em; }
fieldset { padding: 0; border: 0; }
.choice-grid { display: grid; gap: 10px; }
.choice { position: relative; margin: 0; cursor: pointer; }
.choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.choice > span { display: block; min-height: 76px; padding: 15px; border: 1px solid #b9c6d3; border-radius: 13px; background: white; transition: .15s; }
.choice input:checked + span { border-color: var(--gold-500); background: var(--gold-100); box-shadow: 0 0 0 3px rgba(201,149,50,.12); }
.choice input:focus-visible + span { outline: 3px solid rgba(201,149,50,.35); outline-offset: 2px; }
.choice strong { display: block; color: var(--navy-950); }
.choice small { margin-top: 3px; }
.distance-preview { min-height: 24px; margin: 8px 0 0; color: var(--success); font-weight: 750; }
.exception-panel { padding: 16px; border: 1px solid #e4b752; border-radius: 13px; background: var(--warning-bg); }
.exception-panel[hidden] { display: none; }
.exception-panel p { margin: 4px 0 12px; color: #714b11; font-size: .85rem; }
.exception-panel label:not(:first-of-type) { margin-top: 12px; }
.secondary-form { margin-top: 18px; text-align: center; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 11px 17px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; text-decoration: none; font-size: .9rem; font-weight: 780; transition: transform .12s, box-shadow .12s, opacity .12s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { color: white; background: var(--navy-900); box-shadow: 0 8px 18px rgba(16,42,67,.16); }
.button-secondary { border-color: var(--line); color: var(--navy-900); background: white; }
.button-danger { color: white; background: var(--danger); }
.button-full { width: 100%; }
.link-button { padding: 0; border: 0; color: var(--navy-700); background: none; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.revoke-button { color: var(--danger); font-size: .78rem; }

.alert { margin-bottom: 14px; padding: 13px 15px; border: 1px solid; border-radius: 11px; font-size: .9rem; }
.alert-success { border-color: #a8dec8; color: #0e6747; background: var(--success-bg); }
.alert-error { border-color: #f4b9b4; color: #8f1d15; background: var(--danger-bg); }
.alert-warning { border-color: #e8ca7d; color: #764c0a; background: var(--warning-bg); }
.state-card { max-width: 680px; margin: 24px auto; padding: 30px; text-align: center; }
.state-card p { color: var(--muted); }
.state-warning { border-color: #ead49b; background: #fffdf7; }
.state-error { border-color: #efc2bf; }

.confirmation-card { max-width: 540px; margin: 20px auto; padding: 32px; text-align: center; }
.success-mark { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 18px; border-radius: 50%; color: white; background: var(--success); font-size: 2rem; font-weight: 900; }
.confirmation-card > p { color: var(--muted); }
.receipt { margin: 24px 0; border-top: 1px solid var(--line); }
.receipt div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); text-align: left; }
.receipt dt { color: var(--muted); font-size: .82rem; }
.receipt dd { margin: 0; color: var(--navy-950); text-align: right; font-weight: 760; }
.receipt dd small { margin-top: 3px; }
.confirmation-note { padding: 14px; border-radius: 10px; background: var(--canvas); font-size: .9rem; }

.page-heading { display: flex; flex-direction: column; gap: 16px; margin-bottom: 22px; }
.page-heading h1 { margin-bottom: 4px; }
.page-heading p { margin: 0; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.stat-card small { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stat-card strong { display: block; margin-top: 4px; color: var(--navy-950); font-size: 2rem; }
.stat-alert { border-color: #e6bf59; background: var(--warning-bg); }
.admin-card { margin-bottom: 18px; padding: 20px; box-shadow: 0 8px 28px rgba(16,42,67,.05); }
.admin-card > h2 { margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { padding: 10px 12px; color: var(--muted); background: #f6f8fa; text-align: left; white-space: nowrap; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
td { padding: 13px 12px; border-top: 1px solid var(--line); vertical-align: top; }
td strong, td small { display: block; }
.row-overdue td { background: #fffaf0; }
.badge { display: inline-block; margin: 2px 5px 2px 0; padding: 3px 7px; border-radius: 999px; color: var(--navy-800); background: #eaf1f6; font-size: .66rem; font-weight: 800; text-transform: uppercase; }
.badge-alert { color: #804e00; background: #ffe6a6; }
.empty-state { padding: 24px; color: var(--muted); text-align: center; }
.filter-bar { display: grid; gap: 10px; margin-bottom: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.filter-bar label { margin: 0; }
.filter-bar input, .filter-bar select { min-height: 42px; margin-top: 4px; }
.check-label { display: flex !important; align-items: center; gap: 8px; min-height: 44px; margin: 0 !important; }
.check-label input { width: 18px; min-height: 18px; height: 18px; }
.detail-grid { display: grid; gap: 18px; }
.note-box { display: grid; gap: 4px; padding: 14px; border-radius: 10px; background: var(--canvas); }
.evidence-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.evidence-links strong { width: 100%; }

.inline-editor, .directory-row { display: grid; gap: 12px; align-items: end; }
.inline-editor label, .directory-row label { margin: 0; }
.directory-list { display: grid; gap: 14px; }
.directory-row { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfd; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.vehicle-admin-row { padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.vehicle-admin-row .directory-row { border: 0; border-radius: 0; }
.regenerate-form { padding: 9px 15px; border-top: 1px solid var(--line); background: white; text-align: right; }

.print-toolbar { display: flex; justify-content: space-between; margin-bottom: 18px; }
.qr-sticker { width: min(100%, 620px); margin: 0 auto; padding: 34px; border: 4px solid var(--navy-950); border-radius: 22px; background: white; text-align: center; box-shadow: var(--shadow); }
.qr-sticker img { display: block; width: min(100%, 460px); height: auto; margin: 14px auto; image-rendering: pixelated; }
.qr-sticker h1 { margin: 10px 0 0; font-size: clamp(2.2rem, 10vw, 4rem); }
.qr-sticker h2 { margin: 2px 0 12px; color: var(--gold-500); text-transform: uppercase; }
.qr-sticker > p { margin: 20px 0 0; font-weight: 900; letter-spacing: .08em; }
.qr-sticker code { display: block; overflow-wrap: anywhere; margin-top: 14px; color: var(--muted); font-size: .65rem; }
.sticker-brand { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 9px; color: var(--navy-950); font-size: .84rem; letter-spacing: .12em; }
.sticker-logo { display: block; width: min(82%, 350px); height: auto; }

@media (min-width: 620px) {
  .brand-app-name { display: inline-block; }
  .user-name { display: inline; }
  .page-shell { padding-top: 38px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .steps div { grid-template-columns: 36px 1fr; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .page-heading { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .filter-bar { grid-template-columns: repeat(3, 1fr); align-items: end; }
  .filter-bar .button { align-self: end; }
  .inline-editor { grid-template-columns: 2fr 2fr 1fr auto auto; }
  .directory-row { grid-template-columns: 2fr 2fr 1fr auto; }
  .directory-row .row-actions { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  .detail-grid { grid-template-columns: 1.05fr .95fr; }
  .filter-bar { grid-template-columns: repeat(5, 1fr) auto auto; }
  .directory-row { grid-template-columns: 2fr 2fr 1fr auto 1.4fr; }
  .directory-row .row-actions { grid-column: auto; justify-content: flex-end; }
}

@media print {
  body { background: white; }
  .site-header, .admin-nav, .site-footer, .print-toolbar { display: none !important; }
  .page-shell { width: 100%; padding: 0; }
  .qr-sticker { width: 145mm; box-shadow: none; page-break-inside: avoid; }
}
