:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel-2: #16233c;
  --line: #1f2b45;
  --text: #e5e7eb;
  --muted: #8fa3bf;
  --accent: #e4572e;
  --accent-2: #f59e0b;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

a { color: #7dd3fc; text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  flex: 0 0 224px;
  background: #0a101c;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo { display: flex; gap: 10px; align-items: center; padding: 20px 18px; border-bottom: 1px solid var(--line); }
.mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b1220; font-weight: 800;
}
.logo strong { display: block; font-size: 13px; letter-spacing: .5px; }
.logo small { color: var(--muted); font-size: 11px; }

.sidebar nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  padding: 9px 12px; border-radius: 9px; color: #b9c8dd; font-size: 13.5px;
}
.sidebar nav a:hover { background: var(--panel); text-decoration: none; }
.sidebar nav a.active { background: var(--panel-2); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.who { font-size: 12.5px; }
.who small { display: block; color: var(--muted); }

.content { flex: 1; min-width: 0; padding: 22px 26px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar h1 { font-size: 21px; margin: 0; letter-spacing: -.2px; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.flash.ok { background: #0f3b2e; color: #a7f3d0; border: 1px solid #14532d; }
.flash.bad { background: #3f1418; color: #fecaca; border: 1px solid #7f1d1d; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 18px; }
.panel h2 { font-size: 15px; margin: 0 0 14px; }

.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat b { display: block; font-size: 26px; letter-spacing: -.5px; }
.stat span { color: var(--muted); font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }

label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; background: #0d1728; border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font: inherit; font-size: 13.5px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #1d4ed8; outline-offset: 1px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 9px; padding: 9px 15px;
  background: var(--accent); color: #fff; font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; border-color: var(--line); color: #c9d6e8; font-weight: 500; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.bad { background: #7f1d1d; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--line); }
.badge.ok { color: #a7f3d0; background: #0f3b2e; border-color: #14532d; }
.badge.off { color: #fecaca; background: #3f1418; border-color: #7f1d1d; }
.badge.warn { color: #fde68a; background: #3d2c0a; border-color: #78350f; }
.badge.prem { color: #fde68a; background: #3d2c0a; border-color: #78350f; }

.thumb { width: 74px; height: 42px; object-fit: cover; border-radius: 6px; background: #0a101c; }
.thumb.logo { object-fit: contain; background: #0a101c; }

.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card .btn { width: 100%; margin-top: 6px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-foot { flex-direction: row; justify-content: space-between; align-items: center; }
  .content { padding: 16px; }
}

/* form VOD ditumpuk ke bawah (satu kolom) */
.form-grid.form-stack { grid-template-columns: 1fr; }
.form-grid.form-stack textarea { min-height: 120px; }

/* ---------------- saran genre (VOD) ---------------- */
.genre-wrap { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #0d1728; border: 1px solid var(--line);
  border-radius: 10px; padding: 4px; z-index: 20;
  max-height: 220px; overflow: auto;
  box-shadow: 0 14px 34px #0008;
}
.suggest[hidden] { display: none; }
.suggest-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--text);
}
.suggest-item:hover, .suggest-item.on { background: var(--surface-2); color: var(--amber); }

/* ---------------- kategori live: drag urut ---------------- */
#cat-rows tr[draggable="true"] { cursor: grab; }
#cat-rows tr[draggable="true"]:active { cursor: grabbing; }
#cat-rows tr.dragging { opacity: .45; background: var(--surface-2); }
.drag-handle {
  display: inline-block; margin-right: 8px;
  color: var(--muted); letter-spacing: -2px;
  user-select: none;
}
.sort-cell { white-space: nowrap; }

/* nomor channel inline */
.inline-num {
  width: 78px;
  padding: 6px 8px;
  text-align: center;
  font-weight: 700;
}

/* tab jadwal live */
.sched-tabs { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.sched-tab {
  appearance: none;
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 10px;
  padding: 9px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.sched-tab:hover { color: var(--text); border-color: var(--muted); text-decoration: none; }
.sched-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-pane[hidden] { display: none !important; }

/* play list */
.playlist-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.playlist-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.table-scroll { overflow-x: auto; }
.playlist-table td, .playlist-table th { vertical-align: middle; }
.playlist-table .drag-col { width: 34px; text-align: center; }
.playlist-table .start-cell { white-space: nowrap; }
.playlist-table .start-cell .drag-handle,
.playlist-table .start-cell .lock-mark { margin-right: 6px; }
.playlist-table tr.future .drag-handle { cursor: grab; }
.playlist-table tr.future .drag-handle:active { cursor: grabbing; }
.playlist-table tr.dragging { opacity: .4; background: var(--panel-2); }
.lock-mark { color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* dialog pilih acara */
.admin-modal {
  width: min(560px, 92vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  padding: 18px;
}
.admin-modal::backdrop { background: rgba(2, 6, 23, .72); }
.admin-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.admin-modal-head h2 { margin: 0; }
.modal-close {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.modal-close:hover { color: var(--text); }
.program-options {
  display: grid;
  gap: 8px;
  max-height: 60vh;
  overflow: auto;
  margin-top: 14px;
}
.program-option button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}
.program-option button:hover { border-color: var(--accent); }
.program-title { display: block; font-weight: 600; }
.program-meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* kalender jadwal */
.calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.calendar-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calendar-month { font-weight: 700; min-width: 132px; text-align: center; }
.calendar-grid { width: 100%; min-width: 640px; border-collapse: separate; border-spacing: 6px; table-layout: fixed; }
.calendar-grid th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 6px;
}
.calendar-grid td {
  height: 82px;
  vertical-align: top;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 0;
}
.calendar-grid td.cal-empty { border: 0; background: transparent; }
.cal-day .cal-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px 9px;
  color: var(--text);
  text-decoration: none;
  gap: 2px;
}
.cal-day a.cal-inner:hover { background: #1a2a45; border-radius: 9px; }
.cal-day .cal-num { font-weight: 700; }
.cal-day .cal-today { color: var(--accent); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.cal-day .cal-count { margin-top: auto; color: var(--muted); font-size: 11px; }
.cal-day.has .cal-count { color: var(--ok); }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.past { opacity: .38; }
/* header tabel jadwal freeze + baris siaran sekarang */
.playlist-scroll { overflow: visible; }
.playlist-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--panel);
  box-shadow: inset 0 -1px 0 var(--line);
}
.playlist-table tr.current {
  background: rgba(52, 211, 153, .10);
  box-shadow: inset 3px 0 0 var(--ok);
}
.playlist-table tr.current td { background: transparent; }
.playlist-table tr.current:focus { outline: 2px solid var(--ok); outline-offset: -2px; }
@media (max-width: 900px) {
  .playlist-scroll { overflow-x: auto; }
}
/* freeze seluruh header halaman jadwal; hanya daftar yang scroll */
body.sched-freeze .content {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
}
body.sched-freeze .content > * { flex: 0 0 auto; }
body.sched-freeze .content > .tab-pane:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.sched-freeze #tab-kalender > .panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
body.sched-freeze .playlist-head { flex: 0 0 auto; }
body.sched-freeze .playlist-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
}