:root {
  --bg: #0a0e0c;
  --bg-elevated: #101614;
  --panel: #141a17;
  --panel-2: #1a221e;
  --panel-hover: #1f2823;
  --line: #2a3530;
  --line-soft: #222b27;
  --text: #eef2ef;
  --muted: #8a9a92;
  --accent: #e8a838;
  --accent-dim: #b88428;
  --accent-glow: rgba(232, 168, 56, 0.15);
  --ok: #3dba7a;
  --warn: #d4a017;
  --danger: #e07070;
  --sidebar-w: 220px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── App shell ─────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1rem;
}
.brand-mark {
  display: block;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.16em;
  font-size: 0.88rem;
  color: var(--accent);
}
.brand-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
  letter-spacing: 0.04em;
}

.sidebar-nav { flex: 1; padding: 0 0.75rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.25rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.nav-item:hover {
  background: var(--panel);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(232, 168, 56, 0.25);
}
.nav-icon {
  font-size: 0.85rem;
  opacity: 0.85;
  width: 1.1rem;
  text-align: center;
}
.nav-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.65rem;
  min-width: 1.2rem;
  text-align: center;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: rgba(224, 112, 112, 0.2);
  color: var(--danger);
  border: 1px solid rgba(224, 112, 112, 0.4);
}

/* Compliance */
.brand-viewer-tag {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(232, 168, 56, 0.45);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  width: fit-content;
}
body.viewer-mode .admin-only,
body.viewer-mode .mpo-upload-card {
  display: none !important;
}
.mpo-hero-viewer {
  grid-template-columns: 1fr;
}
body.viewer-mode .sidebar-copy {
  color: var(--muted);
}

.alarm-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.alarm-status-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}
.alarm-status-btn.has-alarms {
  color: #f0c0c0;
  border-color: rgba(224, 112, 112, 0.55);
  background: rgba(224, 112, 112, 0.12);
}
.alarm-status-btn.has-alarms:hover {
  border-color: rgba(224, 112, 112, 0.85);
  color: #fff;
}
.alarm-status-count {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0;
  text-transform: none;
  min-width: 1.25rem;
  text-align: center;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}
.alarm-status-btn.has-alarms .alarm-status-count {
  background: rgba(224, 112, 112, 0.35);
  color: #fff;
}
.alarms-slide-panel {
  width: min(480px, 96vw);
}
.alarms-slide-body {
  flex: 1;
  overflow: auto;
  padding: 0.35rem 1rem 1.25rem;
}
.alarm-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line-soft);
  font-size: 0.85rem;
}
.alarm-item.critical { border-left: 3px solid var(--danger); padding-left: 0.65rem; }
.alarm-strip {
  display: none;
}
.alarm-strip-head {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--danger);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.compliance-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.mpo-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  padding: 1.35rem 1.4rem;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(232, 168, 56, 0.12), transparent 55%),
    linear-gradient(165deg, #1a1f2a 0%, #12151c 55%, #0e1117 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.mpo-hero-eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.mpo-hero-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}
.mpo-hero-lead {
  margin: 0;
  max-width: 36rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
}
.mpo-upload-card {
  background: rgba(8, 10, 14, 0.45);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 1rem;
}
.mpo-drop-lg {
  min-height: 7.5rem;
  justify-content: center;
  text-align: center;
  align-items: center;
}
.mpo-drop-hint {
  font-size: 0.75rem;
  color: var(--muted);
}
.mpo-library-panel {
  margin-bottom: 1rem;
}
.report-section-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.report-head-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.report-letterhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.85rem 0 1rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.report-letterhead-main {
  min-width: 0;
  flex: 1;
}
.report-logo-box {
  width: 140px;
  height: 72px;
  flex: 0 0 140px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.report-logo-box img,
img.report-logo {
  width: 140px !important;
  height: 72px !important;
  max-width: 140px !important;
  max-height: 72px !important;
  object-fit: contain !important;
  display: block;
  margin: 0;
  padding: 6px;
  box-sizing: border-box;
  background: transparent;
  border: none;
  border-radius: 0;
}
.report-logo-box.missing {
  background: var(--panel-2);
}
.report-station-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.report-station-addr {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
.report-letterhead-meta {
  margin-top: 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.report-doc-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.finance-stats .search-stat-val {
  font-size: 1.05rem;
}
.compliance-workspace {
  display: block;
}
.compliance-reports-panel {
  display: flex;
  flex-direction: column;
  min-height: 12rem;
}
.compliance-reports-panel .mpo-list {
  flex: 1;
  overflow: auto;
  padding: 0;
}
.mpo-list .search-table-wrap {
  margin: 0;
  border: none;
  border-radius: 0;
}
.compliance-row {
  cursor: pointer;
}
.compliance-row.active td {
  background: rgba(232, 168, 56, 0.08);
}
.compliance-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}
.compliance-row-actions .ghost,
.compliance-row-actions a.ghost {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
}
.compliance-slide {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  visibility: hidden;
}
.compliance-slide.open {
  pointer-events: auto;
  visibility: visible;
}
body.compliance-slide-open {
  overflow: hidden;
}
.compliance-slide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.compliance-slide.open .compliance-slide-backdrop {
  opacity: 1;
}
.compliance-slide-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(920px, 96vw);
  margin: 0;
  border-radius: 0;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  background: var(--panel);
}
.compliance-slide.open .compliance-slide-panel {
  transform: translateX(0);
}
.compliance-report {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: none;
  box-shadow: none;
  background: transparent;
}
.compliance-report .panel-head {
  flex: 0 0 auto;
}
.compliance-report .report-empty {
  padding: 2rem 1.25rem;
}
.compliance-report .report-body {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.15rem 1.5rem;
}
@media print {
  body * { visibility: hidden; }
  #compliance-slide,
  #compliance-slide .compliance-slide-panel,
  #compliance-report,
  #compliance-report * { visibility: visible; }
  #compliance-slide {
    position: static !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  .compliance-slide-backdrop { display: none !important; }
  .compliance-slide-panel {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
  }
  #compliance-report {
    position: absolute;
    left: 0; top: 0; width: 100%;
    background: #fff; color: #111;
    overflow: visible;
  }
  .sidebar, .nav-item, .ghost, .badge, .panel-head .ghost,
  .compliance-reports-panel, .mpo-hero, .alarm-strip, .alarm-status-btn,
  #btn-close-compliance-slide, #alarms-slide { display: none !important; }
  .report-logo-box { border-color: #ccc; width: 140px; height: 72px; }
  .report-logo-box img { width: 140px !important; height: 72px !important; }
}
@media (max-width: 1100px) {
  .compliance-slide-panel { width: min(100vw, 100%); }
}
@media (max-width: 900px) {
  .mpo-hero { grid-template-columns: 1fr; }
  .report-letterhead { flex-direction: row; }
}
.mpo-form {
  padding: 1rem 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.mpo-upload-lead { margin: 0 0 0.35rem; line-height: 1.45; }
.mpo-drop {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 1.25rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}
.mpo-drop input[type="file"] {
  font: inherit;
  color: var(--text);
  width: 100%;
}
.mpo-drop-label {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}
.mpo-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.mpo-form input,
.mpo-form textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}
.mpo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.mpo-list {
  padding: 0;
  max-height: none;
  overflow: auto;
}
.mpo-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.5rem;
}
.mpo-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}
.mpo-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.mpo-card-actions .ghost,
.mpo-card-actions a.ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.compliance-report .report-body {
  padding: 1rem 1.15rem 1.25rem;
}

@media (max-width: 1100px) {
  .compliance-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
}

.sidebar-foot {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--line-soft);
}
.sidebar-copy {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.5rem;
  letter-spacing: 0.04em;
}
.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}
.health-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.health-pill.ok { color: var(--ok); border-color: rgba(61, 186, 122, 0.35); }
.health-pill.ok::before { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.health-pill.bad { color: var(--danger); border-color: rgba(224, 112, 112, 0.35); }
.health-pill.bad::before { background: var(--danger); }

.main {
  min-width: 0;
  padding: 1.5rem 1.75rem 2.5rem;
  background:
    radial-gradient(900px 500px at 100% -20%, rgba(232, 168, 56, 0.06) 0%, transparent 55%),
    radial-gradient(600px 400px at 0% 100%, rgba(61, 186, 122, 0.04) 0%, transparent 50%),
    var(--bg);
}
.main-settings { max-width: 56rem; }

.view.hidden { display: none !important; }

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}
.page-title-block { flex: 1; min-width: 200px; }
.page-title-block h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  max-width: 28rem;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
  box-shadow: var(--shadow);
}
.search-icon {
  color: var(--muted);
  font-size: 1rem;
}
.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0;
  min-width: 0;
}
.search-bar input:focus { outline: none; }
.search-bar button, .btn {
  font: inherit;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid var(--accent-dim);
  background: var(--accent);
  color: #1a1205;
  font-weight: 600;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  white-space: nowrap;
}
.search-bar-lg {
  max-width: none;
  width: 100%;
  padding: 0.45rem 0.45rem 0.45rem 1rem;
}
.search-bar-lg input {
  font-size: 1rem;
  padding: 0.55rem 0;
}
.search-bar-lg button {
  padding: 0.65rem 1.25rem;
}
.ghost {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }
.btn.secondary {
  background: transparent;
  color: var(--accent);
}

.clock {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: nowrap;
  margin-left: auto;
}

.dash-top {
  display: grid;
  grid-template-columns: 3fr 3fr 4fr;
  /* ≈ 30% | 30% | 40% preview */
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}
.kpi-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.kpi-stack .kpi-card,
.kpi-stack .ops-card {
  /* Grow to fill stack, but never shrink below content (avoids clipped footers). */
  flex: 1 0 auto;
}
.ops-card-compact {
  max-width: 100%;
}
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem 0.75rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: none;
  justify-self: stretch;
}
.preview-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}
.live-preview {
  position: relative;
  width: 100%;
  background: #05070b;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
  flex: 1;
}
.live-preview-main {
  aspect-ratio: 16 / 9;
  max-height: none;
  min-height: 180px;
}
.live-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}
.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
  background: rgba(8, 10, 14, 0.78);
  pointer-events: none;
}
.preview-overlay.hidden {
  display: none;
}
.preview-badge {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  background: rgba(220, 60, 60, 0.92);
  color: #fff;
  font-weight: 600;
}
.preview-badge.off {
  background: rgba(80, 90, 110, 0.85);
}
.preview-caption {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
@media (max-width: 980px) {
  .dash-top {
    grid-template-columns: 1fr 1fr;
  }
  .preview-panel {
    grid-column: 1 / -1;
    max-width: none;
    justify-self: stretch;
  }
  .live-preview-main {
    max-height: 260px;
  }
}
@media (max-width: 640px) {
  .dash-top {
    grid-template-columns: 1fr;
  }
}

/* ── Search hero (full-width, top of dashboard) ────────────── */
.search-hero {
  margin-bottom: 1.25rem;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-hero-inner {
  background: linear-gradient(135deg, var(--panel) 0%, rgba(232, 168, 56, 0.07) 100%);
  border: 1px solid rgba(232, 168, 56, 0.28);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1.1rem;
  box-shadow: var(--shadow);
}
.search-loading {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.search-hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-soft);
}
.search-hero-eyebrow {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.search-hero-brand {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-transform: capitalize;
}
.search-hero-summary {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.search-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.search-stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  text-align: center;
}
.search-stat.primary {
  border-color: rgba(232, 168, 56, 0.4);
  background: rgba(232, 168, 56, 0.08);
}
.search-stat-val {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
}
.search-stat.primary .search-stat-val { color: var(--accent); }
.search-stat-lbl {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.2rem;
}
.search-body {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: 1rem;
  align-items: start;
}
.search-schedule { min-height: 200px; }
.search-table-wrap {
  max-height: 360px;
  overflow: auto;
}
.search-table .cell-time {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}
.search-table tbody tr.search-row { cursor: pointer; }
.search-table tbody tr.search-row:hover td {
  background: var(--accent-glow);
}
.search-side {
  display: flex;
  flex-direction: column;
}
.search-video-list {
  padding: 0.5rem;
  flex: 1;
  overflow: auto;
  max-height: 320px;
}
.search-video-card {
  padding: 0.65rem 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  margin-bottom: 0.45rem;
}
.search-video-name {
  font-size: 0.82rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-video-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.3rem;
}
.search-side-foot {
  padding: 0.55rem 0.85rem;
  border-top: 1px solid var(--line-soft);
}
.search-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}
.search-raw {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-soft);
}
.search-raw .raw-matches {
  margin-top: 0.65rem;
  max-height: 240px;
  overflow: auto;
  display: grid;
  gap: 0.4rem;
}

#dashboard-body.search-active .kpi-row {
  opacity: 0.55;
  transform: scale(0.98);
  transition: opacity 0.2s;
}
#dashboard-body.search-active .live-ops {
  opacity: 0.7;
}

/* ── Dashboard quick actions ───────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 0.5rem;
}
.quick-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
  padding: 1.1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  box-shadow: var(--shadow);
}
.quick-card:hover {
  border-color: rgba(232, 168, 56, 0.35);
  background: var(--panel-hover);
}
.quick-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}
.quick-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ── Aired commercials tab ─────────────────────────────────── */
.commercials-toolbar {
  margin-bottom: 1.25rem;
}
.commercials-empty {
  text-align: center;
  padding: 3.5rem 2rem;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  max-width: 36rem;
  margin: 2rem auto;
}
.commercials-empty h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}
.commercials-empty p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.empty-icon {
  font-size: 2rem;
  color: var(--accent);
  opacity: 0.45;
  margin-bottom: 0.75rem;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.chip {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.chip:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* ── Analysis runs tab ─────────────────────────────────────── */
.runs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.runs-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.runs-table-wrap {
  max-height: min(42vh, 360px);
  min-height: 180px;
}
.runs-detail {
  overflow: auto;
  min-height: 280px;
}
.runs-detail .detail,
.runs-detail .welcome-card {
  padding: 1.25rem 1.35rem 2rem;
}

/* ── Pagination ────────────────────────────────────────────── */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--line-soft);
  background: var(--panel-2);
  font-size: 0.78rem;
  color: var(--muted);
}
.pager.hidden { display: none !important; }
.pager-info { font-family: var(--mono); font-size: 0.72rem; }
.pager-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
}
.pager-size select {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
}
.pager-page {
  font-family: var(--mono);
  font-size: 0.72rem;
  min-width: 5.5rem;
  text-align: center;
}
.pager .ghost:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
#run-airings-pager,
#windows-pager,
#airings-pager,
#videos-pager,
#matches-pager {
  border-radius: 0 0 8px 8px;
  margin-bottom: 0.75rem;
}
#matches-pager { margin-top: 0.5rem; }

/* ── KPI row ───────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.kpi-card.accent {
  border-color: rgba(232, 168, 56, 0.35);
  background: linear-gradient(135deg, var(--panel) 0%, rgba(232, 168, 56, 0.06) 100%);
}
.kpi-label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.kpi-value {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 500;
  margin-top: 0.35rem;
  line-height: 1.1;
}
.kpi-card.accent .kpi-value { color: var(--accent); }
.kpi-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ── Live operations ───────────────────────────────────────── */
.live-ops { margin-bottom: 1.5rem; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-head h2 {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.live-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.live-grid-archive {
  max-width: 36rem;
}
@media (min-width: 1100px) {
  .live-grid:not(.live-grid-archive) {
    grid-template-columns: repeat(4, 1fr);
  }
}
.ops-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 132px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: visible;
  box-shadow: var(--shadow);
  box-sizing: border-box;
}
.ops-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  min-width: 0;
  flex-shrink: 0;
}
.ops-title {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.ops-body {
  font-size: 0.92rem;
  font-weight: 500;
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ops-body.mono { font-family: var(--mono); font-size: 0.82rem; font-weight: 400; }
.ops-bitrate {
  margin-top: 0.45rem;
  margin-bottom: 0.15rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--accent, #5ec8a0);
  letter-spacing: 0.02em;
  min-width: 0;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ops-foot {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line-soft);
  line-height: 1.45;
  min-width: 0;
  flex-shrink: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ops-card:first-child {
  grid-column: 1 / -1;
}
@media (min-width: 900px) {
  .ops-card:first-child {
    grid-column: auto;
  }
}

.status-chip {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.status-chip.running { color: var(--ok); border-color: rgba(61, 186, 122, 0.4); background: rgba(61, 186, 122, 0.08); }
.status-chip.recording { color: #ff8a8a; border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.08); }
.status-chip.analyzing { color: var(--accent); border-color: rgba(232, 168, 56, 0.4); background: var(--accent-glow); }
.status-chip.connecting { color: var(--warn); border-color: rgba(212, 160, 23, 0.4); background: rgba(212, 160, 23, 0.08); }
.status-chip.source_down, .status-chip.error, .status-chip.stopped { color: var(--danger); border-color: rgba(224, 112, 112, 0.4); background: rgba(224, 112, 112, 0.08); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.status-dot.live { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.status-dot.off { background: var(--danger); }

/* ── Content grid ──────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 1rem;
  min-height: 420px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel-2);
}
.panel-head h2 {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.panel-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(232, 168, 56, 0.25);
}

.table-wrap {
  flex: 1;
  overflow: auto;
  max-height: calc(100vh - 420px);
  min-height: 280px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.data-table th {
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}
.data-table tbody tr:hover td { background: var(--panel-hover); }
.data-table tbody tr.active td {
  background: var(--accent-glow);
  border-bottom-color: rgba(232, 168, 56, 0.15);
}
.data-table tbody tr.active td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}
.data-table .cell-file {
  font-weight: 500;
  font-size: 0.85rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table .cell-mono {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.table-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem !important;
  cursor: default !important;
}

.detail-panel {
  padding: 0;
  overflow: auto;
}
.detail-panel .detail,
.detail-panel .search-results {
  padding: 1.25rem 1.35rem 2rem;
}

.welcome-card {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--muted);
}
.welcome-icon {
  font-size: 2rem;
  color: var(--accent);
  opacity: 0.5;
  margin-bottom: 0.75rem;
}
.welcome-card h2 {
  margin: 0 0 0.5rem;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 600;
}
.welcome-card p { margin: 0.35rem 0; font-size: 0.9rem; max-width: 28rem; margin-left: auto; margin-right: auto; }
.welcome-hint { font-size: 0.8rem !important; opacity: 0.8; }

.hidden { display: none !important; }

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.62rem;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.pending { background: rgba(212, 160, 23, 0.15); color: var(--warn); border: 1px solid rgba(212, 160, 23, 0.3); }
.badge.synced { background: rgba(61, 186, 122, 0.12); color: var(--ok); border: 1px solid rgba(61, 186, 122, 0.3); }

.detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.detail-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}
.detail-meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.window {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.window-head {
  padding: 0.85rem 1rem;
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.window-head strong { font-size: 0.92rem; }
.window-head .t {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
}
.window-body {
  padding: 0.85rem 1rem 1.1rem;
  border-top: 1px solid var(--line-soft);
  display: none;
}
.window.open .window-body { display: block; }

.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

.block-title {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 1rem 0 0.5rem;
}
.timeline {
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.45;
  max-height: 220px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
}
.timeline .row { margin-bottom: 0.35rem; }
.timeline .when { color: var(--accent-dim); margin-right: 0.5rem; }
.speech { white-space: pre-wrap; }

.hit {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 0.12s;
}
.hit:hover { border-color: var(--accent-dim); }
.hit .src {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1.25rem;
}
.dash-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}
.dash-card.accent {
  border-color: rgba(232, 168, 56, 0.35);
  box-shadow: inset 3px 0 0 var(--accent);
}
.dash-label {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.dash-value {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 500;
  margin-top: 0.25rem;
}
.dash-card.accent .dash-value { color: var(--accent); }
.dash-sub { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }

.dash-by-video { margin-bottom: 1rem; }
.dash-video-row {
  padding: 0.65rem 0.85rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.4rem;
}
.run-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.dash-table-wrap {
  overflow: auto;
  max-height: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  margin-bottom: 1rem;
}
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.dash-table th {
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
}
.dash-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}
.dash-table tr:hover td { background: var(--accent-glow); }
.dash-table .mono { font-family: var(--mono); font-size: 0.8rem; color: var(--accent); }

.raw-toggle-row { margin: 0.5rem 0 0.75rem; }
.raw-matches { margin-top: 0.5rem; }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; }

/* ── Settings ──────────────────────────────────────────────── */
.settings-page { padding: 0; }
.settings-lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}
.settings-form { display: flex; flex-direction: column; gap: 1rem; }
.settings-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}
.settings-block h2 {
  margin: 0 0 0.9rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.settings-fields,
.settings-block label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.settings-block label:last-child { margin-bottom: 0; }
.settings-block input[type="url"],
.settings-block input[type="text"],
.settings-block input[type="email"],
.settings-block textarea,
.settings-block select,
.settings-block input[type="file"] {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}
.settings-block textarea {
  resize: vertical;
  min-height: 4.5rem;
  line-height: 1.4;
}
.logo-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.25rem;
}
.logo-preview-wrap img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.logo-preview-wrap img.missing { opacity: 0.35; min-height: 140px; }
.btn-upload-logo {
  align-self: flex-end;
  width: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.settings-fields .btn-upload-logo {
  display: inline-flex;
}
.source-fieldset {
  border: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.radio-line {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  color: var(--text) !important;
  font-size: 0.9rem !important;
  cursor: pointer;
}
.radio-line input { accent-color: var(--accent); }
.settings-inline {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}
.settings-inline .grow { flex: 1; margin-bottom: 0 !important; }
.settings-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.5rem;
}
.settings-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.75rem;
}
.settings-controls-block {
  margin-top: 1.25rem;
}
.btn.btn-control {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  cursor: pointer;
  opacity: 1;
}
.btn.btn-control:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.btn.btn-control.danger {
  color: #ff8a8a;
  border-color: rgba(224, 112, 112, 0.55);
}
.btn.btn-control.danger:hover:not(:disabled) {
  background: rgba(224, 112, 112, 0.12);
  color: #ffb0b0;
}
.btn.btn-control:disabled {
  opacity: 0.55;
  cursor: wait;
}
/* Native <dialog> — browser centers it in the viewport top layer */
dialog.app-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(26rem, calc(100vw - 2.5rem));
  max-width: calc(100vw - 2.5rem);
  border: none;
  padding: 0;
  background: transparent;
  color: var(--text);
  z-index: 99999;
}
dialog.app-dialog:not([open]) {
  display: none !important;
}
dialog.app-dialog[open] {
  display: block;
}
dialog.app-dialog::backdrop {
  background: rgba(4, 6, 10, 0.78);
  backdrop-filter: blur(3px);
}
.app-dialog-card {
  width: 100%;
  background: linear-gradient(165deg, #1c222d 0%, #12161e 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  padding: 1.25rem 1.35rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  animation: app-dialog-in 0.16s ease-out;
}
@keyframes app-dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.app-dialog-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.app-dialog-icon {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  border: 1px solid transparent;
}
.app-dialog.tone-warn .app-dialog-icon {
  color: var(--warn);
  background: rgba(212, 160, 23, 0.12);
  border-color: rgba(212, 160, 23, 0.35);
}
.app-dialog.tone-danger .app-dialog-icon,
.app-dialog.tone-error .app-dialog-icon {
  color: #ff8a8a;
  background: rgba(224, 112, 112, 0.12);
  border-color: rgba(224, 112, 112, 0.4);
}
.app-dialog.tone-ok .app-dialog-icon {
  color: var(--ok);
  background: rgba(61, 186, 122, 0.12);
  border-color: rgba(61, 186, 122, 0.4);
}
.app-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.app-dialog-body {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
}
.app-dialog-actions {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.25rem;
}
.btn.btn-dialog-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn.btn-dialog-cancel:hover {
  color: var(--text);
  border-color: var(--muted);
}
.btn.btn-dialog-confirm {
  min-width: 7rem;
}
.app-dialog.tone-danger .btn-dialog-confirm,
.app-dialog.tone-error .btn-dialog-confirm {
  background: rgba(224, 112, 112, 0.9);
  border-color: rgba(224, 112, 112, 0.9);
  color: #1a0c0c;
}
.app-dialog.tone-ok .btn-dialog-confirm {
  background: rgba(61, 186, 122, 0.9);
  border-color: rgba(61, 186, 122, 0.9);
  color: #0a1a12;
}
.app-dialog.mode-status .btn-dialog-cancel,
.app-dialog.mode-status #app-dialog-cancel {
  display: none !important;
}
.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(224, 112, 112, 0.55);
}
.btn.danger:hover {
  background: rgba(224, 112, 112, 0.12);
}
.hint { font-size: 0.78rem; color: var(--muted); margin: 0.35rem 0 0; }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .live-grid { grid-template-columns: 1fr; }
  .search-stats { grid-template-columns: repeat(3, 1fr); }
  .search-body { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .sidebar-brand { padding: 0; border: none; margin: 0; }
  .sidebar-nav { display: flex; flex: 1; padding: 0; gap: 0.25rem; }
  .sidebar-foot { border: none; padding: 0; display: flex; align-items: center; gap: 0.5rem; }
  .sidebar-copy { display: none; }
  .content-grid { grid-template-columns: 1fr; }
  .table-wrap { max-height: 240px; }
  .page-header { flex-direction: column; }
  .search-bar { max-width: none; width: 100%; }
  .search-stats { grid-template-columns: repeat(2, 1fr); }
  .search-hero-brand { font-size: 1.45rem; }
  .logo-row { grid-template-columns: 1fr; }
}
