/* SLFF Toll ANPR operator console.
 *
 * The page is a page of the ION dashboard (apps/admin in the slff-toll repo). The dashboard
 * shows it in a frame, under its own navbar and page title. Thus this page has no top bar:
 * the status (ANPR, cameras, reads, clock) is in the head of the Cameras panel.
 *
 * Rules for this sheet:
 * - The colors, the fonts and the radii are the dashboard tokens (apps/admin/src/styles.css).
 *   When the dashboard theme changes, change the tokens below to agree.
 * - The panels are solid dashboard cards. In a frame, the page background is transparent,
 *   so the dashboard gradient shows between the panels. Alone, the page draws the gradient.
 * - Green, amber and red appear only for state.
 * - A number plate is a white plate with black letters. Nothing else looks like that.
 * - Zone editor: pink is a new zone that is not active. Light blue is the active zone (the
 *   server draws it on the video).
 * - No font from the network: toll sites can be offline. The Roboto files are in fonts/.
 */

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/roboto-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/roboto-latin-500-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/roboto-latin-700-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/roboto-mono-latin-400-normal.woff2") format("woff2");
}

:root {
  /* Dashboard tokens (names as in apps/admin/src/styles.css). */
  --background: #050f17;
  --card: #081017;
  --popover: #0e1820;
  --secondary: #121a21; /* Tiles in a card: camera tiles, plate reads. */
  --secondary-hover: #18232c;
  --foreground: #ffffff;
  --muted-foreground: #b5b5b5;
  --dim: #808b95; /* Third level of text. 5:1 on --card. */
  --border: rgb(255 250 250 / 0.08);
  --border-strong: rgb(255 250 250 / 0.12);
  --input: rgb(255 250 250 / 0.16);
  --input-hover: rgb(255 250 250 / 0.28);
  --field: #121a21;
  --ring: #8fd4ee;
  --primary: #134975; /* Brand Void Blue. */
  --brand-cyan: #009edc; /* Brand Quantum Cyan: the one main action. */
  --brand-cyan-hover: color-mix(in oklab, #009edc, #bffff8 30%);
  --brand-void: #020202;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Solid status tags (the dashboard StatusTag): white text on the fill. */
  --tag-success: #15771c;
  --tag-warning: #c19e00;
  --tag-danger: #810f1e;
  --tag-neutral: #3a4652;

  /* State lamps and state text. Lighter than the tag fills, to read on the dark cards. */
  --ok: #3ac46a;
  --wait: #e6c13a;
  --bad: #f2695c;
  --bad-text: #f4b2a0; /* The dashboard error text. */
  --off: #6b7783;

  /* Zone editor. */
  --draft: #ff7ad1;
  --zone-active: #3cc8ff; /* The server zone line: BGR (255, 200, 60). */

  --font-ui: "Roboto", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-code: "Roboto Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* Only for the number plates: the plate face is DIN. DIN is on macOS, Bahnschrift (also
     DIN) is on Windows. */
  --font-sign: "DIN Alternate", "Bahnschrift", "DIN 1451 Std", "D-DIN", "Roboto Condensed",
    "Arial Narrow", var(--font-ui);

  color-scheme: dark;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 16px;
  overflow: hidden;
  /* The dashboard page glow, when the page is open alone. */
  background-color: var(--background);
  background-image: linear-gradient(
    to bottom,
    #040b11 0%,
    #092033 20%,
    var(--primary) 50%,
    #0b273e 80%,
    #050e16 100%
  );
  color: var(--foreground);
  font: 14px/1.43 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--input) transparent;
  scrollbar-width: thin;
}

/* In the dashboard frame: the dashboard draws the background and the margins. A frame is
   transparent only when its color-scheme is the same as the page around it (dark). */
.is-embedded body {
  padding: 0;
  background: transparent;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 500;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

::selection {
  background: var(--primary);
  color: var(--foreground);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* --- State lamps ------------------------------------------------------------------------- */

.lamp {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lamp, var(--off));
}

[data-state="online"],
[data-state="ready"],
[data-state="live"],
[data-state="all"] {
  --lamp: var(--ok);
}

[data-state="connecting"],
[data-state="loading"],
[data-state="some"] {
  --lamp: var(--wait);
}

[data-state="offline"],
[data-state="error"],
[data-state="none"] {
  --lamp: var(--bad);
}

[data-state="disabled"] {
  --lamp: var(--off);
}

[data-state="online"] .lamp,
[data-state="ready"] .lamp,
[data-state="live"] .lamp {
  box-shadow: 0 0 6px color-mix(in srgb, var(--ok) 55%, transparent);
}

[data-state="connecting"] .lamp,
[data-state="loading"] .lamp {
  animation: blink 1.6s steps(2, jump-none) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* --- Server link lost -------------------------------------------------------------------- */

.link-lost {
  --lamp: var(--bad);
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--tag-danger) 45%, var(--card));
  color: var(--bad-text);
  font-weight: 500;
}

/* --- Layout and panels ------------------------------------------------------------------- */

.console {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) 384px;
  gap: 16px;
  min-height: 0;
}

/* A dashboard card ("Dashboard/Card" in the design): solid, so the video and the rows keep
   their contrast on the gradient. */
.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
}

.panel-head {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 60px;
  padding: 12px 16px;
}

.panel-title {
  font-size: 14px;
  line-height: 24px;
  font-weight: 500;
}

.cameras {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  /* 2 px at the top: room for the focus ring of a tile in the first row. */
  padding: 2px 16px 16px;
  overflow-y: auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 1), minmax(0, 1fr));
  align-content: start;
  gap: 12px;
  width: 100%;
  max-width: var(--grid-max, none);
  margin-inline: auto;
}

.empty {
  margin: 0;
  padding: 24px 16px;
  color: var(--muted-foreground);
  max-width: 60ch;
}

/* --- System status (the head of the Cameras panel) ---------------------------------------- */

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  min-width: 0;
  margin-left: auto;
  color: var(--muted-foreground);
}

.anpr {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 0.03);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: help;
}

.anpr[data-state="error"] {
  border-color: color-mix(in srgb, var(--bad) 60%, transparent);
  color: var(--bad-text);
}

.stat {
  white-space: nowrap;
}

.stat .num {
  margin-right: 2px;
  color: var(--foreground);
  font-size: 16px;
  font-weight: 700;
}

#cams[data-state="some"] .num {
  color: var(--wait);
}

#cams[data-state="none"] .num {
  color: var(--bad);
}

.clock {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-left: 18px;
  border-left: 1px solid var(--border-strong);
  white-space: nowrap;
}

.clock-time {
  color: var(--foreground);
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.clock-zone {
  color: var(--foreground);
  font-size: 12px;
  font-weight: 500;
}

.clock-date {
  font-size: 12px;
}

/* --- Buttons (the dashboard "outline" and "brand" buttons) -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 0.03);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s;
}

.btn:hover {
  border-color: var(--input-hover);
  background: rgb(255 255 255 / 0.08);
}

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

.btn:disabled:hover {
  border-color: var(--input);
  background: rgb(255 255 255 / 0.03);
}

.btn-main {
  border-color: transparent;
  background: var(--brand-cyan);
  color: var(--brand-void);
  font-weight: 600;
}

.btn-main:hover {
  border-color: transparent;
  background: var(--brand-cyan-hover);
}

/* --- Form fields (the dashboard Input) ---------------------------------------------------- */

.feed-tools select,
.feed-tools input {
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--field);
  font-size: 14px;
}

.feed-tools select:focus-visible,
.feed-tools input:focus-visible,
.zone-yaml textarea:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

.feed-tools input::placeholder {
  color: var(--muted-foreground);
}

/* --- Tooltip (drawn by the page, see Tooltip in util.js) ---------------------------------- */

.tip {
  position: fixed;
  z-index: 50;
  width: max-content;
  padding: 6px 10px;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  background: var(--popover);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  color: var(--foreground);
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
}

/* --- Camera tile (as the dashboard CCTV card) --------------------------------------------- */

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--secondary);
  cursor: zoom-in;
}

/* The top edge works like a lane signal: its color is the camera state. */
.tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 2px;
  background: var(--lamp);
}

.tile[data-state="online"]::before {
  opacity: 0.7;
}

.tile:hover {
  border-color: var(--input);
}

.tile:focus-visible {
  outline-offset: 1px;
}

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile[data-signal="none"] .video {
  visibility: hidden;
}

.tile[data-signal="stale"] .video {
  opacity: 0.3;
  filter: grayscale(1);
}

.nosignal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  text-align: center;
  background: repeating-linear-gradient(
    135deg,
    transparent 0 12px,
    rgb(255 255 255 / 0.02) 12px 24px
  );
}

.nosignal-title {
  font-size: 16px;
  font-weight: 500;
}

.tile[data-state="offline"] .nosignal-title {
  color: var(--bad-text);
}

.nosignal-detail {
  max-width: 44ch;
  color: var(--muted-foreground);
  font-size: 12px;
}

.caption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  min-height: 60px;
  padding: 10px 14px;
}

.cam-name {
  overflow: hidden;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* The dashboard StatusTag: a small solid tag, white text. */
.badge {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  padding: 0 6px;
  border-radius: 2px;
  background: var(--tag-neutral);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}

.badge .lamp {
  display: none;
}

.tile[data-state="online"] .badge {
  background: var(--tag-success);
}

.tile[data-state="connecting"] .badge {
  background: var(--tag-warning);
}

.tile[data-state="offline"] .badge {
  background: var(--tag-danger);
}

.cam-tech {
  overflow: hidden;
  color: var(--dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: pre;
  text-overflow: ellipsis;
}

.cam-last {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
  min-height: 20px;
}

.cam-last-time {
  color: var(--muted-foreground);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.cam-last-none {
  color: var(--dim);
  font-size: 12px;
}

/* --- Focus mode -------------------------------------------------------------------------- */

.focus-bar {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.hint {
  margin-left: auto;
  color: var(--dim);
  font-size: 12px;
}

/* --- Zone editor ------------------------------------------------------------------------- */

.zone-why {
  color: var(--muted-foreground);
  font-size: 12px;
}

.zone-why.is-blocked {
  color: var(--wait);
}

.zone-bar,
.zone-result {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--draft);
  border-radius: var(--radius-md);
  background: var(--secondary);
}

.zone-bar p,
.zone-result p {
  margin: 0;
}

.zone-tools,
.zone-result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.zone-gap {
  flex: 1;
  min-width: 8px;
}

.zone-help {
  color: var(--muted-foreground);
  font-size: 12px;
}

.zone-keys {
  color: var(--dim);
}

.zone-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 2px;
}

.swatch + .swatch,
.zone-legend .swatch-active {
  margin-left: 10px;
}

.swatch-draft {
  background: var(--draft);
}

.swatch-active {
  background: var(--zone-active);
}

.zone-status {
  font-variant-numeric: tabular-nums;
  min-height: 1lh; /* Keep one line when empty: the video must not move while the user edits. */
}

.zone-status.is-problem {
  color: var(--wait);
}

.zone-warn {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--bad-text);
  font-weight: 500;
}

.zone-result {
  max-height: 50%;
  overflow-y: auto;
}

.zone-result-title {
  font-size: 14px;
}

.zone-note {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--wait) 12%, transparent);
  color: var(--wait);
}

.zone-steps {
  margin: 0;
  padding-left: 22px;
}

.zone-steps li + li {
  margin-top: 2px;
}

.zone-result code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--background);
  font: 12px var(--font-code);
}

.zone-yaml {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.zone-yaml textarea {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--foreground);
  font: 12px/1.5 var(--font-code);
  field-sizing: content;
  resize: none;
}

.zone-copy-msg:empty {
  display: none;
}

.zone-copy-msg {
  color: var(--wait);
}

.zone-copy-msg.is-ok {
  color: var(--ok);
}

/* A margin around the video while the editor is open, so the points at the frame edges are
   easy to see and to drag. A click in the margin puts the point on the edge. */
.tile.is-zone-editing .video {
  inset: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
}

.zone-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.zone-layer:focus {
  outline: none;
}

.zone-layer:focus-visible {
  outline: 2px solid var(--draft);
  outline-offset: -2px;
}

.zone-layer.is-readonly {
  cursor: default;
}

.zone-svg {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}

.zone-fill {
  fill: color-mix(in srgb, var(--draft) 16%, transparent);
  fill-rule: evenodd;
}

.zone-casing {
  stroke: rgb(0 0 0 / 0.55);
  stroke-width: 4.5;
  stroke-linecap: round;
}

.zone-edge {
  stroke: var(--draft);
  stroke-width: 2;
  stroke-linecap: round;
}

.zone-edge.is-crossing {
  stroke: var(--bad);
  stroke-dasharray: 7 5;
}

.zone-pt {
  pointer-events: auto;
  cursor: grab;
}

.zone-layer.is-dragging,
.zone-layer.is-dragging .zone-pt {
  cursor: grabbing;
}

.zone-layer.is-readonly .zone-pt {
  pointer-events: none;
}

.zone-hit {
  fill: transparent;
}

.zone-dot {
  fill: var(--draft);
  stroke: #1a0b15;
  stroke-width: 1.5;
}

.zone-pt.is-first .zone-dot {
  fill: #1a0b15;
  stroke: var(--draft);
  stroke-width: 3;
}

.zone-pt:hover .zone-dot,
.zone-pt.is-active .zone-dot {
  stroke: var(--foreground);
}

.zone-layer.is-readonly .zone-pt .zone-dot {
  r: 3;
}

body[data-mode="focus"] .cameras {
  overflow: hidden;
}

body[data-mode="focus"] .grid {
  flex: 1;
  max-width: none;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}

body[data-mode="focus"] .tile:not(.is-focused) {
  display: none;
}

.tile.is-focused {
  min-height: 0;
  cursor: default;
}

.tile.is-focused .screen {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
}

.tile.is-focused .cam-name {
  font-size: 15px;
}

/* --- Number plate ------------------------------------------------------------------------ */

/* A current Indonesian civil plate: white face, black letters, thin black rim. */
.plate {
  display: inline-block;
  padding: 5px 9px 4px;
  border: 1px solid #000;
  border-radius: 3px;
  background: #fff;
  box-shadow:
    inset 0 0 0 1px #fff,
    inset 0 0 0 2px #000;
  color: #000;
  font: 700 17px/1 var(--font-sign);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.plate-sm {
  padding: 3px 6px 2px;
  font-size: 13px;
}

.plate-lg {
  padding: 8px 16px 6px;
  box-shadow:
    inset 0 0 0 2px #fff,
    inset 0 0 0 3.5px #000;
  font-size: 30px;
}

.plate-invalid {
  outline: 2px dashed var(--bad);
  outline-offset: 2px;
}

/* --- Read feed (as the dashboard "Transaksi terbaru" list) -------------------------------- */

.feed-count {
  color: var(--dim);
  font-size: 12px;
}

.feed-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--muted-foreground);
  font-size: 12px;
}

.feed-live[data-state="connecting"] {
  color: var(--wait);
}

.feed-tools {
  display: grid;
  flex: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 0 16px 12px;
}

.reads {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding: 2px 16px 16px;
  overflow-y: auto;
  list-style: none;
}

.read-item {
  flex: none;
}

.read {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  grid-template-areas:
    "crop plate time"
    "crop sub conf";
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--secondary);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}

.read:hover {
  background: var(--secondary-hover);
}

.read-crop {
  grid-area: crop;
  display: block;
  width: 96px;
  height: 34px;
  overflow: hidden;
  border-radius: 4px;
  background: #000;
}

.read-crop img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.read-crop-none {
  background: repeating-linear-gradient(135deg, var(--secondary-hover) 0 4px, var(--card) 4px 8px);
}

.read-plate {
  grid-area: plate;
  min-width: 0;
}

.read-sub {
  grid-area: sub;
  display: flex;
  gap: 8px;
  min-width: 0;
  color: var(--muted-foreground);
  font-size: 12px;
}

.read-cam {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.read-flag {
  flex: none;
  color: var(--bad-text);
  font-weight: 500;
}

.read-time {
  grid-area: time;
  justify-self: end;
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.read-conf {
  grid-area: conf;
  justify-self: end;
  color: var(--muted-foreground);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.read-conf.is-low {
  color: var(--wait);
}

/* A new read: a short cyan wash and ring that fade out. */
.read-item.is-new .read {
  animation: arrive 2.4s ease-out;
}

@keyframes arrive {
  from {
    background-color: color-mix(in srgb, var(--brand-cyan) 22%, var(--secondary));
    box-shadow: inset 0 0 0 1px var(--brand-cyan);
  }
  to {
    background-color: var(--secondary);
    box-shadow: inset 0 0 0 1px transparent;
  }
}

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

.dlg {
  width: min(1200px, 94vw);
  max-height: 92vh;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.5);
  color: var(--foreground);
}

.dlg::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.dlg-inner {
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.dlg-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  padding: 16px;
  overflow: auto;
}

.dlg-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #000;
}

.dlg-img-wrap {
  position: relative;
  line-height: 0;
}

.dlg-img-wrap img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 130px);
}

.dlg-frame.is-empty .dlg-img-wrap {
  display: none;
}

.dlg-box {
  position: absolute;
  border: 2px solid var(--wait);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.6);
}

.dlg-noimg {
  padding: 24px;
  color: var(--muted-foreground);
}

.dlg-crop {
  display: block;
  width: 100%;
  margin-bottom: 16px;
  border-radius: 4px;
}

.dlg-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
}

.dlg-facts dt {
  color: var(--muted-foreground);
}

.dlg-facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.dlg-facts dd.is-bad {
  color: var(--bad-text);
  font-weight: 500;
}

.dlg-raw,
.dlg-id {
  font-family: var(--font-code);
  font-size: 12px;
  word-break: break-all;
}

/* --- Small screens ----------------------------------------------------------------------- */

@media (max-width: 960px) {
  body {
    height: auto;
    min-height: 100dvh;
    padding: 12px;
    overflow: auto;
  }

  .console {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .status {
    margin-left: 0;
  }

  .cameras,
  body[data-mode="focus"] .cameras {
    overflow: visible;
  }

  .tile.is-focused .screen {
    aspect-ratio: 16 / 9;
  }

  .feed {
    max-height: 75vh;
  }

  .hint {
    display: none;
  }

  .zone-gap {
    display: none;
  }

  .dlg-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

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