/* ============================================================
   Arajet · Documentación Pilotos — Estilos
   ============================================================ */

:root {
  --brand-deep: #1a0f2e;
  --brand-primary: #4c1d95;
  --brand-mid: #6d28d9;
  --brand-accent: #8b5cf6;
  --brand-light: #c4b5fd;
  --brand-glow: rgba(139, 92, 246, 0.35);

  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --ok: #059669;
  --ok-bg: #d1fae5;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info-bg: #dbeafe;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 20px rgba(26, 15, 46, 0.08);
  --shadow-lg: 0 20px 50px rgba(26, 15, 46, 0.15);
  --shadow-glow: 0 0 40px var(--brand-glow);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --topbar-h: 72px;
  --app-top-gap: 1.5rem;
  --topbar-pad-top: 10px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Views ─── */
.view {
  display: none;
  min-height: 100vh;
}

.view--active {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#view-app.view--active {
  padding: var(--app-top-gap) 1rem 1.5rem;
  box-sizing: border-box;
}

.app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  min-height: calc(100vh - 5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════ */
#view-login {
  position: relative;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(139, 92, 246, 0.25), transparent 50%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(5, 150, 105, 0.12), transparent 45%),
    linear-gradient(160deg, var(--brand-deep) 0%, #2e1064 40%, #1e1b4b 100%);
}

.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  padding: 2.5rem 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: cardIn 0.5s ease;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  text-align: center;
  margin-bottom: 2rem;
}

.brand__logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--brand-mid), var(--brand-accent));
  color: #fff;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--brand-glow);
}

.brand__logo svg {
  width: 32px;
  height: 32px;
}

.brand__logo--sm {
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 12px;
}

.brand__logo--sm svg {
  width: 22px;
  height: 22px;
}

.brand__tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-mid);
  background: #ede9fe;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.brand--compact {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-align: left;
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-top: 0.15rem;
}

.brand__title {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.brand__sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.3;
}

.login-footer {
  text-align: center;
  margin: 1.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* ─── Fields & forms ─── */
.field {
  display: block;
  margin-bottom: 1.1rem;
}

.field__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.field__wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field__icon {
  position: absolute;
  left: 0.85rem;
  font-size: 0.9rem;
  color: var(--text-soft);
  pointer-events: none;
  z-index: 1;
}

.field__wrap input {
  padding-left: 2.5rem;
}

.field--grow {
  flex: 1;
  min-width: 180px;
}

.form input,
.form select,
.form textarea,
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form input:hover,
.field input:hover,
.form select:hover,
.field select:hover {
  border-color: var(--border-strong);
}

.form input:focus,
.form select:focus,
.form textarea:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.form textarea,
.field textarea {
  resize: vertical;
  min-height: 88px;
}

.alert {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert--error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: linear-gradient(135deg, var(--brand-mid), var(--brand-accent));
  color: #fff;
  box-shadow: 0 4px 14px var(--brand-glow);
}

.btn--primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px var(--brand-glow);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

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

.btn--outline {
  background: transparent;
  color: var(--brand-mid);
  border: 1.5px solid var(--brand-light);
}

.btn--outline:hover {
  background: #f5f3ff;
  border-color: var(--brand-accent);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn--ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn--lg {
  padding: 0.8rem 1.25rem;
  font-size: 0.95rem;
}

.btn--block {
  width: 100%;
}

.btn--icon {
  gap: 0.35rem;
}

/* ═══════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: var(--topbar-pad-top) 1.5rem 1rem;
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.topbar--admin {
  gap: 1.25rem;
}

.topbar__left {
  flex-shrink: 0;
}

.topbar__center {
  flex: 1;
  max-width: 400px;
}

.topbar__right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.topbar__title-block h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar__title-block p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.search-wrap {
  position: relative;
}

.search-wrap__icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.6rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface-2);
  transition: all var(--transition);
}

.search-wrap input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
}

.user-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border: 1px solid #ddd6fe;
  border-radius: 999px;
  color: var(--brand-primary);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══════════════════════════════════════
   TOOLBAR & LEGEND
   ═══════════════════════════════════════ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(180deg, #faf8ff 0%, var(--surface-2) 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Selector pilotos / cabina (control segmentado) */
.tipo-nav {
  flex: 1 1 100%;
  display: flex;
  justify-content: center;
  order: -1;
}

.tipo-nav__track {
  display: inline-flex;
  align-items: stretch;
  padding: 4px;
  gap: 4px;
  background: #ede9fe;
  border: 1px solid #ddd6fe;
  border-radius: var(--radius);
  box-shadow: inset 0 1px 2px rgba(76, 29, 149, 0.06);
}

.tipo-nav__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.15rem;
  min-height: 2.5rem;
  border: none;
  border-radius: calc(var(--radius-sm) + 2px);
  background: transparent;
  color: #5b21b6;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.15s ease;
}

.tipo-nav__btn:hover:not(.tipo-nav__btn--active) {
  background: rgba(255, 255, 255, 0.55);
  color: var(--brand-primary);
}

.tipo-nav__btn--active {
  background: var(--surface);
  color: var(--brand-primary);
  box-shadow:
    0 1px 3px rgba(76, 29, 149, 0.12),
    0 4px 12px rgba(76, 29, 149, 0.1);
}

.tipo-nav__btn:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

.tipo-nav__icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.tipo-nav__btn--active .tipo-nav__icon {
  opacity: 1;
  color: var(--brand-mid);
}

.tipo-nav__text--short {
  display: none;
}

@media (max-width: 640px) {
  .tipo-nav__btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  .tipo-nav__btn[data-tipo="cabina"] .tipo-nav__text:not(.tipo-nav__text--short) {
    display: none;
  }

  .tipo-nav__btn[data-tipo="cabina"] .tipo-nav__text--short {
    display: inline;
  }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.legend__title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin-right: 0.25rem;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.pill {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
  flex-shrink: 0;
}

.pill--ok { background: var(--ok); box-shadow: 0 0 0 2px var(--ok-bg); }
.pill--warn { background: var(--warn); box-shadow: 0 0 0 2px var(--warn-bg); }
.pill--danger { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-bg); }
.pill--neutral { background: var(--border-strong); }

.toolbar__actions {
  display: flex;
  gap: 0.5rem;
}

/* ═══════════════════════════════════════
   MATRIZ
   ═══════════════════════════════════════ */
.matriz-wrap {
  flex: 1 1 auto;
  display: block;
  min-height: 420px;
  height: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 4rem 2rem;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border: 1px solid var(--border);
  border-top: none;
  min-height: 280px;
}

.loading__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.loading__hint {
  margin: 0;
  font-size: 0.85rem;
  max-width: 360px;
  text-align: center;
  line-height: 1.5;
}

.matriz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
  min-height: 200px;
}

.matriz-empty strong {
  color: var(--text);
  font-size: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#matriz-container.matriz-container {
  display: block;
  width: 100%;
  min-height: 420px;
  max-height: calc(100vh - 240px);
  overflow: auto;
  overflow-x: auto;
  background: var(--surface);
  transition: opacity 0.2s ease;
  box-sizing: border-box;
}

.matriz-container--cargando {
  opacity: 0.85;
  pointer-events: none;
}

.matriz-placeholder {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.matriz {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 0.8rem;
}

.matriz thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--brand-deep) 0%, var(--brand-primary) 100%);
  color: #fff;
  font-weight: 600;
  padding: 0.75rem 0.5rem;
  text-align: center;
  min-width: 115px;
  max-width: 150px;
  font-size: 0.72rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
  border-bottom: 2px solid var(--brand-accent);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.matriz thead th.col-nombre {
  left: 0;
  z-index: 20;
  min-width: 220px;
  max-width: 260px;
  text-align: left;
  padding-left: 1.15rem;
  font-size: 0.8rem;
  background: linear-gradient(180deg, #0f0a1a 0%, var(--brand-deep) 100%);
}

.matriz tbody tr:nth-child(even) th {
  background: #f1f5f9;
}

.matriz tbody tr:hover th {
  background: #e2e8f0;
}

.matriz tbody th {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface);
  font-weight: 600;
  font-size: 0.82rem;
  text-align: left;
  padding: 0.55rem 1.15rem;
  min-width: 220px;
  max-width: 260px;
  border-right: 2px solid var(--border-strong);
  color: var(--text);
  box-shadow: 4px 0 8px rgba(15, 23, 42, 0.04);
}

.matriz th,
.matriz td {
  border: 1px solid var(--border);
  vertical-align: top;
}

.matriz tbody tr:hover td:not(.celda--readonly) {
  filter: brightness(0.97);
}

.celda {
  min-width: 115px;
  max-width: 150px;
  min-height: 58px;
  padding: 0.5rem 0.55rem;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
}

.celda::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color var(--transition);
}

.celda:hover::after {
  border-color: var(--brand-accent);
}

.celda--readonly {
  cursor: default;
}

.celda--readonly:hover::after {
  border-color: transparent;
}

.celda--vencido::after {
  border-color: var(--danger) !important;
}

.celda__estado {
  font-weight: 700;
  font-size: 0.76rem;
  line-height: 1.25;
  color: var(--text);
}

.celda__nota {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  word-break: break-word;
  line-height: 1.35;
}

.celda__fecha {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.35rem;
  padding: 0.15rem 0.4rem;
  background: rgba(255,255,255,0.6);
  border-radius: 4px;
}

.celda--vencido .celda__fecha {
  color: var(--danger);
  background: var(--danger-bg);
}

.celda--por_vencer .celda__fecha {
  color: var(--warn);
}

.celda__empty {
  color: var(--text-soft);
  font-size: 0.75rem;
}

/* ═══════════════════════════════════════
   ADMIN
   ═══════════════════════════════════════ */
#view-admin.view--active {
  padding: var(--app-top-gap) 1rem 1.5rem;
  box-sizing: border-box;
  background: var(--surface-2);
}

#view-admin .topbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin-bottom: 0;
}

.admin-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 1rem 1.5rem 0;
  flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.admin-tab[hidden] {
  display: none !important;
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  padding: 0.65rem 1.1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.admin-tab:hover {
  color: var(--brand-mid);
  background: #faf5ff;
}

.admin-tab--active {
  color: var(--brand-mid);
  background: var(--surface-2);
  border-bottom-color: var(--brand-accent);
}

.admin-tab__icon {
  font-size: 1rem;
  opacity: 0.85;
}

.admin-panels {
  padding: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.admin-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.admin-panel--active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.panel-header {
  margin-bottom: 1.25rem;
}

.panel-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.panel-header__meta {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--brand-mid);
  font-weight: 600;
}

.panel-header__meta--warn {
  color: #b45309;
}

.panel-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card--form {
  border-left: 4px solid var(--brand-accent);
}

.card--warning {
  border-left: 4px solid #dc2626;
  background: linear-gradient(135deg, #fffbeb 0%, #fff 40%);
}

.card--warning h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #b91c1c;
}

.card--warning p {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.card--info {
  background: linear-gradient(135deg, #faf5ff 0%, var(--surface) 100%);
}

.card--info p,
.card--info .info-steps {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 1rem;
}

.info-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.9rem;
}

.step span {
  width: 26px;
  height: 26px;
  background: var(--brand-mid);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.form-inline .field {
  margin-bottom: 0;
}

.form-inline .btn {
  flex-shrink: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.form-grid .field {
  margin-bottom: 0;
}

.form-grid .btn {
  grid-column: 1 / -1;
  justify-self: start;
}

.card-list .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card-list .item:hover {
  border-color: var(--brand-light);
  box-shadow: var(--shadow-sm);
}

.item__actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.item--estado {
  align-items: center;
}

.estado-swatch {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.color-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-field input[type="color"] {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
}

.color-field input[type="text"] {
  flex: 1;
  min-width: 0;
}

.field--check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field--check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
}

.field--check-inline {
  margin-top: 1.75rem;
}

.form-grid--estados {
  align-items: end;
}

.btn--sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.btn--danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn--danger:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.item strong {
  font-weight: 600;
  color: var(--text);
}

.item__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.badge {
  font-size: 0.68rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--admin {
  background: #ede9fe;
  color: var(--brand-primary);
}

.badge--editor {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge--visor {
  background: var(--surface-3);
  color: var(--text-muted);
}

.badge--outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.item__badges {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}

.field-hint {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--brand-mid);
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: var(--radius-sm);
}

.matriz-empty--sm {
  padding: 1.25rem;
  font-size: 0.9rem;
}

.mono-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.25rem 0 0.4rem;
  color: var(--text-soft);
}

.code-block {
  display: block;
  padding: 0.85rem 1rem;
  background: var(--brand-deep);
  color: #c4b5fd;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  word-break: break-all;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.card--info code:not(.code-block) {
  background: #ede9fe;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--brand-primary);
}

/* ═══════════════════════════════════════
   MODAL
   ═══════════════════════════════════════ */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal:not([open]) {
  display: none;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand-primary));
  color: #fff;
}

.modal__eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
}

.modal__header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.modal__close {
  background: rgba(255,255,255,0.15);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  transition: background var(--transition);
}

.modal__close:hover {
  background: rgba(255,255,255,0.25);
}

.modal__body {
  padding: 1.5rem;
  background: var(--surface);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.modal--informe[open] {
  display: flex;
  flex-direction: column;
  max-width: min(960px, calc(100vw - 2rem));
  width: calc(100% - 2rem);
  max-height: calc(100vh - 2rem);
  margin: auto;
}

.modal--informe .modal__header {
  flex-shrink: 0;
}

.informe-resumen {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  opacity: 0.9;
  font-weight: 400;
}

.informe-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-wrap--sm {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.informe-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.informe-contenido {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--surface);
  min-height: 200px;
  max-height: min(60vh, 520px);
}

.informe-loading,
.informe-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  margin: 0;
}

.informe-grupo {
  margin-bottom: 1.5rem;
}

.informe-grupo__titulo {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-deep);
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--brand-light);
}

.informe-piloto-codigo {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.9em;
}

.informe-tabla-wrap {
  overflow-x: auto;
}

.informe-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.informe-tabla th,
.informe-tabla td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.informe-tabla th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-3);
}

.informe-tabla tbody tr:hover {
  background: var(--surface-2);
}

.informe-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.informe-badge--vencido {
  background: #fee2e2;
  color: #991b1b;
}

.informe-badge--por_vencer {
  background: #fef3c7;
  color: #92400e;
}

.informe-badge--atencion {
  background: #fef9c3;
  color: #854d0e;
}

.informe-badge--pendiente {
  background: #f3f4f6;
  color: #4b5563;
}

/* Encabezado solo al imprimir */
.informe-print-header {
  display: none;
  padding: 0 1.25rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.informe-print-header__brand {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-primary);
  font-weight: 600;
}

.informe-print-header__title {
  margin: 0.25rem 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-deep);
}

.informe-print-header__meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Contenedor off-screen para generar PDF */
.informe-pdf-mount {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 210mm;
  pointer-events: none;
  visibility: hidden;
  z-index: -1;
}

.informe-pdf-doc {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 10pt;
  color: #1e293b;
  background: #fff;
  width: 190mm;
  padding: 0;
}

.informe-pdf-doc__head {
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 55%, #6366f1 100%);
  color: #fff;
  padding: 14mm 12mm 12mm;
  margin-bottom: 8mm;
  border-radius: 4px;
}

.informe-pdf-doc__eyebrow {
  margin: 0 0 2mm;
  font-size: 8pt;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.88;
}

.informe-pdf-doc__head h1 {
  margin: 0 0 3mm;
  font-size: 22pt;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.informe-pdf-doc__meta {
  margin: 0;
  font-size: 9pt;
  opacity: 0.92;
}

.informe-pdf-doc__body {
  padding: 0 2mm;
}

.informe-pdf-grupo {
  margin-bottom: 7mm;
}

.informe-pdf-grupo__titulo {
  margin: 0 0 3mm;
  padding: 2.5mm 4mm;
  font-size: 11pt;
  font-weight: 700;
  color: #312e81;
  background: #eef2ff;
  border-left: 3px solid #4f46e5;
  border-radius: 2px;
}

.informe-pdf-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5pt;
}

.informe-pdf-tabla th {
  background: #f1f5f9;
  color: #475569;
  font-size: 7pt;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2.5mm 2mm;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.informe-pdf-tabla td {
  padding: 2.5mm 2mm;
  border: 1px solid #e2e8f0;
  vertical-align: top;
  line-height: 1.35;
}

.informe-pdf-tabla tbody tr:nth-child(even) td {
  background: #fafafa;
}

.informe-pdf-badge {
  display: inline-block;
  font-size: 7pt;
  font-weight: 700;
  padding: 0.5mm 1.5mm;
  border-radius: 2px;
  margin-right: 1mm;
}

.informe-pdf-badge--vencido {
  background: #fee2e2;
  color: #991b1b;
}

.informe-pdf-badge--por_vencer {
  background: #fef3c7;
  color: #92400e;
}

.informe-pdf-badge--atencion {
  background: #fef9c3;
  color: #854d0e;
}

.informe-pdf-badge--pendiente {
  background: #f3f4f6;
  color: #4b5563;
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  html,
  body {
    height: auto !important;
    overflow: visible !important;
  }

  body > *:not(#app) {
    display: none !important;
  }

  #app,
  #view-app,
  .view,
  .app-shell {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    position: static !important;
  }

  .topbar,
  .toolbar,
  .matriz-wrap,
  #toast,
  .modal::backdrop {
    display: none !important;
  }

  #modal-informe {
    position: static !important;
    display: block !important;
    max-width: 100% !important;
    max-height: none !important;
    height: auto !important;
    box-shadow: none !important;
    width: 100% !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  .informe-toolbar,
  .modal__footer,
  .modal__close,
  .modal--informe .modal__header {
    display: none !important;
  }

  .informe-print-header {
    display: block !important;
    padding: 0 0 12pt;
    margin-bottom: 12pt;
    border-bottom: 2pt solid #4f46e5;
  }

  .informe-print-header__title {
    font-size: 18pt;
  }

  .informe-contenido {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  .informe-grupo {
    break-inside: auto;
    page-break-inside: auto;
  }

  .informe-grupo__titulo {
    break-after: avoid;
    page-break-after: avoid;
  }

  .informe-tabla thead {
    display: table-header-group;
  }

  .informe-tabla tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  padding: 0.65rem;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand-light);
}

/* Modal de confirmación */
.modal--confirm {
  padding: 1.75rem 1.5rem 1.5rem;
  max-width: 400px;
  text-align: center;
  background: var(--surface);
}

.modal-confirm__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: #fef2f2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fecaca;
}

.modal-confirm__title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.modal-confirm__text {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-confirm__nombre {
  margin: 0 0 0.75rem;
  padding: 0.65rem 1rem;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brand-primary);
  line-height: 1.35;
  word-break: break-word;
}

.modal-confirm__hint {
  margin: 0 0 1.5rem;
  font-size: 0.8rem;
  color: var(--text-soft);
  line-height: 1.4;
}

.modal-confirm__footer {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
}

.modal-confirm__footer .btn {
  flex: 1;
  max-width: 160px;
}

.btn--danger-solid {
  background: #dc2626;
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn--danger-solid:hover {
  background: #b91c1c;
}

/* ═══════════════════════════════════════
   TOAST
   ═══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  left: 1.5rem;
  max-width: 360px;
  margin-left: auto;
  background: var(--brand-deep);
  color: #fff;
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(139, 92, 246, 0.4);
  animation: toastIn 0.35s ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ═══════════════════════════════════════
   RESPONSIVE — móvil y tablet
   ═══════════════════════════════════════ */

/* Textos cortos/largos en botones */
.btn__text--short {
  display: none;
}

.login-title__short {
  display: none;
}

/* Tablet */
@media (max-width: 900px) {
  :root {
    --topbar-h: auto;
    --app-top-gap: 0.5rem;
  }

  #view-app.view--active,
  #view-admin.view--active {
    padding: var(--app-top-gap) 0.5rem 0.75rem;
  }

  .app-shell {
    border-radius: var(--radius);
    min-height: calc(100dvh - 1rem);
  }

  .topbar {
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem 0.75rem;
    min-height: 0;
  }

  .topbar__left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar__center {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }

  .topbar__right {
    flex-shrink: 0;
    gap: 0.35rem;
  }

  .brand--compact .brand__logo--sm {
    width: 38px;
    height: 38px;
  }

  .brand__title {
    font-size: 0.9rem;
  }

  .user-badge {
    max-width: 120px;
    font-size: 0.68rem;
    padding: 0.3rem 0.5rem;
  }

  #matriz-container.matriz-container {
    max-height: calc(100dvh - 220px);
    -webkit-overflow-scrolling: touch;
  }

  .admin-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 0.85rem 0;
    gap: 0.25rem;
    scrollbar-width: none;
  }

  .admin-tabs::-webkit-scrollbar {
    display: none;
  }

  .admin-tab {
    flex-shrink: 0;
    padding: 0.55rem 0.85rem;
    font-size: 0.8rem;
  }
}

/* Móvil */
@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  #view-login {
    padding: 1rem;
    align-items: flex-start;
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .login-card {
    padding: 1.5rem 1.15rem;
    margin-top: 0.5rem;
    border-radius: var(--radius-lg);
  }

  .login-title__full {
    display: none;
  }

  .login-title__short {
    display: inline;
  }

  .brand h1,
  .login-title {
    font-size: 1.2rem;
    line-height: 1.3;
  }

  .brand {
    margin-bottom: 1.5rem;
  }

  .field__wrap input,
  .search-wrap input,
  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
  }

  .topbar {
    padding: 0.5rem 0.65rem;
  }

  .brand__sub {
    display: none;
  }

  .brand__title {
    font-size: 0.82rem;
    line-height: 1.2;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-badge {
    display: none;
  }

  .btn--icon-only-sm .btn__text {
    display: none;
  }

  .btn--icon-only-sm {
    padding: 0.55rem;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }

  .btn--sm-text {
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
    min-height: 44px;
  }

  .tipo-nav {
    padding: 0 0.65rem;
  }

  .tipo-nav__track {
    width: 100%;
    display: flex;
  }

  .tipo-nav__btn {
    flex: 1;
    padding: 0.5rem 0.4rem;
    font-size: 0.75rem;
    min-height: 44px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.65rem;
  }

  .legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.5rem;
    width: 100%;
  }

  .legend__title {
    grid-column: 1 / -1;
    margin-bottom: 0.15rem;
  }

  .legend__item {
    font-size: 0.72rem;
  }

  .toolbar__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    width: 100%;
  }

  .toolbar__actions .btn {
    min-height: 44px;
    padding: 0.55rem 0.5rem;
    font-size: 0.78rem;
    justify-content: center;
  }

  .toolbar__actions .btn--primary {
    grid-column: 1 / -1;
  }

  .btn__text--long {
    display: none;
  }

  .btn__text--short {
    display: inline;
  }

  #matriz-container.matriz-container {
    min-height: 280px;
    max-height: calc(100dvh - 200px);
    border-radius: 0;
  }

  .matriz {
    font-size: 0.72rem;
  }

  .matriz thead th {
    min-width: 88px;
    max-width: 110px;
    padding: 0.55rem 0.35rem;
    font-size: 0.65rem;
  }

  .matriz thead th.col-nombre,
  .matriz tbody th {
    min-width: 130px;
    max-width: 150px;
    padding-left: 0.65rem;
    padding-right: 0.5rem;
    font-size: 0.72rem;
  }

  .celda {
    min-width: 88px;
    max-width: 110px;
    min-height: 48px;
    padding: 0.4rem;
  }

  .celda__estado {
    font-size: 0.68rem;
  }

  .celda__nota,
  .celda__fecha {
    font-size: 0.62rem;
  }

  .modal {
    width: calc(100vw - 1rem);
    max-width: none;
    max-height: calc(100dvh - 1rem);
    margin: auto;
  }

  .modal--informe[open] {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .modal__header {
    padding: 1rem;
  }

  .modal__body {
    padding: 1rem;
    max-height: calc(100dvh - 180px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal__footer {
    flex-direction: column-reverse;
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .modal__footer .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .modal-confirm__footer {
    flex-direction: column-reverse;
  }

  .modal-confirm__footer .btn {
    width: 100%;
    min-height: 44px;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline .btn {
    width: 100%;
    min-height: 44px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .card-list .item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem;
  }

  .item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
  }

  .item__actions .btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 40px;
  }

  .item__badges {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
  }

  .admin-panels {
    padding: 0.65rem;
  }

  .panel-header h3 {
    font-size: 1rem;
  }

  .topbar--admin .topbar__title-block h2 {
    font-size: 1rem;
  }

  .topbar--admin .topbar__title-block p {
    display: none;
  }

  #toast {
    left: 0.65rem;
    right: 0.65rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    max-width: none;
  }
}

@media (max-width: 380px) {
  .toolbar__actions {
    grid-template-columns: 1fr;
  }

  .tipo-nav__btn .tipo-nav__icon {
    display: none;
  }
}
