:root {
  --bg: #f1f7f6;
  --bg-soft: #f7fbfd;
  --panel: #ffffff;
  --panel-tint: #f8fcff;
  --ink: #1e3447;
  --muted: #658097;
  --border: #d9e8f2;
  --shadow: 0 4px 16px rgba(64, 116, 149, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 0% 0%, #eef8ff 0%, transparent 45%),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(231, 244, 252, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  max-width: 1420px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #153449;
}

.nav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-pills a {
  text-decoration: none;
  font-weight: 600;
  color: #214860;
  background: #f5fbff;
  border: 1px solid #cfe4f3;
  border-radius: 999px;
  padding: 8px 12px;
  line-height: 1;
  transition: all 0.16s ease;
}

.nav-pills a:hover {
  background: #e7f4fd;
  border-color: #b8d9ee;
  color: #1a3d54;
}

.user-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid #cfe4f3;
  background: #f9fdff;
  color: #2a5268;
  font-size: 13px;
  font-weight: 600;
}

.logout-form {
  margin: 0;
}

.page-wrap {
  padding: 12px 14px 18px;
}

.content {
  max-width: 1420px;
  margin: 0 auto;
}

h1 {
  margin: 8px 0 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1b3a4f;
}

.live-shell {
  margin-top: 2px;
}

.muted { color: var(--muted); }

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

.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(64, 116, 149, 0.14);
}

.tile img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #d9ebf7;
  border-bottom: 1px solid #e5f0f7;
}

.tile .meta {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--panel-tint);
}

.tile .meta strong {
  font-size: 13px;
  line-height: 1.2;
  color: #173a50;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile .meta .clock {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(13, 34, 50, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.hidden { display: none; }

.modal-inner {
  width: min(980px, 96vw);
  background: #f3fbff;
  border: 1px solid #cde3f3;
  color: #173449;
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 20px 40px rgba(31, 70, 95, 0.22);
}

.stream-large {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  background: #cde5f3;
  border-radius: 10px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th,
.table td {
  border-bottom: 1px solid #e7f1f7;
  padding: 9px 10px;
  font-size: 13px;
  text-align: left;
}

.table thead th {
  background: #f0f8fd;
  color: #2a4f66;
  font-weight: 700;
}

.badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.ok { background: #def5e7; color: #17643e; }
.off { background: #eef3f7; color: #546779; }

.actions {
  margin: 8px 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions input,
.actions select {
  border: 1px solid #cfe2ef;
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  min-height: 36px;
}

.btn {
  border: 1px solid #8bc8ee;
  background: #9dd2f2;
  color: #12374f;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn:hover {
  background: #86c7ee;
  border-color: #6cb9e7;
}

.btn.secondary {
  background: #ebf8f2;
  border-color: #c7ead7;
  color: #245441;
}

.btn.secondary:hover {
  background: #ddf1e7;
  border-color: #b0e0c8;
}

.btn.secondary.active {
  background: #cdeedb;
  border-color: #9fd6bc;
}

.summary {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.event-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.event-card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: #d7e9f5;
}

.event-body {
  padding: 10px;
  font-size: 13px;
  color: #29465a;
}

.event-links a { margin-right: 8px; }
code { font-family: "IBM Plex Mono", "Consolas", monospace; }

.tv-shell {
  display: grid;
  gap: 8px;
}

.tv-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tv-stream {
  width: 100%;
  max-height: calc(100vh - 160px);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #cde5f3;
  box-shadow: var(--shadow);
  object-fit: contain;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-card {
  width: min(420px, 96vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(64, 116, 149, 0.14);
  padding: 18px;
}

.auth-card h1 {
  margin-top: 0;
  margin-bottom: 6px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #35586e;
}

.auth-form input {
  border: 1px solid #cfe2ef;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
  color: var(--ink);
}

.auth-error {
  margin: 10px 0;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #f2c3c8;
  background: #fff1f3;
  color: #9b1f2d;
  font-size: 13px;
}

@media (max-width: 900px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
  }

  .tile img { height: 135px; }
}
