:root {
  --ink: #16242e;
  --muted: #5c6b74;
  --muted-2: #647279;
  --paper: #f6f8f9;
  --card: #ffffff;
  --border: #dee4e7;
  --border-strong: #b9c4c9;
  --accent: #0d72b9;
  --accent-dark: #0a5d97;
  --accent-darker: #084a79;
  --accent-wash: #e6f1fa;
  --accent-wash-border: #bcdaf0;
  --amber: #93630b;
  --amber-text: #785109;
  --amber-wash: #f8f1e3;
  --amber-wash-border: #e8cd93;
  --coral: #ab392e;
  --coral-wash: #f8eae8;
  --coral-wash-border: #e8bcb6;
  --shell: #0c2233;
  --shell-highlight: #6fc0e8;
  --wash: #f1f4f5;
  --shadow-xs: 0 1px 2px rgba(16, 29, 38, .05);
  --shadow: 0 1px 2px rgba(16, 29, 38, .06), 0 2px 6px rgba(16, 29, 38, .04);
  --shadow-lift: 0 8px 24px rgba(16, 29, 38, .14);
  --sidebar-w: 232px;
  --topbar-h: 56px;
  --bottombar-h: 68px;
  --radius: 8px;
  --radius-sm: 6px;
  --focus: 0 0 0 3px rgba(13, 114, 185, .32);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-base: 14.5px;
  --fs-md: 16px;
  --fs-lg: 19px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  caret-color: var(--accent);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #e6edf1;
  --muted: #93a6b0;
  --muted-2: #7c909a;
  --paper: #0d161d;
  --card: #16232c;
  --border: #263440;
  --border-strong: #3a4d59;
  --accent: #3d97d6;
  --accent-dark: #6cc0ee;
  --accent-darker: #9bd6f5;
  --accent-wash: #16303f;
  --accent-wash-border: #2f5772;
  --amber: #dba746;
  --amber-text: #eec582;
  --amber-wash: #2c2413;
  --amber-wash-border: #5c471f;
  --coral: #e2776a;
  --coral-wash: #331d1a;
  --coral-wash-border: #5c322c;
  --shell: #0a161e;
  --shell-highlight: #6cc0ee;
  --wash: #121e26;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .28);
  --shadow-lift: 0 8px 28px rgba(0, 0, 0, .48);
  --focus: 0 0 0 3px rgba(61, 151, 214, .38);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; scrollbar-color: var(--accent) var(--paper); }
a, button, .btn, input, select, textarea, summary { touch-action: manipulation; }
h1, h2, .page-title { scroll-margin-top: 72px; text-wrap: balance; }

.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
}
.skip-link:focus, .skip-link:focus-visible {
  transform: none;
  color: #fff;
  text-decoration: none;
  box-shadow: var(--focus);
}
::selection { background: var(--accent-wash-border); color: var(--ink); }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .brand, .page-title, .btn, th, label, .app-title, .login-logo .name {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.brand-serif, .login-logo .name {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

.brand-mark {
  display: block;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
}

.dev-credit {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted-2);
  line-height: 1.55;
  padding: 18px 16px 8px;
  margin: 0;
}
.dev-credit a { color: inherit; font-weight: 500; }
.dev-credit a:hover { color: var(--accent-darker); }
.login-wrap > .dev-credit { padding: 18px 8px 0; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.mobile-bar { display: none; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--shell);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar .brand-block {
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.05) 0%, rgba(255,255,255,0) 100%);
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 4px;
}
.sidebar .brand {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700; font-size: 17px;
  display: flex; align-items: center; gap: 9px;
  letter-spacing: -0.02em;
}
.sidebar .brand .brand-mark { width: 32px; height: 32px; }
.sidebar .brand-copy { min-width: 0; }
.sidebar .brand-name { line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .brand-sub {
  font-size: 11px; color: rgba(255,255,255,.55);
  margin: 1px 0 0; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.side-nav {
  display: flex; flex-direction: column; gap: 2px; padding: 4px 10px; flex: 1; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.28) transparent;
}
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-track { background: transparent; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 3px; }
.side-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }
.nav-secondary {
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.28) transparent;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.08);
}
.nav-secondary::-webkit-scrollbar { width: 6px; }
.nav-secondary::-webkit-scrollbar-track { background: transparent; }
.nav-secondary::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 3px; }
.nav-secondary::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.68); font-size: 13.5px; font-weight: 600;
  transition: background .12s, color .12s;
  background: transparent; border: none; font-family: inherit; cursor: pointer; width: 100%;
  text-align: left;
}
.nav-more-toggle { display: none; appearance: none; -webkit-appearance: none; }
.nav-secondary { display: flex; flex-direction: column; gap: 2px; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link.active svg { opacity: 1; }
.nav-link:not(.active):hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link:focus-visible { outline: 2px solid var(--shell-highlight); outline-offset: -2px; }

.sidebar-foot {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.12);
}
.sidebar-foot .who {
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: background .12s;
}
.sidebar-foot .who:hover { background: rgba(255,255,255,.06); }
.sidebar-foot .who a {
  font-size: 12.5px; font-weight: 600;
  color: rgba(255,255,255,.9); text-decoration: none;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
}
.sidebar-foot .who a svg {
  width: 26px; height: 26px; padding: 6px; box-sizing: border-box;
  background: rgba(255,255,255,.1); border-radius: 50%; flex-shrink: 0;
  transition: background .12s;
}
.sidebar-foot .who a:hover, .sidebar-foot .who a.active { color: #fff; }
.sidebar-foot .who a:hover svg, .sidebar-foot .who a.active svg { background: var(--accent); }
.sidebar-foot form { margin: 0; height: 100%; }
.sidebar-foot-row { display: flex; gap: 8px; align-items: stretch; }
.sidebar-foot-row form { flex: 1; }
.sidebar-foot .btn.logout-btn {
  width: 100%; height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); font-weight: 600;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm); font-size: 12.5px;
  transition: background .12s, color .12s, border-color .12s;
}
.sidebar-foot .btn.logout-btn:hover {
  background: var(--coral-wash); color: var(--coral); border-color: var(--coral-wash-border);
}

.theme-toggle {
  width: 36px; height: 36px; flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.1); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,.18); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.theme-toggle:focus-visible { outline: none; box-shadow: var(--focus); }

.mobile-bar-actions, .topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Delivery top bar */
.topbar {
  background: var(--shell);
  color: #fff;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}
.topbar .brand {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700; font-size: 17px;
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.topbar a.brand { color: #fff; text-decoration: none; }
.topbar a.brand:hover { color: #fff; text-decoration: none; }
.topbar .brand .brand-mark { width: 32px; height: 32px; }
.topbar .brand .brand-text { white-space: nowrap; }
.topbar form { margin: 0; }

.container {
  padding: 22px 28px 56px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}
.container-flush { max-width: none; }

/* ---------- Page header ---------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-header .page-title {
  margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2;
  display: flex; align-items: center; gap: 9px;
}
.page-title svg { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.page-header .page-sub {
  margin: 4px 0 0; font-size: 13px; color: var(--muted); font-weight: 500;
}
.page-header .page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Attention strip ---------- */
.attention-strip {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 18px;
}
.attention-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 700; text-decoration: none;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, transform .12s;
}
.attention-chip svg { width: 14px; height: 14px; flex-shrink: 0; }
.attention-chip:hover { text-decoration: none; transform: translateY(-1px); }
.attention-chip.warn {
  background: var(--amber-wash); color: var(--amber-text); border-color: var(--amber-wash-border);
}
.attention-chip.warn:hover { border-color: var(--amber); }
.attention-chip.danger {
  background: var(--coral-wash); color: var(--coral); border-color: var(--coral-wash-border);
}
.attention-chip.danger:hover { border-color: var(--coral); }

.stat-group-label {
  margin: 0 0 8px; font-size: 12.5px; font-weight: 700; color: var(--muted-2);
}
.attention-strip + .stat-group-label { margin-top: 0; }
.stat-group-label + .grid + .stat-group-label { margin-top: 2px; }

/* ---------- Snapshot bar ---------- */
.snapshot-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); font-weight: 600;
  margin: -6px 0 16px;
}
.snapshot-bar strong { color: var(--ink); font-weight: 700; }
.snapshot-bar .divider { color: var(--border-strong); }

/* ---------- Stat tiles ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 20px;
}
@media (max-width: 1080px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
  transition: border-color .12s, transform .12s;
}
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-2px); }
.stat-icon {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--wash); color: var(--muted-2);
}
.stat-icon svg { width: 19px; height: 19px; }
.stat.t-primary .stat-icon, .stat.t-aqua .stat-icon { background: var(--accent-wash); color: var(--accent); }
.stat.t-amber .stat-icon { background: var(--amber-wash); color: var(--amber); }
.stat.t-coral .stat-icon { background: var(--coral-wash); color: var(--coral); }
.stat.alert { border-color: var(--coral-wash-border); }
.stat-body { min-width: 0; }
.stat .label { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.stat .value {
  font-size: 22px; font-weight: 700; margin-top: 3px;
  letter-spacing: -0.02em; line-height: 1.15;
  color: var(--ink); overflow-wrap: anywhere;
}

.grid.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-trend {
  flex-direction: column; align-items: flex-start; gap: 10px;
}
.stat-trend .stat-body { width: 100%; }
.stat-meta { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 3px; }

/* ---------- Report tiles ---------- */
.report-category { margin-bottom: 18px; }
.report-category-title {
  font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 0 0 8px;
}
.report-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.report-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 9px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 13px; text-decoration: none; color: inherit;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.report-tile:hover { border-color: var(--border-strong); transform: translateY(-1px); text-decoration: none; color: inherit; }
.report-tile.active { border-color: var(--accent); background: var(--accent-wash); }
.report-tile-icon {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--wash); color: var(--muted-2);
}
.report-tile.active .report-tile-icon { background: var(--card); color: var(--accent-dark); }
.report-tile-icon svg { width: 17px; height: 17px; }
.report-tile-label { font-size: 12.5px; font-weight: 600; line-height: 1.25; }

/* ---------- Cards / tables ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 14px; font-size: 14px; font-weight: 700;
  letter-spacing: -0.01em; color: var(--ink);
}
.card h2::before {
  content: ''; display: inline-block; width: 3px; height: 12px;
  background: var(--accent); border-radius: 2px; margin-right: 8px; vertical-align: -1px;
}
.card .hint { font-size: 13px; color: var(--muted); margin: -6px 0 14px; line-height: 1.45; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.card-head h2 { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  color: var(--muted); font-weight: 700; font-size: 11px;
  letter-spacing: .03em; text-transform: uppercase;
  background: var(--wash);
}
thead th:first-child { border-radius: 6px 0 0 0; }
thead th:last-child { border-radius: 0 6px 0 0; }
tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--wash); }
tbody tr:hover { background: var(--accent-wash); }
tr.row-link { cursor: pointer; }
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin: 0 -2px;
  background:
    linear-gradient(to right, var(--card) 30%, transparent) 0 0,
    linear-gradient(to left, var(--card) 30%, transparent) 100% 0,
    linear-gradient(to right, rgba(16,29,38,.12), transparent) 0 0,
    linear-gradient(to left, rgba(16,29,38,.12), transparent) 100% 0;
  background-repeat: no-repeat;
  background-size: 24px 100%, 24px 100%, 10px 100%, 10px 100%;
  background-attachment: local, local, scroll, scroll;
}
@media (min-width: 701px) {
  .table-wrap table { min-width: 820px; }
  .table-wrap td[data-label="Actions"] .action-group { flex-wrap: nowrap; }
  .table-wrap th:last-child, .table-wrap td[data-label="Actions"] {
    position: sticky; right: 0; background: var(--card);
    box-shadow: -6px 0 8px -6px rgba(16, 29, 38, .1);
  }
  .table-wrap tbody tr:nth-child(even) td[data-label="Actions"] { background: var(--wash); }
  .table-wrap tbody tr:hover td[data-label="Actions"] { background: var(--accent-wash); }
}
.table-wrap table { margin: 0; }
.table-wrap th, .table-wrap td { padding-left: 12px; padding-right: 12px; }
.table-wrap tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-summary { width: 100%; }
.table-summary td { padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table-summary tr:last-child td { border-bottom: none; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  padding: 10px 15px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: background .12s, transform .08s;
  min-height: 44px; white-space: nowrap; text-decoration: none;
  font-family: inherit;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn.small svg { width: 13px; height: 13px; }
.btn[hidden] { display: none !important; }
.btn:hover { background: var(--accent-darker); text-decoration: none; color: #fff; }
.btn:active { transform: scale(.98); }
.btn.secondary {
  background: var(--card); color: var(--ink);
  border: 1px solid var(--border-strong);
}
.btn.secondary:hover { background: var(--paper); color: var(--ink); border-color: var(--muted-2); }
.btn.danger { background: var(--coral); }
.btn.danger:hover { background: #8f2f25; }
.btn.small { padding: 8px 12px; font-size: 12.5px; min-height: 40px; font-weight: 650; }
.btn.aqua, .btn.green { background: var(--accent); }
.btn.aqua:hover, .btn.green:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: var(--accent-dark); border: 1px solid transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--accent-wash); color: var(--accent-dark); box-shadow: none; transform: none; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: none; box-shadow: var(--focus);
}
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 16px; margin-bottom: 10px;
  background: var(--card); color: var(--ink); font-family: inherit;
  min-height: 42px; transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); outline: none;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  box-shadow: var(--focus);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input[type="color"] {
  width: 56px; min-height: 42px; padding: 4px; cursor: pointer;
}
label {
  font-size: 12px; color: var(--muted); font-weight: 700;
  display: block; margin-bottom: 5px;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 150px; }

.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 14px; padding: 12px; background: var(--wash);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.toolbar input, .toolbar select { margin-bottom: 0; }
.toolbar .btn { flex-shrink: 0; }
.toolbar-field { min-width: 140px; }
.toolbar-field.flex-1 { flex: 1; min-width: 160px; }

.date-chips {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--border);
}
.date-chip {
  display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 650; font-family: inherit; cursor: pointer; line-height: 1.2;
  background: var(--card); color: var(--muted); border: 1px solid var(--border); min-height: 30px;
}
.date-chip:hover { background: var(--wash); color: var(--ink); }
.date-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.date-chip:focus-visible { outline: none; box-shadow: var(--focus); }
.date-range-badge {
  display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 650; background: var(--accent-wash); color: var(--accent-dark);
  border: 1px solid var(--accent-wash-border); margin-left: auto;
}
.date-range-badge[hidden] { display: none; }
@media (max-width: 560px) {
  .date-range-badge { margin-left: 0; flex-basis: 100%; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.statement-section { margin-top: 4px; }
.statement-section + .statement-section { margin-top: 18px; }
.statement-heading {
  margin: 0 0 8px; font-size: 13.5px; font-weight: 700;
  color: var(--muted);
}
.row-total td { font-weight: 800; background: var(--wash); }

.action-group {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end;
}

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  margin-top: 4px; margin-bottom: 8px;
}
.back-link:hover { color: var(--accent-dark); }
.back-link svg { width: 14px; height: 14px; flex-shrink: 0; }

.empty-state {
  text-align: center; padding: 28px 16px; color: var(--muted);
}
.empty-state p { margin: 0 0 12px; font-size: 14px; }
.empty-state .empty-title { font-weight: 700; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

.pagination {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 4px;
}

/* ---------- Analytics ---------- */
.analytics-row { align-items: stretch; }
.analytics-row .card { min-width: 280px; }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-fill {
  width: 100%; min-height: 3px; border-radius: 4px 4px 0 0;
  transition: height .2s;
}
.bar-fill.aqua { background: var(--accent); }
.bar-fill.primary { background: var(--border-strong); }
.bar-value { font-size: 11px; font-weight: 700; color: var(--ink); margin-top: 6px; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.bar-chart-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; height: 160px; color: var(--muted); font-size: 12.5px; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.bar-chart-empty svg { width: 26px; height: 26px; opacity: .45; }

.hbar-chart { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: flex; align-items: center; gap: 10px; }
.hbar-label {
  width: 120px; flex-shrink: 0; font-size: 12.5px; font-weight: 600;
  color: var(--ink); line-height: 1.25; overflow-wrap: anywhere;
}
.hbar-track { flex: 1; background: var(--paper); border-radius: 4px; height: 10px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--coral); border-radius: 0 4px 4px 0; min-width: 3px; transition: width .2s; }
.hbar-fill.accent { background: var(--accent); }
.hbar-value { min-width: 88px; flex-shrink: 0; text-align: right; font-size: 12.5px; font-weight: 700; color: var(--ink); }

/* ---------- Line chart (SVG, hover crosshair) ---------- */
.chart-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; height: 168px; color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.chart-empty svg { width: 26px; height: 26px; opacity: .45; }
.linechart-wrap { position: relative; padding-top: 24px; --lc-color: var(--accent); }
.linechart { display: block; width: 100%; height: 168px; overflow: visible; }
.lc-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.lc-line {
  stroke: var(--lc-color); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.lc-end { fill: var(--lc-color); stroke: var(--card); stroke-width: 2; vector-effect: non-scaling-stroke; }
.lc-hit { fill: transparent; cursor: crosshair; }
.lc-cursor { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.lc-cursor-dot { fill: var(--lc-color); stroke: var(--card); stroke-width: 2; vector-effect: non-scaling-stroke; }
.lc-endlabel {
  position: absolute; top: 2px; transform: translateX(-50%);
  font-size: 11px; font-weight: 700; color: var(--ink);
  background: var(--card); padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border); pointer-events: none; white-space: nowrap;
  transition: opacity .12s;
}
.linechart-wrap.is-hovering .lc-endlabel { opacity: 0; }
.lc-axis { position: relative; height: 16px; margin-top: 4px; }
.lc-axis span {
  position: absolute; transform: translateX(-50%);
  font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap;
}
.lc-tooltip {
  position: absolute; top: 0; transform: translate(-50%, 0);
  pointer-events: none; background: var(--shell); color: #fff;
  font-size: 11.5px; font-weight: 650; padding: 5px 10px; border-radius: 6px;
  white-space: nowrap; box-shadow: var(--shadow-lift); z-index: 5;
}
.lc-tooltip::after {
  content: ''; position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: var(--shell);
}

@media (max-width: 700px) {
  .hbar-label { width: 92px; }
  .hbar-value { min-width: 72px; width: auto; }
}

/* ---------- Status ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status.due, .status.pending { color: var(--amber-text); }
.status.due::before, .status.pending::before { background: var(--amber); }
.status.ok { color: var(--accent-dark); }
.status.ok::before { background: var(--accent); }
.status.warn { color: var(--amber-text); }
.status.warn::before { background: var(--amber); }
.status.danger { color: var(--coral); }
.status.danger::before { background: var(--coral); }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 6px;
  font-size: 11.5px; font-weight: 700;
}
.badge.due { background: var(--coral-wash); color: var(--coral); }
.badge.ok { background: var(--accent-wash); color: var(--accent-dark); }
.badge.pending { background: var(--amber-wash); color: var(--amber-text); }

.muted-cell { color: var(--muted); font-size: 12.5px; }
.row-voided { opacity: .55; }
.row-voided td { text-decoration: line-through; }

/* ---------- Flash ---------- */
.flash-wrap { padding: 16px 28px 0; max-width: 1180px; width: 100%; margin: 0 auto; }
.container > .flash-wrap { padding: 0; max-width: none; margin: 0 0 14px; }
.flash {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
  margin-bottom: 0; border: 1px solid transparent;
  display: flex; align-items: flex-start; gap: 10px;
  animation: flash-in .18s ease-out;
}
.flash-success { background: var(--accent-wash); color: var(--accent-dark); border-color: var(--accent-wash-border); }
.flash-error { background: var(--coral-wash); color: var(--coral); border-color: var(--coral-wash-border); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Utilities ---------- */
.flex-1 { flex: 1; }
.w-70 { min-width: 70px; }
.w-80 { min-width: 80px; }
.w-pay { min-width: 110px; flex: 1; }
.pay-form .btn { min-height: 42px; }
.btn-block { width: 100%; }
.tile-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px; margin-bottom: 18px;
}
.tile-nav .tile-form { margin: 0; display: contents; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 12px 6px; min-height: 76px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--muted); font-size: 12px; font-weight: 650;
  text-decoration: none; text-align: center; cursor: pointer; width: 100%;
  transition: border-color .12s, box-shadow .12s, transform .12s, background .12s, color .12s;
}
.tile:hover { color: var(--ink); border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); }
.tile-icon {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--wash); color: var(--muted-2);
}
.tile-icon svg { width: 18px; height: 18px; }
.tile.active { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-wash); }
.tile.active .tile-icon { background: var(--accent-wash); color: var(--accent); }
.tile.tile-danger { color: var(--coral); }
.tile.tile-danger .tile-icon { background: var(--coral-wash); color: var(--coral); }
.tile.tile-danger:hover { border-color: var(--coral); }
td > form.inline-form, td form.inline-form { display: inline-flex; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  background:
    radial-gradient(64% 50% at 50% 0%, rgba(111, 192, 232, .30) 0%, transparent 72%),
    radial-gradient(46% 38% at 88% 100%, rgba(13, 114, 185, .28) 0%, transparent 70%),
    var(--shell);
  position: relative;
}
.login-waves {
  position: absolute; left: 0; right: 0; bottom: 0; width: 100%;
  height: 42vh; max-height: 320px; z-index: 0; pointer-events: none;
}
.login-waves .wave-1 { fill: rgba(111, 192, 232, .16); }
.login-waves .wave-2 { fill: rgba(61, 151, 214, .16); }
.login-waves .wave-3 { fill: rgba(9, 20, 28, .55); }
.login-wrap { max-width: 380px; width: 100%; position: relative; z-index: 1; }
.login-logo {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 18px; color: #fff;
}
.login-logo .brand-mark {
  width: 104px; height: 104px; margin-bottom: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}
.login-logo .name { font-size: 26px; color: #fff; margin: 0; }
.login-logo .tag { font-size: 13px; color: rgba(255, 255, 255, .68); margin-top: 5px; font-weight: 500; }
.login-wrap .card {
  border: 1px solid var(--border); box-shadow: 0 28px 64px rgba(3, 10, 16, .38), 0 2px 8px rgba(3, 10, 16, .2);
  padding: 22px 20px 20px; background: var(--card);
  border-radius: 16px;
}
.login-wrap .card .btn.btn-block {
  min-height: 46px; padding: 10px 15px; font-size: 14.5px; margin-top: 4px;
}
.login-wrap > .dev-credit { color: rgba(255, 255, 255, .5); }
.login-wrap > .dev-credit a { color: rgba(255, 255, 255, .82); }
.password-field {
  position: relative;
  margin-bottom: 10px;
}
.password-field input {
  margin-bottom: 0;
  padding-right: 68px;
}
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.password-toggle:hover { color: var(--ink); background: var(--paper); }
.password-toggle:focus-visible { outline: none; box-shadow: var(--focus); }
.login-wrap .card h2 { display: none; }
.error-wrap .card h1.error-title,
.login-wrap.error-wrap .card h1 {
  display: block;
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.error-wrap .card .hint { margin: 0 0 16px; }
.error {
  color: var(--coral); font-size: 13px; margin-bottom: 12px; font-weight: 600;
  padding: 10px 12px; background: var(--coral-wash); border-radius: var(--radius-sm);
  border: 1px solid var(--coral-wash-border);
}

@media (max-height: 640px) {
  .login-page { padding: 14px 16px; align-items: flex-start; }
  .login-logo { margin-bottom: 10px; }
  .login-logo .brand-mark { width: 64px; height: 64px; margin-bottom: 6px; }
  .login-logo .name { font-size: 21px; }
  .login-logo .tag { display: none; }
  .login-wrap .card { padding: 16px 18px 16px; }
  .login-wrap > .dev-credit { padding: 8px 8px 0; }
}

.login-page.pwa-open {
  align-items: flex-start;
  padding-top: 28px;
  padding-bottom: calc(160px + env(safe-area-inset-bottom));
}
.pwa-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  max-height: 100vh;
  max-height: 100dvh;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
  display: flex;
  align-items: flex-end;
}
.pwa-sheet-inner {
  pointer-events: auto;
  max-width: 380px;
  max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
  overflow-y: auto;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px 14px 12px 12px;
  box-shadow: var(--shadow-lift), 0 -8px 32px rgba(15, 23, 32, .08);
  padding: 12px 14px 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.pwa-sheet-brand {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff;
  display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(16, 29, 38, .1);
  flex-shrink: 0;
}
.pwa-sheet-brand .brand-mark { width: 34px; height: 34px; }
.pwa-sheet-text { flex: 1 1 auto; min-width: 0; }
.pwa-sheet h2 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.pwa-sheet p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.pwa-ios-steps {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pwa-ios-steps li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}
.pwa-step-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 6px;
  background: var(--accent-wash);
  color: var(--accent);
  display: grid; place-items: center;
}
.pwa-step-icon svg { width: 12px; height: 12px; }
.pwa-sheet-actions {
  flex-basis: 100%;
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.pwa-sheet .btn { min-height: 36px; padding: 8px 12px; font-size: 13px; flex: 1; }
.pwa-sheet #pwa-dismiss-btn {
  flex: 0 0 auto;
  background: none;
  border: none;
  box-shadow: none;
  color: var(--muted);
  text-decoration: underline;
  min-height: auto;
  padding: 8px 4px;
}

/* ---------- Delivery mobile ---------- */
.progress-wrap { margin: 4px 0 16px; }
.progress-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px;
}
.progress-bar {
  height: 8px; background: var(--border); border-radius: 99px; overflow: hidden;
}
.progress-bar .fill {
  height: 100%; background: var(--accent); border-radius: 99px;
  transition: width .25s ease;
}

.section-label {
  font-size: 13px; font-weight: 700; color: var(--muted);
  margin: 18px 0 10px;
}
h2.section-label { font-size: 13px; }

.customer-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  border-left: 3px solid var(--border-strong);
  padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  transition: box-shadow .12s, border-color .12s;
}
.customer-item.pg-hidden,
.customer-item.search-hidden {
  display: none;
}
.offline-banner {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--amber-wash);
  color: var(--amber-text);
  border: 1px solid var(--amber-wash-border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.offline-banner.error {
  background: var(--coral-wash);
  color: var(--coral);
  border-color: var(--coral-wash-border);
}
.filter-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--card);
  color: var(--ink);
}
.customer-item.done {
  background: var(--accent-wash); border-color: var(--accent-wash-border); border-left-color: var(--accent);
}
.customer-item .name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.customer-item .meta a { color: var(--accent-dark); font-weight: 600; }
.deliver-hint { margin: 8px 0 0; font-size: 12px; }
.customer-item .meta-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px;
}
.chip {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 650;
  background: var(--paper); color: var(--muted); border: 1px solid var(--border);
}
.chip.ok { background: var(--accent-wash); color: var(--accent-dark); border-color: var(--accent-wash-border); }
.chip.warn { background: var(--amber-wash); color: var(--amber-text); border-color: var(--amber-wash-border); }
.chip.danger { background: var(--coral-wash); color: var(--coral); border-color: var(--coral-wash-border); }

/* ---------- Stepper (delivery Given/Empties) ---------- */
.deliver-form .stepper-field { flex: 1 1 130px; min-width: 130px; }
.stepper {
  display: flex; align-items: stretch;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--card);
}
.stepper-btn {
  flex: 0 0 40px; border: none; background: var(--wash); color: var(--ink);
  font-size: 19px; font-weight: 700; line-height: 1; cursor: pointer; min-height: 44px;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.stepper-btn:hover { background: var(--accent-wash); color: var(--accent-dark); }
.stepper-btn:active { background: var(--accent-wash); }
.stepper-btn:focus-visible { outline: none; box-shadow: var(--focus); position: relative; z-index: 1; }
.stepper input {
  flex: 1; min-width: 0; width: 100%; text-align: center;
  border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  border-radius: 0; margin: 0; -moz-appearance: textfield; font-weight: 700;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { box-shadow: none; }

/* ---------- Card "More" disclosure (delivery route cards) ---------- */
.card-more { margin: 10px 0 0; }
.card-more > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 6px 2px; min-height: 32px;
}
.card-more > summary::-webkit-details-marker { display: none; }
.card-more > summary::after { content: '▾'; font-size: 9px; }
.card-more[open] > summary::after { content: '▴'; }
.card-more-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------- Completed deliveries disclosure ---------- */
.completed-panel { margin-top: 4px; }
.completed-panel > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  margin: 18px 0 10px; min-height: 32px;
}
.completed-panel > summary::-webkit-details-marker { display: none; }
.completed-panel > summary::after { content: '▾'; font-size: 9px; }
.completed-panel[open] > summary::after { content: '▴'; }

.check-row {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 14px; font-weight: 650; cursor: pointer;
  color: var(--ink);
}
.check-row input[type="checkbox"] {
  width: 18px; height: 18px; margin: 0; flex-shrink: 0;
  accent-color: var(--accent);
  min-height: 0; min-width: 0; padding: 0;
}

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form input, .inline-form select { margin-bottom: 0; }
.inline-form div { flex: 1; min-width: 72px; }
.inline-form label { font-size: 11px; margin-bottom: 4px; }
.inline-form .btn { flex-shrink: 0; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; }
.table-wrap td.cell-zones .chip-list { justify-content: flex-start; }

.check-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2px 14px; margin: 4px 0 12px;
  max-height: 260px; overflow-y: auto;
}
.check-grid .check-row { margin: 0; padding: 5px 0; font-weight: 600; font-size: 13.5px; text-align: left; }
.check-grid .check-row .muted-cell { font-weight: 500; }
details.edit-toggle .check-grid { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }

.deliver-form {
  background: var(--wash); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px; gap: 8px;
}
.deliver-form input { min-height: 44px; font-weight: 600; text-align: center; }
.deliver-form .btn { min-height: 44px; padding: 10px 18px; }

details.edit-toggle { margin-bottom: 6px; }
details.edit-toggle summary { list-style: none; cursor: pointer; }
details.edit-toggle summary::-webkit-details-marker { display: none; }
details.edit-toggle[open] summary { margin-bottom: 10px; }
details.edit-toggle .inline-form { margin-bottom: 8px; }
details.edit-toggle[open] {
  background: var(--wash); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px; margin-top: 6px;
}

.create-panel > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 700; letter-spacing: -0.01em;
  min-height: 44px;
}
.create-panel > summary::-webkit-details-marker { display: none; }
.summary-label { display: inline-flex; align-items: center; gap: 8px; }
.summary-label svg { width: 16px; height: 16px; flex-shrink: 0; }
.create-panel > summary::after {
  content: '+';
  color: var(--muted);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}
.create-panel[open] > summary::after { content: '–'; }
.create-panel[open] > summary { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.disabled-hint { display: block; margin-top: 4px; }

.sticky-bottom {
  position: sticky; bottom: 0;
  background: linear-gradient(to top, var(--paper) 70%, transparent);
  padding: 16px 0 calc(10px + env(safe-area-inset-bottom));
  margin-top: 8px; z-index: 10;
}
.sticky-bottom .btn { min-height: 48px; font-size: 15px; }
.sticky-bottom-stack { display: flex; flex-direction: column; gap: 8px; }
.sticky-bottom-stack form { margin: 0; }
.sticky-bottom-stack .round-form label { margin-bottom: 4px; }
.sticky-bottom-stack .round-form input[type="number"] { margin-bottom: 8px; }
.plain-list { margin: 0 0 12px; padding-left: 18px; }
.plain-list li { margin: 6px 0; }

/* ---------- Responsive tables ---------- */
@media (max-width: 700px) {
  .table-wrap table { min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr:has(th) { display: none; }
  .table-wrap { border: none; border-radius: 0; background: transparent; }
  .table-wrap tbody { display: flex; flex-direction: column; gap: 10px; }
  .table-wrap tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; margin-bottom: 0; background: var(--card); box-shadow: var(--shadow);
  }
  .table-wrap td {
    border-bottom: 1px dashed var(--border); padding: 8px 0;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right;
  }
  .table-wrap td:last-child { border-bottom: none; }
  .table-wrap td::before {
    content: attr(data-label); font-weight: 700; color: var(--muted); font-size: 11px;
    text-transform: uppercase; letter-spacing: .02em; text-align: left; flex-shrink: 0;
  }
  .table-wrap td:empty::after { content: '—'; color: var(--muted); }
  .table-wrap td[data-label=""]::before,
  .table-wrap td:not([data-label])::before { content: none; }
  .table-wrap td[data-label=""]:empty::after,
  .table-wrap td:not([data-label]):empty::after { content: none; }
  .table-wrap td form.inline-form,
  .table-wrap td form { width: 100%; justify-content: flex-end; }
  .table-wrap td > a { margin-left: auto; }
  .table-wrap td .action-group { width: 100%; justify-content: flex-end; }
  .table-wrap td[data-label="Actions"] {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .table-wrap td.cell-zones { flex-wrap: wrap; }
  .table-wrap td.cell-zones > .chip-list,
  .table-wrap td.cell-zones > details.edit-toggle { width: 100%; }
  .check-grid { grid-template-columns: 1fr; max-height: 220px; }
  details.edit-toggle .check-grid { padding: 8px; }

  .table-wrap td.cell-stack {
    display: block; text-align: left;
  }
  .table-wrap td.cell-stack::before {
    display: block; margin-bottom: 4px;
  }
}

/* ---------- Mobile shell: bottom tabs ---------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }

  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--shell); color: #fff;
    padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top));
    position: sticky; top: 0; z-index: 30; box-shadow: var(--shadow);
  }
  .mobile-bar .brand {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700; font-size: 17px;
    display: flex; align-items: center; gap: 8px;
  }
  .mobile-bar .brand .brand-mark { width: 32px; height: 32px; }
  .mobile-bar .btn.logout-btn { width: auto; padding: 8px 14px; font-size: 13px; min-height: 44px; }

  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: auto; flex-direction: row;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 20px rgba(10, 20, 30, .16);
    z-index: 30; border-right: none; border-top: 1px solid rgba(255,255,255,.08);
    overflow: visible;
  }
  .sidebar .brand-block, .sidebar .sidebar-foot { display: none; }
  .side-nav {
    flex-direction: row; justify-content: space-around; padding: 6px 4px 6px 6px; gap: 2px; width: 100%;
    overflow: visible; overflow-y: visible;
  }
  .nav-link {
    flex-direction: column; gap: 3px; padding: 8px 3px; border-radius: 8px;
    font-size: 10.5px; letter-spacing: -0.01em; flex: 1 1 0; min-width: 0; min-height: 52px; text-align: center; width: auto;
  }
  .nav-link span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav-link svg { width: 20px; height: 20px; margin: 0; }
  .nav-link.active { background: var(--accent); }
  .nav-more-toggle { display: flex; }
  .nav-secondary {
    display: none;
    position: absolute;
    left: 8px; right: 8px;
    bottom: calc(100% + 8px);
    background: var(--shell);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 12px;
    padding: 8px;
    margin-top: 0;
    flex-direction: column;
    gap: 2px;
    max-height: min(70vh, 420px);
    overflow-y: auto;
    box-shadow: 0 -8px 32px rgba(10, 20, 30, .28);
    z-index: 40;
  }
  .nav-secondary.open { display: flex; }
  .nav-secondary .nav-link {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    min-height: 44px; text-align: left; font-size: 14px; flex: none; width: 100%;
  }

  .main { padding-bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); }

  .container { padding: 16px 14px 40px; }
  .flash-wrap { padding: 12px 14px 0; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); justify-content: stretch; gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 32px; height: 32px; border-radius: 9px; }
  .stat-icon svg { width: 16px; height: 16px; }
  .stat .value { font-size: 20px; }
  .bar-value { font-size: 10.5px; max-width: 100%; overflow: visible; }
  .bar-chart, .bar-chart-empty { height: 176px; gap: 6px; }
  .linechart, .chart-empty { height: 140px; }
  .card { padding: 14px 14px; }
  .page-header .page-title { font-size: 19px; }
  .row { gap: 10px; }
  .row > div { min-width: 100%; }
  .tile-nav { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
}

@media (max-width: 480px) {
  .container { padding: 14px 12px 36px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  h2, .card h2 { font-size: 13.5px; }
  .deliver-form div:not(.stepper-field) { min-width: calc(33.33% - 6px); }
  .stepper-btn { flex-basis: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- Utilities ---------- */
.flex-2 { flex: 2; }
.field-sm { min-width: 100px; }
.field-md { min-width: 140px; }
.field-wide { min-width: 180px; }
.row-inline { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.card-narrow { max-width: 480px; }
.stat-narrow { max-width: 260px; }
.btn-lg { min-height: 48px; }
.justify-start { justify-content: flex-start; }
.u-mt-0 { margin-top: 0 !important; }
.u-mt-1 { margin-top: var(--space-1) !important; }
.u-mt-2 { margin-top: var(--space-2) !important; }
.u-mt-3 { margin-top: var(--space-3) !important; }
.u-mt-4 { margin-top: var(--space-4) !important; }
.u-mt-5 { margin-top: var(--space-5) !important; }

/* ---------- Confirm dialog ---------- */
.confirm-dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); padding: 20px; max-width: 360px; width: calc(100% - 32px);
  color: var(--ink); background: var(--card);
}
.confirm-dialog::backdrop { background: rgba(10, 20, 30, .45); }
.confirm-dialog-text { margin: 0 0 18px; font-size: var(--fs-md); font-weight: 600; line-height: 1.4; }
.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-dialog-actions .btn { margin: 0; }
.confirm-dialog label { display: block; }
.confirm-dialog input[type="number"] { width: 100%; margin-bottom: 8px; }

.edit-dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); padding: 0; max-width: 640px;
  width: calc(100% - 32px); max-height: calc(100dvh - 24px);
  height: auto; overflow: hidden;
  color: var(--ink); background: var(--card);
}
.edit-dialog::backdrop { background: rgba(10, 20, 30, .45); }
.edit-dialog > form,
.edit-dialog > .edit-dialog-inner {
  padding: 22px 22px 18px; overflow: auto; max-height: calc(100dvh - 24px);
}
.edit-dialog h3 { margin: 0 0 16px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.edit-dialog .row { margin-bottom: 0; }
.edit-dialog .row:last-of-type input,
.edit-dialog .row:last-of-type select { margin-bottom: 0; }
.edit-dialog .hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.edit-dialog .check-grid {
  background: var(--wash); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; margin: 0 0 4px;
}
.edit-dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.edit-dialog-actions .btn { margin: 0; }
.edit-dialog-kicker {
  margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--muted);
}
.edit-dialog-reset {
  background: var(--wash); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 14px;
}
.edit-dialog-reset .row { align-items: flex-end; }
.edit-dialog-reset .btn { margin: 0; flex-shrink: 0; }
