/* --- MCC AI Design Inspector - light UAE-government theme --- */
/* Design system recreated from the TP/025 proposal deck (slide 5 "التغطية"):
   paper/sand surfaces, ink text, gold accents, Tajawal + Inter + JetBrains
   Mono, large radii, deep soft shadows, colored card top-borders. */
:root {
  --bg: #FBF7EE;
  --surface: #ffffff;
  --surface-2: #FCFAF5;
  --border: #EDE3CC;
  --border-strong: #D9C99E;
  --text: #101820;
  --text-dim: #4E5D66;
  --gold: #C89B3C;
  --gold-deep: #A87E1A;
  --gold-soft: #F3E7C6;
  --pass: #1b7a4b;
  --pass-bg: #e6f4ec;
  --warn: #a76a08;
  --warn-bg: #fbf0da;
  --fail: #b23327;
  --fail-bg: #fbe9e6;
  --info: #2c5d86;
  --id: #cf3a2e;
  --rec: #1d8a4c;
  --det: #2f6fd0;
  --shadow: 0 18px 50px -20px rgba(16, 24, 32, .28);
  --shadow-sm: 0 8px 24px -12px rgba(16, 24, 32, .22);
  --radius: 20px;
  --mono: 'JetBrains Mono', monospace;
  font-size: 15px;
}
:root[data-theme="dark"] {
  --bg: #0A1016;
  --surface: #131E27;
  --surface-2: #182530;
  --border: #24313C;
  --border-strong: #35455270;
  --text: #E9EEF2;
  --text-dim: #93A3AD;
  --gold: #D4A537;
  --gold-deep: #E3BC5E;
  --gold-soft: #2E2A18;
  --pass: #4cc07e;
  --pass-bg: #16281f;
  --warn: #e0a53e;
  --warn-bg: #2d2513;
  --fail: #e06a5e;
  --fail-bg: #301d17;
  --info: #7fb0d9;
  --id: #e0584a;
  --rec: #41b06f;
  --det: #6b9dea;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, .6);
  --shadow-sm: 0 8px 24px -12px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; margin: 0; }
input, select, textarea { background: var(--surface); color: var(--text); }
body { transition: background .2s; }
body {
  background: linear-gradient(180deg, var(--surface-2), var(--bg)); color: var(--text);
  font-family: 'Tajawal', 'Inter', "Segoe UI", system-ui, sans-serif;
  height: 100vh; overflow: hidden; display: flex; flex-direction: column;
}
:root[data-theme="dark"] body {
  background: radial-gradient(1200px 600px at 80% -10%, #1C2B38 0%, #101820 55%, #0A1016);
}
.ar { font-size: .78em; color: inherit; opacity: .75; margin-inline-start: .45em; direction: rtl; }

/* Top bar — one clean row: brand | page nav | plan switch + theme */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 26px; background: transparent;
  border-bottom: 1px solid var(--border);
}
/* Page nav — pill segmented control, deck-kicker style */
.page-nav {
  margin-inline: auto; display: flex; flex-shrink: 0; gap: 3px;
  border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
  background: var(--surface); padding: 4px; box-shadow: var(--shadow-sm);
}
.page-nav button {
  border: none; border-radius: 999px; background: none; padding: 8px 20px;
  font-family: inherit; font-weight: 700;
}
.page-nav button.pulse { animation: pulse 1s ease-in-out 3; }
.top-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.meta-strip {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 22px 0;
  font-size: .74rem;
}
.meta-strip:empty, .meta-strip.hidden { display: none; }
.toolbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; width: 100%; }
.tool-sep { width: 1px; height: 22px; background: var(--border-strong); flex-shrink: 0; }
@media (max-width: 1280px) {
  .brand-ar { display: none; }
  .topbar { gap: 10px; }
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-ar { font-weight: 800; font-size: 1.06rem; direction: rtl; text-align: left; color: var(--text); letter-spacing: 0; }
.brand-en { font-family: var(--mono); font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); margin-top: 1px; }
.tender-ref { color: var(--gold); font-weight: 600; }
.plan-switch { display: flex; gap: 6px; margin-inline-start: auto; }
.plan-switch button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 15px; border-radius: 999px; cursor: pointer; font-size: .88rem; font-weight: 500;
}
.plan-switch button.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-deep); font-weight: 800; }
.meta-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  border-radius: 999px; padding: 5px 14px; font-size: .76rem; color: var(--text-dim);
}
.chip::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-inline-end: 7px; vertical-align: 1px; }
.chip b { color: var(--text); }

/* KPIs */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; padding: 14px 22px 0;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 13px 17px 12px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::before { /* deck-style coloured top border */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--border-strong); border-radius: 4px 4px 0 0;
}
.kpi.good::before { background: var(--pass); }
.kpi.warn::before { background: var(--gold); }
.kpi.bad::before { background: var(--fail); }
.kpi .v { font-family: 'Inter', sans-serif; font-size: 1.55rem; font-weight: 800; letter-spacing: -.5px; }
.kpi .l { font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); margin-top: 3px; }
.kpi .l .ar { display: block; margin: 0; }
.kpi.good .v { color: var(--pass); } .kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--fail); }
.kpi .bar { height: 5px; border-radius: 4px; background: var(--border); margin-top: 8px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; border-radius: 4px; background: currentColor; }

/* Layout */
.content { display: flex; gap: 14px; padding: 14px 22px 18px; flex: 1; min-height: 0; overflow: hidden; }
.map-card {
  flex: 1.6; min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow);
}
.map-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.tool-group { display: flex; align-items: center; gap: 6px; }
.tool {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 11px;
  padding: 7px 12px; cursor: pointer; font-size: .84rem; font-family: inherit; font-weight: 500; color: var(--text);
}
.tool:hover { border-color: var(--gold); }
.tool.armed { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-deep); font-weight: 700; }
.tool-ai { background: linear-gradient(120deg, #fdf6e6, #f6ecd2); border-color: var(--gold); color: var(--gold-deep); font-weight: 600; }
.tool-ghost { border-style: dashed; color: var(--text-dim); }
.layers { margin-inline-start: auto; gap: 10px; }
.layers label { font-size: .8rem; color: var(--text-dim); display: flex; gap: 4px; align-items: center; cursor: pointer; }
.scale-group { font-size: .8rem; color: var(--text-dim); }
.scale-group input { width: 74px; padding: 4px 6px; border: 1px solid var(--border-strong); border-radius: 6px; }
.scale-note { font-size: .7rem; color: var(--warn); max-width: 150px; }
.canvas-wrap { position: relative; flex: 1; min-height: 0; background: var(--bg); }
#planCanvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
#view3d { position: absolute; inset: 0; }
.pov-label {
  position: absolute; right: 12px;
  background: rgba(44,39,33,.85); color: #fff; font-size: .74rem;
  padding: 4px 10px; border-radius: 7px 7px 0 0; pointer-events: none;
}
#view3d canvas { display: block; }
#view3d.hidden { display: none; }
#planCanvas.placing { cursor: crosshair; }
.map-legend {
  position: absolute; left: 10px; bottom: 10px; display: flex; gap: 10px; flex-wrap: wrap;
  background: rgba(255,255,255,.92); border: 1px solid var(--border); border-radius: 9px;
  padding: 6px 10px; font-size: .72rem;
}
.lg b { border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-inline-start: 2px; font-size: .9em; }
.lg-id { color: var(--id); } .lg-rec { color: var(--rec); } .lg-det { color: var(--det); } .lg-blind { color: #8a4a00; }
.hint {
  position: absolute; top: 8px; right: 10px; font-size: .72rem; color: var(--text-dim);
  background: rgba(255,255,255,.85); padding: 3px 9px; border-radius: 7px; border: 1px solid var(--border);
}

/* Side panel */
.side {
  flex: 1; min-width: 360px; max-width: 470px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow);
}
.tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tabs button {
  flex: 1; border: none; background: none; padding: 12px 6px; cursor: pointer;
  font-family: inherit; font-size: .86rem; font-weight: 700; color: var(--text-dim); border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--gold-deep); font-weight: 800; border-bottom-color: var(--gold); background: var(--surface); }
.tab-body { flex: 1; overflow-y: auto; padding: 12px; }
.hidden { display: none !important; }

/* Checklist */
.cl-section { margin-bottom: 14px; }
.cl-section h3 {
  font-family: var(--mono); font-size: .66rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--gold-deep); margin: 6px 2px 9px;
}
.cl-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 9px; margin-bottom: 6px; background: var(--surface-2); font-size: .84rem;
}
.cl-row .st { font-weight: 800; font-size: .72rem; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.st-pass { color: var(--pass); background: var(--pass-bg); border: 1px solid #bfe3cf; }
.st-partial { color: var(--warn); background: var(--warn-bg); border: 1px solid #ecd6a8; }
.st-fail { color: var(--fail); background: var(--fail-bg); border: 1px solid #f0c4bd; }
.st-info { color: var(--info); background: #e9f1f8; border: 1px solid #c5d9e8; }
.cl-name { flex: 1; min-width: 0; }
.cl-name small { display: block; color: var(--text-dim); font-size: .72rem; }
.lvl-chip {
  font-size: .68rem; font-weight: 800; padding: 2px 7px; border-radius: 5px; border: 1.5px solid; white-space: nowrap;
}
.lvl-identification { color: var(--id); border-color: var(--id); background: #fdeeec; }
.lvl-recognition { color: var(--rec); border-color: var(--rec); background: #e9f6ee; }
.lvl-detection { color: var(--det); border-color: var(--det); background: #ebf2fc; }
.cl-row .loc { border: none; background: none; cursor: pointer; font-size: 1rem; opacity: .6; }
.cl-row .loc:hover { opacity: 1; }
.cl-summary { font-size: .8rem; color: var(--text-dim); margin: 2px 2px 10px; }

/* Cameras tab */
.cam-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 9px; margin-bottom: 6px; cursor: pointer; font-size: .85rem; background: var(--surface-2);
}
.cam-row.sel { border-color: var(--gold); background: var(--gold-soft); }
.cam-row .cam-status { font-size: .68rem; padding: 2px 7px; border-radius: 5px; }
.cs-existing { background: #e8eef5; color: var(--info); }
.cs-proposed-ai { background: var(--gold-soft); color: var(--gold-deep); border: 1px dashed var(--gold); }
.cs-proposed-inspector { background: var(--pass-bg); color: var(--pass); border: 1px dashed var(--pass); }
.cam-editor {
  border: 1px solid var(--border-strong); border-radius: 11px; padding: 11px; margin-top: 10px;
  background: var(--surface-2); font-size: .84rem; display: grid; gap: 9px;
}
.cam-editor label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-dim); }
.cam-editor select, .cam-editor input[type=number] { padding: 4px 7px; border: 1px solid var(--border-strong); border-radius: 6px; width: 120px; }
.cam-editor input[type=range] { width: 150px; }
.cam-reason { font-size: .75rem; color: var(--gold-deep); background: var(--gold-soft); border-radius: 7px; padding: 6px 9px; }
.btn-danger { background: var(--fail-bg); color: var(--fail); border: 1px solid #f0c4bd; border-radius: 7px; padding: 6px 10px; cursor: pointer; }
.btn-small { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; padding: 5px 10px; cursor: pointer; font-size: .8rem; }

/* AI tab */
.ai-actions { display: grid; gap: 8px; margin-bottom: 10px; }
.btn-primary {
  background: linear-gradient(120deg, var(--gold), var(--gold-deep)); color: #fff; font-weight: 800;
  border: none; border-radius: 12px; padding: 12px; cursor: pointer; font-size: .92rem;
  box-shadow: var(--shadow-sm); font-family: inherit;
}
.btn-primary:disabled { opacity: .55; cursor: wait; }
.ai-cost { font-size: .74rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ai-cost b { color: var(--gold-deep); }
.report {
  font-size: .84rem; line-height: 1.55; border: 1px solid var(--border); border-radius: 10px;
  padding: 4px 13px; background: var(--surface-2); margin-bottom: 12px; max-height: 46vh; overflow-y: auto;
}
.report:empty { display: none; }
.report h2 { font-size: 1rem; color: var(--gold-deep); margin: 12px 0 6px; }
.report h3 { font-size: .9rem; margin: 10px 0 4px; }
.report p, .report li { margin: 6px 0; }
.report [dir=rtl] { text-align: right; }
.chat { border-top: 1px solid var(--border); padding-top: 10px; }
.chat-log { display: grid; gap: 8px; max-height: 30vh; overflow-y: auto; margin-bottom: 8px; }
.msg { padding: 8px 11px; border-radius: 11px; font-size: .84rem; line-height: 1.5; max-width: 92%; }
.msg.user { background: var(--gold-soft); justify-self: end; }
.msg.bot { background: var(--surface-2); border: 1px solid var(--border); justify-self: start; white-space: pre-wrap; }
.msg .cost { display: block; font-size: .68rem; color: var(--text-dim); margin-top: 4px; }
.chat-input { display: flex; gap: 6px; }
.chat-input input { flex: 1; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 9px; font-size: .86rem; }
.chat-input button {
  width: 40px; border: none; border-radius: 9px; background: var(--gold); color: #fff; font-size: 1.1rem; cursor: pointer;
}

.foot {
  padding: 9px 26px; font-size: .7rem; color: var(--text-dim);
  border-top: 1px solid var(--border); background: transparent;
  border-inline-start: 3px solid var(--gold);
}
@media (max-width: 1100px) { .content { flex-direction: column; } .side { max-width: none; } }

/* --- Pages & nav --- */
.page { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.page.hidden { display: none; }
.page-nav button {
  color: var(--text-dim); cursor: pointer; font-size: .92rem;
}
.page-nav button.active { background: linear-gradient(120deg, var(--gold), var(--gold-deep)); color: #fff; }
:root[data-theme="dark"] .page-nav button.active { color: #101820; }
@keyframes pulse { 50% { background: var(--gold-soft); color: var(--gold-deep); } }
.page-scroll { flex: 1; overflow-y: auto; padding: 18px 26px 30px; }

/* --- Training page --- */
.train-intro h1 { font-size: 1.6rem; font-weight: 900; color: var(--text); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ar-block { font-size: .85em; direction: rtl; color: var(--text-dim); font-weight: 500; }
.train-intro p { color: var(--text-dim); font-size: .9rem; margin: 6px 0 16px; max-width: 860px; }
.train-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); gap: 16px; }
.train-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.train-card h2 { font-size: 1.02rem; color: var(--text); margin-bottom: 4px; }
.tc-sub { font-size: .8rem; color: var(--text-dim); margin: 4px 0 12px; }
.krow {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 7px; background: var(--surface-2);
}
.krow-off { opacity: .55; }
.kmain { flex: 1; min-width: 0; font-size: .87rem; }
.kmain small { display: block; color: var(--text-dim); font-size: .73rem; margin-top: 1px; }
.k-live { color: var(--pass); font-weight: 600; }
.ktoggle {
  width: 38px; height: 21px; border-radius: 999px; background: #cfc8ba; cursor: pointer; position: relative; flex-shrink: 0; transition: background .2s;
}
.ktoggle i { position: absolute; top: 2.5px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: left .2s; }
.ktoggle.on { background: var(--pass); }
.ktoggle.on i { left: 19px; }
.btn-x { border: none; background: none; cursor: pointer; opacity: .5; font-size: .95rem; }
.btn-x:hover { opacity: 1; }
.upload-zone {
  display: block; text-align: center; border: 2px dashed var(--border-strong); border-radius: 11px;
  padding: 13px; font-size: .84rem; color: var(--text-dim); cursor: pointer; margin-top: 10px;
}
.upload-zone:hover { border-color: var(--gold); color: var(--gold-deep); background: var(--gold-soft); }
.tdata-count { font-size: .8rem; color: var(--gold-deep); background: var(--gold-soft); border-radius: 8px; padding: 6px 10px; margin-bottom: 9px; }
.tchip { font-size: .68rem; padding: 3px 8px; border-radius: 6px; white-space: nowrap; background: #eef2f7; color: var(--info); }
.tchip-corrections { background: var(--warn-bg); color: var(--warn); }
.tchip-data { background: var(--gold-soft); color: var(--gold-deep); }
.tdata-add { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tdata-add input, .tdata-add select { padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: .8rem; }
.tdata-add input { flex: 1; min-width: 120px; }
.btn-add { background: var(--gold-soft); border-color: var(--gold) !important; color: var(--gold-deep); font-weight: 700; }
.btn-file { display: inline-flex; align-items: center; cursor: pointer; }
#customPrompt {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px;
  font-size: .84rem; font-family: inherit; resize: vertical; background: var(--surface-2);
}
.prompt-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.sess { border: 1px solid var(--border); border-radius: 11px; padding: 10px 13px; margin-bottom: 9px; background: var(--surface-2); font-size: .83rem; }
.sess-learned { border-color: #bfe3cf; background: #f4fbf7; }
.sess-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.sess-date { color: var(--text-dim); font-size: .74rem; }
.sess-dec { font-size: .7rem; font-weight: 700; color: var(--info); background: #e9f1f8; padding: 2px 8px; border-radius: 6px; }
.sess-dev { color: var(--text-dim); margin: 6px 0; }
.sess-lesson { background: var(--gold-soft); border-radius: 8px; padding: 7px 10px; }
.sess-learned .sess-lesson { background: var(--pass-bg); }
.sess-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }

/* --- Impact page --- */
.demo-chip {
  font-size: .62rem; font-weight: 800; letter-spacing: .8px; color: var(--warn);
  border: 1.5px dashed var(--warn); border-radius: 6px; padding: 3px 8px; vertical-align: middle;
}
.imp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.imp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 16px; }
.imp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 20px; box-shadow: var(--shadow-sm); }
.imp-card h3 { font-size: .95rem; margin-bottom: 8px; }
.imp-svg { width: 100%; height: auto; }
.imp-svg .lbl { font-size: 11px; fill: #52514e; }
.imp-svg .val { font-size: 11px; font-weight: 700; fill: #0b0b0b; }
.imp-svg .tick { font-size: 10px; fill: #898781; }
.imp-svg .note { font-size: 10px; }
.imp-svg .endlbl { font-size: 12px; font-weight: 700; }
.imp-svg rect, .imp-svg circle { cursor: default; }
.imp-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .76rem; color: var(--text-dim); margin-bottom: 8px; }
.imp-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; }
.imp-tip {
  position: fixed; z-index: 50; background: #2c2721; color: #fff; font-size: .76rem;
  padding: 7px 11px; border-radius: 8px; pointer-events: none; max-width: 260px; line-height: 1.45;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.imp-table-card { margin-top: 16px; }
.imp-table { width: 100%; border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; }
.imp-table th { text-align: left; color: var(--text-dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; padding: 7px 10px; border-bottom: 2px solid var(--border-strong); }
.imp-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.imp-total td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.btn-vlm { background: linear-gradient(120deg, #2c5d86, #1d3f5c); }
.tool-approve { background: var(--pass-bg); border-color: #bfe3cf; color: var(--pass); font-weight: 600; }

/* --- Map search & filters --- */
.search-group { margin-inline-start: auto; }
#zoneSearch { width: 190px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: .82rem; }
#zoneSearch:focus { border-color: var(--gold); outline: none; }
.filter-chips { display: flex; gap: 4px; }
.filter-chips button {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px;
  padding: 4px 11px; cursor: pointer; font-size: .74rem; color: var(--text-dim);
}
.filter-chips button.active { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; font-weight: 700; }
.layers { margin-inline-start: 0; }

/* --- Dark-mode specifics (selected values, not auto-flips) --- */
.theme-btn {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1.05rem;
}
.theme-btn:hover { border-color: var(--gold); }
[data-theme="dark"] .map-legend { background: rgba(30,28,24,.93); }
[data-theme="dark"] .hint { background: rgba(30,28,24,.88); }
[data-theme="dark"] .tool-ai { background: linear-gradient(120deg, #3a3220, #2e2818); }
[data-theme="dark"] .st-pass { border-color: #2e5c42; }
[data-theme="dark"] .st-partial { border-color: #5c4a22; }
[data-theme="dark"] .st-fail { border-color: #5e332b; }
[data-theme="dark"] .st-info { background: #22303c; border-color: #375063; }
[data-theme="dark"] .cs-existing { background: #22303c; }
[data-theme="dark"] .lvl-identification { background: #3a2320; }
[data-theme="dark"] .lvl-recognition { background: #1e3226; }
[data-theme="dark"] .lvl-detection { background: #202c40; }
[data-theme="dark"] .btn-danger { border-color: #5e332b; }
[data-theme="dark"] .sess-learned { border-color: #2e5c42; background: #1c2b22; }
[data-theme="dark"] .tchip { background: #22303c; }
[data-theme="dark"] .topbar { box-shadow: 0 1px 6px rgba(0,0,0,.4); }
[data-theme="dark"] .imp-svg .lbl { fill: #c3c2b7; }
[data-theme="dark"] .imp-svg .val { fill: #ffffff; }
[data-theme="dark"] .imp-svg .tick { fill: #898781; }
[data-theme="dark"] .imp-tip { background: #efeadf; color: #22201c; }

/* --- Area segmentation overlay & zone editor --- */
.zone-pop {
  position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 26px rgba(0,0,0,.25);
  font-size: .84rem; width: 250px;
}
.zone-pop h4 { font-size: .9rem; margin-bottom: 2px; }
.zone-pop .zp-meta { color: var(--text-dim); font-size: .76rem; margin-bottom: 9px; }
.zone-pop .zp-cur { margin-bottom: 9px; }
.zone-pop .zp-btns { display: grid; gap: 5px; }
.zone-pop button {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  border-radius: 8px; padding: 7px 9px; cursor: pointer; font-size: .8rem; text-align: left;
}
.zone-pop button:hover { border-color: var(--gold); }
.zone-pop button.zp-active { border-color: var(--gold); background: var(--gold-soft); color: var(--gold-deep); font-weight: 700; }
.zone-pop .zp-close { position: absolute; top: 6px; right: 9px; border: none; background: none; font-size: 1rem; opacity: .5; cursor: pointer; }
.ovr-chip { font-size: .64rem; font-weight: 800; color: var(--gold-deep); border: 1px dashed var(--gold); border-radius: 5px; padding: 1px 6px; }

/* --- SVG icon system --- */
.ic { display: inline-flex; width: 15px; height: 15px; vertical-align: -2.5px; margin-inline-end: 6px; flex-shrink: 0; }
.ic svg { width: 100%; height: 100%; }
.page-nav .ic, .tabs .ic { width: 13px; height: 13px; margin-inline-end: 5px; }
.plan-switch .ic { width: 14px; height: 14px; margin-inline-end: 5px; }
.st .ic { width: 10px; height: 10px; margin-inline-end: 3px; vertical-align: -1px; }
.filter-chips .ic { width: 11px; height: 11px; margin-inline-end: 3px; vertical-align: -1.5px; }
.btn-x .ic { width: 13px; height: 13px; margin: 0; }
.train-intro h1 .ic, .train-card h2 .ic { width: 18px; height: 18px; vertical-align: -3px; color: var(--gold-deep); }
.zone-pop .ic { width: 14px; height: 14px; }
.cam-row .ic { width: 14px; height: 14px; color: var(--info); }
.mt-kind .ic { width: 14px; height: 14px; margin: 0; color: #fff; filter: drop-shadow(0 1px 2px #000); }
.tchip .ic { width: 10px; height: 10px; margin-inline-end: 3px; vertical-align: -1px; }
.theme-btn { display: inline-flex; align-items: center; justify-content: center; }
.tool .ic { margin-inline-end: 5px; }
.btn-primary .ic { vertical-align: -3px; }

/* --- Media tab & lightbox --- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 9px; }
.media-thumb {
  position: relative; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden;
  cursor: zoom-in; aspect-ratio: 4/3; background: #000;
}
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .mt-name {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: .64rem; color: #fff;
  background: rgba(0,0,0,.55); padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-thumb .mt-kind { position: absolute; top: 5px; left: 6px; font-size: .9rem; text-shadow: 0 1px 3px #000; }
.media-thumb .mt-del { position: absolute; top: 3px; right: 4px; border: none; background: rgba(0,0,0,.5); color: #fff; border-radius: 6px; cursor: pointer; font-size: .7rem; }
.lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(10,9,7,.92);
  display: flex; flex-direction: column;
}
.lightbox.hidden { display: none; }
.lb-bar {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  color: #eee; font-size: .84rem; background: rgba(0,0,0,.4);
}
.lb-bar .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-bar button {
  border: 1px solid #555; background: rgba(255,255,255,.08); color: #eee;
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: .82rem;
}
.lb-bar button:hover { border-color: var(--gold); }
.lb-stage { flex: 1; overflow: hidden; position: relative; cursor: grab; touch-action: none; }
.lb-stage img, .lb-stage video {
  position: absolute; top: 50%; left: 50%; max-width: none; max-height: none;
  transform-origin: 0 0; user-select: none; -webkit-user-drag: none;
}
.lb-zoom { font-variant-numeric: tabular-nums; color: #aaa; min-width: 52px; text-align: right; }
.lb-ai {
  max-height: 26vh; overflow-y: auto; background: rgba(20,18,14,.95); color: #e8e2d5;
  font-size: .82rem; line-height: 1.5; padding: 10px 18px; border-top: 1px solid #443;
}
.lb-ai:empty { display: none; }
