/* ==========================================================================
   MERKEB INDUSTRIAL — operational panels
   Customer / Vendor / Moderator / Admin / Super Admin / Control room
   Denser than the storefront by design: smaller type, tighter rhythm.
   ========================================================================== */

.panel-body{
  --rail-w: 252px;
  font-size:var(--step--1);
}
.panel-shell{ display:grid; grid-template-columns:var(--rail-w) minmax(0,1fr); min-height:100vh; }

/* ---------- left rail ---------------------------------------------------- */
.rail{
  background:var(--color-ink); color:rgba(255,255,255,.66);
  display:flex; flex-direction:column; position:sticky; top:0; height:100vh; overflow-y:auto;
}
.rail-head{ padding:20px 20px 18px; border-bottom:1px solid rgba(255,255,255,.1); }
.rail-head .logo-word{ color:#fff; font-size:15px; }
.rail-scope{
  margin-top:14px; display:flex; align-items:center; gap:9px;
  font-family:var(--font-mono); font-size:10px; letter-spacing:.12em; color:var(--color-accent);
}
.rail-scope::before{ content:""; width:16px; height:2px; background:var(--color-accent); }

.rail-nav{ padding:14px 12px; flex:1; }
.rail-nav .group{ font-family:var(--font-mono); font-size:10px; letter-spacing:.14em; color:rgba(255,255,255,.3); padding:14px 10px 7px; }
.rail-nav a{
  display:flex; align-items:center; gap:11px; padding:9px 10px;
  border-radius:var(--radius-small); font-size:13px; line-height:1.2;
  transition:background .15s var(--ease), color .15s var(--ease);
}
.rail-nav a:hover{ background:rgba(255,255,255,.06); color:#fff; }
.rail-nav a[data-current="true"]{ background:rgba(255,255,255,.09); color:#fff; box-shadow:inset 2px 0 0 var(--color-accent); }
.rail-nav a .pip{
  margin-left:auto; font-family:var(--font-mono); font-size:10px;
  background:var(--color-accent); color:var(--color-ink); padding:1px 6px; border-radius:8px;
}
.rail-nav svg{ width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:1.5; flex:none; opacity:.8; }
.rail-foot{ padding:16px 20px; border-top:1px solid rgba(255,255,255,.1); font-size:11px; }
.rail-foot .who{ display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.rail-foot .avatar{
  width:30px; height:30px; background:rgba(255,255,255,.1); color:#fff;
  display:grid; place-items:center; font-size:11px; font-weight:600; flex:none;
}
.rail-foot .who b{ display:block; color:#fff; font-size:12px; }
.rail-foot .who span{ font-family:var(--font-mono); font-size:10px; color:rgba(255,255,255,.4); }

/* ---------- top bar ------------------------------------------------------ */
.panel-main{ display:flex; flex-direction:column; min-width:0; background:var(--color-background); }
.panel-top{
  display:flex; align-items:center; gap:18px; padding:0 28px; height:62px;
  background:var(--color-surface); border-bottom:1px solid var(--color-border);
  position:sticky; top:0; z-index:50;
}
.panel-top h1{ font-size:var(--step-1); font-weight:600; }
.panel-top .sub{ font-family:var(--font-mono); font-size:11px; color:var(--color-muted); }
.panel-top .spacer{ margin-left:auto; }
.panel-search{ position:relative; width:260px; }
.panel-search input{ width:100%; height:36px; padding:0 12px 0 34px; border:1px solid var(--color-border); background:var(--color-background); font-size:13px; }
.panel-search svg{ position:absolute; left:11px; top:10px; width:15px; height:15px; stroke:var(--color-faint); fill:none; stroke-width:1.7; }
.rail-toggle{ display:none; }

.panel-content{ padding:26px 28px 60px; }
.panel-section{ margin-bottom:34px; }
.panel-section > header{
  display:flex; align-items:center; justify-content:space-between; gap:20px;
  margin-bottom:14px; padding-bottom:10px; border-bottom:1px solid var(--color-border);
}
.panel-section > header h2{ font-size:var(--step-0); font-weight:600; letter-spacing:0; }
.panel-section > header .hint{ font-size:11px; color:var(--color-muted); font-family:var(--font-mono); }

/* ---------- metric strip ------------------------------------------------- */
.metrics{ display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:1px; background:var(--color-border); border:1px solid var(--color-border); margin-bottom:28px; }
.metric{ background:var(--color-surface); padding:18px 20px 20px; position:relative; }
.metric .label{ font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--color-muted); }
.metric .value{ font-family:var(--font-mono); font-size:var(--step-3); font-weight:600; letter-spacing:-.03em; margin-top:8px; line-height:1.1; overflow-wrap:break-word; }
.metric .value small{ font-size:13px; font-weight:500; color:var(--color-muted); letter-spacing:0; }
.metric .delta{ margin-top:9px; font-family:var(--font-mono); font-size:11px; display:inline-flex; align-items:center; gap:5px; }
.metric .delta[data-dir="up"]{ color:var(--color-success); }
.metric .delta[data-dir="down"]{ color:var(--color-danger); }
.metric .delta[data-dir="flat"]{ color:var(--color-muted); }
.metric[data-alert="true"]{ box-shadow:inset 3px 0 0 var(--color-accent); }

/* ---------- surface card ------------------------------------------------- */
.surface{ background:var(--color-surface); border:1px solid var(--color-border); }
.surface > header{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:14px 18px; border-bottom:1px solid var(--color-border);
}
.surface > header h3{ font-size:var(--step-0); font-weight:600; }
.surface .pad{ padding:18px; }
.split{ display:grid; gap:22px; }
.split-2{ grid-template-columns:minmax(0,1.6fr) minmax(0,1fr); }
.split-even{ grid-template-columns:repeat(2,minmax(0,1fr)); }

/* ---------- tables ------------------------------------------------------- */
.dtable{ width:100%; font-size:13px; }
.dtable thead th{
  text-align:left; font-weight:600; font-size:11px; letter-spacing:.07em; text-transform:uppercase;
  color:var(--color-muted); background:var(--color-surface-alt);
  padding:9px 14px; border-bottom:1px solid var(--color-border); white-space:nowrap;
}
.dtable tbody td{ padding:11px 14px; border-bottom:1px solid var(--color-border); vertical-align:middle; }
.dtable tbody tr:hover{ background:var(--color-background); }
.dtable .num{ font-family:var(--font-mono); text-align:right; white-space:nowrap; }
.dtable .id{ font-family:var(--font-mono); font-size:12px; }
.dtable .actions{ display:flex; gap:6px; justify-content:flex-end; }
.dtable .prime{ font-weight:600; }
.dtable .sub{ font-size:11px; color:var(--color-muted); }
.linkish{ font-size:12px; font-weight:600; border-bottom:1px solid var(--color-border-strong); padding-bottom:1px; }
.linkish:hover{ border-bottom-color:var(--color-ink); }
.linkish[data-tone="danger"]{ color:var(--color-danger); }

.chip{
  display:inline-flex; align-items:center; gap:6px; padding:3px 9px;
  font-size:11px; font-weight:600; border:1px solid var(--color-border);
  background:var(--color-surface); white-space:nowrap;
}
.chip::before{ content:""; width:6px; height:6px; border-radius:50%; background:var(--color-faint); }
.chip[data-tone="ok"]{ color:var(--color-success); border-color:#BFD8C8; background:#F1F8F3; }
.chip[data-tone="ok"]::before{ background:var(--color-success); }
.chip[data-tone="warn"]{ color:var(--color-warning); border-color:#E7D2A6; background:var(--color-accent-wash); }
.chip[data-tone="warn"]::before{ background:var(--color-warning); }
.chip[data-tone="bad"]{ color:var(--color-danger); border-color:#E5C4C0; background:#FBF1F0; }
.chip[data-tone="bad"]::before{ background:var(--color-danger); }
.chip[data-tone="info"]{ color:var(--color-info); border-color:#C3D5E2; background:#F0F5F9; }
.chip[data-tone="info"]::before{ background:var(--color-info); }

.filterbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:12px 18px; border-bottom:1px solid var(--color-border); background:var(--color-background); }
.filterbar .input{ height:34px; width:auto; min-width:140px; }
.filterbar .grow{ flex:1; min-width:180px; }

/* ---------- charts (pure CSS/SVG) --------------------------------------- */
.chart-bars{ display:flex; align-items:flex-end; gap:8px; height:210px; padding:16px 18px 0; }
.chart-bars .col{ flex:1; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; gap:8px; height:100%; }
.chart-bars .bar{
  width:100%; max-width:38px; background:var(--color-ink); position:relative;
  transition:height .8s var(--ease); border-top:3px solid var(--color-accent);
}
.chart-bars .col:hover .bar{ background:var(--color-accent-dark); }
.chart-bars .bar::after{
  content:attr(data-value); position:absolute; top:-20px; left:50%; transform:translateX(-50%);
  font-family:var(--font-mono); font-size:10px; color:var(--color-muted); opacity:0; transition:opacity .15s;
  white-space:nowrap;
}
.chart-bars .col:hover .bar::after{ opacity:1; }
.chart-bars .lab{ font-family:var(--font-mono); font-size:10px; color:var(--color-muted); }
.chart-foot{ display:flex; gap:20px; padding:14px 18px; border-top:1px solid var(--color-border); font-size:11px; color:var(--color-muted); }
.chart-foot b{ font-family:var(--font-mono); color:var(--color-ink); font-size:13px; display:block; }

.chart-line{ padding:14px 18px; }
.chart-line svg{ width:100%; height:190px; overflow:visible; }
.chart-line .grid line{ stroke:var(--color-border); stroke-width:1; }
.chart-line .series{ fill:none; stroke:var(--color-ink); stroke-width:2; stroke-linejoin:round; }
.chart-line .series-2{ stroke:var(--color-accent); stroke-dasharray:4 3; }
.chart-line .area{ fill:rgba(22,24,26,.06); }
.chart-line .dot{ fill:var(--color-surface); stroke:var(--color-ink); stroke-width:2; }
.chart-line .axis{ font-family:var(--font-mono); font-size:10px; fill:var(--color-faint); }

.legend{ display:flex; gap:18px; font-size:11px; color:var(--color-muted); padding:0 18px 14px; }
.legend i{ width:14px; height:2px; display:inline-block; vertical-align:middle; margin-right:7px; background:var(--color-ink); }
.legend .alt i{ background:var(--color-accent); }

.meter{ height:6px; background:var(--color-surface-alt); overflow:hidden; }
.meter i{ display:block; height:100%; background:var(--color-ink); }
.meter[data-tone="accent"] i{ background:var(--color-accent); }

/* ---------- activity feed ----------------------------------------------- */
.feed{ padding:6px 18px 14px; }
.feed li{ display:grid; grid-template-columns:auto 1fr; gap:14px; padding:11px 0; border-bottom:1px solid var(--color-border); }
.feed li:last-child{ border-bottom:0; }
.feed time{ font-family:var(--font-mono); font-size:10px; color:var(--color-faint); padding-top:2px; white-space:nowrap; }
.feed .what{ font-size:12px; line-height:1.45; }
.feed .what b{ font-weight:600; }

/* ---------- moderation queue -------------------------------------------- */
.queue-item{
  display:grid; grid-template-columns:82px minmax(0,1fr) 170px auto; gap:18px;
  align-items:center; padding:16px 18px; border-bottom:1px solid var(--color-border);
}
.queue-item:last-child{ border-bottom:0; }
.queue-item img{ width:82px; height:62px; object-fit:cover; background:var(--color-surface-alt); }
.queue-item .q-name{ font-weight:600; font-size:13px; }
.queue-item .q-meta{ font-family:var(--font-mono); font-size:11px; color:var(--color-muted); margin-top:3px; }
.queue-item .q-vendor{ font-size:12px; min-width:0; overflow-wrap:break-word; }
.queue-item .q-vendor span{ display:block; color:var(--color-muted); font-size:11px; }
.queue-actions{ display:flex; gap:6px; justify-content:flex-end; }
.queue-item[data-state="approved"]{ background:#F4F8F5; }
.queue-item[data-state="rejected"]{ background:#FBF3F2; opacity:.8; }

/* ---------- permission matrix / toggles ---------------------------------- */
.matrix{ font-size:12px; }
.matrix th{ text-align:left; padding:10px 12px; border-bottom:1px solid var(--color-border); background:var(--color-surface-alt); font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--color-muted); }
.matrix th.perm{ text-align:center; width:96px; }
.matrix td{ padding:10px 12px; border-bottom:1px solid var(--color-border); }
.matrix td.perm{ text-align:center; }
.matrix .role-name b{ display:block; font-size:13px; }
.matrix .role-name span{ font-family:var(--font-mono); font-size:10px; color:var(--color-muted); letter-spacing:.08em; }

.switch{ position:relative; display:inline-block; width:36px; height:20px; vertical-align:middle; }
.switch input{ opacity:0; width:0; height:0; }
.switch i{
  position:absolute; inset:0; background:var(--color-border-strong); border-radius:20px;
  transition:background .2s var(--ease); cursor:pointer;
}
.switch i::before{
  content:""; position:absolute; top:2px; left:2px; width:16px; height:16px;
  background:#fff; border-radius:50%; transition:transform .2s var(--ease);
  box-shadow:0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + i{ background:var(--color-ink); }
.switch input:checked + i::before{ transform:translateX(16px); }
.switch input:disabled + i{ opacity:.55; cursor:not-allowed; }
.switch input:disabled:not(:checked) + i{ opacity:.35; }
.switch input:focus-visible + i{ outline:2px solid var(--color-accent); outline-offset:2px; }

.role-cards{ display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:1px; background:var(--color-border); }
.role-card{ background:var(--color-surface); padding:18px; }
.role-card .tier{ font-family:var(--font-mono); font-size:10px; letter-spacing:.12em; color:var(--color-muted); }
.role-card h4{ font-size:var(--step-0); margin:6px 0 10px; }
.role-card .count{ font-family:var(--font-mono); font-size:var(--step-2); font-weight:600; letter-spacing:-.02em; }
.role-card p{ font-size:11px; color:var(--color-muted); margin:6px 0 0; }
.role-card[data-tier="super"]{ box-shadow:inset 0 3px 0 var(--color-accent); }

/* ---------- health / system --------------------------------------------- */
.kv{ display:grid; grid-template-columns:1fr auto; gap:8px 16px; font-size:12px; padding:4px 0; }
.kv dt{ color:var(--color-muted); }
.kv dd{ margin:0; font-family:var(--font-mono); }
.logline{
  font-family:var(--font-mono); font-size:11px; padding:7px 18px; border-bottom:1px solid var(--color-border);
  display:grid; grid-template-columns:130px 70px 1fr; gap:14px; align-items:baseline;
}
.logline:hover{ background:var(--color-background); }
.logline .lvl{ font-weight:600; }
.logline[data-lvl="warn"] .lvl{ color:var(--color-warning); }
.logline[data-lvl="error"] .lvl{ color:var(--color-danger); }
.logline[data-lvl="info"] .lvl{ color:var(--color-info); }
.logline .msg{ color:var(--color-muted); }

/* ---------- overflow safety --------------------------------------------
   Grid/flex items default to min-width:auto (their max-content size),
   which can force a track — and the whole page — wider than the viewport
   even when the track itself is sized with minmax()/1fr. Zeroing the
   item's minimum lets long values and log lines wrap instead of pushing
   the layout sideways on narrow screens. */
.metric, .logline > *, .feed li > *, .kv, .role-card, .chart-bars .col,
.veh-rows .r, .telemetry .tel, .surface, .panel-content, .split > * {
  min-width: 0;
}
.logline{ overflow-wrap:anywhere; }
.logline .msg{ white-space:normal; }
.feed .what{ overflow-wrap:break-word; }
.chart-line{ overflow-x:auto; }

.control-body{ background:#0E1012; color:rgba(255,255,255,.76); }
.control-shell{ display:grid; grid-template-columns:300px minmax(0,1fr) 320px; height:calc(100vh - 54px); }
.control-top{
  height:54px; display:flex; align-items:center; gap:18px; padding:0 20px;
  background:var(--color-ink); border-bottom:1px solid rgba(255,255,255,.12);
}
.control-top .logo-word{ color:#fff; font-size:14px; }
.control-top .spacer{ margin-left:auto; }
.control-clock{ font-family:var(--font-mono); font-size:12px; color:rgba(255,255,255,.6); letter-spacing:.06em; }
.live-flag{
  display:inline-flex; align-items:center; gap:8px; font-family:var(--font-mono);
  font-size:10px; letter-spacing:.14em; color:var(--color-accent);
  border:1px solid rgba(223,162,20,.4); padding:4px 10px;
}
.live-flag i{ width:6px; height:6px; border-radius:50%; background:var(--color-accent); animation:blip 1.8s infinite; }
@keyframes blip{ 0%,100%{ opacity:1 } 50%{ opacity:.25 } }

.control-col{ background:#141719; border-right:1px solid rgba(255,255,255,.1); display:flex; flex-direction:column; min-height:0; }
.control-col:last-child{ border-right:0; border-left:1px solid rgba(255,255,255,.1); }
.control-col > header{
  padding:14px 18px; border-bottom:1px solid rgba(255,255,255,.1);
  display:flex; align-items:center; justify-content:space-between;
}
.control-col > header h2{ font-size:12px; letter-spacing:.1em; text-transform:uppercase; color:rgba(255,255,255,.55); font-weight:600; }
.control-col .scroll{ overflow-y:auto; flex:1; min-height:0; }

.fleet-item{
  display:block; width:100%; text-align:left; padding:14px 18px;
  border-bottom:1px solid rgba(255,255,255,.08); transition:background .15s var(--ease);
}
.fleet-item:hover{ background:rgba(255,255,255,.04); }
.fleet-item[data-active="true"]{ background:rgba(223,162,20,.09); box-shadow:inset 3px 0 0 var(--color-accent); }
.fleet-item .f-top{ display:flex; align-items:center; gap:10px; }
.fleet-item .f-id{ font-family:var(--font-mono); font-size:13px; font-weight:600; color:#fff; }
.fleet-item .f-kind{ font-size:11px; color:rgba(255,255,255,.45); }
.fleet-item .f-route{ font-size:12px; margin:8px 0 6px; color:rgba(255,255,255,.72); }
.fleet-item .f-route span{ color:rgba(255,255,255,.35); margin:0 6px; }
.fleet-item .f-meta{ display:flex; gap:14px; font-family:var(--font-mono); font-size:10px; color:rgba(255,255,255,.45); }
.state{
  margin-left:auto; font-family:var(--font-mono); font-size:9px; letter-spacing:.1em;
  padding:2px 7px; border:1px solid currentColor;
}
.state[data-s="transit"]{ color:var(--color-accent); }
.state[data-s="loading"]{ color:#7FA8C9; }
.state[data-s="delivered"]{ color:#6FBF8F; }
.state[data-s="hold"]{ color:#D98A80; }

#fleetMap{ height:100%; width:100%; background:#1A1D20; }
.map-wrap{ position:relative; min-height:0; }
.map-controls{
  position:absolute; left:14px; bottom:14px; z-index:500; display:flex; gap:6px; flex-wrap:wrap;
}
.map-controls button{
  background:rgba(20,23,25,.92); border:1px solid rgba(255,255,255,.18); color:rgba(255,255,255,.76);
  font-size:11px; padding:7px 12px; letter-spacing:.02em; backdrop-filter:blur(4px);
}
.map-controls button:hover{ border-color:var(--color-accent); color:#fff; }
.map-controls button[aria-pressed="true"]{ background:var(--color-accent); color:var(--color-ink); border-color:var(--color-accent); font-weight:600; }
.map-note{
  position:absolute; right:14px; top:14px; z-index:500;
  background:rgba(20,23,25,.92); border:1px solid rgba(255,255,255,.14);
  padding:8px 12px; font-size:11px; color:rgba(255,255,255,.6); max-width:260px; line-height:1.4;
}

.veh-hero{ padding:18px; border-bottom:1px solid rgba(255,255,255,.1); }
.veh-hero .vid{ font-family:var(--font-mono); font-size:var(--step-2); font-weight:600; color:#fff; letter-spacing:-.01em; }
.veh-hero .vkind{ font-size:12px; color:rgba(255,255,255,.45); }
.telemetry{ display:grid; grid-template-columns:1fr 1fr; gap:1px; background:rgba(255,255,255,.1); }
.tel{ background:#141719; padding:14px 16px; }
.tel .t-lab{ font-size:10px; letter-spacing:.1em; text-transform:uppercase; color:rgba(255,255,255,.4); }
.tel .t-val{ font-family:var(--font-mono); font-size:var(--step-1); color:#fff; margin-top:5px; letter-spacing:-.01em; }
.tel .t-val small{ font-size:11px; color:rgba(255,255,255,.45); }
.veh-rows{ padding:16px 18px; display:grid; gap:11px; font-size:12px; }
.veh-rows .r{ display:flex; justify-content:space-between; gap:12px; }
.veh-rows .r span:first-child{ color:rgba(255,255,255,.45); }
.veh-rows .r span:last-child{ font-family:var(--font-mono); color:#fff; }
.route-line{ padding:16px 18px; border-top:1px solid rgba(255,255,255,.1); }
.route-line li{ display:grid; grid-template-columns:58px 1fr; gap:12px; padding-bottom:14px; position:relative; }
.route-line li::before{
  content:""; position:absolute; left:64px; top:16px; bottom:0; width:1px; background:rgba(255,255,255,.14);
}
.route-line li:last-child{ padding-bottom:0; }
.route-line li:last-child::before{ display:none; }
.route-line time{ font-family:var(--font-mono); font-size:10px; color:rgba(255,255,255,.4); }
.route-line .pt{ font-size:12px; position:relative; padding-left:16px; }
.route-line .pt::before{
  content:""; position:absolute; left:-5px; top:5px; width:7px; height:7px; border-radius:50%;
  background:#141719; border:2px solid rgba(255,255,255,.3);
}
.route-line li[data-done="true"] .pt::before{ background:var(--color-accent); border-color:var(--color-accent); }
.route-line li[data-done="true"] .pt{ color:#fff; }

/* leaflet skin ----------------------------------------------------------- */
.leaflet-container{ background:#1A1D20 !important; font-family:var(--font-body) !important; }
.leaflet-control-attribution{ background:rgba(20,23,25,.85) !important; color:rgba(255,255,255,.4) !important; font-size:9px !important; }
.leaflet-control-attribution a{ color:rgba(255,255,255,.6) !important; }
.leaflet-control-zoom a{
  background:rgba(20,23,25,.92) !important; color:#fff !important;
  border-color:rgba(255,255,255,.16) !important;
}
.leaflet-control-zoom a:hover{ background:var(--color-accent) !important; color:var(--color-ink) !important; }
.veh-marker{
  width:30px; height:30px; display:grid; place-items:center;
  background:var(--color-ink); border:2px solid var(--color-accent); border-radius:50%;
  font-family:var(--font-mono); font-size:9px; font-weight:600; color:#fff;
  box-shadow:0 0 0 6px rgba(223,162,20,.14);
  transition:box-shadow .25s var(--ease);
}
.veh-marker[data-sel="true"]{ box-shadow:0 0 0 12px rgba(223,162,20,.22); }
.veh-marker[data-s="delivered"]{ border-color:#6FBF8F; box-shadow:0 0 0 6px rgba(111,191,143,.14); }
.veh-marker[data-s="hold"]{ border-color:#D98A80; box-shadow:0 0 0 6px rgba(217,138,128,.14); }
.stop-dot{ width:10px; height:10px; border-radius:50%; background:#fff; border:2px solid var(--color-ink); }

/* map on light pages (contact / order tracking) --------------------------- */
.map-light{ height:320px; border:1px solid var(--color-border); background:var(--color-surface-alt); }
