/* ═══════════════════════════════════════════════════════════════════════════
   Panel Tenants M365 — prototipo
   Mobile-first. Oscuro por defecto, claro disponible. Sin dependencias.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────────────────── */

:root {
  --bg:            #0b0f16;
  --bg-elev:       #111825;
  --surface:       #141c2a;
  --surface-2:     #1a2434;
  --surface-3:     #22304a;
  --border:        #24304a;
  --border-soft:   #1b2436;

  --text:          #e8edf6;
  --text-dim:      #9aa8c0;
  --text-faint:    #64748b;

  --accent:        #5b8cff;
  --accent-soft:   rgba(91, 140, 255, .14);
  --accent-text:   #a9c2ff;

  --ok:            #34d399;
  --ok-soft:       rgba(52, 211, 153, .13);
  --warn:          #fbbf24;
  --warn-soft:     rgba(251, 191, 36, .13);
  --danger:        #f87171;
  --danger-soft:   rgba(248, 113, 113, .13);
  --muted:         #64748b;
  --muted-soft:    rgba(100, 116, 139, .16);

  --r-sm: 8px;
  --r:    13px;
  --r-lg: 20px;
  --r-full: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 8px 24px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 -14px 46px -12px rgba(0,0,0,.7);

  --topbar-h: 58px;
  --tabbar-h: 60px;
  --max-w: 1180px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

:root[data-theme="light"] {
  --bg:            #f4f6fa;
  --bg-elev:       #ffffff;
  --surface:       #ffffff;
  --surface-2:     #f1f4f9;
  --surface-3:     #e4eaf3;
  --border:        #dde3ed;
  --border-soft:   #e8ecf3;

  --text:          #10192b;
  --text-dim:      #55637c;
  --text-faint:    #8391a8;

  --accent:        #2f5fe0;
  --accent-soft:   rgba(47, 95, 224, .10);
  --accent-text:   #2148b8;

  --ok:            #0f9b6c;
  --ok-soft:       rgba(15, 155, 108, .11);
  --warn:          #b57200;
  --warn-soft:     rgba(181, 114, 0, .11);
  --danger:        #d33a3a;
  --danger-soft:   rgba(211, 58, 58, .10);
  --muted:         #7d8798;
  --muted-soft:    rgba(125, 135, 152, .14);

  --shadow-sm: 0 1px 2px rgba(16,25,43,.06);
  --shadow:    0 8px 24px -10px rgba(16,25,43,.18);
  --shadow-lg: 0 -14px 46px -14px rgba(16,25,43,.24);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

/* El `display:none` de [hidden] lo pone la hoja del NAVEGADOR, y cualquier
   regla propia con `display` le gana — da igual la especificidad, las reglas
   de autor siempre pesan más que las del user-agent. Sin esta línea,
   `.sheet { display:flex }`, `.tenantstrip { display:flex }` y
   `.iconbtn { display:grid }` ignoran el atributo `hidden` y quedan siempre
   visibles: la hoja vacía tapaba el borde inferior del menú. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; }

svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.app { min-height: 100%; }

.view {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 26px);
  outline: none;
}

.view > * + * { margin-top: 14px; }

@media (min-width: 780px) {
  .view { padding-left: 24px; padding-right: 24px; }
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar__main {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}

.topbar__title { flex: 1; min-width: 0; }

.topbar__title h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__title p {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions { display: flex; gap: 4px; }

.iconbtn {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn:active { transform: scale(.94); }

#btn-theme .ico-sun  { display: none; }
:root[data-theme="light"] #btn-theme .ico-moon { display: none; }
:root[data-theme="light"] #btn-theme .ico-sun  { display: block; }

.is-spinning { animation: spin .7s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tira de tenants ─────────────────────────────────────────────────────── */

.tenantstrip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 0 12px 10px;
  max-width: var(--max-w);
  margin: 0 auto;
  scrollbar-width: none;
}
.tenantstrip::-webkit-scrollbar { display: none; }

.tchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  scroll-snap-align: start;
  transition: all .16s var(--ease);
}
.tchip:hover { border-color: var(--surface-3); color: var(--text); }
.tchip.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent-text);
}

/* ── Barra de modo seguro ────────────────────────────────────────────────── */

.safebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 12px;
  background: var(--ok-soft);
  color: var(--ok);
  border-top: 1px solid color-mix(in srgb, var(--ok) 22%, transparent);
}
.safebar.is-live {
  background: var(--danger-soft);
  color: var(--danger);
  border-top-color: color-mix(in srgb, var(--danger) 26%, transparent);
}
/* Datos inventados. En ámbar y no en verde a propósito: el verde se lee como
   «todo correcto» y aquí nada de lo que hay en pantalla es tu cuenta. */
.safebar.is-demo {
  background: var(--warn-soft);
  color: var(--warn);
  border-top-color: color-mix(in srgb, var(--warn) 30%, transparent);
  font-weight: 600;
}
.safebar__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.safebar.is-live .safebar__dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.safebar span:nth-child(2) { flex: 1; min-width: 0; }
.safebar__link {
  border: 0;
  background: none;
  color: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 2px 0;
}

/* ── Tabbar ──────────────────────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border-soft);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: color .15s var(--ease);
}
.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--accent); }
.tab:active { transform: scale(.95); }

.tab__badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 6px);
  min-width: 17px;
  padding: 1px 4px;
  border-radius: var(--r-full);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}
/* Códigos pendientes: informativo, no una alarma. */
.tab__badge--code { background: var(--accent); }

/* ── Bandeja de correo ───────────────────────────────────────────────────── */

.msg {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background .13s var(--ease);
}
.msg:last-child { border-bottom: 0; }
.msg:hover { background: var(--surface-2); }
.msg.is-unread { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.msg.is-unread .msg__from { font-weight: 680; }

.msg__main { flex: 1; min-width: 0; }
.msg__top { display: flex; align-items: baseline; gap: 8px; }
.msg__from {
  flex: 1;
  font-size: 13.5px;
  font-weight: 570;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg__when { font-size: 11px; color: var(--text-faint); flex: none; }
.msg__subject {
  margin-top: 1px;
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg__box {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* El código extraído es la razón de existir de esta vista: se toca y se copia. */
.codepill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  margin-top: 2px;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  border: 1px solid color-mix(in srgb, var(--ok) 42%, transparent);
  background: var(--ok-soft);
  color: var(--ok);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .09em;
  cursor: pointer;
  transition: transform .12s var(--ease), filter .12s var(--ease);
}
.codepill:hover { filter: brightness(1.12); }
.codepill:active { transform: scale(.95); }
.codepill svg { width: 14px; height: 14px; stroke-width: 2.2; opacity: .75; }
.codepill--baja {
  border-color: color-mix(in srgb, var(--warn) 42%, transparent);
  background: var(--warn-soft);
  color: var(--warn);
}

/* ── Alta masiva ─────────────────────────────────────────────────────────── */

.bulk-input {
  width: 100%;
  min-height: 168px;
  padding: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}
.bulk-input:focus { border-color: var(--accent); }
.bulk-input::placeholder { color: var(--text-faint); }

.bulk-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.bulk-row:last-child { border-bottom: 0; }
.bulk-row__n {
  width: 26px;
  flex: none;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  text-align: right;
}
.bulk-row__main { flex: 1; min-width: 0; }
.bulk-row__upn {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bulk-row__msg { font-size: 11px; margin-top: 1px; }
.bulk-row.is-bad { background: var(--danger-soft); }
.bulk-row.is-bad .bulk-row__msg { color: var(--danger); }
.bulk-row.is-warn .bulk-row__msg { color: var(--warn); }

.pickrow { cursor: pointer; }
.pickrow.is-picked { background: var(--accent-soft); }
.checkbox {
  width: 20px; height: 20px;
  flex: none;
  border-radius: 6px;
  border: 1.8px solid var(--border);
  display: grid;
  place-items: center;
  color: transparent;
}
.pickrow.is-picked .checkbox {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.checkbox svg { width: 13px; height: 13px; stroke-width: 3; }

@media (min-width: 780px) {
  .tabbar {
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    width: min(540px, 94vw);
    height: 58px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding-bottom: 0;
  }
}

/* ── Card ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.card__head h2 {
  flex: 1;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.card__body { padding: 14px; }
.card__body--tight { padding: 0; }

.section-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 2px;
}

/* ── Stats ───────────────────────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 13px 14px;
}
.stat__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.stat__value {
  margin-top: 5px;
  font-size: 25px;
  font-weight: 680;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat__value small {
  font-size: 14px;
  font-weight: 550;
  color: var(--text-faint);
}
.stat__hint { margin-top: 3px; font-size: 12px; color: var(--text-dim); }

.stat--ok     .stat__value { color: var(--ok); }
.stat--warn   .stat__value { color: var(--warn); }
.stat--danger .stat__value { color: var(--danger); }

/* ── Meter ───────────────────────────────────────────────────────────────── */

.meter {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
  margin-top: 9px;
}
.meter__fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width .5s var(--ease);
}
.meter__fill.is-warn   { background: var(--warn); }
.meter__fill.is-danger { background: var(--danger); }
.meter--thin { height: 4px; margin-top: 7px; }

/* ── Dots, badges, chips ─────────────────────────────────────────────────── */

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}
.dot--ok      { background: var(--ok);     box-shadow: 0 0 0 3px var(--ok-soft); }
.dot--warn    { background: var(--warn);   box-shadow: 0 0 0 3px var(--warn-soft); }
.dot--danger  { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot--unknown { background: var(--muted);  box-shadow: 0 0 0 3px var(--muted-soft); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 620;
  letter-spacing: .01em;
  background: var(--muted-soft);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge--ok     { background: var(--ok-soft);     color: var(--ok); }
.badge--warn   { background: var(--warn-soft);   color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); }

/* Etiqueta de agrupación. Con 300 buzones es lo único que distingue un lote
   de otro de un vistazo, así que va en la propia fila y no escondida. */
.tagpill {
  display: inline-block;
  padding: 1px 7px;
  margin-left: 5px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .01em;
  vertical-align: 1px;
}

.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  padding: 6px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 570;
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.chip:hover { color: var(--text); }
.chip.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.chip__n { opacity: .55; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ── Tenant grid (vista global) ──────────────────────────────────────────── */

.tgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
}

.tcard {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px;
  border-radius: var(--r);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  cursor: pointer;
  transition: transform .16s var(--ease), border-color .16s var(--ease);
}
.tcard:hover { border-color: var(--surface-3); transform: translateY(-2px); }
.tcard:active { transform: translateY(0) scale(.99); }

.tcard__top { display: flex; align-items: center; gap: 7px; }
.tcard__name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 640;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tcard__sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tcard__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 11px;
  font-size: 12px;
  color: var(--text-dim);
}
.tcard__lic { font-size: 17px; font-weight: 660; color: var(--text); font-variant-numeric: tabular-nums; }
.tcard__lic small { font-size: 12px; color: var(--text-faint); font-weight: 500; }

/* ── Listas / filas ──────────────────────────────────────────────────────── */

.list { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background .13s var(--ease);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row:active { background: var(--surface-3); }

.avatar {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 660;
  letter-spacing: .02em;
}
.avatar--off { opacity: .5; }

.row__main { flex: 1; min-width: 0; }
.row__name {
  font-size: 14px;
  font-weight: 570;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__sub {
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex: none;
}
.row__chev { color: var(--text-faint); }
.row__chev svg { width: 17px; height: 17px; }

/* ── Search ──────────────────────────────────────────────────────────────── */

.search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
}
.search svg { width: 17px; height: 17px; color: var(--text-faint); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}
.search input::placeholder { color: var(--text-faint); }

/* ── Switch (bloques de servicio) ────────────────────────────────────────── */

.blocks { display: flex; flex-direction: column; }

.block {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.block:last-child { border-bottom: 0; }

.block__text { flex: 1; min-width: 0; }
.block__label { font-size: 14px; font-weight: 570; }
.block__desc { margin-top: 2px; font-size: 11.5px; color: var(--text-faint); line-height: 1.4; }
.block__warn {
  margin-top: 6px;
  padding: 6px 9px;
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11.5px;
  line-height: 1.4;
}
.block.is-changed { background: var(--accent-soft); }

.switch {
  position: relative;
  width: 44px; height: 26px;
  flex: none;
  margin-top: 2px;
  border: 0;
  border-radius: var(--r-full);
  background: var(--surface-3);
  cursor: pointer;
  transition: background .2s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease);
}
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch:disabled { opacity: .4; cursor: not-allowed; }

/* ── Botones ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 590;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn svg { width: 17px; height: 17px; }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn--danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
  color: var(--danger);
}
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btnrow--3 { grid-template-columns: repeat(3, 1fr); }

/* ── Hoja inferior ───────────────────────────────────────────────────────── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 7, 12, .6);
  backdrop-filter: blur(3px);
  animation: fade .2s var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 61;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  animation: slideup .28s var(--ease);
}
@keyframes slideup { from { transform: translateY(100%); } }

.sheet__grab {
  display: grid;
  place-items: center;
  padding: 9px 0 4px;
  cursor: grab;
  touch-action: none;
}
.sheet__grab span {
  width: 38px; height: 4px;
  border-radius: var(--r-full);
  background: var(--surface-3);
}

.sheet__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 14px calc(20px + env(safe-area-inset-bottom));
}
.sheet__body > * + * { margin-top: 12px; }

@media (min-width: 780px) {
  .sheet {
    left: 50%;
    bottom: 50%;
    transform: translate(-50%, 50%);
    width: min(560px, 94vw);
    max-height: 84dvh;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    animation: pop .22s var(--ease);
  }
  @keyframes pop {
    from { opacity: 0; transform: translate(-50%, calc(50% + 14px)) scale(.97); }
  }
}

.sheet__head { display: flex; align-items: center; gap: 12px; padding: 6px 0 2px; }
.sheet__head h2 { font-size: 18px; font-weight: 660; letter-spacing: -.01em; }
.sheet__head p { font-size: 12.5px; color: var(--text-dim); word-break: break-all; }

/* ── Definiciones / detalle ──────────────────────────────────────────────── */

.dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
  font-size: 13px;
}
.dl dt { color: var(--text-faint); }
.dl dd { margin: 0; text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; }

/* ── Bloque de código (payload de Graph) ─────────────────────────────────── */

.code {
  margin: 0;
  padding: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-soft);
  background: var(--bg);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}
.code .k { color: var(--accent-text); }
.code .s { color: var(--ok); }
.code .n { color: var(--warn); }

details.disclose { border-radius: var(--r-sm); }
details.disclose > summary {
  padding: 9px 0;
  font-size: 12.5px;
  font-weight: 590;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .16s var(--ease);
}
details.disclose[open] > summary::before { transform: rotate(45deg); }

/* ── Notas / avisos ──────────────────────────────────────────────────────── */

.note {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r);
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
}
.note svg { width: 17px; height: 17px; margin-top: 1px; }
.note--warn   { background: var(--warn-soft);   border-color: color-mix(in srgb, var(--warn) 25%, transparent);   color: var(--warn); }
.note--danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.note--accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent-text); }
.note b { color: inherit; }

/* ── Estados vacíos y esqueletos ─────────────────────────────────────────── */

.empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 44px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}
.empty svg { width: 30px; height: 30px; opacity: .5; }

.skeleton-wrap { display: grid; gap: 12px; padding: 6px 0; }
.skeleton {
  border-radius: var(--r);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite linear;
}
.skeleton--card { height: 84px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ── Toasts ──────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  animation: toastin .24s var(--ease);
}
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }
.toast.is-out { opacity: 0; transform: translateY(8px); transition: all .22s var(--ease); }
.toast svg { width: 17px; height: 17px; margin-top: 1px; }
.toast--ok     { border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.toast--ok     svg { color: var(--ok); }
.toast--warn   svg { color: var(--warn); }
.toast--danger svg { color: var(--danger); }

/* ── Utilidades ──────────────────────────────────────────────────────────── */

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.tnum  { font-variant-numeric: tabular-nums; }
.mono  { font-family: var(--mono); font-size: .92em; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hstack { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
