@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* Brand (Grupo AMIX HN red - do not change) */
  --amix-red: #e30613;
  --amix-red-dark: #a30410;

  /* Surfaces */
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-1: #f3f5f8;
  --surface-2: #e5e9ee;

  /* Text */
  --text: #171b21;
  --text-muted: #6b7280;
  --text-secondary: #4b5563;

  /* Borders */
  --border: rgba(23, 27, 33, 0.12);
  --border-strong: rgba(23, 27, 33, 0.22);

  /* Semantic */
  --bg-accent: #e8f0fe;
  --text-accent: #1a56db;
  --bg-danger: #fdeaea;
  --text-danger: #a30410;
  --bg-success: #e5f6ec;
  --text-success: #157347;
  --bg-warning: #fdf2e0;
  --text-warning: #92590a;

  /* Type */
  --font-sans: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(23, 27, 33, 0.06);
  --shadow-md: 0 4px 16px rgba(23, 27, 33, 0.08);
  --shadow-lg: 0 16px 40px rgba(23, 27, 33, 0.16);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 999px;

  --ease: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: 220ms cubic-bezier(0.34, 1.4, 0.64, 1);

  /* Bold accents (sidebar + glow system) */
  --glow-red-sm: 0 2px 10px rgba(227, 6, 19, 0.28);
  --glow-red: 0 10px 28px rgba(227, 6, 19, 0.32);
  --sidebar-bg: linear-gradient(178deg, #17181d 0%, #1c1319 55%, #21131a 100%);
  --sidebar-text: rgba(255, 255, 255, 0.6);
  --sidebar-text-strong: #f5f6f8;
  --sidebar-border: rgba(255, 255, 255, 0.09);
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active-grad: linear-gradient(135deg, var(--amix-red), var(--amix-red-dark));
  --accent-grad: linear-gradient(90deg, var(--amix-red), #ff8a5c);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #171b22;
    --surface-1: #1e232c;
    --surface-2: #262c37;

    --text: #edeff3;
    --text-muted: #9aa3b2;
    --text-secondary: #b7bfcb;

    --border: rgba(237, 239, 243, 0.11);
    --border-strong: rgba(237, 239, 243, 0.2);

    --amix-red: #ff4655;
    --amix-red-dark: #d42636;

    --bg-accent: rgba(89, 141, 255, 0.16);
    --text-accent: #7ea2ff;
    --bg-danger: rgba(255, 70, 85, 0.15);
    --text-danger: #ff8791;
    --bg-success: rgba(52, 211, 153, 0.15);
    --text-success: #4ade95;
    --bg-warning: rgba(251, 191, 36, 0.15);
    --text-warning: #fbbf24;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(1100px 520px at 105% -12%, rgba(227, 6, 19, 0.07), transparent 60%),
    radial-gradient(800px 400px at -10% 105%, rgba(227, 6, 19, 0.04), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--amix-red); color: #fff; }

a { transition: color var(--ease); }

:focus-visible {
  outline: 2px solid var(--amix-red);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background:
    radial-gradient(120% 90% at 15% 10%, rgba(227, 6, 19, 0.35), transparent 55%),
    linear-gradient(160deg, #150506 0%, #1a1a1a 45%, #2c0a0e 100%);
  background-size: cover;
  background-position: center;
}

.login-card {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 300px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(227, 6, 19, 0.12), 0 30px 90px rgba(227, 6, 19, 0.14);
}

.login-logo { max-width: 200px; margin-bottom: 12px; filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.45)); }

.login-subtitle {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin: 0 0 24px;
  font-weight: 500;
}

label { display: block; font-size: 13px; color: var(--text-muted); margin: 14px 0 5px; text-align: left; font-weight: 500; }

.login-body label { color: rgba(255, 255, 255, 0.68); }

.login-body input[type="text"],
.login-body input[type="password"] {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
}
.login-body input[type="text"]:focus,
.login-body input[type="password"]:focus {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
}
.login-body input[type="text"]::placeholder,
.login-body input[type="password"]::placeholder { color: rgba(255, 255, 255, 0.38); }

input[type="text"], input[type="password"] {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--ease), box-shadow var(--ease);
}
input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--amix-red);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.15);
}

.btn {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--sidebar-active-grad);
  border-color: var(--amix-red-dark);
  color: #fff;
  box-shadow: var(--glow-red-sm);
}

.btn-primary:hover { filter: brightness(1.08); box-shadow: var(--glow-red); transform: translateY(-1px); }

.btn-pill { border-radius: var(--radius-full); }
.btn-pill.btn-primary { box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.14), var(--glow-red-sm); }
.btn-pill.btn-primary:hover { box-shadow: 0 0 0 5px rgba(227, 6, 19, 0.2), var(--glow-red); }

.btn-icon-lead { display: inline-flex; align-items: center; gap: 9px; padding: 4px 16px 4px 4px !important; }
.btn-icon-box {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--bg-accent);
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-icon-box-primary { background: rgba(255, 255, 255, 0.22); color: #fff; }

.btn-danger {
  background: var(--surface);
  border-color: var(--amix-red);
  color: var(--amix-red);
}
.btn-danger:hover { background: var(--bg-danger); }

form button { width: 100%; margin-top: 22px; background: var(--amix-red); border-color: var(--amix-red-dark); color: #fff; }

.error { color: var(--text-danger); font-size: 13px; margin-top: 8px; }

/* ---------- Topbar (non-sidebar pages) ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-logo { height: 32px; }

.topbar-links { display: flex; gap: 22px; align-items: center; }

.logout-link { color: var(--text-muted); font-size: 13px; text-decoration: none; }

.container { max-width: 900px; margin: 28px auto; padding: 0 16px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 12px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 36px;
  width: 230px;
  color: var(--text-muted);
  background: var(--surface);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.search-box:focus-within { border-color: var(--amix-red); box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12); }
.search-box svg { flex-shrink: 0; }
.search-box input {
  border: none;
  outline: none;
  font-size: 13px;
  width: 100%;
  height: 100%;
  background: transparent;
  color: var(--text);
}

.muted { color: var(--text-muted); font-size: 14px; }

.client-list { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }

#client-list {
  border: none;
  background: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.client-row-wrap {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease), border-color var(--ease), transform var(--ease);
}
.client-row-wrap:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.client-row-wrap.active {
  border-left: 3px solid var(--text-success);
}
#client-list .client-row {
  border-bottom: none;
  border-radius: 0 9px 9px 0;
  background: transparent;
}

.client-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}

.client-row:last-child { border-bottom: none; }

.avatar-ring {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  padding: 2px;
  flex-shrink: 0;
  background: var(--border-strong);
}
.avatar-ring.on { background: var(--text-success); }

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: var(--bg-danger);
  color: var(--amix-red-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.client-info { flex: 1; min-width: 0; }
.client-name { font-size: 14px; font-weight: 600; margin: 0; }
.client-link { color: var(--text); text-decoration: none; }
.client-link:hover { color: var(--amix-red); text-decoration: underline; }
.client-path { font-size: 12px; color: var(--text-muted); margin: 0; font-family: var(--font-mono); }

.badge { font-size: 11px; padding: 3px 10px; border-radius: var(--radius-full); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-active { background: var(--bg-success); color: var(--text-success); box-shadow: 0 0 0 1px rgba(21, 115, 71, 0.12); }
.badge-suspended { background: var(--bg-warning); color: var(--text-warning); box-shadow: 0 0 0 1px rgba(146, 89, 10, 0.12); }
.badge-danger { background: var(--bg-danger); color: var(--text-danger); box-shadow: 0 0 0 1px rgba(163, 4, 16, 0.12); }

.action-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

.row-actions {
  display: flex;
  gap: 2px;
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  padding: 3px;
  flex-shrink: 0;
}

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text);
  transition: background var(--ease), color var(--ease);
}
.icon-btn:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.icon-btn-danger:hover { color: var(--text-danger); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 15, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
  border: none;
  position: relative;
}
.modal::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--accent-grad);
}

.modal-title { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; }

.modal-wide { max-width: 640px; }

.form-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--amix-red);
  margin: 18px 0 8px;
}
.form-section-title:first-of-type { margin-top: 4px; }

.form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px 14px;
  background: var(--surface-1);
}
.form-section label:first-child { margin-top: 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 13px; color: var(--text); }
.checkbox-label input { width: auto; accent-color: var(--amix-red); }

.row { display: flex; gap: 8px; }
.modal-actions { margin-top: 22px; }
.modal-actions .btn { flex: 1; }

.urls-body p { font-size: 12px; font-family: var(--font-mono); word-break: break-all; margin: 0 0 10px; }
.urls-body .url-label { font-family: var(--font-sans); color: var(--text-muted); font-size: 12px; margin: 0 0 2px; }
.url-copy-line { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.url-copy-line code { font-size: 12px; font-family: var(--font-mono); word-break: break-all; flex: 1; }

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  max-width: 480px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.settings-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-grad);
  opacity: 0.85;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
select:focus { outline: none; border-color: var(--amix-red); box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12); }

#settings-msg, #fw-msg, #pw-msg { margin-top: 14px; font-size: 13px; padding: 9px 11px; border-radius: var(--radius-sm); }
.ok { background: var(--bg-success); color: var(--text-success); }
.err { background: var(--bg-danger); color: var(--text-danger); }

.status-banner { padding: 12px 16px; border-radius: var(--radius-md); font-size: 14px; margin-bottom: 16px; font-weight: 500; }
.status-banner.ok { background: var(--bg-success); color: var(--text-success); }
.status-banner.err { background: var(--bg-danger); color: var(--text-danger); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: box-shadow var(--ease), transform var(--ease);
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.metric-label { font-size: 13px; color: var(--text-muted); margin: 0 0 6px; }
.metric-value { font-size: 24px; font-weight: 600; margin: 0; font-family: var(--font-mono); }

.fw-row-status { display: flex; gap: 8px; align-items: center; }

.hidden { display: none; }

.back-link { display: inline-block; margin-bottom: 16px; color: var(--text-muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--amix-red); }

.detail-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.detail-title { font-size: 20px; font-weight: 600; margin: 0; }

.player-wrap { background: #000; border-radius: var(--radius-md); overflow: hidden; aspect-ratio: 16 / 9; max-width: 720px; }
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.kv-list { font-size: 13px; }
.kv-list .kv-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv-list .kv-row:last-child { border-bottom: none; }
.kv-list .kv-key { color: var(--text-muted); }
.kv-list .kv-val { font-weight: 600; text-align: right; font-family: var(--font-mono); }

.detail-actions { margin-top: 20px; flex-wrap: wrap; }
.detail-actions .btn { flex: 0 0 auto; }

.console-frame {
  position: relative;
  background: #0a0a0a;
  border-radius: var(--radius-lg);
  aspect-ratio: 16 / 9;
  max-width: 720px;
  overflow: hidden;
}

.console-frame video { width: 100%; height: 100%; display: block; object-fit: contain; background: #0a0a0a; }

.console-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #6b7280;
  font-size: 13px;
  pointer-events: none;
}
.console-empty i { font-size: 32px; color: #4b5563; }

.console-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.console-name { font-size: 15px; font-weight: 600; margin: 0; color: #fff; }
.console-path { font-size: 11px; font-family: var(--font-mono); margin: 0; color: #aaa; }

.console-live {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: #3a1a1a;
  color: #f87171;
  white-space: nowrap;
  font-weight: 500;
}
.console-live.on { background: #143324; color: #4ade80; }

.console-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  padding: 24px 12px 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.console-stat { display: flex; flex-direction: column; }
.console-stat-label { font-size: 10px; color: #9aa3b2; }
.console-stat-val { font-size: 13px; font-weight: 600; color: #fff; font-family: var(--font-mono); }

.container-wide { max-width: 1080px; }

.breadcrumb { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--amix-red); }

.stream-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

.back-circle {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text);
  flex-shrink: 0; transition: background var(--ease);
}
.back-circle:hover { background: var(--surface-2); }

.stream-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--bg-danger); color: var(--text-danger);
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}

.stream-title-block { flex: 1; min-width: 160px; }
.stream-title { font-size: 20px; font-weight: 600; margin: 0; }
.stream-subtitle { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); margin: 0; }

.live-pill {
  font-size: 11px; padding: 4px 11px; border-radius: var(--radius-full); background: var(--bg-warning); color: var(--text-warning);
  white-space: nowrap; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.live-pill.on { background: var(--bg-success); color: var(--text-success); box-shadow: 0 0 0 3px rgba(21, 115, 71, 0.14); }

.stream-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stream-actions .btn { height: 34px; padding: 0 13px; font-size: 13px; }

.tabs-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab-btn {
  background: none; border: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; border-bottom: 2px solid transparent; padding: 9px 12px; margin-right: 4px;
  font-size: 14px; font-family: inherit; color: var(--text-muted); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: color var(--ease), border-color var(--ease), background var(--ease);
}
.tab-btn svg { flex-shrink: 0; }
.tab-btn:hover { color: var(--text); background: var(--surface-1); }
.tab-btn.active { color: var(--amix-red); border-bottom-color: var(--amix-red); font-weight: 600; background: var(--bg-danger); }

.tab-panel.hidden { display: none; }

.source-pills { display: flex; gap: 8px; margin-bottom: 10px; }
.source-pill {
  font-size: 12px; padding: 4px 11px; border-radius: var(--radius-full); border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer; background: var(--surface); transition: background var(--ease), color var(--ease);
}
.source-pill.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.player-card { background: #000; border-radius: var(--radius-md); overflow: hidden; position: relative; aspect-ratio: 16/9; }
.player-card video { width: 100%; height: 100%; display: block; }
.player-card iframe { position: absolute; inset: 0; }

.url-copy-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px;
  padding: 9px 11px; background: var(--surface-1); border-radius: var(--radius-sm);
}
.url-copy-row code { font-size: 12px; word-break: break-all; font-family: var(--font-mono); }

.copy-btn {
  border: none;
  background: var(--bg-accent);
  color: var(--text-accent);
  cursor: pointer;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter var(--ease);
}
.copy-btn:hover { filter: brightness(0.95); }
.copy-btn span { display: none; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
.stat-card { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 13px 14px; background: var(--surface); transition: box-shadow var(--ease), transform var(--ease); }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label { font-size: 12px; color: var(--text-muted); margin: 0 0 4px; display: flex; align-items: center; gap: 4px; }
.stat-value { font-size: 18px; font-weight: 600; margin: 0; font-family: var(--font-mono); }

.stat-card-icon { display: flex; align-items: center; gap: 10px; }
.stat-card-icon svg { flex-shrink: 0; color: var(--text-muted); }
.stat-card-icon .stat-label { margin: 0; font-size: 10px; }
.stat-card-icon .stat-value { font-size: 15px; }

.overview-media-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  align-items: stretch;
}
.overview-media-row .player-card { margin-bottom: 0; }
.stats-sidebar { display: flex; flex-direction: column; gap: 8px; }
.stats-sidebar .stat-card { flex: 1; display: flex; align-items: center; }

.stats-sidebar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats-sidebar-grid .stat-card { flex: none; border-left-width: 3px; }
.spark { width: 100%; height: 16px; display: block; margin-top: 4px; }

@media (max-width: 640px) {
  .overview-media-row { grid-template-columns: 1fr; }
}

.section-label { font-size: 13px; font-weight: 600; margin: 22px 0 9px; }

.url-list { display: flex; flex-direction: column; gap: 6px; }
.url-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 9px 11px; background: var(--surface); }
.url-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--bg-accent); color: var(--text-accent); flex-shrink: 0; }
.url-tag-hls { background: var(--bg-danger); color: var(--text-danger); }
.url-tag-srt { background: var(--bg-success); color: var(--text-success); }
.url-tag-rtmp { background: var(--bg-warning); color: var(--text-warning); }
.url-tag-passphrase { background: var(--surface-1); color: var(--text-secondary); }
.url-tag-url, .url-tag-iframe, .url-tag-host, .url-tag-streamid, .url-tag-server, .url-tag-key { background: var(--surface-1); color: var(--text-secondary); }
.url-row code { font-size: 12px; flex: 1; word-break: break-all; font-family: var(--font-mono); }

.timeline-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }

.viewers-summary { font-size: 13px; margin-bottom: 12px; }

.top-countries { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.country-row { display: flex; align-items: center; gap: 10px; }
.country-name { width: 90px; font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.country-bar-track { flex: 1; height: 8px; background: var(--surface-1); border-radius: var(--radius-full); overflow: hidden; }
.country-bar-fill { height: 100%; background: var(--amix-red); border-radius: var(--radius-full); }
.country-count { width: 30px; text-align: right; font-size: 12px; font-weight: 600; flex-shrink: 0; font-family: var(--font-mono); }

.viewers-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.viewers-filters { display: flex; gap: 8px; }
.viewers-filters select { height: 32px; font-size: 12px; width: auto; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.viewers-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.viewers-table th { text-align: left; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 9px 11px; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.viewers-table td { padding: 9px 11px; border-bottom: 1px solid var(--border); }
.viewers-table tr:last-child td { border-bottom: none; }
.viewers-table tbody tr { transition: background var(--ease); }
.viewers-table tbody tr:hover { background: var(--surface-1); }

.pill-filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.pill-filter-btn {
  height: 32px; padding: 0 14px; border-radius: var(--radius-full); border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text);
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.pill-filter-btn.active { background: var(--amix-red); border-color: var(--amix-red-dark); color: #fff; }

.sessions-table td { font-size: 12px; }
.session-id { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); word-break: break-all; }
.client-ua { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; color: var(--text-secondary); }

.url-block-title { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); margin: 0; font-weight: 600; }
.url-host-line { font-size: 12px; color: var(--text-secondary); margin: 0 0 14px; }
.url-host-line code { color: var(--text); font-family: var(--font-mono); }

.url-section-divider { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid var(--border); font-weight: 600; }

.split-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.split-row .url-row { margin: 0; }
.split-row:empty { display: none; margin: 0; }

.url-footer-note { font-size: 12px; color: var(--text-secondary); margin: 16px 0 0; }

.header-stats { display: flex; gap: 18px; }
.header-stat { display: flex; flex-direction: column; align-items: flex-start; }
.header-stat-label { font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.header-stat-value { font-size: 15px; font-weight: 600; font-family: var(--font-mono); }

.plain-icons { display: flex; align-items: center; gap: 14px; }
.plain-icon-btn {
  border: none;
  background: none;
  padding: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--ease);
}
.plain-icon-btn:hover { color: var(--text); }
.plain-icon-btn-danger:hover { color: var(--amix-red); }

.mon-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

.mon-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 15px; background: var(--surface); box-shadow: var(--shadow-sm); transition: box-shadow var(--ease), transform var(--ease); }
.mon-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.mon-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.mon-card-header svg { flex-shrink: 0; color: var(--text-muted); }

.mon-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; }
.mon-row .mon-val { font-weight: 600; font-family: var(--font-mono); }
.mon-val-ok { color: var(--text-success); }
.mon-val-danger { color: var(--text-danger); }

.graph-toolbar { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; }

.graph-stats-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; font-family: var(--font-mono); }
.graph-stats-table th { text-align: right; color: var(--text-muted); font-weight: 400; padding: 3px 8px; font-family: var(--font-sans); }
.graph-stats-table th:first-child, .graph-stats-table td:first-child { text-align: left; }
.graph-stats-table td { text-align: right; padding: 3px 8px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }

.fw-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 17px;
  margin: 12px 0 16px;
  background: var(--surface);
}
.fw-status-card.open { border-left-color: var(--text-success); }
.fw-status-card.closed { border-left-color: var(--amix-red); }

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-size: 11px;
  line-height: 1;
  transition: color var(--ease);
}
.nav-link svg { flex-shrink: 0; }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--amix-red); border-bottom-color: var(--amix-red); font-weight: 600; }

.fw-row { border-left: 3px solid var(--border); }
.fw-row.open { border-left-color: var(--text-success); }
.fw-row.closed { border-left-color: var(--amix-red); }

.fw-switch {
  width: 34px;
  height: 19px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  position: relative;
  flex-shrink: 0;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background var(--ease);
}
.fw-switch.on { background: var(--text-success); cursor: default; }
.fw-switch .knob {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left var(--ease);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.fw-switch.on .knob { left: 17px; }

.flag-icon { width: 16px; height: 12px; object-fit: cover; border-radius: 2px; vertical-align: middle; margin-right: 4px; border: 1px solid rgba(0, 0, 0, 0.1); }

.push-form-label { font-size: 12px; color: var(--text-muted); margin: 6px 0 8px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

.push-platform-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 14px; }
.push-platform-btn {
  height: 56px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}
.push-platform-btn:hover { border-color: var(--border-strong); }
.push-platform-btn.active { border-color: var(--amix-red); color: var(--text); font-weight: 600; background: var(--bg-danger); }

.push-switch {
  width: 30px;
  height: 17px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  position: relative;
  flex-shrink: 0;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background var(--ease);
}
.push-switch.on { background: var(--text-success); }
.push-switch .knob {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left var(--ease);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.push-switch.on .knob { left: 15px; }

.login-tabs { display: flex; background: rgba(255, 255, 255, 0.08); border-radius: var(--radius-md); padding: 3px; margin-bottom: 18px; }
.login-tab {
  flex: 1;
  text-align: center;
  font-size: 13px;
  padding: 8px 0;
  border-radius: 7px;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background var(--ease), color var(--ease);
}
.login-tab.active { background: rgba(255, 255, 255, 0.14); font-weight: 600; color: #fff; box-shadow: var(--shadow-sm); }
.login-form.hidden { display: none; }

.mtx-table { border-collapse: collapse; }
.mtx-row td:first-child { border-left: 3px solid transparent; padding-left: 15px; }
.mtx-row.live td:first-child { border-left: 3px solid var(--text-success); }
.mtx-table code { font-size: 12px; font-weight: 600; font-family: var(--font-mono); }

.proto-tag { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; color: var(--text-secondary); margin-right: 3px; }

.mtx-accent-card { border-left: 3px solid var(--amix-red); }
.mtx-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: var(--radius-full); background: var(--bg-danger); color: var(--text-danger); margin-left: 8px; vertical-align: middle; }

/* ---------- Sidebar layout (admin pages) ----------
   Collapsed to an icon-only rail by default; hovering it expands it as a
   floating overlay (fixed position, doesn't push page content) and it
   snaps back to the rail the moment the mouse leaves. */
:root { --sidebar-rail-w: 72px; --sidebar-open-w: 232px; }

body:has(.sidebar) { min-height: 100vh; }

.sidebar {
  width: var(--sidebar-rail-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.18);
  z-index: 40;
  transition: width var(--ease-spring);
}
.sidebar:hover { width: var(--sidebar-open-w); }

.sidebar .brand {
  padding: 22px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 11px;
  transition: padding var(--ease);
}
.sidebar:not(:hover) .brand { padding: 22px 0; justify-content: center; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--sidebar-active-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: var(--glow-red-sm);
}
.brand-mark:has(img) { background: rgba(255, 255, 255, 0.08); padding: 4px; box-shadow: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text { line-height: 1.28; white-space: nowrap; flex-shrink: 0; opacity: 1; transition: opacity var(--ease); }
.brand-text b { font-size: 13.5px; display: block; font-weight: 700; color: var(--sidebar-text-strong); letter-spacing: -0.01em; }
.brand-text span { display: block; font-size: 10px; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 1px; }
/* Collapsed rail: fully hide labels rather than letting them clip mid-word -
   only icons (and the always-visible brand mark) show until hovered. */
.sidebar:not(:hover) .brand-text { opacity: 0; pointer-events: none; }

.sidebar nav { padding: 16px 10px; flex: 1; }
.nav-section-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.32);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 16px 10px 7px;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--ease);
}
.nav-section-label:first-child { padding-top: 4px; }
.sidebar:not(:hover) .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  border-left: none;
  white-space: nowrap;
  transition: background var(--ease), color var(--ease), transform var(--ease), box-shadow var(--ease), padding var(--ease), justify-content var(--ease);
}
.nav-item svg { flex-shrink: 0; }
.nav-item span { flex-shrink: 0; opacity: 1; transition: opacity var(--ease); }
.sidebar:not(:hover) .nav-item { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
.sidebar:not(:hover) .nav-item span { opacity: 0; pointer-events: none; width: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); transform: translateX(1px); }
.nav-item.active {
  background: var(--sidebar-active-grad);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--glow-red-sm);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 11px;
  color: var(--sidebar-text);
}
.sidebar-footer .nav-item { padding: 7px 8px; margin: 0 -8px 6px; }
.sidebar:not(:hover) .sidebar-footer .nav-item { padding: 7px 0; margin: 0 0 6px; gap: 0; }
.sidebar-footer .nav-item:hover { color: var(--sidebar-text-strong); }
.sidebar-footer p { margin: 0; display: flex; align-items: center; color: var(--sidebar-text); white-space: nowrap; }
.sidebar:not(:hover) .sidebar-footer p { justify-content: center; }
.footer-label { opacity: 1; transition: opacity var(--ease); }
.sidebar:not(:hover) .footer-label { opacity: 0; pointer-events: none; width: 0; }
.server-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade95;
  display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 6px #4ade95;
  transition: margin var(--ease);
}
.sidebar:not(:hover) .server-dot { margin-right: 0; }

@media (prefers-reduced-motion: no-preference) {
  .server-dot { animation: server-pulse 2.4s ease-in-out infinite; }
}
@keyframes server-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

body:has(.sidebar) main.container, body:has(.sidebar) main.container-wide {
  margin-left: var(--sidebar-rail-w);
  min-width: 0;
  padding: 26px 30px;
  max-width: none;
}

@media (max-width: 900px) {
  /* No hover on touch, and screen width is precious - drop the rail/overlay
     behavior entirely and go back to a normal, always-fully-visible horizontal bar. */
  body:has(.sidebar) { display: flex; flex-direction: column; }
  .sidebar, .sidebar:hover { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; }
  .sidebar .brand, .sidebar:not(:hover) .brand { border-bottom: none; border-right: 1px solid var(--sidebar-border); padding: 14px 18px; justify-content: flex-start; }
  .brand-text, .sidebar:not(:hover) .brand-text { opacity: 1; pointer-events: auto; }
  .sidebar nav { display: flex; padding: 8px; }
  .nav-section-label { display: none; }
  .nav-item, .sidebar:not(:hover) .nav-item { white-space: nowrap; justify-content: flex-start; padding: 9px 12px; gap: 10px; }
  .nav-item span, .sidebar:not(:hover) .nav-item span { opacity: 1; pointer-events: auto; width: auto; }
  .sidebar-footer { display: none; }
  body:has(.sidebar) main.container, body:has(.sidebar) main.container-wide { margin-left: 0; }
}

.mtx-bitrate-track { height: 3px; background: var(--surface-1); border-radius: 2px; overflow: hidden; width: 70px; }
.mtx-bitrate-fill { height: 100%; background: var(--text-success); }

.mtx-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 15px 16px; border-left: 3px solid var(--border); box-shadow: var(--shadow-sm); transition: box-shadow var(--ease), transform var(--ease); }
.mtx-stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.mtx-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 6px; font-weight: 600; }
.mtx-stat-value { font-size: 22px; font-weight: 700; margin: 0; font-family: var(--font-mono); }
.mtx-stat-sub { font-size: 11px; color: var(--text-secondary); margin: 4px 0 0; }
.mtx-stat-green { border-left-color: var(--text-success); }
.mtx-stat-green .mtx-stat-sub { color: var(--text-success); }
.mtx-stat-pink { border-left-color: #d4537e; }
.mtx-stat-pink .mtx-stat-sub { color: #d4537e; }
.mtx-stat-blue { border-left-color: var(--text-accent); }
.mtx-stat-blue .mtx-stat-sub { color: var(--text-accent); }
.mtx-stat-amber { border-left-color: var(--text-warning); }
.mtx-stat-amber .mtx-stat-sub { color: var(--text-warning); }
.mtx-stat-gray { border-left-color: var(--border); }

.mtx-path-url { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin: 2px 0 0; word-break: break-all; }
