/* ════════════════════════════════════════════════════
   ScreenMonitor Admin  ·  Design System
   ════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0b1120;
  --bg-elevated: #111827;
  --surface:     #1a2236;
  --surface-2:   #1f2d45;
  --border:      #263352;
  --border-light:#2e3d58;

  --text:        #e8edf5;
  --text-muted:  #8a9bb8;
  --text-dim:    #4f617d;

  --accent:      #3b82f6;
  --accent-dim:  #1d3a6e;

  --green:       #22c55e;
  --green-dim:   #14532d;
  --yellow:      #f59e0b;
  --yellow-dim:  #78350f;
  --red:         #ef4444;
  --red-dim:     #450a0a;
  --orange:      #f97316;
  --orange-dim:  #7c2d12;
  --purple:      #a78bfa;
  --purple-dim:  #312e81;

  --radius-sm:   4px;
  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;

  --sidebar-w:   232px;
  --topbar-h:    56px;

  --shadow:      0 4px 24px rgba(0,0,0,.45);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.3);
}

html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ══════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════ */

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #1d4ed8 0%, #7c3aed 100%);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

.sidebar-logo-text { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.2; }
.sidebar-logo-sub  { font-size: 10px; color: var(--text-dim); letter-spacing: .06em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.sidebar-section {
  font-size: 10px; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 16px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
  user-select: none;
}
.nav-item:hover  { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 16px; text-align: center; flex-shrink: 0; font-size: 13px; }

.sidebar-user {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  margin-bottom: 6px;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-name  { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.2; }
.sidebar-user-role  { font-size: 11px; color: var(--text-muted); }

/* ── Main content ──────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Topbar ────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
  position: sticky; top: 0; z-index: 50;
  flex-shrink: 0;
}

.topbar-title {
  flex: 1;
  font-size: 14px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

.topbar-title .breadcrumb {
  color: var(--text-muted); font-weight: 400;
}
.topbar-title .breadcrumb::after { content: '/'; margin: 0 6px; color: var(--text-dim); }

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

.refresh-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-dim);
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
}

/* ── Page body ─────────────────────────────────────── */
.page-body { padding: 20px 24px; flex: 1; }

/* ══════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 7px;
}
.card-title i { color: var(--accent); font-size: 12px; }

.card-body { padding: 16px 18px; }

/* ── Stat cards ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .15s;
}
.stat-card:hover { border-color: var(--border-light); }

.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

.stat-num, .stat-value { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat-lbl, .stat-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* ══════════════════════════════════════════════════════
   AGENT CARDS
   ══════════════════════════════════════════════════════ */

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  position: relative;
}
.agent-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), var(--shadow-sm);
  transform: translateY(-1px);
}
.agent-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
}
.agent-card.health-healthy::before { background: var(--green); }
.agent-card.health-warning::before { background: var(--yellow); }
.agent-card.health-critical::before { background: var(--red); animation: border-pulse 2s infinite; }

@keyframes border-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

.agent-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 14px 10px 18px;
}

.agent-card-name { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.2; }
.agent-card-id   { font-size: 11px; color: var(--text-muted); font-family: 'SF Mono', 'Fira Code', monospace; margin-top: 2px; }

.agent-card-meta {
  text-align: right; font-size: 11px; color: var(--text-dim); line-height: 1.6;
}

/* mini preview */
.agent-card-preview {
  margin: 0 14px 10px;
  background: #060d1a;
  border-radius: var(--radius);
  aspect-ratio: 16/9;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}

.agent-card-preview-inner {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-dim);
}
.agent-card-preview-inner.live { color: var(--accent); }

.mini-live-badge {
  position: absolute; top: 6px; left: 6px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 800;
  padding: 1px 5px; border-radius: 3px;
  letter-spacing: .05em;
  animation: live-blink 2.5s infinite;
}
/* @keyframes live-blink defined in LIVE PLAYER section below */

.agent-card-badges {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 0 14px 10px 18px;
}

.agent-card-times {
  display: flex; gap: 16px;
  padding: 8px 14px 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim);
}
.agent-card-times span { display: flex; align-items: center; gap: 4px; }

.agent-card-error {
  margin: 0 14px 10px;
  padding: 6px 10px;
  background: rgba(239,68,68,.07);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius-sm);
  font-size: 11px; color: #f87171;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.agent-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,.15);
}

/* ══════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════ */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap; line-height: 1.4;
  border: 1px solid transparent;
}

/* status dots */
.badge::before {
  content: '';
  display: inline-block; width: 5px; height: 5px;
  border-radius: 50%; flex-shrink: 0;
}
.badge.no-dot::before { display: none; }

/* Online */
.badge-online  { background:#14532d22; color:#4ade80; border-color:#16a34a44; }
.badge-online::before  { background:#4ade80; }
.badge-stale   { background:#78350f22; color:#fbbf24; border-color:#d9770644; }
.badge-stale::before   { background:#fbbf24; }
.badge-offline { background:#450a0a22; color:#f87171; border-color:#dc262644; }
.badge-offline::before { background:#f87171; animation: dot-pulse 2s infinite; }

/* Health */
.badge-healthy  { background:#14532d22; color:#4ade80; border-color:#16a34a44; }
.badge-healthy::before  { background:#4ade80; }
.badge-warning  { background:#78350f22; color:#fbbf24; border-color:#d9770644; }
.badge-warning::before  { background:#fbbf24; }
.badge-critical { background:#450a0a22; color:#f87171; border-color:#dc262644; }
.badge-critical::before { background:#f87171; animation: dot-pulse 1.5s infinite; }

/* Recording */
.badge-recording     { background:#1e3a5f33; color:#60a5fa; border-color:#2563eb44; }
.badge-recording::before { background:#60a5fa; animation: dot-pulse 1.8s infinite; }
.badge-test_recording{ background:#312e8133; color:#a78bfa; border-color:#7c3aed44; }
.badge-test_recording::before { background:#a78bfa; animation: dot-pulse 1.5s infinite; }
.badge-stopped       { background:#1e293b; color:#4f617d; border-color:#26335244; }
.badge-stopped::before { background:#4f617d; }
.badge-stopping      { background:#78350f22; color:#fbbf24; border-color:#d9770644; }
.badge-stopping::before { background:#fbbf24; }
.badge-starting      { background:#14533422; color:#34d399; border-color:#05966944; }
.badge-starting::before { background:#34d399; animation: dot-pulse 1.2s infinite; }
.badge-error         { background:#450a0a22; color:#f87171; border-color:#dc262644; }
.badge-error::before { background:#f87171; animation: dot-pulse 1.5s infinite; }

/* Stream */
.badge-stream_online     { background:#14532d22; color:#4ade80; border-color:#16a34a44; }
.badge-stream_online::before { background:#4ade80; animation: dot-pulse 2.5s infinite; }
.badge-stream_connecting { background:#78350f22; color:#fbbf24; border-color:#d9770644; }
.badge-stream_connecting::before { background:#fbbf24; animation: dot-pulse 1.2s infinite; }
.badge-stream_missing    { background:#450a0a22; color:#f87171; border-color:#dc262644; }
.badge-stream_missing::before { background:#f87171; }
.badge-stream_error      { background:#450a0a22; color:#f87171; border-color:#dc262644; }
.badge-stream_error::before { background:#f87171; animation: dot-pulse 1.5s infinite; }

/* Upload */
.badge-upload_ok      { background:#14532d22; color:#4ade80; border-color:#16a34a44; }
.badge-upload_ok::before { background:#4ade80; }
.badge-upload_pending  { background:#78350f22; color:#fbbf24; border-color:#d9770644; }
.badge-upload_pending::before { background:#fbbf24; animation: dot-pulse 1.5s infinite; }
.badge-upload_delayed  { background:#7c2d1222; color:#fb923c; border-color:#ea580c44; }
.badge-upload_delayed::before { background:#fb923c; animation: dot-pulse 1.5s infinite; }
.badge-upload_error    { background:#450a0a22; color:#f87171; border-color:#dc262644; }
.badge-upload_error::before { background:#f87171; animation: dot-pulse 1.2s infinite; }

/* Command status */
.badge-queued      { background:#1e293b; color:#4f617d; border-color:#26335244; }
.badge-queued::before { background:#4f617d; }
.badge-acknowledged{ background:#1e3a5f33; color:#60a5fa; border-color:#2563eb44; }
.badge-acknowledged::before { background:#60a5fa; }
.badge-running     { background:#14533422; color:#34d399; border-color:#05966944; }
.badge-running::before { background:#34d399; animation: dot-pulse 1s infinite; }
.badge-success     { background:#14532d22; color:#4ade80; border-color:#16a34a44; }
.badge-success::before { background:#4ade80; }
.badge-failed      { background:#450a0a22; color:#f87171; border-color:#dc262644; }
.badge-failed::before { background:#f87171; }
.badge-expired     { background:#1e293b; color:#4f617d; border-color:#26335244; }
.badge-expired::before { background:#4f617d; }

/* Log levels — no dot variant */
.badge-info { background:#1e3a5f33; color:#60a5fa; border-color:#2563eb44; }
.badge-info::before { display: none; }
.badge-warn { background:#78350f22; color:#fbbf24; border-color:#d9770644; }
.badge-warn::before { display: none; }
/* badge-error already defined above */

@keyframes dot-pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50% { opacity:.4; transform:scale(.75); }
}

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s, transform .08s;
  white-space: nowrap; line-height: 1;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background:#2563eb; color:#fff; border-color:#1d4ed8; }
.btn-primary:hover:not(:disabled)   { background:#1d4ed8; }

.btn-secondary { background:var(--surface-2); color:var(--text); border-color:var(--border-light); }
.btn-secondary:hover:not(:disabled) { background:var(--border); }

.btn-danger  { background:#dc2626; color:#fff; border-color:#b91c1c; }
.btn-danger:hover:not(:disabled)  { background:#b91c1c; }

.btn-warning { background:#d97706; color:#fff; border-color:#b45309; }
.btn-warning:hover:not(:disabled) { background:#b45309; }

.btn-success { background:#16a34a; color:#fff; border-color:#15803d; }
.btn-success:hover:not(:disabled) { background:#15803d; }

.btn-ghost   { background:transparent; color:var(--text-muted); border-color:transparent; }
.btn-ghost:hover:not(:disabled)   { background:var(--surface-2); color:var(--text); }

.btn-sm   { padding: 4px 10px; font-size: 11px; }
.btn-xs   { padding: 2px 8px;  font-size: 11px; border-radius: var(--radius-sm); }
.btn-icon { padding: 6px; width:30px; height:30px; border-radius: var(--radius); }
.btn-icon.btn-sm { width:26px; height:26px; padding:4px; }

/* ══════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════ */

.form-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px; width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-input::placeholder { color: var(--text-dim); }
.form-input:disabled { opacity:.5; cursor:not-allowed; }

select.form-input { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234f617d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 28px;
}
select.form-input option { background: var(--surface-2); }

.form-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 6px; display: block;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

/* ══════════════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════════════ */

.table-wrap,
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table { width: 100%; border-collapse: collapse; font-size: 12px; }

thead th {
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  padding: 9px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .08s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody td {
  padding: 10px 14px;
  color: var(--text);
  vertical-align: middle;
}

/* ══════════════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════════════ */

.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
}

.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
  user-select: none; white-space: nowrap;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .tab-count {
  font-size: 10px; padding: 1px 5px;
  background: var(--surface-2); border-radius: 99px;
  color: var(--text-dim);
}
.tab.active .tab-count { background: var(--accent-dim); color: var(--accent); }

/* ══════════════════════════════════════════════════════
   LIVE PLAYER
   ══════════════════════════════════════════════════════ */

.live-player {
  background: #050c18;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
  border: 1px solid var(--border);
}

.live-player video { width:100%; height:100%; object-fit:contain; display:block; }

.live-player-offline,
.live-player-ready {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  text-align: center;
}

.live-player-offline { color: var(--text-dim); }
.live-player-offline i { font-size: 36px; opacity:.3; }
.live-player-offline p { font-size: 12px; }

.live-player-ready { color: var(--text-muted); }
.live-player-ready i { font-size: 32px; color: var(--accent); }
.live-player-ready p { font-size: 12px; }
.live-player-ready .stream-url {
  font-family: 'SF Mono','Fira Code',monospace;
  font-size: 10px; color: var(--text-dim);
  background: rgba(0,0,0,.4);
  padding: 4px 10px; border-radius: 4px;
  max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.live-badge {
  position: absolute; top: 8px; left: 8px;
  background: #dc2626; color: #fff;
  font-size: 9px; font-weight: 800;
  padding: 2px 6px; border-radius: 3px;
  letter-spacing: .06em;
  animation: live-blink 2.5s infinite;
}
@keyframes live-blink { 0%,100%{opacity:1} 50%{opacity:.55} }

.live-mode-badge {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,.7); color: var(--text-muted);
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 3px;
  letter-spacing: .04em; backdrop-filter: blur(4px);
}

/* ══════════════════════════════════════════════════════
   LIVE PLAYER — STATE OVERLAYS
   ══════════════════════════════════════════════════════ */

/* Base overlay */
.lp-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; text-align: center;
  padding: 16px;
}

.lp-text    { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 0; }
.lp-subtext { font-size: 10px; color: var(--text-dim); margin: 0; line-height: 1.5; }

/* ── Loading ── */
.lp-loading { background: #050c18; }
.lp-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: lp-spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes lp-spin { to { transform: rotate(360deg); } }

/* ── Empty ── */
.lp-empty { background: #050c18; }
.lp-empty i { font-size: 32px; opacity: .2; color: var(--text-dim); }

/* ── Offline ── */
.lp-offline { background: #050c18; }
.lp-offline i { font-size: 28px; opacity: .25; color: var(--text-dim); }

/* ── Error ── */
.lp-error { background: #080508; }
.lp-error i { font-size: 28px; color: #ef4444; opacity: .7; }

.lp-retry-btn {
  margin-top: 6px;
  padding: 6px 16px;
  background: transparent;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: border-color .12s, color .12s;
}
.lp-retry-btn:hover  { border-color: var(--accent); color: var(--text); }
.lp-retry-btn:focus  { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Unsupported ── */
.lp-unsupported { background: #050c18; }
.lp-unsupported i { font-size: 28px; opacity: .25; color: #f59e0b; }

/* ── Reconnect badge (inside playing state) ── */
.lp-reconnect-info {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,.75); color: var(--text-muted);
  font-size: 9px; padding: 2px 8px; border-radius: 3px;
  display: flex; align-items: center; gap: 4px;
  backdrop-filter: blur(4px);
}

/* ── Mini preview: open live button ── */
.lp-open-live-btn {
  position: absolute; inset: 0; width: 100%; height: 100%;
  background: transparent;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.lp-open-live-btn i { font-size: 22px; color: #fff; }
.agent-card-preview:hover .lp-open-live-btn {
  opacity: 1;
  background: rgba(0,0,0,.45);
}

/* ══════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
  animation: fade-in .15s;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%; max-width: 420px;
  animation: slide-up .15s;
  box-shadow: var(--shadow);
}
.modal-title   { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.modal-message { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }
.modal-footer  { display: flex; gap: 8px; justify-content: flex-end; }

@keyframes fade-in  { from { opacity:0 } }
@keyframes slide-up { from { transform: translateY(12px); opacity:0 } }

/* ══════════════════════════════════════════════════════
   TOASTS
   ══════════════════════════════════════════════════════ */

.toast-wrap {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  font-size: 13px; color: var(--text);
  pointer-events: all;
  max-width: 340px;
  box-shadow: var(--shadow);
  animation: toast-in .2s;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red);   }
.toast-warning { border-left: 3px solid var(--yellow); }
.toast-info    { border-left: 3px solid var(--accent); }

@keyframes toast-in { from { transform:translateX(100%); opacity:0 } }

/* ══════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════ */

.login-bg {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 16px;
  position: relative; overflow: hidden;
}
/* subtle radial glows */
.login-bg::before,
.login-bg::after {
  content: '';
  position: absolute; border-radius: 50%;
  pointer-events: none; z-index: 0;
}
.login-bg::before {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(59,130,246,.08) 0%, transparent 70%);
  top: -100px; left: -100px;
}
.login-bg::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(124,58,237,.07) 0%, transparent 70%);
  bottom: -80px; right: -80px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow);
  position: relative; z-index: 1;
}

.login-logo {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #1d4ed8 0%, #7c3aed 100%);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 8px 24px rgba(59,130,246,.3);
}
.login-logo-title { font-size: 18px; font-weight: 800; color: var(--text); }
.login-logo-sub   { font-size: 12px; color: var(--text-muted); }

.login-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px; color: #f87171;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}

.login-demo {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.login-demo-label {
  font-size: 11px; color: var(--text-dim);
  text-align: center; margin-bottom: 8px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.login-demo-btns { display: grid; grid-template-columns:repeat(3,1fr); gap: 6px; }

/* ══════════════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════════════ */

.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  position: relative; flex: 1; min-width: 180px;
}
.search-wrap i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-size: 11px; pointer-events: none;
}
.search-wrap .form-input { padding-left: 30px; }

.filter-bar .filter-count {
  font-size: 11px; color: var(--text-dim);
  white-space: nowrap; padding: 0 4px;
}

/* ══════════════════════════════════════════════════════
   DETAIL PAGE — INFO GRID
   ══════════════════════════════════════════════════════ */

.info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  font-size: 12px;
}
.info-row { display: contents; }
.info-key {
  color: var(--text-dim); font-size: 11px;
  padding: 5px 0; display: flex; align-items: center;
}
.info-val {
  color: var(--text); padding: 5px 0;
  display: flex; align-items: center; gap: 5px;
  overflow: hidden; text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════
   MISC UTILITIES
   ══════════════════════════════════════════════════════ */

.mono    { font-family: 'SF Mono','Fira Code','Cascadia Code',monospace; font-size: .9em; }
.muted   { color: var(--text-muted); }
.dim     { color: var(--text-dim); }
.small   { font-size: 11px; }
.clamp1  { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.divider { border:none; border-top:1px solid var(--border); margin:0; }

.spinning { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Pulse dot standalone */
.pulse-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.pulse-green  { background: var(--green);  animation: dot-pulse 2s infinite; }
.pulse-yellow { background: var(--yellow); animation: dot-pulse 2s infinite; }
.pulse-red    { background: var(--red);    animation: dot-pulse 1.5s infinite; }
.pulse-dim    { background: var(--text-dim); }

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px;
  padding: 48px 24px;
  color: var(--text-dim); text-align: center;
}
.empty-state i   { font-size: 32px; opacity:.4; }
.empty-state p   { font-size: 13px; }

/* error box */
.error-box {
  background: rgba(239,68,68,.07);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px; color: #f87171;
  display: flex; align-items: flex-start; gap: 7px;
}

/* section title (above filter-bar alternative) */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 12px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

/* log row */
.log-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  transition: background .08s;
}
.log-row:last-child { border-bottom: none; }
.log-row:hover { background: rgba(255,255,255,.02); }
.log-row-meta { font-size: 10px; color: var(--text-dim); margin-bottom: 2px; }
.log-row-msg  { color: var(--text); line-height: 1.4; }
.log-row-msg.error { color: #f87171; }
.log-row-msg.warn  { color: #fbbf24; }

/* responsive */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main-content { margin-left: 0; }
  .sidebar-mobile-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 55;
  }
}
@media (min-width: 861px) {
  .sidebar-mobile-overlay { display: none !important; }
  #sidebar-toggle { display: none !important; }
}

.card + .card { margin-top: 14px; }

/* ══════════════════════════════════════════════════════
   LIVE PLAYER — RESPONSIVE & COMPACT
   ══════════════════════════════════════════════════════ */

/* Compact mode for smaller containers */
.live-player.compact { aspect-ratio: auto; height: 160px; }

/* Max width constraint on detail page */
.live-player-wrap { max-width: 680px; }

/* Ensure live-blink is defined only once (de-duplicate) */

/* Video wrapper used inside the live player container */
.lp-video-wrap { position: absolute; inset: 0; }

/* Status indicator dot next to stream mode */
.stream-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
}
.stream-indicator.online  { color: #4ade80; }
.stream-indicator.offline { color: #f87171; }
.stream-indicator.missing { color: #94a3b8; }

/* ══════════════════════════════════════════════════════
   AGENT CARD PREVIEW — improved hover
   ══════════════════════════════════════════════════════ */
.agent-card-preview {
  cursor: pointer;
  transition: border-color .15s;
}
.agent-card-preview:hover {
  border-color: var(--border-light);
}

/* Live badge pulsing text in mini preview */
.agent-card-preview-inner .live-text {
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  color: #e2e8f0;
}
.agent-card-preview-inner .live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #ef4444;
  animation: live-blink 2.5s infinite;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════
   SETTINGS PAGE — URL preview code block
   ══════════════════════════════════════════════════════ */
.srs-url-preview { font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace; }

/* Code inline */
code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE: smaller screens
   ══════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .live-player { aspect-ratio: 4/3; }
  .live-player-wrap { max-width: 100%; }
}

@media (max-width: 480px) {
  .agent-card-preview { aspect-ratio: 4/3; }
}

