/* DirectHaul
   Palette borrowed from interstate guide signage and weigh-station paperwork:
   reflective guide green, lane-paint yellow reserved for the one action that
   matters on each screen, asphalt for text. Built thumb-first: nothing
   interactive is under 48px, and the rate-per-mile is the largest thing on a
   load because that is the number a driver actually decides on. */

:root {
  --guide:    #0B5D3B;
  --guide-lo: #094C30;
  --asphalt:  #26272B;
  --slate:    #5C6068;
  --concrete: #D6D8D3;
  --surface:  #EDEEEC;
  --card:     #FFFFFF;
  --paint:    #E8A317;
  --flag:     #A32218;
  --ok:       #0B5D3B;

  --gap: 1rem;
  --radius-card: 3px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

/* Status bar runs translucent over the masthead (see apple-mobile-web-app-status-bar-style
   in <head>), and Android draws edge-to-edge in standalone mode - both need the real inset,
   not a guessed pixel value, or content sits under the notch/status bar. overscroll-behavior
   kills the rubber-band-into-browser-chrome bounce that is the single biggest "this is a
   website" tell when the app is running standalone. */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--asphalt);
  font-family: ui-sans-serif, system-ui, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.wrap { max-width: 44rem; margin: 0 auto; padding: var(--gap) var(--gap) calc(6rem + env(safe-area-inset-bottom)); }

/* ---- masthead ---- */
.masthead {
  background: var(--guide);
  color: #fff;
  padding: 1.1rem var(--gap);
  padding-top: calc(1.1rem + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: .6rem;
}
.masthead h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.masthead h1 a { text-decoration: none; }
.masthead .who { font-size: .85rem; opacity: .85; margin-left: auto; white-space: nowrap; }
.masthead a { color: #fff; }

/* Tap targets read as controls, not as text: no selection highlight, no iOS
   press-and-hold callout, no 300ms tap delay, and a quick press-down so a
   finger gets the same instant feedback a native button gives it. */
button, .task, .tab, a.sidebar-link {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
button, .task, .tab, .sidebar-link {
  transition: transform .1s ease, opacity .1s ease, border-left-color .15s ease, background-color .15s ease;
}
button:active, .task:active, .tab:active, .sidebar-link:active {
  transform: scale(.97);
}
button:disabled:active, .task:disabled:active { transform: none; }

/* ---- landing hero ---- */
/* The artwork is the photograph only. The headline is real text below it, so it
   stays legible on a phone and says what the app actually does. Capped on tall
   viewports; the crop holds the bottom-left logo and the driver. */
.hero { display: block; background: var(--asphalt); }
.hero img {
  display: block; width: 100%; height: auto;
  max-height: 58vh; object-fit: cover; object-position: left bottom;
}
.hero-copy { background: var(--guide); color: #fff; padding: 1rem var(--gap) 1.1rem; }
.hero-line {
  margin: 0; max-width: none;
  font-size: 1.35rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em;
}
.hero-sub { margin: .45rem 0 0; max-width: 46ch; font-size: .92rem; opacity: .9; }

h2 { font-size: 1.05rem; font-weight: 700; margin: 2rem 0 .75rem; letter-spacing: -0.01em; }
h2:first-of-type { margin-top: 1rem; }
p { max-width: 60ch; }
.muted { color: var(--slate); font-size: .9rem; }

/* ---- the task picker: the carrier's whole home screen ---- */
.tasks { display: grid; gap: .6rem; margin: 1rem 0 2rem; }
.task {
  display: block;
  background: var(--card);
  border: 1px solid var(--concrete);
  border-left: 5px solid var(--guide);
  border-radius: var(--radius-card);
  padding: 1rem;
  min-height: 56px;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.task strong { display: block; font-size: 1.02rem; }
.task span { color: var(--slate); font-size: .88rem; }
.task:hover { border-left-color: var(--paint); }
.task:disabled { opacity: .5; cursor: not-allowed; border-left-color: var(--concrete); }

/* ---- load card: origin, a rule carrying the mileage, destination ---- */
.load {
  background: var(--card);
  border: 1px solid var(--concrete);
  border-radius: var(--radius-card);
  padding: .9rem 1rem;
  margin-bottom: .6rem;
}
.route { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.route .place { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.route .rule {
  flex: 1; height: 0; border-top: 2px solid var(--concrete); position: relative;
}
.route .rule::after {
  content: attr(data-miles);
  position: absolute; top: -.72em; left: 50%; transform: translateX(-50%);
  background: var(--card); padding: 0 .45rem;
  font-size: .72rem; color: var(--slate); white-space: nowrap;
}
.rate { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.rate small { font-size: .78rem; font-weight: 400; color: var(--slate); letter-spacing: 0; }
.load .meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .85rem; color: var(--slate); margin-top: .4rem; }
.load .bottom { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .5rem; }

/* ---- window: a raised panel for a self-contained block of information.
   Reserved for standalone summary panels (like the BASIC-score chart below),
   not a blanket replacement for the flat .load card used in scrolling lists. */
.window {
  background: var(--card);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  margin: 1rem 0;
  border: 1px solid rgba(11,93,59,.08);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 10px 24px -14px rgba(15,30,22,.35), 0 2px 6px rgba(15,30,22,.1);
}
.window h2, .window h3 { margin-top: 0; }

/* ---- BASIC score columns: one bar per CSA category, 0-100th percentile ---- */
.basic-chart { display: flex; gap: .5rem; align-items: flex-end; margin: 1rem 0 .3rem; padding: 0 .1rem; }
.basic-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.basic-track {
  width: 100%; max-width: 36px; height: 100px;
  background: var(--surface); border-radius: 6px 6px 2px 2px;
  display: flex; align-items: flex-end; overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.14);
}
.basic-bar { width: 100%; border-radius: 6px 6px 0 0; min-height: 4px; }
.basic-bar.ok { background: linear-gradient(180deg, #3FA36B, var(--guide-lo)); }
.basic-bar.flag { background: linear-gradient(180deg, #E2604C, var(--flag)); }
.basic-bar.na { background: var(--concrete); }
.basic-val { font-size: .78rem; font-weight: 700; }
.basic-val.flag { color: var(--flag); }
.basic-val.na { color: var(--slate); font-weight: 400; }
.basic-label { font-size: .65rem; color: var(--slate); text-align: center; line-height: 1.15; }

.tag {
  display: inline-block; border-radius: var(--radius-pill);
  padding: .12rem .6rem; font-size: .75rem; border: 1px solid var(--concrete);
}
.tag.match { background: #E7F0EA; border-color: var(--guide); color: var(--guide-lo); }
.tag.miss  { background: #FBF0DA; border-color: var(--paint); color: #7A5606; }

/* ---- compliance panel ---- */
.blockers {
  background: #FBF0DA; border: 1px solid var(--paint);
  border-radius: var(--radius-card); padding: .9rem 1rem; margin: 1rem 0;
}
.blockers ul { margin: .5rem 0 0; padding-left: 1.1rem; }
.blockers li { margin-bottom: .3rem; }
.cleared {
  background: #E7F0EA; border: 1px solid var(--guide);
  border-radius: var(--radius-card); padding: .75rem 1rem; margin: 1rem 0;
}

/* ---- forms ---- */
label { display: block; margin-bottom: .8rem; font-size: .9rem; color: var(--slate); }
input, select, textarea {
  display: block; width: 100%; margin-top: .25rem;
  padding: .7rem .65rem; min-height: 48px;
  font: inherit; color: var(--asphalt);
  background: var(--card);
  border: 1px solid var(--concrete); border-radius: var(--radius-card);
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, .task:focus-visible {
  outline: 3px solid var(--paint); outline-offset: 2px;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

/* A checkbox paired with inline text, e.g. terms-of-service agreement -
   overrides the generic input rule's full-width block layout. */
.check-row {
  display: flex; align-items: flex-start; gap: .6rem;
}
.check-row input[type="checkbox"] {
  display: block; width: 1.4rem; height: 1.4rem; min-height: 0;
  margin-top: .1rem; flex-shrink: 0;
}

button {
  font: inherit; font-weight: 600; cursor: pointer;
  min-height: 48px; padding: .7rem 1.1rem;
  border-radius: var(--radius-card); border: 1px solid var(--guide);
  background: var(--guide); color: #fff;
}
button.primary { background: var(--paint); border-color: #C7860B; color: #26272B; }
button.quiet { background: transparent; color: var(--guide); }
button.small { min-height: 40px; padding: .4rem .8rem; font-size: .88rem; }

/* Filter tabs. Unselected reads as a choice, not as an action - lane-paint yellow
   stays reserved for the one real action on a screen. aria-current carries the
   same state for screen readers, which a colour swap alone did not. */
.tab { background: var(--card); color: var(--guide); border: 1px solid var(--concrete); }
.tab[aria-current="true"] { background: var(--guide); border-color: var(--guide); color: #fff; }
.tab.small { min-height: 44px; }

/* Back at the top of a section as well as the bottom: the carrier profile is a long
   scroll, and a driver should not have to reach the end of it to get out. */
.back-top { margin: 0 0 .4rem; padding-left: 0; }

.notice { padding: .7rem .9rem; border-radius: var(--radius-card); margin: .8rem 0; font-size: .92rem;
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  animation: pop-in .18s cubic-bezier(.22,1,.36,1); }
.notice.error { background: #F6E2E0; border: 1px solid var(--flag); color: #6E1610; }
.notice.info  { background: #E7F0EA; border: 1px solid var(--guide); }
.notice.warn  { background: #FBF0DA; border: 1px solid var(--paint); color: #7A5606; }

.empty {
  border: 2px dashed var(--concrete); border-radius: var(--radius-card);
  padding: 1.5rem 1rem; text-align: center; color: var(--slate);
}

.privacy {
  border-top: 1px solid var(--concrete); margin-top: 2rem; padding-top: .8rem;
  font-size: .82rem; color: var(--slate);
}

.hidden { display: none; }

/* ---- sidebar menu ---- */
.menu-btn {
  background: transparent; border: none; color: #fff;
  font-size: 1.3rem; line-height: 1; padding: .3rem;
  min-height: 48px; min-width: 48px;
}
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20;
  opacity: 1;
  transition: opacity .24s ease;
}
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 30;
  width: min(78vw, 320px);
  background: var(--card);
  box-shadow: 2px 0 12px rgba(0,0,0,.25);
  padding: 1rem;
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: .2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(0);
  visibility: visible;
  transition: transform .24s cubic-bezier(.32,.72,0,1);
}
/* .sidebar's own display:flex ties with .hidden's display:none on
   specificity; this compound selector outranks both, so it drives the
   closed state as an off-canvas slide instead of an instant cut. */
.sidebar.hidden {
  display: flex;
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform .24s cubic-bezier(.32,.72,0,1), visibility 0s linear .24s;
}
.sidebar-backdrop.hidden {
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .24s ease, visibility 0s linear .24s;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .6rem; padding-bottom: .6rem; border-bottom: 1px solid var(--concrete);
}
.sidebar-head strong { font-size: 1.05rem; }
.sidebar-link {
  display: block; width: 100%; text-align: left;
  background: transparent; color: var(--asphalt); border: none;
  border-radius: var(--radius-card);
  padding: .8rem .6rem; min-height: 48px; font-weight: 600;
  text-decoration: none;
}
.sidebar-link:hover { background: var(--surface); }

/* ---- account settings modal ---- */
dialog#account-modal {
  border: none; border-radius: var(--radius-card);
  padding: 1.2rem; width: min(92vw, 26rem);
  color: var(--asphalt); background: var(--card);
  opacity: 1; transform: scale(1) translateY(0);
  transition: opacity .18s ease, transform .18s cubic-bezier(.22,1,.36,1), overlay .18s ease allow-discrete,
    display .18s ease allow-discrete;
}
dialog#account-modal::backdrop {
  background: rgba(0,0,0,.5);
  transition: background-color .18s ease, overlay .18s ease allow-discrete, display .18s ease allow-discrete;
}
dialog#account-modal h2:first-of-type { margin-top: 0; }
/* Progressive enhancement: browsers without @starting-style just show the
   dialog instantly, same as before. Where it's supported, this is the "from"
   state for the opening transition above. */
@starting-style {
  dialog#account-modal[open] { opacity: 0; transform: scale(.96) translateY(8px); }
  dialog#account-modal[open]::backdrop { background-color: rgb(0 0 0 / 0); }
}

/* ---- legal pages ---- */
.draft-banner {
  background: #FBF0DA; border: 1px solid var(--paint);
  border-radius: var(--radius-card); padding: .9rem 1rem; margin: 1rem 0;
  font-size: .88rem; color: #7A5606;
}
.legal-nav { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; font-size: .9rem; }
.legal h3 { font-size: .95rem; font-weight: 700; margin: 1.6rem 0 .5rem; }
.legal p, .legal li { color: var(--asphalt); max-width: 68ch; }
.legal ol, .legal ul { padding-left: 1.3rem; }
.legal li { margin-bottom: .4rem; }
.legal .placeholder { background: #FBF0DA; padding: 0 .2rem; }

/* ---- view transitions ----
   Section swaps in setupViews() (app.js) toggle display via .hidden - a
   display:none -> block transition restarts a CSS animation the same way
   opening the app fresh does, so this needs no JS coordination: every
   section that becomes visible, including on first load, plays this once. */
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
main > section:not(.hidden) { animation: view-in .22s cubic-bezier(.22,1,.36,1); }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
