/* Jota Player Admin · diseño pensado primero para el teléfono */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --border: #e2e7ef;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #e6eeff;
  --ok: #15803d;   --ok-soft: #dcfce7;
  --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c;  --bad-soft: #fee2e2;
  --info: #6d28d9; --info-soft: #ede9fe;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 4px 14px rgb(15 23 42 / .05);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #121a2b; --surface-2: #1a2438; --border: #253149;
    --text: #e6eaf2; --muted: #94a3b8; --primary: #3b82f6; --primary-soft: #172a4d;
    --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #3a2a0a;
    --bad: #f87171; --bad-soft: #3b1414; --info: #a78bfa; --info-soft: #261c45;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace; letter-spacing: .02em; }
.strong { font-weight: 700; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px 16px; }
.login .card { width: 100%; max-width: 400px; padding: 28px 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 14px; height: 14px; fill: #fff; margin-left: 2px; }

/* ---------- Estructura ---------- */
.shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

.main { padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 24px); max-width: 1100px; margin: 0 auto; }
.page-head { display: none; }

/* Barra inferior (teléfono) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--border);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.active { color: var(--primary); }
.nav a.only-desk { display: none; }
.side-brand, .side-foot { display: none; }

/* Escritorio: barra lateral */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .topbar { display: none; }
  .side { position: sticky; top: 0; height: 100dvh; background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; }
  .side-brand { display: flex; }
  .side-foot { display: block; margin-top: auto; font-size: 12px; color: var(--muted); word-break: break-all; }
  .nav { position: static; display: flex; flex-direction: column; gap: 2px; height: auto; padding: 0; border: 0; background: none; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
  .nav a svg { width: 19px; height: 19px; }
  .nav a:hover { background: var(--surface-2); color: var(--text); }
  .nav a.active { background: var(--primary-soft); }
  .nav a.only-desk { display: flex; }
  .nav a.only-mob { display: none; }
  .main { padding: 28px 32px 48px; margin: 0; }
  .page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
}

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .card + .list, .list + .card { margin-top: 14px; }
.grid > .card { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(2, 1fr); margin: 14px 0; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; line-height: 1.3; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.hl { background: var(--primary); border-color: var(--primary); color: #fff; }
.kpi.hl .label { color: rgb(255 255 255 / .8); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.danger { color: var(--bad); }
.btn.danger-fill { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (min-width: 900px) { .btn:hover:not(:disabled) { filter: brightness(.97); } .btn.primary:hover { filter: brightness(1.08); } }

label.field { display: grid; gap: 6px; font-weight: 600; font-size: 13.5px; margin-bottom: 14px; }
input, select, textarea {
  font: inherit; font-size: 16px; /* 16px evita el zoom automático en iPhone */
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; width: 100%; min-height: 48px;
}
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .item:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.search-bar { position: sticky; top: calc(61px + var(--safe-t)); z-index: 10; background: var(--bg); padding: 2px 0 12px; display: flex; gap: 8px; }
.search-bar input { flex: 1; }
@media (min-width: 900px) { .search-bar { top: 0; } }

/* Listas tipo tarjeta (todas las pantallas) */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  width: 100%; text-align: left; padding: 14px 16px; background: none; border: 0; color: inherit; font: inherit;
  border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: 0; }
button.item { cursor: pointer; }
button.item:active { background: var(--surface-2); }
@media (min-width: 900px) { button.item:hover { background: var(--surface-2); } }
.item .t { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; flex-wrap: wrap; }
.item .s { grid-column: 1; color: var(--muted); font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.item .r { grid-row: 1 / span 3; grid-column: 2; text-align: right; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.item .big { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.chev { width: 18px; height: 18px; color: var(--muted); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.more { padding: 12px; text-align: center; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-active { background: var(--ok-soft); color: var(--ok); }
.b-trial { background: var(--info-soft); color: var(--info); }
.b-expired { background: var(--warn-soft); color: var(--warn); }
.b-blocked, .b-suspended { background: var(--bad-soft); color: var(--bad); }
.pos { color: var(--ok); } .neg { color: var(--bad); }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }

/* Ficha de detalle */
.hero { text-align: center; padding: 4px 0 16px; }
.hero .id { font-size: 22px; font-weight: 700; margin: 6px 0; word-break: break-all; }
.chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0 0 16px; padding: 14px 16px; background: var(--surface-2); border-radius: 12px; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; text-align: right; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.copy { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; padding: 4px; }
.section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 18px; }

/* Ventanas: hoja inferior en teléfono, centrada en escritorio */
dialog {
  border: 0; padding: 0; color: var(--text); background: var(--surface);
  width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0 0;
  border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / .25);
}
dialog[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
dialog::backdrop { background: rgb(15 23 42 / .5); }
.sheet { padding: 8px 18px calc(20px + var(--safe-b)); max-height: 92dvh; overflow: auto; overscroll-behavior: contain; }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
@media (min-width: 700px) {
  dialog { width: min(600px, calc(100vw - 32px)); margin: auto; border-radius: 18px; }
  dialog[open] { animation: none; }
  .grabber { display: none; }
  .sheet { padding: 22px 24px; max-height: 88dvh; }
  #ask { width: min(420px, calc(100vw - 32px)); }
}

#toast {
  position: fixed; inset: auto auto calc(var(--nav-h) + var(--safe-b) + 14px) 50%; margin: 0; border: 0;
  transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 8px 24px rgb(0 0 0 / .25);
}
@media (min-width: 900px) { #toast { bottom: 24px; } }
#toast.error { background: var(--bad); color: #fff; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 0 0 8px; }

@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } .btn:active { transform: none; } }
