/* Moletole Express — the one stylesheet of the admin panel and the merchant portal.
   A light work UI: neutral greys carry the page, Moletole orange (#FB690C) marks the primary action and
   where you are; text on orange is #140A03 (white on this orange fails contrast). 1px borders, no drop
   shadows except on things that float (dialogs, toasts). Spacing steps: 4 8 12 16 20 24 32 48. */

:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --accent: #fb690c;
  --accent-hover: #e05a05;
  --accent-soft: #fff1e7;
  --accent-text: #b8460a;
  --on-accent: #140a03;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --warning: #a35a00;
  --warning-soft: #fff7e6;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0369a1;
  --info-soft: #eff8ff;
  --radius: 8px;
  --radius-lg: 12px;
  --focus: 0 0 0 3px rgba(251, 105, 12, 0.28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Devanagari", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 236px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; color: var(--text); }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0.01em; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.overline { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.ico { width: 18px; height: 18px; flex: none; }
.alert > .ico { margin-top: 1px; }

/* ---------- layout: admin (sidebar) ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.15; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }
.nav-group { margin-top: 12px; }
.nav-group-title { padding: 0 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 7px;
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
}
.nav-link:hover { background: #f4f4f5; color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-link .ico { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav-link .count {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 600;
  line-height: 18px; text-align: center; background: var(--accent); color: var(--on-accent);
}
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.who { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 999px; flex: none; display: grid; place-items: center;
  background: #f4f4f5; color: var(--text-2); font-weight: 600; font-size: 12px; border: 1px solid var(--border);
}
.who-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.who-role { font-size: 12px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding: 12px 32px; background: rgba(246, 246, 247, 0.92); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; }
.topbar .crumb { color: var(--muted); font-weight: 500; }
.topbar .crumb a { color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar .menu-button, .portal-header .menu-button { display: none; }
.content { padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.content.narrow { max-width: 880px; }

/* ---------- layout: merchant portal (top bar) ---------- */
.portal-header {
  position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border);
}
.portal-header-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 24px; padding: 0 24px; min-height: 60px; }
.portal-header .brand { padding: 0; }
.portal-nav { display: flex; gap: 4px; align-items: center; flex: 1; overflow-x: auto; }
.portal-nav .nav-link { padding: 7px 10px; white-space: nowrap; }
.portal-main { max-width: 1200px; margin: 0 auto; padding: 24px 24px 64px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards, grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.split-wide { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------- stat tiles ---------- */
.stat { padding: 16px 18px; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.is-alert { border-color: #f9c9a8; background: var(--accent-soft); }
.stat.is-alert .stat-value { color: var(--accent-text); }

/* ---------- buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 500 13.5px/1 var(--font); cursor: pointer;
  white-space: nowrap; transition: background-color 120ms ease, border-color 120ms ease;
}
.btn:hover { background: #f4f4f5; text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: #f3c4c4; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #991b1b; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #ededef; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn .ico { width: 16px; height: 16px; }
.link-button { appearance: none; border: 0; background: none; padding: 0; color: var(--accent-text); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 12.5px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 14px/1.4 var(--font);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; }
.select { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2371717a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.input-sm, .select-sm { height: 32px; font-size: 13px; }
.input-group { display: flex; align-items: stretch; }
.input-group .prefix { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.input-group .input { border-radius: 0 var(--radius) var(--radius) 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Checkboxes and radios are drawn here so they look the same everywhere: orange when on, the tick in
   #140A03 (the text colour on orange). Switches (.switch) restyle their checkbox below. */
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0; flex: none; vertical-align: -3px;
  border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
input[type="checkbox"] { border-radius: 4px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5 6.5 11.5 12.5 4.5' fill='none' stroke='%23140a03' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
}
input[type="radio"]:checked { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--surface); }
input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--accent); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: var(--focus); }
input[type="radio"]:checked:focus-visible { box-shadow: inset 0 0 0 3px var(--surface), var(--focus); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.45; cursor: not-allowed; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check input { margin-top: 2px; }
.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.radio-card { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.radio-card:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.radio-card:has(input:focus-visible) { box-shadow: var(--focus); }
.radio-card .rc-title { font-weight: 600; }
.radio-card .rc-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; height: 34px; font-size: 13.5px; }
.toolbar .search { min-width: 240px; flex: 1; max-width: 360px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 36px; height: 20px; margin: 0; border: 0; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background-color 150ms ease; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #fff; transition: transform 150ms ease; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 500; font-size: 12px; color: var(--muted);
  padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: #fafafa; }
.table tbody tr.selected td { background: var(--accent-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.check-cell, .table th.check-cell { width: 36px; padding-right: 0; }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.card > .table-wrap .table th:first-child { border-top-left-radius: var(--radius-lg); }
.card > .table-wrap .table th:last-child { border-top-right-radius: var(--radius-lg); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: #f4f4f5; color: var(--text-2); border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: 0.8; }
.badge.plain::before { display: none; }
.badge.orange { background: var(--accent-soft); color: var(--accent-text); }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.grey { background: #f4f4f5; color: #52525b; }
.badge.outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); }

/* ---------- alerts, empty, loading ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 13.5px; }
.alert.info { background: var(--info-soft); border-color: #cfe7f7; color: #0b4a6f; }
.alert.warn { background: var(--warning-soft); border-color: #f6dfb0; color: #7a4300; }
.alert.danger { background: var(--danger-soft); border-color: #f5cccc; color: #8a1616; }
.alert.success { background: var(--success-soft); border-color: #c4ecd3; color: #0f5d2c; }
.alert .alert-actions { margin-left: auto; display: flex; gap: 8px; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty .empty-title { color: var(--text); font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }
.state-error { padding: 28px 24px; text-align: center; }
.state-error .empty-title { color: var(--danger); font-weight: 600; margin-bottom: 4px; }
.skeleton { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #efeff1 0%, #f7f7f8 40%, #efeff1 80%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton-block { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner { width: 16px; height: 16px; border-radius: 999px; border: 2px solid rgba(0, 0, 0, 0.15); border-top-color: currentColor; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .skeleton, .spinner { animation: none; } * { transition: none !important; } }

/* ---------- key/value, timeline, tabs ---------- */
/* The label column is as wide as its longest label (up to 180px), so narrow side cards keep room for values. */
.kv { display: grid; grid-template-columns: fit-content(180px) minmax(0, 1fr); gap: 8px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.money-lines { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.money-lines .line { display: flex; justify-content: space-between; gap: 12px; }
.money-lines .line.total { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 999px; background: var(--border-strong); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 18px; bottom: -2px; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.current::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline .t-title { font-weight: 500; }
.timeline .t-meta { font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { appearance: none; border: 0; background: none; padding: 10px 12px; font: 500 13.5px var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { margin-left: 6px; font-size: 11.5px; padding: 1px 6px; border-radius: 999px; background: #f4f4f5; color: var(--text-2); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: #ededef; border-radius: 9px; }
.segmented button { appearance: none; border: 0; background: none; padding: 5px 12px; border-radius: 7px; font: 500 13px var(--font); color: var(--text-2); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

/* ---------- dialogs, drawers, toasts ---------- */
dialog { border: 0; padding: 0; border-radius: var(--radius-lg); max-width: min(520px, calc(100vw - 32px)); width: 100%; color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.06); }
dialog::backdrop { background: rgba(24, 24, 27, 0.42); }
dialog.wide { max-width: min(760px, calc(100vw - 32px)); }
.dialog-head { padding: 18px 20px 0; }
.dialog-head h2 { font-size: 16px; }
.dialog-body { padding: 12px 20px 4px; display: flex; flex-direction: column; gap: 12px; color: var(--text-2); max-height: 70vh; overflow-y: auto; }
.dialog-foot { padding: 16px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; max-width: min(560px, 100vw); border-radius: 0; }
dialog.drawer .dialog-body { max-height: none; height: calc(100vh - 140px); }
.toasts { position: fixed; z-index: 1000; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: 10px; background: #18181b; color: #fafafa; font-size: 13.5px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25); animation: toast-in 180ms ease-out; }
.toast.error { background: #7f1d1d; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- maps ---------- */
.map { width: 100%; height: 420px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: #eef0ee; overflow: hidden; }
.map.tall { height: calc(100vh - 160px); min-height: 480px; }
.map.small { height: 240px; }
.leaflet-container { font: 13px/1.4 var(--font); }
.pin { width: 14px; height: 14px; border-radius: 999px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.pin.free { background: #16a34a; }
.pin.busy { background: var(--accent); }
.pin.stale { background: #a1a1aa; }
.pin.offline { background: #d4d4d8; }
.pin.pickup { background: var(--accent); width: 16px; height: 16px; }
.pin.drop { background: #18181b; width: 16px; height: 16px; }
.pin.vertex { width: 12px; height: 12px; background: #fff; border: 2px solid var(--accent); box-shadow: none; cursor: grab; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .pin { width: 10px; height: 10px; border-width: 1px; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; padding: 0 0 20px; }
.auth-card .brand img { width: 40px; height: 40px; border-radius: 10px; }
.auth-card .brand-name { font-size: 18px; }
.auth-card .card { padding: 24px; }
.auth-card h1 { font-size: 18px; margin-bottom: 4px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--muted); }

/* ---------- misc ---------- */
.doc-viewer { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.doc { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.doc-thumb { height: 150px; display: grid; place-items: center; background: #f1f1f3; color: var(--muted); font-size: 13px; }
.doc-thumb img { width: 100%; height: 150px; object-fit: cover; }
.doc-meta { padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.code-block { font-family: var(--mono); font-size: 12px; background: #f4f4f5; border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
.bar { height: 8px; border-radius: 999px; background: #f0f0f2; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- print (labels) ---------- */
.label-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ship-label { background: #fff; border: 1.5px dashed #a1a1aa; border-radius: 10px; padding: 16px; display: grid; grid-template-columns: 1fr 120px; gap: 12px; break-inside: avoid; }
.ship-label .qr { width: 120px; height: 120px; }
.ship-label .tracking { font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: 0.04em; }
.ship-label .cod { display: inline-block; margin-top: 6px; padding: 4px 10px; border-radius: 6px; background: #18181b; color: #fff; font-weight: 700; }
.ship-label .to-name { font-size: 16px; font-weight: 700; }
.ship-label .from { font-size: 12px; color: var(--muted); }
@media print {
  body { background: #fff; }
  .portal-header, .no-print, .toasts { display: none !important; }
  .portal-main { padding: 0; max-width: none; }
  .ship-label { border: 1.5px solid #000; }
  .label-sheet { gap: 10mm; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  /* A laptop: a slimmer sidebar and tighter table cells, so the wide tables fit without scrolling. */
  :root { --sidebar: 208px; }
  .content { padding: 20px 20px 40px; }
  .table th, .table td { padding-left: 8px; padding-right: 8px; }
  .hide-md { display: none !important; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .split-wide { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform 180ms ease; box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: 0 0 48px rgba(0, 0, 0, 0.25); }
  .topbar .menu-button { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px; }
  .doc-viewer { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  body { font-size: 15px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-grid-mobile-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .stat-grid-mobile-2 .stat { padding: 14px; }
  .stat-grid-mobile-2 .stat-value { font-size: 20px; }
  .portal-header-inner { padding: 0 16px; gap: 12px; min-height: 56px; }
  /* With the links folded into the menu, the account button and the menu sit at the right edge. */
  .portal-header .brand { margin-right: auto; }
  .portal-nav { display: none; }
  .portal-nav.open { display: flex; position: fixed; inset: 56px 0 auto 0; flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 16px 32px rgba(0, 0, 0, 0.12); }
  .portal-nav.open .nav-link { padding: 12px; font-size: 15px; }
  .portal-main { padding: 16px 16px 48px; gap: 16px; }
  .page-head h1 { font-size: 20px; }
  .page-head-actions { width: 100%; margin-left: 0; }
  .page-head-actions .btn { flex: 1; }
  .card-pad, .card-body { padding: 16px; }
  .card-head { padding: 12px 16px; }
  .btn, .input, .select { height: 44px; }
  .btn-sm { height: 36px; }
  .toolbar .input, .toolbar .select, .toolbar .search { min-width: 0; width: 100%; max-width: none; flex: 1 1 100%; height: 44px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  /* Tables become a list of cards on a phone. */
  .table.stack-mobile thead { display: none; }
  .table.stack-mobile, .table.stack-mobile tbody, .table.stack-mobile tr, .table.stack-mobile td { display: block; width: 100%; }
  .table.stack-mobile tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table.stack-mobile td { padding: 2px 0; border: 0; text-align: left !important; }
  /* Label on the left, value beside it (a two-line value stays in its column). */
  .table.stack-mobile td[data-label] { display: flex; gap: 8px; align-items: baseline; }
  .table.stack-mobile td[data-label]::before { content: attr(data-label); flex: none; width: 104px; color: var(--muted); font-size: 13px; }
  .table.stack-mobile td[data-label] > * { min-width: 0; }
  .table.stack-mobile td.check-cell { display: none; }
  .label-sheet { grid-template-columns: minmax(0, 1fr); }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
  dialog { max-width: calc(100vw - 24px); }
}
@media (max-width: 720px) {
  .hide-sm { display: none !important; }
  .portal-header .menu-button { display: inline-flex !important; }
}
.card.is-alert { border-color: #f9c9a8; }
.card.is-alert > .card-head { background: var(--accent-soft); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

/* Live map riders (contract §12): the rider's photo (or initials) in a ring coloured by state, a small arrow for
   the heading, faded with the age shown when the location is older than 2 minutes (busy riders too). */
.rider-icon { background: none; border: 0; }
.rider-marker { position: relative; width: 36px; height: 36px; color: #a1a1aa; }
.rider-marker.free, .rider-marker.stale { color: #16a34a; }
.rider-marker.busy { color: var(--accent); }
.rider-marker .rm-ring {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; border-radius: 999px;
  border: 3px solid currentColor; background: #f4f4f5; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.rider-marker .rm-ring img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rider-marker .rm-initials { font: 600 12px/1 var(--font); color: var(--text-2); }
.rider-marker .rm-heading { position: absolute; inset: -9px; pointer-events: none; }
.rider-marker .rm-heading::before {
  content: ""; position: absolute; left: 50%; top: 0; margin-left: -5px;
  border: 5px solid transparent; border-top: 0; border-bottom: 7px solid currentColor;
}
.rider-marker.faded .rm-ring { opacity: 0.6; }
.rider-marker.faded .rm-ring img, .rider-marker.faded .rm-initials { filter: grayscale(0.8); opacity: 0.8; }
.rider-marker .rm-age {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 3px; padding: 0 6px;
  border-radius: 999px; background: rgba(24, 24, 27, 0.8); color: #fff; font: 600 10.5px/16px var(--font); white-space: nowrap;
}
.rider-marker.selected .rm-ring { box-shadow: 0 0 0 3px #fff, 0 0 0 5px currentColor, 0 1px 6px rgba(0, 0, 0, 0.4); }
.legend-ring { display: inline-block; width: 12px; height: 12px; border-radius: 999px; border: 3px solid #a1a1aa; background: #f4f4f5; }
.legend-ring.free, .legend-ring.stale { border-color: #16a34a; }
.legend-ring.busy { border-color: var(--accent); }
.legend-ring.stale { opacity: 0.5; }
.avatar.photo { overflow: hidden; }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.faded { opacity: 0.5; }
.live-age { font-variant-numeric: tabular-nums; }
.live-age.late { color: var(--warning); font-weight: 600; }
/* Assign dialogs: distance from the pickup and the location's age (grey past 30 minutes). */
.candidate .where { margin-top: 3px; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.candidate .where-distance { font-weight: 600; color: var(--text); }
.candidate .where-age.old { color: var(--muted); }
