/*
 * IGO Multi-Dealership ERP — design system.
 * Same visual language as the IGO Coco Pith Factory ERP: one forest-green accent on white surfaces over a pale
 * neutral backdrop, Geist type, hairline borders, a grouped sidebar with a solid green active pill.
 * Theme follows the system unless the user picks one (data-theme on <html>).
 */

:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: rgba(20, 40, 28, 0.05);
  --border: rgba(20, 40, 28, 0.1);
  --border-strong: rgba(20, 40, 28, 0.2);
  --hairline: rgba(20, 40, 28, 0.08);
  --text: #14231b;
  --text-muted: #4f6157;
  --text-faint: #76867c;

  --accent: #1b8a4b;
  --accent-hover: #167a41;
  --accent-ink: #17743f;
  --accent-soft: rgba(27, 138, 75, 0.12);
  --accent-contrast: #ffffff;

  /* Second brand colour: Jain Irrigation. Green Pro uses the accent. */
  --jain: #d98a3d;
  --jain-ink: #9a5b0a;
  --jain-soft: rgba(217, 138, 61, 0.16);

  --danger: #b3382a;
  --danger-soft: rgba(179, 56, 42, 0.12);
  --warning: #9a5b0a;
  --warning-soft: rgba(224, 160, 40, 0.2);
  --info: #2b6a8f;
  --info-soft: rgba(43, 95, 139, 0.12);
  --neutral-soft: rgba(20, 40, 28, 0.06);

  --ring: 0 0 0 2px #ffffff, 0 0 0 4px #1b8a4b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 40, 28, 0.06);
  --shadow-md: 0 12px 30px -14px rgba(20, 40, 28, 0.25);

  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --chart-grid: rgba(20, 40, 28, 0.1);
  --chart-axis: #76867c;

  color-scheme: light;
  font-family: var(--font-sans);
}

:root[data-theme='dark'] {
  --bg: #0e1411;
  --surface: #141c17;
  --surface-raised: #19231d;
  --surface-sunken: rgba(0, 0, 0, 0.3);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.2);
  --hairline: rgba(255, 255, 255, 0.07);
  --text: #e8efe9;
  --text-muted: #a9b8ae;
  --text-faint: #7f9085;
  --accent: #3dbb78;
  --accent-hover: #52c98a;
  --accent-ink: #5fd197;
  --accent-soft: rgba(61, 187, 120, 0.16);
  --accent-contrast: #06150c;
  --jain: #e6a25c;
  --jain-ink: #eab452;
  --jain-soft: rgba(230, 162, 92, 0.18);
  --danger: #f08577;
  --danger-soft: rgba(240, 133, 119, 0.15);
  --warning: #eab452;
  --warning-soft: rgba(234, 180, 82, 0.15);
  --info: #86b9e3;
  --info-soft: rgba(134, 185, 227, 0.15);
  --neutral-soft: rgba(255, 255, 255, 0.07);
  --ring: 0 0 0 2px #0e1411, 0 0 0 4px #3dbb78;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 18px 40px -16px rgba(0, 0, 0, 0.7);
  --chart-grid: rgba(255, 255, 255, 0.1);
  --chart-axis: #7f9085;
  color-scheme: dark;
}

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

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; margin: 0 0 4px; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
p { margin: 0; text-wrap: pretty; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.num, table { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.i { font-size: 18px; line-height: 1; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-contrast);
  text-decoration: none; font-weight: 600; transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

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

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 500; line-height: 1;
  padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-raised); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
button:hover:not(:disabled), .btn:hover { background: var(--neutral-soft); border-color: var(--text-faint); }
button:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary, button[type='submit'] {
  background: var(--accent); border-color: transparent; color: var(--accent-contrast); font-weight: 600;
}
.btn-primary:hover:not(:disabled), button[type='submit']:hover:not(:disabled) { background: var(--accent-hover); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--neutral-soft); border-color: transparent; color: var(--text); }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; font-weight: 600; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.icon-btn {
  position: relative; width: 38px; height: 38px; padding: 0;
  border-color: transparent; background: transparent; color: var(--text-muted); border-radius: var(--radius-md);
}
.icon-btn:hover:not(:disabled) { background: var(--neutral-soft); border-color: transparent; color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 7px; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 1;
}

/* ---- fields ------------------------------------------------------- */

input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 11px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-raised); color: var(--text); width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input[type='checkbox'] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
.field input, .field select, .field textarea { font-weight: 400; }
.req { color: var(--danger); }
.hint { font-size: 12px; font-weight: 400; color: var(--text-faint); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-section { margin: 0 0 6px; padding: 0; border: none; }
.form-section > legend { padding: 0; margin-bottom: 10px; font-size: 12px; font-weight: 600; color: var(--text-faint); letter-spacing: 0.04em; text-transform: uppercase; }
.form-section + .form-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--hairline); }
.check-row { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; background: var(--surface-raised);
}
.check-chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

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

.shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100dvh;
  display: flex; flex-direction: column; gap: 8px; padding: 18px 12px 14px;
  background: var(--surface-raised); border-right: 1px solid var(--hairline);
  overflow-y: auto; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; text-decoration: none; color: var(--text); }
.brand-mark { width: 38px; height: 38px; border-radius: var(--radius-md); flex: none; }
.brand-text { display: grid; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.brand-text small { font-size: 12px; color: var(--text-muted); }
.nav { display: grid; gap: 16px; flex: 1; align-content: start; }
.nav-group-name { margin: 0 0 4px; padding: 0 10px; font-size: 11.5px; font-weight: 600; color: var(--text-faint); letter-spacing: 0.02em; }
.nav-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; justify-content: flex-start; gap: 11px; width: 100%; height: 40px; padding: 0 12px;
  border: none; border-radius: var(--radius-md); background: transparent;
  color: var(--text-muted); font-size: 14px; font-weight: 500; text-align: left;
}
.nav-item:hover:not(:disabled) { background: var(--neutral-soft); color: var(--text); border: none; }
.nav-item.active, .nav-item.active:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item .count {
  margin-left: auto; min-width: 22px; padding: 2px 7px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; text-align: center; background: var(--neutral-soft); color: var(--text-muted);
}
.nav-item.active .count { background: var(--surface-raised); color: var(--accent-ink); }
.nav-item .count.alert { background: var(--danger-soft); color: var(--danger); }
.nav-item.active .count.alert { background: var(--surface-raised); color: var(--danger); }
.tagline { margin: 8px 8px 0; font-size: 11.5px; color: var(--text-faint); }

.column { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.menu-btn { display: none; }
.search {
  position: relative; flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 40px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); background: var(--surface-raised); color: var(--text-faint);
}
.search:focus-within { box-shadow: var(--ring); }
.search input { flex: 1; border: none; background: transparent; padding: 0; height: 100%; min-width: 0; box-shadow: none !important; }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--surface-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: 50;
}
.results button { width: 100%; justify-content: flex-start; padding: 9px 10px; border: none; background: transparent; }
.results button:hover:not(:disabled) { background: var(--neutral-soft); border: none; }
.results small { margin-left: auto; color: var(--text-faint); }
.scope { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.scope select { width: auto; max-width: 260px; height: 40px; padding-right: 30px; font-weight: 500; border-radius: var(--radius-md); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.user { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 8px; }
.avatar {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 12.5px; font-weight: 700; flex: none;
}
.user-text { display: grid; line-height: 1.2; }
.user-text b { font-size: 13.5px; font-weight: 600; }
.user-text small { font-size: 11.5px; color: var(--text-muted); }
.main { width: 100%; max-width: 1480px; padding: 26px 28px 64px; }
.scrim { display: none; }

/* demo tools popover */
.popover-wrap { position: relative; }
.popover {
  position: absolute; top: calc(100% + 8px); right: 0; width: 320px; padding: 16px;
  background: var(--surface-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); z-index: 60;
}
.popover h3 { margin-bottom: 4px; }
.popover .persona-list { display: grid; gap: 6px; margin-top: 12px; }
.persona { justify-content: space-between; width: 100%; font-weight: 500; }
.persona small { color: var(--text-faint); font-weight: 500; }

/* ---- page chrome -------------------------------------------------- */

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header p { color: var(--text-muted); max-width: 64ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 20px; }

.panel { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel-head p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.link-btn { padding: 0; border: none; background: none; color: var(--accent-ink); font-weight: 600; font-size: 13px; }
.link-btn:hover:not(:disabled) { background: none; border: none; text-decoration: underline; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.stat-label { font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius-md); background: var(--neutral-soft); color: var(--text-muted); }
.stat-icon.accent { background: var(--accent-soft); color: var(--accent-ink); }
.stat-icon.warn { background: var(--warning-soft); color: var(--warning); }
.stat-icon.bad { background: var(--danger-soft); color: var(--danger); }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-hint { font-size: 12.5px; color: var(--text-faint); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { width: 100%; height: 260px; }
.chart-loading { height: 100%; display: grid; place-items: center; color: var(--text-faint); font-size: 13px; }

/* ---- badges ------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 7px; border-radius: 4px;
  font-size: 12px; font-weight: 550; line-height: 1.5; white-space: nowrap;
  background: var(--neutral-soft); color: var(--text-muted);
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.positive { background: var(--accent-soft); color: var(--accent-ink); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.negative { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.jain { background: var(--jain-soft); color: var(--jain-ink); }

/* ---- tables ------------------------------------------------------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .search { max-width: 360px; flex: 1 1 240px; }
.toolbar select { width: auto; min-width: 180px; height: 40px; border-radius: var(--radius-md); }
.toolbar .spacer { margin-left: auto; font-size: 12.5px; color: var(--text-muted); }
.table-wrap { overflow-x: auto; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table th {
  background: color-mix(in srgb, var(--surface-sunken) 70%, var(--surface-raised));
  color: var(--text-muted); font-weight: 600; font-size: 12px; white-space: nowrap;
}
.table tbody tr { transition: background-color 0.12s ease; }
.table tbody tr:hover { background: color-mix(in srgb, var(--neutral-soft) 55%, transparent); }
.table { min-width: 0; table-layout: auto; }
.table td { white-space: normal; overflow-wrap: anywhere; }
.table td .badge, .table td .btn-sm, .table td .row-actions { white-space: nowrap; overflow-wrap: normal; }
.table th, .table td { padding: 10px 12px; }
.table td.right .row-actions .btn-sm { padding: 0 9px; }
.table-compact-actions .btn-label { display: none; }
@media (max-width: 1500px) { .row-actions .btn-label { display: none; } }
.main { min-width: 0; }
.table td.log-detail { white-space: normal; min-width: 260px; }
.table .right { text-align: right; }
.table .cell-person { display: flex; align-items: center; gap: 10px; }
.table .cell-person b { display: block; font-weight: 600; }
.table .cell-person small { display: block; color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }
.table .sub { display: block; font-size: 12.5px; color: var(--text-faint); }
.table tr.low { background: var(--danger-soft); box-shadow: inset 3px 0 0 var(--danger); }
.table tr.low:hover { background: color-mix(in srgb, var(--danger-soft) 140%, transparent); }
.table tr.flash { animation: rowGlow 3s ease-out both; }
@keyframes rowGlow {
  0%, 70% { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  100% { background: transparent; box-shadow: inset 3px 0 0 transparent; }
}
.table-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); }
.empty { padding: 44px 24px; text-align: center; color: var(--text-muted); }
.empty .i { font-size: 30px; color: var(--text-faint); margin-bottom: 8px; display: block; }
.empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.log-detail { max-width: 52ch; color: var(--text-muted); }

/* ---- cards -------------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.d-card { display: flex; flex-direction: column; gap: 14px; }
.d-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.d-card-head h3 { font-size: 16px; margin-top: 6px; }
.d-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; padding-top: 14px; border-top: 1px solid var(--hairline); font-size: 13px; }
.d-meta dt { font-size: 12px; color: var(--text-faint); margin-bottom: 2px; }
.d-meta dd { margin: 0; font-weight: 500; }
.d-card-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; border-top: 1px solid var(--hairline); }
.unit-card { display: flex; flex-direction: column; gap: 12px; }
.unit-card + .unit-card { margin-top: 14px; }
.unit-tag { display: inline-block; width: 4px; height: 100%; }

.feed { display: grid; gap: 0; max-height: 380px; overflow-y: auto; }
.feed-item { padding: 11px 0; border-bottom: 1px solid var(--hairline); }
.feed-item:last-child { border-bottom: none; }
.feed-item .row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.feed-item .row b { font-weight: 600; }
.feed-item .row time { color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }
.feed-item p { margin-top: 2px; font-size: 13px; color: var(--text-muted); }

/* ---- modal -------------------------------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(10, 20, 14, 0.5);
}
.modal {
  width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); animation: pop 0.18s ease-out both;
}
.modal.sm { max-width: 460px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px 22px 14px; border-bottom: 1px solid var(--hairline); }
.modal-head p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--hairline); }
.notice { display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius-sm); background: var(--neutral-soft); font-size: 13px; color: var(--text-muted); }
.notice.warn { background: var(--warning-soft); color: var(--warning); }
.notice.bad { background: var(--danger-soft); color: var(--danger); }
.confirm-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--danger-soft); color: var(--danger); font-size: 22px; margin-bottom: 12px; }
.confirm-icon.ok { background: var(--accent-soft); color: var(--accent-ink); }

/* ---- scanner ------------------------------------------------------ */

.scan-view { position: relative; min-height: 260px; border-radius: var(--radius-md); background: #0b120e; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#qrScannerReader { width: 100%; height: 260px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#qrScannerReader video { object-fit: cover !important; width: 100% !important; height: 100% !important; }
.scan-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px; text-align: center; color: #a9b8ae; font-size: 13px; }
.scan-placeholder b { color: #e8efe9; font-weight: 600; }
.scan-placeholder .i { font-size: 32px; color: #3dbb78; }
.reticle { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.reticle div { position: relative; width: 220px; height: 180px; border: 2px solid rgba(61, 187, 120, 0.6); border-radius: 12px; }
.reticle i { position: absolute; left: 8px; right: 8px; height: 2px; background: linear-gradient(90deg, transparent, #3dbb78, transparent); animation: scanLaser 2.2s ease-in-out infinite; }
@keyframes scanLaser { 0%, 100% { top: 8%; } 50% { top: 88%; } }
.scan-status { position: absolute; left: 12px; bottom: 10px; padding: 4px 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); color: #5fd197; font-size: 12px; font-weight: 500; }
.scan-switch { position: absolute; right: 12px; bottom: 8px; padding: 6px 10px; background: rgba(0, 0, 0, 0.6); color: #fff; border-color: rgba(255, 255, 255, 0.2); font-size: 12px; }
.scan-switch:hover:not(:disabled) { background: rgba(0, 0, 0, 0.8); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 10px; font-family: var(--font-mono); font-size: 12px; }
.chip.low { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.scan-result { border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 16px; display: grid; gap: 12px; }
.scan-result.ok { border-color: var(--accent); background: var(--accent-soft); }
.scan-result.low { border-color: var(--danger); background: var(--danger-soft); }
.scan-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-raised); text-align: center; }
.scan-stats small { display: block; font-size: 11.5px; color: var(--text-faint); margin-bottom: 2px; }
.scan-stats b { font-size: 18px; font-weight: 600; }
.lookup { display: flex; gap: 8px; }
.lookup input { text-transform: uppercase; font-family: var(--font-mono); }

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

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 14px;
  background: var(--surface-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); font-size: 13.5px;
  animation: pop 0.18s ease-out both;
}
.toast .i { font-size: 20px; }
.toast.ok .i { color: var(--accent); }
.toast.err .i { color: var(--danger); }

/* ---- responsive --------------------------------------------------- */

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 272px; transform: translateX(-102%);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1); box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 39; border: none; border-radius: 0; background: rgba(10, 20, 14, 0.45); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 14px; gap: 6px; }
  .user-text { display: none; }
  .search { display: none; }
  .scope { margin-left: 0; flex: 1; min-width: 0; }
  .scope select { max-width: none; width: 100%; }
  .main { padding: 18px 14px 56px; }
  .popover { right: -60px; }
}

@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .stats { gap: 10px; }
  .stat-value { font-size: 24px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .table td { white-space: nowrap; }
  .toasts { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: none; }
  .popover { position: fixed; top: 60px; left: 14px; right: 14px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---- admin additions ---------------------------------------------- */

.attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.attn-item {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); white-space: normal;
}
.attn-item:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.attn-item .stat-icon { flex: none; }
.attn-item b { display: block; font-weight: 600; margin-bottom: 2px; }
.attn-item span { color: var(--text-muted); font-size: 13px; font-weight: 400; }
.attn-ok { display: flex; align-items: center; gap: 10px; color: var(--accent-ink); font-weight: 500; padding: 6px 2px; }

.bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius-md);
  background: var(--accent-soft); color: var(--accent-ink); font-size: 13.5px;
}
.bulk-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--neutral-soft); align-self: start; width: fit-content; }
.seg button { border: none; background: transparent; padding: 7px 14px; border-radius: 8px; color: var(--text-muted); font-weight: 500; }
.seg button:hover:not(:disabled) { background: transparent; border: none; color: var(--text); }
.seg button.active { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.role-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); }
.role-card b { display: block; font-weight: 600; }
.role-card span { font-size: 12.5px; color: var(--text-muted); }
.role-card .n { float: right; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

.perm-table th:not(:first-child), .perm-table td:not(:first-child) { text-align: center; }
.perm-table td:first-child { font-weight: 500; }
.perm { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 99px; font-size: 14px; }
.perm.yes { background: var(--accent-soft); color: var(--accent-ink); }
.perm.part { background: var(--warning-soft); color: var(--warning); }
.perm.no { color: var(--text-faint); }

.date-field { flex-direction: row; align-items: center; gap: 8px; }
.date-field input { width: auto; height: 40px; border-radius: var(--radius-md); }
.row-actions { display: inline-flex; gap: 6px; }

/* ---- sales -------------------------------------------------------- */

.modal.wide { max-width: 860px; }
.totals { display: grid; gap: 6px; margin-top: 18px; margin-left: auto; max-width: 340px; font-size: 14px; }
.totals .row { display: flex; justify-content: space-between; gap: 16px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.totals .row.grand { padding-top: 8px; border-top: 1px solid var(--border); color: var(--text); font-size: 17px; font-weight: 600; }
.line-select { min-width: 220px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 20px; margin-bottom: 18px; }
.kv dt { font-size: 12px; color: var(--text-faint); margin-bottom: 2px; }
.kv dd { margin: 0; font-weight: 500; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.history li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--hairline); font-size: 13px; }
.history li:last-child { border-bottom: none; }
.history time { color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }
.history b { font-weight: 600; }
.doc-section { margin-top: 20px; }
.doc-section h3 { margin-bottom: 8px; font-size: 12px; color: var(--text-faint); letter-spacing: 0.04em; text-transform: uppercase; }
@media (max-width: 640px) { .history li { grid-template-columns: 1fr; gap: 2px; } }

@media print {
  body > *:not(#docModal) { display: none !important; }
  #docModal { position: static; background: none; padding: 0; display: block !important; }
  #docModal .modal { max-height: none; box-shadow: none; border: none; animation: none; }
  #docModal .modal-foot, #docModal .modal-head .icon-btn { display: none; }
  #docModal .modal-body { overflow: visible; }
}

/* ---- leads -------------------------------------------------------- */

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.board-col { background: color-mix(in srgb, var(--surface-sunken) 60%, var(--bg)); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px; min-height: 140px; }
.board-col.drop { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-soft); }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 4px 6px 10px; }
.board-head b { font-weight: 600; font-size: 13.5px; }
.board-head span { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.lead-card {
  display: grid; gap: 6px; width: 100%; padding: 12px; margin-bottom: 8px; text-align: left; white-space: normal;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); cursor: grab;
}
.lead-card:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-raised); }
.lead-card.dragging { opacity: 0.45; }
.lead-card b { font-weight: 600; font-size: 14px; }
.lead-card .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.lead-card .when { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 7px; border-radius: 4px; width: fit-content; background: var(--neutral-soft); color: var(--text-muted); }
.lead-card .when.today { background: var(--warning-soft); color: var(--warning); }
.lead-card .when.late { background: var(--danger-soft); color: var(--danger); }
.board-empty { padding: 18px 8px; text-align: center; font-size: 12.5px; color: var(--text-faint); }

.stages { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.stage-pill { padding: 5px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 500; border: 1px solid var(--border-strong); color: var(--text-faint); background: transparent; }
.stage-pill.done { color: var(--accent-ink); border-color: transparent; background: var(--accent-soft); }
.stage-pill.now { color: var(--accent-contrast); border-color: transparent; background: var(--accent); font-weight: 600; }
.stage-pill.lost { color: var(--danger); border-color: transparent; background: var(--danger-soft); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--hairline); }
.timeline li:last-child { border-bottom: none; }
.timeline .dot { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--neutral-soft); color: var(--text-muted); }
.timeline .dot.stage { background: var(--accent-soft); color: var(--accent-ink); }
.timeline p { font-size: 13.5px; }
.timeline small { color: var(--text-faint); font-size: 12px; }
@media (max-width: 1180px) { #tab-leads .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }

/* ---- sign in ------------------------------------------------------ */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 28px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); display: grid; gap: 14px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-brand b { display: block; font-size: 18px; letter-spacing: -0.02em; }
.login-brand small { color: var(--text-muted); }
.login-card form { display: grid; gap: 12px; }
.login-btn { width: 100%; height: 42px; justify-content: center; }
.login-error { margin: 0; padding: 9px 12px; border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.credentials { margin: 14px 0 0; padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-sunken); font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }

.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: none; background: transparent; color: var(--text-muted); border-radius: var(--radius-md); }
.pw-toggle:hover:not(:disabled) { background: var(--neutral-soft); border: none; color: var(--text); }

/* ---- portal shell (Step 2: public/portal.js and public/modules/*.js; every class here starts with portal-) ---------- */
.portal-form { display: grid; gap: 14px; }
.portal-form-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 12px 14px; }
.portal-span { grid-column: 1 / -1; }
.portal-check { flex-direction: row; align-items: center; gap: 8px; }
.portal-field-error { color: var(--danger); font-size: 12px; font-weight: 500; }
.portal-form-foot { display: flex; justify-content: flex-end; gap: 8px; }
.portal-pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.portal-sort { padding: 2px 6px; margin: -2px -6px; font-weight: 600; text-transform: inherit; letter-spacing: inherit; color: inherit; }
.portal-spin { animation: portal-spin 0.9s linear infinite; display: inline-block; }
@keyframes portal-spin { to { transform: rotate(360deg); } }
.portal-kv { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: 6px 14px; font-size: 13.5px; margin: 0; }
.portal-kv dt { color: var(--text-muted); }
.portal-kv dd { margin: 0; overflow-wrap: anywhere; }
.portal-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.portal-tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--text-muted); padding: 8px 12px; }
.portal-tabs button[aria-selected='true'] { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.portal-perm-module { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: 10px; }
.portal-perm-module > b { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; text-transform: capitalize; }
.portal-perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.portal-perm-list label { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 2px 0; }
.portal-perm-list small { display: block; color: var(--text-faint); }
.portal-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 640px) {
  .portal-form-grid { grid-template-columns: minmax(0, 1fr); }
  .portal-kv { grid-template-columns: minmax(0, 1fr); }
}
/* ---- catalogue, territories and authorisations (public/modules/catalogue.js, territories.js, authorisations.js; classes start with az-) ---- */
.az-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.az-step { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; color: var(--text-muted); }
.az-step b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--border); color: var(--text); font-size: 12px; }
.az-step.done { color: var(--text); }
.az-step.done b { background: var(--accent); color: #fff; }
.az-step.current { border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.az-step.current b { background: var(--accent); color: #fff; }

/* ---- Dealer onboarding (modules onboarding*, agreements, dealer-crm): prefix onb- ---- */
.onb-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.onb-note { margin: 10px 0; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border)); border-radius: var(--radius-md); background: var(--warning-soft); font-size: 13px; }
.onb-note ul { margin: 6px 0 0; padding-left: 18px; }
.onb-secret { display: grid; gap: 10px; }
.onb-password { font-size: 16px; letter-spacing: 0.04em; user-select: all; padding: 2px 6px; background: var(--neutral-soft); border-radius: 4px; }
.onb-history { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.onb-history .sub { display: block; font-size: 12.5px; color: var(--text-muted); }
.onb-document { margin: 10px 0 0; padding: 14px; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 var(--font-mono); background: var(--neutral-soft); border-radius: var(--radius-md); }
.onb-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.onb-column { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px; display: grid; gap: 8px; min-width: 0; }
.onb-column > header { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; }
.onb-card { text-align: left; display: grid; gap: 2px; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; overflow-wrap: anywhere; }
.onb-card:hover { border-color: var(--accent); }
.onb-card .sub { font-size: 12.5px; color: var(--text-muted); }
@media (max-width: 640px) { .onb-board { grid-auto-columns: minmax(78vw, 1fr); } }

/* ---- Logistics, warehouses, support, employees (modules logistics, warehouses, support, employees): prefixes lgx-, sup-, emp- ---- */
.lgx-lines { display: grid; gap: 8px; margin: 6px 0; }
.lgx-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lgx-line input { flex: 1 1 120px; min-width: 0; }
.lgx-line > span { flex: 2 1 160px; min-width: 0; overflow-wrap: anywhere; }
.lgx-neg { color: var(--danger); }
.lgx-pos { color: var(--accent-ink); }
.lgx-files { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 6px; overflow-wrap: anywhere; }
.lgx-upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.lgx-upload select, .lgx-upload input[type='file'] { width: auto; max-width: 100%; }
.lgx-timeline { margin: 0; padding: 0 0 0 18px; display: grid; gap: 10px; border-left: 2px solid var(--border); list-style: none; }
.lgx-timeline li { position: relative; }
.lgx-timeline li::before { content: ''; position: absolute; left: -24px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.lgx-timeline .sub, .sup-thread .sub, .sup-events .sub { display: block; font-size: 12.5px; color: var(--text-muted); }

.sup-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.sup-stat { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); display: grid; gap: 2px; text-align: left; }
.sup-stat b { font-size: 22px; }
.sup-stat span { font-size: 12.5px; color: var(--text-muted); }
.sup-stat.bad b { color: var(--danger); }
.sup-stat.warn b { color: var(--warning); }
.sup-thread { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.sup-msg { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow-wrap: anywhere; white-space: pre-wrap; }
.sup-msg.internal { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); }
.sup-msg.system { background: var(--neutral-soft); font-size: 13px; }
.sup-events { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13.5px; }
.sup-sla { display: grid; gap: 6px; }
.sup-compose { display: grid; gap: 8px; margin-top: 12px; }
.sup-compose textarea { width: 100%; }
.sup-stars { display: inline-flex; gap: 4px; }
.sup-stars button[aria-pressed='true'] { background: var(--accent); color: var(--accent-contrast); }

.emp-note { margin: 10px 0; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border)); border-radius: var(--radius-md); background: var(--warning-soft); font-size: 13px; }
.emp-password { font: 16px var(--font-mono); letter-spacing: 0.04em; user-select: all; padding: 2px 6px; background: var(--neutral-soft); border-radius: 4px; overflow-wrap: anywhere; }
.emp-bar { height: 8px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.emp-bar > i { display: block; height: 100%; background: var(--accent); }
.emp-perms { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; max-height: 220px; overflow: auto; }
.emp-perms li { font: 12px var(--font-mono); padding: 2px 8px; border-radius: 999px; background: var(--neutral-soft); }

/* ---- Notifications, reports, renewals (modules notifications, reports, renewals): prefixes ntf-, rpt-, ren- ---- */
.ntf-pop { width: min(360px, calc(100vw - 24px)); max-height: 70vh; overflow: auto; padding: 12px; }
.ntf-pop-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.ntf-pop h3 { margin: 0; }
.ntf-item { display: grid; gap: 2px; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font-weight: 500; }
.ntf-item:hover { background: var(--neutral-soft); }
.ntf-unread { background: var(--accent-soft); font-weight: 600; }
.ntf-title { overflow-wrap: anywhere; }
.ntf-meta { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.ntf-none { padding: 12px 4px; }
.ntf-all { width: 100%; margin-top: 8px; justify-content: center; }
.ntf-channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.ntf-channel { display: grid; gap: 4px; padding: 12px 14px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); }
.ntf-h { margin-top: 20px; }

.rpt-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.rpt-nav { display: grid; gap: 2px; position: sticky; top: 12px; }
.rpt-group { margin: 12px 0 4px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.rpt-item { text-align: left; justify-content: flex-start; border-color: transparent; background: transparent; padding: 8px 10px; font-weight: 500; color: var(--text-muted); }
.rpt-item:hover { background: var(--neutral-soft); color: var(--text); }
.rpt-item[aria-current='true'] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.rpt-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.rpt-main > * { min-width: 0; }
.rpt-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.rpt-filters .field { margin: 0; }
.rpt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rpt-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.rpt-summary:empty { display: none; }
.rpt-card { display: grid; gap: 2px; padding: 12px 14px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); }
.rpt-card b { font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.rpt-card-label { font-size: 12px; color: var(--text-muted); }

.ren-flow { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; }
.ren-step { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-raised); color: var(--text-faint); font-size: 13px; }
.ren-dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--neutral-soft); font-size: 12px; font-weight: 600; }
.ren-done { color: var(--text); } .ren-done .ren-dot { background: var(--accent); color: var(--accent-contrast); }
.ren-now { color: var(--accent-ink); border-color: var(--accent); font-weight: 600; } .ren-now .ren-dot { background: var(--accent-soft); color: var(--accent-ink); }
.ren-facts { display: grid; grid-template-columns: minmax(130px, 220px) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.ren-facts dt { color: var(--text-muted); font-size: 13px; }
.ren-facts dd { margin: 0; overflow-wrap: anywhere; }
.ren-note { margin-bottom: 4px; } .ren-bad { border-color: var(--danger); }
.ren-bad-text { color: var(--danger); }
.ren-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ren-events .sub { display: block; }
.ren-actions { align-items: center; }
@media (max-width: 760px) {
  .rpt-layout { grid-template-columns: minmax(0, 1fr); }
  .rpt-nav { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-bottom: 6px; }
  .rpt-group { display: none; }
  .ren-facts { grid-template-columns: minmax(0, 1fr); } .ren-facts dd { margin-bottom: 6px; }
}
/* the three pages above: let wide tables scroll inside their own wrapper instead of stretching the page on a phone */
.portal-module[data-module='notifications'], .portal-module[data-module='reports'], .portal-module[data-module='renewals'] { grid-template-columns: minmax(0, 1fr); }
.portal-module[data-module='notifications'] > *, .portal-module[data-module='reports'] > *, .portal-module[data-module='renewals'] > *, .rpt-layout > *, .ntf-channels > * { min-width: 0; }
/* ---- Commerce, commission and finance (modules commission, settlements, dealer-accounts, order-flow; prefix cmx-) -------------- */
.cmx-pre { margin: 6px 0 0; padding: 8px 10px; background: var(--neutral-soft); border-radius: var(--radius-md); font: 12px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.cmx-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.cmx-list li .sub, .cmx-timeline li .sub { display: block; }
.cmx-timeline { margin: 0 0 0 4px; padding: 0 0 0 16px; list-style: none; display: grid; gap: 12px; border-left: 2px solid var(--border); }
.cmx-timeline li { position: relative; }
.cmx-timeline li::before { content: ''; position: absolute; left: -22px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.cmx-checks { display: grid; gap: 6px; margin: 6px 0 14px; }
.cmx-neg { color: var(--danger); }
.portal-module[data-module='commission'], .portal-module[data-module='settlements'], .portal-module[data-module='dealer-accounts'], .portal-module[data-module='order-flow'] { grid-template-columns: minmax(0, 1fr); }
.portal-module[data-module='commission'] > *, .portal-module[data-module='settlements'] > *, .portal-module[data-module='dealer-accounts'] > *, .portal-module[data-module='order-flow'] > * { min-width: 0; }
/* ---- Role dashboards (module dashboard-home, public/modules/dashboard-kit.js; prefix dsh-) ---- */
.dsh-scope { margin: 0 0 12px; color: var(--text-muted, inherit); font-size: 13px; }
.dsh-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0 0 16px; }
.dsh-field { display: grid; gap: 4px; font-size: 12px; min-width: 0; }
.dsh-field > span { font-weight: 600; }
.dsh-field select, .dsh-field input { max-width: 100%; }
.dsh-bar-end { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dsh-stamp { font-size: 12px; opacity: 0.75; }
.dsh-live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.dsh-body { display: grid; gap: 20px; min-width: 0; }
.dsh-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.dsh-kpi { text-align: left; font: inherit; color: inherit; min-width: 0; }
.dsh-kpi .stat-value { overflow-wrap: anywhere; }
button.dsh-click { cursor: pointer; }
button.dsh-click:hover, button.dsh-click:focus-visible { border-color: var(--accent); }
.dsh-delta { font-size: 12px; margin-top: 4px; }
.dsh-delta.up { color: var(--accent); }
.dsh-delta.down { color: var(--danger); }
.dsh-delta.flat { opacity: 0.7; }
.dsh-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 20px; }
.dsh-chart { min-width: 0; }
.dsh-chart-box { width: 100%; height: 260px; min-width: 0; }
.dsh-chart-box.dsh-chart-fallback { height: auto; }
.dsh-bars { display: grid; gap: 8px; }
.dsh-bar-row { display: grid; grid-template-columns: minmax(70px, 30%) minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; }
.dsh-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsh-bar-track { background: var(--neutral-soft); border-radius: 6px; height: 10px; overflow: hidden; }
.dsh-bar-track i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.dsh-tables { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.dsh-table { min-width: 0; }
.dsh-table-wrap { overflow-x: auto; max-width: 100%; }
.dsh-table-actions { display: flex; gap: 8px; }
.dsh-more { margin: 8px 0 0; }
.dsh-actions { flex-wrap: wrap; }
.portal-module[data-module='dashboard-home'] { grid-template-columns: minmax(0, 1fr); }
.portal-module[data-module='dashboard-home'] > * { min-width: 0; }
@media (max-width: 600px) { .dsh-bar-end { margin-left: 0; } .dsh-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dsh-chart-box { height: 220px; } }

/* ---- uiv- UI verification fixes: keep every portal module inside the viewport (a wide table or tab bar must scroll, not widen the page) ---- */
#tab-portal, #portalHost, .portal-module { min-width: 0; max-width: 100%; }
.portal-module { grid-template-columns: minmax(0, 1fr); }
.portal-module > * { min-width: 0; max-width: 100%; }
.portal-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
.portal-tabs button { white-space: nowrap; flex: 0 0 auto; }
.page-header > div { min-width: 0; }
.page-header h1, .page-header p { overflow-wrap: anywhere; }
@media (max-width: 640px) { .main { padding-left: 14px; padding-right: 14px; } .page-header { gap: 12px; } .page-header .actions, .page-header > div:last-child:not(:first-child) { flex-wrap: wrap; } }.cards { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
.attention { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.role-grid { grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); }
.portal-perm-list { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.portal-detail-grid { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.ntf-channels { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.stat-hint { white-space: normal; overflow-wrap: anywhere; }.dsh-table-actions { flex-wrap: wrap; }

.tab-content.stack { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.tab-content > * { min-width: 0; max-width: 100%; }
.toolbar > * { min-width: 0; }
.stat-label, .stat-value { overflow-wrap: anywhere; }
@media (max-width: 480px) { .dsh-kpis { grid-template-columns: minmax(0, 1fr); } .stats { grid-template-columns: minmax(0, 1fr); } .stat-value { font-size: 24px; } }
.d-card-foot, .d-card-foot .row-actions { flex-wrap: wrap; }

.table-wrap { position: relative; }

/* Original pages: hide the write actions the signed-in person's roles do not hold (the server enforces the same rules) */
.no-ws-manage #tab-dealerships .page-actions, .no-ws-manage #tab-dealerships button[onclick^="openEditDealershipModal"], .no-ws-manage #tab-dealerships button[onclick^="toggleDealershipStatus"] { display: none; }
.no-users-manage #tab-users .page-actions button[onclick*="openCsvImportModal"], .no-users-manage #tab-users .page-actions button[onclick*="openCreateUserModal"], .no-users-manage #tab-users td .row-actions { display: none; }.no-ws-manage #tab-dashboard button[onclick^="openAddDealershipModal"], .no-users-manage #tab-dashboard button[onclick^="openCreateUserModal"],
.no-inventory-write #tab-inventory button[onclick^="openProductModal"], .no-inventory-write #tab-inventory button[onclick^="openStockImportModal"], .no-inventory-write #tab-inventory button[onclick^="openAdjustModal"],
.no-leads-write #tab-leads button[onclick^="openLeadModal"], .no-customers-write #tab-customers button[onclick^="openCustomerModal"],
.no-quotations-write button[onclick^="openQuoteModal"], .no-payments-write button[onclick^="openPaymentModal"] { display: none; }
/* Warehouse workspace (public/modules/wh-workspace.js) */
.whx-switch{display:inline-flex;align-items:center;gap:8px;margin:0 0 12px;font-size:13px}
.whx-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;margin:0 0 16px}
.whx-card{border:1px solid var(--line,#dfe5df);border-radius:12px;padding:14px 16px;background:var(--card,#fff)}
.whx-card h3{margin:0 0 4px;font-size:14px}.whx-card p{margin:2px 0}
.whx-big{font-size:26px;font-weight:700;line-height:1.2}
.whx-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:16px;margin-top:12px}
.whx-wh{border:1px solid var(--line,#dfe5df);border-radius:12px;overflow:hidden;background:var(--card,#fff)}
.whx-photo{display:block;width:100%;height:170px;object-fit:cover;background:#eef3ee}
.whx-nophoto{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;color:#6b7a6b;font-size:13px}
.whx-nophoto .i{font-size:30px}
.whx-wh-body{padding:12px 14px}.whx-wh-body h3{margin:0;font-size:16px}.whx-wh-body p{margin:4px 0}
.whx-nums{font-weight:600}
.whx-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
.whx-scroll{overflow-x:auto;margin-top:12px}
.whx-low{color:#b42318;font-weight:600}
.whx-stock{width:100%;border-collapse:collapse;table-layout:auto}
.whx-stock th,.whx-stock td{text-align:left;padding:10px 12px;border-bottom:1px solid var(--line,#e5e7eb);vertical-align:middle}
.whx-stock th{font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:#667085;white-space:nowrap}
.whx-stock th.num,.whx-stock td.num{text-align:right;white-space:nowrap}
.whx-stock td:last-child{text-align:right;width:1%}
.whx-lines{display:grid;gap:6px;margin-bottom:6px}
.whx-line{display:grid;grid-template-columns:1fr 2fr 70px 90px auto;gap:6px}
.whx-items{border:1px solid var(--line,#dfe5df);border-radius:10px;padding:8px 10px;margin:10px 0}
@media (max-width:640px){.whx-line{grid-template-columns:1fr 1fr}}

/* Requirements and quotation approvals (public/modules/requirements.js) */
.reqx-item{display:grid;grid-template-columns:2fr 1.4fr 1fr .8fr auto;gap:6px;margin-bottom:6px}
.reqx-namebox{position:relative}.reqx-namebox input[type=text]{width:100%}
.reqx-suggest{position:absolute;left:0;top:100%;z-index:30;min-width:100%;width:max-content;max-width:min(520px,90vw);max-height:240px;overflow:auto;background:#fff;border:1px solid #d0d5dd;border-radius:8px;box-shadow:0 8px 24px rgba(16,24,40,.15);margin-top:2px}
.reqx-sug{display:flex;justify-content:space-between;gap:16px;padding:8px 12px;cursor:pointer;font-size:.9rem}.reqx-sug:hover{background:#f2f4f7}
.reqx-sug-q{font-size:.75rem;font-weight:600;white-space:nowrap}.reqx-sug-q.ok{color:#067647}.reqx-sug-q.low{color:#b42318}
.reqx-qline{display:grid;grid-template-columns:1.6fr 2fr .7fr .8fr .6fr;gap:6px;align-items:center;margin-bottom:8px;padding-bottom:8px;border-bottom:1px solid var(--line,#dfe5df)}
.reqx-qline .sub{grid-column:1 / -1}
.reqx-block{margin:0 0 14px}.reqx-block p{margin:4px 0}.reqx-total{font-weight:700}
.reqx-hist{margin:4px 0 0;padding-left:18px;font-size:13px;color:#4a5a4a}
@media (max-width:760px){.reqx-item,.reqx-qline{grid-template-columns:1fr 1fr}}

.reqx-ok{background:#e8f5e9;color:#1b5e20;border-radius:8px;padding:8px 10px;font-weight:600}

.reqx-steps{list-style:none;margin:6px 0 0;padding:0;display:grid;gap:4px}
.reqx-steps li{padding:4px 8px;border-left:3px solid #cfd8cf;font-size:13.5px}
.reqx-steps li.done{border-color:#2e7d32}.reqx-steps li.current{border-color:#f9a825;background:#fff8e1}
.reqx-steps li.rejected{border-color:#c62828;background:#fdecea;color:#7f1d1d}.reqx-steps li.pending{color:#8a968a}

.so-item{display:grid;grid-template-columns:minmax(120px,2.2fr) minmax(56px,.8fr) minmax(56px,.8fr) minmax(76px,1fr) minmax(56px,.7fr) minmax(88px,1.1fr) auto;gap:8px;align-items:center;margin-bottom:8px}
.so-item input{min-width:0;width:100%}
.so-head{font-size:12px;font-weight:600;color:#667085;text-transform:uppercase;letter-spacing:.03em;margin-bottom:4px}
.inv-item{display:grid;grid-template-columns:minmax(110px,2fr) minmax(70px,1fr) minmax(64px,.9fr) minmax(48px,.7fr) minmax(48px,.7fr) minmax(52px,.8fr) minmax(46px,.6fr) minmax(62px,.9fr) minmax(76px,1fr) 32px;gap:6px;align-items:center;margin-bottom:8px}
.inv-item input{min-width:0;width:100%}
