/* Altas DAVINCI - estilos. Sin dependencias externas. */
:root {
    --navy: #0b2c57;
    --navy-2: #133a6e;
    --gold: #b8912f;
    --gold-soft: #f6efdc;
    --ink: #172033;
    --ink-2: #4a5468;
    --line: #dde2ea;
    --bg: #f4f6f9;
    --card: #ffffff;
    --ok: #1f7a4d;
    --ok-soft: #e3f3ea;
    --warn: #9a6a00;
    --warn-soft: #fbf1d9;
    --bad: #b42318;
    --bad-soft: #fde8e6;
    --info-soft: #e6eef9;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
a { color: var(--navy-2); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Marca ---------- */
.brand, .auth-brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px;
    background: var(--gold); color: var(--navy); font-weight: 800; font-size: .85rem; letter-spacing: .02em;
}

/* ---------- Estructura de la aplicación ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 1rem; background: var(--navy); color: #fff;
}
.topbar .brand { color: #fff; }
.menu-toggle {
    display: none; background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 8px; padding: .35rem .8rem; font: inherit; cursor: pointer;
}
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 56px); }
.sidenav {
    background: #fff; border-right: 1px solid var(--line); padding: 1rem .75rem;
    display: flex; flex-direction: column; justify-content: space-between; gap: 1rem;
}
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav a {
    display: block; padding: .55rem .75rem; border-radius: 8px; color: var(--ink);
    text-decoration: none; font-weight: 500;
}
.sidenav a:hover { background: var(--bg); }
.sidenav a[aria-current="page"] { background: var(--gold-soft); color: var(--navy); font-weight: 650; box-shadow: inset 3px 0 0 var(--gold); }
.sidenav-user { border-top: 1px solid var(--line); padding-top: .75rem; }
.sidenav-user .who { display: flex; flex-direction: column; padding: 0 .75rem .5rem; }
.sidenav-user .who span { font-size: .85rem; color: var(--ink-2); }
.link-button {
    background: none; border: 0; padding: .55rem .75rem; font: inherit; color: var(--bad);
    cursor: pointer; width: 100%; text-align: left; border-radius: 8px;
}
.link-button:hover { background: var(--bad-soft); }
.main { padding: 1.5rem 2rem 3rem; max-width: 1200px; width: 100%; }
.page-head { margin-bottom: 1.25rem; }
.page-head.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .menu-toggle { display: inline-block; }
    .sidenav { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidenav.open { display: flex; }
    .main { padding: 1rem 1rem 3rem; }
}

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 640px; }
.table-card { padding: 0; overflow: hidden; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; flex-direction: column; margin: 0; }
.stat-value { font-size: 2rem; font-weight: 750; color: var(--navy); line-height: 1.1; }
.stat-label { color: var(--ink-2); font-size: .9rem; }
.roadmap { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.roadmap li { display: flex; flex-direction: column; padding: .6rem .8rem; border-left: 3px solid var(--gold); background: var(--bg); border-radius: 0 8px 8px 0; }
.roadmap span { color: var(--ink-2); font-size: .9rem; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
.form small { font-weight: 400; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select {
    font: inherit; padding: .6rem .7rem; border: 1px solid #c5ccd8; border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
    outline: 3px solid rgba(184, 145, 47, .55); outline-offset: 1px;
}
.code-input { font-size: 1.5rem; letter-spacing: .3em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }
fieldset.radios { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
fieldset.radios legend { font-weight: 600; margin-bottom: .3rem; }
label.radio { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400; border: 1px solid var(--line); border-radius: 8px; padding: .7rem; cursor: pointer; }
label.radio:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); }
label.radio span { display: grid; }
label.radio input { margin-top: .3rem; }
.inline-form { grid-template-columns: 1fr auto; align-items: end; margin-bottom: .75rem; }
@media (max-width: 600px) { .inline-form { grid-template-columns: 1fr; } }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; padding: 1rem; }
.filters label { display: grid; gap: .25rem; font-size: .85rem; font-weight: 600; min-width: 140px; flex: 1; }
.filters .btn { flex: 0 0 auto; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 600; padding: .55rem 1rem; border-radius: 8px; cursor: pointer;
    border: 1px solid #c5ccd8; background: #fff; color: var(--ink); text-decoration: none; min-height: 42px;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-danger { color: var(--bad); border-color: #f0b4ae; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .5rem 0 1rem; }
.actions form { margin: 0; }

/* ---------- Avisos y etiquetas ---------- */
.alert { border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); border-color: #b5dfc6; }
.alert-error { background: var(--bad-soft); border-color: #f4bdb7; }
.alert-warning { background: var(--warn-soft); border-color: #ecd593; }
.alert-info { background: var(--info-soft); border-color: #bfd2ee; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 650; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: #eceff3; color: var(--ink-2); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Tablas ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); background: #f8f9fb; }
.table th, .table td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.changes { margin: .35rem 0 0; padding-left: 1rem; font-size: .9rem; }
.changes del { color: var(--bad); }
.changes ins { color: var(--ok); text-decoration: none; }
@media (max-width: 760px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
    .table td { border: 0; padding: .25rem 1rem; }
    .table td::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
    .table .ua { white-space: normal; }
}
.pager { display: flex; align-items: center; gap: 1rem; justify-content: center; }

/* ---------- Listas de datos ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0 0 1rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; font-size: .9rem; }
.timeline time { color: var(--ink-2); font-variant-numeric: tabular-nums; margin-right: .4rem; }
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .9rem; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--navy); color: #fff; }

/* ---------- Pantallas de acceso ---------- */
body.auth { background: linear-gradient(180deg, var(--navy) 0, var(--navy) 260px, var(--bg) 260px); min-height: 100vh; }
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 2.5rem 1rem; }
.auth-brand { color: #fff; font-size: 1.15rem; margin-bottom: 1.25rem; }
.auth-card { padding: 1.75rem; }
.auth-foot { text-align: center; color: var(--ink-2); font-size: .8rem; }
.steps { padding-left: 1.2rem; display: grid; gap: .6rem; }
.checklist { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; gap: .35rem; }
.checklist li { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.checklist .dot { width: .7rem; height: .7rem; border-radius: 50%; flex: none; }
.checklist .ok .dot { background: var(--ok); }
.checklist .fail .dot { background: var(--bad); }
.checklist .fail { color: var(--bad); font-weight: 600; }
.qr { width: 220px; max-width: 100%; margin: .75rem 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { display: inline-block; font-size: 1.05rem; background: var(--bg); padding: .35rem .6rem; border-radius: 6px; letter-spacing: .05em; user-select: all; overflow-wrap: anywhere; }
.codes { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.codes code { display: block; text-align: center; background: var(--bg); padding: .5rem; border-radius: 6px; font-size: 1.05rem; letter-spacing: .05em; }
details summary { cursor: pointer; color: var(--navy-2); font-weight: 600; margin-top: .75rem; }
.action-box { border-top: 1px solid var(--line); padding: .25rem 0 .5rem; }
.action-box summary { margin: .5rem 0; }
.action-box[open] { padding-bottom: .75rem; }

@media print {
    .topbar, .sidenav, .actions, form, .auth-foot, .auth-brand { display: none !important; }
    body.auth, body { background: #fff; }
    .card { box-shadow: none; border: 0; }
}
