:root {
  --bg: #0b0e13;
  --bg-2: #10141b;
  --card: #141a23;
  --card-2: #1a212c;
  --line: #232c39;
  --line-2: #2e3949;
  --text: #e6ebf2;
  --muted: #8b97a8;
  --dim: #5d6879;
  --accent: #ff4d3d;
  --accent-2: #ff7a5c;
  --live: #ff3b30;
  --ok: #2fd17a;
  --warn: #f5b83d;
  --err: #ff5a5f;
  --info: #4fa3ff;
  --purple: #b07cff;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1a1210 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ------------------------------------------------ login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 32px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .3px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--live);
  box-shadow: 0 0 0 4px rgba(255,59,48,.18), 0 0 18px rgba(255,59,48,.6);
  animation: pulse 2s infinite;
}
.login-card .brand { font-size: 20px; margin-bottom: 6px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }

/* ------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--bg-2); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { padding: 4px 10px 18px; font-size: 16px; }
.nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 9px 12px; border-radius: 10px; color: var(--muted);
  cursor: pointer; font-weight: 500;
}
.nav-btn svg { width: 18px; height: 18px; flex: none; }
.nav-btn:hover { background: var(--card); color: var(--text); }
.nav-btn.active { background: var(--card-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-sep { height: 1px; background: var(--line); margin: 10px 6px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.sidebar-foot .who { font-weight: 600; }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }
.btn.menu-toggle { display: none; }

/* ------------------------------------------------ stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.stat .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.bar { height: 4px; background: var(--line); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 4px; transition: width .4s; }
.bar > i.warn { background: var(--warn); }
.bar > i.err { background: var(--err); }

/* ------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card-2); border: 1px solid var(--line-2); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13px;
  white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #222b38; border-color: #3a4759; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #ff6152; }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: rgba(255,90,95,.12); border-color: rgba(255,90,95,.4); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--card-2); color: var(--text); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.icon { padding: 7px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--dim); }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 12px; outline: none; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,77,61,.15); }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
.search { max-width: 260px; min-width: 160px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: 22px; background: var(--line-2); position: relative; transition: background .2s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(47,209,122,.3); }

.chip {
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line-2); font-size: 11px; font-weight: 600; color: var(--muted);
}
.chip.ok { color: var(--ok); border-color: rgba(47,209,122,.35); background: rgba(47,209,122,.08); }
.chip.err { color: var(--err); border-color: rgba(255,90,95,.35); background: rgba(255,90,95,.08); }
.chip.warn { color: var(--warn); border-color: rgba(245,184,61,.35); background: rgba(245,184,61,.08); }
.chip.info { color: var(--info); border-color: rgba(79,163,255,.35); background: rgba(79,163,255,.08); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------ channel cards */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--line-2); }
.card.offline { opacity: .6; }
.thumb {
  position: relative; aspect-ratio: 16/9; background:
    repeating-linear-gradient(135deg, #10151d 0 12px, #121821 12px 24px);
  display: grid; place-items: center; overflow: hidden;
}
.thumb video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; }
.thumb .play {
  position: relative; z-index: 1; width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.12); backdrop-filter: blur(6px); display: grid; place-items: center;
  transition: transform .15s, background .15s;
}
.thumb .play:hover { transform: scale(1.06); background: var(--accent); }
.thumb .play svg { width: 22px; height: 22px; margin-left: 3px; }
.thumb .res {
  position: absolute; z-index: 2; right: 10px; bottom: 10px; font: 600 11px var(--mono);
  background: rgba(0,0,0,.6); padding: 3px 7px; border-radius: 6px;
}
.badge-live {
  position: absolute; z-index: 2; left: 10px; top: 10px; display: inline-flex; align-items: center; gap: 6px;
  background: var(--live); color: #fff; font-weight: 800; font-size: 11px; letter-spacing: .8px;
  padding: 3px 8px; border-radius: 6px;
}
.badge-live .dot { background: #fff; animation: pulse 1.4s infinite; }
.badge-off { background: #3a4252; }
.badge-off .dot { animation: none; }
.thumb .close-video {
  position: absolute; z-index: 3; right: 8px; top: 8px; background: rgba(0,0,0,.6); border: 0;
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; display: grid; place-items: center;
}
.card-body { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.card-title h3 { margin: 0; font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title .app { color: var(--muted); font: 500 12px var(--mono); }
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.meta div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; min-width: 0; }
.meta b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta span { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); }
.spark { display: flex; align-items: center; gap: 10px; }
.spark svg { flex: 1; height: 34px; color: var(--spark); }
.spark .kbps { font: 700 15px var(--mono); color: var(--text); min-width: 88px; text-align: right; }
.spark .kbps small { color: var(--muted); font-weight: 500; font-size: 11px; }
.card-info { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; border-top: 1px solid var(--line); padding: 10px 12px; flex-wrap: wrap; }
.card-actions .spacer { flex: 1; }

/* ------------------------------------------------ canales: listado */
.ch-table td { padding: 9px 12px; }
.ch-table th { white-space: nowrap; }
.ch-table tr.is-off { opacity: .55; }
.ch-table .ch-name b { font-size: 14px; }
.ch-table .ta-c { text-align: center; }
.ch-table th.ta-r { text-align: right; }
.ch-table td .actions .btn { padding: 6px 8px; }
.ch-table td .actions .btn svg { width: 14px; height: 14px; }
.list-spark { display: flex; align-items: center; gap: 8px; min-width: 170px; }
.list-spark svg { width: 80px; height: 26px; flex: none; color: var(--spark); }
.list-spark .kbps { font: 700 13px var(--mono); white-space: nowrap; }
.list-spark .kbps small { color: var(--muted); font-weight: 500; font-size: 10px; }
.live-chip { color: #fff; background: var(--live); border-color: var(--live); font-weight: 800; letter-spacing: .5px; }
.live-chip .dot { animation: pulse 1.4s infinite; }
.preview-holder .thumb { border-radius: 10px; }

/* ------------------------------------------------ panels / tables */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--dim); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.015); }
td .actions { display: flex; gap: 6px; justify-content: flex-end; }
.secret { font-family: var(--mono); font-size: 12px; background: var(--bg-2); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .4; margin-bottom: 8px; }
pre.log {
  margin: 0; background: #07090d; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font: 12px/1.55 var(--mono); color: #c8d1dd; max-height: 520px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.tabs { display: flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tabs button { background: none; border: 0; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.tabs button.active { background: var(--card-2); color: var(--text); }

/* ------------------------------------------------ restream cards */
.rs-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.rs-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; flex-wrap: wrap; }
.rs-head h3 { margin: 0; font-size: 15px; }
.rs-route { font: 12px var(--mono); color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rs-route .arrow { color: var(--accent); }
.rs-jobs { border-top: 1px solid var(--line); }
.rs-job { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.rs-job:last-child { border-bottom: 0; }
.rs-job details { grid-column: 1 / -1; }
.rs-job summary { cursor: pointer; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------ services */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 18px; }
.svc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.svc h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 10px; }

/* ------------------------------------------------ modal / toast */
.modal-back {
  position: fixed; inset: 0; background: rgba(3,5,8,.7); backdrop-filter: blur(3px); z-index: 50;
  display: grid; place-items: center; padding: 16px; animation: fade .15s;
}
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--card); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 40px 100px rgba(0,0,0,.6);
  animation: rise .18s;
}
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 18px 20px 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast {
  background: var(--card-2); border: 1px solid var(--line-2); border-left: 3px solid var(--ok);
  padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: rise .2s;
  max-width: 420px; white-space: pre-wrap;
}
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
.alert { padding: 10px 14px; border-radius: 10px; border: 1px solid; margin-bottom: 16px; font-size: 13px; }
.alert.warn { color: var(--warn); border-color: rgba(245,184,61,.35); background: rgba(245,184,61,.07); }
.alert.info { color: #a9cdf7; border-color: rgba(79,163,255,.3); background: rgba(79,163,255,.06); }
.alert.err { color: var(--err); border-color: rgba(255,90,95,.35); background: rgba(255,90,95,.07); }
.copy-row { display: flex; gap: 6px; margin-bottom: 8px; }
.copy-row input { font-family: var(--mono); font-size: 12px; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }


/* ------------------------------------------------ reproductor */
.thumb.playing .badge-live, .thumb.playing .res, .thumb.playing .play { display: none; }
.player-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  background: var(--card-2); border-bottom: 1px solid var(--line);
}
.player-bar .spacer { flex: 1; }
.player-bar .btn svg { width: 15px; height: 15px; }
.preview-holder .player-bar { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; }
.preview-holder .thumb.playing { border-radius: 10px 10px 0 0; }
.player-loading {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; font-weight: 600; pointer-events: none;
}
.spinner {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ selección múltiple */
input[type=checkbox][data-sel], #ch-selall, #ch-selall-th {
  width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: var(--accent); flex: none;
}
.sel-box { display: inline-flex; align-items: center; margin-right: 2px; align-self: center; }
.sel-all { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); user-select: none; }
.card.is-sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ch-table tr.is-sel { background: rgba(255,77,61,.06); }
.ch-table .col-sel { width: 36px; padding-right: 0; }
.selbar {
  position: fixed; z-index: 35; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 16px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line-2);
  box-shadow: 0 16px 40px rgba(0,0,0,.45); animation: rise .18s; white-space: nowrap;
}
body.has-selbar .main { padding-bottom: 110px; }
.sel-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 120px; overflow: auto; }

/* ------------------------------------------------ selector de vista (tarjetas / listado) */
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 6px 9px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.seg button svg { width: 16px; height: 16px; }
.seg button.active { background: var(--card-2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }


/* ------------------------------------------------ indicador en vivo: bolita verde */
.live-dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #5d6879; vertical-align: middle; flex: none;
}
.live-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.22), 0 0 10px rgba(34,197,94,.55); animation: pulse 1.6s infinite; }
.ch-table .col-st { width: 44px; text-align: center; }
.badge-live {
  background: rgba(0,0,0,.55) !important; padding: 6px !important; border-radius: 999px !important; gap: 0 !important;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.badge-live .bl-text { display: none; }
.badge-live .dot { width: 11px; height: 11px; background: #22c55e !important; box-shadow: 0 0 8px rgba(34,197,94,.8); }
.badge-live.badge-off .dot { background: #8b97a8 !important; box-shadow: none; animation: none; }

/* ------------------------------------------------ barra flotante: más acciones */
.selbar { max-width: calc(100vw - 24px); }
.selbar .sel-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.selbar .btn svg { width: 15px; height: 15px; }
.selbar .btn:disabled { opacity: .4; }
.seg.seg-text { flex-wrap: wrap; }
.seg.seg-text button { padding: 7px 12px; font-weight: 600; font-size: 13px; }
#pl-out { font-size: 12px; white-space: pre; overflow: auto; }
.pl-actions { margin-bottom: 14px; }


/* ------------------------------------------------ formulario de reenvío */
.fwd-sec {
  font-size: 11px; font-weight: 800; letter-spacing: .9px; text-transform: uppercase; color: var(--accent-2);
  margin: 6px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.grid-fwd { display: grid; grid-template-columns: 150px 1fr 120px; gap: 0 16px; }
.fwd-preview {
  display: flex; flex-direction: column; gap: 4px; margin: 4px 0 16px; padding: 10px 12px;
  background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 10px;
}
.fwd-preview code, .fwd-prev-list { font: 12px/1.6 var(--mono); color: var(--text); word-break: break-all; }
.fwd-prev-list b { color: var(--accent-2); font-weight: 700; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-2); cursor: pointer; text-decoration: underline; margin: -4px 0 12px; display: inline-block; }

/* ------------------------------------------------ compatibilidad entre navegadores */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
body.no-scroll { overflow: hidden; }
.shell { min-height: 100vh; min-height: 100dvh; }
.sidebar { height: 100vh; height: 100dvh; }
.thumb .play, .modal-back { -webkit-backdrop-filter: blur(6px); }
button, select, input, textarea { -webkit-appearance: none; appearance: none; border-radius: 10px; }
input[type=checkbox] { -webkit-appearance: auto; appearance: auto; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b97a8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
input[type=number]::-webkit-inner-spin-button { opacity: .5; }
.table-wrap { -webkit-overflow-scrolling: touch; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
video { -webkit-transform: translateZ(0); }
.sidebar-backdrop { display: none; }

/* Efectos hover solo con mouse (en táctil se "pegan" tras tocar) */
@media (hover: none) {
  .nav-btn:hover { background: none; color: var(--muted); }
  .nav-btn.active:hover { background: var(--card-2); color: var(--text); }
  tbody tr:hover { background: transparent; }
  .btn:hover { background: var(--card-2); border-color: var(--line-2); }
  .btn.primary:hover { background: var(--accent); }
  .thumb .play:hover { transform: none; }
}

/* ------------------------------------------------ táctil: objetivos más grandes */
html[data-input="touch"] .btn { min-height: 40px; }
html[data-input="touch"] .btn.sm { min-height: 36px; padding: 7px 12px; }
html[data-input="touch"] .nav-btn { padding: 12px 14px; }
html[data-input="touch"] .switch .track { width: 44px; height: 26px; }
html[data-input="touch"] .switch .track::after { width: 20px; height: 20px; }
html[data-input="touch"] .switch input:checked + .track::after { transform: translateX(18px); }
/* iOS hace zoom al enfocar campos con letra menor a 16px */
html[data-input="touch"] input, html[data-input="touch"] select, html[data-input="touch"] textarea { font-size: 16px; }

/* ------------------------------------------------ escritorio mediano */
@media (max-width: 1280px) {
  .shell { grid-template-columns: 210px 1fr; }
  .main { padding: 20px 22px 60px; }
}

/* ------------------------------------------------ tableta y menor: menú lateral deslizable */
@media (max-width: 1099px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 45; left: 0; top: 0; bottom: 0; width: min(290px, 84vw);
    transform: translateX(-105%); transition: transform .22s ease; overflow-y: auto;
    padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
  }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(3,5,8,.55); animation: fade .15s; }
  .sidebar-backdrop[hidden] { display: none; }
  .btn.menu-toggle { display: inline-flex; }
  .topbar {
    position: sticky; top: 0; z-index: 30; margin: -20px -22px 16px; padding: 12px 22px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(150%) blur(10px); backdrop-filter: saturate(150%) blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .main { padding-left: max(22px, env(safe-area-inset-left)); padding-right: max(22px, env(safe-area-inset-right)); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* Listado de canales en tableta: se ocultan columnas secundarias para que quepan las acciones */
@media (min-width: 640px) and (max-width: 1279px) {
  .ch-table th.col-opt, .ch-table td[data-label="Origen"], .ch-table td[data-label="Audio"], .ch-table td[data-label="Reenvíos"] { display: none; }
  .ch-table td, .ch-table th { padding-left: 10px; padding-right: 10px; }
  .list-spark { min-width: 140px; }
  .list-spark svg { width: 60px; }
}

/* ------------------------------------------------ teléfono */
@media (max-width: 639px) {
  body { font-size: 15px; }
  .main { padding: 16px max(14px, env(safe-area-inset-right)) calc(80px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .topbar { margin: -16px -14px 14px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); gap: 8px; }
  .topbar h1 { font-size: 19px; }
  #page-actions { width: 100%; }
  #page-actions .btn { flex: 1 1 auto; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 19px; }
  .stat .label { font-size: 10px; letter-spacing: .5px; }

  .toolbar { gap: 8px; }
  .toolbar .search { flex: 1 1 100%; max-width: none; min-width: 0; }
  .toolbar select { flex: 1 1 auto; max-width: none !important; }
  .toolbar > .spacer { display: none; }

  .cards { grid-template-columns: 1fr; gap: 12px; }
  .card-body { padding: 12px 14px; }
  .meta { gap: 6px; }
  .card-actions .btn { flex: 1 1 auto; }
  .card-actions .spacer { display: none; }

  .panel-head { padding: 12px 14px; }
  .panel-body { padding: 14px; }
  .rs-head { padding: 12px 14px; }
  .rs-head > .row { width: 100%; }
  .rs-head > .row .btn { flex: 1 1 auto; }
  .rs-job { grid-template-columns: 1fr; padding: 10px 14px; }
  .svc-grid { grid-template-columns: 1fr; }

  /* Tablas → tarjetas apiladas: cada celda muestra el nombre de su columna */
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table-wrap tbody tr:last-child { border-bottom: 0; }
  .table-wrap td {
    border: 0; padding: 5px 0 5px 38%; position: relative; min-height: 30px;
    text-align: left !important; word-break: break-word;
  }
  .table-wrap td::before {
    content: attr(data-label); position: absolute; left: 0; top: 7px; width: 35%;
    color: var(--dim); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  }
  .table-wrap td > div { margin-top: 3px; }
  .table-wrap td[data-label=""]::before, .table-wrap td.full-row::before { display: none; }
  .table-wrap td[data-label=""], .table-wrap td.full-row { padding-left: 0; }
  .table-wrap td.actions-cell { padding-left: 0; }
  .table-wrap td.actions-cell::before { display: none; }
  .table-wrap td .actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 4px; }
  .table-wrap td .actions .btn { flex: 1 1 auto; }

  /* Listado de canales en teléfono: una fila compacta por canal */
  .table-wrap .ch-table tbody tr {
    display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 6px; padding: 10px 12px; position: static;
  }
  .table-wrap .ch-table td { padding: 0; min-height: 0; width: auto; display: block; }
  .table-wrap .ch-table td::before { display: none; }
  .table-wrap .ch-table td.col-sel { flex: 0 0 18px; }
  .table-wrap .ch-table td[data-label="Canal"] { flex: 1 1 calc(100% - 70px); min-width: 0; order: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table-wrap .ch-table td[data-label="Canal"] b { font-size: 15px; }
  .table-wrap .ch-table td[data-label="Canal"] div { display: inline; margin-left: 6px; }
  .table-wrap .ch-table td[data-label="Estado"] { order: 2; flex: 0 0 auto; width: auto; }
  .table-wrap .ch-table td.col-sel { order: 0; }
  .table-wrap .ch-table td[data-label="Video"],
  .table-wrap .ch-table td[data-label="Bitrate"],
  .table-wrap .ch-table td[data-label="En línea"] { order: 3; font-size: 12px; color: var(--muted); }
  .table-wrap .ch-table td[data-label="Video"] { flex: 0 0 auto; margin-left: 28px; }
  .table-wrap .ch-table td[data-label="Video"] b { font-weight: 600; color: var(--text); }
  .table-wrap .ch-table td[data-label="Video"] div { display: inline; margin-left: 4px; }
  .table-wrap .ch-table .list-spark svg { display: none; }
  .table-wrap .ch-table .list-spark .kbps { font-size: 12px; }
  .table-wrap .ch-table td[data-label="Origen"], .table-wrap .ch-table td[data-label="Audio"],
  .table-wrap .ch-table td[data-label="Espect."], .table-wrap .ch-table td[data-label="Reenvíos"] { display: none; }
  .table-wrap .ch-table td.actions-cell { order: 4; flex: 1 1 100%; padding-left: 28px; }
  .table-wrap .ch-table td.actions-cell .actions { margin-top: 2px; gap: 6px; }
  .table-wrap .ch-table td.actions-cell .btn { flex: 1 1 0; min-width: 0; }
  html:not([data-skin="light"]) .table-wrap .ch-table tbody tr.is-sel { background: rgba(255,77,61,.08); }
  .toolbar .seg { margin-left: auto; }
  .toolbar #ch-count { flex: 1 1 auto; }
  .selbar { left: 10px; right: 10px; transform: none; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px; white-space: normal; }
  .selbar .sel-count { padding-left: 4px; }
  .selbar .sel-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .selbar .sel-actions .btn { padding: 8px 6px; font-size: 12px; gap: 4px; }
  .selbar #sel-clear { grid-column: auto; }
  body.has-selbar .main { padding-bottom: 170px; }
  .pl-actions .btn { flex: 1 1 auto; }
  .grid-fwd { grid-template-columns: 1fr 1fr; }
  .grid-fwd > .field:nth-child(2) { grid-column: 1 / -1; order: -1; }
  .player-bar .btn span { display: none; }
  .player-bar [data-pa=audio] span { display: inline; }

  /* Modales como hoja inferior */
  .modal-back { place-items: end center; padding: 0; }
  .modal { max-width: none !important; width: 100%; max-height: calc(var(--app-h, 100vh) - 24px); border-radius: 18px 18px 0 0; animation: sheet .22s; }
  .modal-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-body { padding: 16px 16px 4px; }

  .toasts { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .login-card { padding: 26px 20px; }
  .login-skin { top: max(12px, env(safe-area-inset-top)); right: 12px; }
  .sidebar-foot .row .btn { flex: 1 1 auto; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }

/* Teléfono horizontal o pantallas muy bajas */
@media (max-height: 500px) and (orientation: landscape) {
  .modal { max-height: calc(var(--app-h, 100vh) - 8px); }
  .topbar { position: static; }
}

/* Impresión: solo el contenido */
@media print {
  .sidebar, .sidebar-backdrop, .topbar .btn, .card-actions, .toasts { display: none !important; }
  .shell { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ------------------------------------------------ multi-servidor */
.srv-pick { display: inline-flex; align-items: center; gap: 8px; }
.srv-pick select { min-width: 180px; max-width: 260px; }
.chip.srv-chip { gap: 4px; color: var(--purple); border-color: color-mix(in srgb, var(--purple) 35%, transparent); }
.chip.srv-chip.err { color: var(--err); }
.card-srv:empty { display: none; }
.card-title .card-srv { margin-left: auto; }
.srv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.srv-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.srv-card.is-off { opacity: .85; }
.srv-card .card-actions { margin: 4px -16px -16px; padding: 10px 16px; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.srv-head { display: flex; gap: 12px; align-items: flex-start; }
.srv-head h3 { margin: 0; font-size: 16px; }
.srv-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--card-2); border: 1px solid var(--line); color: var(--accent); flex: none; }
.srv-ico svg { width: 20px; height: 20px; }
.srv-sub { margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.srv-nums div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; min-width: 0; }
.srv-nums span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); }
.srv-nums b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv-nums small { color: var(--muted); font-weight: 500; }
.srv-metric .bar { margin-top: 5px; }
.srv-offline { background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 10px; padding: 12px; line-height: 1.5; }
.pl-src { max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
@media (max-width: 639px) {
  .srv-grid { grid-template-columns: 1fr; }
  .srv-nums { grid-template-columns: repeat(2, 1fr); }
  .srv-pick { width: 100%; }
  .srv-pick select { flex: 1; max-width: none; }
  .pl-src { max-width: 220px; }
}
.mig-steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.6; font-size: 13.5px; }
.mig-steps li { margin-bottom: 12px; }
.mig-steps .copy-row { margin: 6px 0 2px; }
.mig details summary { cursor: pointer; color: var(--muted); }

/* ------------------------------------------------ idioma y menú de usuario */
.top-tools { display: flex; align-items: center; gap: 10px; order: 10; }
.lang-switch { display: inline-flex; background: var(--card); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.lang-switch button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted);
  font: 600 12px var(--sans); padding: 5px 8px; border-radius: 7px; cursor: pointer; opacity: .75; }
.lang-switch button:hover { color: var(--text); opacity: 1; }
.lang-switch button.active { background: var(--card-2); color: var(--text); opacity: 1; box-shadow: inset 0 0 0 1px var(--line-2); }
.flag { width: 20px; height: 14px; border-radius: 2px; display: block; box-shadow: 0 0 0 1px rgba(0,0,0,.25); flex: none; }
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 9px; background: var(--card); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 12px; padding: 4px 10px 4px 4px; cursor: pointer; font: inherit; max-width: 240px; }
.user-btn:hover { border-color: var(--accent); }
.user-btn .chev { width: 14px; height: 14px; color: var(--muted); flex: none; transition: transform .15s; }
.user-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--purple)); color: #fff; }
.avatar svg { width: 18px; height: 18px; }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 0; }
.user-meta b { font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 11px; color: var(--muted); }
.user-dd { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 250px; background: var(--card);
  border: 1px solid var(--line-2); border-radius: 14px; padding: 6px; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.dd-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dd-head b { font-size: 14px; }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border: 0; color: var(--text);
  font: 500 13.5px var(--sans); padding: 9px 10px; border-radius: 9px; cursor: pointer; text-align: left; }
.dd-item:hover { background: var(--card-2); }
.dd-item > svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.dd-item .dd-val { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 600; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; }
.dd-item.danger, .dd-item.danger > svg { color: var(--err); }
.dd-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.login-skin { display: flex; gap: 8px; align-items: center; }
@media (max-width: 639px) {
  .user-meta, .user-btn .chev, .lang-switch span { display: none; }
  .user-btn { padding: 3px; border-radius: 50%; }
  .avatar { width: 30px; height: 30px; }
  .lang-switch button { padding: 5px 6px; }
  .user-dd { position: fixed; left: 12px; right: 12px; top: 64px; min-width: 0; }
}

/* ------------------------------------------------ mosaicos */
.mos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.mos-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.mos-preview { display: grid; gap: 3px; aspect-ratio: 16/9; background: #05070a; padding: 3px; }
.mos-cell { position: relative; border-radius: 4px; background: #141a23; display: grid; place-items: center; min-width: 0; overflow: hidden; }
.mos-cell.on { background: linear-gradient(135deg, #12351f, #0f2a3a); box-shadow: inset 0 0 0 1px rgba(53,208,127,.35); }
.mos-cell.off { background: repeating-linear-gradient(135deg, #1a1f29 0 8px, #161b24 8px 16px); }
.mos-cell.empty { background: #0d1117; }
.mos-n { position: absolute; left: 5px; top: 3px; font: 600 10px var(--mono); color: rgba(255,255,255,.45); }
.mos-name { font: 600 11px var(--sans); color: #e6edf3; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mos-cell.off .mos-name { color: #7d8796; }
.mos-audio { position: absolute; right: 5px; top: 3px; color: #ffd166; }
.mos-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.mos-body h3 { margin: 0; font-size: 16px; }
.mos-card .card-actions { border-top: 1px solid var(--line); }
.lay-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.lay-pick button { display: flex; flex-direction: column; align-items: center; gap: 5px; background: var(--card-2); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; color: var(--muted); font: 600 11px var(--sans); min-width: 78px; }
.lay-pick button.active { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
.lay-ico { width: 46px; height: 28px; fill: currentColor; opacity: .7; }
.lay-pick button.active .lay-ico { fill: var(--accent); opacity: 1; }
.mos-editor { display: grid; gap: 6px; background: #05070a; padding: 6px; border-radius: 10px; }
.mos-slot { position: relative; display: block; min-width: 0; }
.mos-slot .mos-n { left: 8px; top: 50%; transform: translateY(-50%); z-index: 1; }
.mos-slot input { width: 100%; padding-left: 26px !important; font: 500 12.5px var(--mono); min-width: 0; }
@media (max-width: 639px) {
  .mos-grid { grid-template-columns: 1fr; }
  .mos-editor { grid-template-columns: 1fr 1fr !important; }
}
.modal.modal-xl { max-width: min(1200px, 96vw) !important; }
.mp-wrap { background: #000; border-radius: 10px; overflow: hidden; }
.mp-grid { display: grid; aspect-ratio: 16/9; gap: 2px; background: #000; }
.mp-cell { position: relative; background: #101318; overflow: hidden; display: grid; place-items: center; min-width: 0; min-height: 0; }
.mp-cell video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.mp-msg { position: relative; z-index: 1; color: #8a93a3; font: 600 13px var(--sans); text-align: center; padding: 0 6px; }
.mp-cell.off { background: repeating-linear-gradient(135deg, #161b24 0 10px, #12161e 10px 20px); }
.mp-label { position: absolute; z-index: 2; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font: 700 12px var(--sans);
  padding: 3px 7px; border-radius: 5px; max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-snd, .mos-snd { display: grid; place-items: center; border: 0; cursor: pointer; border-radius: 8px; color: #fff; }
.mp-snd { position: absolute; z-index: 3; right: 8px; top: 8px; width: 34px; height: 34px; background: rgba(0,0,0,.6); }
.mp-snd svg, .mos-snd svg { width: 17px; height: 17px; }
.mp-snd.on { background: #16a34a; }
.mp-snd:not(.on) { color: #cbd5e1; }
.mp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.mos-slot { display: flex !important; align-items: center; gap: 6px; }
.mos-slot input { flex: 1; }
.mos-snd { width: 32px; height: 32px; flex: none; background: var(--card-2); border: 1px solid var(--line-2); color: var(--muted); }
.mos-snd.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.mos-slot select { flex: 1; min-width: 0; padding-left: 26px; font: 500 12.5px var(--mono); }

/* ---------- usuarios y roles ---------- */
.ur-tabs { display: inline-flex; margin-bottom: 14px; }
.ur-tabs button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; }
.ur-tabs button svg { width: 15px; height: 15px; }
.ur-user { display: inline-flex; align-items: center; gap: 8px; }
.ur-user svg { width: 16px; height: 16px; color: var(--muted); }

/* matriz de permisos: compacta, columnas fijas, la tabla no se estira */
.rm-panel { width: fit-content; max-width: 100%; min-width: min(640px, 100%); }
.rm-head { padding: 12px 16px; gap: 8px; flex-wrap: wrap; }
.rm-head h2 { font-size: 15px; }
.rm-head .btn svg { width: 13px; height: 13px; }
.rm-note { padding: 7px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); display: flex; align-items: center; gap: 6px; font-size: 12px; }
.rm-wrap { max-height: calc(100vh - 230px); overflow: auto; }
.rm-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.rm-table th, .rm-table td { border-bottom: 1px solid var(--line); padding: 0; }
.rm-table thead th {
  position: sticky; top: 0; z-index: 3; background: var(--card); vertical-align: bottom;
  padding: 10px 8px 8px; text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--line-2, var(--line));
}
.rm-table .rm-corner {
  left: 0; z-index: 4; min-width: 290px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; color: var(--dim); padding-left: 16px;
}
.rm-role { width: 118px; min-width: 118px; max-width: 118px; text-align: center; position: relative; }
.rm-role + .rm-role, .rm-c + .rm-c { border-left: 1px dashed var(--line); }
.rm-rname { font-weight: 700; font-size: 12.5px; color: var(--text); display: flex; align-items: center; justify-content: center; gap: 4px; }
.rm-rname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 104px; }
.rm-role.is-locked .rm-rname { color: var(--muted); }
.rm-role.is-locked .rm-rmeta { margin-bottom: 25px; }
.rm-rmeta { display: flex; align-items: center; justify-content: center; gap: 3px; margin-top: 3px; font-size: 11px; color: var(--muted); font-weight: 500; }
.rm-rmeta svg { opacity: .7; }
.rm-cnt { font-variant-numeric: tabular-nums; padding: 0 5px; border-radius: 99px; background: var(--card-2); color: var(--text); font-weight: 600; }
.rm-dot { opacity: .5; }
.rm-ract { display: flex; justify-content: center; gap: 4px; margin-top: 5px; opacity: .5; transition: opacity .12s; }
.rm-role:hover .rm-ract, .rm-role:focus-within .rm-ract { opacity: 1; }
.rm-ib { border: 0; background: var(--card-2); color: var(--muted); width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.rm-ib:hover { color: var(--text); }
.rm-ib.danger:hover { color: var(--err); }
.rm-role.dirty::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }

/* filas */
.rm-table tbody th, .rm-table tbody td:first-child { position: sticky; left: 0; z-index: 2; background: var(--card); text-align: left; }
.rm-sec th, .rm-sec td { background: var(--bg-2) !important; }
.rm-sec th { padding: 0 8px 0 10px; height: 32px; }
.rm-fold { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--text); font: inherit; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; cursor: pointer; padding: 0; height: 32px; }
.rm-fold > svg { color: var(--dim); transition: transform .15s; }
.rm-fold[aria-expanded="false"] > svg { transform: rotate(-90deg); }
.rm-sic { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.rm-name { padding: 0 12px 0 46px !important; height: 30px; color: var(--text); white-space: nowrap; }
.rm-c { text-align: center; height: 30px; }
.rm-act:hover td { background: color-mix(in srgb, var(--accent) 5%, var(--card)); }
.rm-table td.col-hl, .rm-table th.col-hl { background-image: linear-gradient(color-mix(in srgb, var(--accent) 6%, transparent), color-mix(in srgb, var(--accent) 6%, transparent)); }
.rm-act:last-child td { border-bottom: 0; }

/* casilla propia */
.rm-tick { display: inline-grid; place-items: center; cursor: pointer; width: 26px; height: 26px; border-radius: 6px; }
.rm-tick:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.rm-tick input { position: absolute; opacity: 0; width: 0; height: 0; }
.rm-tick span { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line-2, var(--dim)); background: var(--card); display: grid; place-items: center; transition: background .1s, border-color .1s; }
.rm-tick input:checked + span { background: var(--accent); border-color: var(--accent); }
.rm-tick input:checked + span::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.rm-tick input:indeterminate + span { background: color-mix(in srgb, var(--accent) 35%, var(--card)); border-color: var(--accent); }
.rm-tick input:indeterminate + span::after { content: ""; width: 8px; height: 2px; background: #fff; border-radius: 1px; }
.rm-tick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.rm-locked { color: var(--dim); }
.rm-locked svg { opacity: .55; }

@media (max-width: 1100px) {
  .table-wrap.rm-wrap { overflow: auto; max-height: calc(100vh - 200px); }
  .table-wrap.rm-wrap table { display: table; width: auto; }
  .table-wrap.rm-wrap thead { display: table-header-group; }
  .table-wrap.rm-wrap tbody { display: table-row-group; width: auto; }
  .table-wrap.rm-wrap tr, .table-wrap.rm-wrap tbody tr { display: table-row; width: auto; padding: 0; }
  .table-wrap.rm-wrap td, .table-wrap.rm-wrap th { display: table-cell; width: auto; min-height: 0; }
  .table-wrap.rm-wrap td.rm-c { text-align: center !important; padding: 0; }
  .table-wrap.rm-wrap td.rm-name { padding: 0 12px 0 46px; }
  .table-wrap.rm-wrap td::before { display: none; content: none; }
  .rm-ract { opacity: 1; }
}
@media (max-width: 720px) {
  .rm-panel { width: 100%; min-width: 0; }
  .rm-table .rm-corner { min-width: 150px; }
  .table-wrap.rm-wrap td.rm-name { padding: 6px 8px 6px 14px !important; white-space: normal; min-width: 150px; max-width: 170px; height: auto; line-height: 1.3; }
  .rm-role { width: 92px; min-width: 92px; max-width: 92px; }
  .rm-rname span { max-width: 80px; }
}

/* =====================================================================
   DENSIDAD COMPACTA (v1.7.1): todo el panel más chico y menos estirado
   ===================================================================== */
:root { --radius: 10px; }
body { font-size: 13px; line-height: 1.4; }

/* menú lateral */
.sidebar { padding: 14px 10px; gap: 2px; }
.sidebar .brand { padding: 2px 8px 12px; font-size: 15px; }
.nav-btn { padding: 6px 10px; gap: 9px; border-radius: 8px; font-size: 13px; }
.nav-btn svg { width: 16px; height: 16px; }
.nav-sep { margin: 6px 4px !important; }

/* página */
.main { padding: 14px 22px 48px; }
.topbar { margin-bottom: 12px; gap: 10px; }
.topbar h1 { font-size: 18px; }

/* botones, campos, interruptores */
.btn { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; gap: 5px; }
.btn svg { width: 14px; height: 14px; }
.btn.sm { padding: 4px 8px; font-size: 11.5px; border-radius: 7px; }
.btn.sm svg { width: 13px; height: 13px; }
.btn.icon { padding: 5px; }
input[type=text], input[type=password], input[type=number], select, textarea { padding: 6px 10px; border-radius: 8px; font-size: 13px; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.field { gap: 4px; margin-bottom: 10px; }
.field label { font-size: 11.5px; }
.field .hint { font-size: 11px; line-height: 1.35; }
.grid-2, .grid-3 { gap: 0 12px; }
.switch { gap: 8px; font-size: 12.5px; }
.switch .track { width: 30px; height: 17px; }
.switch .track::after { top: 2.5px; left: 2.5px; width: 12px; height: 12px; }
.switch input:checked + .track::after { transform: translateX(13px); }
.chip { padding: 1px 7px; font-size: 10.5px; gap: 4px; }
.tabs { padding: 2px; border-radius: 8px; }
.tabs button { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.alert { padding: 7px 12px; font-size: 12.5px; margin-bottom: 12px; border-radius: 8px; }
.toolbar { gap: 8px; margin-bottom: 12px; }

/* paneles y tablas */
.panel { margin-bottom: 14px; }
.panel-head { padding: 10px 14px; gap: 8px; }
.panel-head h2 { font-size: 14px; }
.panel-body { padding: 12px 14px; }
.panel-body h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 4px 0 10px !important; }
th, td { padding: 7px 12px; }
th { font-size: 10.5px; letter-spacing: .6px; }
td .actions { gap: 4px; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 3%, transparent); }

/* estadísticas y tarjetas */
.stats { gap: 10px; margin-bottom: 14px; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
.stat { padding: 10px 12px !important; }
.stat .label { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .value { font-size: 18px; }
.cards { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.card-body { padding: 10px 12px; gap: 7px; }
.card-title h3 { font-size: 15px; }
.card-info { gap: 5px; font-size: 11.5px; }
.card-actions { padding: 7px 10px; gap: 5px; }
.thumb .play svg { width: 18px; height: 18px; }

.cards { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.card-actions .btn.sm { padding: 4px 7px; }
.thumb .play { width: 42px; height: 42px; }
.thumb .res { right: 7px; bottom: 7px; font-size: 10px; padding: 2px 6px; }
.badge-live { left: 7px; top: 7px; font-size: 10px; padding: 2px 6px; }
.card-title h3 { font-size: 14.5px; }
.card-title .app { font-size: 11px; }
.meta { gap: 6px; }
.meta div { padding: 4px 7px; border-radius: 7px; }
.meta b { font-size: 12px; }
.meta span { font-size: 9.5px; }
.spark { gap: 8px; }
.spark svg { height: 28px; min-width: 0; flex: 1 1 0; }
.spark .kbps { font-size: 13px; min-width: 0; white-space: nowrap; }
.spark .kbps small { font-size: 10px; }
.ch-table td { padding: 6px 10px; }
.ch-table .ch-name b { font-size: 13px; }
.ch-table td .actions .btn { padding: 4px 6px; }
.list-spark svg { height: 22px; }
.list-spark .kbps { font-size: 12px; }

/* reenvíos, servicios, servidores, mosaicos */
.rs-card { margin-bottom: 10px; }
.rs-head { padding: 10px 14px; gap: 10px; }
.rs-head h3 { font-size: 14px; }
.rs-job { padding: 7px 14px; }
.svc-grid { gap: 12px; margin-bottom: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.svc { padding: 12px 14px; gap: 8px; }
.svc h3 { font-size: 14px; gap: 8px; }
.srv-grid { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.srv-card { padding: 12px; gap: 10px; }
.srv-card .card-actions { margin: 2px -12px -12px; padding: 7px 12px; }
.srv-head h3 { font-size: 14px; }
.srv-ico { width: 32px; height: 32px; border-radius: 8px; }
.srv-ico svg { width: 17px; height: 17px; }
.srv-nums { gap: 6px; }
.srv-nums div { padding: 4px 7px; border-radius: 7px; }
.srv-nums b { font-size: 12.5px; }
.mos-grid { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.mos-body { padding: 10px 12px; gap: 6px; }
.mos-body h3 { font-size: 14px; }
.mig-steps { font-size: 12.5px; line-height: 1.5; }
.mig-steps li { margin-bottom: 8px; }

/* ventanas */
.modal-head { padding: 11px 16px; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 14px 16px 4px; }
.modal-foot { padding: 10px 16px; gap: 6px; }

/* escritorio: los formularios no se estiran a todo lo ancho */
@media (min-width: 1100px) {
  .shell { grid-template-columns: 208px 1fr; }
  #set-form { max-width: 980px; }
  .panel-body > .grid-3, #set-form .grid-3 { grid-template-columns: repeat(3, minmax(0, 300px)); }
  .panel-body > .grid-2, form.panel-body .grid-2 { grid-template-columns: repeat(2, minmax(0, 340px)); }
  .table-wrap table { font-size: 12.5px; }
}
@media (min-width: 1700px) {
  #view { max-width: 1560px; }
}
.mig { max-width: 1000px; }
.mig .copy-row input { font-size: 12px; }
.svc h3 > svg { width: 17px; height: 17px; flex: none; color: var(--accent); }
.svc h3 .chip { margin-left: auto; }
.svc .row { gap: 6px; flex-wrap: wrap; }

/* ---------- verificación en dos pasos ---------- */
.tfa-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 10px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.tfa-ico svg { width: 24px; height: 24px; }
.login-card .tfa-title { margin: 0 0 4px; color: var(--text); font-weight: 700; font-size: 15px; }
.login-card #tfa-help { margin: 0 0 16px; }
.tfa-input { font: 600 20px var(--mono) !important; letter-spacing: 6px; text-align: center; }
.tfa-links { display: flex; justify-content: space-between; gap: 10px; margin: -2px 0 12px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
#tfa-back { color: var(--muted); }
.tfa-setup { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 8px; }
.tfa-qr { flex: none; background: #fff; border-radius: 10px; padding: 6px; border: 1px solid var(--line); line-height: 0; }
.tfa-qr img { display: block; width: 190px; height: 190px; image-rendering: pixelated; }
.tfa-steps { margin: 0; padding-left: 18px; line-height: 1.5; min-width: 0; flex: 1; }
.tfa-steps li { margin-bottom: 8px; }
.tfa-steps .copy-row input { font-size: 12px; letter-spacing: .5px; }
.tfa-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tfa-codes code { font: 600 14px var(--mono); padding: 7px 10px; text-align: center; border-radius: 8px;
  background: var(--bg-2); border: 1px dashed var(--line-2); letter-spacing: 1px; }
.tfa-status { display: flex; gap: 12px; align-items: center; }
.tfa-badge { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tfa-badge svg { width: 20px; height: 20px; }
@media (max-width: 560px) {
  .tfa-setup { flex-direction: column; align-items: center; }
  .tfa-input { font-size: 22px !important; }
}
.tfa-cell { display: inline-flex; align-items: center; gap: 6px; }
.tfa-cell .btn.sm { padding: 2px 7px; }
.sec-row { display: flex; align-items: center; gap: 12px; }
.sec-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--card-2); color: var(--muted); }
.sec-ico.on { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.sec-txt { flex: 1; min-width: 0; }
.sec-txt b { font-size: 13.5px; }
.tfa-login-qr { display: flex; justify-content: center; }
.tfa-login-qr img { background: #fff; border-radius: 10px; padding: 6px; border: 1px solid var(--line); width: 180px; height: 180px; image-rendering: pixelated; }
.tfa-secret { text-align: center; font-size: 12.5px; letter-spacing: .5px; padding: 6px 8px; border-radius: 8px; background: var(--bg-2); border: 1px dashed var(--line-2); user-select: all; word-break: break-all; }
#login-step3 p.small { margin: 0 0 12px; }

/* Pie de página */
.site-footer { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line-2, rgba(127,127,127,.18));
  text-align: center; font-size: 12px; color: var(--muted); }
.site-footer a { color: var(--accent-2); font-weight: 600; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.main { display: flex; flex-direction: column; }
.main > #view { flex: 1 0 auto; }
.main > .site-footer { margin-top: 40px; }
.login-wrap { grid-template-rows: 1fr auto; }
.login-wrap .site-footer { margin-top: 0; border-top: 0; padding: 0 0 4px; align-self: end; }
