/* IOMS One — premium ledger UI
   Palette: porcelain surface, ink-navy sidebar, brass/gold accent, emerald (credit) / wine (debit) */
:root {
  --paper: #f6f4ef;
  --surface: #ffffff;
  --ink: #191c22;
  --ink-soft: #5c6270;
  --ink-faint: #9a9faa;

  --gold: #a9812e;
  --gold-bright: #c89a3e;
  --gold-soft: #f3e9d2;

  --green: #12664f;
  --green-soft: #e1eee8;
  --rust: #8a2b3c;
  --rust-soft: #f3e1e4;
  --amber: var(--gold);
  --amber-soft: var(--gold-soft);

  --sidebar-bg: #12151c;
  --sidebar-bg-2: #171b24;
  --sidebar-ink: #c7cad3;
  --sidebar-ink-dim: #767c8c;
  --sidebar-active: #1e2330;

  --line: #e7e2d6;
  --line-strong: #d7d0be;
  --radius: 10px;
  --sidebar-w: 232px;
  --shadow-sm: 0 1px 2px rgba(17, 19, 24, .05);
  --shadow-md: 0 10px 26px -10px rgba(17, 19, 24, .22), 0 2px 8px rgba(17, 19, 24, .06);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* Slim, understated scrollbar instead of the browser's chunky default */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background-color: var(--line-strong); background-clip: content-box;
  border: 2px solid transparent; border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--gold); }
*::-webkit-scrollbar-corner { background: transparent; }

/* The sidebar/drawer sit on a dark background — their own scrollbar needs a light thumb */
.sidebar, .cat-drawer { scrollbar-color: rgba(255, 255, 255, .22) transparent; }
.sidebar::-webkit-scrollbar-thumb, .cat-drawer::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, .22); }
.sidebar::-webkit-scrollbar-thumb:hover, .cat-drawer::-webkit-scrollbar-thumb:hover { background-color: var(--gold-bright); }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 500; margin: 0 0 .5rem; }
h1 { font-family: var(--font-display); font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 17px; }

/* Money — the signature: ruled, right-aligned tabular figures like a cash-book column */
.money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right;
  white-space: nowrap;
}
td.money, th.money { border-left: 1px solid var(--line); }
.money.cr { color: var(--green); }
.money.dr { color: var(--rust); }

/* generic helper text — used both inside .field and standalone throughout the app */
.hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }
.hint.warn { color: var(--rust); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg) 65%);
  color: var(--sidebar-ink);
  padding: 18px 12px 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: 4px 0 26px rgba(8, 9, 12, .2);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 16px;
  font-family: var(--font-display);
  font-size: 19px;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  color: #1a1509;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-size: 14px; font-weight: 700;
  box-shadow: 0 3px 10px rgba(169, 129, 46, .3);
}
.sidebar .brand-name { font-family: var(--font-display); font-size: 16.5px; color: #fff; line-height: 1.2; }
.sidebar .brand-sub { font-size: 10.5px; color: var(--sidebar-ink-dim); letter-spacing: .06em; text-transform: uppercase; margin-top: 1px; }
.nav-label {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--sidebar-ink-dim); padding: 14px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: 8px;
  color: var(--sidebar-ink); font-size: 14px;
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-item:hover { background: rgba(255, 255, 255, .05); text-decoration: none; color: #fff; }
.nav-item.active {
  background: var(--sidebar-active); color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gold-bright);
}
.nav-item.active svg { opacity: 1; color: var(--gold-bright); }

/* module tabs — only shown when a tenant/role has both Bookkeeping and Catalog & Orders.
   Icon-only by design: the active module's full name shows as .module-title below instead,
   which sidesteps fitting "Catalog & Orders" as text into a ~100px half-width tab. */
.module-tabs {
  display: flex; gap: 4px; margin: 8px 0 6px; padding: 3px;
  background: rgba(255, 255, 255, .04); border-radius: 9px;
}
.module-tab {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 10px 6px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sidebar-ink-dim);
}
.module-tab svg { width: 19px; height: 19px; }
.module-tab:hover { color: #fff; }
.module-tab.active { background: var(--sidebar-active); color: var(--gold-bright); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }

.module-title {
  font-family: var(--font-display); font-size: 15px; font-weight: 600; color: #fff;
  padding: 6px 10px 10px; letter-spacing: -.005em;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.topbar .page-title { font-family: var(--font-display); font-size: 19px; font-weight: 500; letter-spacing: -.005em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hamburger { display: none; }

.content { padding: 22px; max-width: 1180px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; cursor: pointer;
  min-height: 38px;
  box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--gold); color: var(--gold); background: var(--surface); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: linear-gradient(155deg, var(--gold-bright), var(--gold));
  border-color: transparent; color: #1b1607; font-weight: 600;
  box-shadow: 0 3px 10px rgba(169, 129, 46, .28);
}
.btn-primary:hover { filter: brightness(1.04); color: #1b1607; border-color: transparent; }
.btn-danger { color: var(--rust); border-color: var(--rust); background: var(--surface); }
.btn-danger:hover { color: var(--rust); border-color: var(--rust); background: var(--rust-soft); }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(150deg, #2b3040, var(--ink));
  color: var(--gold-bright);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  border: 1px solid var(--line-strong);
}

/* +New dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 5px; min-width: 190px;
  box-shadow: var(--shadow-md);
  display: none; z-index: 60;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 7px;
  color: var(--ink); font-size: 14px;
}
.dropdown-menu a:hover { background: var(--paper); text-decoration: none; }
.dropdown-menu .sep { border-top: 1px solid var(--line); margin: 5px 0; }

/* ---------- Cards / metrics ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.metric .label { font-size: 12.5px; color: var(--ink-soft); }
.metric .value {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 500; margin-top: 2px; letter-spacing: -.005em;
  font-variant-numeric: tabular-nums;
}
.metric.alert { border-left: 3px solid var(--rust); border-radius: 0 var(--radius) var(--radius) 0; }
.metric.good { border-left: 3px solid var(--green); border-radius: 0 var(--radius) var(--radius) 0; }

/* stamp pill for closing balances */
.stamp {
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 6px;
  padding: 2px 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  transform: rotate(-1deg);
}
.stamp.cr { color: var(--green); }
.stamp.dr { color: var(--rust); }

/* ---------- Status tabs (e.g. Orders: All / Pending / Confirmed / ...) ---------- */
.status-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.status-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 12px; border-radius: 99px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-soft); font-size: 13.5px; font-weight: 500;
}
.status-tab:hover { border-color: var(--gold); color: var(--ink); text-decoration: none; }
.status-tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); flex-shrink: 0; }
.status-tab .dot.green { background: var(--green); }
.status-tab .dot.amber { background: var(--amber); }
.status-tab .dot.rust { background: var(--rust); }
.status-tab .dot.gray { background: var(--ink-faint); }
.status-tab .count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  background: var(--paper); color: var(--ink-soft); font-size: 11.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.status-tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.status-tab.active .count { background: rgba(255, 255, 255, .16); color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.list th {
  text-align: left; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line-strong);
  background: var(--surface);
}
table.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: #faf8f2; }
table.list tfoot td { font-weight: 600; background: var(--paper); border-top: 2px solid var(--line-strong); }

.badge {
  display: inline-block; padding: 2.5px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.rust { background: var(--rust-soft); color: var(--rust); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.gray { background: var(--paper); color: var(--ink-soft); }

/* ---------- Toggle switch (e.g. product available/unavailable) ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0; background: var(--line-strong); border-radius: 99px;
  transition: background .15s;
}
.switch-track::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--gold-soft); }
.switch input:disabled { cursor: default; }
.switch input:disabled + .switch-track { opacity: .5; }

/* ---------- Forms ---------- */
.form-card { max-width: 560px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 5px; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  width: 100%; padding: 9px 12px; min-height: 44px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.field input:read-only { background: var(--paper); color: var(--ink-soft); cursor: default; }
.field input:read-only:focus { box-shadow: none; border-color: var(--line-strong); }
.field .hint { margin-top: 4px; }
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }

/* ---------- Custom checkbox — replaces the unstyled native box everywhere a plain
   <input type="checkbox"> + label appears (settings toggles, feature lists, "active"
   flags, ...). Markup: <label class="checkbox"><input type="checkbox" ...><span
   class="box"><svg>check path</svg></span> Label text</label> */
.checkbox {
  position: relative;
  display: inline-flex; align-items: center; gap: 9px;
  cursor: pointer; font-size: 14px; color: var(--ink); font-weight: 400;
  user-select: none;
}
.checkbox input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.checkbox .box {
  width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.checkbox .box svg { width: 11px; height: 11px; opacity: 0; transition: opacity .1s; color: #fff; }
.checkbox input:checked + .box { background: var(--gold); border-color: var(--gold); }
.checkbox input:checked + .box svg { opacity: 1; }
.checkbox input:focus-visible + .box { box-shadow: 0 0 0 3px var(--gold-soft); }
.checkbox input:disabled + .box { opacity: .5; }
.checkbox:has(input:disabled) { cursor: default; opacity: .7; }

.error-list { background: var(--rust-soft); color: var(--rust); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.error-list ul { margin: 0; padding-left: 18px; }

/* filter bar */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin-bottom: 16px;
}
.filter-bar .field { margin: 0; min-width: 130px; flex: 0 1 auto; }
.filter-bar .field input, .filter-bar .field select { min-height: 40px; padding: 6px 10px; font-size: 16px; }
.filter-bar .spacer { flex: 1; }

/* inline-form action styled like a plain link (for actions that must be POST, not GET) */
.btn-link {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--gold);
}
.btn-link:hover { text-decoration: underline; }

/* toast notifications — fixed top-right stack, replaces the old inline .flash banners so a
   message no longer pushes page content down; server still renders the message markup (works
   with JS disabled, just without the auto-dismiss/slide animation), app.js only adds the
   dismiss timer and manual-close wiring. */
.toast-stack {
  position: fixed; top: 18px; right: 18px; z-index: 400;
  display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid;
  border-radius: var(--radius); box-shadow: var(--shadow-md, var(--shadow-sm));
  padding: 12px 14px; font-size: 14px; display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in .25s ease-out;
}
.toast.leaving { animation: toast-out .2s ease-in forwards; }
.toast.success { border-left-color: var(--green); }
.toast.success .toast-msg { color: var(--green); }
.toast.error { border-left-color: var(--rust); }
.toast.error .toast-msg { color: var(--rust); }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  background: none; border: 0; color: var(--ink-faint); font-size: 18px; line-height: 1;
  cursor: pointer; padding: 0 2px;
}
.toast-close:hover { color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(12px); } }

/* styled confirm dialog — replaces window.confirm() for every [data-confirm] element (see
   app.js); same on-brand surface as .card, gold for a routine confirm, rust for anything
   whose trigger carries .btn-danger */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 500; background: rgba(25, 28, 34, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.confirm-overlay[hidden] { display: none; }
.confirm-modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md, var(--shadow-sm));
  padding: 22px 22px 18px; max-width: 420px; width: 100%;
  animation: toast-in .18s ease-out;
}
.confirm-title { margin: 0 0 18px; font-size: 15px; line-height: 1.5; color: var(--ink); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-actions .btn-primary.danger { background: var(--rust); border-color: var(--rust); color: #fff; }

/* payroll — employee profile tab bar (underline style) */
.pr-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.pr-tab {
  padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.pr-tab:hover { color: var(--ink); text-decoration: none; }
.pr-tab.active { color: var(--ink); border-bottom-color: var(--gold-bright); }

/* payroll — dependency-free inline SVG charts (horizontal bars, donut) */
.pr-hbars { display: flex; flex-direction: column; gap: 10px; }
.pr-hbar-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.pr-hbar-label { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-hbar-track { background: var(--paper); border-radius: 4px; height: 10px; overflow: hidden; }
.pr-hbar-fill { display: block; height: 100%; border-radius: 4px; }
.pr-hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; min-width: 70px; }

.pr-donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.pr-donut-ring { position: relative; width: 120px; height: 120px; flex: 0 0 auto; }
.pr-donut { width: 120px; height: 120px; display: block; }
.pr-donut-total {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; pointer-events: none;
}
.pr-donut-total-n { font-family: var(--font-display); font-size: 22px; color: var(--ink); }
.pr-donut-legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.pr-donut-legend-row { display: flex; align-items: center; gap: 8px; }
.pr-donut-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }

/* payroll — colour-hashed initials avatar */
.pr-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .2px; flex: 0 0 auto;
  font-family: var(--font-body);
}
.pr-avatar.lg { width: 44px; height: 44px; font-size: 16px; }

/* payroll run lifecycle stepper */
.pr-steps { display: flex; align-items: center; margin: 4px 0 18px; flex-wrap: wrap; gap: 0; }
.pr-step { display: flex; align-items: center; gap: 8px; color: var(--ink-faint); font-size: 13px; font-weight: 600; }
.pr-step:not(:last-child)::after {
  content: ''; display: inline-block; width: 36px; height: 1px; background: var(--line-strong);
  margin: 0 10px;
}
.pr-step-dot {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong);
  background: var(--surface); flex: 0 0 auto;
}
.pr-step.done .pr-step-dot { background: var(--green); border-color: var(--green); }
.pr-step.done { color: var(--green); }
.pr-step.now .pr-step-dot { background: var(--gold-bright); border-color: var(--gold-bright); box-shadow: 0 0 0 3px var(--gold-soft); }
.pr-step.now { color: var(--ink); }
.pr-step-detour { margin-left: 16px; font-size: 13px; color: var(--rust); display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  .pr-steps { gap: 10px 0; }
  .pr-step:not(:last-child)::after { width: 14px; margin: 0 4px; }
  .pr-step-label { display: none; }
}

/* persistent banner (not auto-hidden like .flash) */
.persistent-banner {
  padding: 11px 16px; border-radius: 8px; margin: 10px 10px 0; font-size: 14px;
  border: 1px solid; background: var(--rust-soft); color: var(--rust); border-color: #e8c7cc;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* pagination */
.pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
.pagination li a, .pagination li span {
  display: block; padding: 6px 11px; border: 1px solid var(--line-strong);
  border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 13.5px;
}
.pagination li.active span, .pagination li a:hover { background: var(--gold); color: #1b1607; border-color: var(--gold); text-decoration: none; }

/* dashboard two-column */
.dash-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }

/* page header */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { flex: 1; margin: 0; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--paper);
}
.login-card {
  background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 14px; padding: 32px 30px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-card .brand { padding: 0 0 18px; font-size: 22px; }
.shop-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; margin-bottom: 18px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 13.5px; color: var(--ink-soft);
}
.shop-banner strong { color: var(--ink); }

/* ---------- Self-service registration ---------- */
.register-wrap { min-height: 100vh; display: flex; background: var(--paper); }
.register-pitch {
  flex: 0 0 38%; min-width: 320px;
  background: linear-gradient(165deg, var(--sidebar-bg-2), var(--sidebar-bg) 70%);
  color: var(--sidebar-ink);
  padding: 48px 44px;
  display: flex; flex-direction: column;
}
.register-pitch .brand { padding: 0 0 30px; font-size: 22px; }
.register-pitch h1 {
  color: #fff; font-size: 32px; line-height: 1.2; letter-spacing: -.01em;
  margin: 6px 0 14px; text-wrap: balance;
}
.register-pitch > p { color: var(--sidebar-ink); font-size: 15px; line-height: 1.6; max-width: 40ch; }
.pitch-points { list-style: none; margin: 30px 0 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.pitch-points li { display: flex; gap: 12px; align-items: flex-start; }
.pitch-points .pitch-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: rgba(200, 154, 62, .14); color: var(--gold-bright);
  display: flex; align-items: center; justify-content: center;
}
.pitch-points .pitch-icon svg { width: 16px; height: 16px; }
.pitch-points strong { display: block; color: #fff; font-size: 14px; font-weight: 600; }
.pitch-points span { display: block; color: var(--sidebar-ink-dim); font-size: 13px; margin-top: 1px; }
.register-pitch .pitch-foot { margin-top: auto; padding-top: 30px; font-size: 13px; color: var(--sidebar-ink-dim); }
.register-pitch .pitch-foot a { color: var(--gold-bright); font-weight: 600; }

.register-form-side { flex: 1; padding: 48px 44px; display: flex; justify-content: center; overflow-y: auto; }
.register-form-inner { width: 100%; max-width: 620px; }
.register-form-inner > .step-label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
.register-form-inner > h2 { margin: 0 0 4px; }
.register-form-inner > .hint { margin: 0 0 26px; font-size: 14px; }

.form-section { margin-bottom: 26px; }
.form-section > .section-label {
  font-family: var(--font-display); font-size: 15px; color: var(--ink);
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}

/* Module-selection cards — checkbox-driven, styled as selectable tiles rather than a plain
   checkbox list, since picking modules is the one decision this form exists to capture. */
.module-select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.module-select-card {
  position: relative; display: block; cursor: pointer;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); padding: 14px 16px 14px 44px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.module-select-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.module-select-card .check {
  position: absolute; left: 14px; top: 16px;
  width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.module-select-card .check svg { width: 12px; height: 12px; opacity: 0; transition: opacity .1s; color: #fff; }
.module-select-card strong { display: block; font-size: 14.5px; color: var(--ink); }
.module-select-card span { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; line-height: 1.4; }
.module-select-card.selected {
  border-color: var(--gold); background: var(--gold-soft);
  box-shadow: 0 2px 10px rgba(169, 129, 46, .14);
}
.module-select-card.selected .check { background: var(--gold); border-color: var(--gold); }
.module-select-card.selected .check svg { opacity: 1; }

/* Honeypot — off-screen, never visible to a real visitor, but present in the DOM/tab order
   avoided via tabindex so bots that fill every input still get caught. */
.hp-field { position: absolute; left: -9999px; top: -9999px; }

/* ---------- Sidebar pending-count pill (e.g. superadmin Registrations) ---------- */
.nav-pill {
  margin-left: auto; flex-shrink: 0;
  background: var(--rust); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 7px; border-radius: 99px;
}

@media (max-width: 860px) {
  .register-wrap { flex-direction: column; }
  .register-pitch { flex: none; padding: 32px 24px; }
  .register-pitch .pitch-foot { margin-top: 24px; padding-top: 0; }
  .register-form-side { padding: 32px 24px; }
}

/* Clickable metric cards */
a.metric {
  display: block; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
a.metric:hover {
  border-color: var(--gold);
  box-shadow: 0 2px 10px rgba(169, 129, 46, .16);
  text-decoration: none;
}

/* Custom-date fields — hidden by default, shown via JS when preset = custom */
.custom-date { display: none; }

/* ---------- Mobile ---------- */
.scrim { display: none; }
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 70;
    transform: translateX(-105%);
    transition: transform .22s ease;
    height: 100dvh;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .35);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(15, 17, 21, .45);
  }
  .hamburger { display: inline-flex; }
  .content { padding: 14px; }
  .dash-cols { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .topbar { padding: 10px 14px; }
  h1 { font-size: 22px; }
  .btn .btn-text-lg { display: none; }

  /* Touch-friendly tap targets — the desktop sizes below this breakpoint are too tight
     for a finger on a phone (Apple/Google both recommend ~44px minimum). */
  .btn { min-height: 44px; padding: 9px 16px; }
  .btn-sm { min-height: 38px; padding: 7px 12px; }
  .nav-item { padding: 11px 12px; font-size: 15px; }
  .pagination li a, .pagination li span { padding: 9px 13px; }
  .status-tab { padding: 9px 14px 9px 12px; }
  .dropdown-menu a { padding: 11px; }
  .cat-link { padding: 11px 14px; }
  .module-tab { padding: 12px 6px; }

  /* Metric grid already reflows via auto-fit, but on very narrow phones a 165px minimum
     still crowds two half-cut columns — go to one column. */
  .metric-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .page-head { align-items: flex-start; }
  .page-head h1 { flex: 1 1 100%; }
}

@media print {
  .sidebar, .topbar, .filter-bar, .no-print, .pagination { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card, .table-wrap { border: none; box-shadow: none; }
}

/* ---- catalog: slide-out category drawer + product grid ---- */
.cat-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 90;
  width: 300px; max-width: 85vw; background: var(--surface);
  padding: 18px; overflow-y: auto;
  transform: translateX(-105%); transition: transform .22s ease;
  box-shadow: 4px 0 26px rgba(0, 0, 0, .22);
}
.cat-drawer.open { transform: translateX(0); }
.cat-drawer-scrim {
  display: none; position: fixed; inset: 0; z-index: 85; background: rgba(15, 17, 21, .45);
}
.cat-drawer-scrim.open { display: block; }
.cat-drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.cat-tree { display: flex; flex-direction: column; gap: 1px; }
.cat-node { display: flex; flex-direction: column; }
.cat-row { display: flex; align-items: stretch; }
.cat-link {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; color: var(--ink-soft); font-size: 14px;
  border-radius: 7px; min-width: 0;
}
.cat-link span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-link:hover { background: var(--paper); text-decoration: none; color: var(--ink); }
.cat-link.active { color: var(--gold); background: var(--gold-soft); font-weight: 600; }
.cat-count {
  flex-shrink: 0; font-size: 11.5px; font-weight: 600; color: var(--ink-faint);
  background: var(--paper); border-radius: 99px; padding: 1px 8px; font-variant-numeric: tabular-nums;
}
.cat-link.active .cat-count { background: rgba(169, 129, 46, .14); color: var(--gold); }
.cat-toggle {
  flex-shrink: 0; width: 32px; background: none; border: none; cursor: pointer;
  color: var(--ink-faint); display: flex; align-items: center; justify-content: center;
}
.cat-toggle svg { width: 14px; height: 14px; transition: transform .15s; }
.cat-toggle.expanded svg { transform: rotate(90deg); }
.cat-toggle:hover { color: var(--ink); }
.cat-children { padding-left: 14px; margin-left: 12px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
/* same reason as .modal-overlay[hidden] below — "display: flex" is author CSS and beats the
   browser's default [hidden] handling, so without this the JS toggle has no visual effect */
.cat-children[hidden] { display: none; }

.catalog-status-row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px; margin-bottom: 14px;
}
.catalog-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 500;
  background: var(--gold-soft); color: var(--gold);
}
.chip button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(169, 129, 46, .18); color: var(--gold); font-size: 14px; line-height: 1; padding: 0;
}
.chip button:hover { background: var(--gold); color: #fff; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.product-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.product-card-body { cursor: pointer; }
.product-card-body:hover .product-photo { transform: scale(1.045); }
.product-card-text { padding: 14px 16px 12px; }
.product-code { font-size: 10.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.product-name { font-family: var(--font-display); font-size: 15.5px; font-weight: 600; margin: 4px 0 7px; line-height: 1.3; }
.product-price { color: var(--green); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.add-to-cart-form { display: flex; gap: 8px; padding: 2px 16px 16px; }
.add-to-cart-form input[type="number"] { width: 58px; flex-shrink: 0; text-align: center; }
.add-to-cart-form .btn { flex: 1; justify-content: center; white-space: nowrap; }

/* product photo + placeholder, used in the catalog grid, admin list and detail popup */
.product-photo {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  background: var(--paper); border-bottom: 1px solid var(--line);
  transition: transform .25s ease;
}
.product-photo-empty {
  width: 100%; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
  background: var(--paper); border-bottom: 1px solid var(--line); color: var(--ink-faint);
  overflow: hidden;
}
.product-photo-empty svg { width: 32px; height: 32px; opacity: .5; }
.product-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.product-thumb-empty { width: 40px; height: 40px; border-radius: 6px; display: block; background: var(--paper); border: 1px solid var(--line); }
.modal-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; margin-bottom: 12px; }

@media (max-width: 480px) {
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .cat-drawer { width: 260px; padding: 14px; }
}

/* ---- lightweight modal (no library, matches the rest of the app) ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 17, 21, .55); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
/* the [hidden] attribute is how browse.php toggles this modal via JS — without this rule,
   the class's own "display: flex" (author CSS) overrides the browser's default [hidden]
   handling and the modal stays visible even when the hidden attribute is set */
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--surface); border-radius: var(--radius); max-width: 480px; width: 100%;
  max-height: 85vh; overflow-y: auto; padding: 24px; position: relative;
  box-shadow: var(--shadow-md);
}
.modal-close {
  position: absolute; top: 10px; right: 14px; border: none; background: none;
  font-size: 22px; line-height: 1; color: var(--ink-faint); cursor: pointer;
}
.modal-close:hover { color: var(--ink); }

/* ---- cart / order summary table ---- */
.cart-table { width: 100%; border-collapse: collapse; }
.cart-table td, .cart-table th { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.cart-table input[type="number"] { width: 60px; font-size: 16px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 6px; }
.add-to-cart-form input[type="number"] { font-size: 16px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 6px; }

/* ---- Support / tickets ---- */
.wa-btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: var(--radius);
  background: #25D366; color: #fff; font-weight: 600; font-size: 15px; border: none;
}
.wa-btn:hover { filter: brightness(1.05); color: #fff; text-decoration: none; }
.wa-btn svg { flex: 0 0 auto; }

.ticket-thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.ticket-msg {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line-strong);
  border-radius: var(--radius); padding: 14px 16px;
}
.ticket-msg.tenant { border-left-color: var(--gold); }
.ticket-msg.superadmin { border-left-color: var(--green); }
.ticket-msg-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 10px; }
.ticket-msg-author { font-weight: 700; font-size: 13.5px; }
.ticket-msg.superadmin .ticket-msg-author { color: var(--green); }
.ticket-msg.tenant .ticket-msg-author { color: var(--gold); }
.ticket-msg-time { font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.ticket-msg-body { font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; }

/* ---- Help ("?") — topbar icon, hub cards, accordion + search ---- */
.help-btn {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-family: var(--font-display); font-weight: 600; font-size: 16px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  flex: 0 0 auto;
}
.help-btn:hover { border-color: var(--gold); color: var(--gold); text-decoration: none; }

.help-intro { max-width: 640px; margin: 0 0 22px; color: var(--ink-soft); font-size: 15px; line-height: 1.6; }
.help-hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.help-hub-card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm); color: var(--ink);
}
.help-hub-card:hover { border-color: var(--gold); text-decoration: none; box-shadow: var(--shadow-md); }
.help-hub-card .icn {
  width: 40px; height: 40px; border-radius: 10px; background: var(--gold-soft); color: var(--gold);
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.help-hub-card h2 { font-size: 17px; margin: 0 0 4px; }
.help-hub-card p { margin: 0; font-size: 13.5px; color: var(--ink-soft); }

.help-search { position: relative; max-width: 420px; margin: 0 0 20px; }
.help-search input {
  width: 100%; padding: 11px 14px 11px 38px; border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 15px; background: var(--surface);
}
.help-search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.help-search::before {
  content: ''; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; opacity: .5;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") center / contain no-repeat;
}
.help-search-empty { display: none; color: var(--ink-faint); padding: 14px 4px; }

.help-group-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint);
  margin: 24px 0 8px; font-weight: 700;
}
.help-group-label:first-child { margin-top: 0; }

.help-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.help-item-head {
  width: 100%; text-align: left; background: none; border: none; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.help-item-head:hover { color: var(--gold); }
.help-item-head .chev { transition: transform .15s; flex: 0 0 auto; color: var(--ink-faint); }
.help-item.open .help-item-head .chev { transform: rotate(180deg); }
.help-item-body { display: none; padding: 0 16px 16px; color: var(--ink-soft); font-size: 14.5px; line-height: 1.65; }
.help-item.open .help-item-body { display: block; }
.help-item-body p { margin: 0 0 10px; }
.help-item-body ol, .help-item-body ul { margin: 0 0 10px; padding-left: 22px; }
.help-item-body li { margin-bottom: 5px; }
.help-item-body .help-why {
  background: var(--paper); border-left: 3px solid var(--gold); padding: 8px 12px; border-radius: 6px;
  font-size: 13.5px; margin: 10px 0;
}
.help-item-body .help-who {
  color: var(--ink-faint); font-size: 13px; font-style: italic; margin-top: 8px;
}
.help-item[hidden] { display: none; }
