@import url("https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,400;0,600;0,700;1,400&family=Teko:wght@500;600;700&display=swap");

:root {
  --bg: #ebe4d6;
  --bg-2: #d8cbb3;
  --surface: #f6f0e4;
  --ink: #1c1712;
  --muted: #5c5348;
  --line: #2a241c;
  --amber: #d97706;
  --checkin: #1f7a4d;
  --checkout: #c2410c;
  --maint: #4b5563;
  --oos: #9f1239;
  --unknown: #6b5c45;
  --stripe: #c9a227;
  --danger: #9f1239;
  --shadow: 4px 4px 0 #1c1712;
  --font-display: "Teko", Impact, sans-serif;
  --font-body: "Public Sans", "Segoe UI", sans-serif;
  --radius: 2px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg: #12100e;
  --bg-2: #1c1916;
  --surface: #1f1b17;
  --ink: #f3e6d0;
  --muted: #b5a48a;
  --line: #c9a227;
  --shadow: 4px 4px 0 #000;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  background:
    repeating-linear-gradient(135deg, transparent, transparent 18px, rgb(0 0 0 / 0.03) 18px, rgb(0 0 0 / 0.03) 20px),
    var(--bg);
  color: var(--ink);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px; }

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 4px solid var(--stripe);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: inherit;
  line-height: 1;
}
.brand span { display: block; font-size: 0.7rem; letter-spacing: 0.22em; color: var(--muted); font-family: var(--font-body); }
.nav-main { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.nav-main a, .nav-util button, .nav-util a {
  color: inherit;
  text-decoration: none;
  border: 2px solid var(--line);
  padding: 8px 10px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.nav-main a[aria-current="page"], .nav-main a:hover { background: var(--stripe); color: #1c1712; }
.nav-util { display: flex; gap: 6px; align-items: center; }

.theme-toggle {
  width: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}
.theme-toggle .theme-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}
.theme-toggle .theme-icon-sun {
  display: block;
  filter: drop-shadow(0 0 5px #fde047) drop-shadow(0 0 10px #facc15);
}
.theme-toggle .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-moon { display: block; }

.flash {
  margin: 12px 14px 0;
  padding: 12px 14px;
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
}
.flash-error { background: #fde8ee; color: #4a0519; }
.flash-success { background: #dcfce7; color: #14532d; }
[data-theme="dark"] .flash-error { background: #3f1220; color: #fecdd3; }
[data-theme="dark"] .flash-success { background: #14532d; color: #bbf7d0; }

.page { padding: 16px 14px 96px; max-width: 1100px; margin: 0 auto; }
.page-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 8vw, 4rem);
  margin: 0 0 4px;
  letter-spacing: 0.04em;
  line-height: 0.9;
}
.lede { color: var(--muted); margin: 0 0 20px; }

.stencil {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0; }
.stat {
  border: 3px solid var(--line);
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-family: var(--font-display); font-size: 2.4rem; line-height: 1; }
.stat span { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 4px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  border: 2px solid currentColor;
}
.badge-checked_in { color: var(--checkin); }
.badge-checked_out { color: var(--checkout); }
.badge-maintenance { color: var(--maint); }
.badge-out_of_service { color: var(--oos); }
.badge-unknown { color: var(--unknown); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 16px;
  border: 3px solid var(--line);
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn-primary { background: var(--stripe); color: #1c1712; }
.btn-checkin { background: var(--checkin); color: #f3eee4; border-color: #14532d; }
.btn-checkout { background: var(--checkout); color: #fff7ed; border-color: #7c2d12; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }

.has-sticky-action { padding-bottom: 96px; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 0 -14px;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: var(--bg);
  pointer-events: none;
}
.sticky-actions .btn { pointer-events: auto; }

.panel {
  border: 3px solid var(--line);
  background: var(--surface);
  padding: 16px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}

label { display: block; font-weight: 700; margin: 12px 0 6px; letter-spacing: 0.04em; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 3px solid var(--line);
  background: var(--bg);
  color: inherit;
  font: inherit;
  padding: 10px;
}
textarea { min-height: 110px; }
.checks { display: grid; gap: 8px; }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 2px dashed var(--line);
  padding: 8px 10px;
}
.check input { width: 28px; height: 28px; min-height: 28px; }

.stepper {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.stepper input { flex: 1; min-width: 0; border-left: 0; border-right: 0; text-align: center; }
.stepper-btn {
  min-width: 52px;
  min-height: 48px;
  border: 3px solid var(--line);
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid rgb(0 0 0 / 0.15); }
th { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.card-list { display: none; }
.trailer-card {
  border: 3px solid var(--line);
  padding: 12px;
  margin: 10px 0;
  background: var(--surface);
}
.trailer-num { font-family: var(--font-display); font-size: 2.4rem; line-height: 0.9; }

.search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-bar input { flex: 1; min-width: 160px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filters a { padding: 8px 10px; border: 2px solid var(--line); text-decoration: none; color: inherit; min-height: 48px; display: inline-flex; align-items: center; }
.filters a.is-on { background: var(--stripe); color: #1c1712; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  border: 4px solid var(--line);
  background: var(--surface);
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-family: var(--font-display); font-size: 3.2rem; margin: 0 0 8px; }

.hero-status { font-family: var(--font-display); font-size: clamp(2.6rem, 10vw, 5rem); line-height: 0.85; margin: 8px 0; }

.hidden { display: none; }
.muted { color: var(--muted); }

.qr-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin: 12px 0 16px;
}
.qr-toolbar label { margin: 0; }
.qr-toolbar select { min-width: 110px; }
.qr-table-wrap { display: block; }
.qr-table { background: var(--surface); border: 3px solid var(--line); }
.qr-table th, .qr-table td { vertical-align: middle; }
.qr-check-col { width: 44px; text-align: center; }
.qr-check-col input { width: 22px; height: 22px; min-height: 22px; }
.qr-table td.editable { cursor: text; min-width: 88px; }
.qr-table td.editable:hover { outline: 2px dashed var(--stripe); outline-offset: -2px; }
.qr-table .cell-editor {
  min-height: 40px;
  margin: 0;
  width: 100%;
}
.qr-row-actions { white-space: nowrap; }
.qr-row-actions a { margin-right: 8px; }
.pager { display: flex; gap: 10px; align-items: center; margin: 16px 0; }

.guide img { max-width: 100%; border: 3px solid var(--line); margin: 8px 0 20px; }
.guide h2 { font-family: var(--font-display); font-size: 2rem; margin-top: 28px; }

@media (max-width: 799px) {
  .desktop-table { display: none; }
  .card-list { display: block; }
  .nav-main a { flex: 1 1 auto; justify-content: center; }
}

@media print {
  .app-header, .flash, .sticky-actions, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .page { padding: 0; }
}
