/* ==========================================================================
   PezControl — app.css (Estilos de componentes y layout)
   ========================================================================== */

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

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-family);
  font-size: var(--font-body);
  line-height: 1.4;
  color: var(--text-primary);
  background-color: var(--bg-app);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   App Shell Layout
   ========================================================================== */

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  background-color: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  padding: 0 var(--space-lg);
  color: var(--sidebar-text);
  z-index: var(--z-topbar);
  flex-shrink: 0;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-title);
  font-weight: var(--font-weight-bold);
  color: var(--text-inverse);
  text-decoration: none;
  cursor: pointer;
}

.brand-icon {
  width: 26px;
  height: 26px;
  background: var(--color-brand);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 15px;
}

.brand-name {
  letter-spacing: -0.2px;
}

.brand-name span {
  color: var(--color-brand);
}

.selector-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 3px var(--space-sm);
}

.selector-group label {
  font-size: var(--font-meta);
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.5px;
}

.topbar-select {
  background: transparent;
  color: var(--sidebar-text);
  border: none;
  font-size: var(--font-label);
  font-weight: var(--font-weight-medium);
  outline: none;
  cursor: pointer;
  max-width: 180px;
}

.topbar-select option {
  background: var(--color-slate-800);
  color: var(--sidebar-text);
}

.btn-icon-topbar {
  background: transparent;
  border: none;
  color: var(--sidebar-text-muted);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-topbar:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-inverse);
}

.btn-icon-topbar:focus-visible {
  outline: 2px solid var(--color-brand);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 4px var(--space-sm);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-round);
  background: var(--color-brand);
  color: #fff;
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-email {
  font-size: var(--font-label);
  color: var(--sidebar-text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-tag {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(243, 115, 41, 0.2);
  color: var(--color-brand-softer);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
}

/* ── Main Layout Body ── */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Sidebar ── */
.sidebar {
  width: 210px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--topbar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
}

.sidebar-nav {
  padding: var(--space-md) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--sidebar-text-muted);
  text-decoration: none;
  font-size: var(--font-label);
  font-weight: var(--font-weight-medium);
  transition: all 0.15s ease;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.nav-item.active {
  background: rgba(243, 115, 41, 0.12);
  color: #FFFFFF;
  border-left-color: var(--color-brand);
  font-weight: var(--font-weight-semibold);
}

.nav-item-content {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.nav-badge-soon {
  font-size: 9px;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text-muted);
  border-radius: var(--radius-sm);
  letter-spacing: 0.2px;
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--font-meta);
  color: var(--sidebar-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Workspace / Content Area ── */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-app);
  position: relative;
}

.content-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ==========================================================================
   Botones y Controles
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  font-family: inherit;
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 1px;
}

.btn-primary {
  background-color: var(--color-brand);
  color: var(--text-inverse);
  border-color: var(--color-brand);
}

.btn-primary:hover {
  background-color: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
}

.btn-primary:disabled {
  background-color: var(--border-color);
  border-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--color-brand-soft);
  border-color: var(--color-brand);
  color: var(--color-brand-hover);
}

.btn-secondary:disabled {
  background-color: var(--bg-surface-subtle);
  color: var(--text-faint);
  cursor: not-allowed;
}

.btn-danger {
  background-color: var(--color-error);
  color: var(--text-inverse);
  border-color: var(--color-error);
}

.btn-danger:hover {
  background-color: var(--color-error-dark);
}

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

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--color-brand);
}

.btn-sm {
  padding: 2px var(--space-sm);
  font-size: var(--font-meta);
  min-height: 24px;
}

.btn-group {
  display: inline-flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.btn-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border-color);
}

.btn-group .btn:last-child {
  border-right: none;
}

/* ==========================================================================
   Inputs y Formularios
   ========================================================================== */

.input-text, .input-select, .input-textarea {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  font-family: inherit;
  font-size: var(--font-body);
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-text:focus, .input-select:focus, .input-textarea:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px rgba(243, 115, 41, 0.2);
}

.input-text:disabled, .input-select:disabled, .input-textarea:disabled {
  background-color: var(--bg-surface-alt);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-group label {
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
}

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

.form-helper {
  font-size: var(--font-meta);
  color: var(--text-muted);
}

/* ==========================================================================
   Cards y KPI Summary (Presupuesto)
   ========================================================================== */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.kpi-summary-card {
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-md);
}

.kpi-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--border-subtle);
  padding-right: var(--space-sm);
}

.kpi-item:last-child {
  border-right: none;
}

.kpi-label {
  font-size: var(--font-label);
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.2px;
}

.kpi-value {
  font-size: var(--font-title);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-item.kpi-highlight .kpi-value {
  color: var(--color-brand);
  font-size: 16px;
}

/* ==========================================================================
   Toolbar de Presupuesto
   ========================================================================== */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 220px;
}

.search-input {
  padding-left: 28px;
  height: 30px;
  font-size: var(--font-label);
}

.search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 12px;
}

/* ==========================================================================
   Tabla en Árbol (Presupuesto)
   ========================================================================== */

.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  max-height: calc(100vh - 230px);
}

.tree-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-label);
  text-align: left;
}

.tree-table th {
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-weight: var(--font-weight-semibold);
  padding: var(--space-sm) var(--space-sm6);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  user-select: none;
}

.tree-table td {
  padding: 5px var(--space-sm6);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-primary);
}

.tree-table tr:hover {
  background-color: var(--bg-hover);
}

.tree-table tr.selected {
  background-color: var(--bg-selected) !important;
}

/* Filas Título */
.row-titulo {
  font-weight: var(--font-weight-bold);
}

.row-titulo td {
  border-top: 1px solid var(--border-subtle);
}

.tree-item-cell {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.toggle-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 2px;
  transition: transform 0.15s ease;
  font-size: 10px;
}

.toggle-icon.collapsed {
  transform: rotate(-90deg);
}

.item-code {
  font-family: var(--font-mono);
  font-weight: var(--font-weight-semibold);
  font-size: 11px;
}

/* Colores de nivel en títulos */
.nivel-1 { color: var(--nivel-1-fg); background-color: var(--nivel-1-bg); }
.nivel-2 { color: var(--nivel-2-fg); background-color: var(--nivel-2-bg); }
.nivel-3 { color: var(--nivel-3-fg); }
.nivel-4 { color: var(--nivel-4-fg); }
.nivel-5 { color: var(--nivel-5-fg); }
.nivel-6 { color: var(--nivel-6-fg); }
.nivel-7 { color: var(--nivel-7-fg); }
.nivel-8 { color: var(--nivel-8-fg); }
.nivel-9 { color: var(--nivel-9-fg); }

/* Edición Inline */
.editable-cell {
  cursor: pointer;
  min-height: 20px;
  border-radius: var(--radius-sm, 3px);
  padding: 1px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  transition: background 0.15s ease, outline 0.15s ease;
}

.editable-cell:hover {
  outline: 1px dashed var(--color-brand);
  background: rgba(243, 115, 41, 0.08);
}

.editable-cell .edit-hint {
  opacity: 0;
  font-size: 10px;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.editable-cell:hover .edit-hint {
  opacity: 0.75;
}

.inline-edit-input {
  width: 100%;
  max-width: 110px;
  padding: 2px 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--color-brand);
  border-radius: var(--radius-sm, 3px);
  outline: none;
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px rgba(243, 115, 41, 0.25);
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0.3;
  transition: opacity 0.15s ease;
}

.tree-table tr:hover .row-actions {
  opacity: 1;
}

/* ==========================================================================
   Panel Lateral Deslizante (Side Drawer / ACU & Metrados)
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: var(--z-drawer-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.side-drawer {
  position: fixed;
  top: 48px;
  right: 0;
  bottom: 0;
  width: 580px;
  max-width: 90vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-drawer);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.side-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
}

.drawer-title-box h3 {
  font-size: var(--font-subt);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.drawer-title-box p {
  font-size: var(--font-meta);
  color: var(--text-muted);
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  padding: 0 var(--space-md);
}

.drawer-tab {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all 0.15s ease;
}

.drawer-tab:hover {
  color: var(--color-brand);
}

.drawer-tab.active {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.drawer-footer {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Badges de tipo de recurso */
.badge-tipo {
  font-size: 9px;
  font-weight: var(--font-weight-bold);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.badge-mo { background: var(--badge-mo-bg); color: var(--badge-mo-fg); }
.badge-mat { background: var(--badge-mat-bg); color: var(--badge-mat-fg); }
.badge-eq { background: var(--badge-eq-bg); color: var(--badge-eq-fg); }
.badge-sc { background: var(--badge-sc-bg); color: var(--badge-sc-fg); }

.badge-modelo {
  background: rgba(37, 99, 235, 0.15);
  color: var(--color-info-light);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-semibold);
}

/* ==========================================================================
   Modales y Diálogos
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-md);
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-lg {
  max-width: 850px;
  width: 90vw;
}

.modal-card.modal-xl {
  max-width: 1150px;
  width: 94vw;
}

.modal-card.modal-full {
  max-width: 96vw;
  width: 96vw;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: var(--font-title);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
}

.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ==========================================================================
   Toasts (Notificaciones flotantes)
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--color-slate-900);
  color: #FFFFFF;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-label);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 240px;
  max-width: 400px;
  pointer-events: auto;
  animation: toastIn 0.2s ease;
  border-left: 4px solid var(--color-brand);
}

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

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Pantalla de Autenticación (Login / Registro / Verificación)
   ========================================================================== */

.auth-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, var(--color-slate-800), var(--color-slate-900));
  padding: var(--space-md);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xxxl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  text-align: center;
}

.auth-tabs {
  display: flex;
  background: var(--bg-surface-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 6px;
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.15s ease;
}

.auth-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.auth-code-inputs {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  margin: var(--space-md) 0;
}

.auth-code-digit {
  width: 44px;
  height: 52px;
  font-size: 24px;
  font-weight: var(--font-weight-bold);
  text-align: center;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
}

.auth-code-digit:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px rgba(243, 115, 41, 0.2);
}

/* ==========================================================================
   Estados Vacíos y Placeholders
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-page);
  text-align: center;
  gap: var(--space-md);
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  color: var(--color-brand);
  opacity: 0.8;

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  font-size: 42px;
  margin-bottom: var(--space-md);
  color: var(--color-brand);
}

.empty-state h3 {
  font-size: var(--font-title);
  color: var(--text-primary);
}

.empty-state p {
  font-size: var(--font-label);
  color: var(--text-muted);
  max-width: 380px;
}

/* Responsive */
@media (max-width: 768px) {
  .topbar {
    padding: 0 var(--space-sm);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: var(--space-xs);
  }
  .topbar::-webkit-scrollbar {
    display: none;
  }
  .topbar-left, .topbar-right {
    gap: var(--space-xs);
    flex-shrink: 0;
  }
  .selector-group {
    padding: 2px var(--space-xs);
  }
  .selector-group label {
    font-size: 10px;
  }
  .topbar-select {
    max-width: 105px;
    font-size: 11px;
  }
  .user-badge {
    padding: 2px 4px;
    gap: 0;
  }
  .user-email,
  .role-tag {
    display: none;
  }
  .sidebar {
    width: 48px;
  }
  .nav-item {
    padding: var(--space-sm) 4px;
    justify-content: center;
  }
  .nav-item-content {
    justify-content: center;
  }
  .sidebar .nav-item-text, .sidebar .nav-badge-soon, .sidebar-footer {
    display: none;
  }
  .side-drawer {
    width: 100vw;
  }
  .kpi-summary-card {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Vistas Almacén y Compras (Pestañas modulares, Cabeceras y Tablas)
   ========================================================================== */

.view-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-xs);

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-page);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  gap: var(--space-md);
  flex-wrap: wrap;
}

.view-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.view-header-title h2 {
  font-size: var(--font-h1);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.3px;

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  margin: 0;
  font-size: var(--font-h1);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.view-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.module-tabs {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 4px;
  overflow-x: auto;
  box-shadow: var(--shadow-xs);

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  display: flex;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 var(--space-page);
  gap: var(--space-xs);
  overflow-x: auto;
}

.module-tab {
  padding: var(--space-sm) var(--space-lg);
  font-family: inherit;
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm6);
  padding: var(--space-md10) var(--space-lg);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--font-body);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease-in-out;
  white-space: nowrap;
}

.module-tab:hover {
  color: var(--color-brand);
  background: var(--color-brand-soft);

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  color: var(--color-brand);
  background-color: var(--bg-hover);
}

.module-tab.active {
  background: var(--color-brand);
  color: #FFFFFF;
  border-color: var(--color-brand);
  box-shadow: var(--shadow-xs);

  /* fusionado desde avance-reportes.css (estilo final vigente) */
  color: var(--color-brand);
  font-weight: var(--font-weight-semibold);
  border-bottom-color: var(--color-brand);
  background-color: var(--bg-surface);
}

[data-theme="dark"] .module-tab.active {
  background: var(--color-brand);
  color: #FFFFFF;
}

.row-bajo-minimo {
  background-color: rgba(239, 68, 68, 0.08) !important;
}

.text-error {
  color: var(--color-error) !important;
}

.kardex-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  font-size: var(--font-label);
  color: var(--text-secondary);
}

/* ==========================================================================
   Vista Cronograma y Diagrama de Gantt SVG (Split View + Drawer)
   ========================================================================== */

.cronograma-toolbar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-xs);
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.toolbar-label {
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
}

/* Chips de Calendario Laboral */
.calendar-chips-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.calendar-chips {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-surface-subtle);
  padding: 2px 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.cal-chip {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-tiny);
  font-weight: var(--font-weight-bold);
  user-select: none;
  transition: all 0.15s ease;
}

.cal-chip.work-day {
  background: #EAF5E1;
  color: #2E7D32;
  border: 1px solid rgba(46, 125, 50, 0.3);
}

.cal-chip.rest-day {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid transparent;
  opacity: 0.6;
}

[data-theme="dark"] .cal-chip.work-day {
  background: rgba(46, 125, 50, 0.25);
  color: #86EFAC;
  border-color: rgba(46, 125, 50, 0.4);
}

[data-theme="dark"] .cal-chip.rest-day {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-faint);
}

.btn-link-action {
  background: transparent;
  border: none;
  color: var(--color-brand);
  font-size: var(--font-label);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.btn-link-action:hover {
  text-decoration: underline;
  background: var(--color-brand-soft);
}

/* Buscador de Actividades */
.input-text-search {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-label);
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  min-width: 180px;
}

.input-text-search:focus {
  border-color: var(--color-brand);
}

/* Toggles */
.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-label);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-control input[type="checkbox"] {
  accent-color: var(--color-brand);
  cursor: pointer;
}

/* Botones de Zoom */
.zoom-btn-group {
  display: inline-flex;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}

.zoom-btn {
  padding: 3px 10px;
  font-size: var(--font-label);
  font-family: inherit;
  font-weight: var(--font-weight-medium);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.zoom-btn:hover {
  color: var(--color-brand);
}

.zoom-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: var(--font-weight-bold);
  box-shadow: var(--shadow-xs);
}

/* Split View Principal */
.cronograma-split-container {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  height: calc(100vh - 285px);
  min-height: 480px;
  overflow: hidden;
  position: relative;
}

/* Panel Izquierdo: Tabla WBS */
.cronograma-table-panel {
  width: 620px;
  min-width: 500px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  z-index: 2;
}

.cronograma-table-header {
  height: 50px;
  background: var(--bg-surface-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.cronograma-table-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.cronograma-table-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--font-label);
  color: var(--text-primary);
  transition: background 0.12s ease;
  user-select: none;
}

.cronograma-table-row:nth-child(even) {
  background: var(--bg-surface-alt);
}

.cronograma-table-row:hover {
  background: var(--bg-hover);
}

.cronograma-table-row.selected {
  background: var(--bg-selected) !important;
}

/* Columnas de Tabla */
.th-cell, .td-cell {
  padding: 0 var(--space-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
}

.th-wbs { width: 62px; flex-shrink: 0; font-weight: 600; }
.th-nombre { flex: 1; min-width: 140px; font-weight: 500; }
.th-dur { width: 44px; flex-shrink: 0; }
.th-minimo { width: 78px; flex-shrink: 0; font-size: var(--font-tiny); }
.th-plan { width: 78px; flex-shrink: 0; font-size: var(--font-tiny); }
.th-holgura { width: 60px; flex-shrink: 0; }
.th-avance { width: 72px; flex-shrink: 0; }
.th-costo { width: 85px; flex-shrink: 0; }
.th-estado { width: 60px; flex-shrink: 0; }
.th-acciones { width: 55px; flex-shrink: 0; text-align: right; }

.act-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.cell-editable {
  cursor: text;
}

.cell-editable:hover {
  outline: 1px dashed var(--color-brand);
  outline-offset: -2px;
}

.input-inline-table {
  width: 100%;
  padding: 2px 4px;
  font-size: var(--font-label);
  font-family: inherit;
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
}

/* Panel Derecho: Diagrama Gantt SVG */
.cronograma-gantt-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  position: relative;
}

.cronograma-gantt-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
}

.cronograma-svg {
  display: block;
}

/* Badges y Tags */
.badge-critica {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--font-tiny);
  font-weight: var(--font-weight-bold);
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid rgba(198, 38, 46, 0.3);
}

.badge-critica-sm {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  background: var(--color-error-bg);
  color: var(--color-error);
}

.badge-holgura-sm {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-hito, .badge-tag-hito {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  background: #EFE6FB;
  color: #7A36B1;
}

.badge-tag-critica {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  background: var(--color-error-bg);
  color: var(--color-error);
}

.badge-tag-normal {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--font-weight-normal);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
}

.mini-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 2px;
}

.mini-progress-fill {
  height: 100%;
  background: var(--color-brand);
  border-radius: 2px;
}

.btn-icon-cell {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.btn-icon-cell:hover {
  opacity: 1;
  background: var(--bg-hover);
}

/* Tooltip Flotante del Gantt */
.gantt-tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  pointer-events: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-label);
  max-width: 320px;
  color: var(--text-primary);
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.tooltip-wbs {
  font-weight: bold;
  color: var(--color-brand);
  font-size: var(--font-tiny);
}

.tooltip-title {
  font-weight: 600;
  font-size: var(--font-label);
  margin-bottom: 8px;
  line-height: 1.3;
}

.tooltip-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  font-size: var(--font-tiny);
}

.tooltip-label {
  color: var(--text-muted);
}

.tooltip-val {
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
}

/* Drawer Lateral de Cronograma */
.cronograma-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  z-index: var(--z-wide-drawer-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.cronograma-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.cronograma-drawer {
  position: fixed;
  top: 0;
  right: -460px;
  width: 440px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-drawer);
  z-index: var(--z-wide-drawer);
  display: flex;
  flex-direction: column;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.cronograma-drawer.open {
  right: 0;
}

.drawer-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  background: var(--bg-surface-alt);
}

.drawer-title-box {
  flex: 1;
}

.badge-wbs {
  font-size: var(--font-tiny);
  font-weight: bold;
  color: var(--color-brand);
  background: var(--color-brand-soft);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.drawer-act-name {
  font-size: var(--font-title);
  font-weight: bold;
  color: var(--text-primary);
  margin-top: 4px;
  line-height: 1.3;
}

.drawer-kpis-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.drawer-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.drawer-kpi .label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.drawer-kpi .val {
  font-size: var(--font-label);
  font-weight: bold;
  color: var(--text-primary);
  margin-top: 2px;
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface-subtle);
  padding: 0 var(--space-md);
  gap: 4px;
}

.drawer-tab {
  padding: var(--space-sm) var(--space-md);
  font-family: inherit;
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.drawer-tab:hover {
  color: var(--color-brand);
}

.drawer-tab.active {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
  background: var(--bg-surface);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.drawer-section h4 {
  font-size: var(--font-subt);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.dep-list, .partidas-vinculadas-list, .elementos-bim-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dep-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.dep-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.dep-wbs {
  font-size: var(--font-tiny);
  font-weight: bold;
  color: var(--color-brand);
}

.dep-name {
  font-size: var(--font-label);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dep-tag {
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.add-dep-card {
  padding: var(--space-md);
  background: var(--bg-surface-alt);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  margin-top: var(--space-md);
}

.costo-summary-box {
  padding: var(--space-md);
  background: var(--color-brand-soft);
  border: 1px solid var(--color-brand-300);
  border-radius: var(--radius-lg);
}

/* ==========================================================================
   Cronograma Responsive y Conmutador de Modos (Móvil / Tablet / Desktop)
   ========================================================================== */

.cronograma-view-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 6px 12px;
  margin-bottom: var(--space-sm);
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}

.cronograma-mode-segmented {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.cronograma-view-mode-btn {
  padding: 5px 12px;
  font-size: var(--font-label);
  font-weight: var(--font-weight-medium);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.cronograma-view-mode-btn:hover {
  color: var(--color-brand);
}

.cronograma-view-mode-btn.active {
  background: var(--bg-surface);
  color: var(--color-brand);
  font-weight: var(--font-weight-bold);
  box-shadow: var(--shadow-xs);
}

.cronograma-nav-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cronograma-table-scroll-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

@media (max-width: 1024px) {
  .cronograma-split-container {
    height: calc(100vh - 290px);
    min-height: 480px;
  }
}

@media (max-width: 768px) {
  .cronograma-desktop-only {
    display: none !important;
  }
  .cronograma-view-mode-bar {
    padding: 6px 8px;
    gap: 6px;
  }
  .cronograma-mode-segmented {
    width: 100%;
    display: flex;
  }
  .cronograma-view-mode-btn {
    flex: 1;
    justify-content: center;
    padding: 7px 8px;
    font-size: 12px;
  }
  .cronograma-nav-controls {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
  .cronograma-nav-controls .btn {
    flex: 1;
    justify-content: center;
  }
  .cronograma-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .cronograma-header-actions .btn {
    font-size: 11px;
    padding: 6px 8px;
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }
  .cronograma-toolbar-card {
    padding: 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .cronograma-toolbar-card .toolbar-left,
  .cronograma-toolbar-card .toolbar-right {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .cronograma-toolbar-card .search-box {
    width: 100%;
  }
  .cronograma-split-container {
    height: calc(100vh - 260px);
    min-height: 460px;
  }
  .cronograma-table-panel {
    width: 100% !important;
    min-width: 0 !important;
    max-height: none !important;
    height: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-right: none;
  }
  .cronograma-table-scroll-wrapper {
    min-width: 760px;
  }
  .cronograma-gantt-panel {
    width: 100% !important;
    height: 100% !important;
    min-height: 460px !important;
  }
  .cronograma-gantt-scroll {
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }
  .cronograma-drawer {
    width: 100vw !important;
    max-width: 100vw !important;
    right: -100vw;
  }
  .cronograma-drawer.open {
    right: 0;
  }
  .cronograma-drawer .drawer-tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}



/* Cronograma: avance calculado desde los partes diarios (no editable en la tabla) */
.cron-avance-calculado { cursor: help; }
.cron-avance-calculado .mini-progress-fill { background: var(--color-success, #16A34A); }

/* Presupuesto: selección y borrado masivo de partidas */
.ppto-sel-cell { width: 34px; text-align: center; padding-left: 8px; padding-right: 0; }
.ppto-sel-cell input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-brand); }
.ppto-selbar { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-md); margin-bottom: var(--space-xs); background: var(--bg-surface); border: 1px solid var(--color-brand); border-radius: var(--radius-md); position: sticky; top: 0; z-index: var(--z-sticky); }
.ppto-selbar[hidden] { display: none; }
.ppto-selbar-txt { font-weight: var(--font-weight-semibold, 600); margin-right: auto; }

/* Los bloques de cabecera de una vista no se comprimen cuando el contenido de abajo es alto (el contenedor hace scroll) */
.content-scrollable > .module-tabs,
.content-scrollable > .view-header-row,
.content-scrollable > .toolbar,
.content-scrollable > .kpi-summary-card { flex-shrink: 0; }

/* Cronograma: dependencias visuales (conectores en las barras, flecha elástica y edición de la dependencia) */
.gantt-conn { fill: #FFFFFF; stroke: var(--color-brand); stroke-width: 2; cursor: crosshair; opacity: 0; transition: opacity .12s ease; }
.gantt-bar-item:hover .gantt-conn, .cronograma-svg.gantt-linking .gantt-conn { opacity: 1; }
.gantt-conn:hover, .gantt-conn.gantt-conn-target { fill: var(--color-brand); r: 7; }
.cronograma-svg.gantt-linking { cursor: crosshair; }
.cronograma-svg.gantt-linking .gantt-bar-item { cursor: crosshair; }
.gantt-bar-item.gantt-bar-target rect { stroke: var(--color-brand); stroke-width: 3; }
.gantt-link-preview { fill: none; stroke: var(--color-brand); stroke-width: 2; stroke-dasharray: 5 4; pointer-events: none; }
.gantt-dep-hit { cursor: pointer; pointer-events: stroke; }
.gantt-dep-popover { position: fixed; z-index: var(--z-tooltip); background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-lg, 0 8px 24px rgba(15,23,42,.18)); padding: var(--space-sm) var(--space-md); display: flex; flex-direction: column; gap: var(--space-sm); min-width: 280px; max-width: 360px; }
.gantt-dep-popover-title { font-weight: var(--font-weight-semibold, 600); font-size: var(--font-label); word-break: break-word; }
.gantt-dep-popover-row { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; font-size: var(--font-label); color: var(--text-secondary); }
.gantt-dep-popover-row input { width: 64px; }
.gantt-dep-popover-actions { display: flex; gap: var(--space-xs); justify-content: flex-end; }

/* Cronograma: edición de fechas (arrastrar/estirar), línea base, fecha límite */
.gantt-resize { fill: rgba(255,255,255,.35); cursor: ew-resize; opacity: 0; transition: opacity .12s ease; }
.gantt-bar-item:hover .gantt-resize { opacity: 1; }
.gantt-ghost { fill: rgba(243,115,41,.35); stroke: var(--color-brand); stroke-width: 2; stroke-dasharray: 4 3; pointer-events: none; }
.gantt-drag-label { position: fixed; z-index: var(--z-tooltip); pointer-events: none; background: var(--bg-dark, #1F2A38); color: #fff; font-size: var(--font-tiny); padding: 3px 8px; border-radius: var(--radius-sm, 4px); box-shadow: var(--shadow-md, 0 2px 8px rgba(0,0,0,.25)); }
.gantt-baseline { fill: #94A3B8; opacity: .9; }
.gantt-limite { fill: #D97706; stroke: #fff; stroke-width: 1; }
.gantt-limite-excedido { fill: #C6262E; }

/* ── Marco con pestañas (Reportes, Costos y estimaciones) ── */
.tabsv-bar {
  flex: none;
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg) 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.tabsv-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-label);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabsv-tab:hover { color: var(--text-primary); }
.tabsv-tab.active {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
  font-weight: var(--font-weight-semibold);
}
.tabsv-contenido {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Menú lateral agrupado por etapa de la obra ── */
.nav-group { display: flex; flex-direction: column; gap: var(--space-xxs); }
.nav-group + .nav-group { margin-top: var(--space-sm); }
.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: 0;
  padding: var(--space-xs) var(--space-md);
  font-family: inherit;
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  opacity: 0.8;
  cursor: pointer;
}
.nav-group-title:hover { opacity: 1; }
.nav-group-caret { font-size: 9px; transition: transform 0.15s ease; }
.nav-group.collapsed .nav-group-caret { transform: rotate(-90deg); }
.nav-group.collapsed .nav-item:not(.active) { display: none; }
