/* Tema claro y moderno. Sin fuentes ni recursos externos (CSP: solo 'self'). */
:root {
  color-scheme: light;
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f1f4f9; --text: #1b2537; --muted: #66758b; --border: #e3e8f1; --border-strong: #cfd7e6;
  --accent: #4361ee; --accent-hover: #3550d6; --accent-soft: #e8ecff; --accent-text: #ffffff;
  --ok: #0c8f62; --ok-bg: #e2f6ee; --warn: #a9640a; --warn-bg: #fff2d9; --bad: #d12f24; --bad-bg: #fdebe9;
  --radius: 12px; --radius-sm: 8px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 2px rgba(20, 30, 55, .05); --shadow: 0 1px 2px rgba(20, 30, 55, .04), 0 6px 20px rgba(20, 30, 55, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.015em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 14px; letter-spacing: -.005em; }
h3 { font-size: 13px; font-weight: 650; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.right { text-align: right; } .nowrap { white-space: nowrap; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
svg.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* estructura */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, #4361ee 0%, #7a5af8 100%); box-shadow: 0 4px 12px rgba(67, 97, 238, .35); }
.logo svg.ic { width: 20px; height: 20px; stroke-width: 2; }
.brand b { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; color: #46546b; font-weight: 500; transition: background .12s, color .12s; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .spacer { flex: 1; }
.userbox { border-top: 1px solid var(--border); padding: 14px 6px 2px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; text-transform: uppercase; }
.userbox .who { min-width: 0; flex: 1; } .userbox .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox .who small { color: var(--muted); font-size: 12px; }
.main { padding: 30px 36px 56px; max-width: 1240px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.head h1 + .muted { font-size: 14px; max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.card > .head { margin-bottom: 14px; } .card > .head h2 { margin: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); opacity: .85; }
.kpi .n { font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; } .kpi .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.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.muted { background: var(--surface-2); color: var(--muted); }
.btn { font: inherit; font-weight: 550; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 8px 15px; border-radius: 9px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, box-shadow .12s, transform .04s; }
.btn:hover { background: var(--surface-2); } .btn:active { transform: translateY(1px); } .btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(67, 97, 238, .35); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); border-color: #f0c2bd; background: #fff; } .btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; } .btn.block { width: 100%; padding: 11px 16px; font-size: 15px; }
input, select, textarea { font: inherit; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: #fff; color: var(--text); max-width: 100%; transition: border-color .12s, box-shadow .12s; }
input::placeholder, textarea::placeholder { color: #9aa6b8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(67, 97, 238, .18); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.f { display: block; margin-bottom: 14px; } label.f > span { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
label.f input, label.f select, label.f textarea { width: 100%; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input[type=search] { min-width: 250px; }
.tablewrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; white-space: nowrap; background: #f8fafd; }
th:first-child { border-radius: 8px 0 0 8px; } th:last-child { border-radius: 0 8px 8px 0; }
tbody tr:last-child td { border-bottom: 0; } tr.click { cursor: pointer; } tr.click:hover td { background: #f7f9fe; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.notice { border-radius: 10px; padding: 11px 15px; margin-bottom: 14px; border: 1px solid transparent; }
.notice.warn { background: var(--warn-bg); color: #7c4a06; border-color: #f6dfae; } .notice.bad { background: var(--bad-bg); color: #a3211a; border-color: #f4c9c5; }
.notice.ok { background: var(--ok-bg); color: #08694a; border-color: #b9e6d3; }
.tabs { display: inline-flex; gap: 3px; margin-bottom: 16px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tabs button { font: inherit; font-weight: 550; border: 0; background: none; padding: 7px 16px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.kv { display: grid; grid-template-columns: 200px 1fr auto; gap: 10px 14px; align-items: center; }
.kv .k { color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.chart { width: 100%; height: auto; max-height: 220px; display: block; } .chart .s { fill: #2eb887; } .chart .d { fill: #f0b34a; } .chart .b { fill: #ec6a5e; }
.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.chart text { fill: var(--muted); font-size: 12px; }

/* modal y avisos */
.overlay { position: fixed; inset: 0; background: rgba(20, 28, 46, .45); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px; overflow-y: auto; z-index: 20; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 640px; padding: 24px; border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(20, 30, 55, .25); }
.modal.wide { max-width: 880px; } .modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: #1b2537; color: #fff; padding: 11px 18px; border-radius: 10px; max-width: 380px; box-shadow: 0 8px 24px rgba(20, 30, 55, .3); }
.toast.bad { background: var(--bad); }

/* inicio de sesión */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1.05fr) 1fr; background: var(--surface); }
.auth-brand { position: relative; overflow: hidden; color: #fff; padding: 56px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg, #3346d3 0%, #5a55ea 55%, #7d5cf2 100%); }
.auth-brand::before, .auth-brand::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.auth-brand::before { width: 420px; height: 420px; right: -140px; top: -120px; } .auth-brand::after { width: 320px; height: 320px; left: -110px; bottom: -110px; }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .logo { background: rgba(255, 255, 255, .18); box-shadow: none; border: 1px solid rgba(255, 255, 255, .28); }
.auth-brand .lead { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin: 26px 0 12px; max-width: 16ch; }
.auth-brand .sub { color: rgba(255, 255, 255, .82); font-size: 16px; max-width: 42ch; }
.auth-brand ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 13px; }
.auth-brand li { display: flex; gap: 11px; align-items: flex-start; color: rgba(255, 255, 255, .92); }
.auth-brand li .tick { width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, .2); display: grid; place-items: center; flex: none; margin-top: 1px; }
.auth-brand li svg.ic { width: 13px; height: 13px; stroke-width: 2.6; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 28px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 34px 32px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 26px; } .auth-card .muted { margin-bottom: 22px; }
.auth-card .foot { text-align: center; margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.auth-mobile { display: none; }

/* página pública de la política de uso (/aup) */
.doc { max-width: 820px; margin: 0 auto; padding: 48px 24px 72px; background: var(--surface); min-height: 100vh; }
.docpage { background: var(--bg); }
.doc h1 { font-size: 30px; margin: 4px 0 18px; } .doc h2 { font-size: 18px; margin: 30px 0 10px; }
.doc ul { padding-left: 22px; margin: 8px 0 12px; } .doc li { margin: 6px 0; } .doc code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 34px 0 6px; }
.prewrap { white-space: pre-wrap; background: var(--surface-2); padding: 12px 14px; border-radius: 9px; max-height: 50vh; overflow: auto; }
.checkrow { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; } .checkrow input { margin-top: 3px; flex: none; width: auto; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; } .auth-brand { display: none; }
  .auth-mobile { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .brand { padding: 0 8px 0 4px; } .nav { flex-direction: row; flex-wrap: wrap; } .side .spacer, .userbox .who { display: none; } .userbox { border: 0; padding: 0; margin-left: auto; }
  .main { padding: 20px 16px 40px; } .kv { grid-template-columns: 1fr; }
}
