/* One centred column for everything: the top bar, wide pages and narrow pages share the same
   axis. Wide pages use the full column, forms and lists use two thirds of it. The licence
   plate is the only decorative mark; colour otherwise carries state. */

/* the product name's face, Latin letters in bold only; its licence is LICENSE.cinzel */
@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/cinzel-700.woff2") format("woff2");
}

:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --field: #ffffff;
  --line: #d9dee6;
  --text: #1b222c;
  --muted: #5f6b7a;
  /* the select's chevron, drawn in --muted */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%235f6b7a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --accent: #1d5fd6;
  --accent-hover: #174fb5;
  --accent-ink: #ffffff;
  --accent-soft: rgba(29, 95, 214, 0.16);
  --link: #1d5fd6;
  --ok: #17834a;
  --ok-bg: #e2f4ea;
  --bad: #c9302c;
  --bad-bg: #fbe6e5;
  --warn: #8a5a00;
  --warn-bg: #fdf0d2;
  --media-bg: #10151b;
  /* the state dots lie on a camera's picture, the same in both themes */
  --dot-bg: rgba(10, 13, 16, 0.62);
  --dot-idle: #8b96a3;
  --dot-ok: #43d17a;
  --dot-bad: #ff6b6b;
  --dot-warn: #f2b544;
  --osd-bg: rgba(10, 13, 16, 0.62);
  --osd-ink: #ffffff;
  --osd-muted: #c4ccd5;
  --tl-empty: #eef1f5;
  --tl-record: #c7d1de;
  --tl-motion: #e07b00;
  --tl-head: #1d5fd6;
  --tl-hover: rgba(27, 34, 44, 0.5);
  --tip-bg: #1b222c;
  --tip-ink: #ffffff;
  --plate-bg: #ffffff;
  --plate-ink: #15181c;
  --plate-ring: transparent;
  --plate-edge: #aab2bd;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --menu-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
  --radius: 8px;
  --radius-lg: 12px;
  --column: 1200px;
  --gutter: 24px;
  --footer: 48px;
  --feed: 320px;
  --two-thirds: calc((var(--column) - 2 * var(--gutter)) * 2 / 3);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1317;
  --surface: #171d24;
  --surface-2: #1f2730;
  --field: #0f1317;
  --line: #2c3742;
  --text: #e6ebf0;
  --muted: #93a0ad;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2393a0ad' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --accent: #2f6fe4;
  --accent-hover: #4380ee;
  --accent-ink: #ffffff;
  --accent-soft: rgba(79, 143, 247, 0.28);
  --link: #7aa9ff;
  --ok: #43d17a;
  --ok-bg: rgba(67, 209, 122, 0.14);
  --bad: #ff6b6b;
  --bad-bg: rgba(255, 107, 107, 0.14);
  --warn: #f2b544;
  --warn-bg: rgba(242, 181, 68, 0.14);
  --media-bg: #0a0d10;
  /* the state dots lie on a camera's picture, the same in both themes */
  --dot-bg: rgba(10, 13, 16, 0.62);
  --dot-idle: #8b96a3;
  --dot-ok: #43d17a;
  --dot-bad: #ff6b6b;
  --dot-warn: #f2b544;
  --osd-bg: rgba(10, 13, 16, 0.62);
  --osd-ink: #ffffff;
  --osd-muted: #c4ccd5;
  --tl-empty: #1f2730;
  --tl-record: #3b4858;
  --tl-motion: #f5a524;
  --tl-head: #6ea0ff;
  --tl-hover: rgba(230, 235, 240, 0.55);
  --tip-bg: #e6ebf0;
  --tip-ink: #0f1317;
  --plate-bg: #f4f4ee;
  --plate-ring: rgba(255, 255, 255, 0.35);
  --plate-edge: #f4f4ee;
  --shadow: none;
  --menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* the gutter is reserved so pages with and without a scrollbar share one axis */
html { scroll-padding-top: 76px; scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0 0 12px; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tz { color: var(--muted); font-size: 12px; font-weight: 400; }
/* a time that carries its own offset is not followed by today's */
span.mono:has(time .tz) + .tz { display: none; }
.link { color: var(--link); }
.link:hover { text-decoration: underline; }
.spacer { flex: 1; }

/* a tooltip: the name of a control that shows no text, under it at once on hover or focus.
   It hangs from the right edge and grows leftwards, so it stays inside a card or a dialog. */

[data-tip] { position: relative; }

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--tip-bg);
  color: var(--tip-ink);
  font: 500 12px/1.4 var(--font);
  letter-spacing: 0;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}

[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }
[data-tip-pressed][aria-pressed="true"]::after { content: attr(data-tip-pressed); }

/* top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: var(--column);
  min-height: 56px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { flex: none; }
.brand-name {
  font-family: "Cinzel", "Trajan Pro", "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 700;
  font-variant-caps: small-caps;
  letter-spacing: 0.06em;
  line-height: 1;
}

/* the footer sits at the bottom of the window on a short page */
.footer {
  height: var(--footer);
  padding: 0 var(--gutter);
  color: var(--muted);
  font-size: 12px;
  line-height: var(--footer);
  text-align: center;
}

.nav { display: flex; align-self: stretch; gap: 4px; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 2px solid transparent;
  border-top: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
}

.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); border-bottom-color: var(--accent); }

.topbar-tools { display: flex; align-items: center; gap: 8px; }

.account {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 4px 10px;
  border-radius: var(--radius);
  line-height: 1.25;
}

.account:hover, .account-menu[open] .account { background: var(--surface-2); }

/* the account menu drops from the name in the top bar; leaving is its last item, set apart */
.account-menu { position: relative; }
.account-menu summary { cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--menu-shadow);
}
.menu-form { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--line); }
.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: 14px/1.4 var(--font);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.account-login { font-weight: 600; font-size: 14px; }
.account-role { font-size: 12px; }

.theme-toggle { width: 34px; padding: 0; }

.theme-toggle::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

/* the plate: the brand mark and recognised numbers share the look of a real plate */

.plate {
  display: inline-block;
  padding: 1px 6px 1px 8px;
  border: 2px solid var(--plate-ink);
  border-radius: 4px;
  background: var(--plate-bg);
  color: var(--plate-ink);
  font: 700 15px/1.4 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 0 0 1px var(--plate-ring);
}

a.plate:hover { border-color: var(--accent); }

/* a Russian plate is a drawing with the proportions of the real one; only its height is
   set here */
.plate-ru { display: inline-block; vertical-align: middle; }
.plate-ru svg { display: block; width: auto; height: 30px; }
.plate-ru.plate-lg svg { height: 52px; }
.plate-ru text { font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif; font-weight: 700; font-stretch: condensed; fill: var(--plate-ink); }
/* the plate's own edge is white metal: a faint line keeps it apart from a light page */
.pl-bg { fill: var(--plate-bg); stroke: var(--plate-edge); stroke-width: 2; }
.pl-frame { fill: none; stroke: var(--plate-ink); stroke-width: 4; }
.pl-rus { font-size: 21px; letter-spacing: 2px; }
.pl-flag-edge { fill: none; stroke: var(--plate-ink); stroke-width: 1.5; }
a.plate-ru:hover .pl-frame { stroke: var(--accent); }

/* layout */

.container { flex: 1 0 auto; width: 100%; max-width: var(--column); margin: 0 auto; padding: 28px var(--gutter) 32px; }

/* the page header spans the column on every page; forms take two thirds of it, centred */
.narrow-block { max-width: var(--two-thirds); margin-inline: auto; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  min-height: 38px;
  margin-bottom: 20px;
}

.page-title { font-size: 24px; letter-spacing: -0.01em; }
.breadcrumb { display: flex; gap: 8px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.breadcrumb a { color: var(--link); }
.breadcrumb a:hover { text-decoration: underline; }

.stack { display: flex; flex-direction: column; gap: 20px; }

.grid {
  display: grid;
  /* the columns always fill the row, so a lone card stands in the first one */
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.grid > .empty { grid-column: 1 / -1; }

/* cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

.card-title, .section-title { font-size: 16px; }
.card-body { padding: 20px; }
.card-body > :last-child { margin-bottom: 0; }

.card-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.hint { font-size: 13px; color: var(--muted); }
.card-body > .hint { display: block; margin-bottom: 16px; }

.empty { padding: 48px 20px; color: var(--muted); text-align: center; }
.empty p:last-child { margin-bottom: 0; }

/* status */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.badge.online, .badge.confirmed, .badge.sent { background: var(--ok-bg); color: var(--ok); }
.badge.offline, .badge.rejected, .badge.failed { background: var(--bad-bg); color: var(--bad); }
.badge.pending, .badge.recording { background: var(--warn-bg); color: var(--warn); }
.badge.role-admin { background: var(--accent-soft); color: var(--link); }
/* a mark beside a status, not a status: outlined and without the dot */
.badge.manual { padding-inline: 10px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.badge.manual::before { content: none; }

@keyframes pulse { 50% { opacity: 0.35; } }
.badge.recording::before { animation: pulse 1.6s ease-in-out infinite; }

/* buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 500 14px/1.2 var(--font);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:disabled { opacity: 0.5; cursor: default; pointer-events: none; }
/* a disabled button that says why: it takes the pointer so the tooltip shows, and is dimmed
   by its colours, since opacity would dim the tooltip with it */
.btn:disabled[data-tip] { opacity: 1; pointer-events: auto; background: var(--surface-2); border-color: var(--line); color: var(--muted); }
/* disabled by its own request, the recognize button stays primary: its icon pulses and its
   tooltip stays up, saying what is happening */
.btn-primary[data-recognize-now].htmx-request:disabled { pointer-events: none; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn[data-recognize-now].htmx-request svg { animation: pulse 1.2s ease-in-out infinite; }
.btn[data-recognize-now].htmx-request::after { content: "Распознаём…"; opacity: 1; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
/* a button that is only an icon: the action is named by its tooltip and aria-label */
.btn-icon { flex: none; width: 32px; padding: 0; }
.btn-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card-actions { display: flex; flex: none; gap: 4px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { border-color: transparent; color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: transparent; border-color: transparent; color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: transparent; }

/* forms */

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row label { font-size: 13px; font-weight: 600; }

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  font: 15px/1.4 var(--font);
  transition: border-color 0.12s, box-shadow 0.12s;
}

/* a select draws its own chevron, as far from the right edge as the text is from the left:
   the browser's arrow sits against the border */
select {
  appearance: none;
  padding-right: 36px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
  cursor: pointer;
}

input::placeholder { color: var(--muted); opacity: 0.8; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* a secret field draws one frame as wide as its neighbours around the input and its eye:
   the input itself ends before the eye, where a password manager puts its own icon */
.secret-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.secret-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.secret-field input { flex: 1; min-width: 0; min-height: 36px; border: 0; background: transparent; }
.secret-field input:focus { box-shadow: none; }
.secret-field .btn-icon { min-height: 36px; margin-right: 2px; }
.secret-field .btn-icon:focus-visible { box-shadow: none; outline: 2px solid var(--accent); outline-offset: -2px; }
/* stands in for the eye in a field that shares another field's eye, so both inputs end at the same place */
.secret-gap { flex: none; width: 32px; }
.secret-field .strike { display: none; }
.secret-field [aria-pressed="true"] .strike { display: inline; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid > .form-row { margin-bottom: 0; }
.form-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; }
.form-grid + .form-inline { margin-top: 20px; }

/* a checkbox drawn as a switch */

.checkbox { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }

.checkbox input {
  appearance: none;
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: background-color 0.15s;
}

.checkbox input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.checkbox input:checked { background: var(--accent); }
.checkbox input:checked::after { transform: translateX(16px); }
.checkbox input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* messages */

.notice, .error {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
}

.notice.success { border-color: transparent; background: var(--ok-bg); color: var(--ok); }
.error { border-color: transparent; background: var(--bad-bg); color: var(--bad); }

.test-result:empty { display: none; }
.test-result p { margin: 16px 20px; }
.busy { display: none; font-size: 13px; color: var(--muted); }
.busy.htmx-request { display: inline; }

/* tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }

.table th {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.table td { padding: 10px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* cameras */

.camera-header { min-height: 60px; }
.camera-name { flex: 1; min-width: 0; }
.camera-title { font-size: 16px; }
.camera-title a:hover { color: var(--link); }

/* the page of one camera: the picture is not a link to the page it is on */
.camera-view .preview { pointer-events: none; }

/* the archive player of a camera's page: the picture with the time of its frame, the
   controls, and the timeline of recording, motion and recognitions under them */
.player-days { align-items: center; }
.player-date { width: auto; min-height: 32px; padding: 2px 8px; font-size: 13px; }
/* the picture leaves room for the controls and the timeline in one screen */
.player { container-type: inline-size; }
.player-screen { position: relative; height: min(56.25cqw, max(240px, calc(100vh - 280px))); background: var(--media-bg); }
.player-video { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--media-bg); }
/* top right, clear of the date most cameras print in their top left corner */
.player-clock {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--osd-bg);
  color: var(--osd-ink);
  font-size: 13px;
  pointer-events: none;
}
.player-clock:empty { display: none; }
.player-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 12px;
  color: var(--osd-muted);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}
.player-note[hidden] { display: none; }
.player-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}
.player-group { display: flex; align-items: center; gap: 4px; }
.player-play .icon-pause { display: none; }
.player[data-playing] .player-play .icon-play { display: none; }
.player[data-playing] .player-play .icon-pause { display: block; }
.player-speed { display: flex; }
.player-speed .btn { min-width: 44px; border-radius: 0; font-variant-numeric: tabular-nums; }
.player-speed .btn + .btn { margin-left: -1px; }
.player-speed .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.player-speed .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.player-speed .btn[aria-pressed="true"] { position: relative; z-index: 1; border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.timeline { position: relative; margin: 0 16px 14px; border-radius: 4px; touch-action: none; user-select: none; }
.timeline:focus-visible { outline-offset: 4px; }
.timeline-canvas { display: block; width: 100%; height: 72px; cursor: crosshair; }
.timeline-tip {
  position: absolute;
  bottom: calc(100% + 4px);
  z-index: 20;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--tip-bg);
  color: var(--tip-ink);
  font-size: 12px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.camera-url { display: block; max-width: 100%; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--media-bg);
}

.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview-note { margin: 0; padding: 12px; color: #93a0ad; font-size: 14px; text-align: center; }

/* the camera's state as dots in the bottom right corner of its picture: the link,
   recognition, recording, each named by a tooltip that opens above it, inside the card */
.camera-live { position: relative; }
.camera-status {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--dot-bg);
}

.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot-idle); cursor: default; }
.status-dot.online { background: var(--dot-ok); }
.status-dot.offline { background: var(--dot-bad); }
.status-dot.recording { background: var(--dot-warn); animation: pulse 1.6s ease-in-out infinite; }
.status-dot:focus-visible { outline-offset: 3px; }
.status-dot[data-tip]::after { top: auto; right: -8px; bottom: calc(100% + 12px); }


/* login */

.login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px - var(--footer));
}

.login-card { width: 100%; max-width: 400px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; text-align: center; }
.login-brand .brand-name { font-size: 28px; }
.login-card .card-body { padding: 28px; }
.login .page-title { margin-bottom: 20px; font-size: 20px; text-align: center; }

/* journal */

.filters {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px 20px;
}

.filters .form-row { margin: 0; }
.filters .filter-plate input { font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.filters .filter-plate input::placeholder { font-family: var(--font); letter-spacing: normal; text-transform: none; }

.journal td { white-space: nowrap; }
.journal .nowrap { white-space: nowrap; }

.thumb-cell { width: 96px; text-align: right; }
.thumb { display: inline-block; height: 36px; width: auto; border-radius: 4px; background: var(--media-bg); }

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

/* how many of the rows found are on the page, above the table */
.table-count { padding: 12px 20px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.table-count .mono { color: var(--text); }

/* page numbers joined into one strip, the current one filled */
.pagination { display: flex; grid-column: 2; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  margin-left: -1px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--link);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.page-link:first-child { margin-left: 0; border-radius: var(--radius) 0 0 var(--radius); }
.page-link:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
a.page-link:hover { position: relative; background: var(--surface-2); border-color: var(--muted); }
.page-link.current { position: relative; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* the strip lies on the card's bottom edge, which cuts off whatever hangs below it */
.page-link[data-tip]::after { top: auto; right: auto; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); }
.page-link.off { color: var(--muted); opacity: 0.6; }
.page-size { display: flex; align-items: center; justify-self: end; gap: 8px; color: var(--muted); white-space: nowrap; }
.page-size select { width: auto; min-height: 36px; }

/* event page */

.event-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.plate.plate-lg { padding: 3px 12px 3px 14px; font-size: 24px; }
.event-where { font-size: 14px; }

.event-media {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.event-frame { display: flex; align-items: center; justify-content: center; background: var(--media-bg); }
.event-frame img { width: 100%; height: auto; }
.event-frame .preview-note { padding: 40px 16px; }

.event-crop-wrap { display: flex; justify-content: center; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--media-bg); }
.event-crop { max-height: 96px; width: auto; border-radius: 4px; }

.meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px 20px;
  align-items: center;
  margin: 0;
  font-size: 14px;
}

.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.event-details .meta dd { text-align: right; }

.event-section { margin-bottom: 20px; }

.clip { display: block; width: 100%; max-height: 70vh; border-radius: var(--radius); background: var(--media-bg); }
#clip > p, .deliveries > p { margin: 0; }

.delivery-list { margin: -8px 0; padding: 0; list-style: none; }

.delivery {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 110px 170px;
  align-items: center;
  gap: 6px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.delivery:first-child { border-top: 0; }
.delivery > .mono { text-align: right; }
.delivery-channel { font-weight: 600; }
.delivery-error { grid-column: 1 / -1; color: var(--bad); overflow-wrap: anywhere; }

/* settings */

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }

.tabs a {
  margin-bottom: -1px;
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
}

.tabs a:hover { color: var(--text); }
.tabs a.active { border-bottom-color: var(--accent); color: var(--text); }

/* a tab is one form: its groups sit side by side and share the save in the footer */
.groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 40px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.group-title { margin-bottom: 16px; font-size: 16px; }
.group-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.group .test-result p { margin: 12px 0 0; }

.webhooks .webhook-name { font-weight: 600; white-space: nowrap; }
.webhooks .webhook-url { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.webhooks .actions { text-align: right; white-space: nowrap; }
.webhooks .actions .btn { margin-left: 4px; }

/* a list to tick from that stays usable with dozens of items: search, counter, own scroll */
.picker { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.picker-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.picker-bar input[type="search"] { flex: 0 1 220px; min-height: 32px; padding-block: 3px; }
.picker-count { font-size: 13px; white-space: nowrap; }
.picker-empty { margin: 0; }

.picker-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px 12px;
  max-height: 216px;
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

.check { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 6px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* dialogs: the form card is the whole visible surface */

.modal {
  width: min(480px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100vh - 2 * var(--gutter));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: inherit;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  overflow: auto;
}

/* a long form scrolls inside its body, so the header and the buttons stay in view */
.modal .card { display: flex; flex-direction: column; max-height: calc(100vh - 2 * var(--gutter)); margin: 0; box-shadow: none; }
.modal .card-body { min-height: 0; overflow-y: auto; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
textarea.sample { font-size: 13px; line-height: 1.5; resize: vertical; white-space: pre; }
.modal-wide { width: min(680px, calc(100vw - 2 * var(--gutter))); }
.modal::backdrop { background: rgba(10, 14, 20, 0.55); }

/* users */

.card-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.card-toolbar input[type="search"] { flex: 0 0 240px; }
.card-toolbar .hint { flex: 1 1 280px; }

/* toasts: result messages float under the top bar and never push the page */

.toasts {
  position: fixed;
  top: 68px;
  left: 50%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100vw - 2 * var(--gutter)));
  transform: translateX(-50%);
  pointer-events: none;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 12px 12px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ok);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast-error { border-left-color: var(--bad); }
.toast-text { flex: 1; overflow-wrap: anywhere; }

.toast-close {
  position: relative;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toast-close:hover { background: var(--surface-2); color: var(--text); }

.toast-close::before, .toast-close::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 7px;
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(45deg);
}

.toast-close::after { transform: rotate(-45deg); }
.users td { white-space: nowrap; }
.users :is(th, td) { padding-inline: 12px; }
.users :is(th, td):first-child { padding-left: 20px; }
.users :is(th, td):last-child { padding-right: 20px; }
.users td:first-child { width: 22%; }
.users .user-login { margin-right: 8px; font-weight: 600; }
.users form { margin: 0; }
.users select {
  width: 156px;
  min-height: 32px;
  padding: 3px 32px 3px 10px;
  background-position: right 10px center;
  font-size: 14px;
}
.users .actions { text-align: right; }
.users .actions .btn { margin-left: 4px; }
[hidden] { display: none !important; }

/* the feed of recognitions: a panel on the left edge of the window that stays open from
   page to page; the page, top bar included, moves over and keeps its one axis */

.feed {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  width: var(--feed);
  background: var(--surface);
  border-right: 1px solid var(--line);
}

body:has(> .feed:not([hidden])) { padding-left: var(--feed); }
body:has(> .feed:not([hidden])) .toasts { left: calc(50% + var(--feed) / 2); }

.feed-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 57px;
  padding: 0 16px 0 12px;
  border-bottom: 1px solid var(--line);
}

.feed-header .section-title { flex: 1; }

/* the feed's button stands at the left edge of the window, where the feed opens: in the
   top bar while the feed is closed, in the feed's own header, on the same spot, while it
   is open. Its tooltip grows rightwards, into the window. */
.feed-switch[data-tip]::after { right: auto; left: 0; }
.feed-switch svg { width: 18px; height: 18px; }
.topbar .feed-switch { position: absolute; top: 12px; left: 12px; }
body:has(> .feed:not([hidden])) .topbar .feed-switch { display: none; }
/* the column reaches the edge of a narrower window, so the brand makes room for the button */
@media (max-width: 1300px) {
  .topbar-inner { padding-left: 56px; }
}

/* the filter of the feed's types: a funnel at the right of its header that drops a list of
   ticks; it is marked while it hides a type, so the header carries no text for it */
.feed-types { position: relative; }
.feed-types summary { list-style: none; }
.feed-types summary::-webkit-details-marker { display: none; }
.feed-types[open] summary { background: var(--surface-2); color: var(--text); }
.feed-types[open] summary::after { opacity: 0; }
.feed-types:has(input:not(:checked)) summary { color: var(--link); }
.feed-types:has(input:not(:checked)) summary::before {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}
.feed-types .menu { min-width: 190px; }
.feed-types .check { padding: 6px 8px; }

/* the list and its stream are swapped together, as children of the panel */
.feed-body { display: contents; }

.feed-list { flex: 1; min-height: 0; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.feed-list:empty { display: none; }
.feed-empty { margin: 0; padding: 48px 16px; color: var(--muted); text-align: center; }
.feed-list:not(:empty) + .feed-empty { display: none; }

.feed-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.feed-item:hover { background: var(--surface-2); }
.feed-item:focus-visible { outline-offset: -2px; }
.feed-badges { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; justify-self: end; gap: 4px 6px; }
.feed-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed-camera { overflow: hidden; font-size: 13px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }

/* too narrow for the panel and the page side by side: the panel lies over the page;
   FEED_OVER_PAGE in app.js repeats this width */
@media (max-width: 1100px) {
  .feed { box-shadow: var(--menu-shadow); }
  body:has(> .feed:not([hidden])) { padding-left: 0; }
  body:has(> .feed:not([hidden])) .toasts { left: 50%; }
}

/* phone */

@media (max-width: 720px) {
  :root { --gutter: 12px; --feed: 100vw; }
  .topbar-inner { flex-wrap: wrap; gap: 0 12px; padding-top: 8px; padding-left: var(--gutter); }
  /* only the first row makes room for the feed's button; the sections keep the full width */
  .brand { margin-left: 40px; }
  .topbar-tools { margin-left: auto; }
  .nav { order: 2; flex-basis: 100%; min-height: 44px; }
  .nav a { flex: 1; justify-content: center; padding: 0 4px; }
  .container { padding-top: 16px; }
  .grid { grid-template-columns: 1fr; }
  .form-grid, .groups { grid-template-columns: 1fr; }
  .picker-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-header, .card-body, .card-footer { padding-inline: 14px; }
  .filters { grid-template-columns: 1fr 1fr; padding-inline: 14px; }
  .filters .filter-plate { grid-column: 1 / -1; }
  .table th, .table td { padding-inline: 12px; }
  .pager { grid-template-columns: 1fr; justify-items: center; }
  .pagination { grid-column: 1; }
  .page-link.far { display: none; }
  .page-size { justify-self: center; }
  .table-count { padding-inline: 14px; }
  .event-media { grid-template-columns: 1fr; }
  .plate.plate-lg { font-size: 20px; }
  .plate-ru.plate-lg svg { height: 44px; }
  .delivery { grid-template-columns: 1fr auto; }
  .delivery > .mono { grid-column: 1 / -1; text-align: left; }
  .card-toolbar { padding-inline: 14px; }
  .card-toolbar input[type="search"] { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
