:root {
  color-scheme: dark;
  --bg: #080b10;
  --surface: rgba(18, 24, 33, 0.82);
  --surface-strong: #121822;
  --line: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #a8b3c5;
  --soft: #6b7688;
  --brand: #2dd4bf;
  --brand-strong: #14b8a6;
  --success: #22c55e;
  --danger: #fb7185;
  --warning: #f59e0b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(45, 212, 191, 0.12), transparent 30%),
    linear-gradient(135deg, #080b10 0%, #10151e 54%, #080b10 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(8, 11, 16, 0.7);
  padding: 32px 24px;
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 40px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  color: #03110f;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 12px;
  border-radius: 8px;
}

.nav a:hover,
.nav a.active {
  background: rgba(45, 212, 191, 0.1);
  color: var(--text);
}

.content {
  padding: 32px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

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

.topbar-actions,
.guide-actions,
.export-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 38px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

.primary-action,
.danger-action,
.panel button,
.inline-form button {
  min-height: 44px;
  border-radius: 8px;
  color: #03110f;
  background: var(--brand);
  padding: 0 18px;
  font-weight: 800;
}

.danger-action {
  border: 1px solid rgba(251, 113, 133, 0.34);
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.12);
}

.danger-action:hover {
  background: rgba(251, 113, 133, 0.2);
}

.primary-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 18px 40px rgba(20, 184, 166, 0.24);
}

.primary-action:hover,
.panel button:hover,
.inline-form button:hover {
  background: var(--brand-strong);
}

.primary-action[disabled] {
  cursor: wait;
  opacity: 0.78;
}

.primary-link,
.ghost-link,
.export-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  text-decoration: none;
}

.primary-link {
  color: #03110f;
  background: var(--brand);
}

.primary-link:hover {
  background: var(--brand-strong);
}

.ghost-link,
.export-links a {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(8, 11, 16, 0.48);
}

.ghost-link:hover,
.export-links a:hover {
  border-color: rgba(45, 212, 191, 0.52);
  background: rgba(45, 212, 191, 0.1);
}

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(3, 17, 15, 0.32);
  border-top-color: #03110f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.is-loading .spinner {
  display: inline-block;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  min-height: 29px;
  overflow-wrap: anywhere;
  font-size: 22px;
}

.progress-metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 999px;
  background: rgba(8, 11, 16, 0.58);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  transition: width 0.35s ease;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  padding: 20px;
}

.panel.wide {
  grid-column: 1 / -1;
}

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

.panel-head p {
  color: var(--muted);
  margin-bottom: 0;
  font-size: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 16px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.72);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.72);
  color: var(--text);
  padding: 12px;
  outline: none;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}

.list,
.chip-list,
.history {
  display: grid;
  gap: 8px;
}

.row,
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.48);
  padding: 10px 12px;
}

.row span,
.history-row span {
  overflow-wrap: anywhere;
}

.remove {
  flex: 0 0 auto;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--danger);
  background: rgba(251, 113, 133, 0.12);
}

.remove:hover {
  background: rgba(251, 113, 133, 0.2);
}

.chip-list {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.08);
  padding: 8px 8px 8px 12px;
}

.schedule-box,
.settings-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-row {
  grid-template-columns: 180px 180px minmax(0, 1fr);
  margin-top: 12px;
}

.export-links {
  margin-top: 12px;
}

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

.radio-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.48);
  padding: 14px;
}

.radio-card input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
  accent-color: var(--brand);
}

.radio-card small,
.history-row small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.success {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.16);
}

.error {
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.16);
}

.partial,
.warning,
.running {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.16);
}

.never {
  color: #dbeafe;
  background: rgba(96, 165, 250, 0.16);
}

.reset {
  color: #e5e7eb;
  background: rgba(148, 163, 184, 0.16);
}

.empty {
  color: var(--soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
}

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 20;
}

.toast {
  width: min(420px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.guide-page {
  overflow-x: hidden;
}

.guide-shell {
  width: min(1500px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 32px 0;
}

.guide-header,
.guide-meta,
.guide-toolbar,
.tv-frame {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

.guide-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 16px;
}

.guide-meta article {
  min-height: 92px;
  background: rgba(8, 11, 16, 0.34);
  padding: 16px;
}

.guide-meta span,
.guide-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.guide-meta strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.guide-toolbar {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.72);
  color: var(--text);
  padding: 0 12px;
}

.tv-frame {
  position: relative;
  min-height: 460px;
  overflow: auto;
}

.guide-empty {
  margin: 20px;
}

.guide-grid {
  min-width: 100%;
  padding: 0 0 12px;
}

.tv-frame {
  overflow: visible;
  padding: 16px;
}

.guide-grid {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 0;
}

.guide-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(8, 11, 16, 0.38);
}

.guide-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 16, 0.62);
  padding: 16px;
}

.guide-day-head span {
  display: block;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.guide-day-head strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.guide-day-head em {
  flex: 0 0 auto;
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(96, 165, 250, 0.16);
  padding: 6px 12px;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
}

.guide-channel-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

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

.channel-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.channel-card strong {
  overflow-wrap: anywhere;
}

.channel-logo {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.08);
  overflow: hidden;
}

.channel-logo img {
  max-width: 82%;
  max-height: 82%;
  object-fit: contain;
}

.logo-fallback {
  color: #03110f;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  font-weight: 900;
}

.program-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  min-width: 0;
}

.program-card {
  position: static;
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 112px;
  overflow: hidden;
  border: 1px solid rgba(96, 165, 250, 0.24);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.82), rgba(14, 165, 233, 0.58));
  padding: 12px;
}

.program-card small,
.program-card strong,
.program-card span {
  white-space: normal;
}

.program-card small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 800;
}

.program-card strong {
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
}

.program-episode {
  width: max-content;
  max-width: 100%;
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(8, 11, 16, 0.34);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.program-subtitle {
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  line-height: 1.3;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .sidebar {
    position: static;
    padding: 20px;
  }

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

  .content {
    padding: 20px;
  }

  .status-grid,
  .grid,
  .schedule-box,
  .settings-row {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head,
  .guide-header {
    align-items: stretch;
    flex-direction: column;
  }

  .guide-meta,
  .guide-toolbar {
    grid-template-columns: 1fr;
  }

  .guide-channel-row {
    grid-template-columns: 1fr;
  }

  .program-list {
    grid-template-columns: 1fr;
  }
}

.danger-action:hover,
.panel .danger-action:hover {
  background: rgba(251, 113, 133, 0.2);
}

@media (max-width: 560px) {
  h1 {
    font-size: 30px;
  }

  .nav,
  .inline-form {
    grid-template-columns: 1fr;
  }
}
