:root {
  --bg: #0e1419;
  --bg-elev: #161e26;
  --bg-soft: #1c2732;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3d9a7a;
  --accent-hover: #4db38f;
  --danger: #d46363;
  --warn: #c9a227;
  --radius: 12px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(61, 154, 122, 0.18), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(80, 120, 180, 0.12), transparent 55%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #04120c;
  transition: background 0.15s ease, transform 0.1s ease;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:active, .btn:active { transform: translateY(1px); }
button.secondary, .btn.secondary {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
}
button.danger, .btn.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(61, 154, 122, 0.45);
  border-color: var(--accent);
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field { margin-bottom: 14px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 20, 25, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.wrap {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-box {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-box h1 {
  font-size: 24px;
  margin-bottom: 6px;
}
.login-box .sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 22px;
}
.error {
  background: rgba(212, 99, 99, 0.12);
  border: 1px solid rgba(212, 99, 99, 0.35);
  color: #f0b0b0;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
}
.ok-msg {
  background: rgba(61, 154, 122, 0.12);
  border: 1px solid rgba(61, 154, 122, 0.35);
  color: #a8e0cc;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.tile {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.12s ease;
  width: 100%;
}
.tile:hover {
  border-color: rgba(61, 154, 122, 0.55);
  transform: translateY(-2px);
}
.tile h3 { font-size: 16px; margin-bottom: 6px; }
.tile p { color: var(--muted); font-size: 13px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.section-head h2 { font-size: 22px; }
.crumb { color: var(--muted); font-size: 14px; margin-bottom: 10px; }

.player-shell {
  position: relative;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
  max-height: 70vh;
}
.player-shell video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}
.player-watermark {
  position: absolute;
  right: 12px;
  bottom: 48px;
  opacity: 0.35;
  font-size: 12px;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 1px 3px #000;
  z-index: 3;
}
.player-cover {
  position: absolute;
  inset: 0;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 15px;
  z-index: 5;
  text-align: center;
  padding: 20px;
}
.player-shell.covered .player-cover { display: flex; }
.player-shell.covered video { visibility: hidden; }

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 65px);
}
.admin-nav {
  border-right: 1px solid var(--line);
  background: rgba(22, 30, 38, 0.7);
  padding: 18px 12px;
}
.admin-nav button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  margin-bottom: 6px;
}
.admin-nav button.active,
.admin-nav button:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--line);
}
.admin-main { padding: 22px; }
.panel { display: none; }
.panel.active { display: block; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; background: rgba(0,0,0,0.15); }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.on { background: rgba(61,154,122,0.18); color: #8fd9be; }
.badge.off { background: rgba(148,163,184,0.15); color: var(--muted); }
.badge.warn { background: rgba(201,162,39,0.18); color: #e6cb72; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}
.form-stack {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
}
.inline-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.inline-actions button { padding: 7px 10px; font-size: 12px; }

.dot-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 0 3px rgba(61,154,122,0.2);
}

.empty {
  color: var(--muted);
  padding: 28px 8px;
  text-align: center;
}

@media (max-width: 800px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .admin-nav button { width: auto; white-space: nowrap; }
  .form-row { grid-template-columns: 1fr; }
}
