/* Awareon-GW web panel. Design tokens reused from the legacy frontend; system fonts only
   (the CSP allows no external font). */
:root {
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f1f3f6; --border: #e6e8ee;
  --text: #191c22; --text-2: #5a616e; --text-3: #9299a6;
  --accent: #4c66e0; --accent-2: #6b83f0; --accent-soft: rgba(76, 102, 224, .10);
  --ok: #1a9d5f; --ok-soft: rgba(26, 157, 95, .12);
  --alert: #e14b4f; --alert-soft: rgba(225, 75, 79, .12);
  --warn: #c98a06; --warn-soft: rgba(201, 138, 6, .14);
  --shadow: 0 1px 2px rgba(20, 24, 33, .04), 0 6px 18px rgba(20, 24, 33, .05);
}
[data-theme="dark"] {
  --bg: #0d1015; --surface: #161a21; --surface-2: #1d222b; --border: #282e39;
  --text: #e7eaf0; --text-2: #98a0af; --text-3: #666e7c;
  --accent: #6b83f0; --accent-2: #8fa2f7; --accent-soft: rgba(107, 131, 240, .16);
  --ok: #2bb673; --ok-soft: rgba(43, 182, 115, .16);
  --alert: #f0595d; --alert-soft: rgba(240, 89, 93, .16);
  --warn: #eab308; --warn-soft: rgba(234, 179, 8, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}
a { color: var(--accent); text-decoration: none; }
input, button, select { font-family: inherit; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid var(--surface); }
::-webkit-scrollbar-track { background: transparent; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(22px) scale(.98); } to { opacity: 1; transform: none; } }

/* -- layout ------------------------------------------------------------- */
[hidden] { display: none !important; }
.app { min-height: 100vh; }
.shell { display: flex; height: 100vh; width: 100%; overflow: hidden; }
.sidebar {
  width: 252px; flex-shrink: 0; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; height: 100%;
}
.brand { padding: 18px 18px 14px; display: flex; align-items: center; gap: 11px; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-icon span { width: 13px; height: 13px; border: 2px solid #fff; border-radius: 3px; }
.brand-name { font-size: 14.5px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--text-3); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 18px; }
.nav-section {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; color: var(--text-3);
  padding: 12px 8px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 9px 11px; border: none; background: transparent; color: var(--text-2);
  font-size: 13.5px; border-radius: 9px; cursor: pointer; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-dot { width: 7px; height: 7px; border-radius: 2px; border: 1.5px solid var(--text-3); flex-shrink: 0; }
.nav-item.active .nav-dot { border-color: var(--accent); background: var(--accent); }

.user { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-2);
}

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }
.topbar {
  height: 64px; flex-shrink: 0; border-bottom: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; gap: 14px; padding: 0 26px;
}
.page-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.page-sub { font-size: 12.5px; color: var(--text-2); }
.status-pill {
  display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 20px;
  background: var(--ok-soft); color: var(--ok); font-size: 12px; font-weight: 600;
}
.status-pill.err { background: var(--alert-soft); color: var(--alert); }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }

main { flex: 1; overflow-y: auto; padding: 26px 30px; }
.view { animation: fadeUp .4s ease; }
.hidden { display: none !important; }

/* -- components ---------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow);
}
.card-pad { padding: 16px 18px; }
.card-title { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-side { grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.grid-side-lg { grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }

.stat-label { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.stat-value.sm { font-size: 22px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 12.5px; font-weight: 600; border-radius: 9px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost-accent { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.btn-sm { padding: 6px 12px; font-size: 11.5px; }

.chip {
  padding: 6px 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12px; border-radius: 20px; cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.chip-star { color: var(--warn); font-weight: 700; }
.chip-x { color: var(--alert); font-weight: 700; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-add { display: flex; gap: 8px; margin-top: 10px; }
.chip-hint { font-size: 11px; color: var(--text-3); margin-top: 8px; line-height: 1.5; }
.badge { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-alert { color: var(--alert); background: var(--alert-soft); }
.badge-accent { color: var(--accent); background: var(--accent-soft); }

.input {
  padding: 11px 14px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); border-radius: 10px; font-size: 13px; width: 100%;
}
.search-input {
  flex: 1; padding: 13px 16px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 11px; font-size: 13.5px;
}

.toggle {
  width: 44px; height: 25px; border-radius: 20px; border: none; cursor: pointer;
  position: relative; transition: background .2s; background: var(--border); flex-shrink: 0;
}
.toggle.on { background: var(--ok); }
.toggle .knob {
  position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%;
  background: #fff; transition: left .2s;
}
.toggle.on .knob { left: 22px; }

input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=range].warn { accent-color: var(--warn); }

.table-head, .table-row { display: grid; padding: 11px 20px; align-items: center; }
.table-head {
  font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.table-row { font-size: 12.5px; padding: 13px 20px; border-bottom: 1px solid var(--border); }

.empty { padding: 34px; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* -- video tiles ---------------------------------------------------------- */
.cam-tile {
  background: #0a0d12; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; position: relative; aspect-ratio: 16/10;
}
.cam-tile video, .cam-tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cam-tile video { object-fit: cover; }
.cam-tile .placeholder {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, #12161d, #12161d 12px, #0d1116 12px, #0d1116 24px);
}
.cam-label {
  position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 7px;
  background: rgba(0, 0, 0, .55); padding: 4px 9px; border-radius: 20px; z-index: 3;
}
.cam-label .rec { width: 7px; height: 7px; border-radius: 50%; background: #f0595d; animation: pulse 1.4s infinite; }
.cam-label span { color: #fff; font: 600 10.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.cam-foot {
  position: absolute; bottom: 9px; left: 10px; color: rgba(255, 255, 255, .55);
  font: 500 9.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; z-index: 3;
}
/* toggles de overlay (👁 zonas/linhas · ▣ caixas) por tile e barra do player */
.cam-toggles { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 4; }
.cam-toggle {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  background: rgba(0, 0, 0, .55); color: rgba(255, 255, 255, .5);
  font-size: 14px; line-height: 1; transition: background .15s, color .15s, border-color .15s;
}
.cam-toggle:hover { background: rgba(0, 0, 0, .72); color: #fff; }
.cam-toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.cam-toggle:disabled { opacity: .4; cursor: not-allowed; }

.feed-item { display: flex; gap: 11px; padding: 10px 8px; border-radius: 9px; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.feed-title { font-size: 12.5px; font-weight: 600; }
.feed-sub { font-size: 11px; color: var(--text-3); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.info-banner {
  display: flex; align-items: flex-start; gap: 10px; background: var(--accent-soft);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 15px;
  font-size: 12.5px; color: var(--text-2);
}
.info-banner.warn { background: var(--warn-soft); }
.info-banner .sq { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); flex-shrink: 0; margin-top: 4px; }
.info-banner.warn .sq { background: var(--warn); }

/* -- event cards ------------------------------------------------------------ */
.event-card { overflow: hidden; cursor: pointer; }
.event-thumb {
  position: relative; aspect-ratio: 16/9;
  background: repeating-linear-gradient(135deg, #12161d, #12161d 10px, #0d1116 10px, #0d1116 20px);
}
.event-tag {
  position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .6); color: #fff;
  font: 600 9.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 2px 7px; border-radius: 5px;
}
.conf-bar { flex: 1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.conf-bar > div { height: 100%; background: var(--accent); }

/* -- charts ------------------------------------------------------------------ */
.bars { display: flex; align-items: flex-end; gap: 7px; height: 150px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-col > div { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-col span { font-size: 9px; color: var(--text-3); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* -- geometry editor ---------------------------------------------------------- */
.geo-canvas-wrap {
  position: relative; aspect-ratio: 16/9;
  background: repeating-linear-gradient(135deg, #12161d, #12161d 12px, #0d1116 12px, #0d1116 24px);
}
/* object-fit:fill obrigatório: o SVG usa preserveAspectRatio="none", as coords precisam coincidir. */
.geo-canvas-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; z-index: 0; }
.geo-canvas-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.geo-hint {
  position: absolute; top: 10px; left: 12px; z-index: 2; color: rgba(255, 255, 255, .55);
  font: 500 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#geoBgStatus {
  position: absolute; inset: 0; z-index: 3; align-items: center; justify-content: center;
  background: rgba(13, 16, 21, .55); color: var(--text); pointer-events: none;
  font: 600 12.5px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* -- player -------------------------------------------------------------------- */
.player-video { position: relative; aspect-ratio: 16/9; background: #0a0d12; }
/* vídeo com object-fit:fill (default) → estica p/ o box 16/9 sem letterbox; o canvas de
   overlay cobre exatamente a mesma área, então coords normalizadas 0..1 mapeiam direto. */
.player-video video { width: 100%; height: 100%; }
.player-video canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

/* -- pop-up alerts (cenários / webhook inbound) ---------------------------------- */
#popupStack {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  width: 320px; max-width: calc(100vw - 36px); pointer-events: none;
}
.popup-alert {
  position: relative; pointer-events: auto; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--alert);
  border-radius: 12px; box-shadow: var(--shadow); padding: 14px 34px 14px 15px;
  animation: slideUp .3s cubic-bezier(.2, .8, .2, 1);
}
.popup-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.popup-msg { font-size: 12.5px; color: var(--text-2); line-height: 1.5; word-break: break-word; }
.popup-close {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; line-height: 1;
  border: none; background: transparent; color: var(--text-3); font-size: 13px;
  cursor: pointer; border-radius: 6px;
}
.popup-close:hover { background: var(--surface-2); color: var(--text); }

.kv { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); line-height: 2.1; }
.kv b { color: var(--text); font-weight: 600; }
.slider-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 9px; }
.slider-val { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; color: var(--accent); }

/* modal genérico (overlay + card centrado) */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 11, 16, .55); padding: 20px; animation: fadeIn .18s ease;
}
.modal-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
  animation: slideUp .28s cubic-bezier(.2, .8, .2, 1);
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 14px; font-weight: 700; color: var(--text); }
.modal-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-label { font-size: 11.5px; font-weight: 700; color: var(--text-2); letter-spacing: .02em; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end;
}
.input-err { border-color: var(--alert); }

/* -- confiança por objeto (Limiares) ------------------------------------------- */
.class-conf-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.class-conf-name { flex: 1; font-size: 12.5px; color: var(--text-2); }
.class-conf-input { width: 78px; text-align: right; padding: 7px 9px; }
.class-conf-unit { font-size: 12px; color: var(--text-3); width: 12px; }

/* -- anotador de imagens (Modo Treino) ----------------------------------------- */
.annotator-card { max-width: 1100px; width: 92vw; max-height: 90vh; display: flex; flex-direction: column; }
.annotator-head { display: flex; align-items: center; gap: 12px; }
.annotator-x { position: static; width: 28px; height: 28px; font-size: 15px; }
.annotator-body {
  display: grid; grid-template-columns: 1fr 300px; gap: 16px;
  padding: 16px 20px; overflow: auto; min-height: 0;
}
.annotator-canvas-col { min-width: 0; }
.annotator-canvas-wrap {
  position: relative; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden;
  background: repeating-linear-gradient(135deg, #12161d, #12161d 12px, #0d1116 12px, #0d1116 24px);
}
.annotator-canvas-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; z-index: 0; }
.annotator-canvas-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; cursor: crosshair; }
.annotator-hint {
  position: absolute; top: 10px; left: 12px; z-index: 2; color: rgba(255, 255, 255, .6);
  font: 500 10.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; pointer-events: none;
  background: rgba(13, 16, 21, .5); padding: 3px 7px; border-radius: 6px;
}
.annotator-loading {
  position: absolute; inset: 0; z-index: 4; align-items: center; justify-content: center;
  background: rgba(13, 16, 21, .55); color: var(--text); pointer-events: none;
  font: 600 12.5px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.annotator-classpick {
  position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(340px, 90%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px;
}
.annotator-pick-title { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.annotator-pick-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.annotator-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.annotator-panel {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column; min-height: 0;
}
.annotator-panel-title {
  padding: 10px 14px; font-size: 11.5px; font-weight: 700; color: var(--text-2);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.annotator-list { max-height: 240px; overflow: auto; }
.annotator-list .empty { padding: 16px; font-size: 11.5px; }
.annotator-frame {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 9px 14px; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text-2); font-size: 11.5px; cursor: pointer;
}
.annotator-frame:hover { background: var(--surface-2); }
.annotator-frame.on { background: var(--accent-soft); color: var(--text); }
.annotator-frame-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.annotator-badge {
  flex-shrink: 0; min-width: 20px; text-align: center; font-size: 10.5px; font-weight: 700;
  padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-2);
}
.annotator-frame.on .annotator-badge { background: var(--accent); color: #fff; }
.annotator-ann {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.annotator-ann-cls { flex: 1; font-size: 12px; color: var(--text); font-weight: 600; }

/* -- web panel (specs/005-web-interface) ---------------------------------------- */
.noscript { padding: 24px; font-size: 14px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; padding: 8px 22px 22px; }
.login-card .brand { padding: 14px 0 6px; }
.login-title { font-size: 18px; font-weight: 800; margin: 8px 0 14px; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.login-label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.login-form .btn { justify-content: center; padding: 11px 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.login-message { min-height: 1.4em; margin: 12px 0 0; font-size: 12.5px; color: var(--alert); }

/* -- accounts (specs/007-user-login) ---------------------------------------------- */
.password-row { display: flex; gap: 8px; align-items: stretch; }
.password-row .input { flex: 1; min-width: 0; }
.login-form .password-toggle { padding: 6px 10px; white-space: nowrap; }
.field-error { margin: -4px 0 0; font-size: 12px; color: var(--alert); }
.field-warn { margin: -4px 0 0; font-size: 12px; font-weight: 700; color: var(--warn); }
.input[aria-invalid="true"] { border-color: var(--alert); }
.user-form { max-width: 420px; }
.user-form .select { width: 100%; }

.topbar-title { flex: 1; min-width: 0; }
#main-message { margin: 0 0 16px; }
.view > * + * { margin-top: 16px; }
.card-title { margin: 0; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .04em;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.table td.empty { text-align: center; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar-title { flex: 1; min-width: 120px; margin: 0; font-size: 13px; }
.toolbar-label { font-size: 12px; color: var(--text-2); }
.select { width: auto; max-width: 100%; padding: 7px 10px; }
.pager { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; }
.unavailable-title { margin: 0 0 8px; font-size: 15px; }
.unavailable-tag { margin: 0 0 6px; font-weight: 700; color: var(--warn); font-size: 12.5px; }
.unavailable-reason { margin: 0; color: var(--text-2); font-size: 13px; }

/* APIs view (specs/008-api-explorer): guide and tester, same theme variables */
.api-op { min-width: 0; }
.api-op > * + * { margin-top: 10px; }
.api-op-title { margin: 0; font-size: 15px; }
.api-op-purpose, .api-op-auth { margin: 0; font-size: 13px; color: var(--text-2); }
.api-op-route {
  margin: 0; font-size: 13px; font-weight: 700; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.api-h { margin: 14px 0 6px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.api-list { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-2); }
.api-list li { overflow-wrap: anywhere; }
.api-list li + li { margin-top: 4px; }
.api-note { margin: 0; font-size: 12px; color: var(--text-3); }
.api-op code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); }
/* previews, examples and results: monospace text that wraps inside the card (390 px screens) */
.api-pre {
  margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; font-size: 12px; line-height: 1.5; max-height: 360px; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.api-op-params .table-wrap { border: 1px solid var(--border); border-radius: 10px; }
.api-op-form { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.api-op-form .select { width: 100%; }
.api-field { display: flex; flex-direction: column; gap: 4px; }
.api-op-run { align-self: flex-start; }
.api-op-error { margin: 0; }
.api-op-result p { margin: 4px 0 0; font-size: 12.5px; }
.api-result-status { font-weight: 700; }
.api-result-duration, .api-result-omitted { color: var(--text-3); }
.api-result-notice { color: var(--warn); font-weight: 700; }
.api-result-notice:empty, .api-result-omitted:empty { display: none; }
.api-op-result .api-pre { margin-top: 6px; }
.api-confirm { flex-direction: column; }
.api-confirm p { margin: 0; color: var(--text); font-weight: 700; }
.api-confirm-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.api-outside p { margin: 8px 0 0; font-size: 13px; color: var(--text-2); }

/* mobile menu: the toggle only exists on narrow screens */
.menu-toggle { display: none; }

@media (max-width: 780px) {
  .annotator-body { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; height: auto;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .topbar { height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .topbar-title { flex-basis: 40%; }
  .page-sub { display: none; }
  main { padding: 14px 12px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value.sm { font-size: 18px; }
  .table th, .table td { padding: 10px; }
}

@media (max-width: 420px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .status-pill { order: 10; width: 100%; justify-content: center; }
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-side, .grid-side-lg { grid-template-columns: 1fr; }
}
