:root {
  --ink: #002d56;
  --ink-soft: #506778;
  --teal: #01b3bf;
  --teal-dark: #008e99;
  --teal-pale: #e5f9fa;
  --lime: #73cf75;
  --paper: #ffffff;
  --canvas: #f3f7f5;
  --line: #dce7e3;
  --danger: #b54747;
  --shadow: 0 18px 48px rgba(8, 40, 59, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
svg { width: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

.shell {
  display: grid;
  grid-template: 76px minmax(0, 1fr) / 270px minmax(0, 1fr);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.6rem;
  color: white;
  background: var(--ink);
  box-shadow: 0 4px 18px rgba(5, 25, 38, 0.18);
}

.brand { display: flex; align-items: center; gap: 1rem; color: inherit; text-decoration: none; }
.brand-logo { display: block; width: 148px; height: 50px; object-fit: contain; object-position: left center; }
.brand-product { padding-left: 1rem; color: #b9d4df; border-left: 1px solid rgba(255,255,255,.18); font-size: .68rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: .7rem; }
.status-pill { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .75rem; font-size: .75rem; color: #cce0e6; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; }
.status-pill i { width: 7px; height: 7px; background: #f4bc55; border-radius: 50%; box-shadow: 0 0 0 4px rgba(244,188,85,.12); }
.status-pill.online i { background: var(--lime); box-shadow: 0 0 0 4px rgba(168,214,68,.13); }
.status-pill.error i { background: #ed7777; box-shadow: 0 0 0 4px rgba(237,119,119,.13); }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; color: white; background: transparent; border: 1px solid rgba(255,255,255,.14); border-radius: 10px; }
.icon-button:hover { background: rgba(255,255,255,.08); }

.sidebar { position: sticky; top: 76px; height: calc(100vh - 76px); display: flex; flex-direction: column; padding: 1.5rem 1rem; overflow: auto; background: var(--paper); border-right: 1px solid var(--line); }
.sidebar-heading { display: flex; align-items: end; justify-content: space-between; padding: 0 .4rem 1rem; }
.eyebrow { display: block; margin-bottom: .3rem; color: var(--teal-dark); font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.sidebar h2 { margin-bottom: 0; font-size: 1.2rem; }
.count-badge { min-width: 29px; padding: .3rem .5rem; color: var(--teal-dark); background: var(--teal-pale); border-radius: 999px; font-size: .75rem; font-weight: 800; text-align: center; }
.camera-list { display: grid; gap: .45rem; }
.camera-option { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: .65rem; width: 100%; padding: .55rem; color: var(--ink); text-align: left; background: transparent; border: 1px solid transparent; border-radius: 12px; }
.camera-option:hover { background: #f5faf8; }
.camera-option.active { background: var(--teal-pale); border-color: #bce8e5; }
.camera-thumb { display: grid; width: 44px; height: 40px; place-items: center; object-fit: cover; color: var(--teal); background: #dceeed; border-radius: 9px; }
.camera-thumb svg { width: 20px; }
.camera-copy { min-width: 0; }
.camera-copy strong, .camera-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera-copy strong { font-size: .82rem; }
.camera-copy small { margin-top: .2rem; color: var(--ink-soft); font-size: .68rem; }
.demo-notice { margin-top: auto; padding: 1rem; background: #f3f7f5; border: 1px solid var(--line); border-radius: 12px; }
.demo-notice span { font-size: .75rem; font-weight: 800; }
.demo-notice p { margin: .35rem 0 0; color: var(--ink-soft); font-size: .7rem; line-height: 1.5; }

.content { min-width: 0; padding: clamp(1.2rem, 3vw, 2.5rem); }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.35rem; }
.hero h1 { margin-bottom: .35rem; font-size: clamp(1.8rem, 4vw, 3.3rem); letter-spacing: -.045em; }
.hero p { margin-bottom: 0; color: var(--ink-soft); }
.hero-stat { min-width: 130px; padding: 1rem 1.2rem; text-align: right; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 25px rgba(8,40,59,.05); }
.hero-stat span { display: block; font-size: 1.55rem; font-weight: 850; }
.hero-stat small { color: var(--ink-soft); }

.filters { display: grid; grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(130px, .7fr)) auto; align-items: end; gap: .75rem; margin-bottom: 1.4rem; padding: .9rem; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.filters label, .access-dialog label { display: grid; gap: .35rem; color: var(--ink-soft); font-size: .7rem; font-weight: 700; }
.filters input, .filters select, .access-dialog input { width: 100%; height: 42px; padding: 0 .75rem; color: var(--ink); background: #f9fbfa; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.filters input:focus, .filters select:focus, .access-dialog input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(5,174,181,.1); }
.search-field { position: relative; align-self: end; }
.search-field svg { position: absolute; left: .75rem; bottom: 11px; width: 19px; color: var(--ink-soft); }
.search-field input { padding-left: 2.25rem; }
.text-button { height: 42px; padding: 0 .8rem; color: var(--teal-dark); background: transparent; border: 0; font-size: .76rem; font-weight: 800; }

.image-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.image-card { position: relative; min-width: 0; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgba(8,40,59,.06); transition: transform .18s ease, box-shadow .18s ease; }
.image-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.image-button { display: block; width: 100%; padding: 0; text-align: left; background: none; border: 0; }
.image-frame { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #d9e6e1; }
.image-frame img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.image-card:hover .image-frame img { transform: scale(1.025); }
.image-unavailable { display: grid; height: 100%; place-items: center; color: var(--ink-soft); font-size: .78rem; }
.camera-chip { position: absolute; top: .7rem; left: .7rem; max-width: calc(100% - 1.4rem); padding: .38rem .55rem; overflow: hidden; color: white; background: rgba(8,40,59,.82); border-radius: 8px; backdrop-filter: blur(8px); font-size: .68rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.card-copy { padding: .85rem .9rem 1rem; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--ink-soft); font-size: .72rem; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .65rem; min-height: 24px; }
.tag { padding: .28rem .45rem; color: var(--teal-dark); background: var(--teal-pale); border-radius: 7px; font-size: .65rem; font-weight: 750; }
.tag.plate { color: #2e2b12; background: #f5dd68; letter-spacing: .06em; }
.inspect-event { display: flex; align-items: center; justify-content: space-between; margin-top: .75rem; padding-top: .65rem; color: var(--teal-dark); border-top: 1px solid #e8efed; font-size: .65rem; font-weight: 800; }
.inspect-event b { font-size: .85rem; transition: transform .18s ease; }
.image-card:hover .inspect-event b { transform: translateX(3px); }
.load-more-wrap { display: flex; justify-content: center; padding: 1.6rem; }
.primary-button { min-height: 44px; padding: .75rem 1.2rem; color: white; background: var(--teal-dark); border: 0; border-radius: 10px; font-weight: 800; box-shadow: 0 8px 18px rgba(7,139,146,.2); }
.primary-button:hover { background: #057c82; }
.primary-button:disabled { cursor: wait; opacity: .6; }

.message-panel { padding: 2rem; color: var(--ink-soft); text-align: center; background: var(--paper); border: 1px dashed #bacbc5; border-radius: 16px; }
.message-panel.error { color: var(--danger); border-color: #e7bcbc; background: #fff8f8; }
.skeleton { min-height: 270px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.skeleton::before { display: block; height: 180px; content: ""; background: linear-gradient(90deg,#e4ece9 25%,#f5f8f7 45%,#e4ece9 65%); background-size: 250% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }

dialog { padding: 0; border: 0; }
dialog::backdrop { background: rgba(4,24,35,.72); backdrop-filter: blur(5px); }
.image-dialog { width: min(1180px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow: auto; background: var(--paper); border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.dialog-close { position: sticky; z-index: 5; top: .8rem; float: right; width: 38px; height: 38px; margin: .8rem .8rem -46px 0; color: white; background: rgba(8,40,59,.8); border: 0; border-radius: 50%; font-size: 1.4rem; }
.dialog-visual { position: relative; display: flex; justify-content: center; min-height: 240px; overflow: hidden; background: var(--ink); }
.image-stage { position: relative; display: inline-grid; max-width: 100%; max-height: 60vh; }
.dialog-image { display: block; grid-area: 1 / 1; width: auto; max-width: 100%; height: auto; max-height: 60vh; object-fit: contain; }
.dialog-unavailable { min-height: 320px; }
.geometry-overlays { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.geometry-overlays.visible { opacity: 1; }
.overlay-shape rect { stroke-width: 3; vector-effect: non-scaling-stroke; }
.overlay-shape.interest rect { fill: rgba(151, 103, 255, .18); stroke: #a981ff; stroke-dasharray: 9 6; }
.overlay-shape.vehicle rect { fill: rgba(1, 179, 191, .2); stroke: #00e5f2; }
.overlay-shape.anpr rect { fill: rgba(255, 154, 59, .16); stroke: #ff9a3b; stroke-dasharray: 12 6; }
.overlay-shape.plate rect { fill: rgba(245, 221, 104, .36); stroke: #ffe43b; stroke-width: 4; }
.overlay-controls { position: absolute; z-index: 4; left: 1rem; bottom: 1rem; display: grid; gap: .55rem; max-width: min(360px, calc(100% - 2rem)); }
.overlay-controls button { justify-self: start; padding: .55rem .72rem; color: white; background: rgba(0,45,86,.9); border: 1px solid rgba(255,255,255,.32); border-radius: 9px; box-shadow: 0 6px 22px rgba(0,0,0,.25); backdrop-filter: blur(8px); font-size: .68rem; font-weight: 850; }
.overlay-controls button:hover:not(:disabled), .overlay-controls.active button { background: rgba(1,142,153,.94); }
.overlay-controls button:disabled { cursor: wait; opacity: .65; }
.overlay-legend { display: flex; flex-wrap: wrap; gap: .35rem .65rem; padding: .55rem .65rem; color: white; background: rgba(0,32,61,.88); border: 1px solid rgba(255,255,255,.2); border-radius: 9px; box-shadow: 0 6px 22px rgba(0,0,0,.22); backdrop-filter: blur(8px); }
.overlay-legend span { display: flex; align-items: center; gap: .3rem; font-size: .58rem; font-weight: 750; }
.overlay-legend i { width: 10px; height: 10px; border: 2px solid; border-radius: 2px; }
.overlay-legend i.interest { background: rgba(151,103,255,.35); border-color: #a981ff; }
.overlay-legend i.vehicle { background: rgba(1,179,191,.4); border-color: #00e5f2; }
.overlay-legend i.anpr { background: rgba(255,154,59,.35); border-color: #ff9a3b; }
.overlay-legend i.plate { background: rgba(245,221,104,.5); border-color: #ffe43b; }
.dialog-details { display: grid; grid-template-columns: 1fr auto; gap: 1rem; padding: 1.25rem 1.4rem 1.4rem; }
.dialog-details h2 { margin-bottom: .25rem; }
.dialog-details p { margin-bottom: 0; color: var(--ink-soft); font-size: .82rem; }
.download-link { align-self: center; padding: .65rem .8rem; color: var(--teal-dark); border: 1px solid #a9dcda; border-radius: 9px; font-size: .75rem; font-weight: 800; text-decoration: none; }
.access-dialog { width: min(430px, calc(100vw - 2rem)); padding: 1.8rem; border-radius: 18px; box-shadow: var(--shadow); }
.access-logo { display: block; width: 180px; height: 60px; margin: 0 0 1rem; object-fit: contain; object-position: left center; }
.access-dialog form { display: grid; }
.access-dialog h2 { margin-bottom: .45rem; }
.access-dialog p { color: var(--ink-soft); line-height: 1.5; }
.access-dialog .primary-button { margin-top: .85rem; }
.form-error { min-height: 1.25rem; margin: .35rem 0 0 !important; color: var(--danger) !important; font-size: .75rem; }

.diagnostic-loading { display: flex; align-items: center; justify-content: center; gap: .85rem; min-height: 145px; margin: 0 1.4rem 1.4rem; color: var(--ink-soft); background: #f6f9fa; border: 1px solid var(--line); border-radius: 14px; }
.diagnostic-loading strong, .diagnostic-loading small { display: block; }
.diagnostic-loading strong { color: var(--ink); font-size: .82rem; }
.diagnostic-loading small { margin-top: .2rem; font-size: .7rem; }
.diagnostic-loading.error { color: var(--danger); background: #fff8f8; border-color: #e8c1c1; }
.spinner { width: 25px; height: 25px; border: 3px solid #cde9ea; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.event-diagnostics { padding: 0 1.4rem 1.5rem; }
.diagnostic-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem 0 .9rem; border-top: 1px solid var(--line); }
.diagnostic-heading h3 { margin: 0; font-size: 1.15rem; }
.outcome-pill { padding: .45rem .65rem; color: var(--ink-soft); background: #eef3f5; border: 1px solid #dce5e9; border-radius: 999px; font-size: .66rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.outcome-pill.success { color: #087743; background: #e7f8ef; border-color: #bcebd1; }
.diagnostic-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-bottom: .8rem; }
.diagnostic-metrics article { min-width: 0; padding: .85rem .9rem; background: linear-gradient(145deg, #f7fbfc, #eef7f8); border: 1px solid #d9ecee; border-radius: 12px; }
.diagnostic-metrics span, .diagnostic-metrics small { display: block; color: var(--ink-soft); font-size: .62rem; }
.diagnostic-metrics strong { display: block; margin: .25rem 0 .15rem; color: var(--ink); font-size: 1.12rem; }
.diagnostic-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.diagnostic-panel { min-width: 0; padding: 1rem; background: #fbfcfc; border: 1px solid var(--line); border-radius: 13px; }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; padding-bottom: .65rem; border-bottom: 1px solid var(--line); }
.panel-heading span { color: var(--ink); font-size: .8rem; font-weight: 850; }
.panel-heading small { color: var(--ink-soft); font-size: .62rem; }
.diagnostic-list { margin: 0; }
.diagnostic-list > div { display: grid; grid-template-columns: minmax(115px, .8fr) minmax(0, 1.2fr); gap: .7rem; padding: .43rem 0; border-bottom: 1px solid #e8eeec; }
.diagnostic-list > div:last-child { border-bottom: 0; }
.diagnostic-list dt { color: var(--ink-soft); font-size: .65rem; }
.diagnostic-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: .68rem; font-weight: 700; text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .62rem !important; }
.plate-results { display: grid; gap: .6rem; margin-bottom: .7rem; }
.plate-result { display: grid; grid-template-columns: auto 1fr 1fr; gap: .55rem; align-items: center; padding: .7rem; background: #fffdf3; border: 1px solid #eadb91; border-radius: 10px; }
.plate-result .registration { grid-row: 1 / span 2; padding: .42rem .55rem; color: #2d2a12; background: #f5dd68; border: 1px solid #dec650; border-radius: 7px; font-size: .77rem; font-weight: 900; letter-spacing: .08em; }
.plate-result div span, .plate-result div strong { display: block; }
.plate-result div span { color: var(--ink-soft); font-size: .56rem; }
.plate-result div strong { margin-top: .15rem; font-size: .68rem; }
.plate-result div:last-child { grid-column: 2 / -1; }
.attempt-list { display: grid; gap: .5rem; margin: 0 0 .7rem; padding: 0; list-style: none; }
.attempt-list li { display: grid; grid-template-columns: 27px minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: .55rem; background: #f2f5f6; border-radius: 9px; }
.attempt-list li > span { display: grid; width: 27px; height: 27px; place-items: center; color: var(--ink-soft); background: white; border: 1px solid var(--line); border-radius: 50%; font-size: .62rem; font-weight: 850; }
.attempt-list li.success { background: #eaf8f1; }
.attempt-list li.success > span { color: #087743; border-color: #acdcbf; }
.attempt-list strong, .attempt-list small { display: block; }
.attempt-list strong { font-size: .69rem; }
.attempt-list small { margin-top: .12rem; color: var(--ink-soft); font-size: .59rem; }
.attempt-list b { color: var(--ink-soft); font-size: .64rem; }
.empty-detail { margin: .4rem 0 .8rem; color: var(--ink-soft); font-size: .7rem; }
.diagnostic-disclosure { margin-top: .8rem; overflow: hidden; background: #fbfcfc; border: 1px solid var(--line); border-radius: 13px; }
.diagnostic-disclosure summary { display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; cursor: pointer; list-style: none; }
.diagnostic-disclosure summary::-webkit-details-marker { display: none; }
.diagnostic-disclosure summary::before { width: 7px; height: 7px; content: ""; border-right: 2px solid var(--teal-dark); border-bottom: 2px solid var(--teal-dark); transform: rotate(-45deg); transition: transform .18s ease; }
.diagnostic-disclosure[open] summary::before { transform: rotate(45deg); }
.diagnostic-disclosure summary span { color: var(--ink); font-size: .76rem; font-weight: 850; }
.diagnostic-disclosure summary small { margin-left: auto; color: var(--ink-soft); font-size: .62rem; }
.disclosure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; padding: 0 1rem 1rem; }
.disclosure-grid section { min-width: 0; padding: .8rem; background: white; border: 1px solid #e5ecea; border-radius: 10px; }
.disclosure-grid h4 { margin: 0 0 .55rem; color: var(--teal-dark); font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; }
.disclosure-grid .wide { grid-column: 1 / -1; }
.object-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.object-grid > div { min-width: 0; padding: .55rem; background: #f5f8f8; border-radius: 8px; }
.object-grid span, .object-grid strong { display: block; overflow-wrap: anywhere; }
.object-grid span { color: var(--ink-soft); font-size: .56rem; }
.object-grid strong { margin-top: .18rem; color: var(--ink); font-size: .64rem; }
.raw-disclosure pre { max-height: 480px; margin: 0; padding: 1rem; overflow: auto; color: #d9eef4; background: #062942; font: .64rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 1100px) {
  .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-field { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .shell { display: block; padding-top: 70px; }
  .topbar { position: fixed; width: 100%; height: 70px; padding: 0 .9rem; }
  .status-pill { display: none; }
  .sidebar { position: static; width: 100%; height: auto; padding: .85rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-heading, .demo-notice { display: none; }
  .camera-list { display: flex; gap: .45rem; overflow-x: auto; padding-bottom: .25rem; }
  .camera-option { flex: 0 0 auto; width: auto; grid-template-columns: auto; padding: .6rem .8rem; border-color: var(--line); }
  .camera-thumb { display: none; }
  .camera-copy small { display: none; }
  .content { padding: 1.2rem .85rem; }
  .hero { align-items: center; }
  .hero-stat { min-width: 105px; padding: .75rem; }
  .hero-stat span { font-size: 1.2rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  .image-grid { grid-template-columns: 1fr; }
  .brand-logo { width: 125px; }
  .brand-product { display: none; }
  .dialog-details { grid-template-columns: 1fr; }
  .event-diagnostics { padding: 0 .85rem 1rem; }
  .diagnostic-metrics, .diagnostic-layout, .disclosure-grid { grid-template-columns: 1fr; }
  .disclosure-grid .wide { grid-column: auto; }
  .diagnostic-disclosure summary small { display: none; }
}

@media (max-width: 480px) {
  .filters { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .hero-stat { display: none; }
  .diagnostic-metrics { grid-template-columns: repeat(2, 1fr); }
  .object-grid { grid-template-columns: 1fr; }
  .plate-result { grid-template-columns: 1fr 1fr; }
  .plate-result .registration { grid-row: auto; grid-column: 1 / -1; justify-self: start; }
  .plate-result div:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
