/* Pakl web app. Tokens are generated from the Pakl design system (tokens.json); components follow its guidelines. */
:root {
  color-scheme: light dark;
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --widget-bg: #FBFAF8C7;
  --widget-row: #FFFFFFEB;
  --surface-2: #EFEDE9;
  --line: #E4E1DB;
  --ink: #1A1816;
  --ink-2: #6B665F;
  --brand: #E0601E;
  --brand-strong: #B94A12;
  --on-brand: #FFFFFF;
  --brand-ink: #B2470E;
  --ready: #0E7A4A;
  --on-ready: #FFFFFF;
  --ready-soft: #E3F3EA;
  --on-ready-soft: #0B5E39;
  --transit-soft: #FCEBDD;
  --on-transit-soft: #8A3A0C;
  --attention: #C62F2F;
  --on-attention: #FFFFFF;
  --attention-soft: #FBE6E4;
  --on-attention-soft: #8E1E1E;
  --shadow-float: 0 8px 24px rgba(26, 24, 22, 0.14);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --radius-sm: 8px;
  --radius-control: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 999px;
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --font-sans: Geist, "Google Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", "Roboto Mono", monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1C1A18;
    --widget-bg: #1C1A18B3;
    --widget-row: #121110E0;
    --surface-2: #272522;
    --line: #34312D;
    --ink: #F3F1ED;
    --ink-2: #A8A29A;
    --brand: #F27A3A;
    --brand-strong: #F27A3A;
    --on-brand: #1A0C04;
    --brand-ink: #FF9A5E;
    --ready: #17603F;
    --on-ready: #EAFBF1;
    --ready-soft: #123222;
    --on-ready-soft: #7BE0AA;
    --transit-soft: #3A2416;
    --on-transit-soft: #FFB27F;
    --attention: #FF7A6E;
    --on-attention: #2A0806;
    --attention-soft: #3B1A17;
    --on-attention-soft: #FF9C92;
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/22px var(--font-sans); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-2); }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; height: calc(env(safe-area-inset-top) + 56px);
  padding: env(safe-area-inset-top) var(--space-3) 0 var(--space-5); background: var(--bg); border-bottom: 1px solid transparent; transition: border-color var(--duration-fast) var(--ease); }
.top.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; line-height: 28px; font-weight: 600; }
.brand img { border-radius: 8px; display: block; }
.top-actions { display: flex; gap: var(--space-1); position: relative; }
.icon-btn { position: relative; width: 40px; height: 40px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; transition: background-color var(--duration-fast) var(--ease); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--attention); box-shadow: 0 0 0 2px var(--bg); }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.menu { position: absolute; top: 44px; right: 0; min-width: 236px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-float); padding: var(--space-1); display: grid; z-index: 10;
  opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease); }
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 var(--space-3); border: 0; background: none; border-radius: var(--radius-control); text-decoration: none; color: var(--ink); font-size: 14px; cursor: pointer; text-align: left; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu svg.i { color: var(--ink-2); }
.menu .badge { margin-left: auto; font-size: 12px; color: var(--on-attention-soft); background: var(--attention-soft); border-radius: var(--radius-full); padding: 0 8px; line-height: 20px; }

main { max-width: 640px; overflow-x: clip; margin: 0 auto; padding: var(--space-3) var(--space-5) calc(env(safe-area-inset-bottom) + 104px); }

/* Summary: count tiles weighted by state */
.tiles { display: flex; gap: var(--space-3); margin-bottom: var(--space-6); }
.count { flex: 1; min-width: 0; border: 0; text-align: left; cursor: pointer; border-radius: var(--radius-lg); padding: var(--space-4) var(--space-4) 14px; display: grid; gap: 2px; transition: flex-grow var(--duration-base) var(--ease), background-color var(--duration-base) var(--ease); }
.count .n { font-size: 56px; line-height: 56px; font-weight: 600; letter-spacing: -0.03em; }
.count .l { font-size: 15px; line-height: 20px; font-weight: 500; }
.count .s { font-size: 12px; line-height: 16px; opacity: .88; min-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count.lead { flex-grow: 1.5; }
.count.ready { background: var(--ready); color: var(--on-ready); }
.count.transit { background: var(--transit-soft); color: var(--on-transit-soft); }
.count.quiet { background: var(--surface-2); color: var(--ink-2); }

/* Sections */
.group { margin-bottom: var(--space-6); }
.group > h2 { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); margin: 0 0 var(--space-2) var(--space-1); display: flex; gap: 6px; }
.group > h2 .c { color: var(--ink-2); opacity: .8; }
.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.list.cards { gap: var(--space-3); }
details.group > summary { list-style: none; cursor: pointer; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); margin: 0 0 var(--space-2) var(--space-1); display: flex; align-items: center; gap: 6px; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary svg.i { width: 16px; height: 16px; transition: transform var(--duration-fast) var(--ease); }
details.group[open] > summary svg.i { transform: rotate(90deg); }

/* Carrier mark */
.carrier { width: 40px; height: 40px; flex: none; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); display: grid; place-items: center; font-size: 12px; font-weight: 600; }

/* Pickup card */
.pickup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); cursor: pointer; min-width: 0; }
.pickup .top-row { display: flex; gap: var(--space-3); align-items: center; }
.pickup .place { font-size: 17px; line-height: 22px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pickup .meta { font-size: 12px; line-height: 16px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: 100%; border: 0; cursor: pointer; text-align: left;
  background: var(--ready-soft); color: var(--on-ready-soft); border-radius: var(--radius-md); padding: 12px 20px; transition: transform var(--duration-fast) var(--ease); }
.pin:active { transform: scale(0.98); }
.pin::before, .pin::after { content: ""; position: absolute; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--surface); }
.pin::before { left: -6px; } .pin::after { right: -6px; }
.pin .k { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; font-weight: 500; }
.pin .k svg.i { width: 16px; height: 16px; }
.pin .v { font-family: var(--font-mono); font-size: 22px; line-height: 26px; font-weight: 500; letter-spacing: .06em; }
.pickup.urgent .pin { background: var(--attention-soft); color: var(--on-attention-soft); }
.pin.missing { background: var(--surface-2); color: var(--ink-2); }
.pin.missing::before, .pin.missing::after { display: none; }
.pin.missing .v { font-family: var(--font-sans); font-size: 14px; letter-spacing: 0; color: var(--brand-ink); }
.pickup .foot { display: flex; justify-content: flex-end; gap: var(--space-2); }

/* Parcel row */
.row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: var(--space-3); row-gap: 10px; align-items: center; cursor: pointer; width: 100%; text-align: left; font: inherit; color: inherit; }
.row .t { font-size: 15px; line-height: 20px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .d { font-size: 13px; line-height: 18px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .eta { text-align: right; font-size: 12px; line-height: 16px; color: var(--ink-2); white-space: nowrap; }
.row .eta b { display: block; font-size: 15px; line-height: 20px; color: var(--ink); font-weight: 500; }
.row.done { background: transparent; }
.track { grid-column: 2 / 4; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.track i { height: 4px; border-radius: 2px; background: var(--surface-2); }
.track i.on { background: var(--ink-2); opacity: .55; }
.track i.now { background: var(--brand); }
.track.problem i.now { background: var(--attention); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-control); font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease); }
.btn:active { transform: scale(0.97); }
.btn.sm { height: 32px; padding: 0 var(--space-3); font-size: 13px; }
.btn.primary { background: var(--brand-strong); color: var(--on-brand); }
.btn.tonal { background: var(--surface-2); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--brand-ink); padding: 0 var(--space-2); }
.btn.danger { background: transparent; color: var(--on-attention-soft); }
.btn:disabled { opacity: .5; }
.fab { position: fixed; right: calc(env(safe-area-inset-right) + var(--space-5)); bottom: calc(env(safe-area-inset-bottom) + var(--space-5)); height: 56px; padding: 0 var(--space-5); border: 0; border-radius: var(--radius-md);
  background: var(--brand-strong); color: var(--on-brand); box-shadow: var(--shadow-float); display: flex; align-items: center; gap: var(--space-2); font-size: 15px; font-weight: 500; cursor: pointer; transition: transform var(--duration-fast) var(--ease); }
.fab:active { transform: scale(0.97); }

/* Chips (detail sheet and inbox only) */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-full); font-size: 13px; line-height: 18px; font-weight: 500; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ready { background: var(--ready-soft); color: var(--on-ready-soft); }
.chip.transit { background: var(--transit-soft); color: var(--on-transit-soft); }
.chip.out { background: var(--transit-soft); color: var(--on-transit-soft); } .chip.out::before { background: var(--brand); }
.chip.attention { background: var(--attention-soft); color: var(--on-attention-soft); }
.chip.neutral { background: var(--surface-2); color: var(--ink-2); }

/* Banner, empty, toast, footer */
.banner { position: relative; background: var(--transit-soft); color: var(--on-transit-soft); border-radius: var(--radius-md); padding: var(--space-3) 44px var(--space-3) var(--space-4); margin-bottom: var(--space-6); font-size: 14px; line-height: 20px; }
.banner a { color: inherit; font-weight: 500; }
.banner .code { font-family: var(--font-mono); font-size: 17px; margin: 0 6px; }
.banner-x { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: 0; border-radius: var(--radius-control); background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; }
.empty { text-align: center; color: var(--ink-2); padding: var(--space-8) var(--space-4); }
.empty b { display: block; color: var(--ink); font-weight: 500; font-size: 17px; margin-bottom: var(--space-1); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 40px); display: flex; align-items: center; gap: var(--space-3); background: var(--ink); color: var(--bg); padding: 10px var(--space-4); border-radius: var(--radius-control); font-size: 14px; line-height: 20px; box-shadow: var(--shadow-float); z-index: 30; }
.toast[hidden] { display: none; }
.toast-act { border: 0; background: transparent; color: var(--brand); font-weight: 500; font-size: 14px; padding: 4px 6px; margin: -4px -6px -4px auto; border-radius: 6px; cursor: pointer; flex: none; }
.footer { text-align: center; font-size: 12px; color: var(--ink-2); margin-top: var(--space-8); }
.footer a { color: var(--ink-2); }

/* Sheets (dialogs) */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, 100vw); max-height: 88vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; margin: auto auto 0; box-shadow: var(--shadow-float); }
@media (min-width: 640px) { dialog { border-radius: var(--radius-xl); margin: auto; } }
dialog::backdrop { background: rgba(18, 17, 16, 0.42); }
dialog[open] { animation: rise var(--duration-base) var(--ease); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.sheet { padding: var(--space-5) var(--space-5) calc(env(safe-area-inset-bottom) + var(--space-5)); display: grid; gap: var(--space-4); }
.sheet h3 { margin: 0; font-size: 22px; line-height: 28px; font-weight: 600; }
.sheet .sub { margin: -12px 0 0; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.sheet label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.sheet input, .sheet select { height: 44px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--bg); color: var(--ink); padding: 0 var(--space-3); font: inherit; font-size: 15px; }
.sheet input:focus, .sheet select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.actions.left { justify-content: flex-start; }
.form-err { margin: 0; color: var(--on-attention-soft); background: var(--attention-soft); border-radius: var(--radius-control); padding: var(--space-2) var(--space-3); font-size: 13px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--space-4); font-size: 14px; margin: 0; }
.facts dt { color: var(--ink-2); } .facts dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 12px minmax(0, 1fr); column-gap: var(--space-3); font-size: 14px; line-height: 20px; padding-bottom: var(--space-3); position: relative; }
.timeline li > span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-top: 6px; justify-self: center; position: relative; z-index: 1; }
.timeline li:first-child > span { background: var(--ink-2); }
.timeline li::after { content: ""; position: absolute; left: 5.5px; top: 14px; bottom: -6px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; margin-top: 0; font-size: 12px; line-height: 16px; color: var(--ink-2); }
.inbox-item { padding: var(--space-3) 0; border-top: 1px solid var(--line); font-size: 14px; display: grid; gap: 4px; }
.inbox-item b { font-weight: 500; overflow-wrap: anywhere; }
.inbox-item .muted { font-size: 12px; line-height: 16px; }
.qr { background: #FFFFFF; border-radius: var(--radius-md); padding: var(--space-3); width: 240px; justify-self: center; }
.qr svg { display: block; width: 100%; height: auto; }
.warn-note { margin: 0; font-size: 13px; line-height: 18px; color: var(--on-attention-soft); background: var(--attention-soft); border-radius: var(--radius-control); padding: var(--space-2) var(--space-3); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (prefers-color-scheme: dark) { .toast-act { color: #B2470E; } }
