/* =========================================================================
   StreamerOS — Watch AR Try-On Admin Console
   Refined dark theme, product-gallery focused.
   Responsive: phone (360px) → laptop (1366px) → desktop → 4K.
   ========================================================================= */

:root {
  --bg:          #0b0d12;
  --bg-elev:     #12151d;
  --bg-elev-2:   #171b25;
  --panel:       #141824;
  --panel-hover: #1a1f2e;
  --border:      #232838;
  --border-soft: #1c2130;
  --text:        #e8ecf4;
  --text-dim:    #9aa4b8;
  --text-faint:  #5f6a80;

  --accent:      #7c5cff;   /* violet */
  --accent-2:    #22d3ee;   /* cyan   */
  --accent-soft: rgba(124, 92, 255, 0.14);

  --ok:      #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn:    #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger:  #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info:    #60a5fa;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 12px 40px rgba(0,0,0,0.45);
  --checker: conic-gradient(#20242f 90deg, #171b25 90deg 180deg, #20242f 180deg 270deg, #171b25 270deg);

  --sidebar-w: 232px;
  --topbar-h: 54px;
  --content-max: 1560px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: radial-gradient(1200px 800px at 80% -10%, #16192400 0%, var(--bg) 60%), var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232838; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2e3550; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.wrap { flex-wrap: wrap; }
.min0 { min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Wide tables scroll inside their own container — the page never scrolls sideways. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > table { min-width: 560px; }

/* Action column pinned to the right edge of a scrollable table, so long URLs can
   never push the buttons out of view. */
.link-table th.act-cell, .link-table td.act-cell {
  position: sticky; right: 0;
  background: var(--bg);
  box-shadow: -10px 0 12px -10px rgba(0, 0, 0, .7);
}

/* =========================================================================
   Login
   ========================================================================= */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  background: rgba(6,8,12,0.72); backdrop-filter: blur(10px);
  padding: 24px;
}
.overlay.active { display: flex; }
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--bg-elev-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 18px; padding: 34px 30px;
  box-shadow: var(--shadow);
  animation: pop .3s ease;
}
.login-card .brand-mark { width: 46px; height: 46px; margin-bottom: 18px; }
.login-card h2 { font-size: 21px; }
.login-card p { color: var(--text-dim); font-size: 13px; line-height: 1.5; margin: 8px 0 22px; }
.login-card input { width: 100%; margin-bottom: 12px; }
.error-text { color: var(--danger); font-size: 12.5px; min-height: 16px; margin-top: 10px; }

@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px);} to { opacity:1; transform: none; } }

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

/* Mobile topbar — hidden on desktop */
.topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 800;
  height: var(--topbar-h);
  align-items: center; gap: 10px; padding: 0 12px;
  background: rgba(18,21,29,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar .brand-compact { display: flex; align-items: center; gap: 9px; padding: 0; }
.topbar .brand-compact .brand-mark { width: 28px; height: 28px; }
.topbar .brand-compact h1 { font-size: 15px; }
.topbar-view { margin-left: auto; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.hamburger {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); color: var(--text);
  cursor: pointer;
}
.hamburger svg { width: 20px; height: 20px; }

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 849;
  background: rgba(6,8,12,.6); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sidebar-scrim.active { opacity: 1; pointer-events: auto; }

.sidebar {
  background: linear-gradient(180deg, var(--bg-elev), var(--bg));
  border-right: 1px solid var(--border-soft);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand .brand-mark { width: 34px; height: 34px; flex-shrink: 0; }
.brand h1 { font-size: 16px; }
.brand small { display: block; color: var(--text-faint); font-size: 10.5px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  color: var(--text-dim); font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s; user-select: none;
}
.nav-item svg { width: 18px; height: 18px; opacity: .85; flex-shrink: 0; }
.nav-item:hover { background: var(--panel-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #fff; }
.nav-item .count {
  margin-left: auto; background: var(--bg-elev-2); color: var(--text-dim);
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 20px;
}
.nav-item.active .count { background: var(--accent); color: #fff; }
.nav-item .count.warn { background: var(--warn); color: #1a1400; }

.sidebar .bottom { margin-top: auto; }

.main { overflow-y: auto; padding: 26px 30px 60px; }
/* Cap line length on very large monitors so content doesn't stretch edge-to-edge. */
.main > .view { max-width: var(--content-max); margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head p { color: var(--text-dim); font-size: 13px; margin: 3px 0 0; max-width: 70ch; }

/* =========================================================================
   Buttons / inputs
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6b4bf0; }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-hover); color: var(--text); }
.btn-soft { background: var(--bg-elev-2); color: var(--text); border-color: var(--border); }
.btn-soft:hover { background: var(--panel-hover); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(248,113,113,.3); }
.btn-danger:hover { background: rgba(248,113,113,.22); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; outline: none; width: auto;
  transition: border-color .15s, box-shadow .15s;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
label.field { display: block; font-size: 12px; color: var(--text-dim); margin: 0 0 6px; font-weight: 500; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; font-family: inherit; }
.w-full { width: 100%; }

/* =========================================================================
   KPI tiles
   ========================================================================= */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi {
  background: linear-gradient(180deg, var(--bg-elev-2), var(--panel));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi .k-label { font-size: 12px; color: var(--text-dim); font-weight: 500; display:flex; align-items:center; gap:7px; }
.kpi .k-value { font-size: 30px; font-weight: 700; margin-top: 8px; letter-spacing: -0.02em; }
.kpi .k-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.kpi .k-dot { width: 8px; height: 8px; border-radius: 50%; }
.kpi.attn { border-color: rgba(251,191,36,.3); }
.kpi.attn .k-value { color: var(--warn); }
.kpi.good .k-value { color: var(--ok); }

/* =========================================================================
   Cards / panels
   ========================================================================= */
.panel {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.panel > h3 { font-size: 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel-split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.company-card {
  background: linear-gradient(180deg, var(--bg-elev-2), var(--panel));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: border-color .15s, transform .1s, box-shadow .15s;
}
.company-card:hover { border-color: var(--border); transform: translateY(-2px); box-shadow: var(--shadow); }
.company-card .cc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.company-avatar {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #fff;
}
.company-card h4 { font-size: 15px; }
.company-card .slug { font-size: 11.5px; color: var(--text-faint); }
.cc-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 4px; }
.cc-stat { background: var(--bg); border-radius: 9px; padding: 9px 10px; text-align: center; }
.cc-stat .v { font-size: 17px; font-weight: 700; }
.cc-stat .l { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }

/* =========================================================================
   Badges
   ========================================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ready   { background: var(--ok-soft); color: var(--ok); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.processing { background: rgba(96,165,250,.14); color: var(--info); }
.badge.error   { background: var(--danger-soft); color: var(--danger); }
.badge.global  { background: rgba(34,211,238,.12); color: var(--accent-2); }
.badge.linked_ready { background: var(--ok-soft); color: var(--ok); }
.badge.no_image { background: var(--warn-soft); color: var(--warn); }
.badge.unlinked { background: var(--danger-soft); color: var(--danger); }
.badge.hidden-badge { background: rgba(159,168,190,.16); color: var(--text-dim); }

/* =========================================================================
   Toolbars / segmented controls
   ========================================================================= */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }

/* Scoped to `.search` itself, NOT to `.toolbar .search`. An inline SVG with no width/height
   has no intrinsic size, so it stretches to fill whatever box it lands in — which is exactly
   what happened everywhere the search box was used OUTSIDE a `.toolbar` (the DataTable's own
   toolbar, the asset-picker modal): a viewport-sized magnifying glass. Sizing the icon here
   means any search box is correct wherever it is used. */
.search { flex: 1; min-width: 200px; position: relative; display: block; }
.search input { width: 100%; padding-left: 34px; }
.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  flex: none;            /* never let a flex parent stretch it */
  pointer-events: none;  /* the icon sits over the input — don't eat clicks */
  color: var(--text-faint);
}
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { background: transparent; border: none; color: var(--text-dim); font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.seg button.active { background: var(--accent-soft); color: #fff; }
.seg button .n { opacity: .7; margin-left: 4px; font-weight: 500; }

/* Bulk-select action bar (Gaps triage) */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid rgba(124,92,255,.35);
  border-radius: 11px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 13px;
  animation: pop .15s ease;
}

tr.row-dim td { opacity: .5; }

/* =========================================================================
   Watch catalog gallery
   ========================================================================= */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 15px; }
.watch-card {
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius);
  overflow: hidden; transition: border-color .15s, transform .1s, opacity .15s; position: relative;
}
.watch-card:hover { border-color: var(--border); transform: translateY(-2px); }
.watch-card.needs { border-color: rgba(251,191,36,.28); }
.watch-card.is-hidden .thumb img, .watch-card.is-hidden .thumb .placeholder { opacity: .35; filter: grayscale(.7); }
.thumb {
  aspect-ratio: 1 / 1; background: var(--checker); background-size: 22px 22px;
  display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.thumb .placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-faint); }
.thumb .placeholder svg { width: 32px; height: 32px; }
.thumb .placeholder span { font-size: 11px; font-weight: 600; }
.thumb .badge { position: absolute; top: 9px; left: 9px; }
.thumb .badge.hidden-badge { top: 9px; left: auto; right: 9px; background: rgba(11,13,18,.75); }
.thumb .hover-cta {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(11,13,18,.7); opacity: 0; transition: opacity .15s; font-size: 12px; font-weight: 600; color: #fff; gap: 6px;
}
.thumb:hover .hover-cta { opacity: 1; }
.wc-body { padding: 11px 13px 13px; }
.wc-body .name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wc-body .meta { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* Four actions (upload / eye / rename / delete) — primary gets its own row so
   the rest never overflow the card at narrow grid widths. */
.wc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.wc-actions .btn:first-child { flex: 1 1 100%; }
.wc-actions .btn:not(:first-child) { flex: 1; }

/* =========================================================================
   Drawer (company detail)
   ========================================================================= */
.drawer-scrim { position: fixed; inset: 0; background: rgba(6,8,12,.6); backdrop-filter: blur(4px); z-index: 900; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-scrim.active { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; width: 580px; max-width: 94vw; z-index: 901;
  background: var(--bg-elev); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.4);
}
.drawer.active { transform: none; }
.drawer-head { padding: 20px 24px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 14px; }
.drawer-head h3 { font-size: 18px; }
.drawer-body { padding: 22px 24px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }

.close-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.close-btn:hover { background: var(--panel-hover); color: var(--text); }

.subsection { margin-bottom: 24px; }
.subsection > h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 11px; font-weight: 600; display:flex; align-items:center; gap:8px; }
.subsection.danger-zone { border: 1px solid rgba(248,113,113,.25); border-radius: 11px; padding: 14px; }
.subsection.danger-zone > h4 { color: var(--danger); margin-bottom: 8px; }

.stat-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 120px; background: var(--bg); border: 1px solid var(--border-soft); border-radius: 11px; padding: 13px; }
.stat-box .l { font-size: 11px; color: var(--text-faint); }
.stat-box .v { font-size: 22px; font-weight: 700; margin-top: 4px; }

.token-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.key-reveal { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.key-reveal code { flex: 1; min-width: 200px; font-size: 12px; word-break: break-all; color: var(--accent-2); }

.mini-watch { display: flex; align-items: center; gap: 11px; padding: 9px; border-radius: 10px; border: 1px solid var(--border-soft); margin-bottom: 8px; background: var(--bg); flex-wrap: wrap; }
.mini-thumb { width: 42px; height: 42px; border-radius: 8px; background: var(--checker); background-size: 14px 14px; flex-shrink: 0; overflow: hidden; display:flex; align-items:center; justify-content:center; }
.mini-thumb img { width: 100%; height: 100%; object-fit: contain; }
.mini-watch .info { flex: 1; min-width: 140px; }
.mini-watch .info .n { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link-table, .data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.link-table th, .data-table th { text-align: left; color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.link-table td, .data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); }
.link-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-elev); }
.link-table .n { font-weight: 600; }

/* =========================================================================
   Modal
   ========================================================================= */
.modal-scrim { position: fixed; inset: 0; z-index: 950; display: none; align-items: center; justify-content: center; background: rgba(6,8,12,.7); backdrop-filter: blur(8px); padding: 24px; }
.modal-scrim.active { display: flex; }
.modal {
  width: 100%; max-width: 460px; background: linear-gradient(180deg, var(--bg-elev-2), var(--panel));
  border: 1px solid var(--border); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); position: relative;
  animation: pop .22s ease; max-height: 90vh; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain;
}
.modal.wide { max-width: 640px; }
.modal h3 { font-size: 18px; margin-bottom: 4px; padding-right: 36px; }
.modal .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.modal .close-btn { position: absolute; top: 18px; right: 18px; }
.modal .form-row { margin-bottom: 14px; }
.modal .actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.modal .actions .btn { flex: 1; }

.dz {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px 20px;
  text-align: center; color: var(--text-dim); cursor: pointer; transition: border-color .15s, background .15s;
}
.dz:hover, .dz.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dz svg { width: 34px; height: 34px; color: var(--text-faint); margin-bottom: 10px; }
.dz .big { font-size: 14px; font-weight: 600; color: var(--text); }
.dz .small { font-size: 12px; margin-top: 4px; }
.upload-preview { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 12px; background: var(--bg); border-radius: 11px; border: 1px solid var(--border-soft); }
.upload-preview .pv { width: 64px; height: 64px; border-radius: 9px; background: var(--checker); background-size: 16px 16px; overflow: hidden; display:flex;align-items:center;justify-content:center; flex-shrink:0; }
.upload-preview .pv img { width: 100%; height: 100%; object-fit: contain; }

/* =========================================================================
   Toast
   ========================================================================= */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-elev-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 11px; padding: 13px 16px; min-width: 240px; max-width: 360px; box-shadow: var(--shadow);
  animation: slideIn .25s ease; font-size: 13px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast .t-title { font-weight: 600; margin-bottom: 2px; }
.toast .t-msg { color: var(--text-dim); font-size: 12.5px; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.empty { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty svg { width: 46px; height: 46px; margin-bottom: 14px; opacity: .6; }
.empty .big { font-size: 15px; font-weight: 600; color: var(--text-dim); }
.empty .small { font-size: 13px; margin-top: 6px; }

.alert-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 11px; background: var(--bg); border: 1px solid var(--border-soft); margin-bottom: 9px; flex-wrap: wrap; }
.alert-item .ai-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.alert-item .ai-icon svg { width: 16px; height: 16px; }
.alert-item .ai-body { flex: 1; min-width: 200px; }
.alert-item .ai-body .t { font-size: 13px; font-weight: 600; }
.alert-item .ai-body .s { font-size: 12px; color: var(--text-dim); }

/* Pagination (catalog + pending + queue) */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin: 20px 2px 4px;
}
.pager-info { color: var(--text-dim); font-size: 12px; }
.pager-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager .pg {
  min-width: 34px; height: 34px; padding: 0 10px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; cursor: pointer; transition: background .12s, border-color .12s;
}
.pager .pg:hover:not(:disabled) { background: var(--panel-hover); border-color: var(--accent); }
.pager .pg.active {
  background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600;
}
.pager .pg:disabled { opacity: .4; cursor: default; }
.pager .pg-gap { color: var(--text-dim); padding: 0 2px; }

/* =========================================================================
   Responsive breakpoints
   ========================================================================= */

/* Small laptops (1366×768 and similar): tighten density so more fits. */
@media (max-width: 1440px) {
  :root { --sidebar-w: 210px; }
  .main { padding: 20px 22px 50px; }
  .page-head h2 { font-size: 20px; }
  .kpi .k-value { font-size: 26px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* Tablets / narrow laptops: icon-rail sidebar. */
@media (max-width: 1024px) {
  :root { --sidebar-w: 64px; }
  .brand h1, .brand small, .sidebar .nav-item .label, .sidebar .nav-item .count { display: none; }
  .sidebar { padding: 18px 12px; align-items: center; }
  .nav-item { justify-content: center; padding: 11px; width: 40px; }
  .panel-split { grid-template-columns: 1fr; }
}

/* Phones + small tablets: topbar + slide-over sidebar. */
@media (max-width: 768px) {
  .app.active { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .main { padding: calc(var(--topbar-h) + 14px) 14px 70px; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 850;
    width: 260px; max-width: 84vw;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    box-shadow: 20px 0 60px rgba(0,0,0,.45);
    align-items: stretch; padding: 20px 14px;
  }
  .sidebar.open { transform: none; }
  /* restore full labels inside the slide-over */
  .brand h1, .brand small, .sidebar .nav-item .label, .sidebar .nav-item .count { display: block; }
  .sidebar .nav-item .count { display: inline-flex; }
  .nav-item { justify-content: flex-start; padding: 12px; width: auto; }

  .page-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .page-head .spacer { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi .k-value { font-size: 23px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .card-grid { grid-template-columns: 1fr; }

  .toolbar { gap: 8px; }
  .toolbar .search { flex-basis: 100%; }
  .toolbar select { flex: 1; min-width: 0; }

  .drawer { width: 100vw; max-width: 100vw; border-left: none; }
  .drawer-head { padding: 16px; }
  .drawer-body { padding: 16px; }

  .modal-scrim { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; border-radius: 18px 18px 0 0; max-height: 92dvh; padding: 20px 18px; }

  .toast-wrap { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: none; width: 100%; }

  /* comfortable touch targets */
  .btn { padding: 10px 15px; }
  .btn-sm { padding: 8px 12px; }
  .nav-item { padding: 13px 12px; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .cc-stats { grid-template-columns: repeat(3, 1fr); }
  .seg button { padding: 6px 9px; font-size: 12px; }
  .topbar-view { display: none; }
}

/* ===================== Crawl monitor =====================
   A crawl used to be an opaque background task. This panel is what makes one
   observable: phase, live URL, running counters, and working controls. */
.crawl-monitor {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--panel-2, rgba(255,255,255,.02));
}
.crawl-monitor + .crawl-monitor { margin-top: 8px; }
.crawl-monitor.running      { border-left: 3px solid var(--accent); }
.crawl-monitor.paused       { border-left: 3px solid var(--warn); }
.crawl-monitor.interrupted,
.crawl-monitor.failed       { border-left: 3px solid var(--danger); }
.crawl-monitor.done         { border-left: 3px solid var(--ok); }
.crawl-monitor.stopped      { border-left: 3px solid var(--line); }

.cm-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }
.cm-head .spacer { flex: 1; }
.cm-phase { font-size: 12px; }

.cm-bar {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,.07);
}
.cm-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2, #22d3ee));
  transition: width .4s ease;
}
/* While the crawl is still discovering links, the denominator is unknown — so we
   animate a stripe rather than draw a percentage we'd be inventing. */
.cm-bar.indeterminate .cm-fill {
  background-image: linear-gradient(90deg,
    rgba(255,255,255,.05) 25%, var(--accent) 25%, var(--accent) 50%,
    rgba(255,255,255,.05) 50%, rgba(255,255,255,.05) 75%, var(--accent) 75%);
  background-size: 28px 100%;
  animation: cm-stripe 900ms linear infinite;
}
@keyframes cm-stripe { from { background-position: 0 0; } to { background-position: 28px 0; } }

.cm-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: 12px; }
.cm-dot { opacity: .35; }
.cm-url { font-size: 11px; opacity: .6; margin-top: 5px; max-width: 100%; }
.cm-msg { font-size: 12px; opacity: .75; margin-top: 6px; }

@media (max-width: 640px) {
  .cm-head { gap: 6px; }
  .cm-head .spacer { flex-basis: 100%; height: 0; }
}

/* ===================== Access control =====================
   The allow-list the Blocked page always promised but never showed. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 26px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 6px 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,.04);
  font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.chip-x {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  opacity: .45; font-size: 15px; line-height: 1; padding: 0 3px;
}
.chip-x:hover { opacity: 1; color: var(--danger); }

/* An unrestricted key is a live liability, so it gets banner treatment — not a footnote. */
.risk-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid var(--danger);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--danger-soft, rgba(248,113,113,.12));
}
.risk-banner .rb-body { flex: 1; min-width: 220px; }
.risk-banner .t { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.risk-banner .s { font-size: 12px; opacity: .8; line-height: 1.45; }

.cc-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ===================== DataTable =====================
   One table implementation behind every tab. Replaces six hand-rolled tables that each
   loaded every row into the browser and filtered in JS. */
.dt-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.dt-toolbar .spacer { flex: 1; }
.dt-facets { display: flex; gap: 8px; flex-wrap: wrap; }
.dt-tools { display: flex; gap: 6px; }

select.dt-facet {
  padding: 7px 10px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--line); background: var(--panel); color: inherit;
  max-width: 190px;
}

/* Sortable headers must LOOK clickable — not one table had sorting before. */
th.dt-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.dt-sortable:hover { color: var(--text, inherit); background: rgba(255,255,255,.03); }
th.dt-sortable.sorted { color: var(--accent); }
.dt-arrow { font-size: 9px; opacity: .8; }
th.dt-check, td.dt-check { width: 34px; text-align: center; }
td.dt-thumb, th.dt-thumb { width: 52px; }

.dt-bulk {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; margin-bottom: 10px; border-radius: 9px;
  border: 1px solid var(--accent);
  background: rgba(124,92,255,.10);
  font-size: 13px;
}
.dt-bulk.hidden { display: none; }

.dt-pager {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 2px 0; font-size: 12px;
}
.dt-pager .spacer { flex: 1; }

.col-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin: 6px 0 4px; }
.col-opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px;
  font-size: 13px; cursor: pointer; border-radius: 6px;
}
.col-opt:hover { background: rgba(255,255,255,.04); }
.company-avatar.sm { width: 28px; height: 28px; font-size: 11px; flex: none; }

@media (max-width: 720px) {
  .dt-toolbar { gap: 8px; }
  .dt-toolbar .search { flex: 1 1 100%; }
  .dt-facets { flex: 1 1 100%; }
  select.dt-facet { flex: 1; max-width: none; }
  .dt-tools { flex: 1 1 100%; justify-content: flex-end; }
  .col-picker { grid-template-columns: 1fr; }
}

/* ===================== Analytics ===================== */
.chart-wrap { width: 100%; }
.chart { width: 100%; height: 200px; display: block; color: var(--text, #e6e8ee); }
.chart-legend {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 8px; font-size: 12px;
}
.chart-legend .spacer { flex: 1; }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }

/* The funnel: the gap between two bars is the whole point, so the drop-off is labelled. */
.funnel { display: flex; flex-direction: column; gap: 9px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-row .fl { width: 132px; font-size: 12px; opacity: .8; flex: none; }
.funnel-row .fbar { flex: 1; height: 20px; border-radius: 5px; background: rgba(255,255,255,.05); overflow: hidden; }
.funnel-row .ffill { height: 100%; border-radius: 5px; transition: width .5s ease; }
.funnel-row .fv { width: 108px; text-align: right; font-size: 12px; flex: none; }

@media (max-width: 640px) {
  .funnel-row .fl { width: 92px; font-size: 11px; }
  .funnel-row .fv { width: 78px; }
}

/* ===================== System ===================== */
.hgrid { display: flex; flex-direction: column; gap: 8px; }
.hstat { display: flex; align-items: center; gap: 12px; }
.hstat .hl { width: 68px; font-size: 12px; opacity: .75; flex: none; }
.hstat .hbar { flex: 1; height: 8px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.hstat .hfill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.hstat .hv { width: 40px; text-align: right; font-size: 12px; flex: none; }

details.fail-group { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; }
details.fail-group summary { cursor: pointer; font-size: 13px; list-style: none; }
details.fail-group summary::-webkit-details-marker { display: none; }
details.fail-group summary::before { content: '▸ '; opacity: .5; }
details.fail-group[open] summary::before { content: '▾ '; }
details.fail-group > .table-scroll { margin-top: 10px; }

/* Core map: one square per CPU, so a split is something you SEE, not something you compute. */
.core-map { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 10px; }
.core-map i { width: 14px; height: 14px; border-radius: 3px; display: block; }
.core-map i.ar { background: var(--accent); opacity: .85; }
.core-map i.crawl { background: var(--warn); opacity: .85; }
#rs-cores.dim { opacity: .45; pointer-events: none; }
#rs-cores.dim .core-map i.crawl { background: var(--accent); }

input[type=range] { accent-color: var(--accent); }
