/* ==========================================================================
   MyManageRH — Design System v2  ("libro de sueldos")
   Se carga DESPUÉS de styles.css. Redefine los tokens que ya usa todo el
   frontend (mismos nombres de variable) y reemplaza los componentes
   compartidos. Dirección: documental y precisa. La estructura la llevan
   bordes y tipografía, no sombras ni efectos.
   Modo de diseño (impeccable): app = "Operate", documentación = "Read".
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Marca: índigo "tinta de sello". Continuidad con la marca actual, más
     profundo y sin degradé. Texto blanco sobre brand-700 = 7.5:1. */
  --brand-900: #1c2566;
  --brand-800: #2a3592;
  --brand-700: #3440b8;
  --brand-600: #4552cf;
  --brand-500: #5a66dd;
  --brand-100: #e4e7fa;
  --brand-50: #f1f3fd;
  /* Sigue siendo un <image> válido para `background-image`, pero es plano. */
  --brand-gradient: linear-gradient(var(--brand-700), var(--brand-700));

  /* Neutros azulados. (--slate-600 y --brand-500 se usaban sin estar definidos.) */
  --slate-950: #0e1424;
  --slate-900: #172033;
  --slate-800: #243049;
  --slate-700: #3b475f;
  --slate-600: #4b5873;
  --slate-500: #5b677e;
  --slate-400: #7d889d;
  --slate-300: #c3cad8;
  --slate-200: #dde2ec;
  --slate-100: #edf0f6;
  --slate-50: #f5f7fa;
  --white: #ffffff;

  --ink: var(--slate-900);
  --paper: #f4f6fa;
  --surface: #ffffff;
  --line: var(--slate-200);
  --line-strong: var(--slate-300);
  --focus: var(--brand-600);

  /* Estados de documento. Siempre acompañados de texto, nunca solo color. */
  --success-text: #0f7b4f;
  --success-solid: #0b5c3b;
  --success-bg: #e3f5ec;
  --success-border: #b7e3cc;

  --warning-text: #9a5b00;
  --warning-solid: #6f4200;
  --warning-bg: #fff1d6;
  --warning-border: #f2d49b;

  --error-text: #b3261e;
  --error-solid: #8a1c16;
  --error-bg: #fde8e6;
  --error-border: #f4bdb8;

  --info-text: var(--brand-700);
  --info-solid: var(--brand-800);
  --info-bg: var(--brand-100);
  --info-border: #c9cff3;

  /* Tipografía: IBM Plex Sans (documental, números tabulares nativos).
     Plex Mono solo para identificadores: CUIL, hashes, códigos. */
  --font-sans: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-h1: 30px;
  --text-h2: 22px;
  --text-h3: 17px;
  --text-body: 15px;
  --text-label: 14px;
  --text-caption: 13px;

  /* Geometría con jerarquía: controles < tarjetas < diálogos. */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Sombras casi nulas: las superficies se separan con bordes. */
  --shadow-sm: none;
  --shadow-md: 0 2px 8px rgba(23, 32, 51, 0.06);
  --shadow-lg: 0 8px 24px rgba(23, 32, 51, 0.1);
  --shadow-xl: 0 16px 48px rgba(23, 32, 51, 0.16);
  --shadow-glow: none;

  /* Movimiento: corto, ease-out, sin rebote. */
  --duration-fast: 100ms;
  --duration-base: 140ms;
  --duration-smooth: 200ms;
  --ease-spring: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Espaciado (escala de 4) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Layout */
  --nav-height: 56px;
  --sidebar-w: 248px;
  --container-max: 1120px;
  --content-max: 1200px;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
html {
  scroll-behavior: auto;
  scroll-padding-top: calc(var(--nav-height) + 16px);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--paper);
  color: var(--slate-700);
  font-size: var(--text-body);
  line-height: 1.55;
  letter-spacing: 0;
}

h1, h2, h3, h4, h5, h6, .card-title {
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

p, .text-muted { color: var(--slate-500); }

a { color: var(--brand-700); font-weight: 500; transition: color var(--duration-base) ease-out; }
a:hover { color: var(--brand-900); text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--brand-100); color: var(--ink); }

code { font-family: var(--font-mono); background: var(--slate-100); border-radius: 4px; }
/* Identificadores (CUIL, hashes): monoespaciado, sin fondo */
.mono { font-family: var(--font-mono); font-size: 0.93em; }
.table .mono { white-space: nowrap; }

/* Foco visible, único para todo el producto. */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--focus) !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.input:focus-visible {
  outline-offset: 0 !important;
}

/* Controles: sin selección de texto ni retardo táctil. El contenido sí se
   puede seleccionar. */
button, [role="button"], .btn, .tab-item, .tab-btn {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.modal-open { overflow: hidden; }

.page { animation: none; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 3000;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--white);
  font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; color: var(--white); text-decoration: none; }

/* --------------------------------------------------------------------------
   3. Shell: encabezado, navegación lateral (escritorio) y barra inferior (móvil)
   -------------------------------------------------------------------------- */
.site-header {
  min-height: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 20px 0;
  background: var(--surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}

.brand-title {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Barra de navegación de la aplicación autenticada */
.app-nav { display: none; }

.layout[data-shell="app"] .app-nav {
  display: flex;
  position: fixed;
  z-index: 90;
  background: var(--surface);
}

.app-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--slate-700);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-base) ease-out, color var(--duration-base) ease-out;
}
.app-link:hover { text-decoration: none; color: var(--slate-700); }
.app-link svg { width: 20px; height: 20px; flex: none; }
.app-link .link-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-link:active { background: var(--slate-100); }
.app-link[aria-current="page"] {
  background: var(--brand-50);
  color: var(--brand-800);
  font-weight: 600;
}

@media (hover: hover) and (pointer: fine) {
  .app-link:hover { background: var(--slate-100); color: var(--ink); }
  .app-link[aria-current="page"]:hover { background: var(--brand-100); color: var(--brand-900); }
}

.nav-context {
  padding: 4px 12px 12px;
  color: var(--slate-500);
  font-size: var(--text-caption);
}

.nav-context-label { min-width: 0; }
.nav-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  padding: 6px;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--slate-600);
  cursor: pointer;
}
.nav-collapse-btn:hover { background: var(--slate-100); color: var(--ink); }
.nav-collapse-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.nav-collapse-btn svg { width: 18px; height: 18px; }
.nav-more-btn { display: none; }
.nav-more-btn[aria-expanded="true"] { background: var(--slate-100); color: var(--ink); }

/* El contador de notificaciones lo agrega router.js como hijo de #nav-notif */
.app-link .notification-badge {
  position: static;
  margin-left: auto;
  border: 0;
  box-shadow: none;
  background: var(--error-text);
}

/* Escritorio: barra lateral */
@media (min-width: 1024px) {
  .layout[data-shell="app"][data-sidebar-collapsed="true"] { --sidebar-w: 72px; }

  .layout[data-shell="app"] .app-nav {
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    flex-direction: column;
    gap: 2px;
    padding: 16px 12px;
    overflow-y: auto;
    border-right: 1px solid var(--line);
  }
  .nav-context { display: flex; align-items: center; justify-content: space-between; }
  .nav-more-sheet { display: contents; }
  .nav-divider { height: 1px; margin: 8px 12px; background: var(--line); }
  .app-link--logout { margin-top: auto; color: var(--slate-600); }

  .layout[data-shell="app"][data-sidebar-collapsed="true"] .nav-context {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
  .layout[data-shell="app"][data-sidebar-collapsed="true"] .nav-context-label,
  .layout[data-shell="app"][data-sidebar-collapsed="true"] .app-link .link-label {
    display: none;
  }
  .layout[data-shell="app"][data-sidebar-collapsed="true"] .nav-collapse-btn svg {
    transform: rotate(180deg);
  }
  .layout[data-shell="app"][data-sidebar-collapsed="true"] .app-link {
    justify-content: center;
    padding-left: 4px;
    padding-right: 4px;
  }
  .layout[data-shell="app"][data-sidebar-collapsed="true"] .app-link .notification-badge {
    position: absolute;
    top: 2px;
    right: 3px;
    margin: 0;
  }

  .layout[data-shell="app"] > .page {
    /* .container trae width:100%; con el margen de la barra lateral se desbordaba */
    width: auto;
    max-width: none;
    margin-left: var(--sidebar-w);
    margin-right: 0; /* el "auto" de .container anula el estiramiento del flex */
    padding: 32px clamp(24px, 4vw, 48px) 64px;
  }
  .layout[data-shell="app"] > .page > * {
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
  }
  .layout[data-shell="app"] > .footer { margin-left: var(--sidebar-w); }
}

/* Móvil y tablet: barra inferior + hoja "Más" */
@media (max-width: 1023.98px) {
  .layout[data-shell="app"] .app-nav {
    left: 0;
    right: 0;
    bottom: 0;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
  }
  .layout[data-shell="app"] .app-nav > .app-link,
  .layout[data-shell="app"] .app-nav > .nav-more-btn {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 52px;
    padding: 6px 4px;
    font-size: 12px;
    text-align: center;
  }
  .nav-more-btn { display: flex; }
  .nav-context, .nav-divider, .nav-collapse-btn { display: none; }

  .layout[data-shell="app"] .app-nav > .app-link .notification-badge {
    position: absolute;
    top: 2px;
    left: calc(50% + 4px);
    right: auto; /* styles.css fija right:-10px y la estiraba */
    margin: 0;
  }

  .nav-more-sheet {
    display: none;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
  }
  .app-nav[data-more="open"] .nav-more-sheet {
    display: flex;
    animation: ds-pop-in var(--duration-smooth) var(--ease-out);
  }
  .nav-more-sheet .app-link {
    flex-direction: row;
    justify-content: flex-start;
    min-height: 48px;
    font-size: 15px;
    text-align: left;
  }

  .layout[data-shell="app"] > .page {
    padding-left: clamp(16px, 4vw, 32px);
    padding-right: clamp(16px, 4vw, 32px);
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }
  .layout[data-shell="app"] > .footer {
    margin-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

.footer, .footer-trust {
  margin-top: 48px;
  padding: 24px;
  border-top: 1px solid var(--line);
  color: var(--slate-500);
}

/* --------------------------------------------------------------------------
   4. Botones
   -------------------------------------------------------------------------- */
.btn {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  transition:
    background-color var(--duration-base) ease-out,
    border-color var(--duration-base) ease-out,
    color var(--duration-base) ease-out,
    transform var(--duration-fast) ease-out;
}

/* Anula el "levantar" del sistema anterior; el hover real va más abajo, solo con mouse */
.btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled),
.btn-sign:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
}

.btn:active:not(:disabled) { transform: scale(0.98); background: var(--slate-100); }

.btn-primary, .btn-sign {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: var(--white);
  box-shadow: none;
}
.btn-primary:active:not(:disabled), .btn-sign:active:not(:disabled) {
  background: var(--brand-900);
  border-color: var(--brand-900);
}

.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--slate-700); }
.btn-ghost:active:not(:disabled) { background: var(--slate-100); }

.btn-danger { background: var(--error-text); border-color: var(--error-text); color: var(--white); box-shadow: none; }
.btn-danger:active:not(:disabled) { background: var(--error-solid); border-color: var(--error-solid); }

@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: var(--slate-50); border-color: var(--slate-400); }
  .btn-primary:hover:not(:disabled), .btn-sign:hover:not(:disabled) {
    background: var(--brand-800); border-color: var(--brand-800); color: var(--white);
  }
  .btn-secondary:hover:not(:disabled) { background: var(--slate-50); border-color: var(--slate-400); color: var(--ink); }
  .btn-ghost:hover:not(:disabled) { background: var(--slate-100); border-color: transparent; color: var(--ink); }
  .btn-danger:hover:not(:disabled) { background: var(--error-solid); border-color: var(--error-solid); color: var(--white); }
}

.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-lg { min-height: 46px; padding: 10px 24px; font-size: 15px; }

.btn-logout {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--slate-700);
  box-shadow: none;
}

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .empresa-icon-btn, .empresa-employee-action { min-height: 40px; }
}

/* --------------------------------------------------------------------------
   5. Superficies, KPIs y avisos
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
  padding: 24px;
  transition: border-color var(--duration-base) ease-out;
}
.card:hover { transform: none; box-shadow: none; border-color: var(--line); }
.card-header { border-bottom: 1px solid var(--line); }
.card-title { font-size: var(--text-h3); font-weight: 600; }

@media (hover: hover) and (pointer: fine) {
  .empresa-import-mode-card:hover,
  .empresa-history-employee-button:hover { border-color: var(--brand-600); background: var(--brand-50); }
}

.kpi-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.kpi-card {
  background: var(--surface) !important;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: none;
  transition: none;
}
.kpi-card { container-type: inline-size; }
.kpi-card::before { display: none; }
.kpi-card:hover { transform: none; box-shadow: none; border-color: var(--line); }

.kpi-label {
  color: var(--slate-500);
  font-size: var(--text-label);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.kpi-value {
  color: var(--ink);
  /* El tamaño sigue el ancho de la tarjeta (container query), así un importe largo entra sin partirse */
  font-size: clamp(20px, 10cqw, 28px);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap; /* un importe no se parte en dos líneas */
  font-variant-numeric: tabular-nums;
}

.notice-panel { border-radius: var(--radius-md); }

.error, .success { border-radius: var(--radius-md); }

.page-title { font-size: var(--text-h2); font-weight: 700; color: var(--ink); }
.page-subtitle { font-size: var(--text-label); }

.dl-label { text-transform: none; font-size: var(--text-caption); font-weight: 500; }

/* --------------------------------------------------------------------------
   6. Formularios
   -------------------------------------------------------------------------- */
.form-group { gap: 6px; margin-bottom: 18px; }
.form-group label { font-size: var(--text-label); font-weight: 600; color: var(--ink); }

.input, select, textarea {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
  font-size: var(--text-body);
}
textarea { min-height: 96px; resize: vertical; }

.input::placeholder, textarea::placeholder { color: var(--slate-400); }

.input:focus, select:focus, textarea:focus {
  border-color: var(--brand-600);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(69, 82, 207, 0.16);
}

.input:disabled, select:disabled, textarea:disabled { background: var(--slate-50); color: var(--slate-500); }

.input.error, select.error, textarea.error,
.input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--error-text);
}
.input.error:focus, select.error:focus, textarea.error:focus,
.input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px var(--error-bg);
}

.form-error-msg { color: var(--error-text); font-size: var(--text-caption); font-weight: 500; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-700); }

@media (hover: hover) and (pointer: fine) {
  .input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) {
    border-color: var(--slate-400);
    background-color: var(--surface);
  }
}

/* iOS hace zoom al enfocar inputs de menos de 16px. */
@media (pointer: coarse) {
  input, textarea, select, .input { font-size: 16px; }
  .checkbox-label input[type="checkbox"], .radio-label input[type="radio"] { width: 22px; height: 22px; }
}

/* --------------------------------------------------------------------------
   7. Tablas
   -------------------------------------------------------------------------- */
.table-container {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.table { font-size: 14px; }

.table th {
  padding: 10px 16px;
  background: var(--slate-50);
  color: var(--slate-600);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.table td { padding: 12px 16px; border-bottom: 1px solid var(--slate-100); color: var(--ink); }

@media (hover: hover) and (pointer: fine) {
  .table tbody tr:hover { background: var(--slate-50); }
}

.table .amount, .td-right, .th-right { font-variant-numeric: tabular-nums; }

/* Nombres largos y textos sin espacios no deben romper el layout */
.empresa-employee-name, .empresa-import-name, .notification-item, .preview-field-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Corrige textos de 10px del panel de recibos */
.empresa-dashboard-shell #receiptsTable .badge.warning { padding: 2px 10px; font-size: 12px; }
.empresa-dashboard-shell #receiptsTable .table-actions .btn { min-height: 32px; padding: 5px 10px; font-size: 12px; }

/* --------------------------------------------------------------------------
   8. Insignias de estado
   -------------------------------------------------------------------------- */
.badge { min-height: 24px; padding: 2px 10px; font-size: var(--text-caption); font-weight: 600; white-space: nowrap; }
.badge.neutral { background: var(--slate-100); color: var(--slate-700); }

/* --------------------------------------------------------------------------
   9. Pestañas
   -------------------------------------------------------------------------- */
.tab-item, .tab-btn { min-height: 44px; font-size: var(--text-label); }
.tab-item.active, .tab-btn.active { color: var(--brand-800); border-bottom-color: var(--brand-700); }
.empresa-tabs, .empresa-tabs-scroll { scrollbar-width: none; }
.empresa-tabs::-webkit-scrollbar, .empresa-tabs-scroll::-webkit-scrollbar { display: none; }

@media (hover: hover) and (pointer: fine) {
  .tab-item:hover { color: var(--brand-800); background: var(--slate-50); }
}

/* --------------------------------------------------------------------------
   10. Diálogos
   -------------------------------------------------------------------------- */
.modal {
  background: rgba(23, 32, 51, 0.5);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overscroll-behavior: contain;
}

.modal-content {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  animation: ds-modal-in var(--duration-smooth) var(--ease-out);
}

.modal-header { border-bottom: 1px solid var(--line); }
.modal-title { font-size: var(--text-h3); font-weight: 700; }
.modal-footer { background: var(--slate-50); border-top: 1px solid var(--line); }

@keyframes ds-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes ds-sheet-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes ds-pop-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Móvil: los diálogos suben desde abajo, como una hoja */
@media (max-width: 640px) {
  .modal { align-items: flex-end; padding: 0; }
  .modal .modal-content {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: ds-sheet-in var(--duration-smooth) var(--ease-out);
  }
  .modal .modal-body { max-height: none; }
  .modal-actions, .modal-footer { flex-wrap: wrap; }
  .modal-actions .btn, .modal-footer .btn { flex: 1 1 auto; }
}

/* --------------------------------------------------------------------------
   11. Avisos (toasts)
   -------------------------------------------------------------------------- */
.toasts, .toast-container {
  right: 24px;
  bottom: 24px;
  align-items: flex-end;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--ink);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  color: var(--white);
  font-size: var(--text-label);
  font-weight: 500;
  line-height: 1.4;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: ds-pop-in var(--duration-smooth) var(--ease-out);
}
.toast.success { background: var(--success-solid); }
.toast.error { background: var(--error-solid); }
.toast.warning { background: var(--warning-solid); }

.toast-icon { display: inline-flex; flex: none; margin-top: 1px; }
.toast-icon svg { width: 18px; height: 18px; }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: -2px -4px 0 0;
  border-radius: var(--radius-sm);
  color: inherit;
  opacity: 0.8;
}
.toast-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.16); }
.toast-close svg { width: 14px; height: 14px; }
.toast .toast-close:focus-visible { outline-color: var(--white) !important; }

@media (max-width: 1023.98px) {
  .layout[data-shell="app"] .toasts { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 768px) {
  .toasts, .toast-container { left: 16px; right: 16px; align-items: stretch; }
  .toast { min-width: 0; max-width: none; width: 100%; }
}

/* --------------------------------------------------------------------------
   12. Estados vacíos, carga y cabeceras
   -------------------------------------------------------------------------- */
.empty-title { font-weight: 600; }
.skeleton { border-radius: var(--radius-sm); }

@media (max-width: 768px) {
  .site-header {
    flex-direction: row;
    align-items: center;
    min-height: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 16px 0;
  }
  .page { padding-top: 20px; }
  .card { padding: 16px; }
  h1 { font-size: 26px; }
}

/* --------------------------------------------------------------------------
   13. Movimiento reducido
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .skeleton, .sign-otp-success { animation: none !important; }
  /* La landing revela secciones al hacer scroll: con movimiento reducido todo queda visible */
  .reveal-on-scroll { opacity: 1 !important; transform: none !important; }
}
