:root {
  --bg: #060b18;
  --bg-2: #0a1128;
  --bg-3: #0f1b3d;
  --card: #0a1128;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .14);
  --text: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --primary: #f97316;
  --primary-2: #fb923c;
  --primary-d: #ea580c;
  --sky: #0ea5e9;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 18px;
  --nav-h: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 50% -120px, rgba(249, 115, 22, .13), transparent 70%),
    radial-gradient(700px 400px at 100% 10%, rgba(14, 165, 233, .08), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--primary-2); }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

/* ---------- estructura ---------- */
.shell { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--sat) + 12px) 16px 12px;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(6, 11, 24, .96) 60%, rgba(6, 11, 24, 0));
  backdrop-filter: blur(8px);
}
.topbar .logo { width: 34px; height: 34px; border-radius: 10px; flex: none; }
.topbar h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; flex: 1; }
.topbar .sub { font-size: .8rem; color: var(--text-2); font-weight: 500; display: block; margin-top: 1px; }
.content { flex: 1; padding: 4px 16px calc(var(--nav-h) + var(--sab) + 28px); }
.content > * + * { margin-top: 14px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding-bottom: var(--sab);
  background: rgba(6, 13, 31, .92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav-in { width: 100%; max-width: 640px; display: flex; }
.nav a {
  flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--text-3); font-size: .72rem; font-weight: 600; position: relative; transition: color .15s;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--primary-2); }
.nav a.on::before { content: ""; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 4px 4px; background: var(--primary); }
.nav .dot { position: absolute; top: 10px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }

/* ---------- componentes ---------- */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, 0)), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.card.tight { padding: 0; overflow: hidden; }
.section-title { margin-top: 20px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); margin-bottom: 8px; margin-left: 4px; margin-right: 4px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 650; font-size: .98rem;
  transition: transform .08s, background .15s, opacity .15s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: linear-gradient(180deg, var(--primary-2), var(--primary)); color: #1a0d02; box-shadow: 0 6px 20px rgba(249, 115, 22, .28); }
.btn.ghost { background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2); }
.btn.danger { background: rgba(239, 68, 68, .14); border: 1px solid rgba(239, 68, 68, .4); color: #fca5a5; }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: .88rem; border-radius: 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .76rem; font-weight: 650; background: rgba(255, 255, 255, .07); color: var(--text-2); white-space: nowrap; }
.chip.ok { background: rgba(34, 197, 94, .14); color: #86efac; }
.chip.warn { background: rgba(245, 158, 11, .15); color: #fcd34d; }
.chip.bad { background: rgba(239, 68, 68, .15); color: #fca5a5; }
.chip.live { background: rgba(239, 68, 68, .16); color: #fca5a5; }
.chip.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); animation: pulse 1.6s infinite; }
.chip.accent { background: rgba(249, 115, 22, .15); color: var(--primary-2); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.8); } }

.banner { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; font-size: .88rem; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .04); color: var(--text-2); }
.banner svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.banner.warn { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .35); color: #fcd34d; }
.banner.bad { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .35); color: #fca5a5; }
.banner.info { background: rgba(14, 165, 233, .1); border-color: rgba(14, 165, 233, .3); color: #7dd3fc; }

.avatar { width: 56px; height: 56px; border-radius: 16px; flex: none; background: var(--bg-3) center/contain no-repeat; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 800; color: var(--primary-2); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.avatar.sm { width: 44px; height: 44px; border-radius: 12px; font-size: .9rem; }
.avatar.lg { width: 72px; height: 72px; border-radius: 20px; font-size: 1.4rem; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 28px 22px calc(28px + var(--sab)); max-width: 440px; margin: 0 auto; }
.login .brand { text-align: center; margin-bottom: 26px; }
.login .brand img { width: 92px; height: 92px; border-radius: 26px; box-shadow: 0 14px 40px rgba(249, 115, 22, .22), 0 0 0 1px var(--line); }
.login .brand h1 { font-size: 1.9rem; margin-top: 16px; letter-spacing: -.02em; }
.login .brand p { color: var(--text-2); margin-top: 4px; }
.field { display: block; }
.field + .field { margin-top: 14px; }
.field > span { display: block; font-size: .8rem; color: var(--text-2); font-weight: 600; margin: 0 4px 6px; }
.input {
  width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px; background: var(--bg-3);
  border: 1px solid var(--line-2); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(249, 115, 22, .2); }
textarea.input { padding: 12px 16px; min-height: 84px; resize: vertical; }
.pass { position: relative; }
.pass .input { padding-right: 52px; }
.pass button { position: absolute; right: 4px; top: 4px; width: 42px; height: 42px; color: var(--text-2); display: grid; place-items: center; }
.pass svg { width: 22px; height: 22px; }
.login .foot { text-align: center; margin-top: 18px; color: var(--text-3); font-size: .82rem; }

/* ---------- ahora en reproduccion ---------- */
.now { position: relative; overflow: hidden; }
.now::before { content: ""; position: absolute; inset: 0; background: radial-gradient(420px 160px at 0% 0%, rgba(249, 115, 22, .13), transparent 70%); pointer-events: none; }
.now > * { position: relative; }
.now h3 { font-size: 1.2rem; font-weight: 750; letter-spacing: -.01em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fact { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); font-size: .92rem; }
.fact svg { width: 22px; height: 22px; flex: none; color: var(--primary-2); }
.fact.alone svg { color: var(--ok); }
.fact b { font-weight: 700; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions .btn { flex: 1; }
.empty { text-align: center; padding: 30px 20px; }
.empty img { width: 84px; height: 84px; border-radius: 24px; opacity: .55; filter: grayscale(.35); }
.empty h3 { margin-top: 14px; font-size: 1.1rem; }
.empty p { margin-top: 6px; color: var(--text-2); font-size: .92rem; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); text-align: left; display: block; width: 100%; }
a.stat { text-decoration: none; color: inherit; }
.stat .n { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.stat .l { font-size: .78rem; color: var(--text-2); font-weight: 600; margin-top: 2px; }
.stat.full { grid-column: 1 / -1; }

/* ---------- canales ---------- */
.searchbar { position: sticky; top: calc(var(--sat) + 58px); z-index: 15; padding: 4px 0 8px; background: linear-gradient(180deg, var(--bg) 70%, rgba(6, 11, 24, 0)); margin-top: 0 !important; }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 14px; width: 22px; height: 22px; color: var(--text-3); }
.search .input { padding-left: 46px; }
.catrow { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.catrow::-webkit-scrollbar { display: none; }
.pill { flex: none; padding: 8px 14px; border-radius: 999px; font-size: .85rem; font-weight: 650; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--text-2); }
.pill.on { background: rgba(249, 115, 22, .16); border-color: rgba(249, 115, 22, .6); color: var(--primary-2); }
.pill small { opacity: .7; margin-left: 4px; font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); margin-top: 10px; }
.seg button { padding: 8px 0; border-radius: 10px; font-size: .86rem; font-weight: 650; color: var(--text-2); }
.seg button.on { background: var(--bg-3); color: var(--text); box-shadow: 0 1px 0 var(--line-2) inset; }
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); width: 100%; text-align: left; transition: background .12s; }
.item:first-child { border-top: 0; }
.item:active { background: rgba(255, 255, 255, .04); }
.item .name { font-weight: 600; font-size: .97rem; }
.item.off .name, .item.off .avatar { opacity: .42; }
.item.off .name { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, .3); }
.switch { width: 50px; height: 30px; border-radius: 999px; background: rgba(255, 255, 255, .14); position: relative; flex: none; transition: background .18s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }
.bulk { display: flex; gap: 8px; margin-top: 12px; }
.bulk .btn { flex: 1; }
.more { text-align: center; padding: 14px; color: var(--text-3); font-size: .85rem; }

/* ---------- cuenta ---------- */
.profile { display: flex; align-items: center; gap: 14px; }
.profile h2 { font-size: 1.3rem; letter-spacing: -.01em; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.kv > div { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.kv .l { font-size: .74rem; color: var(--text-2); font-weight: 600; }
.kv .v { font-weight: 700; margin-top: 2px; }
form.stack > * + * { margin-top: 12px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

/* ---------- hoja inferior ---------- */
#sheet-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.backdrop { position: absolute; inset: 0; background: rgba(2, 6, 16, .66); backdrop-filter: blur(3px); opacity: 0; transition: opacity .2s; pointer-events: auto; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: #0b132c; border: 1px solid var(--line-2); border-bottom: 0; border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(18px + var(--sab)); transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .9, .3, 1); pointer-events: auto;
}
#sheet-root.open .backdrop { opacity: 1; }
#sheet-root.open .sheet { transform: none; }
.grab { width: 44px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .22); margin: 2px auto 14px; }
.sheet h3 { font-size: 1.25rem; letter-spacing: -.01em; }
.sheet .lead { color: var(--text-2); font-size: .92rem; margin-top: 4px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; border-radius: 16px; border: 1.5px solid var(--line-2); background: rgba(255, 255, 255, .03); text-align: left; transition: border-color .15s, background .15s; }
.opt + .opt { margin-top: 8px; }
.opt.on { border-color: var(--primary); background: rgba(249, 115, 22, .1); }
.opt.cur { opacity: .6; }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; display: grid; place-items: center; }
.opt.on .radio { border-color: var(--primary); }
.opt.on .radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.opt .t { font-weight: 650; }
.opt .s { font-size: .82rem; color: var(--text-2); margin-top: 1px; }
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.reasons .opt { padding: 12px; }
.reasons .opt + .opt { margin-top: 0; }
.reasons .t { font-size: .9rem; }
.sheet .foot { display: flex; gap: 10px; margin-top: 16px; }
.sheet .foot .btn { flex: 1; }

/* ---------- varios ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--sab) + 18px); transform: translate(-50%, 20px); z-index: 80;
  max-width: min(92vw, 460px); padding: 12px 18px; border-radius: 14px; background: #1a2547; border: 1px solid var(--line-2);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5); font-size: .92rem; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: rgba(239, 68, 68, .5); color: #fecaca; }
#toast.ok { border-color: rgba(34, 197, 94, .5); }
.skeleton { border-radius: 14px; background: linear-gradient(90deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .09), rgba(255, 255, 255, .04)); background-size: 200% 100%; animation: sk 1.3s infinite; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
@media (min-width: 700px) {
  .sheet { border-radius: 26px; bottom: 6vh; border-bottom: 1px solid var(--line-2); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
