/* gK1wi Developers — sistema de diseño del panel.
   No se entregó un logotipo de gK1wi: se usa una paleta neutra (tinta + grises cálidos)
   con un único acento índigo para acciones primarias. Colores funcionales: verde/ámbar/rojo
   solo para estados. Ver docs/DISENO.md. */
:root {
  --ink: #111827; --ink-2: #1f2937; --text: #1f2937; --muted: #6b7280; --faint: #9ca3af;
  --bg: #f6f6f4; --surface: #ffffff; --surface-2: #fafaf9; --line: #e7e5e4; --line-2: #d6d3d1;
  --accent: #4f46e5; --accent-ink: #ffffff; --accent-soft: #eef2ff;
  --ok: #15803d; --ok-soft: #ecfdf3; --warn: #b45309; --warn-soft: #fffbeb; --bad: #b91c1c; --bad-soft: #fef2f2;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(17,24,39,.06), 0 8px 24px rgba(17,24,39,.04);
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f5f5f4; --ink-2: #e7e5e4; --text: #e7e5e4; --muted: #a8a29e; --faint: #78716c;
    --bg: #0f0f10; --surface: #18181b; --surface-2: #1f1f23; --line: #2a2a2e; --line-2: #3a3a40;
    --accent: #818cf8; --accent-ink: #0f0f10; --accent-soft: #1e1b4b;
    --ok: #4ade80; --ok-soft: #052e16; --warn: #fbbf24; --warn-soft: #2a1d05; --bad: #f87171; --bad-soft: #2a0b0b;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; color: var(--ink); }
h2 { font-size: 17px; margin: 0 0 12px; color: var(--ink); }
h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0 0 12px; }
.sub { color: var(--muted); margin-bottom: 24px; }
code, .mono { font-family: var(--mono); font-size: 13px; }

/* Estructura */
body.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 6px 8px 18px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; }
.brand-text { font-size: 15px; color: var(--muted); } .brand-text strong { color: var(--ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .i { width: 18px; text-align: center; opacity: .8; }
.logout { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.who { font-size: 13px; color: var(--muted); }
.main { padding: 32px clamp(16px, 4vw, 48px); max-width: 1280px; width: 100%; }
body.auth .main { display: grid; place-items: center; min-height: 100vh; max-width: none; }

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 24px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.kpi .card { padding: 16px 18px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 650; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .card.attn { border-color: var(--warn); }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 600 14px var(--font); text-decoration: none; cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

form.form { display: grid; gap: 14px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=search], input[type=tel], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 14px var(--font); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td a.link, a.link { color: var(--accent); text-decoration: none; font-weight: 600; } a.link:hover { text-decoration: underline; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; 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.bad { background: var(--bad-soft); color: var(--bad); }
.badge.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.props dt { color: var(--muted); font-size: 13px; } dl.props dd { margin: 0; font-weight: 500; word-break: break-word; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.keybox { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 18px; border-radius: var(--radius); background: var(--ink); color: var(--bg); }
.keybox code { font-size: clamp(16px, 3vw, 22px); letter-spacing: .06em; color: inherit; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: 13px; }
details.danger-zone { border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line)); border-radius: var(--radius); padding: 14px 18px; background: var(--surface); }
details.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--bad); }
details > form { margin-top: 12px; }

.login { width: min(420px, 100%); }
.login .brand { justify-content: center; padding-bottom: 8px; }

@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px; } .brand-text { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .nav a { padding: 8px 10px; white-space: nowrap; } .nav .i { display: none; }
  .logout { margin: 0; padding: 0; border: 0; flex-direction: row; align-items: center; } .who { display: none; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  dl.props { grid-template-columns: 1fr; gap: 2px 0; } dl.props dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Utilidades (la CSP del panel bloquea estilos en línea) */
.grow { flex: 1; } .fs-16 { font-size: 16px; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.mb-16 { margin-bottom: 16px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.w-140 { max-width: 140px; } .w-180 { max-width: 180px; } .w-220 { max-width: 220px; } .w-280 { max-width: 280px; } .w-760 { max-width: 760px; } .minw-220 { min-width: 220px; }
