/* ==========================================================
   CCSB Portal — estilos
   ========================================================== */

:root {
  color-scheme: dark;
  --bg: #070b16;
  --bg-2: #0b1120;
  --surface: #0f1626;
  --surface-2: #131c2f;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #f1f5f9;
  --text-soft: #a3b0c2;
  --text-dim: #7b8aa0;
  --green: #4ade80;
  --cyan: #22d3ee;
  --accent: #34d8b0;
  --danger: #f87171;
  --grad: linear-gradient(120deg, var(--green) 0%, var(--cyan) 100%);
  --radius: 14px;
  --radius-lg: 18px;
  --sidebar-w: 248px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--text-dim); }
.small { font-size: 13px; }

/* ── Marca ── */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 30px; height: 30px; }
.brand span { font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: 14px; }
.brand em {
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  color: var(--accent);
  margin-left: 2px;
}

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 11px; border: 1px solid transparent;
  font-weight: 600; font-size: 14.5px; cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--grad); color: #03140d; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { border-color: var(--border-strong); background: rgba(255,255,255,.02); }
.btn-ghost:hover { background: rgba(255,255,255,.06); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; border-radius: 9px; }
.btn-google { width: 100%; height: 48px; background: #fff; color: #1f2937; font-size: 15px; }
.btn-google svg { width: 20px; height: 20px; }
.btn-google:hover { background: #f3f4f6; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 9px;
  background: transparent; border: 1px solid var(--border); cursor: pointer; color: var(--text-soft);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.link-btn { background: none; border: 0; color: var(--text-dim); cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Alertas ── */
.alert { padding: 12px 16px; border-radius: 11px; font-size: 14px; margin-bottom: 20px; border: 1px solid; }
.alert-ok { background: rgba(74,222,128,.08); border-color: rgba(74,222,128,.3); color: #bbf7d0; }
.alert-error { background: rgba(248,113,113,.08); border-color: rgba(248,113,113,.3); color: #fecaca; }

/* ── Login ── */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(600px circle at 15% 0%, rgba(74,222,128,.10), transparent 60%),
    radial-gradient(600px circle at 90% 100%, rgba(34,211,238,.10), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px; padding: 40px 32px;
  border-radius: 22px; border: 1px solid var(--border-strong); background: var(--surface);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.7);
}
.auth-card .brand { margin-bottom: 32px; }
.auth-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 8px; }
.auth-card p { color: var(--text-soft); margin-bottom: 28px; }
.auth-foot { font-size: 13px; color: var(--text-dim) !important; margin: 24px 0 0 !important; text-align: center; }

/* ── Layout app ── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  display: flex; flex-direction: column; gap: 24px;
  padding: 22px 16px; background: var(--bg-2); border-right: 1px solid var(--border);
  z-index: 40; transition: transform .25s ease;
}
.sidebar .brand { padding: 4px 8px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-dim); padding: 16px 10px 6px;
}
.side-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--text-soft); font-weight: 500; font-size: 14.5px;
}
.side-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.side-nav a:hover { background: rgba(255,255,255,.04); color: var(--text); }
.side-nav a.active { background: rgba(52,216,176,.1); color: var(--text); }
.side-nav a.active svg { color: var(--accent); }
.side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px 4px; border-top: 1px solid var(--border);
}
.side-user img, .avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.avatar { display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: 14px; color: var(--accent); }
.side-user .who { flex: 1; min-width: 0; }
.side-user strong { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user span { font-size: 12px; color: var(--text-dim); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 64px; padding: 0 32px;
  background: rgba(7,11,22,.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 16px; font-weight: 600; }
.menu-btn { display: none; }
.content { padding: 32px; max-width: 1280px; }
.scrim { display: none; }

/* ── Encabezados de página ── */
.page-head { margin-bottom: 28px; }
.page-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 4px; }
.page-head p { color: var(--text-soft); }
.page-head.with-actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

/* ── Paneles ── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; }
.panel h3 { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.empty {
  text-align: center; padding: 64px 24px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}
.empty h2 { font-size: 20px; margin-bottom: 8px; letter-spacing: -0.02em; }
.empty p { color: var(--text-soft); max-width: 460px; margin: 0 auto 24px; }

/* ── Módulos (inicio) ── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.module-card {
  display: flex; flex-direction: column; padding: 24px;
  border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface);
  transition: border-color .2s ease, transform .2s ease;
}
.module-card:hover { border-color: rgba(52,216,176,.35); transform: translateY(-2px); }
.module-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 18px;
  color: var(--accent); background: rgba(52,216,176,.1); border: 1px solid rgba(52,216,176,.22);
}
.module-icon svg { width: 22px; height: 22px; }
.module-card h3 { font-size: 17px; margin-bottom: 6px; }
.module-card p { color: var(--text-soft); font-size: 14px; margin-bottom: 18px; }
.module-go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--accent); }
.module-go svg { width: 15px; height: 15px; }

/* ── Controles segmentados ── */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); }
.segmented button {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--text-soft);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.segmented.small button { padding: 5px 11px; font-size: 13px; }

/* ── KPIs ── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.kpi span { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.kpi strong { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi small { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.kpi.skeleton strong { color: var(--text-dim); }

/* ── Gráfico ── */
.chart-panel { margin-bottom: 20px; }
.chart-wrap { position: relative; height: 320px; }
.chart-note { margin-top: 10px; }

/* ── Tablas ── */
.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.two-col > *, .kpis > * { min-width: 0; }
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim); padding: 0 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .actions { text-align: right; }
.ch { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.ch img { width: 28px; height: 28px; border-radius: 50%; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; background: var(--border-strong); }
.ch-title { font-weight: 600; }
tr.has-error td { color: var(--text-dim); }

.top-videos { list-style: none; display: grid; gap: 4px; counter-reset: v; }
.top-videos li { counter-increment: v; }
.top-videos a {
  display: grid; grid-template-columns: 22px 64px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 8px; border-radius: 10px;
}
.top-videos a:hover { background: rgba(255,255,255,.04); }
.top-videos a::before { content: counter(v); font-size: 13px; color: var(--text-dim); text-align: center; font-variant-numeric: tabular-nums; }
.top-videos img { width: 64px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.top-videos .vt { min-width: 0; }
.top-videos .vt strong { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-videos .vt span { font-size: 12.5px; color: var(--text-dim); }
.top-videos .vv { font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--text-soft); }

/* ── Formularios (admin) ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field span, .checks legend { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field input, .field select {
  height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--bg-2);
}
.field select:disabled { opacity: .6; }
.field.grow { flex: 1; min-width: 220px; }
.field.compact select { height: 36px; }
.add-user { margin-bottom: 24px; display: grid; gap: 16px; }
.add-user .btn { justify-self: start; }
.add-user-row { display: flex; gap: 12px; flex-wrap: wrap; }
.checks { border: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.checks legend { margin-bottom: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.user-list { display: grid; gap: 10px; }
.user-row {
  display: grid; grid-template-columns: minmax(220px, 1.4fr) 150px 1.4fr 90px auto;
  align-items: center; gap: 16px; padding: 16px 20px;
}
.user-row.inactive { opacity: .55; }
.user-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-id img { width: 36px; height: 36px; border-radius: 50%; }
.user-id strong { display: block; font-size: 14px; }
.user-id span { font-size: 13px; color: var(--text-dim); word-break: break-all; }
.checks.compact legend { display: none; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .user-row { grid-template-columns: 1fr 1fr; }
  .user-row .user-id { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 40px; }
}

@media (max-width: 520px) {
  .kpi strong { font-size: 22px; }
  .kpi { padding: 14px 16px; }
  .kpis { gap: 10px; }
  .panel { padding: 18px 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .chart-wrap { height: 260px; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .user-row { grid-template-columns: 1fr; }
  .top-videos a { grid-template-columns: 18px 56px minmax(0, 1fr); row-gap: 2px; }
  .top-videos .vv { grid-column: 3; font-size: 12.5px; }
  .page-head h2 { font-size: 22px; }
}
.auth-foot a { color: var(--text-soft); text-decoration: underline; text-underline-offset: 3px; }

/* ==========================================================
   Módulos con secciones, filtro, en vivo, comentarios y PWA
   ========================================================== */
[hidden] { display: none !important; }

/* ── Submenú lateral ── */
.side-sub { display: none; flex-direction: column; gap: 1px; margin: 2px 0 6px 20px; padding-left: 10px; border-left: 1px solid var(--border); }
.side-sub.open { display: flex; }
.side-nav .side-sub a { padding: 7px 10px; font-size: 14px; color: var(--text-dim); }
.side-nav .side-sub a:hover { color: var(--text); }
.side-nav .side-sub a.current { color: var(--text); background: rgba(255,255,255,.05); }

/* ── Migas y pestañas del módulo ── */
.topbar h1 { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb { color: var(--text-dim); font-weight: 500; }
.crumb:hover { color: var(--text); }
.crumb-sep { color: var(--text-dim); opacity: .6; }
.mod-tabs {
  position: sticky; top: 64px; z-index: 25;
  display: flex; gap: 4px; padding: 0 32px;
  background: rgba(7,11,22,.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.mod-tabs::-webkit-scrollbar { display: none; }
.mod-tabs a {
  position: relative; padding: 13px 12px; font-size: 14px; font-weight: 500; color: var(--text-soft); white-space: nowrap;
}
.mod-tabs a:hover { color: var(--text); }
.mod-tabs a.current { color: var(--text); }
.mod-tabs a.current::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--grad);
}

/* ── Barra de herramientas ── */
.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }

/* ── Filtro de canales ── */
.ch-filter { position: relative; }
.ch-filter-btn { gap: 8px; max-width: 280px; }
.ch-filter-btn .ch-filter-label { overflow: hidden; text-overflow: ellipsis; }
.ch-filter-btn .chev { width: 14px; height: 14px; color: var(--text-dim); transition: transform .15s ease; }
.ch-filter-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.ch-filter.filtered .ch-filter-btn { border-color: rgba(52,216,176,.45); background: rgba(52,216,176,.08); }
.ch-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  width: 300px; max-width: calc(100vw - 32px); max-height: 60vh; overflow-y: auto;
  padding: 6px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border-strong);
  box-shadow: 0 20px 50px -12px rgba(0,0,0,.7);
}
.ch-opt { display: flex; width: 100%; padding: 9px 10px; border-radius: 8px; gap: 10px; }
.ch-opt:hover { background: rgba(255,255,255,.05); }
.ch-opt-all { border-bottom: 1px solid var(--border); border-radius: 8px 8px 0 0; margin-bottom: 4px; font-weight: 600; }
.ch-opt-img { width: 22px; height: 22px; border-radius: 50%; }
.ch-opt-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-only {
  border: 0; background: none; cursor: pointer; font-size: 12.5px; color: var(--text-dim);
  padding: 2px 6px; border-radius: 6px; opacity: 0;
}
.ch-opt:hover .ch-only, .ch-only:focus-visible { opacity: 1; }
.ch-only:hover { color: var(--accent); }
@media (hover: none) { .ch-only { opacity: 1; } }

/* ── Avisos y etiquetas ── */
.alert-info { background: rgba(57,135,229,.08); border-color: rgba(57,135,229,.3); color: #cfe0f7; }
.alert a { text-decoration: underline; text-underline-offset: 3px; }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-soft); background: rgba(255,255,255,.06); white-space: nowrap;
}
.tag-ok { color: #bbf7d0; background: rgba(74,222,128,.12); }
.tag-error { color: #fecaca; background: rgba(248,113,113,.12); }
.chart-note a { color: var(--text-soft); text-decoration: underline; text-underline-offset: 3px; }

/* ── En vivo ── */
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.live-badge {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: #bbf7d0; background: rgba(74,222,128,.1); border: 1px solid rgba(74,222,128,.25);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-in-out infinite; }
.live-badge.paused { color: var(--text-dim); background: rgba(255,255,255,.04); border-color: var(--border); }
.live-badge.paused .live-dot { background: var(--text-dim); animation: none; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(74,222,128,.6); } 50% { box-shadow: 0 0 0 6px rgba(74,222,128,0); } }
.delta { display: inline-block; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--green); }
.delta.down { color: var(--danger); }
.kpi small .delta { font-size: 12.5px; }
#liveChannels, .recent-list { margin-bottom: 0; }
.panel + .panel, .kpis + .panel, #liveError + .panel { margin-top: 20px; }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.live-card { padding: 16px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--border); min-width: 0; }
.live-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-width: 0; }
.live-card-head img { width: 32px; height: 32px; border-radius: 50%; }
.live-card-head strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.live-stat span { display: block; font-size: 12px; color: var(--text-dim); }
.live-stat strong { display: block; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.recent { display: flex; gap: 12px; padding: 8px; border-radius: 12px; min-width: 0; }
.recent:hover { background: rgba(255,255,255,.04); }
.recent-thumb { width: 120px; height: 68px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--surface-2); }
.recent-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.recent-body strong { font-size: 14px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recent-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); min-width: 0; }
.recent-meta span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-nums { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-soft); font-variant-numeric: tabular-nums; }

/* ── Comentarios ── */
.comment-list { display: grid; gap: 12px; }
.thread { padding: 16px 18px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.thread.answered { border-color: rgba(74,222,128,.18); }
.thread-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px; min-width: 0; }
.thread-ch { font-weight: 600; color: var(--text-soft); }
.thread-video { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 160px; }
.thread-video::before { content: '· '; }
.thread-video:hover { color: var(--text); }
.cm { display: flex; gap: 12px; min-width: 0; }
.cm-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; background: var(--surface-2); }
.cm-body { min-width: 0; flex: 1; }
.cm-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.cm-author { font-weight: 600; font-size: 14px; }
a.cm-author:hover { text-decoration: underline; }
.cm-time { font-size: 12.5px; color: var(--text-dim); }
.cm-text { font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.cm-likes { display: inline-block; margin-top: 4px; font-size: 12.5px; color: var(--text-dim); }
.replies { margin: 10px 0 0 48px; display: grid; gap: 10px; }
.replies:empty { display: none; }
.cm.reply .cm-avatar { width: 28px; height: 28px; }
.thread-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0 48px; }
.reply-form { margin: 12px 0 0 48px; display: grid; gap: 8px; }
.reply-form textarea {
  width: 100%; resize: vertical; min-height: 80px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--bg-2); font: inherit; color: var(--text); font-size: 14.5px;
}
.reply-form textarea:focus { outline: none; border-color: var(--accent); }
.reply-row { display: flex; gap: 8px; justify-content: flex-end; }
.form-error { color: #fecaca; font-size: 13px; }
.small-empty { padding: 40px 24px; color: var(--text-soft); }

/* ── Canales ── */
.channel-list { display: grid; gap: 10px; margin-bottom: 20px; }
.channel-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 16px; padding: 16px 20px; }
.channel-row .ch { min-width: 0; }
.channel-row .ch img { width: 40px; height: 40px; }
.channel-row .ch > div { min-width: 0; display: flex; flex-direction: column; }
.channel-row .ch-title:hover { text-decoration: underline; }
.channel-status, .channel-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.channel-error { grid-column: 1 / -1; font-size: 13px; color: #fecaca; }
.help ol { margin: 12px 0 10px 20px; display: grid; gap: 6px; color: var(--text-soft); font-size: 14px; }
.help a { text-decoration: underline; text-underline-offset: 3px; }

/* ── Deslizar para actualizar (app instalada) ── */
.ptr {
  position: fixed; top: 0; left: 50%; z-index: 60;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-soft);
  box-shadow: 0 8px 24px rgba(0,0,0,.5); opacity: 0; transform: translate(-50%, -48px); pointer-events: none;
  margin-top: env(safe-area-inset-top);
}
.ptr svg { width: 20px; height: 20px; }
.ptr.ready { color: var(--accent); }
.ptr.settle { transition: transform .25s ease, opacity .25s ease; }
.ptr.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.standalone, .standalone body { overscroll-behavior-y: none; }
.standalone .topbar { padding-top: env(safe-area-inset-top); height: calc(64px + env(safe-area-inset-top)); }
.standalone .mod-tabs { top: calc(64px + env(safe-area-inset-top)); }
.standalone .sidebar { padding-top: calc(22px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.standalone .content { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

@media (max-width: 860px) {
  .mod-tabs { padding: 0 8px; }
}
@media (max-width: 640px) {
  .kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpis-3 .kpi { padding: 12px; }
  .kpis-3 .kpi strong { font-size: 17px; }
  .kpis-3 .kpi span { font-size: 12px; }
  .channel-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .replies, .thread-actions, .reply-form { margin-left: 0; }
  .thread { padding: 14px; }
  .recent-list { grid-template-columns: minmax(0, 1fr); }
  .recent-thumb { width: 104px; height: 58px; }
  .toolbar { align-items: flex-start; }
  .toolbar-left { width: 100%; }
  .ch-filter-btn { max-width: 200px; }
}
.live-card-head img, .cm-avatar, .ch-opt-img { background: var(--surface-2); }
.kpi small:empty { display: none; }
