:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #202224;
  background: #f2f3f3;
  --black: #161817;
  --dark: #272a29;
  --dark-soft: #333735;
  --border: #d8dcda;
  --muted: #737a76;
  --green: #49a942;
  --green-dark: #3b8d36;
  --green-soft: #eaf6e8;
  --red: #b42318;
  --white: #ffffff;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f2f3f3; }
.hidden { display: none !important; }
button, input, select { font: inherit; }
a { color: inherit; }
.login-screen { min-height: 100vh; display: grid; place-items: center; background: #202321; }
.login-card { width: min(420px, calc(100vw - 32px)); background: var(--white); border-radius: 8px; padding: 34px; box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 7px; background: var(--green); color: #fff; font-weight: 800; }
.login-card h1 { margin: 18px 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 26px; color: var(--muted); }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
input, select { width: 100%; min-height: 40px; border: 1px solid var(--border); border-radius: 5px; padding: 0 11px; background: #fff; color: #222; }
.login-card .button { margin-top: 14px; width: 100%; }
.button { min-height: 38px; border: 0; border-radius: 5px; padding: 0 16px; cursor: pointer; font-weight: 600; transition: .12s ease; }
.button:disabled { opacity: .42; cursor: default; }
.button.primary { background: var(--green); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--green-dark); }
.button.secondary { background: #eef0ef; color: #333; border: 1px solid var(--border); }
.button.secondary:hover:not(:disabled) { background: #e2e6e3; }
.button.secondary.active { background: var(--green-soft); border-color: var(--green); color: #245f20; }
.button.danger { background: #fff; color: var(--red); border: 1px solid #e8c8c4; }
.button.icon { min-width: 42px; padding: 0 10px; background: #eef0ef; border: 1px solid var(--border); }
.button.ghost { background: transparent; color: #e6e8e7; border: 1px solid #4b4f4d; }
.button.wide { width: 100%; }
.error { margin-top: 14px; color: var(--red); font-size: 13px; }
.topbar { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: var(--black); color: #fff; }
.topbar-brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--green); }
.topbar-right { display: flex; gap: 14px; align-items: center; }
.top-link { color: #d5dad7; font-size: 13px; text-decoration: none; padding: 7px 9px; border-radius: 4px; }
.top-link:hover { background: #292d2b; color: #fff; }
.identity { font-size: 13px; color: #b9bfbc; }
.layout { min-height: calc(100vh - 58px); display: grid; grid-template-columns: 225px minmax(0, 1fr); transition: grid-template-columns .28s ease; }
.layout.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.layout.sidebar-collapsed .sidebar { padding-left: 0; padding-right: 0; opacity: 0; pointer-events: none; }
.sidebar-toggle { border: 1px solid #444b47; color: #fff; background: #2c312e; border-radius: 5px; min-width: 35px; min-height: 34px; cursor: pointer; }
.sidebar-toggle:hover { background: #404640; }
.sidebar { background: var(--dark); padding: 18px 10px; min-width: 0; overflow: hidden; opacity: 1; transition: padding .28s ease, opacity .2s ease; }
.nav { display: grid; gap: 4px; }
.nav button { border: 0; background: transparent; color: #dfe3e1; text-align: left; padding: 11px 13px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.nav button:hover { background: var(--dark-soft); }
.nav button.active { background: var(--green); color: #fff; }
.content { padding: 24px; min-width: 0; }
.panel { max-width: 1680px; margin: 0 auto; }
.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 16px; }
h2 { margin: 0; font-size: 22px; }
.page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.save-state { font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.save-state.dirty { color: #9a6700; font-weight: 600; }
.toolbar-card, .viewer-card, .editor-card, .placeholder-card { background: #fff; border: 1px solid var(--border); border-radius: 7px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.toolbar-card { display: flex; gap: 12px; align-items: flex-end; padding: 14px; margin-bottom: 14px; }
.field { min-width: 210px; }
.field.grow { flex: 1; }
.snapshot-controls { display: flex; gap: 6px; }
.live-toggle { min-height: 40px; display: flex; align-items: center; gap: 8px; margin: 0; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; background: #fff; white-space: nowrap; cursor: pointer; }
.live-toggle input { width: 16px; min-height: auto; }
.parking-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 14px; align-items: start; }
.viewer-card { overflow: hidden; min-width: 0; }
.viewer-header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 15px; border-bottom: 1px solid var(--border); }
.viewer-header strong { display: block; }
.viewer-header span { color: var(--muted); font-size: 12px; }
.viewer-meta-right { display: grid; gap: 2px; text-align: right; }
.frame-meta { white-space: nowrap; }
.viewer { min-height: 580px; background: #111; display: grid; place-items: center; overflow: auto; padding: 10px; }
.viewer-stage { position: relative; display: inline-block; max-width: 100%; line-height: 0; user-select: none; }
.viewer-stage img { display: block; max-width: 100%; max-height: calc(100vh - 275px); width: auto; height: auto; object-fit: contain; user-select: none; }
.geometry-overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; touch-action: none; }
.geometry-overlay .analysis-fill { fill: rgba(73,169,66,.13); stroke: #66d05f; stroke-width: 3; vector-effect: non-scaling-stroke; }
.geometry-overlay .boundary-line { fill: none; stroke: #ffd54a; stroke-width: 3; vector-effect: non-scaling-stroke; }
.geometry-overlay .draft-line { fill: none; stroke: #74a9ff; stroke-width: 2; stroke-dasharray: 7 5; vector-effect: non-scaling-stroke; }
.geometry-overlay .ruler-line { stroke: #f6f7f6; stroke-width: 2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.geometry-overlay .vertex { fill: #fff; stroke: #1e7420; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: grab; }
.geometry-overlay .vertex.boundary { stroke: #b88b00; }
.geometry-overlay .vertex.dragging { cursor: grabbing; fill: #dff6dc; }
.geometry-overlay .snap-target { fill: rgba(73,169,66,.18); stroke: #75d96e; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
.viewer-empty { color: #aab0ad; font-size: 14px; padding: 30px; }
.viewer-footer { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 13px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.editor-card { padding: 16px; }
.editor-section { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid #e8eae9; }
.editor-section:last-child { border-bottom: 0; }
.editor-section h3 { margin: 0 0 5px; font-size: 15px; }
.editor-section p { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.editor-actions { display: grid; gap: 7px; }
.mode-hint { min-height: 34px; margin-top: 10px; padding: 8px 9px; border-radius: 5px; background: #f4f6f5; color: #59605c; font-size: 12px; line-height: 1.35; }
.compact-actions { display: grid; gap: 7px; }
.ruler-status { display: flex; justify-content: space-between; font-size: 13px; }
.inline-message { min-height: 18px; margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.inline-message.error { color: var(--red); margin-top: 8px; }
.editor-help { color: var(--muted); font-size: 11px; line-height: 1.45; }
.editor-help p { margin: 7px 0; }
.placeholder-card { padding: 28px; }
.placeholder-card p { color: var(--muted); }
@media (max-width: 1180px) {
  .parking-grid { grid-template-columns: 1fr; }
  .editor-card { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
  .editor-section { border: 0; margin: 0; padding: 0; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { padding: 8px; }
  .nav { grid-auto-flow: column; overflow-x: auto; }
  .content { padding: 14px; }
  .toolbar-card { flex-direction: column; align-items: stretch; }
  .field { min-width: 0; width: 100%; }
  .snapshot-controls { width: 100%; }
  .snapshot-controls .primary { flex: 1; }
  .topbar-right .top-link { display: none; }
  .editor-card { display: block; }
  .editor-section { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid #e8eae9; }
  .viewer { min-height: 420px; }
}

/* Dataset + Model workspaces (0.6.2) */
#dataset-panel { max-width: none; }
.wheel-toolbar { flex-wrap: wrap; align-items: center; gap: 9px; }
.wheel-spacer { flex: 1; }
.wheel-image-index { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.wheel-image-index input { width: 80px; border: 1px solid var(--border); border-radius: 5px; padding: 8px; }
.wheel-viewport { width: 100%; min-height: 510px; height: clamp(510px, calc(100vh - 310px), 1020px); display: grid; place-items: center; overflow: hidden; background: #151a18; touch-action: none; }
.wheel-stage { position: relative; display: inline-block; width: auto; max-width: 100%; line-height: 0; background: #151a18; transform-origin: center center; will-change: transform; user-select: none; }
.wheel-stage img { display: block; width: auto; max-width: 100%; max-height: clamp(510px, calc(100vh - 310px), 1020px); height: auto; user-select: none; }
.wheel-overlay { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.wheel-overlay circle { stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: grab; }
.wheel-overlay circle.prediction { fill: #2ea365; stroke: #e5fff2; pointer-events: all; }
.wheel-overlay circle.annotation { fill: #2387df; }
.wheel-overlay circle.dragging { cursor: grabbing; }
.wheel-overlay.panning { cursor: grabbing; }
.wheel-zoom-controls { display: flex; align-items: center; gap: 6px; }
.wheel-zoom-controls #dataset-zoom-reset { min-width: 68px; }
.wheel-zoom-controls span { margin-left: 9px; }
.wheel-inline-controls { display: flex; align-items: center; gap: 10px; font-size: 12px; margin-bottom: 15px; }
.wheel-inline-controls input { flex: 1; min-width: 50px; }
.wheel-model-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.wheel-model-card { padding: 18px; min-width: 0; }
.wheel-model-card h3 { margin: 0 0 12px; }
.wheel-model-card.wheel-full { grid-column: 1 / -1; }
.wheel-model-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.wheel-detail { font-size: 13px; line-height: 1.8; color: var(--text); overflow-wrap: anywhere; }
.wheel-detail .muted { color: var(--muted); }
.wheel-detail strong { font-weight: 600; }
.wheel-model-card progress { width: 100%; height: 12px; margin: 12px 0; accent-color: var(--green); }
.wheel-training-log { background: #1d2422; color: #dbe6de; border-radius: 5px; padding: 16px; max-height: 330px; overflow: auto; font-size: 12px; line-height: 1.55; white-space: pre-wrap; }
@media (max-width: 900px) { .wheel-model-grid { grid-template-columns: 1fr; } .wheel-model-card.wheel-full { grid-column: auto; } }

@media (max-width: 900px) { .layout.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); } .wheel-viewport { min-height: 350px; } }
.wheel-clahe { display: flex; gap: 8px; align-items: center; font-size: 12px; margin: 4px 0 16px; }
.wheel-clahe input { width: 16px; min-height: 16px; }

/* Compact horizontal dataset tools: more screen space for the annotated image. */
.dataset-viewer { min-width: 0; }
.dataset-tools { display: block; padding: 0 14px; margin-bottom: 12px; }
.dataset-tools-heading { display: flex; align-items: center; gap: 16px; min-height: 48px; }
.dataset-tools-heading strong { font-size: 14px; white-space: nowrap; }
.dataset-tools-heading .inline-message { flex: 1; min-width: 0; margin: 0; }
.dataset-tools-toggle { flex-shrink: 0; min-height: 32px; font-size: 12px; }
.dataset-tools-body { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows .26s ease, opacity .22s ease; }
.dataset-tools-body > .dataset-tools-inner { min-height: 0; overflow: hidden; }
.dataset-tools.tools-collapsed .dataset-tools-body { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }
.dataset-tools-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 4px 0 8px; }
.dataset-tools-row .wheel-inline-controls { margin: 0; flex: 0 1 260px; }
.dataset-tools-row .wheel-inline-controls input { width: 125px; }
.dataset-tools-row .wheel-clahe { margin: 0; white-space: nowrap; }
.dataset-tool-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dataset-tools-help { font-size: 12px; line-height: 1.45; color: var(--muted); margin: 0 0 12px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); transition: grid-template-rows .28s ease; }
  .layout.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: 0fr minmax(0, 1fr); }
  .dataset-tools-heading { flex-wrap: wrap; padding: 6px 0; }
  .dataset-tool-actions { margin-left: 0; }
  .wheel-viewport { min-height: 350px; height: max(350px, calc(100vh - 355px)); }
}
@media (prefers-reduced-motion: reduce) {
  .layout, .sidebar, .dataset-tools-body { transition: none; }
}


/* Web Analytics Settings / Test */
.analytics-toolbar {display:flex;gap:14px;align-items:end;flex-wrap:wrap;margin-bottom:15px}
.analytics-columns {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:15px;margin-bottom:15px}
.analytics-card {padding:18px;margin-bottom:15px}
.analytics-card h3 {margin:0 0 14px;font-size:17px}
.analytics-card h4 {margin:18px 0 10px}
.analytics-card .field {margin-bottom:12px}
.analytics-card input:not([type=checkbox]),.analytics-card select,.analytics-toolbar select {width:100%;padding:9px;border:1px solid #cbd5da;border-radius:8px;box-sizing:border-box}
.analytics-fields {display:flex;align-items:end;gap:12px;flex-wrap:wrap}
.analytics-fields .field {flex:1 1 180px}
.inline-actions {display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:12px 0}
.small-muted {color:#687780;font-size:13px}
.technical-panel {border-top:1px solid #dce3e5;margin-top:16px;padding-top:4px}
.danger-confirm {display:flex;gap:8px;align-items:center;margin:12px 0;color:#a23535}
.analytics-test-grid {display:grid;grid-template-columns:minmax(0,2fr) minmax(300px,1fr);gap:15px}
.at-stage {position:relative;overflow:hidden;background:#1c2228;min-height:340px;display:flex;align-items:center;justify-content:center}
.at-stage img {display:block;width:100%;height:auto;object-fit:contain}
.at-stage svg {position:absolute;inset:0;width:100%;height:100%;touch-action:none;cursor:crosshair}
.at-stage .viewer-empty {position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#222;color:#eee;text-align:center}
.analytics-console {background:#151d23;color:#e2f6ea;padding:14px;border-radius:9px;white-space:pre-wrap;overflow-wrap:anywhere;overflow:auto;max-height:720px;min-height:300px;font-size:12px;line-height:1.45}
@media(max-width:1000px) {.analytics-columns,.analytics-test-grid{grid-template-columns:1fr}}

.analytics-logic {max-height:420px;overflow:auto;margin-top:14px;display:flex;flex-direction:column;align-items:center;gap:10px}
.analytics-logic-node {border:1px solid #cfd8dc;border-radius:10px;padding:10px 15px;text-align:center;width:90%;background:#f8faf9;display:flex;flex-direction:column;gap:5px}
.analytics-logic-node span {font-size:12px;color:#51636c;white-space:pre-wrap}
.analytics-logic-node:not(:last-child)::after {content:"↓";position:relative;top:13px;color:#349966}

/* 0.7.1: linked camera viewing. The existing single-camera geometry editor is unchanged. */
.linked-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:9px; margin: -3px 0 14px; }
.linked-indicator { color:#57615b; font-size:13px; margin-right:auto; }
.linked-editor { background:#fff; border:1px solid var(--border); border-radius:7px; padding:16px; margin-bottom:14px; }
.linked-editor-title { display:flex; flex-direction:column; gap:4px; margin-bottom:13px; }
.linked-editor-title span { color:var(--muted); font-size:12px; }
.linked-camera-options { display:flex; flex-wrap:wrap; gap:9px; margin-top:10px; }
.linked-camera-option { display:inline-flex; align-items:center; gap:8px; padding:9px 13px; border:1px solid var(--border); border-radius:6px; margin:0; background:#f8faf8; }
.linked-camera-option input { min-height:unset; width:17px; }
.linked-camera-option small { color:var(--muted); }
.parking-grid.group-mode { grid-template-columns:minmax(0,1fr); }
.parking-grid.group-mode > .editor-card { display:none; }
.parking-toolbar.group-mode .snapshot-controls, .parking-toolbar.group-mode .live-toggle { display:none; }
.linked-tiles { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; padding:14px; }
.linked-tiles.three { grid-template-columns:repeat(3,minmax(0,1fr)); }
.linked-tile { background:#161a18; color:#eef4ef; border:2px solid transparent; border-radius:6px; min-width:0; overflow:hidden; }
.linked-tile.selected { border-color:var(--green); }
.linked-tile-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:9px 10px; }
.linked-tile-heading strong { font-size:13px; overflow-wrap:anywhere; }
.linked-tile-status { color:#c1c9c2; font-size:11px; text-align:right; }
.linked-tile-stage { background:#0d100e; aspect-ratio:16/9; display:flex; align-items:center; justify-content:center; }
.linked-tile-stage img { display:block; width:100%; height:100%; object-fit:contain; }
.linked-tile-bottom { padding:8px 10px; display:flex; align-items:center; justify-content:space-between; gap:6px; font-size:11px; color:#c1c9c2; }
.linked-tile-bottom .button { font-size:11px; min-height:28px; padding:0 9px; }
@media(max-width:1200px) { .linked-tiles.three { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:700px) { .linked-tiles, .linked-tiles.three { grid-template-columns:1fr; } }

/* GateTwin/ALPR diagnostic snapshots share the Parking camera selection. */
.plate-preview-toolbar {display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 14px;padding:11px;background:#fff;border:1px solid var(--border);border-radius:7px}
.plate-preview-hint {font-size:12px;color:var(--muted);flex:1;min-width:190px}
.plate-preview-results {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr));gap:12px;margin-bottom:14px}
.plate-preview-card {min-width:0;background:#fff;border:1px solid var(--border);border-radius:7px;padding:12px}
.plate-preview-card h3 {font-size:14px;margin:0 0 6px}
.plate-preview-status {font-size:12px;color:var(--muted);margin:6px 0}
.plate-preview-status.error {color:var(--red)}
.plate-preview-frame {display:block;width:100%;height:auto;background:#171717;border-radius:4px}
.plate-preview-plates {display:grid;gap:6px;margin-top:9px}
.plate-preview-plate {display:flex;align-items:center;gap:10px;padding:7px;border:1px solid var(--border);border-radius:5px}
.plate-preview-crop {width:110px;max-height:58px;object-fit:contain;background:#111}
.plate-preview-details {font-size:12px;display:grid;gap:3px;overflow-wrap:anywhere}
