/* Cuentas. Todos los valores salen de tokens.css (sistema de diseño de usados).
   Celular primero; lista + panel de detalle lado a lado desde 1100 px. Sin estilos en línea (CSP). */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: var(--fs-body); line-height: 1.5; }
h1, h2, h3, p, ul, fieldset { margin: 0; }
h1 { font-size: var(--fs-title); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: var(--fs-section); line-height: 1.25; font-weight: 600; }
h3 { font-size: var(--fs-body); font-weight: 600; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
img { display: block; max-width: 100%; }
button, input, select { font-family: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: var(--control-h); padding: 0 var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-control); background: var(--surface); color: var(--ink);
  font-size: var(--fs-control); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--line-soft); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { min-height: var(--primary-h); border-color: var(--accent); background: var(--accent); color: #fff; font-size: var(--fs-body); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.danger { color: var(--accent); border-color: var(--accent); }
.btn.danger:hover { background: var(--accent-soft); }

/* Campos */
.field { display: grid; gap: 6px; font-size: var(--fs-small); min-width: 0; }
.field > span { color: var(--muted); font-weight: 500; }
:where(input:not([type="checkbox"]), select) { width: 100%; min-height: var(--control-h); padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--r-control); background: var(--surface); color: var(--ink); font-size: var(--fs-control); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.check { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 600; cursor: pointer; font-size: var(--fs-control); }

/* Avisos */
.notice { padding: var(--s-3) var(--s-4); border-radius: var(--r-control); background: var(--surface); color: var(--text-2); border: 1px solid var(--line); font-size: var(--fs-control); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.notice.error { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.hint { color: var(--muted); font-size: var(--fs-small); }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-3); min-height: 60px; padding: var(--s-2) var(--s-4);
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: var(--s-3); min-width: 0; margin-right: auto; }
.brand img { border-radius: var(--r-control); }
.brand span { display: grid; line-height: 1.2; min-width: 0; }
.brand small { color: var(--muted); font-size: var(--fs-small); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: var(--s-1); order: 3; width: 100%; overflow-x: auto; }
.tabs button { min-height: 40px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-control); background: none; color: var(--muted); font-weight: 600; font-size: var(--fs-control); cursor: pointer; }
.tabs button:hover { background: var(--line-soft); }
.tabs button.on { color: var(--accent); background: var(--accent-soft); }
@media (min-width: 720px) { .tabs { order: 0; width: auto; } }

.app { padding: var(--s-6) var(--s-4) var(--s-12); display: grid; gap: var(--s-4); min-width: 0; }
.view { display: grid; gap: var(--s-4); min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-4); display: grid; gap: var(--s-3); min-width: 0; }
.row { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* Lista */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: end; }
.toolbar h1 { width: 100%; }
.toolbar .grow { flex: 1 1 260px; }
.toolbar .field:not(.grow) { flex: 1 1 140px; max-width: 220px; }
.split { display: grid; gap: var(--s-4); min-width: 0; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow-x: auto; min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-control); }
th { text-align: left; font-size: var(--fs-small); color: var(--muted); font-weight: 600; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line-soft); vertical-align: top; }
td small { color: var(--muted); font-size: var(--fs-small); word-break: break-all; }
.people tbody tr { cursor: pointer; }
.people tbody tr:hover { background: var(--line-soft); }
.people tbody tr.sel { background: var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: var(--r-pill); background: var(--line-soft); color: var(--text-2); font-size: var(--fs-small); white-space: nowrap; }
.chip.off { text-decoration: line-through; color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--fs-small); font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.off { background: var(--line-soft); color: var(--muted); }
@media (max-width: 719px) { .people thead { display: none; } .people tr { display: grid; padding: var(--s-2) 0; border-bottom: 1px solid var(--line-soft); } .people td { border: 0; padding: 4px var(--s-4); } }

/* Panel de detalle: pantalla completa en el celular, columna a la derecha desde 1100 px */
.drawer { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; padding: var(--s-4); display: grid; gap: var(--s-4); align-content: start; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); position: sticky; top: calc(-1 * var(--s-4)); background: var(--bg); padding: var(--s-2) 0; z-index: 1; }
body.drawer-open { overflow: hidden; }
@media (min-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(420px, 520px); align-items: start; }
  .drawer { position: sticky; top: 76px; inset: auto; z-index: auto; max-height: calc(100vh - 92px); padding: 0 var(--s-1) var(--s-4) 0; background: none; }
  .drawer-head { top: 0; }
  body.drawer-open { overflow: auto; }
}

/* Accesos */
.access { border: 1px solid var(--line); border-radius: var(--r-control); padding: var(--s-2) var(--s-3) var(--s-3); min-width: 0; }
.access legend { padding: 0 var(--s-1); }
.access.on { border-color: var(--accent); }
.access:not(.on) .access-body { display: none; }
.access:not(.on) { border-style: dashed; border-width: 1px 0 0; border-radius: 0; padding: 0 0 var(--s-1); }
.access-body { display: grid; gap: var(--s-2); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }

.credential { display: grid; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-control); background: var(--ok-soft); }
.credential code { font-size: 22px; font-weight: 700; letter-spacing: .06em; user-select: all; }
details > summary { cursor: pointer; font-weight: 600; }
.log { list-style: none; padding: 0; display: grid; gap: var(--s-2); font-size: var(--fs-control); }
.log small { color: var(--muted); }
.my-apps { padding-left: var(--s-4); display: grid; gap: var(--s-1); }

.toast { position: fixed; left: 50%; bottom: var(--s-6); transform: translateX(-50%); z-index: 60; max-width: min(560px, calc(100vw - 32px));
  padding: var(--s-3) var(--s-4); border-radius: var(--r-control); background: var(--ink); color: #fff; font-size: var(--fs-control); box-shadow: var(--shadow-hover); }
.toast.error { background: var(--accent); }

/* Ingreso */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--s-4); }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-8) var(--s-6); display: grid; gap: var(--s-4); }
.login-card img { border-radius: var(--r-control); }
.login-card p, .login-card small { color: var(--muted); }
.login-card form { display: grid; gap: var(--s-4); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 48px; }
.password-field button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: var(--r-control); }
