:root {
  --bg: #0f1117; --panel: #171a23; --panel2: #1e2230; --line: #2a2f40; --text: #e7e9ef; --muted: #8c93a8;
  --accent: #f43f5e; --accent2: #fb7185; --ok: #22c55e; --warn: #f59e0b; --info: #38bdf8;
  --radius: 12px; --shadow: 0 8px 30px rgba(0,0,0,.35);
  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(--accent2); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: #fca5a5; min-height: 1.2em; margin: 0; }
h1 { font-size: 22px; margin: 0 0 4px; }
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; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, rgba(244,63,94,.18), transparent 50%), var(--bg); }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow); }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 8px 18px; }
.brand.big { font-size: 20px; padding: 0 0 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(244,63,94,.25); flex: none; }
nav { display: grid; gap: 2px; }
nav a { color: var(--text); padding: 9px 12px; border-radius: 8px; opacity: .8; }
nav a:hover { background: var(--panel2); opacity: 1; }
nav a.active { background: rgba(244,63,94,.14); color: #fff; opacity: 1; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding: 8px; font-size: 13px; }
.user-row { display: flex; justify-content: space-between; align-items: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: rgba(15,17,23,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.menu-btn { display: none; }
.onair { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; padding: 4px 12px; border-radius: 99px; background: var(--panel2); white-space: nowrap; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.onair.on .pulse { background: var(--ok); animation: pulse 1.6s infinite; }
.onair.live { background: rgba(244,63,94,.2); }
.onair.live .pulse { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.6); } 100% { box-shadow: 0 0 0 10px rgba(34,197,94,0); } }
.np { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.view { padding: 24px; max-width: 1280px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

/* Componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stat .v { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.now-card { display: flex; gap: 18px; align-items: center; background: linear-gradient(135deg, rgba(244,63,94,.18), rgba(99,102,241,.12)); }
.vinyl { width: 76px; height: 76px; border-radius: 50%; flex: none; background: repeating-radial-gradient(circle, #111 0 2px, #222 2px 4px); position: relative; }
.vinyl::after { content: ""; position: absolute; inset: 28px; border-radius: 50%; background: var(--accent); }
.vinyl.spin { animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.now-title { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #3b4258; background: #252a3a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #e11d48; }
.btn.danger { color: #fca5a5; }
.btn.danger:hover { background: rgba(239,68,68,.15); border-color: #7f1d1d; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(244,63,94,.5); border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 36px; width: 60px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.form { display: grid; gap: 14px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.badge.jingle { color: var(--warn); border-color: rgba(245,158,11,.4); }
.badge.live { color: #fff; background: var(--accent); border-color: var(--accent); }
.badge.ok { color: var(--ok); border-color: rgba(34,197,94,.4); }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.t-title { font-weight: 600; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

/* Subida */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.drop.over, .drop:hover { border-color: var(--accent); color: var(--text); background: rgba(244,63,94,.05); }
.progress { height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* Playlists */
.pl-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.pl-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.pl-item:hover { background: var(--panel2); }
.pl-item.active { background: rgba(244,63,94,.12); }
.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }

/* Programación */
.week { display: grid; grid-template-columns: 46px repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.week .hd { padding: 8px 4px; text-align: center; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line); background: var(--panel2); }
.week .hd.today { color: var(--accent2); }
.week .hours { position: relative; }
.week .hours div { height: 24px; font-size: 10px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-6px); }
.week .col { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0 47px, var(--line) 47px 48px); height: 576px; }
.block { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: 11px; color: #fff; overflow: hidden; cursor: pointer; border-left: 3px solid rgba(255,255,255,.6); opacity: .92; }
.block:hover { opacity: 1; z-index: 2; }
.block.off { opacity: .35; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 3; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { display: flex; align-items: center; gap: 4px; background: var(--panel2); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); color: var(--text); cursor: pointer; }

/* Gráfico */
.chart { width: 100%; height: 220px; display: block; }
.chart .grid-l { stroke: var(--line); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .area { fill: rgba(244,63,94,.18); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }

pre.code, code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
pre.code { padding: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
code { padding: 1px 6px; }
.kv { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px 12px; align-items: center; }
.kv .k { color: var(--muted); }

/* Modal y toasts */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; animation: in .2s; }
.toast.err { border-left-color: #ef4444; }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: 1fr; } .pl-layout { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-block; }
  .view { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .g2, .span2 { grid-template-columns: 1fr; grid-column: auto; }
  .np { display: none; }
  .kv { grid-template-columns: 1fr auto; } .kv .k { grid-column: 1 / -1; margin-bottom: -6px; }
  .week { grid-template-columns: 34px repeat(7, minmax(0, 1fr)); }
  .block { font-size: 9px; padding: 2px 3px; }
}
