/* ═══════════════════════════════════════
   SMARTFACTORY - ESTILOS BASE Y COMMON
   Los design tokens viven en tokens.css
   ═══════════════════════════════════════ */
@import url('tokens.css');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-root);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-weight: var(--weight-medium);
  font-size: var(--text-base);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

input, select, textarea, button {
  font-family: var(--font-sans);
  font-weight: var(--weight-medium);
  font-size: var(--text-base);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

/* ── LAYOUT PRINCIPAL ─────────────────────────────────── */
#sf-app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR LATERAL ──────────────────────────────────── */
#sf-sidebar {
  width: var(--sidebar-w-collapsed);
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  overflow: visible;
  transition: width var(--transition-slow);
}

/* Sidebar expandido */
#sf-sidebar.sidebar-expanded {
  width: var(--sidebar-w-expanded);
  overflow: hidden;
  overflow-y: auto;
}

/* ── SIDEBAR BRAND ─────────────────────────────────────── */
.sidebar-brand {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  flex-shrink: 0;
  min-height: 52px;
  overflow: hidden;
}

/* Collapsed: logo centered + toggle only */
.sidebar-brand__left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

#sf-sidebar:not(.sidebar-expanded) .sidebar-brand__left {
  overflow: visible;
  flex: 1;
  justify-content: center;
}

#sf-sidebar:not(.sidebar-expanded) .brand-logo img {
  width: 36px !important;
  height: 36px !important;
}

.brand-logo {
  font-size: 22px;
  color: var(--primary);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.brand-info {
  display: none;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.sidebar-expanded .brand-info {
  display: block;
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  line-height: 1.2;
  margin-bottom: 4px;
}

.brand-plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

/* Ocultar campana cuando colapsado — aparece solo en expanded */
.notification-bell-container {
  flex-shrink: 0;
}
/* !important para sobrescribir el inline display:flex del elemento */
#sf-sidebar:not(.sidebar-expanded) .notification-bell-container {
  display: none !important;
}
.sidebar-brand__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color var(--transition-base), background var(--transition-base);
}
.sidebar-toggle-btn:hover {
  color: var(--text-1);
  background: var(--bg-subtle);
}

/* ── SIDEBAR NAV ──────────────────────────────────────── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  flex-grow: 1;
  overflow: visible;
}

/* Nav item base */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  color: var(--text-2);
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  border-left: 2px solid transparent;
  transition: all var(--transition-base);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-1);
}

.nav-item.active {
  background-color: var(--primary);
  color: white;
  border-left-color: transparent;
  box-shadow: 0 2px 14px rgba(245, 158, 11, 0.45);
}
.nav-item.active:hover {
  background-color: #d97706;
  color: white;
}
.nav-item.active:hover iconify-icon { color: white; }

/* CONTRAÍDO: solo icono centrado, sin label */
#sf-sidebar:not(.sidebar-expanded) .nav-item {
  justify-content: center;
  padding: 8px 0;
  border-left-color: transparent !important;
  overflow: visible;
}
#sf-sidebar:not(.sidebar-expanded) .nav-item.active {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.45);
}

/* Ocultar TODOS los .nav-label en sidebar colapsado */
#sf-sidebar:not(.sidebar-expanded) .nav-label {
  display: none;
}

/* Excepción: mostrar labels dentro del popup flotante (submenú) */
#sf-sidebar:not(.sidebar-expanded) .nav-section-content .nav-label {
  display: inline;
}

/* .nav-label como flex item cuando está visible */
.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* En sidebar expandido, mostrar labels de nav-items normalmente */
.sidebar-expanded .nav-item .nav-label {
  display: inline;
}

/* Restaurar alineación normal dentro del popup flotante
   (mayor especificidad que #sf-sidebar:not(.sidebar-expanded) .nav-item) */
#sf-sidebar .nav-section-content .nav-item {
  justify-content: flex-start;
  padding: 9px 12px;
  border-left: 2px solid transparent;
  overflow: hidden;
  color: var(--text-1);
}
#sf-sidebar .nav-section-content .nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-1);
}
#sf-sidebar .nav-section-content .nav-item.active {
  background-color: var(--primary);
  color: white;
  border-left-color: transparent;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4);
}

.nav-section-wrapper {
  position: relative;
}

/* ── SECCIONES DEL NAV ────────────────────────────────── */
.nav-section-header {
  padding: 8px 0;
  margin: 1px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  border-left: 2px solid transparent;
  position: relative;
}

.nav-section-header:hover {
  background: var(--bg-subtle);
}
.nav-section-header.active-section:hover {
  background-color: #d97706;
}
.nav-section-header.active-section:hover .section-icon { color: white; }

.nav-section-header:not(.collapsed):not(.active-section) {
  background: var(--primary-glow);
  border-left-color: var(--primary);
}

.nav-section-header.active-section {
  background-color: var(--primary);
  border-left-color: transparent;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.4);
}
.nav-section-header.active-section .section-icon { color: white; }

/* En modo CONTRAÍDO: ocultar texto y chevron */
.nav-section-header span,
.nav-section-header .chevron-indicator {
  display: none;
}

.nav-section-header .section-icon {
  font-size: 18px;
  color: var(--text-3);
  transition: color var(--transition-base);
}
.nav-section-header:not(.collapsed) .section-icon { color: var(--primary); }
.nav-section-header:hover .section-icon { color: var(--primary); }
.nav-section-header.active-section:not(.collapsed) .section-icon { color: white; }

/* En modo EXPANDIDO: mostrar texto y chevron */
.sidebar-expanded .nav-section-header {
  justify-content: space-between;
  padding: 6px 10px;
}
.sidebar-expanded .nav-section-header span { display: block; font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.sidebar-expanded .nav-section-header.active-section span { color: rgba(0,0,0,0.75); }
.sidebar-expanded .nav-section-header:hover span { color: var(--text-2); }
.sidebar-expanded .nav-section-header.active-section:hover span { color: white; }
.sidebar-expanded .nav-section-header .chevron-indicator { display: block; font-size: 14px; color: var(--text-3); transition: transform var(--transition-base); }
.sidebar-expanded .nav-section-header.active-section .chevron-indicator { color: rgba(0,0,0,0.5); }
.sidebar-expanded .nav-section-header:not(.collapsed) .chevron-indicator { transform: rotate(180deg); }

/* ── CONTENIDO DE SECCIÓN ─────────────────────────────── */

/* MODO CONTRAÍDO: flotante a la derecha */
.nav-section-content {
  position: absolute;
  left: calc(var(--sidebar-w-collapsed) + 4px);
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 220px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

/* Franja de escape para que el hover no cierre el popup */
.nav-section-content::after {
  content: '';
  position: absolute;
  left: -10px;
  top: 0;
  bottom: 0;
  width: 10px;
  background: transparent;
}

/* Encabezado del popup con nombre del grupo */
.nav-section-content::before {
  content: attr(data-label);
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--primary);
  text-transform: uppercase;
  font-weight: var(--weight-bold);
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.nav-section-content.collapsed { display: none; }

/* MODO EXPANDIDO: inline accordion */
.sidebar-expanded .nav-section-content {
  position: static;
  box-shadow: none;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 2px 0 4px 4px;
  min-width: unset;
  border-left: 2px solid var(--border);
  margin-left: 12px;
}
.sidebar-expanded .nav-section-content::before,
.sidebar-expanded .nav-section-content::after { display: none; }
.sidebar-expanded .nav-section-content.collapsed { display: none; }

/* ── POWERED BY SMARTECH ──────────────────────────────── */
.sidebar-powered-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  margin: 4px 0 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  text-decoration: none;
  color: var(--primary);
  width: 100%;
  box-sizing: border-box;
  transition: opacity var(--transition-base);
}
.sidebar-powered-link:hover { opacity: 0.75; }
#sf-sidebar:not(.sidebar-expanded) .sidebar-powered-link {
  padding: 5px 6px;
}
.powered-by-text {
  font-size: 9px;
  font-family: var(--font-sans);
  font-weight: var(--weight-bold);
  white-space: nowrap;
  text-align: center;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.powered-by-prefix {
  font-weight: var(--weight-semibold);
  opacity: 0.6;
  text-transform: uppercase;
  font-size: 8px;
}
/* Collapsed: dos líneas, sin uppercase (muy ancho a ese tamaño) */
#sf-sidebar:not(.sidebar-expanded) .powered-by-text {
  font-size: 6px;
  text-transform: none;
  line-height: 1.5;
  letter-spacing: 0;
}
#sf-sidebar:not(.sidebar-expanded) .powered-by-prefix {
  display: block;
  font-size: 6px;
  opacity: 0.5;
}

/* ── USER PROFILE CARD (sidebar) ──────────────────────────── */
.sf-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--text-1);
  transition: background var(--transition-base);
  flex-shrink: 0;
}
.sf-user-card:hover { background: var(--bg-subtle); }

.sf-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.sf-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.sf-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.sf-user-role-label {
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
  white-space: nowrap;
}

/* Collapsed sidebar: show only avatar centered */
#sf-sidebar:not(.sidebar-expanded) .sf-user-card {
  justify-content: center;
  padding: 8px 0;
}
#sf-sidebar:not(.sidebar-expanded) .sf-user-info,
#sf-sidebar:not(.sidebar-expanded) .sf-user-chevron {
  display: none;
}

/* ── USER PROFILE MODAL ───────────────────────────────────── */
#modal-user-profile .up-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
#modal-user-profile .up-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
#modal-user-profile .up-change-photo-btn {
  font-size: 11px;
  padding: 4px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#modal-user-profile .up-change-photo-btn:hover { background: var(--bg-card); }
#modal-user-profile .up-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* Password eye toggle */
.up-pass-wrap {
  position: relative;
}
.up-pass-wrap .form-control {
  padding-right: 38px;
}
.up-pass-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 3px;
  display: flex;
  align-items: center;
  line-height: 1;
}
.up-pass-eye:hover { color: var(--text-1); }

/* Strength bar */
.up-strength-bar {
  display: flex;
  gap: 4px;
  flex: 1;
  margin-right: 8px;
}
.up-strength-seg {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.25s;
}
.up-strength-label {
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1;
  align-self: center;
  min-width: 64px;
  text-align: right;
}

/* Requirements list */
.up-req-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.up-req-list li {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}
.up-req-list li .req-icon { font-size: 12px; flex-shrink: 0; }
.up-req-list li.req-ok  { color: #10b981; }
.up-req-list li.req-fail { color: #ef4444; }

/* ── 2FA SECTION ──────────────────────────────────────────── */
.up-2fa-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.up-2fa-pill--on  { background: #10b98122; border: 1px solid #10b98155; color: #10b981; }
.up-2fa-pill--off { background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text-3); }

.up-2fa-info {
  font-size: 12px;
  color: var(--text-2);
  margin: 0 0 10px;
  line-height: 1.5;
}
.up-2fa-info--warn { color: #f59e0b; }

.up-2fa-action-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  font-size: 12px;
}

.up-2fa-loading {
  display: flex;
  justify-content: center;
  padding: 14px 0;
}
@keyframes up-spin { to { transform: rotate(360deg); } }
.up-2fa-spin { animation: up-spin 0.9s linear infinite; display: inline-block; }

.up-2fa-steps {
  font-size: 12px;
  color: var(--text-2);
  padding-left: 18px;
  margin: 0 0 12px;
  line-height: 1.7;
}

.up-2fa-qr-wrap {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 4px;
}
.up-2fa-qr {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  object-fit: contain;
  background: #fff;
  padding: 4px;
}
.up-2fa-qr--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

.up-2fa-secret-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.up-2fa-secret-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.up-2fa-secret {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 8px;
  word-break: break-all;
  letter-spacing: 0.08em;
}
.up-2fa-copy-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-2);
}
.up-2fa-copy-btn:hover { background: var(--bg-card); color: var(--text-1); }

.up-2fa-code-input {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
}

/* Sidebar stats and badges */
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: rgba(0, 0, 0, 0.15);
}

.sidebar-save-status {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  margin-bottom: 4px;
}

.sidebar-stat-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.sidebar-stat-badge span:first-child {
  color: var(--text-2);
}

.sidebar-stat-badge span:last-child {
  font-family: 'JetBrains Mono', monospace;
}

.sidebar-stat-badge.badge-yellow span:last-child { color: var(--yellow); }
.sidebar-stat-badge.badge-green span:last-child { color: var(--green); }
.sidebar-stat-badge.badge-grey span:last-child { color: var(--text-2); }

/* ── MAIN CONTENT AREA ────────────────────────────────── */
#sf-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-root);
}

/* ── PAGE HEADER ──────────────────────────────────────── */
.page-header {
  height: 56px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  gap: 12px;
}

.page-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.page-title-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.page-title {
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
  letter-spacing: -0.01em;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-subtitle {
  font-family: var(--font-sans);
  font-weight: var(--weight-normal);
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.page-icon {
  font-size: 18px;
  color: var(--yellow);
  display: inline-flex;
  align-items: center;
}
.page-icon iconify-icon {
  font-size: 20px;
}
.nav-item iconify-icon {
  font-size: 20px;
  color: var(--text-2);
  transition: color 0.15s, transform 0.15s;
}
.nav-item:hover iconify-icon {
  color: var(--text-1);
}
.nav-item.active iconify-icon,
.nav-item.active:hover iconify-icon,
#sf-sidebar .nav-section-content .nav-item.active iconify-icon,
#sf-sidebar .nav-section-content .nav-item.active:hover iconify-icon {
  color: white;
}

/* ── GENERAL PAGE CONTAINER ───────────────────────────── */
.page-body {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  position: relative;
}

/* ── BUTTON STYLES ────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost,
.btn-row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: 7px 14px;
  transition: all var(--transition-base);
  white-space: nowrap;
  line-height: 1;
}
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--slate-900);
  border: 1px solid var(--primary-dim);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dim);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-1);
  border-color: var(--border-strong);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-1);
}

.btn-danger {
  background-color: var(--danger-muted);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover:not(:disabled) {
  background-color: var(--danger);
  color: white;
}

/* Tamaños */
.btn-sm { padding: 4px 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 10px 20px; font-size: var(--text-base); }

/* Botones de fila en tablas */
.btn-row-action {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: var(--text-xs);
}
.btn-row-action:hover {
  border-color: var(--primary);
  color: var(--text-1);
  background-color: var(--primary-muted);
}

.btn-row-danger {
  color: var(--danger);
  border-color: transparent;
}
.btn-row-danger:hover {
  background-color: var(--danger-muted);
  border-color: var(--danger);
  color: var(--danger);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.spin { display: inline-block; animation: spin 0.8s linear infinite; }

/* ── FORMS AND INPUTS ─────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.form-group label,
.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-2);
  display: block;
  margin-bottom: 4px;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: 4px;
}

.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: 4px;
}

.form-section-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  padding: 8px 12px;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  width: 100%;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
  color: var(--text-3);
}

.form-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

/* ── TOASTS ───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-1);
  min-width: 300px;
  max-width: 380px;
  animation: toastIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
}

.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: var(--weight-semibold); color: var(--text-1); margin-bottom: 2px; }
.toast-msg   { font-size: var(--text-xs); color: var(--text-2); }

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info    { border-left-color: var(--info); }

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
.toast-close:hover { color: var(--text-1); }

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

/* ── MODALS ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(2px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  animation: modalScale 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  box-shadow: var(--shadow-xl);
}

/* Tamaños de modal */
.modal-sm  { max-width: 400px; }
.modal-md  { max-width: 560px; }
.modal-lg  { max-width: 760px; }
.modal-xl  { max-width: 960px; }

@keyframes modalScale {
  from { transform: scale(0.9); }
  to   { transform: scale(1); }
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.modal-close-btn,
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  line-height: 1;
}

.modal-close-btn:hover,
.modal-close:hover {
  color: var(--text-1);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background-color: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Modal success/celebration custom styling */
.success-check-icon {
  font-size: 42px;
  color: var(--green);
  text-align: center;
  margin: 10px 0;
  animation: bounce 0.5s ease-out;
}

.modal-accent-title {
  text-align: center;
  font-family: var(--font-sans);
  font-weight: var(--weight-bold);
  color: var(--text-1);
  font-size: var(--text-lg);
  margin-bottom: 16px;
}

/* Color picker component */
.color-picker-grid {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.color-dot-opt {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.1s;
  position: relative;
}

.color-dot-opt.selected {
  border-color: var(--text-1);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}

/* ── ANIMATIONS ───────────────────────────────────────── */
@keyframes pulse-glow {
  0% { text-shadow: 0 0 2px rgba(245, 197, 24, 0.2); }
  100% { text-shadow: 0 0 10px rgba(245, 197, 24, 0.7); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--yellow-dim); }
  50% { border-color: var(--yellow); box-shadow: 0 0 6px var(--yellow-glow); }
}

/* ── BADGES ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-draft     { background: var(--bg-subtle);       color: var(--text-2); }
.badge-pending   { background: var(--warning-muted);   color: var(--warning-text); }
.badge-active    { background: var(--info-muted);      color: var(--info-text); }
.badge-done      { background: var(--success-muted);   color: var(--success-text); }
.badge-blocked   { background: var(--danger-muted);    color: var(--danger-text); }
.badge-cancelled { background: var(--bg-subtle);       color: var(--text-3); }
.badge-review    { background: rgba(147,51,234,0.10);  color: #6B21A8; }
.badge-yellow    { background: var(--primary-muted);   color: var(--primary-text); }
.badge-green     { background: var(--success-muted);   color: var(--success-text); }
.badge-red       { background: var(--danger-muted);    color: var(--danger-text); }
.badge-blue      { background: var(--info-muted);      color: var(--info-text); }
.badge-grey      { background: var(--bg-subtle);       color: var(--text-2); }

/* ── CARDS ────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-1);
}
.card-body   { padding: var(--space-5); }
.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

/* Variante stat (KPI) */
.card-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card-stat__val  { font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--text-1); font-family: var(--font-mono); }
.card-stat__lbl  { font-size: var(--text-xs); color: var(--text-3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.card-stat__sub  { font-size: var(--text-xs); color: var(--text-2); margin-top: 2px; }

/* Variante alerta */
.card-alert {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
}
.card-alert--danger  { border-left-color: var(--danger); }
.card-alert--success { border-left-color: var(--success); }
.card-alert--info    { border-left-color: var(--info); }

/* ── TABLES ───────────────────────────────────────────── */
.table-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
thead th {
  background: var(--bg-subtle);
  color: var(--text-2);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }
tbody td {
  padding: 11px 16px;
  color: var(--text-1);
  font-size: var(--text-sm);
}
.table-compact tbody td { padding: 7px 16px; }

/* Row actions (visibles en hover) */
.table-row-actions {
  opacity: 0;
  transition: opacity var(--transition-base);
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
tbody tr:hover .table-row-actions { opacity: 1; }

/* Filas de alerta */
tbody tr.row-warning { background: var(--warning-muted); }
tbody tr.row-danger  { background: var(--danger-muted); }

/* ── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
}
.empty-state__icon {
  font-size: 48px;
  color: var(--slate-300);
  margin-bottom: var(--space-4);
  display: block;
}
.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-2);
  margin-bottom: var(--space-2);
}
.empty-state__desc {
  font-size: var(--text-sm);
  color: var(--text-3);
  max-width: 320px;
  line-height: var(--leading-loose);
  margin-bottom: var(--space-5);
}

/* ── SKELETON LOADER ──────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-subtle) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-subtle) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-row  { height: 44px; margin-bottom: 1px; }
.skeleton-text { height: 12px; }

/* ── DRAWER (panel lateral deslizante) ────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}
.drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 95vw;
  height: 100vh;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 901;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
}
.drawer.active { transform: translateX(0); }
.drawer-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.drawer-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-1);
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

/* ── BREADCRUMB ───────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-bottom: var(--space-3);
}
.breadcrumb a { color: var(--text-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-2); }
.breadcrumb-sep     { color: var(--border-strong); }
.breadcrumb-current { color: var(--text-2); font-weight: var(--weight-medium); }

/* ── BULK ACTIONS BAR ─────────────────────────────────── */
.bulk-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--slate-800);
  color: white;
  padding: 10px 16px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 50;
  border-top: 1px solid var(--slate-700);
  font-size: var(--text-sm);
}
.bulk-bar.visible { display: flex; }
.bulk-bar__count { font-weight: var(--weight-semibold); flex: 1; }

/* ── COMMAND PALETTE (Ctrl+K) ─────────────────────────── */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  backdrop-filter: blur(2px);
}
.cmd-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.cmd-palette {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 560px;
  max-width: 95vw;
  overflow: hidden;
  transform: translateY(-12px) scale(0.98);
  transition: transform var(--transition-base);
}
.cmd-overlay.active .cmd-palette {
  transform: translateY(0) scale(1);
}
.cmd-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cmd-search-bar iconify-icon {
  color: var(--text-3);
  font-size: 18px;
  flex-shrink: 0;
}
.cmd-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text-1);
}
.cmd-search-input::placeholder { color: var(--text-3); }
.cmd-kbd {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  flex-shrink: 0;
  cursor: pointer;
}
.cmd-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}
.cmd-group-label {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 8px 10px 4px;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.cmd-item:hover,
.cmd-item.selected {
  background: var(--bg-subtle);
}
.cmd-item__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  color: var(--text-2);
}
.cmd-item__text { flex: 1; min-width: 0; }
.cmd-item__name { font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--text-1); }
.cmd-item__desc { font-size: var(--text-xs); color: var(--text-3); margin-top: 1px; }
.cmd-item__badge {
  font-size: 10px;
  color: var(--text-3);
  flex-shrink: 0;
}
.cmd-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-3);
}
.cmd-footer span { display: flex; align-items: center; gap: 4px; }

/* ── SAVE FEEDBACK (botón guardado) ───────────────────── */
.btn-saved {
  background: var(--success) !important;
  color: white !important;
  border-color: var(--success) !important;
  pointer-events: none;
}

/* ── INLINE CONFIRMATION (R10) ────────────────────────── */
.inline-confirm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--danger-muted);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--danger-text);
  animation: slideInRight 150ms ease;
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.inline-confirm__yes {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  font-family: var(--font-sans);
}
.inline-confirm__yes:hover { background: var(--danger-dim); }
.inline-confirm__no {
  background: transparent;
  color: var(--text-2);
  border: none;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: var(--text-xs);
  cursor: pointer;
  font-family: var(--font-sans);
}
.inline-confirm__no:hover { color: var(--text-1); background: var(--bg-subtle); }

/* ── SIDEBAR NAV BADGE (R4) ────────────────────────────── */
.nav-item .nav-badge {
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: var(--radius-full);
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  margin-left: auto;
  line-height: 1;
}
/* Collapsed: position badge over icon */
#sf-sidebar:not(.sidebar-expanded) .nav-item .nav-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  margin-left: 0;
}
#sf-sidebar:not(.sidebar-expanded) .nav-item {
  position: relative;
}

/* ── SCROLLBAR FINO ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Móvil / Tablet (Fase 0 · planmovil.md)
   Escritorio (≥769px) queda intacto. ≤768px: sidebar → drawer con ☰.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Ocultos en escritorio; el media query los muestra. */
.sf-hamburger { display: none; }
#sf-drawer-backdrop { display: none; }

@media (max-width: 768px) {
  /* Permitir scroll de página (en escritorio body es 100vh/overflow:hidden). */
  body { height: auto; min-height: 100dvh; overflow-y: auto; overflow-x: hidden; display: block; }
  /* Layout a una columna, con scroll vertical natural y altura dvh (iOS). */
  #sf-app { width: 100%; height: auto; min-height: 100dvh; overflow: visible; display: block; }

  /* ── Sidebar → drawer off-canvas ── */
  #sf-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    height: 100dvh; width: var(--sidebar-w-expanded) !important;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 1200; overflow-y: auto;
    padding-left: env(safe-area-inset-left, 0);
  }
  #sf-sidebar.drawer-open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  /* En el drawer siempre se ven los labels (look expandido). */
  #sf-sidebar .nav-label { display: flex !important; }
  #sf-sidebar .brand-info { display: block !important; }
  #sf-sidebar .nav-section-header span,
  #sf-sidebar .nav-section-header .chevron-indicator {
    display: block !important;
  }
  #sf-sidebar .nav-item {
    justify-content: flex-start !important;
    padding: 10px 10px !important;
  }
  #sf-sidebar .nav-section-header {
    justify-content: space-between !important;
    padding: 6px 10px !important;
  }
  #sf-sidebar .nav-section-content {
    position: static !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 2px 0 4px 4px !important;
    min-width: unset !important;
    border-left: 2px solid var(--border) !important;
    margin-left: 12px !important;
  }
  #sf-sidebar .nav-section-content::before,
  #sf-sidebar .nav-section-content::after {
    display: none !important;
  }

  /* ── Backdrop ── */
  #sf-drawer-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 1100; opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  #sf-drawer-backdrop.show { opacity: 1; pointer-events: auto; }

  /* ── Main a ancho completo ── */
  #sf-main { width: 100%; height: auto; min-height: 100dvh; overflow: visible; }

  /* ── Header de página: ☰ + envolver acciones ── */
  .sf-hamburger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; min-width: 42px;
    border: none; background: transparent; color: var(--text-1);
    cursor: pointer; border-radius: var(--radius-md); flex-shrink: 0; font-size: 20px;
  }
  .page-header {
    flex-wrap: wrap; height: auto; min-height: 52px;
    padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top, 0));
    position: sticky; top: 0; z-index: 50;
  }
  .page-title { font-size: 16px; }
  .page-body {
    padding: 14px 12px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0));
  }

  /* ── Touch / formularios ── */
  .nav-item, .tab-link, .sf-hamburger { min-height: 44px; }
  /* 16px evita el zoom automático de iOS al enfocar inputs */
  input, select, textarea, .form-control { font-size: 16px; }
}

/* Teléfono pequeño: ajustes finos */
@media (max-width: 480px) {
  .page-header .page-actions { gap: 6px; width: 100%; }
  #sf-sidebar { width: 86vw !important; max-width: 320px; }
}

/* ═══ Fase 1 planmovil — Modales como bottom-sheet en móvil/tablet ═══ */
@media (max-width: 768px) {
  .modal-overlay { align-items: flex-end; }
  .modal-container, .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    animation: sheetUp .22s ease forwards;
  }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px 16px 12px; }
  .modal-footer {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0));
    position: sticky; bottom: 0;
  }
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ═══ Fase 3 planmovil — Grids de formulario a una columna en móvil ═══
   Sobrescribe los grid-template-columns inline (1fr 1fr, auto 1fr, etc.). */
@media (max-width: 768px) {
  .form-row-grid { grid-template-columns: 1fr !important; }
}
