/* =========================================================================
   cuRH · Sistema de diseño (ver docs/DISENO.md)
   Base: Bootstrap 5.3 (retícula, menús, modales) con tokens propios.
   ========================================================================= */

/* ---- Tipografía (Inter, servida localmente: el sistema opera sin internet) ---- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../vendor/inter/inter-latin-wght-normal.8e433c0592f7.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-weight: 100 900; font-display: swap;
  src: url("../vendor/inter/inter-latin-ext-wght-normal.ad4eb06671be.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 {
  --c-bg: #f6f7f9;
  --c-surface: #ffffff;
  --c-surface-2: #f9fafb;
  --c-border: #e4e7ec;
  --c-border-strong: #d0d5dd;
  --c-text: #101828;
  --c-muted: #475467;
  --c-subtle: #667085;
  --c-primary: #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-soft: #eef2ff;
  --c-primary-ring: #c7d2fe;
  --c-success: #079455; --c-success-soft: #ecfdf3; --c-success-text: #067647;
  --c-warning: #dc6803; --c-warning-soft: #fffaeb; --c-warning-text: #b54708;
  --c-danger: #d92d20;  --c-danger-soft: #fef3f2;  --c-danger-text: #b42318;
  --c-info: #1570ef;    --c-info-soft: #eff8ff;    --c-info-text: #175cd3;
  --c-neutral-soft: #f2f4f7; --c-neutral-text: #344054;

  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px; --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, .08), 0 4px 6px -2px rgba(16, 24, 40, .03);
  --ring: 0 0 0 4px var(--c-primary-ring);

  --sidebar-w: 248px; --topbar-h: 60px; --content-max: 1280px;

  /* Bootstrap */
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-font-size: .875rem; --bs-body-line-height: 1.5; --bs-body-color: var(--c-text);
  --bs-body-bg: var(--c-bg); --bs-border-color: var(--c-border); --bs-secondary-color: var(--c-muted);
  --bs-tertiary-color: var(--c-subtle); --bs-emphasis-color: var(--c-text);
  --bs-primary: #4f46e5; --bs-primary-rgb: 79, 70, 229; --bs-link-color: #4338ca; --bs-link-color-rgb: 67, 56, 202;
  --bs-link-hover-color: #312e81; --bs-border-radius: var(--radius); --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-lg); --bs-focus-ring-color: var(--c-primary-ring);
}

/* ---- Base ---- */
html { -webkit-text-size-adjust: 100%; }
body { font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; background: var(--c-bg); }
h1, h2, h3, h4, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--c-text); letter-spacing: -.01em; font-weight: 600; }
a { text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--ring) !important; border-radius: var(--radius-sm); }
.text-muted, .text-body-secondary { color: var(--c-muted) !important; }
.text-subtle { color: var(--c-subtle) !important; }
.tabular, td.num, .num { font-variant-numeric: tabular-nums; }
.visually-hidden-focusable:focus { position: fixed; top: 8px; left: 8px; z-index: 2000; background: #fff; padding: 8px 12px; }
[x-cloak] { display: none !important; }

/* ---- Estructura ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--c-surface); border-right: 1px solid var(--c-border); display: flex; flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; color: var(--c-text); font-weight: 600; font-size: 1.05rem; }
.sidebar-brand:hover { text-decoration: none; }
.brand-company { display: block; font-size: .72rem; font-weight: 500; color: var(--c-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; line-height: 1.2; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--c-primary); color: #fff; font-weight: 700; font-size: .95rem; box-shadow: var(--shadow-sm); }
.nav-list { list-style: none; margin: 0; padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 16px 12px 6px; font-size: .72rem; font-weight: 600; color: var(--c-subtle); text-transform: uppercase; letter-spacing: .05em; }
.nav-item-link {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; color: var(--c-neutral-text); font-weight: 500;
  min-height: 40px; transition: background .12s, color .12s;
}
.nav-item-link .bi { font-size: 1.1rem; color: var(--c-subtle); }
.nav-item-link:hover { background: var(--c-surface-2); color: var(--c-text); text-decoration: none; }
.nav-item-link.active { background: var(--c-primary-soft); color: var(--c-primary-hover); }
.nav-item-link.active .bi { color: var(--c-primary); }
.nav-count { margin-left: auto; background: var(--c-neutral-soft); color: var(--c-neutral-text); font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: var(--radius-pill); }
.nav-item-link.active .nav-count { background: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--c-border); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: rgba(246, 247, 249, .85); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--c-border); }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 24px 32px 64px; }
.content-narrow { max-width: 760px; }

/* Barra de búsqueda global (Ctrl + K) */
.global-search { position: relative; flex: 1; max-width: 440px; }
.global-search .bi-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-subtle); }
.global-search input { width: 100%; height: 38px; padding: 0 64px 0 36px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); font-size: .875rem; }
.global-search input:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--ring); }
.kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: .7rem; color: var(--c-subtle); border: 1px solid var(--c-border); border-radius: 5px; padding: 1px 6px; background: var(--c-surface-2); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 1050; }
.search-results a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: var(--c-text); }
.search-results a:hover, .search-results a.active { background: var(--c-surface-2); text-decoration: none; }
.search-results .empty { padding: 14px; color: var(--c-muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius);
  color: var(--c-muted); background: transparent; border: 1px solid transparent;
}
.icon-btn:hover { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--c-danger); color: #fff; font-size: .65rem; font-weight: 600; display: grid; place-items: center; border: 2px solid var(--c-bg); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--c-primary-soft); color: var(--c-primary-hover); font-weight: 600; font-size: .8rem; flex-shrink: 0; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: var(--radius-pill); border: 1px solid transparent; background: transparent; color: var(--c-text); }
.user-btn:hover { background: var(--c-surface); border-color: var(--c-border); }

/* ---- Encabezado de página ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 1.5rem; margin: 0; line-height: 1.25; }
.page-head .lead-text { color: var(--c-muted); margin: 4px 0 0; }
.page-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: .8rem; color: var(--c-subtle); margin-bottom: 6px; }
.crumbs a { color: var(--c-muted); }
.crumbs .bi { font-size: .7rem; }

/* Sub-navegación de sección (segmentada) */
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); margin: -8px 0 20px; overflow-x: auto; scrollbar-width: none; }
.subnav a { padding: 10px 4px; margin-right: 16px; color: var(--c-muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.subnav a:hover { color: var(--c-text); text-decoration: none; }
.subnav a.active { color: var(--c-primary-hover); border-bottom-color: var(--c-primary); }
.subnav .count { margin-left: 6px; font-size: .72rem; background: var(--c-neutral-soft); color: var(--c-neutral-text); border-radius: var(--radius-pill); padding: 1px 7px; }

/* ---- Superficies ---- */
.card { --bs-card-border-color: var(--c-border); --bs-card-border-radius: var(--radius-lg); --bs-card-cap-bg: transparent; box-shadow: var(--shadow-sm); border-radius: var(--radius-lg); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--c-border); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-header .card-hint { margin-left: auto; font-weight: 400; font-size: .8rem; }
.card-body { padding: 20px; }
.card-footer { background: var(--c-surface-2); border-top: 1px solid var(--c-border); padding: 12px 20px; }
.section-title { font-size: 1rem; margin: 0 0 4px; }
.section-desc { color: var(--c-muted); margin: 0 0 16px; font-size: .85rem; }

/* Tarjetas de indicadores */
.stat { display: block; padding: 20px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--c-text); height: 100%; transition: border-color .12s, box-shadow .12s; }
a.stat:hover { border-color: var(--c-primary-ring); box-shadow: var(--shadow-md); text-decoration: none; }
.stat-label { color: var(--c-muted); font-size: .85rem; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 1.875rem; font-weight: 600; line-height: 1.2; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-foot { color: var(--c-subtle); font-size: .8rem; margin-top: 4px; }
.stat-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--c-primary-soft); color: var(--c-primary); }
.stat-icon.warn { background: var(--c-warning-soft); color: var(--c-warning-text); }
.stat-icon.ok { background: var(--c-success-soft); color: var(--c-success-text); }
.stat-icon.info { background: var(--c-info-soft); color: var(--c-info-text); }
.stat-icon.danger { background: var(--c-danger-soft); color: var(--c-danger-text); }

/* Lista de tareas / elementos */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--c-border); color: var(--c-text); }
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--c-surface-2); text-decoration: none; }
.list-row .meta { color: var(--c-subtle); font-size: .8rem; }
.list-row .end { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.list > li > .list-row:first-child { border-top: 1px solid var(--c-border); }
.list > li:first-child > .list-row { border-top: 0; }
.min-w-0 { min-width: 0; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.report-card { display: flex; align-items: center; gap: 14px; padding: 18px 20px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--c-text); }
.report-card:hover { border-color: var(--c-primary-ring); text-decoration: none; box-shadow: var(--shadow-md, var(--shadow-sm)); }
.report-card .meta { color: var(--c-subtle); font-size: .85rem; }

/* ---- Botones ---- */
.btn { --bs-btn-font-weight: 500; --bs-btn-padding-x: 14px; --bs-btn-padding-y: 8px; --bs-btn-font-size: .875rem; --bs-btn-border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; white-space: nowrap; }
.btn-sm { --bs-btn-padding-x: 10px; --bs-btn-padding-y: 5px; --bs-btn-font-size: .8rem; min-height: 32px; }
.btn-lg { --bs-btn-padding-x: 20px; --bs-btn-padding-y: 12px; --bs-btn-font-size: 1rem; min-height: 48px; }
.btn-primary { --bs-btn-bg: var(--c-primary); --bs-btn-border-color: var(--c-primary); --bs-btn-hover-bg: var(--c-primary-hover); --bs-btn-hover-border-color: var(--c-primary-hover); --bs-btn-active-bg: #3730a3; --bs-btn-disabled-bg: #a5b4fc; --bs-btn-disabled-border-color: #a5b4fc; box-shadow: var(--shadow-sm); }
.btn-secondary, .btn-light, .btn-outline-secondary, .btn-outline-primary { --bs-btn-color: var(--c-neutral-text); --bs-btn-bg: var(--c-surface); --bs-btn-border-color: var(--c-border-strong); --bs-btn-hover-color: var(--c-text); --bs-btn-hover-bg: var(--c-surface-2); --bs-btn-hover-border-color: var(--c-border-strong); --bs-btn-active-bg: var(--c-neutral-soft); --bs-btn-active-color: var(--c-text); --bs-btn-active-border-color: var(--c-border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:disabled, .btn-secondary.disabled { --bs-btn-disabled-bg: var(--c-surface); --bs-btn-disabled-color: var(--c-subtle); --bs-btn-disabled-border-color: var(--c-border); box-shadow: none; }
.btn-ghost { --bs-btn-color: var(--c-muted); --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-hover-bg: var(--c-neutral-soft); --bs-btn-hover-color: var(--c-text); --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: var(--c-neutral-soft); }
.btn-success { --bs-btn-bg: var(--c-success); --bs-btn-border-color: var(--c-success); --bs-btn-hover-bg: #067647; --bs-btn-hover-border-color: #067647; }
.btn-danger { --bs-btn-bg: var(--c-danger); --bs-btn-border-color: var(--c-danger); --bs-btn-hover-bg: #b42318; --bs-btn-hover-border-color: #b42318; }
.btn-outline-danger { --bs-btn-color: var(--c-danger-text); --bs-btn-border-color: #fecdca; --bs-btn-bg: var(--c-surface); --bs-btn-hover-bg: var(--c-danger-soft); --bs-btn-hover-color: var(--c-danger-text); --bs-btn-hover-border-color: #fda29b; }
.btn-outline-success { --bs-btn-color: var(--c-success-text); --bs-btn-border-color: #abefc6; --bs-btn-bg: var(--c-surface); --bs-btn-hover-bg: var(--c-success-soft); --bs-btn-hover-color: var(--c-success-text); --bs-btn-hover-border-color: #75e0a7; }
.btn-icon { width: 34px; min-height: 34px; padding: 0; }
.btn:focus-visible { box-shadow: var(--ring) !important; }
.btn .htmx-indicator { width: 14px; height: 14px; }

/* ---- Insignias de estado ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: .75rem; font-weight: 500; line-height: 1.5; white-space: nowrap; background: var(--c-neutral-soft); color: var(--c-neutral-text); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.no-dot::before { display: none; }
.pill-success { background: var(--c-success-soft); color: var(--c-success-text); }
.pill-warning { background: var(--c-warning-soft); color: var(--c-warning-text); }
.pill-danger { background: var(--c-danger-soft); color: var(--c-danger-text); }
.pill-info { background: var(--c-info-soft); color: var(--c-info-text); }
.pill-primary { background: var(--c-primary-soft); color: var(--c-primary-hover); }

/* ---- Barra de herramientas de listas ---- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.search-input { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-input .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-subtle); pointer-events: none; }
.search-input input { padding-left: 36px; }
.filter-panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.filter-grid label { font-size: .8rem; font-weight: 500; color: var(--c-muted); margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: var(--radius-pill); background: var(--c-primary-soft); color: var(--c-primary-hover); font-size: .8rem; font-weight: 500; }
.chip a { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: inherit; }
.chip a:hover { background: var(--c-primary-ring); text-decoration: none; }
.badge-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--c-primary); color: #fff; font-size: .7rem; font-weight: 600; }

/* ---- Tablas ---- */
.data-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--c-surface-2); --bs-table-border-color: var(--c-border); margin: 0; font-size: .875rem; }
.table > thead th {
  background: var(--c-surface-2); color: var(--c-subtle); font-size: .75rem; font-weight: 500; text-transform: none;
  padding: 10px 16px; border-bottom: 1px solid var(--c-border); white-space: nowrap;
}
.table > tbody td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid var(--c-border); color: var(--c-text); }
.table > tbody tr:last-child td { border-bottom: 0; }
.table-sm > tbody td { padding: 8px 16px; }
.table td.actions, .table th.actions { text-align: right; width: 1%; white-space: nowrap; }
.table .cell-main { font-weight: 500; color: var(--c-text); }
.table .cell-sub { display: block; color: var(--c-subtle); font-size: .8rem; }
.table a.row-link { color: var(--c-text); font-weight: 500; }
.table a.row-link:hover { color: var(--c-primary-hover); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--c-border); color: var(--c-muted); font-size: .8rem; }
.table-responsive { scrollbar-width: thin; }
.table-tools { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--c-border); background: var(--c-primary-soft); font-size: .85rem; }

/* ---- Menús ---- */
.dropdown-menu { --bs-dropdown-border-color: var(--c-border); --bs-dropdown-border-radius: var(--radius); --bs-dropdown-link-hover-bg: var(--c-surface-2); --bs-dropdown-link-active-bg: var(--c-primary-soft); --bs-dropdown-link-active-color: var(--c-primary-hover); --bs-dropdown-font-size: .875rem; --bs-dropdown-item-padding-y: 8px; --bs-dropdown-item-padding-x: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.dropdown-item { border-radius: var(--radius-sm); display: flex; align-items: center; gap: 10px; }
.dropdown-item .bi { color: var(--c-subtle); width: 16px; }
.dropdown-item.text-danger .bi { color: inherit; }
.dropdown-header { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-subtle); padding: 8px 12px 4px; }
.dropdown-toggle-none::after { display: none; }

/* ---- Formularios ---- */
.form-label, label.form-label, .col-form-label { font-weight: 500; font-size: .85rem; color: var(--c-neutral-text); margin-bottom: 6px; }
.form-control, .form-select { border-color: var(--c-border-strong); border-radius: var(--radius); padding: 8px 12px; font-size: .875rem; min-height: 40px; box-shadow: var(--shadow-sm); }
.form-control-sm, .form-select-sm { min-height: 34px; padding: 5px 10px; font-size: .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--c-primary); box-shadow: var(--ring); }
.form-control::placeholder { color: #98a2b3; }
.form-text, .form-text.text-muted { color: var(--c-subtle) !important; font-size: .8rem; }
.invalid-feedback { font-size: .8rem; }
.form-control.is-invalid, .form-select.is-invalid { border-color: #fda29b; }
.form-check-input { width: 1.1em; height: 1.1em; border-color: var(--c-border-strong); }
.form-check-input:checked { background-color: var(--c-primary); border-color: var(--c-primary); }
.form-check-input:focus { box-shadow: var(--ring); border-color: var(--c-primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.form-grid > * { min-width: 0; }
.form-grid > .full, .form-grid > div:has(textarea), .form-grid > div:has(.form-check), .form-grid > div:has(> .form-check) { grid-column: 1 / -1; }
.form-section { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 24px; margin-bottom: 16px; }
.form-section > h2 { font-size: 1rem; margin: 0 0 4px; }
.form-section > .section-desc { margin-bottom: 20px; }
.form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 14px 0; margin-top: 8px; background: linear-gradient(to top, var(--c-bg) 70%, transparent); }
.form-actions .end { margin-left: auto; }
.alert { border-radius: var(--radius); border: 1px solid; font-size: .875rem; }
.alert-danger { background: var(--c-danger-soft); border-color: #fecdca; color: var(--c-danger-text); }
.alert-warning { background: var(--c-warning-soft); border-color: #fedf89; color: var(--c-warning-text); }
.alert-info { background: var(--c-info-soft); border-color: #b2ddff; color: var(--c-info-text); }
.alert-success { background: var(--c-success-soft); border-color: #abefc6; color: var(--c-success-text); }
.callout { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--radius); background: var(--c-surface-2); border: 1px solid var(--c-border); color: var(--c-muted); font-size: .85rem; }
.callout .bi { font-size: 1.1rem; }
.callout-warning { background: var(--c-warning-soft); border-color: #fedf89; color: var(--c-warning-text); }
.callout-danger { background: var(--c-danger-soft); border-color: #fecdca; color: var(--c-danger-text); }
.callout-info { background: var(--c-info-soft); border-color: #b2ddff; color: var(--c-info-text); }
.callout-success { background: var(--c-success-soft); border-color: #abefc6; color: var(--c-success-text); }

/* Pasos (alta por pasos) */
.steps { display: flex; gap: 8px; margin-bottom: 24px; counter-reset: step; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-muted); font-weight: 500; text-align: left; }
.step .num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--c-neutral-soft); color: var(--c-neutral-text); font-size: .8rem; font-weight: 600; flex-shrink: 0; }
.step.active { border-color: var(--c-primary); color: var(--c-text); box-shadow: var(--ring); }
.step.active .num { background: var(--c-primary); color: #fff; }
.step.done .num { background: var(--c-success-soft); color: var(--c-success-text); }
.step.error { border-color: #fda29b; }
.step.error .num { background: var(--c-danger-soft); color: var(--c-danger-text); }

/* ---- Pestañas ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--c-border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--c-muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--c-text); text-decoration: none; }
.tabs a.active { color: var(--c-primary-hover); border-bottom-color: var(--c-primary); }

/* ---- Datos descriptivos ---- */
.dl-grid { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 10px 24px; margin: 0; }
.dl-grid dt { font-weight: 400; color: var(--c-subtle); }
.dl-grid dd { margin: 0; color: var(--c-text); font-weight: 500; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.fact .k { color: var(--c-subtle); font-size: .8rem; }
.fact .v { font-weight: 500; }

/* Encabezado de persona */
.profile-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 20px; }
.profile-head h1 { font-size: 1.5rem; margin: 0; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--c-muted); font-size: .85rem; margin-top: 4px; }
.profile-meta .bi { color: var(--c-subtle); margin-right: 4px; }

/* ---- Estado vacío ---- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--c-muted); }
.empty-state .icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--c-neutral-soft); color: var(--c-subtle); font-size: 1.4rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; margin: 0 0 4px; }
.empty-state p { margin: 0 auto 16px; max-width: 42ch; }

/* ---- Avisos (toast) ---- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; width: min(400px, calc(100vw - 32px)); }
.toast-x { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: .875rem; animation: toast-in .18s ease-out; }
.toast-x .bi { font-size: 1.15rem; margin-top: 1px; }
.toast-x.success .bi { color: var(--c-success); }
.toast-x.error .bi, .toast-x.danger .bi { color: var(--c-danger); }
.toast-x.warning .bi { color: var(--c-warning); }
.toast-x.info .bi { color: var(--c-info); }
.toast-x .msg { flex: 1; color: var(--c-text); white-space: pre-line; }
.toast-x .close { border: 0; background: none; color: var(--c-subtle); padding: 0 2px; line-height: 1; font-size: 1.1rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Aviso de licencia (solo cuando importa) */
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 32px; font-size: .85rem; border-bottom: 1px solid; }
.banner-danger { background: var(--c-danger-soft); color: var(--c-danger-text); border-color: #fecdca; }
.banner-warning { background: var(--c-warning-soft); color: var(--c-warning-text); border-color: #fedf89; }
.banner-info { background: var(--c-primary-soft); color: #3730a3; border-color: var(--c-primary-ring); }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---- Paginación ---- */
.pager { display: flex; gap: 4px; }

/* ---- Modal ---- */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--c-border); padding: 16px 20px; }
.modal-body { padding: 20px; }

/* ---- Historial ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--c-primary); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 18px; bottom: 0; width: 1px; background: var(--c-border); }
.timeline li:last-child::after { display: none; }
.diff-old { color: var(--c-danger-text); text-decoration: line-through; }
.diff-new { color: var(--c-success-text); }

/* ---- HTMX ---- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
.htmx-request.loading-dim, .htmx-request .loading-dim { opacity: .55; transition: opacity .15s; }

/* ---- Portal móvil ---- */
.hero { border-radius: var(--radius-lg); padding: 24px; background: linear-gradient(135deg, #4f46e5 0%, #6366f1 60%, #818cf8 100%); color: #fff; box-shadow: var(--shadow-md); }
.hero h1 { color: #fff; font-size: 1.4rem; margin: 0; }
.hero p { color: rgba(255, 255, 255, .85); margin: 4px 0 0; }
.hero .btn-light { --bs-btn-bg: #fff; --bs-btn-color: var(--c-primary-hover); --bs-btn-border-color: #fff; --bs-btn-hover-bg: #eef2ff; --bs-btn-hover-color: var(--c-primary-hover); }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quick { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); color: var(--c-text); font-weight: 500; font-size: .85rem; box-shadow: var(--shadow-sm); text-align: center; }
.quick .bi { font-size: 1.4rem; color: var(--c-primary); }
.quick:hover { border-color: var(--c-primary-ring); text-decoration: none; }
.bottom-nav { display: none; }
.checkin-btn { width: 100%; min-height: 88px; font-size: 1.25rem; border-radius: var(--radius-lg); }

/* ---- Kiosco ---- */
.kiosk-bg { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 30% 20%, #312e81 0%, #111827 60%); }
.kiosk-card { width: 100%; max-width: 420px; background: var(--c-surface); border-radius: 20px; box-shadow: 0 24px 48px rgba(0, 0, 0, .35); padding: 28px; }
.kiosk-clock { font-size: 3rem; font-weight: 600; letter-spacing: -.03em; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; }
.kiosk-display { height: 56px; display: grid; place-items: center; border: 1px solid var(--c-border-strong); border-radius: var(--radius); font-size: 1.4rem; font-weight: 500; letter-spacing: .1em; background: var(--c-surface-2); cursor: pointer; }
.kiosk-display.active { border-color: var(--c-primary); box-shadow: var(--ring); background: #fff; }
.kiosk-display.placeholder { color: var(--c-subtle); letter-spacing: 0; font-size: 1rem; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { height: 60px; border-radius: var(--radius); border: 1px solid var(--c-border); background: var(--c-surface); font-size: 1.4rem; font-weight: 500; color: var(--c-text); }
.keypad button:hover { background: var(--c-surface-2); }
.keypad button:active { background: var(--c-primary-soft); }

/* ---- Inicio de sesión ---- */
.auth-bg { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #e0e7ff 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #ede9fe 0%, transparent 60%), var(--c-bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card-body { padding: 32px; }

/* ---- Registro y suscripción ---- */
.signup-wrap { width: 100%; max-width: 980px; display: grid; grid-template-columns: 1fr 420px; gap: 48px; align-items: center; }
.signup-pitch h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 12px; letter-spacing: -.02em; }
.signup-pitch .lead-text { font-size: 1.05rem; margin-bottom: 24px; }
.signup-card .card-body { padding: 32px; }
.check-list { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 10px; }
.check-list .bi { color: var(--c-success); margin-right: 6px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.plan-card { border: 1px solid var(--c-border); border-radius: var(--radius-lg); background: var(--c-surface); padding: 18px; box-shadow: var(--shadow-sm); }
.plan-card.current { border-color: var(--c-primary); box-shadow: var(--ring); }
.plan-card .price { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; }
.plan-card .price small { font-size: .8rem; font-weight: 400; color: var(--c-muted); }
.meter { height: 8px; border-radius: 99px; background: var(--c-neutral-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--c-primary); border-radius: 99px; }
.meter.full > span { background: var(--c-danger); }
.pre-wrap { white-space: pre-wrap; }

/* ---- Adaptable ---- */
@media (max-width: 991.98px) {
  .signup-wrap { grid-template-columns: 1fr; gap: 24px; }
  .signup-pitch h1 { font-size: 1.5rem; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: var(--c-surface); border-top: 1px solid var(--c-border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--c-subtle); font-size: .72rem; font-weight: 500; border-radius: var(--radius); }
  .bottom-nav a .bi { font-size: 1.25rem; }
  .bottom-nav a.active { color: var(--c-primary); }
  .bottom-nav a:hover { text-decoration: none; }
  body:has(.bottom-nav) .content { padding-bottom: 96px; }
  .sidebar { position: fixed; z-index: 1045; left: calc(-1 * var(--sidebar-w)); transition: left .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 1040; }
  .content { padding: 16px 16px 96px; }
  .topbar { padding: 0 12px; }
  .banner { padding: 10px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 1.3rem; }
  .steps .label { display: none; }
}
@media (max-width: 575.98px) {
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1; }
  .global-search .kbd { display: none; }
  .stat-value { font-size: 1.5rem; }
  .table > tbody td, .table > thead th { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .sidebar, .topbar, .page-actions, .form-actions, .toasts, .bottom-nav { display: none !important; } .content { padding: 0; } }
