/* Black Lion Distribution ERP — design system.
   Charcoal/black sidebar, white nav text, subtle gold accents, light-gray workspace, white cards & tables. */
:root {
  --black: #0f0f0f; --charcoal: #1b1b1d; --charcoal-2: #26262a; --charcoal-3: #34343a;
  --gold: #c9a24b; --gold-2: #e0bf6e; --gold-soft: #f6eedb;
  --bg: #f1f2f4; --card: #ffffff; --line: #e2e4e8; --line-2: #d0d3d9;
  --text: #17181b; --muted: #6b7079; --white: #fff;
  --ok: #1f8a4c; --ok-bg: #e5f5ec; --info: #2563a8; --info-bg: #e6eef9; --warn: #a86a05; --warn-bg: #fdf2dc; --bad: #b42318; --bad-bg: #fde8e6;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --side-w: 264px; --side-w-c: 64px; --top-h: 60px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: .3em 0 .8em; }
.muted { color: var(--muted); } .small { font-size: .85em; } .error { color: var(--bad); } .ok { color: var(--ok); } .warn { color: var(--warn); }
.right { text-align: right; } .nowrap { white-space: nowrap; } [hidden] { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35em; padding: .55em 1em; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; min-height: 38px; text-decoration: none !important; white-space: nowrap; }
.btn:hover { border-color: #9aa0aa; } .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--charcoal); color: #fff; border-color: var(--charcoal); } .btn-primary:hover { background: #000; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #111; } .btn-gold:hover { background: var(--gold-2); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f0b3ad; } .btn-danger:hover { background: var(--bad-bg); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: .3em .65em; min-height: 30px; font-size: .88em; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; font-size: 1.25rem; cursor: pointer; color: inherit; padding: .3em .45em; border-radius: 8px; min-width: 38px; min-height: 38px; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.input { width: 100%; padding: .55em .7em; border: 1px solid var(--line-2); border-radius: 8px; font: inherit; background: #fff; color: var(--text); min-height: 38px; }
.input:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
select.input[multiple] { min-height: 110px; }
textarea.input { resize: vertical; }
.field { display: flex; flex-direction: column; gap: .3em; }
.field .lbl { font-weight: 600; font-size: .86em; color: #3a3f47; } .field .req { color: var(--bad); }
.field .help { color: var(--muted); font-size: .8em; }
.field.invalid .input { border-color: var(--bad); background: #fff8f7; }
.field-check { flex-direction: row; align-items: center; gap: .5em; } .field-check input { width: 18px; height: 18px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: 1fr; } .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full, .form-section { grid-column: 1 / -1; }
.form-section { font-weight: 700; color: var(--charcoal); border-bottom: 2px solid var(--gold-soft); padding-bottom: 4px; margin-top: 6px; }
.checkgroup { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0; } .chk { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.badge { display: inline-block; padding: .18em .6em; border-radius: 999px; font-size: .78em; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.tone-ok { background: var(--ok-bg); color: var(--ok); } .tone-info { background: var(--info-bg); color: var(--info); } .tone-warn { background: var(--warn-bg); color: var(--warn); } .tone-bad { background: var(--bad-bg); color: var(--bad); } .tone-muted { background: #eceef1; color: #555b65; }

/* auth */
body.auth { background: radial-gradient(1200px 600px at 20% -10%, #2a2a2e, #0c0c0c); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 12px; border-top: 4px solid var(--gold); }
.auth-card .brand { color: var(--text); margin-bottom: 6px; } .auth-card .brand img { background: #111; border-radius: 8px; }
.auth-card h1 { font-size: 1.3rem; margin: 0; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--charcoal); color: #fff; display: flex; flex-direction: column; z-index: 40; transition: width .18s ease, transform .2s ease; border-right: 1px solid #000; }
.main-col { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; transition: margin .18s ease; }
body.collapsed .sidebar { width: var(--side-w-c); } body.collapsed .main-col { margin-left: var(--side-w-c); }
body.collapsed .side-nav .txt, body.collapsed .side-nav .chev, body.collapsed .side-items, body.collapsed .brand div, body.collapsed .side-label, body.collapsed .side-foot .txt { display: none !important; }
body.collapsed .collapse-btn { transform: rotate(180deg); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand strong { display: block; letter-spacing: .14em; font-size: .95rem; } .brand span { display: block; letter-spacing: .32em; font-size: .62rem; color: var(--gold); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 10px 14px; border-bottom: 1px solid var(--charcoal-3); min-height: var(--top-h); }
.collapse-btn { color: #aaa; font-size: 1rem; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 8px 16px; scrollbar-width: thin; scrollbar-color: #444 transparent; }
.side-label { color: var(--gold); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; padding: 10px 10px 4px; }
.side-group { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; color: #e9e9ea; font: inherit; font-weight: 600; padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.side-group:hover { background: var(--charcoal-2); } .side-group.has-active { color: #fff; }
.side-group .ico { width: 22px; text-align: center; flex: none; } .side-group .txt { flex: 1; } .side-group .chev { color: #888; font-size: .8em; transition: transform .15s; }
.side-group[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.side-items { padding: 2px 0 6px 32px; display: flex; flex-direction: column; }
.side-link { display: flex; align-items: center; gap: 10px; color: #c9c9cc; padding: 7px 10px; border-radius: 7px; font-size: .92em; text-decoration: none !important; background: none; border: 0; font: inherit; cursor: pointer; width: 100%; text-align: left; border-left: 3px solid transparent; }
.side-link:hover { background: var(--charcoal-2); color: #fff; }
.side-link.on { background: rgba(201, 162, 75, .14); color: var(--gold-2); border-left-color: var(--gold); font-weight: 600; }
.side-link .ico { width: 22px; text-align: center; }
.fav-group { border-bottom: 1px solid var(--charcoal-3); margin-bottom: 6px; padding-bottom: 6px; } .fav-group .side-link .ico { color: var(--gold); }
.side-foot { border-top: 1px solid var(--charcoal-3); padding: 8px; }

.topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.menu-btn { display: none; }
.gsearch-box { position: relative; flex: 1; max-width: 640px; }
.gsearch { background: var(--bg); border-color: transparent; }
.gsearch-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.15); max-height: 70vh; overflow: auto; padding: 6px; }
.gs-group { padding: 4px 0; } .gs-title { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px 10px; }
.gs-item { display: flex; flex-direction: column; padding: 7px 10px; border-radius: 7px; color: var(--text); text-decoration: none !important; } .gs-item:hover { background: var(--gold-soft); } .gs-item span { color: var(--muted); font-size: .85em; }
.gs-empty { padding: 14px; color: var(--muted); }
.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dropdown { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 240px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.16); padding: 6px; z-index: 50; max-height: 75vh; overflow: auto; }
.menu-right { left: auto; right: 0; }
.menu-title { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 4px; font-weight: 700; } .menu-sub { padding: 0 10px 6px; color: var(--muted); font-size: .85em; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; font: inherit; color: var(--text); padding: 8px 10px; border-radius: 7px; cursor: pointer; text-decoration: none !important; }
.menu-item:hover { background: var(--gold-soft); }
.bell { position: relative; } .bell .count { position: absolute; top: 2px; right: 0; background: var(--bad); color: #fff; font-size: .65rem; border-radius: 999px; padding: 1px 5px; font-weight: 700; }
.role-btn { font-size: .85em; } .role-pill { font-size: .8em; font-weight: 700; background: var(--gold-soft); padding: 6px 10px; border-radius: 999px; }
.avatar-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--charcoal); color: var(--gold); border: 2px solid var(--gold); font-weight: 800; cursor: pointer; }
.fab { display: none; }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 16px; font-size: .92em; flex-wrap: wrap; }
.banner-preview { background: var(--gold-soft); border-bottom: 1px solid #ecd9a6; }
.banner-imp { background: var(--bad-bg); border-bottom: 1px solid #f3b8b1; }
.tabbar { display: flex; gap: 4px; padding: 6px 12px 0; background: var(--bg); overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tabbar:empty { display: none; }
.tab { display: flex; align-items: center; gap: 2px; background: #e6e8eb; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; padding: 0 4px 0 12px; max-width: 220px; flex: none; }
.tab a { color: #444; padding: 7px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none !important; font-size: .88em; font-weight: 600; }
.tab.on { background: #fff; border-top: 2px solid var(--gold); } .tab.on a { color: var(--text); }
.tab-x { background: none; border: 0; cursor: pointer; color: #888; font-size: 1rem; padding: 2px 6px; border-radius: 4px; } .tab-x:hover { background: #ddd; }
.workspace { padding: 20px; flex: 1; min-width: 0; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.view-head h1 { margin: 0; } .view-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fav-btn { color: var(--warn); }
.scrim { display: none; }

/* cards, metrics, sections */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-title { font-size: 1rem; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section { margin-bottom: 22px; } .section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 10px; font-weight: 800; }
.grid { display: grid; gap: 14px; } .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.metric { display: flex; flex-direction: column; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; text-align: left; font: inherit; cursor: default; border-left: 3px solid var(--gold); }
a.metric, button.metric { cursor: pointer; } a.metric:hover, button.metric:hover { border-color: var(--gold); transform: translateY(-1px); }
.metric-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.metric-value { font-size: 1.35rem; font-weight: 800; } .metric-sub { font-size: .8em; color: var(--muted); }
.metric.tone-bad { border-left-color: var(--bad); } .metric.tone-warn { border-left-color: var(--warn); } .metric.tone-ok { border-left-color: var(--ok); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.empty-state { text-align: center; padding: 30px 16px; color: var(--muted); } .loading-block { padding: 24px; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 6px 14px; margin: 0; } .kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; overflow-wrap: anywhere; }
.chart-wrap { width: 100%; overflow-x: auto; } .chart { width: 100%; height: auto; max-height: 260px; color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; } .feed li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; } .feed li:last-child { border: 0; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.notice { background: var(--info-bg); color: #1c3d66; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: .92em; }
.notice.warn { background: var(--warn-bg); color: #6b4400; } .notice.bad { background: var(--bad-bg); color: #7a1a12; }

/* tables */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap.loading { opacity: .55; }
.table { width: 100%; border-collapse: collapse; font-size: .93em; }
.table th { text-align: left; background: #f8f9fa; color: #4b5059; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; } .table th.sortable:hover { color: var(--text); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; } .table tr.clickable { cursor: pointer; } .table tr.clickable:hover td { background: #fbf8ef; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td.actions { white-space: nowrap; text-align: right; } .table td.actions .btn { margin-left: 4px; }
.table tfoot td { font-weight: 800; background: #fafafa; border-top: 2px solid var(--line); }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
.table th.sel, .table td.sel { width: 36px; }
.dt { margin-bottom: 16px; }
.dt-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.dt-tools .input { width: auto; min-width: 150px; } .dt-search { flex: 1; min-width: 200px !important; max-width: 360px; }
.dt-tools-right { margin-left: auto; display: flex; gap: 8px; }
.dt-bulk { display: flex; gap: 8px; align-items: center; background: var(--gold-soft); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; flex-wrap: wrap; }
.dt-pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 10px 2px; color: var(--muted); flex-wrap: wrap; }
.dt-pager .input { width: auto; }

/* record pages */
.record-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.record-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.back { display: inline-block; margin-bottom: 6px; font-size: .9em; }
.tabs-inline { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: thin; }
.tabs-inline .tab { all: unset; cursor: pointer; padding: 9px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs-inline .tab.on { color: var(--text); border-bottom-color: var(--gold); }

/* modal & toasts */
.modal-back { position: fixed; inset: 0; background: rgba(10,10,12,.55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,.35); }
.modal-wide { max-width: 920px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal-head h3 { margin: 0; }
.modal-body { padding: 16px 18px; overflow: auto; } .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 11px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-weight: 600; transition: opacity .3s, transform .3s; background: #fff; border-left: 4px solid var(--ok); }
.toast.tone-bad { border-left-color: var(--bad); } .toast.tone-warn { border-left-color: var(--warn); } .toast.tone-info { border-left-color: var(--info); } .toast.out { opacity: 0; transform: translateY(8px); }
.wizard-steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; flex-wrap: wrap; }
.wizard-steps li { flex: 1; min-width: 150px; padding: 8px 10px; border-radius: 8px; background: #f1f2f4; color: var(--muted); font-weight: 600; font-size: .9em; }
.wizard-steps li b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #d9dbe0; color: #fff; margin-right: 4px; font-size: .8em; }
.wizard-steps li.on { background: var(--gold-soft); color: var(--text); } .wizard-steps li.on b { background: var(--gold); }
.notif-list { display: flex; flex-direction: column; gap: 6px; } .notif { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 8px; border-left: 3px solid var(--info); background: #f8f9fb; color: var(--text); text-decoration: none !important; }
.notif.read { opacity: .65; } .notif.sev-warn { border-left-color: var(--warn); } .notif.sev-bad { border-left-color: var(--bad); } .notif small { color: var(--muted); } .notif span { color: #444; font-size: .9em; }

/* scanning, signature */
.scan { display: flex; gap: 8px; } .scan-input { font-size: 1.1rem; min-height: 46px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.scan-log { max-height: 260px; overflow: auto; }
.scan-ok { background: var(--ok-bg); } .scan-warn { background: var(--warn-bg); } .scan-bad { background: var(--bad-bg); }
.cam-video { width: 100%; border-radius: 8px; background: #000; max-height: 60vh; }
.sig-wrap { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; } .sig { width: 100%; max-width: 600px; height: 180px; border: 1px dashed var(--line-2); border-radius: 8px; touch-action: none; background: #fff; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; } .thumbs img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.daterange { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .daterange .input { width: auto; } .daterange .lbl { font-size: .82em; color: var(--muted); font-weight: 600; } .dr-custom { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ───────── responsive ───────── */
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); width: min(86vw, 320px) !important; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  body.nav-open .sidebar { transform: none; } body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  body.collapsed .side-nav .txt, body.collapsed .side-nav .chev, body.collapsed .brand div, body.collapsed .side-foot .txt { display: initial !important; }
  .main-col, body.collapsed .main-col { margin-left: 0; }
  .menu-btn { display: inline-block; } .collapse-btn { display: none; }
  .topbar { padding: 0 8px; gap: 6px; }
  .create-btn .lbl, .role-btn .small { display: none; } .create-btn { display: none; }
  .fab { display: grid; place-items: center; position: fixed; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%; background: var(--gold); color: #111; font-size: 1.8rem; font-weight: 800; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 60; text-decoration: none !important; }
  .top-right .dropdown .menu { position: fixed; top: var(--top-h); left: 8px; right: 8px; min-width: 0; }
  .workspace { padding: 12px; }
  .grid-2, .grid-3, .grid-4, .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .metric-value { font-size: 1.15rem; }
  .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; }
  .dt-search { max-width: none; } .dt-tools .input { flex: 1 1 140px; } .dt-tools-right { margin-left: 0; width: 100%; } .dt-tools-right > * { flex: 1; }
  /* tables become cards: no clipped text, actions reachable, money readable */
  .dt-table thead { display: none; }
  .dt-table, .dt-table tbody, .dt-table tr, .dt-table td, .dt-table tfoot { display: block; width: 100%; }
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  .dt-table tr { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 8px 12px; box-shadow: var(--shadow); }
  .dt-table td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right !important; overflow-wrap: anywhere; }
  .dt-table td::before { content: attr(data-label); font-weight: 700; color: var(--muted); text-align: left; font-size: .82em; text-transform: uppercase; letter-spacing: .03em; flex: none; max-width: 45%; }
  .dt-table td.primary { font-size: 1.05em; font-weight: 700; justify-content: flex-start; text-align: left !important; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 4px; }
  .dt-table td.primary::before { display: none; }
  .dt-table td.hide-m { display: none; }
  .dt-table td.actions { justify-content: flex-end; flex-wrap: wrap; gap: 6px; padding-top: 8px; } .dt-table td.actions::before { display: none; }
  .dt-table td.actions .btn { margin: 0; flex: 1 1 auto; min-height: 38px; }
  .dt-table td.sel { justify-content: flex-start; } .dt-table td.sel::before { display: none; }
  .dt-table td.empty { justify-content: center; } .dt-table td.empty::before { display: none; }
  .dt-table tfoot tr { background: #fafafa; }
  .modal-back { padding: 0; place-items: end stretch; } .modal, .modal-wide { max-width: none; border-radius: 14px 14px 0 0; max-height: 92vh; }
  .wizard-steps li { min-width: 0; font-size: .8em; }
  .view-head h1 { font-size: 1.2rem; }
  .tab { max-width: 160px; }
}
@media (max-width: 420px) { .metrics { grid-template-columns: 1fr 1fr; } .gsearch::placeholder { font-size: .85em; } }
@media print { .sidebar, .topbar, .tabbar, .banner-slot, .dt-tools, .dt-pager, .view-head-actions, .fab { display: none !important; } .main-col { margin: 0 !important; } .workspace { padding: 0; } }

/* line icons (js/icons.js) — inherit text colour; spacing comes from flex gap in buttons / sidebar */
.ico-svg { width: 1.1em; height: 1.1em; vertical-align: -.17em; flex: none; margin-right: .32em; }
.btn .ico-svg, .side-group .ico-svg, .side-link .ico-svg, .icon-btn .ico-svg, .metric-label .ico-svg { margin-right: 0; }
.side-group .ico, .side-link .ico { display: inline-flex; justify-content: center; align-items: center; font-size: 1.12rem; color: var(--gold); opacity: .9; }
.side-link .ico { font-size: 1rem; color: inherit; opacity: .75; }
.side-link.on .ico, .side-group.has-active .ico { opacity: 1; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }
.icon-btn .ico-svg { width: 1.15em; height: 1.15em; }
.gsearch-box > .ico-svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; margin: 0; }
.gsearch-box .gsearch { padding-left: 34px; width: 100%; }
.ok-ico { color: var(--ok); } .bad-ico { color: var(--bad); } .warn-ico { color: var(--warn); }
.banner-sync { background: #eef4ff; border-bottom: 1px solid #c9d8f5; }

/* ── responsive pass (phones / tablets) ── */
.menu-btn { display: none; }
.role-ico { display: none; }
.dt-filter-btn { display: none; }
.dt-filters { display: contents; }
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; } .collapse-btn { display: none !important; }
  .workspace { padding-bottom: 96px; }
  .fab .ico-svg { width: 26px; height: 26px; }
  /* table toolbars: search + Filters button on one row; filters / dates / export open below */
  .dt-tools { flex-wrap: wrap; }
  .dt-tools .dt-search { flex: 1 1 0; min-width: 0 !important; }
  .dt-filter-btn { display: inline-flex; flex: none; }
  .dt-filters { display: none; width: 100%; flex-wrap: wrap; gap: 8px; }
  .dt.f-open .dt-filters { display: flex; }
  .dt:not(.f-open) .dt-export { display: none; }
  .dt-filters > * { flex: 1 1 140px; min-width: 0; }
  .dt-filters .input { width: 100%; }
  .dt.f-open .dt-filter-btn { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
  /* non-card tables (grids, matrices) scroll inside their own box instead of pushing the page sideways */
  .table-wrap:has(> table:not(.dt-table)) { overflow-x: auto; background: #fff; border: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
  /* bigger tap targets */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .input, select.input { min-height: 42px; font-size: 16px; } /* 16px stops iOS zooming into fields */
  .view-head-actions .btn { padding: .45em .8em; }
  .tabbar { scrollbar-width: none; }
}
@media (max-width: 560px) {
  /* search collapses to an icon and expands across the top bar when tapped */
  .gsearch-box { flex: 0 0 42px; min-width: 42px; }
  .gsearch-box .gsearch { padding-right: 0; cursor: pointer; }
  .gsearch-box:not(:focus-within) .gsearch::placeholder { color: transparent; }
  .gsearch-box:focus-within { position: absolute; left: 8px; right: 8px; z-index: 41; flex: none; }
  .gsearch-box:focus-within .gsearch { cursor: text; background: #fff; border-color: var(--gold); }
  /* role switcher becomes an icon button */
  .role-btn { padding: 0 .55em; min-width: 40px; }
  .role-btn .role-name, .role-btn .role-caret, .role-btn .small { display: none; }
  .role-btn .role-ico { display: inline-block; width: 20px; height: 20px; }
  .role-pill { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
  .metrics { gap: 8px; } .metric { padding: 10px 11px; }
  .view-head { gap: 8px; }
  .modal-body { padding-bottom: 8px; }
}
@media (min-width: 861px) and (max-width: 1180px) {
  .workspace { padding: 16px; }
  .dt-tools .input { min-width: 130px; }
}

/* loading / empty / error states (stabilization pass) */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: bl-spin .8s linear infinite; vertical-align: -2px; opacity: .7; }
@keyframes bl-spin { to { transform: rotate(360deg); } }
.state-error { color: var(--bad, #b42318); }
.state-error p { margin: 0 0 10px; }
td.state-error, td.state-loading { text-align: center; }

/* order builder (orders.js) */
.order-steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.order-steps .tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 600; cursor: pointer; color: var(--text); }
.order-steps .tab.active { background: #111; color: var(--gold, #c9a227); border-color: #111; }
.order-steps .tab:disabled { opacity: .45; cursor: not-allowed; }
.rp-qty { display: inline-flex; gap: 4px; align-items: center; }
.rp-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin: 14px 0; }
tr.muted td { opacity: .6; }
/* ───────── permissions editor: toggle switches (admin.js) ───────── */
.perm-editor { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; margin: 10px 0; }
.perm-group { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; background: #111; color: #fff; border-bottom: 2px solid var(--gold); flex-wrap: wrap; }
.perm-group-head h4 { margin: 0; font-size: .95rem; color: var(--gold); letter-spacing: .02em; }
.perm-group-head .muted { color: #c8c8c8; }
.perm-group-actions { display: flex; gap: 6px; }
.perm-group-actions .btn { min-height: 30px; padding: .3em .7em; font-size: .8em; }
.perm-list { display: flex; flex-direction: column; }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); }
.perm-row:first-child { border-top: 0; }
.perm-row.changed { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); }
.perm-text { flex: 1; display: flex; flex-direction: column; gap: 1px; cursor: pointer; min-width: 0; }
.perm-key { font-size: .72em; color: var(--muted); background: none; padding: 0; }
.perm-note .badge { font-size: .7em; white-space: nowrap; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; flex: none; }
.switch-input { position: absolute; opacity: 0; width: 44px; height: 24px; margin: 0; cursor: pointer; }
.switch-track { width: 44px; height: 24px; border-radius: 999px; background: #c9ccd2; position: relative; transition: background .15s; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .15s; }
.switch-input:checked + .switch-track { background: var(--gold); }
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: #111; }
.switch-input:focus-visible + .switch-track { outline: 2px solid #111; outline-offset: 2px; box-shadow: 0 0 0 4px var(--gold-soft); }
.switch-input:disabled, .switch-input:disabled + .switch-track { cursor: not-allowed; opacity: .6; }
.switch-state { font-size: .75em; font-weight: 700; width: 2.2em; color: var(--muted); }
.switch-input:checked ~ .switch-state::after { content: 'On'; color: var(--text); }
.switch-input:not(:checked) ~ .switch-state::after { content: 'Off'; }
.perm-savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.perm-savebar.dirty { background: #111; color: #fff; border-color: var(--gold); }
.perm-savebar.dirty .perm-save-msg { color: var(--gold); font-weight: 700; }
.perm-save-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.perm-level-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 6px 0; }
.perm-level-head h3 { margin: 0; }
.perm-level-head p { margin: 2px 0 0; }
.perm-compare { margin-top: 12px; } .perm-compare summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.perm-diff { list-style: none; padding: 0; margin: 4px 0 10px; display: flex; flex-direction: column; gap: 4px; }
.perm-diff .perm-key { margin-left: 6px; }
@media (max-width: 640px) { .perm-editor { grid-template-columns: 1fr; } .perm-row { flex-wrap: wrap; } .perm-note { order: 3; width: 100%; } }
/* lifecycle (lifecycle.js) */
.lc-show-removed { display: inline-flex; align-items: center; gap: 4px; font-size: .88em; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; }

/* dashboard filter bar (dashboard.js) */
.dash-filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 12px; }
.dash-filters > summary { cursor: pointer; font-weight: 600; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: inline-flex; gap: 6px; align-items: center; }
.dash-filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 8px; }
.dash-filters[open] { flex-basis: 100%; }
.dash-filters[open] > summary { margin-bottom: 2px; }
/* multiselect as on/off switch list */
.toggle-box { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.toggle-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.toggle-head .toggle-search { flex: 1 1 160px; min-width: 120px; }
.toggle-list { max-height: 240px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 12px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 4px; border-bottom: 1px solid var(--line-soft, #f0f0f0); cursor: pointer; }
.toggle-row .toggle-text { font-size: .92em; }
