:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #18212f;
  --muted: #687487;
  --border: #d7dde7;
  --accent: #16a34a;
  --accent-2: #0891b2;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --panel: #151b23;
    --panel-2: #10161d;
    --text: #e5edf7;
    --muted: #8b97a8;
    --border: #263241;
    --accent: #22c55e;
    --accent-2: #06b6d4;
    --warn: #f59e0b;
    --danger: #f87171;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 8px 24px;
  font-weight: 750;
  font-size: 20px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #05070a;
  background-image: url("/watchlink-icon-64.png");
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.22);
  overflow: hidden;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.nav-item.active,
.nav-item:hover {
  background: var(--panel-2);
  color: var(--text);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 8px 0;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.main {
  min-width: 0;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.title-block h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.title-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status-row,
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.stat,
.panel,
.auth-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat {
  padding: 14px;
}

.stat span,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge.good {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--accent);
}

.badge.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--border));
  color: var(--warn);
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 14px;
}

.video-frame {
  display: grid;
  min-height: 430px;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(34, 197, 94, 0.08), transparent 36%),
    #05070a;
}

.video-state {
  width: min(520px, 86%);
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 22px;
  background: rgba(15, 23, 42, 0.82);
  color: #e5edf7;
}

.media-embed {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 430px;
  border: 0;
  background: #05070a;
}

.video-state h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.controls {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 12px;
}

.button,
.icon-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--accent);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.input {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
}

.stack {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.row:last-child {
  border-bottom: 0;
}

.row-title {
  display: grid;
  gap: 3px;
}

.row-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.row-title strong {
  font-size: 14px;
}

.row-title span {
  color: var(--muted);
  font-size: 12px;
}

.avatar {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--avatar-color) 42%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--avatar-color) 18%, var(--panel));
  color: var(--avatar-color);
  font-weight: 800;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.auth-card {
  width: min(440px, 100%);
  padding: 22px;
}

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

.form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-error {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  color: var(--danger);
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

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

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
  }

  .sidebar-user {
    display: none;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    white-space: nowrap;
  }

  .stats-grid,
  .controls {
    grid-template-columns: 1fr;
  }
}
