:root {
  color-scheme: light;
  --teal: #0f5f63;
  --teal-deep: #073f43;
  --orange: #ff8a00;
  --cream: #f6f8f8;
  --paper: #f6f8f8;
  --ink: #173033;
  --muted: #667477;
  --line: #d9ded9;
  --surface: #ffffff;
  --soft: #edf5f2;
  --danger: #a63f35;
  --shadow: 0 14px 40px rgba(15, 95, 99, 0.12);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); }
body, button, input, select, textarea { font: inherit; }
button, input, select, textarea { border-radius: 8px; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: var(--teal); }
.loading { min-height: 100vh; display: grid; place-items: center; font-weight: 800; }
.app-top { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: minmax(200px, 1fr) auto minmax(160px, 1fr); gap: 14px; align-items: center; padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; color: inherit; text-decoration: none; }
.brand img { width: 72px; height: 72px; object-fit: contain; background: #fff; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand strong { font-size: 1.05rem; }
.brand small { margin-top: 4px; color: var(--muted); font-weight: 800; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.tabs a { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 13px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 800; }
.tabs a.active { background: var(--teal); color: #fff; }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.layout { width: min(1220px, 100%); margin: 0 auto; padding: 16px 16px 40px; }
.demo-banner, .notice { margin: 0; padding: 10px 16px; background: #fff1d9; color: #553100; font-weight: 800; text-align: center; }
.trip-ribbon { display: flex; justify-content: space-between; gap: 18px; align-items: end; margin-bottom: 20px; padding: 12px 0 20px; border-bottom: 1px solid var(--line); }
.trip-ribbon h1 { margin: 0 0 6px; font-size: 1.7rem; line-height: 1.2; letter-spacing: 0; overflow-wrap: anywhere; }
.trip-ribbon p { max-width: 620px; margin: 0; color: var(--muted); }
.eyebrow { display: block; margin: 0 0 7px; color: var(--teal); font-size: .76rem; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; width: min(450px, 100%); flex-shrink: 0; }
label span { display: block; margin-bottom: 6px; font-size: .84rem; font-weight: 900; }
input, select, textarea { width: 100%; min-height: 46px; padding: 9px 11px; border: 1px solid var(--line); background: #fbfdf9; color: var(--ink); }
textarea { min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(255, 138, 0, .42); outline-offset: 2px; }
.primary, .secondary, .quiet, .small, .icon { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border-radius: 8px; font-weight: 900; white-space: nowrap; }
.primary { background: var(--teal); color: #fff; }
.secondary { border: 1px solid var(--teal); background: #fff; color: var(--teal-deep); }
.quiet { background: var(--soft); color: var(--teal-deep); }
.small { min-height: 44px; padding: 0 10px; font-size: .9rem; }
.icon { width: 44px; padding: 0; background: var(--teal-deep); color: #fff; font-size: 1.1rem; }
.danger { color: #fff; background: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.subcards, .grid-two { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.wide-panel { grid-column: 1 / -1; }
.metric { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-height: 130px; padding: 15px; }
.metric span { display: block; color: var(--muted); font-weight: 800; }
.metric strong { display: block; margin: 10px 0; font-size: 1.65rem; line-height: 1.15; letter-spacing: 0; overflow-wrap: anywhere; }
.metric small, .note, .empty, .entry-row small, .trip-card small, .stops small { color: var(--muted); line-height: 1.4; }
.panel { min-width: 0; padding: 20px 0; border-top: 1px solid var(--line); }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 1.25rem; }
.panel-head span { color: var(--muted); font-size: .9rem; }
.panel-head div { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chart-list { display: grid; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 90px minmax(110px, 1fr) 110px; gap: 10px; align-items: center; }
.bar-row div { height: 15px; border-radius: 8px; background: var(--soft); overflow: hidden; }
.bar-row i { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.bar-row.spend i { background: var(--orange); }
.bar-row span, .bar-row small { color: var(--muted); font-size: .84rem; }
.bar-row small { grid-column: 2 / 4; margin-top: -8px; }
.compare { display: grid; gap: 0; }
.compare div, .stops article { padding: 12px 0; border-bottom: 1px solid var(--line); }
.compare span, .compare small, .stops span, .stops small { display: block; }
.compare strong, .stops b { display: block; margin: 6px 0; font-size: 1.1rem; }
.stops { display: grid; gap: 10px; }
.mini-list { display: grid; gap: 10px; }
.mini-list div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.mini-list strong, .mini-list span { display: block; }
.mini-list span { color: var(--muted); font-size: .9rem; margin-top: 4px; }
details { margin-top: 14px; }
summary { cursor: pointer; font-weight: 900; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .92rem; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
.entries, .trip-list { display: grid; gap: 10px; }
.entry-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 44px 44px; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.entry-row strong, .entry-row span, .entry-row small { display: block; }
.entry-row > div:nth-child(2) { text-align: right; }
.trip-card { display: block; width: 100%; padding: 13px; border: 1px solid var(--line); background: #fff; color: inherit; text-align: left; }
.trip-card.selected { border-color: var(--teal); box-shadow: inset 4px 0 0 var(--teal); }
.trip-card strong, .trip-card span, .trip-card small { display: block; }
.trip-card em { float: right; padding: 4px 7px; border-radius: 8px; background: var(--soft); color: var(--teal); font-style: normal; font-size: .78rem; }
dialog { width: min(760px, calc(100% - 24px)); max-height: min(860px, calc(100vh - 24px)); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 28px 80px rgba(7, 63, 67, .3); }
dialog::backdrop { background: rgba(7, 31, 33, .56); }
.sheet { display: grid; gap: 14px; padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.dialog-head h2 { margin: 0; font-size: 1.45rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.segmented label { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 900; text-align: center; }
.segmented input { width: 16px; min-height: 16px; accent-color: var(--teal); }
.advanced { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdf9; }
.slider-box { display: grid; gap: 10px; margin: 12px 0; }
.towing-control { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdf9; }
.towing-control input[type="range"] { padding: 0; min-height: 44px; accent-color: var(--teal); }
.tow-labels { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; color: var(--muted); font-size: .86rem; font-weight: 800; }
.tow-labels strong { color: var(--teal-deep); font-size: 1rem; text-align: center; }
.tow-labels span:last-child { text-align: right; }
.mix-strip { min-height: 34px; display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--muted); font-size: .78rem; font-weight: 900; }
.mix-strip span { display: grid; place-items: center; min-width: 0; margin: 0; color: #fff; overflow: hidden; white-space: nowrap; }
.mix-strip span:nth-child(1) { background: var(--teal); }
.mix-strip span:nth-child(2) { background: var(--orange); }
.mix-strip span:nth-child(3) { background: #c67b39; }
.sticky-save { position: sticky; bottom: 0; width: 100%; }
.errors p { margin: 0 0 6px; padding: 8px 10px; border-radius: 8px; background: #ffe8e5; color: var(--danger); font-weight: 800; }
.actions-stack { display: grid; gap: 10px; }
.file-button { display: block; padding: 12px; border: 1px dashed var(--teal); border-radius: 8px; background: #fbfdf9; font-weight: 900; text-align: center; }
.file-button input { margin-top: 8px; }
.discover { font-weight: 900; }
svg.lucide { width: 20px; height: 20px; flex-shrink: 0; }
.icon.quiet { background: var(--soft); color: var(--teal); }
[hidden] { display: none !important; }
.trip-totals { display: flex; flex-wrap: wrap; gap: 12px 24px; padding: 12px 0 20px; color: var(--muted); font-size: .9rem; }
.quality-banner { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 12px; margin-bottom: 12px; text-align: left; color: #714609; background: #fff0d9; }
.quality-banner span { flex: 1; }
.table-scroll { overflow-x: auto; }
.table-scroll table { white-space: nowrap; }
.receipt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.receipt-button { position: relative; cursor: pointer; white-space: normal; text-align: center; }
.receipt-button span { margin: 0; font-size: .9rem; }
.receipt-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.receipt-button:focus-within { outline: 3px solid var(--orange); outline-offset: 2px; }
.receipt-photo { display: block; width: auto; max-width: 100%; max-height: 260px; object-fit: contain; margin: 12px auto; }
.receipt-date, #scanStatus { font-size: .9rem; line-height: 1.4; }
.check-row { display: flex; gap: 10px; align-items: center; padding: 12px; background: var(--soft); }
.check-row input { width: 22px; min-height: 22px; accent-color: var(--teal); flex-shrink: 0; }
.check-row span { margin: 0; }
.previous-odo { margin: 0; color: var(--muted); font-size: .9rem; }
.form-grid > label { min-width: 0; }
.form-grid input { min-width: 0; }
.advanced .form-grid { margin-top: 14px; }
.advanced > label { display: block; margin-top: 14px; }
progress { width: 100%; accent-color: var(--teal); }
#scanStatus:empty, #receiptPreview:empty, #entryErrors:empty { display: none; }
.log-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.log-filter { display: flex; gap: 8px; min-height: 46px; align-items: center; }
.log-filter input { width: 20px; min-height: 20px; accent-color: var(--teal); }
.log-filter span { margin: 0; }
@media (max-width: 900px) {
  .app-top { grid-template-columns: 1fr auto; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .tabs a { flex: 1; justify-content: center; }
  .trip-ribbon { align-items: stretch; flex-direction: column; }
  .filters, .cards, .subcards, .grid-two { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .layout { padding: 12px 14px calc(90px + env(safe-area-inset-bottom)); }
  .app-top { padding: 6px 12px; gap: 8px; }
  .brand img { width: 54px; height: 54px; }
  .brand strong { font-size: .9rem; }
  .brand small { font-size: .7rem; }
  .brand { gap: 6px; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; border-radius: 0; border-width: 1px 0 0; padding: 6px 6px max(6px, env(safe-area-inset-bottom)); background: #fff; }
  .tabs a { flex-direction: column; gap: 3px; min-height: 52px; padding: 4px; font-size: .76rem; }
  .tabs a.active { background: var(--soft); color: var(--teal); }
  .top-actions { display: flex; gap: 6px; }
  .top-actions .primary { padding: 0 10px; font-size: .85rem; }
  .trip-ribbon { padding: 8px 0 16px; gap: 14px; }
  .trip-ribbon h1 { font-size: 1.4rem; }
  .panel { padding: 18px 0; }
  .metric { padding: 12px; }
  .subcards, .grid-two, .form-grid, .segmented, .compare { grid-template-columns: 1fr; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .log-toolbar { grid-template-columns: 1fr; gap: 4px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 128px; }
  .metric strong { font-size: 1.25rem; }
  .bar-row { grid-template-columns: 76px minmax(0, 1fr) auto; gap: 8px; }
  .bar-row strong { font-size: .9rem; }
  .bar-row small { grid-column: 1 / -1; margin-top: -4px; }
  .entry-row { grid-template-columns: minmax(0, 1fr) 44px 44px; gap: 8px; }
  .entry-row > div:first-child { grid-column: 1 / -1; }
  .entry-row > div:nth-child(2) { text-align: left; }
  dialog { width: 100%; max-width: 100%; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .sheet { min-height: 100%; padding: 16px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .sticky-save { min-height: 50px; bottom: 0; box-shadow: 0 -8px 16px #fff; }
}
