:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1b2940;
  background: #f4f7fb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: #2367c6; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  background: #13213a; color: #dce6f6; width: 238px; flex-shrink: 0;
  padding: 28px 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: -.8px; margin: 3px 10px 32px; color: white; }
.brand span { color: #64b5ff; }
.brand small { display: block; font-size: 9px; letter-spacing: 3px; color: #9caec7; margin-left: 26px; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.menu-toggle { display: none; }
nav a { color: #adbed4; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
nav a:hover { background: #223653; color: white; text-decoration: none; }
.user { margin-top: auto; color: #b2c2d8; font-size: 12px; padding: 14px; }
.user a { color: #dce6f6; font-weight: 600; }
.main { width: 100%; min-width: 0; max-width: 1600px; margin: auto; padding: 38px 42px; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 26px; }
footer { color: #a2acb9; font-size: 12px; margin: 35px 0; }
footer a { color: #8796ab; }

/* Typography */
.eyebrow { font-size: 11px; letter-spacing: 2px; color: #4485d1; font-weight: 800; }
h1 { font-size: 32px; letter-spacing: -1px; margin: 8px 0; }
h2 { font-size: 18px; margin: 0 0 6px; }
h2.spaced { margin-top: 26px; }
p { color: #77869a; margin: 6px 0; font-size: 14px; }
.muted { color: #8b98aa; }
.small { font-size: 12px; }
.date { color: #8794a5; font-size: 13px; }
.orange { color: #d78321; }
.missing { background: #fff3dc; color: #8a5a0b; padding: 1px 5px; border-radius: 5px; }

/* Cards */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 24px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats article, .panel, .login-card {
  background: white; border: 1px solid #e7edf5; border-radius: 16px; box-shadow: 0 4px 22px #1e355008;
}
.stats article { padding: 23px; }
.stats span, .stats small { display: block; color: #8492a6; font-size: 12px; }
.stats strong { display: block; font-size: 28px; letter-spacing: -1px; margin: 9px 0; }
.panel { padding: 24px; margin-bottom: 24px; }
.narrow-panel { max-width: 720px; }
.error-panel { max-width: 720px; margin: 8vh auto; }
.section-head { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 18px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions input { max-width: 300px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th {
  text-align: left; color: #8b98aa; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  font-weight: 700; border-bottom: 1px solid #e9eef5; padding: 13px 10px; white-space: nowrap;
}
td { padding: 13px 10px; border-bottom: 1px solid #eef2f7; white-space: nowrap; vertical-align: top; }
td.wrap { white-space: normal; min-width: 180px; }
td small { display: block; color: #98a3b1; margin-top: 5px; }
tr.inactive td { opacity: .55; }

/* Forms */
button, input, select, textarea { font: inherit; }
input, select, textarea {
  background: white; border: 1px solid #dfe7f1; border-radius: 9px; padding: 10px 12px;
  max-width: 100%; color: #253b57;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid #a9d0ff; }
button, .button {
  display: inline-block; border: 1px solid #dfe7f1; border-radius: 9px; padding: 9px 15px; cursor: pointer;
  background: white; color: #344d6b; font-size: 14px; line-height: 1.3;
}
.button:hover { text-decoration: none; background: #f6f9fd; }
.primary { background: #2674d9; border-color: #2674d9; color: white; font-weight: 650; }
.primary:hover { background: #195fbd; }
.ghost { background: transparent; color: #b5c8e2; border-color: #4b5e79; margin-top: 12px; }
.link { border: 0; background: transparent; color: #2872d1; padding: 4px; }
.danger { color: #bd3f4e; }
.danger-button { background: #bd3f4e; border-color: #bd3f4e; }
.mini { padding: 5px 10px; }
.narrow { width: 110px; }
.copy-link { width: 220px; font-size: 11px; margin-top: 6px; display: block; }
.wide-input { width: 100%; }
.form-box { margin-top: 22px; border-top: 1px solid #e8edf5; padding-top: 18px; }
.form-box summary { font-weight: 700; cursor: pointer; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.form-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.form-grid label, .login-card label, .stack label, .filter-bar label {
  display: grid; gap: 7px; font-size: 12px; color: #69798d;
}
.stack { display: grid; gap: 16px; margin: 16px 0; }
.wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; }
.task-form, .upload { display: flex; gap: 9px; flex-wrap: wrap; margin: 20px 0; }
.task-form input, .task-form select { min-width: 125px; flex: 1; }
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.inline { display: inline; margin-left: 6px; }
.inline-form { display: flex; gap: 6px; }
.inline-form input { width: 150px; }
.driver-picker { border: 1px solid #e3e9f2; border-radius: 9px; padding: 8px 12px; display: grid; gap: 4px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 16px 0; }
.plan-card { border: 1px solid #e3e9f2; border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.plan-card.current { border-color: #3664a4; box-shadow: 0 0 0 2px #eaf2ff; }
.plan-card h3 { margin: 0; }
.plan-card .price { font-size: 22px; font-weight: 700; margin: 0; }
.plan-card .price small { font-size: 12px; font-weight: 400; color: #6b7a8f; }
.plan-card ul { margin: 0; padding-left: 18px; flex: 1; }
.plan-card form { margin: 8px 0 0; gap: 8px; }
.row-actions { display: flex; gap: 6px; }
.consent { display: flex !important; align-items: center; gap: 8px; font-size: 12px; color: #4d5f75; }
.consent input { width: auto; flex-shrink: 0; }
.export-links { margin-top: 14px; }
.work-time summary { cursor: pointer; color: #2872d1; font-size: 12px; margin-top: 6px; }
.compact-stack { gap: 8px; margin: 10px 0 0; min-width: 240px; }
.day-picker { border: 1px solid #e3e9f2; border-radius: 9px; padding: 6px 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.day-picker legend { font-size: 11px; color: #69798d; padding: 0 4px; }
.day-picker label { display: flex; align-items: center; gap: 3px; font-size: 12px; }
.day-picker input { width: auto; }
.time-range { display: flex; gap: 8px; }
.time-range label { display: grid; gap: 4px; font-size: 11px; color: #69798d; }
.file-label { display: grid; gap: 5px; font-size: 12px; color: #69798d; }
.confirm-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; align-items: start; }
.doc-preview img { width: 100%; border-radius: 12px; border: 1px solid #e2e8f0; margin-bottom: 12px; }
.doc-preview object { width: 100%; height: 520px; border-radius: 12px; border: 1px solid #e2e8f0; }
.source { font-size: 10px; font-weight: 700; color: #2d7a4b; background: #e3f5ea; padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.source.ai { color: #5b3fb3; background: #efe9ff; }
@media (max-width: 1100px) { .confirm-layout { grid-template-columns: 1fr; } }

/* Notices */
.notice { padding: 12px 16px; background: #e8f5ed; border: 1px solid #bde4cb; border-radius: 9px; margin-bottom: 14px; font-size: 14px; }
.notice.error { background: #fff0f0; border-color: #f4bebe; }
.edit-banner { background: #eaf2ff; border-color: #c4dafc; }

/* Pills and lists */
.pill { background: #eaf2ff; color: #3664a4; padding: 5px 10px; border-radius: 100px; font-size: 11px; white-space: nowrap; }
.pill.overdue { background: #ffe9e9; color: #b82f3c; }
.pill.soon { background: #fff3dc; color: #aa6d0d; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid #eef2f7; font-size: 13px; }
.list-item small { display: block; color: #8b99a9; margin-top: 6px; }
.done { text-decoration: line-through; color: #9aa8b8; }
.plain-list { padding-left: 18px; color: #4d5f75; font-size: 14px; line-height: 1.55; }

/* Login */
.login-card { max-width: 440px; margin: 10vh auto; padding: 36px; }
.login-card form { display: grid; gap: 20px; margin: 26px 0 14px; }
.login-card input { width: 100%; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 18px; }
.photo-card { border: 1px solid #e2e8f0; border-radius: 14px; overflow: hidden; background: white; }
.photo-card img { width: 100%; height: 180px; object-fit: cover; display: block; }
.photo-meta { padding: 14px; }
.photo-meta details { margin-top: 10px; }
.ocr-json { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; max-height: 200px; overflow: auto; background: #f1f5f9; padding: 10px; border-radius: 8px; }
.review-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.review-form textarea { width: 100%; }
.review-form button { font-size: 12px; padding: 7px; }

/* Map */
.map { height: 390px; border-radius: 14px; background: #e7eef3; margin: 12px 0 6px; }

/* Reports */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.bar { background: #eef2f7; border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { background: #2674d9; height: 100%; }

/* Privacy notice */
.prose p, .prose li { color: #3d4f66; line-height: 1.6; }
.prose h2 { margin-top: 26px; }
.prose-table td { white-space: normal; min-width: 140px; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .form-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 25px; }
}
/* Map with route panel */
.map-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; margin: 12px 0 6px; }
.map-layout .map { margin: 0; height: 480px; }
.route-panel { border: 1px solid #e7edf5; border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.route-panel h3 { font-size: 14px; margin: 0; }
.route-list { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.route-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 4px; border-radius: 8px; }
.route-item:hover { background: #f4f7fb; }
.route-item input { width: auto; }
.route-item small { display: block; color: #8b98aa; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; background: #ccc; }
.route-actions { display: flex; gap: 6px; }
.hours-slider { display: grid; gap: 6px; font-size: 13px; color: #4d5f75; }
.hours-slider input { width: 100%; padding: 0; }
.vehicle-marker span { display: block; width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 5px #0006; }
.plate-label { font-weight: 700; font-size: 11px; padding: 1px 6px; }
.map-popup { font-size: 13px; line-height: 1.5; }
.map-popup strong { font-size: 15px; }
@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-layout .map { height: 380px; }
}

/* Login: Google button */
.google-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 22px; font-weight: 600; }
.divider { display: flex; align-items: center; gap: 10px; color: #98a3b1; font-size: 12px; margin: 18px 0 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid #e3e9f2; }

/* ------------------------------------------------------------------------
   Phones and small tablets (iOS Safari, Android Chrome)
   ------------------------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: rgba(38, 116, 217, .15); }

@media (max-width: 760px) {
  .shell { display: block; }

  /* Sticky top bar with a slide-down menu instead of a sideways-scrolling nav. */
  .sidebar {
    position: sticky; top: 0; z-index: 1000; width: 100%; height: auto; overflow: visible;
    padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 10px calc(14px + env(safe-area-inset-left));
    box-shadow: 0 2px 12px #0003;
  }
  .brand { margin: 0; font-size: 20px; }
  .brand small { display: none; }
  .menu-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 44px; height: 44px; padding: 10px; background: transparent; border: 1px solid #4b5e79; border-radius: 10px;
  }
  .menu-toggle span { display: block; height: 2px; background: #dce6f6; border-radius: 2px; transition: transform .2s, opacity .2s; }
  .menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  /* Without JavaScript the menu simply stays open. */
  .js nav { display: none; }
  .js nav.open { display: flex; }
  nav {
    margin-top: 10px; max-height: calc(100dvh - 80px); overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
  }
  nav a { padding: 13px 14px; font-size: 16px; }
  .user { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; padding: 12px 14px; border-top: 1px solid #2a3e5c; font-size: 14px; }
  .ghost { margin-top: 0; }

  .main {
    padding: 16px calc(14px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  }
  header { flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 18px; }
  h1 { font-size: 25px; letter-spacing: -.5px; }
  h2 { font-size: 17px; }
  .date { display: none; }
  .panel { padding: 16px; border-radius: 14px; margin-bottom: 16px; }
  .stats, .stats.three { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stats article { padding: 14px; }
  .stats strong { font-size: 22px; margin: 6px 0; overflow-wrap: anywhere; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .section-head { display: block; }
  .head-actions { margin-top: 12px; flex-wrap: wrap; }
  .head-actions input { width: 100%; max-width: none; flex: 1 1 100%; }

  /* 16px inputs: iOS Safari would otherwise zoom in on every focused field. */
  input, select, textarea { font-size: 16px; min-height: 44px; width: 100%; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; }
  input[type="range"] { min-height: 32px; }
  button, .button { min-height: 44px; padding: 11px 16px; font-size: 15px; }
  .mini, .link { min-height: 36px; }
  .form-grid, .form-grid.compact { grid-template-columns: 1fr; gap: 12px; }
  .task-form, .upload, .filter-bar { flex-direction: column; align-items: stretch; }
  .task-form > *, .upload > *, .filter-bar > * { width: 100%; }
  .actions { flex-wrap: wrap; }
  .actions > button { flex: 1; }
  .inline { display: block; margin: 8px 0 0; }
  .inline-form { flex-direction: column; }
  .inline-form input { width: 100%; }
  .review-form button { flex: 1 1 auto; min-height: 40px; }
  .consent { align-items: flex-start; font-size: 14px; }
  .file-label { width: 100%; }

  /* Tables become cards: app.js copies each column header into data-label. */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { border: 1px solid #e7edf5; border-radius: 12px; padding: 4px 12px; margin-bottom: 10px; background: #fff; }
  table.cards td { white-space: normal; border-bottom: 1px solid #f0f3f8; padding: 9px 0; display: grid; grid-template-columns: 38% 1fr; gap: 10px; align-items: start; }
  table.cards td:last-child { border-bottom: 0; }
  table.cards td::before { content: attr(data-label); color: #8b98aa; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
  table.cards td[data-label=""] { grid-template-columns: 1fr; }
  table.cards td[data-label=""]::before { display: none; }
  table.cards td[colspan] { grid-template-columns: 1fr; }
  table.cards td[colspan]::before { display: none; }
  table.cards td small { margin-top: 2px; }
  table.cards .copy-link { width: 100%; }
  /* Everything after the label stays in the value column (buttons, forms, small notes). */
  table.cards td:not([data-label=""]):not([colspan]) > * { grid-column: 2; justify-self: start; max-width: 100%; }
  table.cards td > form, table.cards td > details { width: 100%; }
  .copy-link { font-size: 16px; }
  .stats article:only-child { grid-column: 1 / -1; }
  .table-wrap { overflow: visible; }

  .list-item { flex-wrap: wrap; }
  .photo-grid { grid-template-columns: 1fr; }
  .photo-card img { height: 220px; }
  .login-card { margin: 4vh auto; padding: 24px 18px; border-radius: 16px; }
  .narrow-panel, .error-panel { max-width: none; }

  /* Map: route panel above a taller map. */
  .map-layout { grid-template-columns: 1fr; gap: 12px; }
  .map-layout .map { height: 62vh; min-height: 320px; }
  .route-list { max-height: 180px; }
  .confirm-layout { grid-template-columns: 1fr; }
  .day-picker label { font-size: 14px; }
  .time-range { flex-direction: column; }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .work-time summary { font-size: 14px; padding: 6px 0; }
  footer { margin: 24px 0 8px; }
}

/* Standalone (added to home screen): leave room for the iOS status bar. */
@media (display-mode: standalone) {
  .sidebar { padding-top: calc(12px + env(safe-area-inset-top)); }
}

/* Test-version banner (only while the legal statement is enabled) */
.test-version { background: #fff7e6; border-color: #f3d29a; color: #6b4a0e; font-size: 14px; }

/* Place search (origin/destination) */
.place-search { position: relative; display: flex; gap: 6px; }
.place-search input { flex: 1; min-width: 0; }
.place-button { flex-shrink: 0; }
.place-results { position: absolute; top: 100%; left: 0; right: 0; z-index: 50; margin: 4px 0 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid #dfe7f1; border-radius: 10px; box-shadow: 0 8px 24px #1e355026; max-height: 280px; overflow-y: auto; }
.place-results li { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: #253b57; }
.place-results li:hover, .place-results li:focus { background: #eef4fd; outline: none; }
.place-results li small { display: block; color: #8b98aa; font-size: 11px; margin-top: 2px; }
.place-results .place-message { cursor: default; color: #8b98aa; }

/* Photo capture */
.big-file { border: 2px dashed #b9cde6; border-radius: 14px; padding: 16px; text-align: center; font-size: 15px; color: #2b4b72; background: #f7faff; }
.type-picker { border: 1px solid #e3e9f2; border-radius: 10px; padding: 8px 12px; display: grid; gap: 6px; }
.type-picker legend { font-size: 12px; color: #69798d; padding: 0 4px; }

/* Vignettes */
.buy-row { display: flex; flex-wrap: wrap; gap: 8px; }
