/* ==========================================================================
   LEMar Inventario -- Sistema de diseño
   Base: paleta y principios tipográficos/espaciales del método de dataviz
   (superficie clara, tinta casi-negra, acento azul, colores de estado
   reservados, bordes hairline en vez de sombra, alta densidad legible).
   ========================================================================== */

/* -------------------------------- Tokens -------------------------------- */
:root {
  color-scheme: light;

  /* Superficies */
  --canvas: #f7f7f5;
  --surface: #ffffff;
  --surface-sunken: #f2f1ee;
  --surface-hover: #f0f4fa;

  /* Tinta */
  --ink-primary: #14181c;
  --ink-secondary: #52514e;
  --ink-muted: #8a8981;
  --ink-inverse: #ffffff;

  /* Bordes */
  --border: rgba(20, 24, 28, 0.10);
  --border-strong: rgba(20, 24, 28, 0.18);
  --border-focus: #2a78d6;

  /* Acento (coincide con la identidad LEMar) */
  --accent: #1c5cab;
  --accent-strong: #184f95;
  --accent-soft: #eaf2fc;
  --accent-soft-border: #cfe1f7;
  --on-accent: #ffffff;

  /* Estado -- reservados, nunca decorativos */
  --good: #0a7a2e;
  --good-soft: #e7f5ea;
  --good-soft-border: #c8e6cf;
  --warning: #8a5a00;
  --warning-soft: #fdf3d9;
  --warning-soft-border: #f3e0a4;
  --critical: #b3261e;
  --critical-soft: #fbeae8;
  --critical-soft-border: #f2c9c4;
  --info: var(--accent);
  --info-soft: var(--accent-soft);

  /* Tipografía */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.6875rem;   /* 11px */
  --text-sm: 0.8125rem;   /* 13px */
  --text-base: 0.875rem;  /* 14px */
  --text-md: 0.9375rem;   /* 15px */
  --text-lg: 1.0625rem;   /* 17px */
  --text-xl: 1.375rem;    /* 22px */
  --text-2xl: 1.75rem;    /* 28px */

  --leading-tight: 1.2;
  --leading-normal: 1.5;

  /* Spacing (base 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radios */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Elevación (uso mínimo, solo para capas flotantes) */
  --shadow-float: 0 8px 24px rgba(20, 24, 28, 0.12), 0 2px 6px rgba(20, 24, 28, 0.06);

  /* Layout */
  --sidebar-width: 232px;
  --topbar-height: 56px;
  --content-max: 1360px;

  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* -------------------------------- Reset ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: var(--leading-tight); letter-spacing: -0.01em; }
p { margin: 0 0 var(--space-3); }
ul, ol { margin: 0; padding: 0; }
button { font-family: inherit; }
::selection { background: var(--accent-soft-border); }

/* Focus ring consistente en todo elemento interactivo */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.icon { width: 1em; height: 1em; }
i.bi { line-height: 1; vertical-align: -0.09em; }

/* ------------------------------ App shell -------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform 0.22s var(--ease);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
}
.sidebar__brand img { height: 26px; width: auto; }
.sidebar__brand-text {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-primary);
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.sidebar__brand-sub { font-size: var(--text-xs); color: var(--ink-muted); font-weight: 400; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--space-3) var(--space-2); }
.sidebar__section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: var(--space-4) var(--space-3) var(--space-1);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  position: relative;
}
.nav-link i.bi { font-size: 1rem; color: var(--ink-muted); }
.nav-link:hover { background: var(--surface-hover); color: var(--ink-primary); text-decoration: none; }
.nav-link:hover i.bi { color: var(--accent); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-link.is-active i.bi { color: var(--accent-strong); }
.nav-link__badge {
  margin-left: auto;
  background: var(--critical);
  color: var(--on-accent);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: var(--radius-pill);
}

.sidebar__footer {
  border-top: 1px solid var(--border);
  padding: var(--space-3);
}
.user-chip { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); }
.user-chip__avatar {
  width: 30px; height: 30px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: 600; flex-shrink: 0;
}
.user-chip__meta { min-width: 0; flex: 1; }
.user-chip__name { font-size: var(--text-sm); font-weight: 600; color: var(--ink-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip__role { font-size: var(--text-xs); color: var(--ink-muted); text-transform: capitalize; }
.user-chip__logout { color: var(--ink-muted); flex-shrink: 0; padding: var(--space-1); border-radius: var(--radius-sm); display: flex; }
.user-chip__logout:hover { color: var(--critical); background: var(--critical-soft); }

.sidebar-scrim {
  position: fixed; inset: 0; background: rgba(20, 24, 28, 0.4);
  z-index: 39; opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease);
}

/* ------------------------------ Topbar & main ----------------------------- */
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.app-main--full { margin-left: 0; }

.topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar__menu-btn {
  display: none;
  border: none; background: transparent; color: var(--ink-secondary);
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  align-items: center; justify-content: center; font-size: 1.15rem; cursor: pointer;
}
.topbar__menu-btn:hover { background: var(--surface-hover); }
.topbar__title { font-size: var(--text-md); font-weight: 600; color: var(--ink-primary); }
.topbar__spacer { flex: 1; }
.topbar__logos { display: flex; align-items: center; gap: var(--space-3); opacity: 0.9; }
.topbar__logos img { height: 24px; width: auto; }

.content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.page-header__title { font-size: var(--text-xl); font-weight: 650; color: var(--ink-primary); }
.page-header__subtitle { font-size: var(--text-sm); color: var(--ink-muted); margin-top: 2px; }
.page-header__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.section-heading {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-primary);
  margin-bottom: var(--space-3);
}

/* --------------------------------- Buttons -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), color 0.12s var(--ease);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }

.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--ink-primary); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--ink-muted); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink-primary); }

.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--ink-muted); }
.btn-danger-ghost:hover { background: var(--critical-soft); color: var(--critical); }

.btn-sm { padding: 4px 10px; font-size: var(--text-xs); }
.btn-icon { width: 32px; height: 32px; padding: 0; flex-shrink: 0; }
.btn-block { width: 100%; }

/* --------------------------------- Forms ---------------------------------- */
.field { margin-bottom: var(--space-4); }
.field-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(var(--cols, 2), 1fr); }
.field-row.cols-3 { --cols: 3; }
.field-row.cols-4 { --cols: 4; }

label, .form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-primary);
  margin-bottom: 6px;
}
.form-hint { font-size: var(--text-xs); color: var(--ink-muted); margin-top: 4px; }
.form-error { font-size: var(--text-xs); color: var(--critical); margin-top: 4px; }

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--ink-primary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  line-height: 1.4;
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
textarea { resize: vertical; min-height: 88px; }
.input::placeholder, input::placeholder, textarea::placeholder { color: var(--ink-muted); }

.input:hover, input:hover, select:hover, textarea:hover { border-color: var(--ink-muted); }
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.is-invalid { border-color: var(--critical) !important; }
.is-invalid:focus { box-shadow: 0 0 0 3px var(--critical-soft) !important; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2352514e' stroke-width='1.4' fill='none' fill-rule='evenodd' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }
.checkbox-row label { margin: 0; font-weight: 400; }

fieldset { border: none; padding: 0; margin: 0 0 var(--space-6); }
fieldset:last-of-type { margin-bottom: 0; }
legend {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: 0 0 var(--space-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
  width: 100%;
}

.form-actions {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
}

/* File input / dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  background: var(--surface-sunken);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
  position: relative;
}
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone__icon { font-size: 1.75rem; color: var(--ink-muted); margin-bottom: var(--space-2); }
.dropzone__title { font-size: var(--text-sm); font-weight: 600; color: var(--ink-primary); }
.dropzone__hint { font-size: var(--text-xs); color: var(--ink-muted); margin-top: 4px; }
.dropzone__filename { font-size: var(--text-sm); font-weight: 500; color: var(--accent-strong); margin-top: var(--space-2); }
.dropzone input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}

/* --------------------------------- Panels/cards ---------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 0;
}
.panel__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.panel__header-title { font-size: var(--text-sm); font-weight: 600; color: var(--ink-primary); }
.panel__body { padding: var(--space-5); }
.panel__body.is-flush { padding: 0; }
.panel + .panel { margin-top: var(--space-4); }
details.panel > summary { list-style: none; cursor: pointer; user-select: none; }
details.panel > summary::-webkit-details-marker { display: none; }
.activity-summary__meta { display: flex; align-items: center; gap: var(--space-3); color: var(--ink-muted); font-size: var(--text-xs); }
.activity-summary__chevron { transition: transform 160ms ease; font-size: var(--text-sm); }
details[open] .activity-summary__chevron { transform: rotate(180deg); }
.activity-filter { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); background: var(--surface-sunken); }
.activity-filter .alert { margin-top: var(--space-3); margin-bottom: 0; }

.grid { display: grid; gap: var(--space-4); min-width: 0; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-aside { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

/* --------------------------------- Stat tiles ------------------------------ */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
}
.stat-tile__top { display: flex; align-items: center; justify-content: space-between; }
.stat-tile__label { font-size: var(--text-xs); font-weight: 500; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile__icon { color: var(--ink-muted); font-size: 1rem; }
.stat-tile__value { font-size: var(--text-2xl); font-weight: 650; color: var(--ink-primary); letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: proportional-nums; }
.stat-tile__delta { font-size: var(--text-xs); font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.stat-tile__delta.is-warning { color: var(--warning); }
.stat-tile__delta.is-good { color: var(--good); }
.stat-tile__delta.is-neutral { color: var(--ink-muted); }
.stat-tile.is-alert { border-color: var(--warning-soft-border); background: var(--warning-soft); }
.stat-tile.is-alert .stat-tile__value { color: #6b4400; }

/* --------------------------------- Tables --------------------------------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--ink-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-hover); }
.table tbody tr.is-flagged td { background: var(--warning-soft); }
.table tbody tr.is-flagged:hover td { background: #fbecc4; }
.table .num, .table td.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: var(--text-xs); }
.table-actions { display: flex; gap: 4px; justify-content: flex-end; }
.table-empty { padding: var(--space-12) var(--space-4); text-align: center; }

/* --------------------------------- Badges/pills ---------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-neutral { background: var(--surface-sunken); color: var(--ink-secondary); border-color: var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-soft-border); }
.badge-good { background: var(--good-soft); color: var(--good); border-color: var(--good-soft-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-soft-border); }
.badge-critical { background: var(--critical-soft); color: var(--critical); border-color: var(--critical-soft-border); }
.badge-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex-shrink: 0; }

/* --------------------------------- Alerts / flash --------------------------- */
.alert-stack { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
}
.alert i.bi { margin-top: 1px; }
.alert-success { background: var(--good-soft); border-color: var(--good-soft-border); color: #145c2c; }
.alert-info { background: var(--accent-soft); border-color: var(--accent-soft-border); color: var(--accent-strong); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-soft-border); color: #6b4400; }
.alert-danger { background: var(--critical-soft); border-color: var(--critical-soft-border); color: #8c1d16; }
.alert__close { margin-left: auto; background: none; border: none; color: inherit; opacity: 0.6; cursor: pointer; padding: 2px; line-height: 1; }
.alert__close:hover { opacity: 1; }

/* --------------------------------- Empty states ------------------------------ */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--ink-muted);
}
.empty-state__icon { font-size: 1.75rem; color: var(--border-strong); margin-bottom: var(--space-3); }
.empty-state__title { font-size: var(--text-sm); font-weight: 600; color: var(--ink-secondary); margin-bottom: 4px; }
.empty-state__hint { font-size: var(--text-sm); color: var(--ink-muted); max-width: 34ch; margin: 0 auto; }

/* --------------------------------- Tooltip ------------------------------------ */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: var(--ink-primary);
  color: var(--ink-inverse);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s var(--ease), transform 0.12s var(--ease);
  z-index: 50;
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --------------------------------- Auth pages ---------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
}
.auth-shell__aside {
  background: var(--ink-primary);
  background-image: radial-gradient(circle at 18% 22%, rgba(255,255,255,0.10), transparent 45%),
                     radial-gradient(circle at 82% 78%, rgba(255,255,255,0.06), transparent 40%);
  color: var(--ink-inverse);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-10);
}
.auth-shell__aside-top { display: flex; align-items: center; gap: var(--space-3); }
.auth-shell__aside-top img { height: 30px; width: auto; }
.auth-shell__aside-logos { display: flex; align-items: center; gap: var(--space-4); }
.auth-shell__aside-logos img.on-dark { filter: brightness(0) invert(1); opacity: 0.92; height: 26px; }
.auth-shell__quote { font-size: var(--text-lg); line-height: 1.5; max-width: 40ch; font-weight: 400; color: rgba(255,255,255,0.92); }
.auth-shell__quote-attr { font-size: var(--text-xs); color: rgba(255,255,255,0.55); margin-top: var(--space-3); text-transform: uppercase; letter-spacing: 0.06em; }

.auth-shell__main { display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card__title { font-size: var(--text-xl); font-weight: 650; color: var(--ink-primary); margin-bottom: 4px; }
.auth-card__subtitle { font-size: var(--text-sm); color: var(--ink-muted); margin-bottom: var(--space-6); }
.auth-card__footer { font-size: var(--text-sm); color: var(--ink-muted); margin-top: var(--space-5); text-align: center; }
.auth-divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-5) 0; color: var(--ink-muted); font-size: var(--text-xs); text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: var(--space-4); border-radius: 12px; background: #e9f5f8; color: #176d87; font-size: 23px; }
.auth-icon--success { background: #e7f5ea; color: #15703a; }
.auth-security-note { margin-top: var(--space-4); line-height: 1.55; }
.password-input-wrap { position: relative; }
.password-input-wrap .input { padding-right: 46px; }
.password-toggle { position: absolute; top: 50%; right: 5px; transform: translateY(-50%); display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ink-muted); cursor: pointer; }
.password-toggle:hover, .password-toggle:focus-visible { color: var(--accent); background: var(--surface-hover); outline: none; }
.password-toggle:focus-visible { box-shadow: 0 0 0 2px var(--accent-soft-border); }

/* --------------------------------- Utilities ------------------------------------ */
.text-muted { color: var(--ink-muted); }
.text-secondary { color: var(--ink-secondary); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.font-mono { font-family: var(--font-mono); }
.mono-id { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-secondary); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.w-full { width: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
@media (max-width: 640px) {
  .hide-mobile { display: none !important; }
}

.definition-list { display: grid; grid-template-columns: 160px 1fr; row-gap: var(--space-3); column-gap: var(--space-4); font-size: var(--text-sm); }
.definition-list dt { color: var(--ink-muted); font-weight: 500; }
.definition-list dd { margin: 0; color: var(--ink-primary); }

.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-item__dot { width: 7px; height: 7px; border-radius: 999px; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.timeline-item__body { flex: 1; min-width: 0; }
.timeline-item__top { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
.timeline-item__time { font-size: var(--text-xs); color: var(--ink-muted); white-space: nowrap; font-family: var(--font-mono); }
.timeline-item__desc { font-size: var(--text-sm); color: var(--ink-secondary); margin-top: 2px; }

.autofill-hint {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); color: var(--accent-strong);
  background: var(--accent-soft); border-radius: var(--radius-sm);
  padding: 2px 8px; margin-top: 6px;
  opacity: 0; transform: translateY(-2px);
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
.autofill-hint.is-visible { opacity: 1; transform: translateY(0); }

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.filter-bar__row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; }
.filter-bar__field { flex: 1 1 180px; min-width: 0; }
.filter-bar__field label { font-size: var(--text-xs); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; margin-bottom: 5px; }
.filter-bar__actions { display: flex; gap: var(--space-2); }
.filter-bar__reset { align-self: center; }

footer.app-footer {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  padding: var(--space-8) var(--space-4) var(--space-6);
}

/* --------------------------------- Responsive ------------------------------------ */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-float); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim.is-open { opacity: 1; pointer-events: auto; }
  .app-main { margin-left: 0; }
  .topbar { padding: 0 var(--space-4); }
  .topbar__menu-btn { display: inline-flex; }
  .topbar__logos { display: none; }
  .content { padding: var(--space-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-main-aside { grid-template-columns: 1fr; }
  .field-row, .field-row.cols-3, .field-row.cols-4 { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-shell__aside { display: none; }
}

@media (max-width: 640px) {
  .content { padding: var(--space-3); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header__actions { width: 100%; }
  .page-header__actions .btn { flex: 1; }
  .panel__body { padding: var(--space-4); }
  .panel__header { padding: var(--space-3) var(--space-4); }
  .definition-list { grid-template-columns: 1fr; row-gap: var(--space-1); }
  .definition-list dt { margin-top: var(--space-2); }
  .filter-bar__row { flex-direction: column; align-items: stretch; gap: var(--space-4); }
  /* En columna, flex-basis pasa a ser altura: hay que neutralizarlo. */
  .filter-bar__field { flex: 0 0 auto !important; }
  .filter-bar__actions { width: 100%; }
  .filter-bar__actions .btn { flex: 1; }
  .stat-tile__value { font-size: var(--text-xl); }
}
