/* ANPR Web Panel - responsive UI. No external fonts/icons/CDN. */

:root {
  --color-primary: #1d6fe8;
  --color-primary-dark: #1659bd;
  --color-primary-soft: #e8f0fd;
  --color-background: #f3f5f8;
  --color-surface: #ffffff;
  --color-border: #e2e6ec;
  --color-border-strong: #cfd6e0;
  --color-text: #17202c;
  --color-muted: #66717f;
  --color-sidebar: #0f1724;
  --color-sidebar-text: #b9c2cf;
  --color-sidebar-hover: #1b2636;
  --color-ok: #15803d;
  --color-ok-bg: #e7f6ec;
  --color-warn: #b45309;
  --color-warn-bg: #fef3e2;
  --color-bad: #c62828;
  --color-bad-bg: #fdecec;
  --color-muted-bg: #eef1f5;
  --sidebar-width: 248px;
  --topbar-height: 64px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 6%);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / 18%);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  --focus: 0 0 0 3px rgb(29 111 232 / 35%);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--color-text);
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--color-background);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

a {
  color: var(--color-primary);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

[hidden] {
  display: none !important;
}

.icon {
  flex: none;
}

.muted {
  color: var(--color-muted);
}

.nowrap {
  white-space: nowrap;
}

.boot {
  padding: 40px;
  color: var(--color-muted);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.is-busy {
  cursor: progress;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.btn-secondary:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  background: var(--color-muted-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-soft {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
}

.btn-soft:hover:not(:disabled) {
  background: #d6e5fc;
}

.btn-danger {
  background: var(--color-bad);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #a51f1f;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--color-bad);
  border-color: #f2c4c4;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--color-bad-bg);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover {
  background: rgb(127 127 127 / 14%);
}

/* ---------- inputs ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: #3d4756;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 15px;
}

.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--focus);
}

.input:disabled {
  background: var(--color-muted-bg);
  color: var(--color-muted);
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-muted) 50%),
    linear-gradient(135deg, var(--color-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 18px,
    calc(100% - 12px) 18px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.input-plate {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hint {
  font-size: 12px;
  color: var(--color-muted);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  cursor: pointer;
  font-weight: 500;
}

.checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

/* ---------- messages / states ---------- */

.msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
}

.msg .icon {
  margin-top: 1px;
}

.msg-error {
  background: var(--color-bad-bg);
  color: #8f1d1d;
  border-color: #f5c6c6;
}

.msg-ok {
  background: var(--color-ok-bg);
  color: #14532d;
  border-color: #bfe5cc;
}

.msg-warn {
  background: var(--color-warn-bg);
  color: #7a3e06;
  border-color: #f6d39c;
}

.form-msg:empty {
  display: none;
}

.form-msg {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 16px;
  text-align: center;
  color: var(--color-muted);
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius);
}

.state-title {
  font-weight: 600;
  color: var(--color-text);
}

.state-text {
  font-size: 13px;
  max-width: 420px;
}

.state-error {
  border-style: solid;
  border-color: #f5c6c6;
  background: #fff8f8;
}

.state-error .icon {
  color: var(--color-bad);
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- badges / chips ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.badge-conf {
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

.badge-admin {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
}

.badge-viewer,
.badge-muted {
  background: var(--color-muted-bg);
  color: #4b5563;
}

.plate-chip {
  display: inline-block;
  padding: 3px 9px 3px 11px;
  border: 1.5px solid #273244;
  border-radius: 5px;
  background: #fff;
  color: #111827;
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
  box-shadow: inset 4px 0 0 #1d4ed8;
}

.plate-chip-unread {
  border-style: dashed;
  border-color: #9aa3ae;
  color: var(--color-muted);
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: none;
  padding-left: 9px;
}

.card-thumb-muted {
  background: var(--color-muted-bg);
  color: var(--color-muted);
}

.plate-chip-lg {
  font-size: 16px;
  padding: 4px 11px 4px 13px;
}

.with-swatch,
.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgb(0 0 0 / 25%);
  flex: none;
}

/* status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 13px;
  white-space: nowrap;
  max-width: 100%;
}

.pill-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill-state {
  font-weight: 600;
}

.pill-ok {
  color: var(--color-ok);
  background: var(--color-ok-bg);
  border-color: #c6e9d2;
}

.pill-warn {
  color: var(--color-warn);
  background: var(--color-warn-bg);
  border-color: #f5d7a8;
}

.pill-bad {
  color: var(--color-bad);
  background: var(--color-bad-bg);
  border-color: #f5c6c6;
}

.pill-muted {
  color: var(--color-muted);
  background: var(--color-muted-bg);
}

.pill .pill-name {
  color: var(--color-text);
}

/* ---------- auth ---------- */

.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--color-sidebar);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  background: var(--color-surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 1px;
  margin-bottom: 22px;
}

.auth-card h1 {
  font-size: 22px;
}

.auth-sub {
  margin: 6px 0 22px;
  color: var(--color-muted);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--color-primary);
  color: #fff;
  flex: none;
}

.brand-mark.sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

/* ---------- shell ---------- */

.shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 22px;
  color: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 17px;
  letter-spacing: 1.5px;
}

.brand-text small {
  color: #8592a5;
  font-size: 11.5px;
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group {
  margin: 18px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #6f7c8f;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-weight: 500;
}

.nav-link:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.nav-link.active {
  background: var(--color-primary);
  color: #fff;
}

.drawer-backdrop {
  display: none;
}

.main {
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-height);
  padding: 10px 24px;
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--color-border);
}

.menu-toggle,
.topbar-brand {
  display: none;
}

.topbar-brand {
  align-items: center;
  gap: 8px;
  font-size: 16px;
  letter-spacing: 1px;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

/* user menu */
.user-menu {
  position: relative;
  margin-left: auto;
}

.user-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 10px 4px 5px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}

.user-button:hover {
  background: var(--color-muted-bg);
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  flex: none;
}

.avatar-lg {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

.user-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  text-align: left;
}

.user-name {
  font-weight: 600;
}

.user-role {
  font-size: 11.5px;
  color: var(--color-muted);
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
  min-width: 220px;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.menu-head {
  display: flex;
  flex-direction: column;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}

.menu-head span {
  font-size: 12px;
  color: var(--color-muted);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--color-muted-bg);
}

.menu-danger {
  color: var(--color-bad);
}

.menu-danger:hover,
.menu-danger:focus-visible {
  background: var(--color-bad-bg);
}

.menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--color-border);
}

/* ---------- page ---------- */

.content {
  width: 100%;
  max-width: 1360px;
  padding: 24px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

.content:focus {
  outline: none;
}

.page-head {
  margin-bottom: 18px;
}

.page-head h1 {
  font-size: 22px;
  font-weight: 700;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--color-muted);
}

.page-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-body.narrow {
  max-width: 560px;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-panel,
.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* search */
.search-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(200px, 1fr) minmax(200px, 1fr);
  gap: 14px 16px;
}

.search-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.search-actions .select {
  width: auto;
  min-width: 140px;
}

.search-actions .btn-primary {
  margin-left: auto;
  min-width: 120px;
}

/* toolbar (recent) */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar-right .select {
  width: auto;
  min-width: 132px;
  min-height: 40px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: 9px;
  max-width: 100%;
}

.segment {
  min-height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.segment:hover:not(.active) {
  background: var(--color-muted-bg);
}

.segment.active {
  background: var(--color-primary);
  color: #fff;
}

/* Okunamayan Plakalar: explicit date range */
.range-grid {
  grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr) auto;
  align-items: end;
}

.field-action .btn {
  min-height: 42px;
}

/* stats */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
}

.stat-label {
  color: var(--color-muted);
  font-size: 13px;
}

.results-area > .msg {
  margin-bottom: 12px;
}

/* ---------- results: desktop table ---------- */

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--color-muted);
  background: #f8f9fb;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #edf0f3;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: #f7f9fc;
}

.data-table th:first-child,
.data-table td:first-child {
  padding-left: 18px;
}

.cell-action {
  text-align: right;
}

.results-cards {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.pager-info {
  min-width: 56px;
  text-align: center;
  font-weight: 600;
}

/* ---------- results: mobile cards ---------- */

.result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid #edf0f3;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.results-cards li:last-child .result-card {
  border-bottom: none;
}

button.result-card:active {
  background: #f1f4f8;
}

.card-thumb {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  flex: none;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-brand {
  font-weight: 600;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  color: #3d4756;
  font-size: 13px;
}

.card-meta .sep {
  color: #a3acb9;
}

.card-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--color-muted);
  font-size: 12.5px;
}

.card-go {
  color: #a3acb9;
}

/* ---------- camera / users ---------- */

.check-list {
  list-style: none;
  margin: 0;
  padding: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check-item {
  display: grid;
  grid-template-columns: 22px auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #f0f2f5;
}

.check-ok .icon {
  color: var(--color-ok);
}

.check-bad .icon {
  color: var(--color-bad);
}

.check-na .icon {
  color: var(--color-muted);
}

.check-label {
  font-weight: 600;
}

.check-detail {
  color: var(--color-muted);
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kv {
  display: grid;
  grid-template-columns: minmax(150px, max-content) 1fr;
  gap: 8px 18px;
  margin: 0;
}

.kv dt {
  color: var(--color-muted);
}

.kv dd {
  margin: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

section.panel:not(.form-panel) {
  padding: 20px;
}

.results.panel {
  padding: 0;
  overflow: hidden;
}

.user-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid #edf0f3;
  flex-wrap: wrap;
}

.user-row-main {
  flex: 1;
  min-width: 160px;
}

.user-row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}

.user-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 12.5px;
  flex-wrap: wrap;
}

.user-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-row-actions .select {
  width: auto;
  min-height: 34px;
  font-size: 13px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ---------- photo viewer ---------- */

.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(8 12 20 / 82%);
  overscroll-behavior: contain;
}

.viewer {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: min(860px, 100%);
  background: #0d131d;
  color: #e7ebf1;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  background: #121a26;
  border-bottom: 1px solid #1f2a3a;
  flex: none;
}

.viewer-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.viewer-time {
  color: #a9b4c4;
  font-size: 13.5px;
  white-space: nowrap;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.viewer-actions .icon-btn {
  color: #e7ebf1;
}

.viewer-actions .icon-btn:hover {
  background: rgb(255 255 255 / 10%);
}

.viewer-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px;
}

/* Absolutely positioned: the stage size comes only from the flex layout, never
   from the photo's natural size, so header / vehicle info / tabs stay visible. */
.viewer-img {
  position: absolute;
  inset: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  object-fit: contain; /* fills the free area, aspect ratio kept (small plate crops scale up) */
  display: block;
}

.viewer-stage.is-loading .viewer-img,
.viewer-stage.has-error .viewer-img {
  visibility: hidden;
}

.viewer-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: #a9b4c4;
  pointer-events: none;
}

.viewer-status:empty {
  display: none;
}

.viewer-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  padding: 10px 18px;
  background: #121a26;
  border-top: 1px solid #1f2a3a;
  flex: none;
  max-height: 30%;
  overflow-y: auto;
}

.fact {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fact-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8592a5;
}

.fact-value {
  font-weight: 600;
}

.fact-value.is-empty {
  color: #6f7c8f;
  font-weight: 400;
}

.fact-note {
  color: #a9b4c4;
  font-size: 13px;
}

.viewer-foot {
  display: flex;
  justify-content: center;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: #121a26;
  flex: none;
}

.viewer-tabs {
  background: #1b2636;
  border-color: #2a374a;
}

.viewer-tabs .segment {
  color: #d6dce6;
  min-height: 40px;
  min-width: 84px;
}

.viewer-tabs .segment:hover:not(.active) {
  background: rgb(255 255 255 / 8%);
}

.viewer-tabs .segment.active {
  background: var(--color-primary);
  color: #fff;
}

/* ---------- dialog ---------- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(8 12 20 / 55%);
}

.dialog {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.dialog-text {
  margin: 0;
  color: #3d4756;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ---------- responsive ---------- */

/* Below 1100px the 10-column table becomes a card list. */
@media (max-width: 1099px) {
  .results-table {
    display: none;
  }

  .results-cards {
    display: block;
  }
}

/* Tablet & phone: sidebar becomes an off-canvas drawer. */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
    visibility: hidden;
  }

  .drawer-open .sidebar {
    transform: none;
    visibility: visible;
  }

  .drawer-open .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgb(8 12 20 / 50%);
  }

  .main {
    margin-left: 0;
  }

  .menu-toggle {
    display: inline-flex;
    margin-left: -8px;
  }

  .topbar-brand {
    display: flex;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 8px 16px;
    padding-top: max(8px, env(safe-area-inset-top));
    row-gap: 6px;
  }

  .status-bar {
    order: 3;
    flex-basis: 100%;
  }

  .content {
    padding: 18px 16px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .search-grid {
    grid-template-columns: 1fr 1fr;
  }

  .search-grid .field:first-child {
    grid-column: 1 / -1;
  }
}

/* Phones */
@media (max-width: 639px) {
  .user-text,
  .user-button > .icon-chevronDown {
    display: none;
  }

  .user-button {
    padding: 4px;
  }

  .pill {
    min-height: 28px;
    padding: 0 10px;
    font-size: 12px;
  }

  .pill .icon {
    display: none;
  }

  .page-head h1 {
    font-size: 20px;
  }

  .search-grid {
    grid-template-columns: 1fr;
  }

  .search-actions .btn-primary {
    width: 100%;
    margin-left: 0;
  }

  .search-actions .select {
    flex: 1;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar > .segmented {
    width: 100%;
    flex-wrap: wrap;
  }

  .toolbar > .segmented .segment {
    flex: 1 1 auto;
  }

  .range-grid {
    grid-template-columns: 1fr;
  }

  .segmented .segment {
    flex: 1;
    padding: 0 8px;
  }

  .toolbar-right {
    width: 100%;
  }

  .toolbar-right .select {
    flex: 1;
  }

  .btn-text {
    display: none;
  }

  .form-actions .btn {
    flex: 1;
  }

  .form-panel,
  .filter-panel,
  section.panel:not(.form-panel) {
    padding: 16px;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .kv dd {
    margin-bottom: 8px;
  }

  .stat {
    flex: 1;
    min-width: 140px;
  }

  /* Full-screen viewer */
  .viewer-overlay {
    padding: 0;
    background: #0d131d;
  }

  .viewer {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .viewer-bar {
    padding: 6px 6px 6px 12px;
    padding-top: max(6px, env(safe-area-inset-top));
  }

  .viewer-title {
    gap: 4px 10px;
  }

  .viewer-time {
    font-size: 12.5px;
  }

  .viewer-stage {
    padding: 6px 0;
  }

  .viewer-img {
    inset: 6px 0;
    width: 100%;
    height: calc(100% - 12px);
  }

  .viewer-info {
    gap: 4px 16px;
    padding: 8px 12px;
    max-height: 24%;
  }

  .viewer-foot {
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .viewer-tabs {
    width: 100%;
  }

  .viewer-tabs .segment {
    flex: 1;
    min-width: 0;
    min-height: 44px;
  }
}

@media (max-width: 359px) {
  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .segment {
    font-size: 13px;
  }

  .card-thumb {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation-duration: 0.01ms !important;
  }
}
