/* ==========================================================================
   Milemarker — brand system (from design_handoff_milemarker_brand)
   Haze paper, Asphalt ink, Sunset Coral, Lane Gold accents, square corners.
   Display & body: Overpass · Technical/meta: Overpass Mono
   ========================================================================== */

:root {
  --paper: #F5EFE6;        /* Haze */
  --paper-deep: #EFE7D8;   /* panel tint */
  --panel: #F8F2E7;
  --ink: #2B2B30;          /* Asphalt */
  --ink-soft: #6F675A;     /* muted text */
  --rule: #D8CFC0;         /* Sand rule */
  --rule-soft: #E5DECF;
  --orange: #E3785C;       /* Sunset Coral */
  --orange-deep: #C4573D;
  --gold: #E8B04B;         /* Lane Gold */
  --blue: #5E7A93;         /* Marine, darkened for text */
  --ok: #3D7A44;
  --warn: #96660A;
  --bad: #A72315;
  --shadow: none;
  --font-display: 'Overpass', 'Helvetica Neue', sans-serif;
  --font-body: 'Overpass', 'Helvetica Neue', sans-serif;
  --font-mono: 'Overpass Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* paper grain */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--orange-deep); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.05; }

.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ==========================================================================
   Sidebar — manual cover / tab index
   ========================================================================== */
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--paper-deep);
  border-right: 2px solid var(--ink);
  padding: 22px 0 24px;
  display: flex; flex-direction: column;
}
.brand { padding: 0 18px 16px; border-bottom: 2px solid var(--ink); margin-bottom: 14px; }
.brand-crest { display: block; overflow: hidden; line-height: 0; margin-bottom: 8px; }
.brand-name {
  font-family: var(--font-display); font-weight: 800; font-size: 17px;
  letter-spacing: .28em; text-transform: uppercase; padding-left: .28em;
}
.brand-sub {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .24em;
  color: #B98A5E; text-transform: uppercase; margin-top: 4px;
}
.nav-link {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 18px; margin: 1px 0;
  color: var(--ink); text-decoration: none;
  font-weight: 600; font-size: 14px; letter-spacing: .02em;
  text-transform: uppercase;
  border-left: 4px solid transparent;
}
.nav-num { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-soft); }
.nav-link:hover { background: var(--panel); border-left-color: var(--rule); }
.nav-link.active { border-left-color: var(--orange); background: var(--panel); }
.nav-link.active .nav-num { color: var(--orange-deep); }

.side-head {
  margin: 20px 18px 6px; padding-top: 14px; border-top: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-soft);
}
.vehicle-btn {
  display: block; width: calc(100% - 24px); margin: 3px 12px; text-align: left;
  background: var(--panel); border: 1.5px solid var(--rule);
  color: var(--ink); padding: 8px 10px; cursor: pointer;
  font: 600 13.5px var(--font-body);
}
.vehicle-btn small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 10.5px; color: var(--ink-soft); margin-top: 1px; }
.vehicle-btn:hover { border-color: var(--ink); }
.vehicle-btn.active { border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); background: #fff; }
.sidebar > .btn { margin: 10px 12px 0; }

/* ==========================================================================
   Main column & section headers
   ========================================================================== */
.main { flex: 1; padding: 30px 36px 70px; max-width: 1080px; min-width: 0; }

@media (prefers-reduced-motion: no-preference) {
  .main > * { animation: rise .35s cubic-bezier(.2,.7,.3,1) both; }
  .main > *:nth-child(2) { animation-delay: .04s; }
  .main > *:nth-child(3) { animation-delay: .08s; }
  .main > *:nth-child(4) { animation-delay: .12s; }
  .main > *:nth-child(5) { animation-delay: .16s; }
  .main > *:nth-child(6) { animation-delay: .20s; }
  @keyframes rise { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
  @keyframes sun-rise { 0%, 100% { transform: translateY(16px); } 50% { transform: translateY(0); } }
}

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  border-bottom: 3px double var(--ink);
  padding-bottom: 12px; margin-bottom: 22px; flex-wrap: wrap;
}
.kicker {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--orange-deep); margin-bottom: 2px;
}
.topbar h1 {
  margin: 0; font-family: var(--font-display); font-weight: 800;
  font-size: 29px; text-transform: uppercase; letter-spacing: .08em; line-height: 1.15;
}
.topbar .sub { color: var(--ink-soft); font-size: 13.5px; max-width: 60ch; }
.topbar .actions { display: flex; gap: 8px; padding-bottom: 4px; }

/* ==========================================================================
   Buttons & inputs
   ========================================================================== */
.btn {
  display: inline-block;
  background: var(--panel); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 0;
  padding: 9px 16px; cursor: pointer; text-decoration: none;
  font: 800 12px var(--font-body); letter-spacing: .14em; text-transform: uppercase;
  transition: filter 150ms ease, background 150ms ease;
}
.btn:hover { background: rgba(43, 43, 48, .06); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #F5EFE6; }
.btn.primary:hover { background: var(--orange); filter: brightness(.94); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: none; }
.btn.danger:hover { background: rgba(167, 35, 21, .07); }
.btn.small { padding: 5px 10px; font-size: 10.5px; }

input, select, textarea {
  background: #FBF7EE; color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 0;
  padding: 8px 10px; font: 400 14px var(--font-body); width: 100%;
}
input[type="number"], input[type="date"] { font-family: var(--font-mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
label {
  display: block; margin-bottom: 4px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft);
}
.field { margin-bottom: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ==========================================================================
   Cards & spec plates
   ========================================================================== */
.card {
  position: relative;
  background: var(--panel);
  border: 1.5px solid var(--ink);
  padding: 18px 20px; margin-bottom: 18px;
}
.card h3 {
  margin: -18px -20px 14px; padding: 8px 20px 7px;
  border-bottom: 1.5px solid var(--ink);
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  background: var(--paper-deep);
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1.5px solid var(--ink);
  padding: 12px 14px 10px; position: relative;
}
.stat::after {
  content: ''; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--rule); box-shadow: inset 0 0 0 1px var(--ink-soft);
}
.stat .num { font-family: var(--font-display); font-weight: 800; font-size: 30px; letter-spacing: .01em; }
.stat .lbl { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); }

/* ==========================================================================
   Stamps (verification verdicts) & tags
   ========================================================================== */
.badge, .stamp {
  display: inline-block;
  font: 600 10.5px var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
  border: 1.5px solid currentColor; border-radius: 1px;
  padding: 2px 8px 1px;
  transform: rotate(-1.6deg);
  white-space: nowrap;
}
.badge.ok   { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad  { color: var(--bad); transform: rotate(-3deg); }
.badge.none { color: var(--ink-soft); border-style: dashed; transform: none; }
.badge.type { color: var(--blue); transform: none; border-style: solid; }

/* ==========================================================================
   Tables
   ========================================================================== */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
  font-family: var(--font-mono); font-weight: 600; font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft);
  border-bottom: 1.5px solid var(--ink);
}
td .mono, .mono { font-family: var(--font-mono); font-size: 12.5px; }
tr:last-child td { border-bottom: none; }

/* ==========================================================================
   Record rows (ledger style)
   ========================================================================== */
.record-row {
  display: flex; gap: 14px; align-items: center;
  padding: 11px 6px; border-bottom: 1px dashed var(--rule); cursor: pointer;
}
.record-row:hover { background: rgba(208, 73, 27, .06); }
.record-row:last-child { border-bottom: none; }
.record-row .grow { flex: 1; min-width: 0; }
.record-row .title { font-weight: 700; font-size: 15px; }
.record-row .meta { color: var(--ink-soft); font-family: var(--font-mono); font-size: 11.5px; margin-top: 1px; }

/* ==========================================================================
   Dynamic form rows
   ========================================================================== */
.row-list .frow { display: grid; gap: 8px; margin-bottom: 8px; align-items: center; }
.frow.part-row { grid-template-columns: 2fr 1.2fr 1.4fr 60px 90px 30px; }
.frow.torque-row { grid-template-columns: 2fr 2fr 30px; }
.frow.plan-part-row { grid-template-columns: 1.8fr 1.2fr 55px 85px 1.6fr 30px; }
.row-x { background: none; border: none; color: var(--bad); font: 700 15px var(--font-mono); cursor: pointer; padding: 2px; }

/* ==========================================================================
   Receipts & vetting output
   ========================================================================== */
.receipt-pending { border: 1.5px dashed var(--ink-soft); padding: 12px; margin-bottom: 12px; background: #FBF7EE; }
.receipt-pending .fname { font-family: var(--font-mono); font-size: 12px; margin-bottom: 10px; }
.vet-flag, .vet-caution, .vet-ok { font-family: var(--font-mono); font-size: 12px; margin: 3px 0; padding-left: 14px; text-indent: -14px; }
.vet-flag { color: var(--bad); }
.vet-caution { color: var(--warn); }
.vet-ok { color: var(--ok); }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img {
  width: 92px; height: 92px; object-fit: cover;
  border: 1.5px solid var(--ink); background: #fff; padding: 3px;
  box-shadow: 2px 2px 0 rgba(232,176,75,.4);
}

/* ==========================================================================
   Modal — pulled work order
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(25, 22, 16, .5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 42px 16px; overflow-y: auto; z-index: 50;
}
.modal {
  background: var(--paper); border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(232,176,75,.35);
  padding: 24px 26px; width: 100%; max-width: 740px;
}
.modal h2 {
  margin: -24px -26px 18px; padding: 14px 26px 12px;
  border-bottom: 2px solid var(--ink); background: var(--paper-deep);
  font-family: var(--font-display); font-weight: 800; font-size: 26px;
  text-transform: uppercase;
}
.modal .card { background: #FBF7EE; }

/* ==========================================================================
   Empty states
   ========================================================================== */
.empty { text-align: center; color: var(--ink-soft); padding: 42px 16px; }
.empty .big {
  font-family: var(--font-display); font-weight: 800; font-size: 54px;
  color: var(--orange); letter-spacing: .02em; margin-bottom: 6px;
}
.empty h2 { font-family: var(--font-display); text-transform: uppercase; font-size: 30px; color: var(--ink); margin: 0 0 8px; }

/* ==========================================================================
   Checkbox grid
   ========================================================================== */
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 18px; }
.check-grid label {
  display: flex; align-items: center; gap: 8px;
  font: 400 13.5px var(--font-body); text-transform: none; letter-spacing: 0;
  color: var(--ink); margin: 0;
}
.check-grid input { width: auto; accent-color: var(--orange); }

/* ==========================================================================
   Report — the printable record
   ========================================================================== */
.report {
  background: #FBF7EE; color: #171512;
  border: 2px solid var(--ink); box-shadow: 8px 8px 0 rgba(232,176,75,.35);
  padding: 36px 40px; position: relative;
}
.report h1 { font-family: var(--font-display); font-weight: 800; font-size: 27px; margin: 0; text-transform: uppercase; }
.report h2 {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  margin: 26px 0 8px; border-bottom: 2px solid #171512; padding-bottom: 4px;
}
.report .rpt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; border-bottom: 3px solid var(--orange); padding-bottom: 14px; }
.report .muted { color: #6a6250; font-size: 12.5px; }
.report .rpt-head .mono, .report .muted { font-family: var(--font-mono); font-size: 11.5px; }
.report table { font-size: 12.5px; }
.report th, .report td { border-bottom: 1px solid #d8d2c0; color: #171512; padding: 6px 8px; }
.report th { color: #5c5442; border-bottom: 1.5px solid #171512; }
.report .rpt-stats { display: flex; gap: 30px; margin: 16px 0 4px; flex-wrap: wrap; }
.report .rpt-stats div { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #5c5442; }
.report .rpt-stats b { font-family: var(--font-display); font-size: 26px; display: block; color: #171512; letter-spacing: .01em; }
.report .integrity { color: var(--bad); font-size: 13px; }
.report .disclaimer { font-size: 10.5px; color: #6a6250; margin-top: 22px; border-top: 1px solid #d8d2c0; padding-top: 10px; line-height: 1.6; }
.report .mi-flag { color: var(--bad); font-weight: 700; }

@media print {
  body { background: #fff; }
  body::before { display: none; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  .main { max-width: none; padding: 0; }
  .report { border: none; box-shadow: none; padding: 0; }
  .report tr { break-inside: avoid; }
}

/* ==========================================================================
   Mobile — companion layout
   ========================================================================== */
@media (max-width: 840px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center;
    border-right: none; border-bottom: 2px solid var(--ink); padding: 12px 8px;
  }
  .brand { border-bottom: none; padding: 0 10px 6px; margin: 0; width: 100%; }
  .brand-name { font-size: 15px; }
  .brand-crest svg { width: 64px; height: 30px; }
  .nav-link { padding: 6px 9px; font-size: 12.5px; border-left: none; border-bottom: 3px solid transparent; }
  .nav-link.active { border-bottom-color: var(--orange); }
  .side-head { display: none; }
  .vehicle-btn { width: auto; margin: 3px 4px; }
  .vehicle-btn small { display: none; }
  .sidebar > .btn { margin: 3px 4px 0; }
  .main { padding: 18px 14px 60px; }
  .topbar h1 { font-size: 30px; }
  .grid2, .grid3, .check-grid { grid-template-columns: 1fr; }
  .frow.part-row { grid-template-columns: 1fr 1fr; }
  .frow.torque-row { grid-template-columns: 1fr 1fr 30px; }
  .frow.plan-part-row { grid-template-columns: 1fr 1fr; }
}
