/* =====================================================================
   Control de Visitantes
   Hoja de estilos única: tokens, modo claro/oscuro, layout y componentes
   ===================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #f8f8f9;
  --surface-3: #efeff1;
  --border: #e4e4e7;
  --border-strong: #d1d1d6;
  --text: #121214;
  --text-2: #3a3a40;
  --muted: #6b6b73;
  /* Rojo de acento inspirado en la marca (no es un código oficial: ajústelo según la guía de marca) */
  --primary: #c8161d;
  --primary-hover: #a51218;
  --primary-soft: #fcecec;
  --primary-text: #b3141a;
  --ink: #121214;
  --ink-text: #ffffff;
  --accent: #1f7a4d;
  --accent-soft: #e5f3eb;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warning: #a15c00;
  --warning-soft: #fdf3e1;
  --success: #1f7a4d;
  --success-soft: #e5f3eb;
  --sidebar-bg: #111113;
  --sidebar-text: #b4b4bb;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, .07);
  --shadow-sm: 0 1px 2px rgba(18, 18, 20, .05);
  --shadow: 0 1px 2px rgba(18, 18, 20, .04), 0 6px 20px -8px rgba(18, 18, 20, .12);
  --shadow-lg: 0 24px 60px -20px rgba(18, 18, 20, .35);
  --radius: 14px;
  --radius-sm: 9px;
  --ring: 0 0 0 3px rgba(200, 22, 29, .2);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sidebar-w: 256px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #151517;
  --surface-2: #1b1b1e;
  --surface-3: #232327;
  --border: #2a2a2f;
  --border-strong: #3a3a40;
  --text: #ededef;
  --text-2: #c9c9cf;
  --muted: #9a9aa3;
  --primary: #e5262d;
  --primary-hover: #f2464c;
  --primary-soft: rgba(229, 38, 45, .14);
  --primary-text: #ff6b70;
  --ink: #ededef;
  --ink-text: #121214;
  --accent: #2f9e66;
  --accent-soft: rgba(47, 158, 102, .15);
  --danger: #ff6b5f;
  --danger-soft: rgba(255, 107, 95, .13);
  --warning: #f2b042;
  --warning-soft: rgba(242, 176, 66, .13);
  --success: #4cc38a;
  --success-soft: rgba(76, 195, 138, .13);
  --sidebar-bg: #0e0e10;
  --sidebar-text: #a0a0a8;
  --sidebar-active-bg: rgba(255, 255, 255, .07);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px -10px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px rgba(229, 38, 45, .3);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
html.theme-ready body, html.theme-ready .sidebar, html.theme-ready .card, html.theme-ready .topbar {
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; font-weight: 650; }
h3 { font-size: 1.02rem; font-weight: 620; }
p { margin: 0 0 .5rem; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-3); padding: .1em .35em; border-radius: 5px; }
pre { margin: 0; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: .93em; letter-spacing: .01em; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar-brand { padding: 20px 18px 18px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--primary); color: #fff; box-shadow: 0 4px 12px -4px rgba(200, 22, 29, .55); }
.brand-mark .icon { width: 20px; height: 20px; }
.brand-text { font-weight: 680; font-size: 15px; letter-spacing: -.01em; line-height: 1.2; color: #fff; }
.auth-brand .brand-text { color: var(--text); font-size: 16px; }
.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-section { margin: 16px 10px 6px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #77777f; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 500; font-size: 14px; position: relative;
}
.nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #e5262d; }
.nav-link.active .icon { color: #ff5a5f; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .06); color: #77777f; }
.sidebar-backdrop { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.page-title { font-size: 1.15rem; font-weight: 650; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 18px; max-width: 1440px; width: 100%; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 560; font-size: 14px; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--text); text-decoration: none !important;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(200, 22, 29, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--accent); color: #fff; }
.btn-success:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-danger-ghost { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-link { background: none; color: var(--primary-text); padding: 0 6px; height: auto; }
.btn-link:hover { text-decoration: underline !important; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
  text-decoration: none !important;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn.sm .icon { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.theme-toggle .when-dark { display: none; }
[data-theme="dark"] .theme-toggle .when-dark { display: inline; }
[data-theme="dark"] .theme-toggle .when-light { display: none; }
.theme-toggle span { display: grid; }

/* ---------- Menú de usuario ---------- */
.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
}
.user-chip:hover { background: var(--surface-2); }
.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13.5px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11.5px; color: var(--muted); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: #2a2a2f; color: #fff; font-weight: 650; font-size: 12.5px; letter-spacing: .02em;
}
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: .15s ease; z-index: 50;
}
.user-menu.open .dropdown { opacity: 1; visibility: visible; transform: none; }
.dropdown-head { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 6px; align-items: flex-start; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px;
  color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
}
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-item.danger { color: var(--danger); }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 1rem; }
.card-title .icon { color: var(--primary); }
.card + .card-title { margin-top: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-actions form { display: inline; }
.section-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 2px -6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2.wide-left { grid-template-columns: 1.6fr 1fr; }
.grid-2.wide-right { grid-template-columns: 1fr 1.6fr; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.welcome { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-left: 4px solid var(--primary); }
.welcome h2 { font-size: 1.5rem; margin-bottom: 4px; }
.welcome p { margin: 0; }
.eyebrow { text-transform: uppercase; font-size: 11.5px; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 1.7rem; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.quick { display: flex; align-items: center; gap: 14px; padding: 16px; color: var(--text); text-decoration: none !important; transition: transform .15s, border-color .15s, box-shadow .15s; }
.quick:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.quick > span:last-child { display: flex; flex-direction: column; }
.quick-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex: none; }
.quick.primary { background: var(--primary); border-color: transparent; color: #fff; }
.quick.primary .muted { color: rgba(255, 255, 255, .78); }
.quick.primary .quick-icon { background: rgba(255, 255, 255, .16); color: #fff; }

/* ---------- Formularios ---------- */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; margin: 0; padding: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 560; color: var(--text-2); padding: 0; }
.field small { font-size: 12px; }
.field-error { color: var(--danger); min-height: 0; }
.field-error:empty { display: none; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 12px; height: 40px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
textarea { padding: 10px 12px; height: auto; resize: vertical; min-height: 64px; }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366758c' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input[disabled], select[disabled], input[readonly] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
input[type="date"] { min-width: 0; }
.is-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 40px; }
.input-action { position: absolute; right: 6px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: grid; }
.input-action:hover { color: var(--text); }
.input-action .pw-hide { display: none; }
.input-action.showing .pw-show { display: none; }
.input-action.showing .pw-hide { display: grid; }
.input-action span { display: grid; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.form-note { padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px dashed var(--border-strong); }
.form-card { max-width: 100%; }
.sticky-actions { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); z-index: 5; }
.check-inline { flex-direction: row; align-items: center; gap: 8px; align-self: end; height: 40px; }
.check-inline span { font-weight: 500; }
.field-actions { flex-direction: row; align-items: flex-end; gap: 6px; }

/* ---------- Filtros ---------- */
.filters { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.filters-main { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters-main select { width: auto; min-width: 160px; }
.search-box { position: relative; flex: 1; min-width: 220px; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 12px; color: var(--muted); }
.search-box input { padding-left: 40px; }
.filters-adv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.filters-adv.always { border-top: 0; padding-top: 0; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.table th a.sort { color: inherit; }
.table th a.sort:hover { color: var(--text); text-decoration: none; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions-col { text-align: right; white-space: nowrap; width: 1%; }
.table .actions-col > * { margin-left: 4px; }
.row-deleted td { opacity: .6; text-decoration: line-through; text-decoration-color: var(--muted); }
.row-deleted td.actions-col { text-decoration: none; opacity: 1; }
.row-muted td { opacity: .62; }
.row-muted td:nth-child(4), .row-muted td.actions-col { opacity: 1; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--border); }
.pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.page { min-width: 34px; height: 34px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); font-size: 13.5px; background: var(--surface); }
.page:hover { background: var(--surface-2); text-decoration: none; }
.page.current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page.disabled { pointer-events: none; opacity: .45; }
.page.gap { border: 0; background: none; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.diff pre { max-height: 220px; overflow: auto; }
.diff td.old pre { color: var(--danger); }
.diff td.new pre { color: var(--success); }
.empty-inline { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px 4px; }

/* ---------- Badges, tags, pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.badge .icon { width: 13px; height: 13px; }
.badge-primary { background: var(--ink); color: var(--ink-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.pill { display: inline-block; min-width: 28px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); text-align: center; font-weight: 600; font-size: 12.5px; }
.tag { display: inline-block; padding: 3px 9px; border-radius: 7px; font-size: 12.5px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.tag-strong { background: var(--ink); color: var(--ink-text); border-color: transparent; font-weight: 600; }

/* ---------- Switch (estado de usuario) ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px; color: var(--muted); padding: 0; }
.switch span { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: .2s; }
.switch.on { color: var(--success); font-weight: 560; }
.switch.on span { background: var(--accent); }
.switch.on span::after { left: 16px; }

/* ---------- Alertas ---------- */
.alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 11px; border: 1px solid; font-size: 14px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--primary-soft); color: var(--primary-text); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.alert-close { background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; padding: 0; display: grid; }
.alert-close:hover { opacity: 1; }

/* ---------- Ficha / listas de definición ---------- */
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.profile-head h2 { font-size: 1.2rem; margin-bottom: 4px; }
.dl { display: grid; grid-template-columns: minmax(130px, 40%) 1fr; gap: 0; margin: 0 0 8px; }
.dl dt, .dl dd { padding: 9px 0; border-bottom: 1px solid var(--border); margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { word-break: break-word; }
.dl.compact dt, .dl.compact dd { padding: 6px 0; font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { padding-left: 16px; border-left: 2px solid var(--border); }

/* ---------- Registro de visita ---------- */
.register { display: flex; flex-direction: column; gap: 18px; max-width: 980px; }
.step-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.step-head p { margin: 2px 0 0; }
.step-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); font-weight: 700; flex: none; }
.dni-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.dni-field { flex: 0 1 320px; }
.dni-field input { height: 46px; font-size: 1.15rem; letter-spacing: .12em; }
.dni-row .btn { margin-top: 25px; }
.dni-status:empty { display: none; }
.dni-status { margin-top: 14px; }
.found-card { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); background: var(--success-soft); }
.found-card.new { border-color: color-mix(in srgb, var(--primary) 30%, transparent); background: var(--primary-soft); }
.found-card.bad { border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); color: var(--danger); }
.found-card strong { display: block; }
.found-card .muted { color: var(--text-2); }
html.js .js-pending.is-pending { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; cursor: pointer; user-select: none;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-weight: 520; transition: .15s;
}
.chip span .icon { width: 15px; height: 15px; display: none; }
.chip:hover span { border-color: var(--primary); }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip input:checked + span .icon { display: inline; }
.chip input:focus-visible + span { box-shadow: var(--ring); }
.step.done { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }

/* ---------- Roles y permisos ---------- */
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.role-card { display: flex; flex-direction: column; gap: 14px; }
.role-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.role-card footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.role-admin { border-top: 3px solid var(--primary); }
.role-perms { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions { display: flex; gap: 4px; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.perm-group { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px 6px; margin: 0; }
.perm-group legend { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; padding: 0 6px; }
.perm { display: flex; gap: 12px; align-items: flex-start; padding: 9px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.perm:last-child { border-bottom: 0; }
.perm > span:last-child { display: flex; flex-direction: column; }
.perm small { font-size: 12px; }
.perm input { position: absolute; opacity: 0; }
.perm-toggle { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; margin-top: 1px; transition: .2s; }
.perm-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.perm input:checked + .perm-toggle { background: var(--primary); }
.perm input:checked + .perm-toggle::after { left: 16px; }
.perm input:focus-visible + .perm-toggle { box-shadow: var(--ring); }
.perm.disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Estadísticas ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { display: flex; gap: 12px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.kpi > div { display: flex; flex-direction: column; min-width: 0; }
.kpi-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex: none; }
.kpi:nth-child(3n+2) .kpi-icon { background: var(--accent-soft); color: var(--accent); }
.kpi:nth-child(3n) .kpi-icon { background: var(--warning-soft); color: var(--warning); }
.kpi-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 1.5rem; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ---------- Modal ---------- */
.modal { border: 1px solid var(--border); border-radius: 16px; padding: 22px; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(10, 10, 12, .55); backdrop-filter: blur(2px); }
.modal h3 { margin-bottom: 4px; }

/* ---------- Estados vacíos ---------- */
.empty-state { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 520px; margin: 40px auto; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty-icon.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Login ---------- */
.auth-body { min-height: 100vh; background: var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 14px; }
.auth-alert { width: min(980px, 100%); }
.auth-split { display: grid; grid-template-columns: 1.05fr 1fr; width: min(980px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden; min-height: 560px; }
.auth-hero { position: relative; background: linear-gradient(155deg, #0e0e10 0%, #1c1c20 60%, #2a2a2f 100%); border-right: 4px solid var(--primary); color: #fff; padding: 44px; display: flex; overflow: hidden; }
.hero-grid { position: absolute; inset: 0; opacity: .18;
  background-image: linear-gradient(rgba(255, 255, 255, .5) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .5) 1px, transparent 1px);
  background-size: 34px 34px; mask-image: radial-gradient(ellipse at 70% 30%, #000 10%, transparent 70%); }
.hero-content { position: relative; display: flex; flex-direction: column; gap: 14px; margin-top: auto; }
.hero-content h2 { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }
.hero-content p { color: rgba(255, 255, 255, .78); max-width: 380px; }
.hero-points { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 10px; }
.hero-points li { display: flex; gap: 10px; align-items: center; color: rgba(255, 255, 255, .9); font-size: 14px; }
.hero-points .icon { color: #ff5a5f; }
.auth-hero .hero-content { height: 100%; }
.auth-card { padding: 44px 44px 36px; display: flex; flex-direction: column; justify-content: center; gap: 6px; background: var(--surface); }
.auth-wrap > .auth-card { width: min(440px, 100%); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); }
.auth-brand { margin-bottom: 18px; }
.auth-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.auth-card form { margin-top: 18px; }
.auth-foot { margin-top: 18px; text-align: center; }
.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }

/* ---------- Utilidades responsive ---------- */
.only-mobile, .only-mobile-inline { display: none !important; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .hide-md { display: none; }
}
@media (max-width: 980px) {
  .grid-2, .grid-2.wide-left, .grid-2.wide-right { grid-template-columns: 1fr; }
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 10, 12, .5); z-index: 35; }
  .main { margin-left: 0; }
  .only-mobile { display: inline-grid !important; }
  .topbar { padding: 0 14px; }
  .content { padding: 16px 14px 40px; gap: 14px; }
  .user-meta { display: none; }
  .user-chip { padding: 3px; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .only-mobile-inline { display: block !important; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .stat-row .stat:last-child { grid-column: span 2; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-icon { display: none; }
  .card { padding: 16px; border-radius: 12px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .table td, .table th { padding: 10px 8px; }
  .dni-row .btn { margin-top: 0; width: 100%; }
  .dni-field { flex: 1 1 100%; }
  .auth-card { padding: 30px 22px; }
  .page-actions, .page-actions .btn-group { width: 100%; }
  .page-actions .btn { flex: 1; }
  .filters-main .btn { flex: 1; }
  .role-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .filters, .page-actions, .actions-col, .pagination { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; border: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Exportar ---------- */
.export-card { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.export-card p { margin: 0; }

/* ---------- Identidad: encabezado con línea de acento ---------- */
.topbar { box-shadow: inset 0 -1px 0 var(--border); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--primary) 0, var(--primary) 64px, transparent 64px); }
.quick-icon, .step-num { background: var(--surface-3); color: var(--primary-text); }
.quick.primary .quick-icon { background: rgba(255, 255, 255, .16); color: #fff; }
.card-title .icon { color: var(--primary); }
.table td a { color: var(--text); font-weight: 560; }
.table td a:hover { color: var(--primary-text); }
.found-card.new { background: var(--surface-2); border-color: var(--border-strong); }
.found-card.new strong { color: var(--text); }
