/* Wrapped console. Style: framed sheet (tasteskill app sheet, seed 294970805).
   The frame takes one low-chroma step of Wrapped's blush; the work sits on a white sheet.
   Burgundy, the brand's ink, is the one data hue: today's bars, the selected tab, focus.
   Grid: sheet padding 24px; one 16px gutter; the Today grid is 6 columns (4 + 2, then 4 + 2). */

:root {
  --frame: #f7f1f2;
  --surface: #ffffff;
  --raised: #faf6f7;
  --active: #ece2e4;
  --border: #ebe3e5;
  --rule: #f3eded;
  --control: #d3c9cc;
  --text: #1e1416;
  --muted: #6a5a5e;
  --faint: #6e6366;
  --accent: #8b2a3a;
  --accent-pale: #f6e4e7;
  --primary: #2a1a1e;
  --primary-ink: #ffffff;
  --positive: #247b50; --negative: #c4242a;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e;
  --pill-neutral-bg: #efeaeb; --pill-neutral-ink: #3d3033;
  --pill-new-bg: #f6e4e7; --pill-new-ink: #6e1f2c;
  --chart-1: var(--accent); --chart-2: #c98d98; --chart-3: #a67c1f; --chart-muted: #ddd3d5; --chart-mark: var(--text);
  --chart-span: 0.06; --chart-track: #e9e1e3;
  --grid: #efe8ea; --axis-ink: var(--muted); --ink: var(--text);

  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-title: 24px; --fs-section: 16px; --fs-kpi: 24px; --fs-lead: 30px; --fs-body: 14px; --fs-small: 12px;
  --sidebar: 232px; --pad: 24px; --gap: 16px; --card-pad: 20px;
  --radius-sheet: 16px; --radius-card: 8px; --radius-control: 6px; --radius-chip: 4px;
  --control-height: 34px; --row: 48px;
  --t: 150ms cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--frame); color: var(--text); font: var(--fs-body)/20px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, table, .figure { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- sign in ---------- */
.signin { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.signin-card { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet); padding: 32px; display: grid; gap: 10px; }
.signin-mark { border-radius: 50%; margin-bottom: 8px; }
.signin-card h1 { font-size: 20px; line-height: 28px; font-weight: 600; margin-bottom: 14px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100svh; }
.sidebar { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; padding: 16px 12px; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand img { border-radius: 50%; flex: none; }
.brand strong { display: block; font-weight: 600; line-height: 18px; }
.brand-sub { display: block; font-size: var(--fs-small); color: var(--muted); line-height: 16px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 10px; border-radius: var(--radius-control); color: #4a3c40; transition: background var(--t); }
.sidebar nav a:hover { background: #f0e8ea; }
.sidebar nav a[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 500; }
.nav-count { font-size: var(--fs-small); font-weight: 600; color: var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.linkish { background: none; border: 0; padding: 6px 10px; text-align: left; color: var(--muted); cursor: pointer; border-radius: var(--radius-control); }
.linkish:hover { color: var(--text); }
.topbar { display: none; }
.sheet { margin: 8px 8px 8px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet); padding: var(--pad); min-width: 0; outline: none; }

/* ---------- title row ---------- */
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.title-row h1 { font-size: var(--fs-title); line-height: 32px; font-weight: 600; letter-spacing: -0.01em; }
.finding { margin-top: 4px; color: var(--text); max-width: 72ch; }
.finding .muted { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { display: inline-block; color: var(--muted); margin-bottom: 4px; }
.crumb:hover { color: var(--text); }

/* ---------- buttons, fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--control-height); padding: 0 14px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background var(--t), border-color var(--t), transform 120ms; }
.btn:hover { border-color: #b9adb0; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: #45292f; }
.btn.danger { color: var(--negative); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 1; color: #8a7d80; background: var(--raised); cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-control); border: 1px solid transparent; background: none; cursor: pointer; }
.icon-btn:hover { background: var(--raised); }
label, .label { font-weight: 500; font-size: 13px; line-height: 18px; }
input, select, textarea { width: 100%; height: var(--control-height); padding: 0 10px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); }
textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 20px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.field { display: grid; gap: 6px; align-content: start; }
.field .hint { font-size: var(--fs-small); color: var(--muted); line-height: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.form-error { color: var(--negative); min-height: 20px; }

/* ---------- panels ---------- */
.grid6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--gap); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .span4 { grid-column: span 4; } .span6 { grid-column: span 6; }
.stack { display: grid; gap: var(--gap); align-content: start; }
.panel { border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; background: var(--surface); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { font-size: var(--fs-section); line-height: 22px; font-weight: 600; }
.panel-head .meta { color: var(--muted); font-size: 13px; }
.lead-figure { font-size: var(--fs-lead); line-height: 36px; font-weight: 500; letter-spacing: -0.01em; }
.empty { border: 1px dashed var(--control); border-radius: var(--radius-card); padding: 10px 12px; color: var(--muted); }

/* ---------- Today: the delivery run ---------- */
.run { display: grid; grid-template-columns: repeat(var(--lanes, 3), minmax(0, 1fr)); gap: 12px; }
.lane { background: var(--raised); border-radius: var(--radius-card); padding: 12px; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.lane-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 2px; }
.lane-head strong { font-weight: 600; }
.lane-head span { color: var(--muted); font-size: 13px; }
.stop { display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; transition: border-color var(--t); }
.stop:hover { border-color: #cdbfc3; }
.stop-top { display: flex; justify-content: space-between; gap: 8px; }
.stop-top strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop .cash { font-size: 13px; display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }

/* ---------- lists inside panels ---------- */
.rowlist > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--rule); align-items: center; }
.rowlist > li:first-child { border-top: 0; padding-top: 0; }
.rowlist .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowlist .sub { grid-column: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowlist .end { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 8px; align-items: center; }

/* ---------- tabs, toolbar, tables ---------- */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { position: relative; padding: 8px 0 10px; color: var(--muted); white-space: nowrap; background: none; border: 0; cursor: pointer; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { color: var(--text); font-weight: 500; }
.tabs [aria-current="page"]::after, .tabs [aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.tabs .count { color: var(--muted); font-weight: 400; margin-left: 4px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="search"] { width: 280px; }
.toolbar select, .toolbar input[type="date"] { width: auto; }
.toolbar .total { margin-left: auto; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); padding: 0 12px 8px 0; white-space: nowrap; }
td { padding: 12px 12px 12px 0; border-top: 1px solid var(--rule); vertical-align: top; }
td:last-child, th:last-child { padding-right: 0; }
th.num, td.num { text-align: right; }
tbody tr { cursor: default; }
tbody tr.link-row { cursor: pointer; transition: background var(--t); }
tbody tr.link-row:hover { background: var(--raised); }
td .sub { display: block; color: var(--muted); font-size: 13px; line-height: 18px; margin-top: 2px; }
td .strong { font-weight: 500; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { margin-top: 12px; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; flex: none; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.pill.new { background: var(--pill-new-bg); color: var(--pill-new-ink); }
.pill.good { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.bad { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }

/* ---------- KPI strip (one container, divided) ---------- */
.strip { display: grid; grid-template-columns: repeat(var(--cells, 4), minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-card); margin-bottom: var(--gap); }
.strip > div { padding: 16px 20px; border-left: 1px solid var(--border); }
.strip > div:first-child { border-left: 0; }
.strip .k { color: var(--muted); font-size: 13px; }
.strip .v { font-size: var(--fs-kpi); line-height: 32px; font-weight: 500; margin-top: 4px; }
.strip .v.lead { font-size: var(--fs-lead); line-height: 36px; }
.strip .s { color: var(--muted); font-size: 13px; }
.series-tabs { display: flex; gap: 24px; margin-bottom: 12px; }
.series-tabs button { background: none; border: 0; padding: 0 0 8px; text-align: left; cursor: pointer; border-bottom: 2px solid transparent; }
.series-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); }
.series-tabs .k { display: block; color: var(--muted); font-size: 13px; }
.series-tabs [aria-selected="true"] .k { color: var(--text); }
.series-tabs .v { display: block; font-size: var(--fs-kpi); line-height: 32px; font-weight: 400; }
.series-tabs [aria-selected="true"] .v { font-weight: 500; }
.chart { width: 100%; }

/* ---------- order detail ---------- */
.object { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius-card); margin-bottom: var(--gap); }
.object h1 { font-size: 22px; line-height: 30px; font-weight: 600; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.object .meta { color: var(--muted); margin-top: 2px; }
dl.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 12px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { overflow-wrap: anywhere; }
.lines li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.lines li:first-child { border-top: 0; padding-top: 0; }
.lines .parts { color: var(--muted); font-size: 13px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.totals .grand { font-weight: 600; font-size: 16px; }
.card-message { white-space: pre-wrap; font-size: 15px; line-height: 22px; }
.events li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 6px 0; }
.events time { color: var(--muted); font-size: 13px; }
.contact-links { display: inline-flex; gap: 10px; margin-left: 8px; }
.contact-links a { color: var(--accent); font-size: 13px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px var(--gap); }
.form-section { border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); margin-bottom: var(--gap); }
.form-section h2 { font-size: var(--fs-section); font-weight: 600; margin-bottom: 14px; }
.line-row { display: grid; grid-template-columns: minmax(0, 3fr) 80px 120px 110px 34px; gap: 8px; align-items: end; padding: 10px 0; border-top: 1px solid var(--rule); }
.line-row:first-of-type { border-top: 0; padding-top: 0; }
.line-total { height: var(--control-height); display: flex; align-items: center; justify-content: flex-end; }
.parts-box { grid-column: 1 / -1; background: var(--raised); border-radius: var(--radius-card); padding: 12px; display: grid; gap: 8px; }
.part-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 34px; gap: 8px; }
.space { font-size: 13px; color: var(--muted); }
.space.over { color: var(--negative); font-weight: 500; }
.sticky-total { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 12px 0 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.sticky-total .sum { font-size: 18px; font-weight: 600; }

/* ---------- dialog, toast ---------- */
/* taste-skill-ignore: dialog floats */ dialog { border: 1px solid var(--border); border-radius: var(--radius-sheet); padding: 24px; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 48px rgba(30, 20, 22, 0.16); color: var(--text); }
dialog::backdrop { background: rgba(30, 20, 22, 0.32); }
dialog h2 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
/* taste-skill-ignore: toast floats */ .toast { position: fixed; right: 20px; bottom: 20px; background: var(--primary); color: var(--primary-ink); padding: 10px 14px; border-radius: var(--radius-control); box-shadow: 0 8px 24px rgba(30, 20, 22, 0.2); max-width: 360px; z-index: 10; }
.toast a { text-decoration: underline; }

/* ---------- loading and errors ---------- */
.skeleton { background: var(--raised); border-radius: 4px; height: 20px; }
.block-error { border: 1px solid var(--pill-negative-bg); background: #fff8f7; border-radius: var(--radius-card); padding: 12px 14px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }

/* ---------- print: the driver's run sheet ---------- */
.print-sheet { display: none; }
@media print {
  body { background: #fff; }
  .app, .toast { display: none !important; }
  .print-sheet { display: block; font: 12px/16px var(--font); color: #000; }
  .print-sheet h1 { font-size: 18px; margin-bottom: 8px; }
  .print-sheet table td, .print-sheet table th { border-top: 1px solid #ccc; padding: 6px 8px 6px 0; color: #000; font-size: 12px; }
  .print-sheet tr { break-inside: avoid; }
}

/* ---------- tablet and phone ---------- */
@media (max-width: 1100px) {
  .grid6 > .span4, .grid6 > .span2 { grid-column: span 6; }
  .run { --lanes: 1 !important; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: fixed; inset: 0; height: auto; z-index: 20; background: var(--frame); padding: 16px; display: none; }
  .sidebar.open { display: flex; }
  .sidebar nav a { height: 44px; font-size: 16px; }
  .topbar { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px 0 4px; position: sticky; top: 0; background: var(--frame); z-index: 5; }
  .topbar-title { font-weight: 600; flex: 1; }
  .sheet { margin: 0; border-radius: 0; border-width: 1px 0 0; padding: 16px; }
  .title-row { flex-direction: column; }
  .title-row h1 { font-size: 22px; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip > div { border-left: 0; border-top: 1px solid var(--border); }
  .strip > div:nth-child(-n+2) { border-top: 0; }
  .strip > div:nth-child(even) { border-left: 1px solid var(--border); }
  .strip > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .grid6 > * { grid-column: span 6 !important; }
  .form-grid > * { grid-column: span 6 !important; }
  .toolbar input[type="search"] { width: 100%; }
  .toolbar .total { margin-left: 0; }
  .object { flex-direction: column; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .line-row { grid-template-columns: minmax(0, 1fr) 70px 34px; }
  .line-row .unit, .line-row .line-total { grid-column: span 1; }
  /* Tables become two-line rows. */
  table.responsive thead { display: none; }
  table.responsive tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-top: 1px solid var(--rule); }
  table.responsive td { border: 0; padding: 0; }
  table.responsive td.hide-sm { display: none; }
  table.responsive td.num { grid-column: 2; grid-row: 1; }
  table.responsive td.end { grid-column: 2; grid-row: 2; text-align: right; }
  .clip { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (max-width: 860px) {
  .wide-only { display: none !important; }
  table.responsive td .sub { display: inline; margin-left: 6px; }
}
@media (max-width: 1100px) {
  /* On smaller screens the lists that need a tap (confirm, cash received) come before the run. */
  .grid6 > .stack.span2 { order: -1; }
}
.phone { display: grid; grid-template-columns: auto minmax(0, 1fr); border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); overflow: hidden; }
.phone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.phone select, .phone input { border: 0; border-radius: 0; outline: none; background-color: transparent; }
.phone select { -webkit-appearance: none; appearance: none; width: auto; padding: 0 26px 0 10px; font-weight: 500; background: var(--raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1.5 5 5.5 9 1.5' stroke='%236a5a5e' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 9px center; }
.phone input { font-variant-numeric: tabular-nums; }
.back { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px 0 8px; margin-bottom: 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; }
.back:hover { background: var(--raised); }
@media (max-width: 860px) { .back { height: 40px; } }
