/* Estilos base y componentes del panel y la landing. Tokens en tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--text-base) / var(--lh-base) var(--font-sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: var(--text-2xl); line-height: var(--lh-2xl); }
h2 { font-size: var(--text-xl); line-height: var(--lh-xl); }
h3 { font-size: var(--text-lg); line-height: var(--lh-lg); }
p { margin: 0 0 var(--space-3); }
img, svg { max-width: 100%; display: block; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--text-sm); line-height: var(--lh-sm); }
.xs { font-size: var(--text-xs); line-height: var(--lh-xs); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); } .mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); }
.flex { display: flex; gap: var(--space-3); align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-start { align-items: start; }
.cols-3-2 { grid-template-columns: 3fr 2fr; }
.cols-2-3 { grid-template-columns: 2fr 3fr; }
.cols-hero { grid-template-columns: 300px 1fr 1fr; }
.form-row.cols-compare { grid-template-columns: 1fr 1fr auto; align-items: end; }
@media (max-width: 960px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } .cols-3-2, .cols-2-3, .cols-hero, .form-row.cols-compare { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .card.stat { padding: var(--space-4); }
  .top-action { grid-template-columns: 36px 1fr; }
  .top-action .impact { grid-column: 2; display: flex; gap: 6px; align-items: baseline; text-align: left; margin-top: 4px; }
  .top-action .impact strong { display: inline; font-size: var(--text-base); }
  .card-flush { overflow: visible; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; mask-image: linear-gradient(90deg, #000 92%, transparent); }
  .table th, .table td { padding: 8px 10px; }
  .table td:first-child, .table th:first-child { width: 1%; white-space: nowrap; }
  .tabs { mask-image: linear-gradient(90deg, #000 88%, transparent); }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 40px; padding: 0 var(--space-4); border-radius: var(--radius); border: 1px solid transparent;
  font: 500 var(--text-sm) / 1 var(--font-sans); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-700); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.btn-danger:hover { background: var(--sev-critica); color: #fff; }
.btn-accent { background: var(--accent); color: var(--accent-contrast); }
.btn-accent:hover { filter: brightness(.93); }
.btn-sm { height: 34px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { height: 48px; padding: 0 var(--space-6); font-size: var(--text-base); }
.btn-block { width: 100%; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.label { font-size: var(--text-sm); font-weight: 500; color: var(--text); }
.hint { font-size: var(--text-xs); color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: 400 var(--text-sm) / 1 var(--font-sans); box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: var(--space-3); line-height: var(--lh-sm); resize: vertical; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--ring); }
.input.is-invalid { border-color: var(--bad); }
.field-error { font-size: var(--text-xs); color: var(--bad); }
.checkbox { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-muted); }
.checkbox input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand-600); flex: none; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-6); }

/* ---------- Tarjetas y métricas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-6); }
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-flush .card-header { padding: var(--space-4) var(--space-5); margin: 0; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: var(--text-base); line-height: var(--lh-base); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-label { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.stat-delta { font-size: var(--text-xs); font-weight: 500; }
.stat-delta.up { color: var(--ok); } .stat-delta.down { color: var(--bad); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 500; background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-brand { background: var(--brand-50); color: var(--brand-800); }
[data-theme="dark"] .badge-brand { background: var(--brand-900); color: var(--brand-200); }
.sev { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 7px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.sev::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sev-critica { background: var(--sev-critica-bg); color: var(--sev-critica); }
.sev-alta { background: var(--sev-alta-bg); color: var(--sev-alta); }
.sev-media { background: var(--sev-media-bg); color: var(--sev-media); }
.sev-baja { background: var(--sev-baja-bg); color: var(--sev-baja); }
.sev-info { background: var(--sev-info-bg); color: var(--sev-info); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 500; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.status-done::before, .status-enviado::before, .status-confirmado::before { background: var(--ok); }
.status-running::before, .status-auditando::before { background: var(--brand-500); animation: pulse 1.2s infinite; }
.status-queued::before, .status-en_cola::before, .status-pendiente::before { background: var(--warn); }
.status-failed::before, .status-fallido::before, .status-caducado::before { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Alertas ---------- */
.alert { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius); font-size: var(--text-sm); line-height: var(--lh-sm); border: 1px solid transparent; }
.alert svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-info { background: var(--brand-50); color: var(--brand-900); }
[data-theme="dark"] .alert-info { background: var(--brand-900); color: var(--brand-100); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: var(--lh-sm); }
.table th, .table td { padding: 10px var(--space-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface-2); color: var(--text-muted); font-weight: 500; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .url { max-width: 420px; }
.table .url a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.table .url a:hover { color: var(--link); }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]::after { content: "↕"; margin-left: 6px; opacity: .35; font-size: 10px; }
.table th[data-sort].asc::after { content: "↑"; opacity: 1; }
.table th[data-sort].desc::after { content: "↓"; opacity: 1; }
.table-tools { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--border); background: var(--surface); }
.table-tools .input, .table-tools .select { height: 36px; width: auto; min-width: 180px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-muted); }
.pager { display: flex; gap: var(--space-1); }
.pager button { height: 30px; min-width: 30px; padding: 0 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); font-size: var(--text-xs); cursor: pointer; }
.pager button[aria-current="page"] { background: var(--brand-600); border-color: var(--brand-600); color: var(--brand-contrast); }
.pager button:disabled { opacity: .4; cursor: default; }

/* ---------- Estados ---------- */
.empty { text-align: center; padding: var(--space-12) var(--space-6); color: var(--text-muted); }
.empty svg { width: 48px; height: 48px; margin: 0 auto var(--space-4); color: var(--text-faint); }
.empty h3 { color: var(--text); margin-bottom: var(--space-2); }
.empty p { max-width: 420px; margin: 0 auto var(--space-4); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.progress { height: 8px; background: var(--surface-3); border-radius: var(--radius-full); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-600); border-radius: var(--radius-full); transition: width .4s; }
.progress.indeterminate > span { width: 30%; animation: slide 1.4s infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Medidor ---------- */
.gauge { position: relative; width: 168px; height: 168px; margin: 0 auto; }
.gauge svg { width: 100%; height: 100%; }
.gauge .gauge-value { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge .gauge-number { font-size: 44px; line-height: 1; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.gauge .gauge-label { font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }
.gauge-sm { width: 44px; height: 44px; margin: 0; }
.gauge-sm .gauge-number { font-size: 14px; font-weight: 600; }
.score-ok { color: var(--ok); } .score-warn { color: var(--warn); } .score-bad { color: var(--bad); }
.bar { display: grid; grid-template-columns: 150px 1fr 44px; gap: var(--space-3); align-items: center; font-size: var(--text-sm); }
.bar .track { height: 10px; background: var(--surface-3); border-radius: var(--radius-full); overflow: hidden; }
.bar .fill { height: 100%; border-radius: var(--radius-full); }
.bar .fill.ok { background: var(--ok); } .bar .fill.warn { background: var(--warn); } .bar .fill.bad { background: var(--bad); }
.bar .value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Layout del panel ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: var(--space-5) var(--space-4); gap: var(--space-6); }
.brand { display: flex; align-items: center; gap: var(--space-3); font-weight: 600; color: var(--text); text-decoration: none; padding: 0 var(--space-2); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-600); color: var(--brand-contrast); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: 9px; }
.brand-name { font-size: var(--text-base); }
.brand-sub { display: block; font-size: var(--text-xs); color: var(--text-muted); font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: var(--space-3); padding: 9px var(--space-3); border-radius: var(--radius); color: var(--text-muted); font-size: var(--text-sm); font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-50); color: var(--brand-800); }
[data-theme="dark"] .nav a.active { background: var(--brand-900); color: var(--brand-100); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-1); }
.sidebar-foot .btn, .sidebar-foot form { width: 100%; }
.sidebar-foot .btn { justify-content: flex-start; padding: 0 var(--space-3); }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-5) var(--space-8) 0; max-width: var(--content-max); margin: 0 auto; }
.topbar h1 { font-size: var(--text-2xl); }
.topbar .crumbs { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: 4px; }
.topbar .crumbs a { color: var(--text-muted); }
.content { padding: var(--space-6) var(--space-8) var(--space-12); max-width: var(--content-max); margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-6); }
.menu-toggle { display: none; }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: space-between; padding: var(--space-3) var(--space-4); gap: var(--space-2); border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { order: 1; }
  .nav { display: none; width: 100%; order: 4; }
  .sidebar.open .nav { display: flex; }
  .sidebar-foot { order: 2; margin: 0 0 0 auto; flex-direction: row; gap: 0; }
  .sidebar-foot .btn, .sidebar-foot form { width: auto; }
  .sidebar-foot .btn span { display: none; }
  .menu-toggle { display: inline-flex; order: 3; }
  .topbar, .content { padding-left: var(--space-4); padding-right: var(--space-4); }
  .topbar { flex-wrap: wrap; }
}

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); background: radial-gradient(1200px 600px at 50% -10%, var(--brand-50), transparent), var(--bg); }
[data-theme="dark"] .auth { background: radial-gradient(1200px 600px at 50% -10%, var(--brand-900), transparent), var(--bg); }
.auth .card { width: 100%; max-width: 400px; padding: var(--space-8); }

/* ---------- Detalles ---------- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; word-break: break-word; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: var(--space-2); } }
.issue-head { display: flex; gap: var(--space-4); align-items: flex-start; }
.issue-head .sev { margin-top: 3px; }
.issue-meta { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); }
.callout { border-left: 3px solid var(--brand-500); background: var(--brand-50); padding: var(--space-3) var(--space-4); border-radius: 0 var(--radius) var(--radius) 0; font-size: var(--text-sm); line-height: var(--lh-sm); }
[data-theme="dark"] .callout { background: var(--brand-900); }
.callout strong { display: block; margin-bottom: 2px; }
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-4); overflow-x: auto; }
.tabs a { padding: 10px var(--space-3); font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--brand-700); border-color: var(--brand-600); }
[data-theme="dark"] .tabs a.active { color: var(--brand-300); }
.chip-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-full); border: 1px solid var(--border-strong); font-size: var(--text-xs); color: var(--text-muted); background: var(--surface); }
.chip.active { background: var(--brand-600); border-color: var(--brand-600); color: var(--brand-contrast); }
.chip:hover { text-decoration: none; border-color: var(--brand-400); }
.toast { position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 50; }
.theme-toggle svg { width: 16px; height: 16px; }
details.details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.details summary { cursor: pointer; padding: var(--space-3) var(--space-4); font-size: var(--text-sm); font-weight: 500; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.details summary::-webkit-details-marker { display: none; }
details.details[open] summary { border-bottom: 1px solid var(--border); }
details.details .details-body { padding: var(--space-4); font-size: var(--text-sm); }
.top-actions { counter-reset: action; display: flex; flex-direction: column; gap: var(--space-3); }
.top-action { display: grid; grid-template-columns: 36px 1fr auto; gap: var(--space-4); align-items: start; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.top-action .n { width: 36px; height: 36px; border-radius: var(--radius); background: var(--brand-600); color: var(--brand-contrast); display: grid; place-items: center; font-weight: 700; }
.top-action h4 { font-size: var(--text-base); line-height: var(--lh-base); margin-bottom: 2px; }
.top-action .impact { text-align: right; font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }
.top-action .issue-meta .badge { height: 20px; }
.top-action .impact strong { display: block; font-size: var(--text-lg); color: var(--text); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--text-muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.actions-inline { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.print-only { display: none; }
