:root {
  --amix-red: #e30613;
  --amix-red-dark: #a30410;
  --bg: #f7f7f7;
  --border: #e3e3e3;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 36px;
  width: 340px;
  text-align: center;
}

.login-logo { max-width: 220px; margin-bottom: 16px; }

.login-card h1 { font-size: 16px; font-weight: 500; margin: 0 0 20px; }

label { display: block; font-size: 13px; color: var(--text-muted); margin: 12px 0 4px; text-align: left; }

input[type="text"], input[type="password"] {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}

.btn:hover { background: #f0f0f0; }

.btn-primary {
  background: var(--amix-red);
  border-color: var(--amix-red-dark);
  color: #fff;
}

.btn-primary:hover { background: var(--amix-red-dark); }

.btn-danger {
  background: #fff;
  border-color: var(--amix-red);
  color: var(--amix-red);
}

form button { width: 100%; margin-top: 20px; }

.error { color: var(--amix-red-dark); font-size: 13px; margin-top: 8px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.topbar-logo { height: 32px; }

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

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

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

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

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

.client-list { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }

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

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

.avatar-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 2px;
  flex-shrink: 0;
  background: var(--border);
}
.avatar-ring.on { background: #22c55e; }

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fde8e8;
  color: var(--amix-red-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  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: 500; 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: monospace; }

.badge { font-size: 12px; padding: 3px 10px; border-radius: 6px; }
.badge-active { background: #e5f6ec; color: #1a7a43; }
.badge-suspended { background: #fdf2e0; color: #a3660b; }

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

.row-actions {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 8px;
  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;
}
.icon-btn:hover { background: #fff; }
.icon-btn-danger:hover { color: var(--amix-red-dark); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

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

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px 28px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.checkbox-label { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 13px; color: var(--text); }
.checkbox-label input { width: auto; }

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

.urls-body p { font-size: 12px; font-family: monospace; word-break: break-all; margin: 0 0 10px; }
.urls-body .url-label { font-family: -apple-system, sans-serif; color: var(--text-muted); font-size: 12px; margin: 0 0 2px; }

.settings-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 480px;
}

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

select {
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

#settings-msg, #fw-msg { margin-top: 14px; font-size: 13px; padding: 8px 10px; border-radius: 6px; }
.ok { background: #e5f6ec; color: #1a7a43; }
.err { background: #fdeaea; color: var(--amix-red-dark); }

.status-banner { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.status-banner.ok { background: #e5f6ec; color: #1a7a43; }
.status-banner.err { background: #fdeaea; color: var(--amix-red-dark); }

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

.metric-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

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

.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: 500; margin: 0; }

.player-wrap { background: #000; border-radius: 8px; 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: 6px 0; border-bottom: 0.5px 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: 500; text-align: right; }

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

.console-frame {
  position: relative;
  background: #0a0a0a;
  border-radius: 12px;
  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: #666;
  font-size: 13px;
  pointer-events: none;
}
.console-empty i { font-size: 32px; color: #444; }

.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: 500; margin: 0; color: #fff; }
.console-path { font-size: 11px; font-family: monospace; margin: 0; color: #aaa; }

.console-live {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #3a1a1a;
  color: #f87171;
  white-space: nowrap;
}
.console-live.on { background: #1a3a2a; 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: #999; }
.console-stat-val { font-size: 13px; font-weight: 500; color: #fff; }

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

.breadcrumb { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; }
.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: 16px; flex-wrap: wrap; }

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

.stream-icon {
  width: 36px; height: 36px; border-radius: 8px; 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: 500; margin: 0; }
.stream-subtitle { font-size: 12px; color: var(--text-muted); font-family: monospace; margin: 0; }

.live-pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--bg-warning); color: var(--text-warning);
  white-space: nowrap;
}
.live-pill.on { background: var(--bg-success); color: var(--text-success); }

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

.tabs-nav { display: flex; gap: 4px; border-bottom: 0.5px solid var(--border); margin-bottom: 16px; }
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 4px; margin-right: 20px;
  font-size: 14px; color: var(--text-muted); cursor: pointer;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--amix-red); font-weight: 500; }

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

.source-pills { display: flex; gap: 8px; margin-bottom: 10px; }
.source-pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 0.5px solid var(--border); color: var(--text-muted);
}
.source-pill.active { background: var(--text); color: #fff; border-color: var(--text); }

.player-card { background: #000; border-radius: 10px; overflow: hidden; position: relative; aspect-ratio: 16/9; }
.player-card video { width: 100%; height: 100%; display: block; }

.url-copy-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px;
  padding: 8px 10px; background: var(--surface-1, #f5f5f5); border-radius: 6px;
}
.url-copy-row code { font-size: 12px; word-break: break-all; }

.copy-btn { border: none; background: none; cursor: pointer; font-size: 14px; flex-shrink: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
.stat-card { border: 0.5px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.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: 500; margin: 0; }

.section-label { font-size: 13px; font-weight: 500; margin: 20px 0 8px; }

.url-list { display: flex; flex-direction: column; gap: 6px; }
.url-row { display: flex; align-items: center; gap: 10px; border: 0.5px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.url-tag { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 4px; background: var(--bg-accent); color: var(--text-accent); flex-shrink: 0; }
.url-row code { font-size: 12px; flex: 1; word-break: break-all; }

.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, #eee); border-radius: 4px; overflow: hidden; }
.country-bar-fill { height: 100%; background: var(--amix-red); border-radius: 4px; }
.country-count { width: 30px; text-align: right; font-size: 12px; font-weight: 500; flex-shrink: 0; }

.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: 0.5px solid var(--border); border-radius: 8px; }
.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; padding: 8px 10px; border-bottom: 0.5px solid var(--border); }
.viewers-table td { padding: 8px 10px; border-bottom: 0.5px solid var(--border); }
.viewers-table tr:last-child td { border-bottom: none; }

.pill-filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.pill-filter-btn {
  height: 32px; padding: 0 14px; border-radius: 999px; border: 0.5px solid var(--border);
  background: #fff; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--text);
}
.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: monospace; 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; }
.url-host-line { font-size: 12px; color: var(--text-secondary); margin: 0 0 14px; }
.url-host-line code { color: var(--text); }

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

.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: 500; }

.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;
}
.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: 0.5px solid var(--border); border-radius: 12px; padding: 14px; background: #fff; }

.mon-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 500;
  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: 4px 0; }
.mon-row .mon-val { font-weight: 500; }
.mon-val-ok { color: #1a7a43; }
.mon-val-danger { color: var(--amix-red-dark); }

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

.graph-stats-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.graph-stats-table th { text-align: right; color: var(--text-muted); font-weight: 400; padding: 3px 8px; }
.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; }
