/* platebot admin — светлая тема, системные шрифты */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #6b7684;
  --line: #e3e8ee;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --info: #0891b2;
  --side: #17202b;
  --side-text: #c6d0dc;
  --side-active: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); }
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.hidden { display: none !important; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 18px 18px 10px; font-weight: 700; font-size: 16px; color: #fff; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: #8b98a8; margin-top: 2px; }
.nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; }
.nav a {
  color: var(--side-text); padding: 8px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav .ico { width: 20px; text-align: center; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 6px; }
.sidebar .foot { margin-top: auto; padding: 12px 18px; font-size: 11px; color: #8b98a8; }
.sidebar .foot a { color: #b8c4d1; }
.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.topbar h1 { margin: 0; }
.menu-btn { display: none; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .sep { display: none; }
  .sidebar .foot { display: none; }
  .main { padding: 14px; }
}

/* cards & grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.tight { padding: 10px 12px; }
.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpi-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi-tile .lbl { font-size: 12px; color: var(--muted); }
.kpi-tile .val { font-size: 24px; font-weight: 700; margin-top: 2px; line-height: 1.2; }
.kpi-tile .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-tile.ok .val { color: var(--ok); }
.kpi-tile.warn .val { color: var(--warn); }
.kpi-tile.bad .val { color: var(--bad); }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
tr:hover td { background: #fafcff; }
tr.low td { background: #fff7ed; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.thumb { height: 34px; max-width: 160px; border-radius: 4px; border: 1px solid var(--line); background: #fff; object-fit: contain; vertical-align: middle; }
.thumb.md { height: 56px; max-width: 260px; }
.thumb.lg { height: 90px; max-width: 420px; }
.thumbs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 18px; white-space: nowrap; background: #e5e7eb; color: #374151; }
.badge.pending, .badge.running { background: #dbeafe; color: #1e40af; }
.badge.confirmed, .badge.ok { background: #dcfce7; color: #166534; }
.badge.corrected { background: #fef3c7; color: #92400e; }
.badge.rejected, .badge.failed { background: #fee2e2; color: #991b1b; }
.badge.auto { background: #e0e7ff; color: #3730a3; }
.badge.review { background: #ffedd5; color: #9a3412; }
.badge.dataset { background: #f3f4f6; color: #4b5563; }
.badge.killed { background: #fde68a; color: #78350f; }
.badge.lost { background: #e5e7eb; color: #6b7280; }
.badge.src-student { background: #ede9fe; color: #5b21b6; }
.badge.src-teacher { background: #cffafe; color: #155e75; }
.badge.src-both { background: #dcfce7; color: #166534; }
.badge.bot { background: #dbeafe; color: #1e40af; }
.badge.admin { background: #fce7f3; color: #9d174d; }
.badge.import { background: #ecfccb; color: #3f6212; }
.badge.other { background: #e5e7eb; color: #374151; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.good { background: #dcfce7; color: #166534; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #dcfce7; }
.dot.busy { background: var(--warn); box-shadow: 0 0 0 3px #fef3c7; animation: pulse 1.2s infinite; }
.dot.off { background: #9ca3af; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* forms */
input[type=text], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  font: inherit; padding: 6px 9px; border: 1px solid #cfd6df; border-radius: 7px; background: #fff; color: var(--text); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.f > * { font-size: 13px; color: var(--text); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label.f { min-width: 120px; }
.filters .chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); padding-bottom: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 7px;
  border: 1px solid #cfd6df; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f3f5f8; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.lg { padding: 10px 18px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kbd { font-family: var(--mono); font-size: 11px; background: #eef1f5; border: 1px solid #d3d9e1; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: #4b5563; }

/* pager */
.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 12px; flex-wrap: wrap; }

/* logs */
.logbox { background: #0f172a; color: #e2e8f0; font-family: var(--mono); font-size: 12px; padding: 12px; border-radius: 8px; max-height: 480px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.logbox.tall { max-height: 70vh; }

/* misc */
.plate { font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: .04em; }
.plate.big { font-size: 28px; }
.plate.guess { font-weight: 600; opacity: .55; text-decoration: underline dotted; }  /* неустоявшаяся догадка ушедшего трека */
.mismatch { color: var(--bad); }
.match { color: var(--ok); }
.bar { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.probs { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 8px; align-items: center; font-size: 12px; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 320px; }
.toast { position: fixed; right: 18px; bottom: 18px; background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 99; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
.toast.warn { background: var(--warn); }
.samples-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.sample-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.sample-card img { width: 100%; max-height: 110px; object-fit: contain; background: #f8fafc; border-radius: 6px; border: 1px solid var(--line); }
.sample-card .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.sample-card .edit { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.sample-card .edit input[type=text] { width: 110px; text-transform: uppercase; font-family: var(--mono); }
.sample-card .edit select { max-width: 120px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: #eef2f7; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.chip b { color: var(--text); }
.review-crop { width: 100%; max-height: 260px; object-fit: contain; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; image-rendering: auto; }
.review-photo { width: 100%; max-height: 520px; object-fit: contain; background: #0f172a; border-radius: 8px; }
.svg-diagram { width: 100%; height: auto; }
.svg-diagram text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.file-map td:first-child { font-family: var(--mono); white-space: nowrap; }
.login-box { max-width: 380px; margin: 12vh auto; }
.login-box .card { padding: 26px; }
.login-box input { width: 100%; margin: 8px 0 14px; }
.warn-box { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 10px 12px; border-radius: 8px; }
.ok-box { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 10px 12px; border-radius: 8px; }
.err-box { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 12px; border-radius: 8px; }
details summary { cursor: pointer; font-weight: 600; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.field-inline { display: inline-flex; gap: 6px; align-items: center; }
select[multiple] { min-height: 90px; }

/* ---------- live-камера / сессии зрения ---------- */
.live-disclaimer { background: #fef2f2; border: 2px solid var(--bad); color: var(--bad); font-weight: 700; font-size: 15px; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; line-height: 1.35; }
.live-disclaimer.small { font-size: 12px; padding: 6px 10px; border-width: 1px; font-weight: 600; }
.live-stage { position: relative; width: 100%; background: #0f172a; border-radius: 10px; overflow: hidden; min-height: 200px; max-height: 72vh; aspect-ratio: 4 / 3; margin-bottom: 10px; }
.live-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0f172a; display: block; }
.live-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.live-stage canvas.hit { pointer-events: auto; cursor: crosshair; }
.live-status { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, .72); color: #e2e8f0; font-family: var(--mono); font-size: 12px; padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-status.err { color: #fca5a5; }
.live-moving { position: absolute; top: 8px; right: 8px; background: rgba(239, 68, 68, .92); color: #fff; font-weight: 700; padding: 4px 10px; border-radius: 999px; text-align: center; font-size: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
/* легенда оверлея (кнопка «🎨 Легенда») */
.live-legend { position: absolute; left: 8px; bottom: 30px; max-width: min(560px, calc(100% - 16px)); background: rgba(15, 23, 42, .82); color: #e2e8f0; border: 1px solid rgba(255,255,255,.15); border-radius: 10px; padding: 8px 10px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; backdrop-filter: blur(4px); }
.live-legend .lg-title { flex-basis: 100%; font-weight: 700; color: #94a3b8; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.live-legend .lg-row { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 12px; border-top: 1px dashed rgba(255,255,255,.15); padding-top: 4px; margin-top: 2px; }
.live-legend .lg-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.live-legend .lg-item i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255,255,255,.4); }
.live-legend .lg-item i.dash { width: 18px; height: 0; border: 0; border-top: 2px dashed #e2e8f0; border-radius: 0; }
/* калибровка плоскости дороги — панель ПОД кадром (не поверх холста: клики по
   углам кадра должны попадать в холст, а не в панель) */
.live-calib { background: #ecfdf5; color: var(--text); border: 1px solid #a7f3d0; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.live-calib.hidden { display: none; }
.live-calib .lc-title { font-weight: 700; font-size: 14px; }
.live-calib .lc-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.live-calib .lc-row label.f { flex: 1 1 120px; }
.live-calib .lc-row input { width: 100%; }
.live-calib .btn-row .btn { flex: 1 1 auto; justify-content: center; }
.chip.calib { background: #ecfdf5; color: #065f46; }
.ok-text { color: var(--ok); font-weight: 600; }
.live-hint { position: absolute; top: 50%; left: 8%; right: 8%; transform: translateY(-50%); color: #cbd5e1; text-align: center; font-size: 13px; }
.live-stage.on .live-hint { display: none; }
.live-controls { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.live-controls .btn-row .btn { flex: 1 1 auto; justify-content: center; }
.live-opts { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.live-opts label.f { min-width: 100px; }
.live-opts .chk { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; }
.live-counts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.live-summary { background: #f0fdf4; border-color: #bbf7d0; }
.live-tracks { display: flex; flex-direction: column; gap: 8px; }
.track-card { display: flex; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; align-items: flex-start; }
.track-card { border-left: 4px solid var(--cls, var(--line)); }
.track-card.live { border-color: #86efac; border-left-color: var(--cls, #86efac); box-shadow: 0 0 0 2px #dcfce7; }
.track-card.gone { opacity: .95; }
.track-card.done-ok { border-left: 4px solid var(--ok); }
.track-card.done-bad { border-left: 4px solid var(--bad); }
.track-card.done-fixed { border-left: 4px solid var(--warn); }
.tc-thumb { flex: 0 0 104px; display: flex; flex-direction: column; gap: 4px; }
.tc-thumb img, .tc-thumb canvas { width: 104px; height: 78px; object-fit: contain; background: #f1f5f9; border-radius: 6px; border: 1px solid var(--line); display: block; }
.tc-thumb img.tc-platecrop { height: 30px; }
.tc-nothumb { width: 104px; height: 78px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; background: #f1f5f9; border-radius: 6px; border: 1px dashed var(--line); }
.tc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tc-title { font-weight: 650; }
.tc-plate .plate { font-size: 17px; }
.tc-meta { font-size: 12px; color: var(--muted); }
.tc-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.tc-actions .btn { flex: 1 1 auto; justify-content: center; min-width: 90px; }
.tc-actions .tc-verdict { flex: 0 0 auto; }
.fix-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; padding: 8px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; }
.fix-form input[type=text] { width: 130px; text-transform: uppercase; font-family: var(--mono); font-size: 16px; }
.fix-form select { max-width: 150px; font-size: 14px; }
.live-video-file { width: 100%; max-height: 70vh; background: #000; border-radius: 8px; }
@media (max-width: 900px) {
  .live-stage { border-radius: 6px; margin-left: -6px; margin-right: -6px; width: calc(100% + 12px); }
  .tc-actions .btn { font-size: 13px; padding: 7px 8px; }
  .live-opts label.f { min-width: 0; flex: 1 1 40%; }
  .live-legend { bottom: 30px; font-size: 11px; }
  .live-controls .btn-row .btn.sm { flex: 0 1 auto; }
}

/* ---------- атрибуты машины (цвет / марка / модель) ---------- */
.veh-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); vertical-align: -2px; margin-right: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.6); }
.veh-attrs { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.veh-attrs .veh-top { flex-basis: 100%; }
.veh-attrs.compact { gap: 4px; }
.veh-text { font-weight: 600; }
.veh-block { border-top: 1px dashed var(--line); padding-top: 10px; }
.veh-crop { width: 100%; max-height: 150px; object-fit: contain; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
.veh-nocrop { width: 100%; height: 90px; display: flex; align-items: center; justify-content: center; background: #f8fafc; border: 1px dashed var(--line); border-radius: 8px; text-align: center; }
.veh-form { margin-top: 8px; padding: 8px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
.veh-form label.f { min-width: 0; }
.tc-vehicle { font-size: 13px; }
.veh-fix { background: #f0f9ff; border-color: #bae6fd; }
.veh-fix select { max-width: 170px; }
.veh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.veh-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.veh-card img { width: 100%; height: 150px; object-fit: contain; background: #f8fafc; border-radius: 6px; border: 1px solid var(--line); }
.veh-card.verified { border-left: 4px solid var(--ok); }
.veh-card .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.veh-card .veh-form { margin-top: 0; padding: 6px; }
.veh-card .veh-form input[type=text] { width: 105px !important; }
.veh-card .veh-form select { max-width: 130px; }
.veh-heads td, .veh-heads th { padding: 5px 8px; }
.color-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.color-chips .chip { display: inline-flex; align-items: center; gap: 4px; }
.badge.user { background: #dbeafe; color: #1e40af; }
.badge.myauto { background: #ecfccb; color: #3f6212; }
.badge.pred { background: #fef3c7; color: #92400e; }  /* предсказание модели, не проверено */
/* заглушки live-карточек: номер/марка ещё определяются («читаю номер…», «определяю авто…») */
.spin { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #cbd5e1; border-top-color: #475569; vertical-align: -1px; animation: spin .8s linear infinite; }
.searching { color: var(--muted); font-style: italic; }
@keyframes spin { to { transform: rotate(360deg); } }
