/* FreshkaRoute web portal
 * Brand green + route orange on cream (the brand sheet), minimal "Swiss" layout.
 * The logos themselves are in assets/brand/, built by tools/build-brand.py.
 * All colors, spacing, and sizes come from the tokens below; components
 * never use raw hex values. See docs/design-system.md.
 */

:root {
  /* Brand */
  --color-primary: #1f5c3d;          /* brand green, 7.9:1 on white */
  --color-primary-hover: #174a31;
  --color-primary-soft: #e3efe7;
  --color-on-primary: #ffffff;
  --color-accent: #a9500f;           /* route orange, deepened for text: 5.5:1 on white */
  --color-accent-soft: #fcebdd;
  --color-brand-orange: #ec8739;     /* the logo's orange: decoration only, too light for text */
  --color-brand-cream: #f6f2e7;

  /* Surfaces and text */
  --color-bg: #f8f5ee;               /* the brand cream, a shade lighter */
  --color-surface: #ffffff;
  --color-surface-muted: #fbf9f4;
  --color-text: #1e281f;             /* the brand's near-black */
  --color-heading: #1f5c3d;
  --color-muted: #52606d;            /* 6.3:1 on white */
  --color-border: #d9e5da;
  --color-border-strong: #b8cbbb;

  /* Status (each also paired with an icon or text, never color alone) */
  --color-success: #15803d;
  --color-success-soft: #dcfce7;
  --color-warning: #b45309;          /* 5.0:1 on white */
  --color-warning-soft: #fef3c7;
  --color-danger: #b91c1c;           /* 6.5:1 on white */
  --color-danger-soft: #fee2e2;
  --color-info: #1d4ed8;
  --color-info-soft: #dbeafe;
  --color-neutral-soft: #eef2ee;

  --color-focus: #1f5c3d;

  /* Type: device fonts load instantly, even offline */
  --font-sans: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --text-xs: 0.8125rem;   /* 13px, labels only */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --leading: 1.5;

  /* Spacing (dense dashboard scale) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 83, 45, 0.06);
  --shadow: 0 1px 3px rgba(20, 83, 45, 0.08), 0 4px 12px rgba(20, 83, 45, 0.05);
  --shadow-lg: 0 10px 30px rgba(20, 45, 30, 0.18);

  --sidebar-width: 248px;
  --topbar-height: 60px;
  --tap: 44px;             /* minimum touch target */
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--color-heading); line-height: 1.25; margin: 0; }
h1 { font-size: var(--text-2xl); font-weight: 700; }
h2 { font-size: var(--text-lg); font-weight: 650; }
h3 { font-size: var(--text-base); font-weight: 650; }
p { margin: 0; }

a { color: var(--color-primary); text-underline-offset: 2px; }
a:hover { color: var(--color-primary-hover); }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; }

.muted { color: var(--color-muted); }
.text-sm { font-size: var(--text-sm); }
.nowrap { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); color: var(--color-on-primary); }

.btn-secondary { background: var(--color-surface); color: var(--color-heading); border-color: var(--color-border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-muted); border-color: var(--color-primary); }

.btn-danger { background: var(--color-surface); color: var(--color-danger); border-color: #f1b8b8; }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-soft); border-color: var(--color-danger); }

.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover:not(:disabled) { background: var(--color-neutral-soft); }

.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-sm); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--tap); height: var(--tap);
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: var(--color-neutral-soft); }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */

/* align-content keeps the label and input at their natural height: side by side
 * in a .field-row, a taller neighbour would otherwise stretch these rows apart. */
.field { display: grid; gap: var(--space-1); align-content: start; }
.field + .field, .field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: var(--space-4); }
.field-row { display: grid; gap: var(--space-4); }
/* Side by side, the row's gap already separates them; the stacking margin above
 * would push the second column down and misalign the two labels. */
.field-row > .field + .field { margin-top: 0; }
@media (min-width: 640px) { .field-row { grid-template-columns: 1fr 1fr; } }

.label { font-weight: 600; font-size: var(--text-sm); color: var(--color-text); }
.label .optional { font-weight: 400; color: var(--color-muted); }
.hint { font-size: var(--text-sm); color: var(--color-muted); }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.input:hover { border-color: var(--color-muted); }
.input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.2); }
.input[aria-invalid="true"] { border-color: var(--color-danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.18); }

.input-group { position: relative; }
.input-group .input { padding-right: calc(var(--tap) + var(--space-1)); }
.input-group .icon-btn { position: absolute; right: 0; top: 0; color: var(--color-muted); }

.input-prefix { position: relative; }
.input-prefix > span {
  position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  color: var(--color-muted); pointer-events: none;
}
.input-prefix .input { padding-left: calc(var(--space-3) + 1.1em); }

.field-error {
  display: flex; gap: var(--space-1); align-items: flex-start;
  font-size: var(--text-sm); color: var(--color-danger); font-weight: 500;
}

.checkbox { display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--color-primary); flex: none; }
.checkbox .hint, .choice .hint { display: block; }

/* A set of radio options laid out as tappable rows (e.g. add or remove stock). */
.choices { display: grid; gap: var(--space-2); }
.choice {
  display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer;
  padding: var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}
.choice input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--color-primary); flex: none; }
.choice:hover { border-color: var(--color-muted); }
.choice:has(input:checked) { border-color: var(--color-primary); background: var(--color-primary-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* Photo picker: preview on the left, the button and file name on the right. */
.photo-field { display: flex; gap: var(--space-4); align-items: flex-start; margin-bottom: var(--space-4); }
.photo-field .label { display: block; margin-bottom: var(--space-2); }
.photo-frame {
  width: 96px; height: 96px; flex: none;
  border-radius: var(--radius); overflow: hidden;
  background: var(--color-surface-muted);
  border: 1px dashed var(--color-border-strong);
}
.photo-preview { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A class that sets display beats the browser's own [hidden] rule, so say it again. */
.photo-preview[hidden], .photo-placeholder[hidden] { display: none; }
.photo-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: var(--color-muted); }
.photo-placeholder .icon { width: 28px; height: 28px; }
.hint-error { color: var(--color-danger); font-weight: 500; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
/* float takes the legend out of the fieldset border, so a section divider can't cross it */
legend { float: left; width: 100%; font-weight: 650; color: var(--color-heading); font-size: var(--text-base); padding: 0; margin-bottom: var(--space-3); }
legend + * { clear: both; }

/* ---------- alerts, badges ---------- */

.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: var(--text-sm);
}
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--color-danger-soft); border-color: #f5b5b5; color: #7f1d1d; }
.alert-info { background: var(--color-info-soft); border-color: #b9cdf6; color: #1e3a8a; }
.alert-success { background: var(--color-success-soft); border-color: #a7e3b9; color: #14532d; }
.alert-warning { background: var(--color-warning-soft); border-color: #f3d58a; color: #78350f; }

.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs); font-weight: 600; line-height: 1.4;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-success { background: var(--color-success-soft); color: #14532d; }
.badge-warning { background: var(--color-warning-soft); color: #78350f; }
.badge-danger { background: var(--color-danger-soft); color: #7f1d1d; }
.badge-info { background: var(--color-info-soft); color: #1e3a8a; }
.badge-neutral { background: var(--color-neutral-soft); color: #374151; }
.badge-accent { background: var(--color-accent-soft); color: #713f12; }

/* ---------- cards, stats ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.card-header h2 { display: flex; align-items: center; gap: var(--space-2); }
.card-body { padding: var(--space-4) var(--space-5); }

.stats { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 960px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.stat {
  display: grid; gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
}
.stat-label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-muted); font-weight: 600; }
.stat-value { font-size: var(--text-2xl); font-weight: 700; color: var(--color-heading); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-note { font-size: var(--text-sm); color: var(--color-muted); }
.stat-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; }
.stat-icon.tone-success { background: var(--color-success-soft); color: var(--color-success); }
.stat-icon.tone-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.stat-icon.tone-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.stat-icon.tone-info { background: var(--color-info-soft); color: var(--color-info); }
.stat-icon.tone-accent { background: var(--color-accent-soft); color: var(--color-accent); }

/* minmax(0, 1fr): let columns shrink below their content's width (tables, long emails)
   instead of pushing the page wider than the screen. */
.grid-2 { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- lists ---------- */

.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
}
.item-list li:first-child { border-top: 0; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: var(--text-sm); color: var(--color-muted); }
.item-end { text-align: right; flex: none; }

.thumb {
  width: 44px; height: 44px; flex: none;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-primary-soft);
}
.thumb-placeholder {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
}

.empty {
  display: grid; justify-items: center; gap: var(--space-2);
  padding: var(--space-6) var(--space-5);
  text-align: center; color: var(--color-muted);
}
.empty .icon { width: 28px; height: 28px; color: var(--color-border-strong); }

.skeleton {
  background: linear-gradient(90deg, var(--color-neutral-soft) 25%, #f7faf6 50%, var(--color-neutral-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.qty-up { color: var(--color-success); font-weight: 600; font-variant-numeric: tabular-nums; }
.qty-down { color: var(--color-danger); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- tables (become stacked cards on phones) ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  text-align: left; font-weight: 600; color: var(--color-muted);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

@media (max-width: 767px) {
  /* Every part becomes a block so the table can't size itself wider than the screen. */
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
  .table-stack tr:last-child { border-bottom: 0; }
  /* Label on the left, value on the right. Each cell holds a single value element. */
  .table-stack td { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); padding: var(--space-1) 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .table-stack td::before { content: attr(data-label); flex: none; font-weight: 600; color: var(--color-muted); text-align: left; }
  .table-stack td.actions { justify-content: stretch; padding-top: var(--space-3); }
  .table-stack td.actions::before { content: none; }
  .table-stack td.actions .btn { flex: 1; min-height: var(--tap); }
  .table-stack td.actions .icon-btn { flex: none; }
}

/* ---------- filter toolbar, product cell, paging ---------- */

.toolbar {
  display: grid; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
@media (min-width: 768px) { .toolbar { grid-template-columns: 2fr 1fr 1fr; align-items: center; } }

.toolbar-search { position: relative; }
.toolbar-search .input { padding-left: calc(var(--space-3) + 1.6em); }
.toolbar-search-icon {
  position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  color: var(--color-muted); pointer-events: none;
}

/* Tabs that filter a list. Scroll sideways on a phone rather than wrapping
 * into a block that pushes the list off the first screen. */
.tabs {
  display: flex; gap: var(--space-1);
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
}
.tab {
  display: flex; align-items: center; gap: var(--space-2);
  flex: none;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  font: inherit; font-weight: 600;
  color: var(--color-muted);
  background: none; border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--color-text); }
.tab[aria-selected="true"] { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* The slot grid: a row per half hour, a column per unloading zone. Each cell
 * is a button showing how full that slot is, colour-coded but never by colour
 * alone — the numbers say the same thing. */
.slot-grid th { text-align: center; }
.slot-grid th:first-child, .slot-grid td:first-child { text-align: left; }
.slot-grid td { padding: var(--space-1); text-align: center; }
.slot-grid tbody th { font-weight: 600; color: var(--color-muted); background: var(--color-surface-muted); }

.slot-cell {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2);
  font: inherit; font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.slot-cell:hover { border-color: var(--color-muted); }
.slot-free    { background: var(--color-surface);      color: var(--color-muted); }
.slot-partial { background: var(--color-info-soft);    color: var(--color-info); border-color: var(--color-info); }
.slot-full    { background: var(--color-warning-soft); color: var(--color-warning); border-color: var(--color-warning); }
.slot-closed  { background: var(--color-neutral-soft); color: var(--color-muted); text-decoration: line-through; }

/* Totals row under a table of produce. */
.table tfoot th, .table tfoot td {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border-strong);
  text-align: left;
  font-weight: 650;
}
@media (max-width: 767px) {
  .table-stack tfoot, .table-stack tfoot tr, .table-stack tfoot th, .table-stack tfoot td { display: block; width: 100%; }
  .table-stack tfoot th { display: none; }
  .table-stack tfoot td { display: flex; justify-content: space-between; padding: var(--space-3) var(--space-4); }
  .table-stack tfoot td::before { content: attr(data-label); font-weight: 600; color: var(--color-muted); }
}

/* Thumbnail beside the produce name inside a table cell. */
.cell-product { display: flex; align-items: center; gap: var(--space-3); min-width: 0; text-align: left; }

.pager { display: flex; align-items: center; justify-content: center; gap: var(--space-4); }

/* ---------- app shell ---------- */

.shell { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-width);
  display: flex; flex-direction: column;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  transform: translateX(-100%);
  transition: transform 220ms var(--ease);
}
.sidebar.open { transform: none; box-shadow: var(--shadow-lg); }

.brand {
  display: flex; align-items: center; gap: var(--space-2);
  height: var(--topbar-height);
  padding: 0 var(--space-5);
  font-weight: 750; font-size: var(--text-lg); color: var(--color-heading);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
}
/* The name is long, so the sidebar logo is sized by width, with room on both sides. */
.brand-logo { display: block; height: auto; width: 100%; max-width: 184px; }

.nav { flex: 1; overflow-y: auto; padding: var(--space-3); }
.nav-section { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-muted); padding: var(--space-4) var(--space-3) var(--space-2); }
.nav a {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text); text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--color-surface-muted); color: var(--color-heading); }
.nav a[aria-current="page"] { background: var(--color-primary-soft); color: var(--color-heading); font-weight: 650; }
.nav a[aria-current="page"] .icon { color: var(--color-primary); }

.sidebar-foot { padding: var(--space-3); border-top: 1px solid var(--color-border); }
.user-chip { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); }
.avatar {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--color-accent-soft); color: var(--color-accent); font-weight: 700;
}
.user-chip .item-sub { text-transform: capitalize; }

.backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(15, 30, 20, 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 200ms var(--ease);
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--space-3);
  height: var(--topbar-height);
  padding: 0 var(--space-4);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--color-border);
}
.bell { position: relative; }
.bell-count {
  position: absolute; top: 4px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--color-danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice-list li { padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border); }
.notice-list li:last-child { border-bottom: 0; }
.notice-list .unread .item-title::before { content: "● "; color: var(--color-primary); }
.topbar-mark { display: flex; flex: none; }
.topbar-mark img { display: block; height: 30px; width: auto; }
.topbar-title { font-weight: 650; color: var(--color-heading); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { padding: var(--space-5) var(--space-4) var(--space-7); max-width: 1200px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.page-head p { color: var(--color-muted); margin-top: var(--space-1); }
.stack > * + * { margin-top: var(--space-5); }

@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .backdrop, .menu-toggle, .topbar-mark { display: none; }   /* the sidebar shows the logo */
  .content { margin-left: var(--sidebar-width); min-width: 0; }
  .main { padding: var(--space-6) var(--space-6) var(--space-7); }
  .topbar { padding: 0 var(--space-6); }
}

/* ---------- dialog ---------- */

dialog.modal {
  width: min(440px, calc(100vw - 2 * var(--space-4)));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--color-text);
}
dialog.modal::backdrop { background: rgba(15, 30, 20, 0.45); }
/* A line of context above the first field, e.g. "In stock now: 35 bundles". */
.modal-lead { margin: 0 0 var(--space-4); color: var(--color-muted); }

/* Courier assignment inside the order dialog. */
.courier-section { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-border); display: grid; gap: var(--space-3); }
.courier-section > .btn { justify-self: start; }
.section-title { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-base); color: var(--color-heading); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.modal-body { padding: var(--space-5); }
.modal-body p + p { margin-top: var(--space-2); }
/* An explanation above the first question needs room, or the two run together. */
.modal-body p + .field, .modal-body .alert + .field { margin-top: var(--space-4); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-muted); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- toast ---------- */

.toasts {
  position: fixed; z-index: 60;
  left: 50%; bottom: var(--space-5); transform: translateX(-50%);
  display: grid; gap: var(--space-2);
  width: min(420px, calc(100vw - 2 * var(--space-4)));
}
.toast {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: #1c2b22; color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); font-weight: 500;
  animation: toast-in 180ms var(--ease);
}
.toast.error { background: #7f1d1d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- auth pages ---------- */

.auth {
  min-height: 100vh;
  display: grid;
}
@media (min-width: 960px) { .auth { grid-template-columns: minmax(360px, 5fr) 7fr; } }

.auth-aside {
  display: none;
  flex-direction: column; justify-content: space-between;
  padding: var(--space-7) var(--space-6);
  background:
    radial-gradient(circle at 20% 110%, rgba(236, 135, 57, 0.28), transparent 55%),
    linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: var(--color-brand-cream);
}
@media (min-width: 960px) { .auth-aside { display: flex; } }
.auth-aside .brand { border: 0; padding: 0; color: #fff; height: auto; }
.auth-aside .brand-logo { width: 420px; max-width: 100%; }
.auth-aside h2 { color: var(--color-brand-cream); font-size: var(--text-2xl); max-width: 22ch; }
.auth-aside ul { list-style: none; padding: 0; margin: var(--space-5) 0 0; display: grid; gap: var(--space-4); }
.auth-aside li { display: flex; gap: var(--space-3); align-items: flex-start; max-width: 42ch; }
.auth-aside li .icon { color: #f5b37e; margin-top: 2px; }   /* light orange, 4.4:1 on the green */
.auth-aside .foot { font-size: var(--text-sm); color: #cfe3d6; }

.auth-main {
  display: grid; place-items: center;
  padding: var(--space-6) var(--space-4);
}
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 640px; }
.auth-card > .brand { border: 0; padding: 0; height: auto; margin-bottom: var(--space-6); }
.auth-card > .brand { justify-content: center; }
.auth-card > .brand .brand-logo { width: 240px; max-width: 80%; }
@media (min-width: 960px) { .auth-card > .brand { display: none; } }
.auth-card h1 { margin-bottom: var(--space-2); }
.auth-card .lead { color: var(--color-muted); margin-bottom: var(--space-5); }
.auth-card form > .alert { margin-bottom: var(--space-4); }
.auth-card .card { padding: var(--space-5); }
.auth-foot { margin-top: var(--space-5); text-align: center; font-size: var(--text-sm); color: var(--color-muted); }
.auth-foot p + p { margin-top: var(--space-2); }

.form-section + .form-section { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--color-border); }

/* ---------- charts (assets/js/charts.js) ---------- */

.chart-bars { display: grid; gap: var(--space-2); }
.chart-row { display: grid; grid-template-columns: 7.5rem 1fr 4.5rem; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
.chart-label { color: var(--color-muted); font-variant-numeric: tabular-nums; }
.chart-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--color-text); }
.chart-track { height: 14px; border-radius: 4px; background: var(--color-surface-muted); outline-offset: 2px; }
.chart-bar { height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--color-primary); }
.chart-plot { position: relative; margin-left: 2.5rem; margin-top: var(--space-3); border-bottom: 1px solid var(--color-border); }
.chart-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--color-border); }
.chart-grid span { position: absolute; right: calc(100% + 6px); top: -0.6em; font-size: var(--text-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.chart-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.chart-col-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline-offset: 2px; }
.chart-col { width: 100%; max-width: 24px; min-height: 0; border-radius: 4px 4px 0 0; background: var(--color-primary); }
.chart-x { display: flex; gap: 2px; margin-left: 2.5rem; padding-top: var(--space-1); }
.chart-x span { flex: 1; text-align: center; font-size: var(--text-xs); color: var(--color-muted); white-space: nowrap; overflow: visible; }
.chart-tip { position: absolute; z-index: 60; pointer-events: none; padding: var(--space-2) var(--space-3); border-radius: 8px; background: var(--color-text); color: var(--color-surface); font-size: var(--text-sm); box-shadow: var(--shadow-lg); }
.chart-table { margin-top: var(--space-3); font-size: var(--text-sm); }
.chart-table summary { cursor: pointer; color: var(--color-primary); }
.map-box { height: 360px; border-radius: 8px; overflow: hidden; border: 1px solid var(--color-border); }
@media (max-width: 600px) { .chart-row { grid-template-columns: 5.5rem 1fr 3.5rem; } }
