:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #182032;
  --border: #253048;
  --text: #e6eaf2;
  --muted: #8a94ab;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --live: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: #fca5a5; min-height: 1em; margin: 0; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; padding: 0 8px; }
.brand.big { font-size: 24px; padding: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 4px rgba(239, 68, 68, .2); }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { color: var(--text); padding: 9px 10px; border-radius: 8px; }
#nav a:hover { background: var(--panel-2); text-decoration: none; }
#nav a.active { background: var(--accent-2); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
main { padding: 26px 30px 60px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

/* Cards & grids */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat .value { font-size: 28px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Forms */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; font: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* Buttons */
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: white; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { color: #fca5a5; }
.btn.danger:hover { border-color: var(--live); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

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

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.badge.live { background: rgba(239, 68, 68, .15); color: #fca5a5; border-color: rgba(239, 68, 68, .4); }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; }
.badge.autodj { background: rgba(59, 130, 246, .15); color: #93c5fd; border-color: rgba(59, 130, 246, .4); }
.badge.ok { background: rgba(34, 197, 94, .12); color: #86efac; border-color: rgba(34, 197, 94, .35); }
.badge.warn { background: rgba(245, 158, 11, .12); color: #fcd34d; border-color: rgba(245, 158, 11, .35); }
@keyframes pulse { 50% { opacity: .3; } }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* Video preview */
.preview { background: black; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; color: var(--muted); }
.preview video { width: 100%; height: 100%; }

/* Progress */
.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; min-width: 120px; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.meter { display: flex; flex-direction: column; gap: 6px; }

/* Log */
.log { background: #05070b; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: 12px/1.5 ui-monospace, Consolas, monospace; color: #9aa4b8; max-height: 160px; overflow: auto; white-space: pre-wrap; margin: 8px 0 0; }

/* Modal */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 8px; padding: 10px 14px; max-width: 360px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast.err { border-left-color: var(--live); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-card p { margin: 0; }

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

/* Web TV */
.seg { gap: 6px; }
.warn-text { color: #fcd34d; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 70%, white); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
dialog.wide { width: min(820px, 96vw); }
.sched-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.sched-row > .btn { align-self: flex-start; }
.daypick { flex-direction: row; gap: 0; cursor: pointer; }
.daypick input { display: none; }
.daypick span { padding: 4px 9px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 12px; user-select: none; }
.daypick input:checked + span { background: var(--accent-2); border-color: var(--accent-2); color: white; }
.item-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }

/* Calendario semanal */
.cal { min-width: 720px; }
.cal-head, .cal-body { display: grid; grid-template-columns: 48px repeat(7, 1fr); }
.cal-head > div { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding-bottom: 6px; }
.cal-head > .today { color: var(--text); }
.cal-hours > div { height: var(--hour); font-size: 10px; color: var(--muted); transform: translateY(-6px); }
.cal-col { position: relative; height: calc(var(--hour) * 24); border-left: 1px solid var(--border);
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), #1c2436 calc(var(--hour) - 1px), #1c2436 var(--hour)); }
.cal-block { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; font-size: 11px; line-height: 1.3;
  background: color-mix(in srgb, var(--c) 75%, black); border: 1px solid var(--c); color: white; }
.cal-block.soft { background: color-mix(in srgb, var(--c) 22%, transparent); }
.cal-block.off { opacity: .4; }
.cal-block:hover { filter: brightness(1.2); z-index: 2; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--live); z-index: 3; }
.cal-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--live); }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  main { padding: 18px 16px 40px; }
}
