:root {
  --ai-bg: #000000;
  --ai-bg-elev: #0a0a0a;
  --ai-panel: #111111;
  --ai-panel-2: #171717;
  --ai-line: rgba(255, 255, 255, 0.12);
  --ai-line-strong: rgba(255, 255, 255, 0.22);
  --ai-text: #ffffff;
  --ai-muted: #a3a3a3;
  --ai-accent: #ffffff;
  --ai-success: #34d399;
  --ai-danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --player-w: 704px;
  --player-h: 488px;
  --font: "Outfit", system-ui, sans-serif;
  --font-display: "Syne", "Outfit", system-ui, sans-serif;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 255, 255, 0.06), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 255, 255, 0.04), transparent 50%),
    var(--ai-bg);
  background-attachment: fixed;
  color: var(--ai-text);
  font-family: var(--font);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

a { color: var(--ai-text); text-decoration: none; }
.muted { color: var(--ai-muted); margin: 0.35rem 0 0; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  display: block;
  height: auto;
  width: 180px;
  opacity: 0.95;
}
.brand-logo-sm {
  width: 128px;
}
.brand-product {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ai-bg);
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--ai-text);
}

.btn {
  appearance: none;
  border: 1px solid var(--ai-line-strong);
  background: transparent;
  color: var(--ai-text);
  border-radius: 0.65rem;
  padding: 0.55rem 1rem;
  font: 600 0.9rem var(--font);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--ai-text);
  border-color: var(--ai-text);
  color: var(--ai-bg);
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.92;
}
.btn-block { width: 100%; }
.btn-ghost:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}
.btn-ghost.active {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.12);
}
.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--ai-danger);
}

.alert {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert-error {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.35);
}
.alert-ok {
  background: rgba(52, 211, 153, 0.12);
  color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-wrap {
  width: min(440px, 100%);
}
.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-brand .brand {
  justify-content: center;
}
.login-subtitle {
  margin: 1rem 0 0;
  color: var(--ai-muted);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.login-card {
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-form, .admin-form {
  display: grid;
  gap: 1rem;
}
.login-form label, .admin-form label, .inline-form label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ai-muted);
}
input, select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ai-line);
  background: var(--ai-bg-elev);
  color: var(--ai-text);
  padding: 0.8rem 0.9rem;
  font: 1rem var(--font);
}
input::placeholder { color: #737373; }
input:focus, select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}
select option {
  background: #111;
  color: #fff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--ai-line);
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ai-text);
}
.topbar-divider {
  width: 1px;
  height: 1.1rem;
  background: var(--ai-line-strong);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.user-chip {
  color: var(--ai-muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-right: 0.25rem;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
  min-height: calc(100vh - 74px);
}
.channel-panel, .player-panel, .admin-card {
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.channel-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.channel-btn {
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ai-line);
  background: var(--ai-panel-2);
  color: var(--ai-text);
  padding: 0.85rem 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font: 600 0.95rem var(--font);
}
.channel-btn:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.05);
}
.channel-btn.active {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.1);
}
.badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
}
.badge-live {
  background: rgba(52, 211, 153, 0.15);
  color: var(--ai-success);
}
.badge-off {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ai-muted);
}

.player-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.player-stage {
  display: grid;
  place-items: center;
  min-height: 320px;
}
.player-shell {
  width: var(--player-w);
  height: var(--player-h);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #050505;
  border: 1px solid var(--ai-line);
  position: relative;
}
.player-shell.is-empty #player { display: none; }
.player-shell:not(.is-empty) #player-placeholder { display: none; }
#player, .op-wrapper, .op-ratio, video {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
}
.player-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #737373;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
}

.admin-layout {
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
  max-width: 980px;
}
.admin-form {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
.users-table th, .users-table td {
  border-bottom: 1px solid var(--ai-line);
  padding: 0.75rem 0.4rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}
.actions-cell {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.inline-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.inline-form input {
  width: auto;
  min-width: 140px;
}

@media (max-width: 860px) {
  .home-layout {
    grid-template-columns: 1fr;
  }
}

.monitor-layout {
  padding: 1.25rem;
}
.monitor-hint {
  margin: 0 0 1rem;
}
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.monitor-card {
  background: var(--ai-panel);
  border: 1px solid var(--ai-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.monitor-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--ai-line);
  font-weight: 600;
}
.monitor-player-shell {
  position: relative;
  aspect-ratio: 16 / 11;
  background: #050505;
}
.monitor-player-shell .op-wrapper,
.monitor-player-shell .op-ratio,
.monitor-player-shell video,
.monitor-player-shell > div:first-child {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
}
.monitor-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #737373;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  background: #050505;
}
