/* VeeMedia — panel de administración, estilo Material 3 (base: Simple DJ) */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --primary: #3F51B5;
  --on-primary: #fff;
  --primary-c: #DEE0FF;
  --on-primary-c: #00105C;
  --sec-c: #E2E1EC;
  --surface: #FBF8FF;
  --surface-1: #F5F2FA;
  --surface-2: #EFEDF4;
  --surface-3: #E9E7EF;
  --card: #FFFFFF;
  --on-surface: #1B1B21;
  --on-surface-v: #46464F;
  --outline: #767680;
  --outline-v: #C6C5D0;
  --error: #BA1A1A;
  --error-c: #FFDAD6;
  --ok: #1B6C3A;
  --ok-c: #C9F0D2;
  --warn-c: #FFE08A;
  --shadow-1: 0 1px 2px rgba(0,0,0,.18), 0 1px 3px 1px rgba(0,0,0,.08);
  --shadow-2: 0 2px 6px 2px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.2);
  --ease: cubic-bezier(.2,0,0,1);
}
html, body { margin: 0; }
body { font-family: Roboto, "Segoe UI", system-ui, sans-serif; font-size: 14px; color: var(--on-surface); background: var(--surface); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1 { font-size: 28px; line-height: 36px; font-weight: 400; margin: 0; }
h2 { font-size: 20px; line-height: 28px; font-weight: 500; margin: 0 0 4px; }
h3 { font-size: 16px; font-weight: 500; margin: 0 0 4px; }
.muted { color: var(--on-surface-v); }
.small { font-size: 12px; }

.ms { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 22px; line-height: 1; display: inline-block; white-space: nowrap; direction: ltr; font-feature-settings: "liga"; font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24; width: 1em; overflow: hidden; flex: none; vertical-align: middle; }
.ms.fill { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

/* Barra superior */
.bar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 16px; background: var(--surface-2); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 500; color: var(--on-surface); }
.brand .ms { color: var(--primary); font-size: 28px; }
.nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.nav a { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 20px; color: var(--on-surface-v); font-weight: 500; }
.nav a:hover { background: rgba(0,0,0,.05); }
.nav a.on { background: var(--sec-c); color: var(--on-surface); }
.who { display: flex; align-items: center; gap: 10px; }
.who-name { display: flex; flex-direction: column; line-height: 16px; font-weight: 500; }
.who-name small { font-weight: 400; color: var(--on-surface-v); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: var(--on-primary); font-weight: 500; }
@media (max-width: 760px) {
  .bar { gap: 8px; padding: 0 8px; }
  .brand span:last-child, .who-name, .nav .t { display: none; }
  .nav { justify-content: flex-start; }
  .nav a { padding: 0 12px; }
}

/* Estructura */
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .grow { flex: 1; min-width: 200px; }
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow-1); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 24px; border-radius: 20px; border: 0; font-weight: 500; letter-spacing: .1px; white-space: nowrap; text-decoration: none; transition: box-shadow .2s, background-color .2s; }
.btn .ms { font-size: 18px; margin-left: -6px; }
.btn.filled { background: var(--primary); color: var(--on-primary); }
.btn.filled:hover { box-shadow: var(--shadow-1); }
.btn.tonal { background: var(--sec-c); color: var(--on-surface); }
.btn.outlined { background: transparent; border: 1px solid var(--outline); color: var(--primary); }
.btn.text { background: transparent; color: var(--primary); padding: 0 12px; }
.btn.text:hover, .btn.outlined:hover, .btn.tonal:hover { background-color: rgba(63,81,181,.08); }
.btn.danger { color: var(--error); border-color: var(--error); }
.btn.danger.filled { background: var(--error); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--on-surface-v); flex: none; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.icon-btn.danger { color: var(--error); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 500; color: var(--on-surface-v); letter-spacing: .3px; }
.field .hint { font-size: 12px; color: var(--on-surface-v); }
.input, select.input, textarea.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--outline);
  border-radius: 8px;
  background: var(--card);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; line-height: 20px; }
.input:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.input.bad { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group .input { flex: 1; }
.check { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; cursor: pointer; }
.check input { display: none; }
.check .sw { position: relative; flex: none; width: 52px; height: 32px; border-radius: 16px; border: 2px solid var(--outline); background: var(--surface-3); transition: all .2s; margin-top: 2px; }
.check .sw::after { content: ""; position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--outline); transition: all .25s var(--ease); }
.check input:checked + .sw { background: var(--primary); border-color: var(--primary); }
.check input:checked + .sw::after { left: 22px; top: 2px; width: 24px; height: 24px; background: #fff; }
.check b { display: block; font-weight: 500; font-size: 15px; }
.check span.d { color: var(--on-surface-v); font-size: 13px; }

/* Chips y estados */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--on-surface-v); white-space: nowrap; }
.chip.ok { background: var(--ok-c); color: var(--ok); }
.chip.off { background: var(--error-c); color: var(--error); }
.chip .ms { font-size: 16px; }


/* Tablas */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--on-surface-v); padding: 10px 12px; border-bottom: 1px solid var(--outline-v); }
.table td { padding: 12px; border-bottom: 1px solid var(--surface-3); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* Mensajes */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px); padding: 14px 20px; border-radius: 8px; background: #303036; color: #F2F0F7; box-shadow: var(--shadow-2); transition: opacity .3s, transform .3s; }
.toast.err .ms { color: #FFB4AB; }
.toast.ok .ms { color: #8CD6A0; }
.toast.hide { opacity: 0; transform: translate(-50%, 20px); pointer-events: none; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; margin-bottom: 16px; background: var(--error-c); color: #410002; }
.alert.info { background: var(--primary-c); color: var(--on-primary-c); }
.alert.ok { background: var(--ok-c); color: #00210C; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.secret { font-family: Consolas, monospace; font-size: 15px; background: var(--surface-2); padding: 2px 8px; border-radius: 6px; user-select: all; }

/* Login / instalación */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(circle at 20% 10%, #E6E8FF, transparent 50%), radial-gradient(circle at 90% 90%, #FFE1EC, transparent 45%), var(--surface); }
.auth .card { width: 100%; max-width: 420px; padding: 32px 28px; }
.auth .card.wide { max-width: 640px; }
.auth .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; font-size: 20px; font-weight: 500; }
.auth .logo .ms { font-size: 36px; color: var(--primary); }

/* Diálogo */
dialog { border: 0; border-radius: 28px; padding: 24px; max-width: min(560px, calc(100% - 32px)); width: 100%; background: var(--surface-1); color: var(--on-surface); box-shadow: var(--shadow-2); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-bottom: 12px; }
dialog .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.empty-state { text-align: center; padding: 56px 16px; color: var(--on-surface-v); }
.empty-state .ms { font-size: 56px; width: auto; opacity: .45; display: block; margin: 0 auto 12px; }

/* Recuadro fijo con credenciales recién creadas */
.cred { position: sticky; top: 64px; z-index: 40; display: flex; align-items: center; gap: 14px; max-width: 1120px; margin: 16px auto 0; padding: 16px 16px 16px 20px; border-radius: 16px; background: var(--warn-c); color: #241A00; box-shadow: var(--shadow-2); }
.cred > .ms { font-size: 28px; }
.cred .grow { flex: 1; min-width: 0; }
.cred .secret { display: inline-block; margin: 6px 0; background: rgba(255,255,255,.6); white-space: normal; word-break: break-word; }
.cred small { display: block; }
@media (max-width: 760px) { .cred { margin: 12px; flex-wrap: wrap; } }


/* ==========================================================================
   VeeMedia
   ========================================================================== */
:root { --live: #C62828; --live-c: #FFDAD6; --warn: #7A5900; }
.mono { font-family: Consolas, "Roboto Mono", monospace; }
.grow { flex: 1; min-width: 0; }
.chip.warn { background: var(--warn-c); color: var(--warn); }
.chip.live { background: var(--live-c); color: var(--live); }
.chip.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.kpi .ico { width: 48px; height: 48px; border-radius: 16px; background: var(--primary-c); color: var(--on-primary-c); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.kpi .ico.live { background: var(--live-c); color: var(--live); }
.kpi .v { font-size: 24px; line-height: 30px; font-weight: 500; }
.kpi .l { font-size: 12px; color: var(--on-surface-v); }

/* Barra de herramientas de listas */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--outline); border-radius: 20px; overflow: hidden; }
.seg a { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; color: var(--on-surface); font-weight: 500; border-left: 1px solid var(--outline); }
.seg a:first-child { border-left: 0; }
.seg a.on { background: var(--sec-c); }
.seg a .ms { font-size: 18px; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search .ms { position: absolute; left: 12px; top: 9px; color: var(--on-surface-v); }
.search .input { height: 40px; border-radius: 20px; padding-left: 42px; }

/* Tabla de cuentas */
.card.flush { padding: 0; overflow: hidden; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-1); }
.acc-num { font-weight: 500; font-size: 15px; }
.acc-name { color: var(--on-surface-v); font-size: 13px; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { display: block; font-size: 12px; color: var(--on-surface-v); }
.over { color: var(--error); font-weight: 500; }
.meter { width: 120px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--primary); }
.meter.warn > span { background: #E0A100; }
.meter.full > span { background: var(--error); }
.td-actions { text-align: right; white-space: nowrap; }
@media (max-width: 760px) { .hide-sm { display: none; } .acc-name { max-width: 140px; } }

/* Editor de cuenta (pestañas verticales) */
.ed { max-width: 1120px; margin: 0 auto; padding: 0 16px 80px; }
.ed-head { position: sticky; top: 64px; z-index: 30; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 0; background: var(--surface); }
.ed-title { flex: 1; min-width: 180px; }
.ed-title h1 { font-size: 22px; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-body { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.ed-tabs { position: sticky; top: 140px; display: flex; flex-direction: column; gap: 2px; }
.ed-tabs a { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 16px; border-radius: 26px; color: var(--on-surface-v); font-weight: 500; }
.ed-tabs a:hover { background: rgba(0,0,0,.05); }
.ed-tabs a.on { background: var(--sec-c); color: var(--on-surface); }
/* Separación con gap: los scripts y formularios vacíos entre tarjetas no la afectan */
.ed-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.ed-main > form:empty { display: none; }
.ed-main > section.card { margin-top: 0; }
.js .ed-main > section[data-tab] { display: none; }
.js .ed-main > section[data-tab].on { display: block; }
.card-sub { margin: 0 0 16px; }
@media (max-width: 860px) {
  .ed { padding: 0 12px 80px; }
  .ed-body { grid-template-columns: 1fr; gap: 12px; }
  .ed-tabs { position: sticky; top: 128px; z-index: 20; flex-direction: row; overflow-x: auto; background: var(--surface); padding-bottom: 6px; scrollbar-width: none; }
  .ed-tabs a { height: 40px; padding: 0 14px; flex: none; }
}

/* Datos para copiar */
.copy { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--surface-3); }
.copy:last-child { border-bottom: 0; }
.copy .lbl { width: 170px; flex: none; font-size: 12px; font-weight: 500; color: var(--on-surface-v); }
.copy .val { flex: 1; min-width: 0; font-family: Consolas, monospace; font-size: 14px; word-break: break-all; }
pre.code { margin: 0; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); font-family: Consolas, monospace; font-size: 13px; white-space: pre-wrap; word-break: break-all; }
@media (max-width: 600px) { .copy { flex-wrap: wrap; } .copy .lbl { width: 100%; } }
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--surface-3); }
.kv td:first-child { color: var(--on-surface-v); width: 45%; }
.kv tr:last-child td { border-bottom: 0; }

/* Estado en vivo dentro de la cuenta */
.live-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.live-box > div { padding: 12px 14px; border-radius: 12px; background: var(--surface-1); }
.live-box .v { font-size: 20px; font-weight: 500; }
.live-box .l { font-size: 12px; color: var(--on-surface-v); }

/* Bitácora */
.ev-ico { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--on-surface-v); }
.ev-ico .ms { font-size: 18px; }
.ev-ico.warn { background: var(--warn-c); color: var(--warn); }
.ev-ico.error { background: var(--error-c); color: var(--error); }
.ev-cnt { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px; background: var(--surface-3); font-size: 12px; font-weight: 500; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; align-items: end; }
.filters .field { margin-bottom: 12px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; }

/* Importación */
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; border: 2px dashed var(--outline-v); border-radius: 16px; text-align: center; color: var(--on-surface-v); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--primary); background: rgba(63,81,181,.04); }
.drop .ms { font-size: 40px; width: auto; color: var(--primary); }
tr.err td { background: #FFF4F2; }
#btnSave.dirty { box-shadow: 0 0 0 4px rgba(63,81,181,.25); }

/* Estadísticas (igual que Simple DJ) */
.stats-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.day-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { height: 32px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--outline-v); background: var(--card); font-weight: 500; font-size: 13px; color: var(--on-surface-v); }
.fchip.on { background: var(--sec-c); border-color: transparent; color: var(--on-surface); }
.range-custom { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.range-custom .field { margin-bottom: 0; width: 170px; }
.st-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.st-kpis .card + .card { margin-top: 0; }
.st-kpi { padding: 16px 18px; }
.kpi-label { font-size: 13px; color: var(--on-surface-v); font-weight: 500; }
.kpi-value { font-size: 28px; line-height: 36px; font-weight: 500; margin: 4px 0 2px; }
.kpi-sub { font-size: 12px; color: var(--on-surface-v); }
.chart-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-head .day-filter { flex: 1; }
.chart-box { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--surface-3); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--on-surface-v); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--primary); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.on { fill: rgba(63,81,181,.06); }
.chart-tip { position: absolute; transform: translate(-50%, calc(-100% - 10px)); pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 8px; background: #303036; color: #F2F0F7; font-size: 12px; white-space: nowrap; box-shadow: var(--shadow-2); }
.chart-tip b { font-size: 14px; font-weight: 500; }
.stats-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.stats-grid .card + .card { margin-top: 0; }
.stats-grid + .card { margin-top: 16px; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-table td { padding: 10px 12px; }
.meters { display: flex; flex-direction: column; gap: 18px; }
.meter-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.meter-top .grow { flex: 1; }
.meter-top .ms { color: var(--on-surface-v); }
.meter-track { height: 8px; border-radius: 4px; background: var(--primary-c); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--primary); }
@media (max-width: 900px) { .stats-grid { grid-template-columns: 1fr; } }

/* Servidor */
.alert.warn { background: var(--warn-c); color: #241A00; }
.gauge { margin-top: 8px; }
.gauge.warn .meter-fill { background: #E0A100; }
.gauge.full .meter-fill { background: var(--error); }
.kv .chip { margin-right: 6px; }

/* AutoDJ */
.adj > .card + .card { margin-top: 16px; }
.adj-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.adj-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.adj-status .ms { font-size: 16px; }
.adj-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.adj-row .grow { min-width: 220px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border: 0; border-left: 1px solid var(--outline); background: transparent; color: var(--on-surface); font-weight: 500; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--sec-c); }
.seg button .ms { font-size: 18px; }
.media-list { margin-top: 16px; border-top: 1px solid var(--surface-3); }
.media-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--surface-3); background: var(--card); }
.media-row .drag { color: var(--outline); cursor: grab; }
.media-row.off .media-title, .media-row.off .muted { opacity: .5; }
.media-row.dragging { opacity: .4; }
.media-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-row .grow { min-width: 0; }
.check.mini { padding: 0; }
.check.mini .sw { margin-top: 0; }
.uploads { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.upload .meter-top { margin-bottom: 6px; }
.upload .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .media-row { flex-wrap: wrap; } .media-row .grow { flex-basis: calc(100% - 40px); } }
