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

/* =============================================
   THEME VARIABLES
   ============================================= */
:root {
  --bg-body: #0a0a0a;
  --bg-sidebar: #111111;
  --bg-card: #141414;
  --bg-input: #1a1a1a;
  --bg-hover: #1a1a1a;
  --bg-deep: #0e0e0e;
  --border: #1e1e1e;
  --border-input: #2a2a2a;
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --text-tertiary: #666;
  --text-muted: #555;
  --accent: #10b981;
  --accent-bg: rgba(16, 185, 129, 0.1);
  --accent-border: rgba(16, 185, 129, 0.3);
  --blue: #3b82f6;
  --orange: #f59e0b;
  --purple: #a855f7;
  --red: #ef4444;
  --nav-active-bg: rgba(16, 185, 129, 0.1);
  --badge-bg: #1e1e1e;
  --modal-bg: #141414;
  --table-header-bg: #111;
  --table-stripe: rgba(255,255,255,0.02);
  --shadow: none;
  --pre-section-bg: #1a1a2e;
  --pre-section-border: #2a2a3e;
}

[data-theme="light"] {
  --bg-body: #f5f7fa;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f0f2f5;
  --bg-hover: #f0f2f5;
  --bg-deep: #f8f9fb;
  --border: #e2e5e9;
  --border-input: #d1d5db;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-muted: #b0b5bf;
  --accent: #059669;
  --accent-bg: rgba(5, 150, 105, 0.08);
  --accent-border: rgba(5, 150, 105, 0.25);
  --blue: #2563eb;
  --orange: #d97706;
  --purple: #7c3aed;
  --red: #dc2626;
  --nav-active-bg: rgba(5, 150, 105, 0.08);
  --badge-bg: #e8ecf0;
  --modal-bg: #ffffff;
  --table-header-bg: #f0f2f5;
  --table-stripe: rgba(0,0,0,0.02);
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --pre-section-bg: #f0f4f8;
  --pre-section-border: #d1d9e0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* =============================================
   NAVIGATION SIDEBAR
   ============================================= */
.nav-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  box-shadow: var(--shadow);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
}

.nav-brand-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.nav-menu {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  position: relative;
}

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

.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--accent);
}

.nav-item.active svg {
  stroke: #10b981;
}

.nav-badge {
  position: absolute;
  right: 12px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.nav-footer {
  padding: 16px;
  border-top: 1px solid #1e1e1e;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-user-info {
  flex: 1;
  min-width: 0;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--border, #1e1e1e);
  border-radius: 6px;
  color: var(--text-secondary, #888);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

/* Selector de usuarios en login */
.login-users {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-hover, rgba(255,255,255,0.03));
  border: 1px solid var(--border, #1e1e1e);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  color: var(--text-primary, #ddd);
  font-family: inherit;
}
.login-user-card:hover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  transform: translateY(-1px);
}
.login-user-card:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}
.login-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.login-user-info { flex: 1; min-width: 0; }
.login-user-info .nombre {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary, #ddd);
}
.login-user-info .rol {
  display: block;
  font-size: 12px;
  color: var(--text-secondary, #888);
  text-transform: capitalize;
  margin-top: 2px;
}
.login-user-card .chev {
  color: var(--text-tertiary, #555);
  flex-shrink: 0;
}

.nav-user-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.nav-user-info {
  display: flex;
  flex-direction: column;
}

.nav-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #ddd;
}

.nav-user-role {
  font-size: 11px;
  color: #666;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.view-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.view-subtitle {
  font-size: 14px;
  color: #666;
  margin-top: 4px;
}

.view-header-actions {
  display: flex;
  gap: 10px;
}

/* =============================================
   DASHBOARD
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-green .stat-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.stat-green .stat-icon svg { stroke: #10b981; }
.stat-blue .stat-icon { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.stat-blue .stat-icon svg { stroke: #3b82f6; }
.stat-orange .stat-icon { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.stat-orange .stat-icon svg { stroke: #f59e0b; }
.stat-purple .stat-icon { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.stat-purple .stat-icon svg { stroke: #a855f7; }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: #666;
  margin-top: 4px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.dash-card {
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  padding: 20px;
}

.dash-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: #ddd;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1e1e1e;
}

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.dash-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-item-title {
  color: var(--text-primary);
  font-weight: 500;
}

.dash-item-sub {
  color: var(--text-secondary);
  font-size: 12px;
}

.dash-empty {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

/* =============================================
   TABLES
   ============================================= */
.search-bar {
  margin-bottom: 16px;
}

.search-bar input {
  width: 100%;
  max-width: 400px;
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  padding: 10px 14px;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: #10b981;
}

.search-bar input::placeholder {
  color: #555;
}

.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 7px 16px;
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 6px;
  color: #888;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  background: #1a1a1a;
  color: #ccc;
}

.filter-btn.active {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
  color: #10b981;
}

.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: #0f0f0f;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
  background: var(--bg-input);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-pendiente { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-en_curso, .badge-en_transito { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-completado, .badge-completada, .badge-recibida { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-cancelado, .badge-cancelada { background: rgba(107, 114, 128, 0.15); color: #6b7280; }
.badge-borrador { background: #dc2626; color: #fff; }
.badge-enviada, .badge-enviado { background: #f59e0b; color: #fff; }
.badge-pagada { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-vigente { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-vencido { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-aceptada, .badge-aceptado { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-rechazada, .badge-rechazado { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-sin_facturar { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-facturado { background: rgba(16, 185, 129, 0.15); color: #10b981; }

/* Role badges */
.badge-role-productor { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.badge-role-operador { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-role-gestor { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-role-transportista { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-cliente { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-proveedor { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.btn-primary {
  background: #10b981;
  color: #fff;
}

.btn-primary:hover {
  background: #059669;
}

.btn-secondary {
  background: #1e1e1e;
  color: #ccc;
}

.btn-secondary:hover {
  background: #2a2a2a;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-ai {
  background: #1a1030;
  color: #c084fc;
  border: 1px solid #2a1a50;
}

.btn-ai:hover {
  background: #2a2050;
}

.btn-ai:disabled {
  opacity: 0.5;
  cursor: wait;
}

.btn-invoice-btn {
  color: #fbbf24;
  background: #1a1810;
  border-color: #2a2210;
}

.btn-invoice-btn:hover {
  background: #2a2810;
}

.btn-destruccion {
  background: rgba(251, 146, 60, 0.1);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.2);
}

.btn-destruccion:hover {
  background: rgba(251, 146, 60, 0.2);
}

.btn-logistica {
  background: rgba(96, 165, 250, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.2);
}

.btn-logistica:hover {
  background: rgba(96, 165, 250, 0.2);
}

.btn-presupuesto {
  background: rgba(52, 211, 153, 0.1);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.btn-presupuesto:hover {
  background: rgba(52, 211, 153, 0.2);
}

.reply-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 6px;
  margin-bottom: 8px;
  color: #34d399;
  font-size: 13px;
}

.reply-attachment .btn-icon {
  color: #ef4444;
  font-size: 16px;
  padding: 0 4px;
}

/* Modal presupuesto email */
.pre-resumen-cliente, .pre-resumen-residuo {
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.pre-resumen-cliente h4, .pre-resumen-residuo h4, .pre-lineas-section h4 {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pre-resumen-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  font-size: 13px;
}

.pre-partes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.pre-input-sm {
  width: 100%;
  background: #1a1a2e;
  border: 1px solid #333;
  color: #e0e0e0;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.pre-input-sm:focus { border-color: #2563eb; outline: none; }
.pre-input-sm[readonly] { opacity: 0.6; cursor: not-allowed; }

.pre-search { margin-bottom: 2px; }

.pre-parte-detail {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
  line-height: 1.4;
  min-height: 30px;
}

.pre-lineas-section { margin-top: 12px; }

.pre-lineas-section input, .pre-lineas-section select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
}

.pre-lineas-section input:focus, .pre-lineas-section select:focus {
  border-color: var(--accent);
  outline: none;
}

.pre-lineas-section .btn-icon {
  color: var(--danger, #ef4444);
  font-size: 16px;
}

.pre-totales {
  margin-top: 12px;
  text-align: right;
  font-size: 13px;
}

.pre-total-row {
  padding: 4px 0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.pre-total-row strong { min-width: 100px; text-align: right; }

.pre-total-final {
  border-top: 2px solid #2563eb;
  padding-top: 8px;
  margin-top: 4px;
  font-size: 15px;
  color: #34d399;
}

/* Pestanas presupuestos */
.presupuestos-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-action.accept {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

.btn-action.accept:hover {
  background: rgba(52, 211, 153, 0.15);
}

.btn-action.launch {
  background: rgba(52, 211, 153, 0.1);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
  font-weight: 600;
}

.btn-action.launch:hover {
  background: rgba(52, 211, 153, 0.25);
}

.badge-aceptado {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

.badge-pendiente {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.badge-completado {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

/* Botones icono en tablas */
.btn-icon-action {
  font-size: 16px !important;
  padding: 4px 8px !important;
  min-width: auto !important;
  line-height: 1;
  cursor: pointer;
}

/* Documentacion tabs */
.doc-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.pill-count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #888);
  background: var(--bg-hover, rgba(255,255,255,0.06));
  border-radius: 10px;
  line-height: 1.4;
}
.filter-btn.active .pill-count {
  color: #fff;
  background: rgba(255,255,255,0.2);
}

.btn-send {
  background: #059669;
  color: #fff;
  margin-left: auto;
}

.btn-send:hover {
  background: #047857;
}

.btn-icon {
  background: none;
  border: none;
  color: #888;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1;
}

.btn-icon:hover {
  background: #222;
  color: #fff;
}

.btn-action {
  background: none;
  border: none;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-action:hover {
  background: #222;
  color: #fff;
}

.btn-action.delete:hover {
  color: #ef4444;
}

.btn-action.workflow {
  color: #10b981;
  font-weight: 600;
}

.btn-action.workflow:hover {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.action-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* =============================================
   MODALS & FORMS
   ============================================= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 14px;
  padding: 24px;
  max-width: 600px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-wide {
  max-width: 750px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #1e1e1e;
}

.modal-header h3 {
  font-size: 18px;
  color: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-form > .form-group,
.modal-form > .typeahead-wrap.form-group {
  margin-bottom: 14px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: #0a0a0a;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  padding: 9px 12px;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #10b981;
}

.form-group textarea {
  resize: vertical;
}

.form-group input[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #1e1e1e;
}

/* Sticky action bar inside scrollable modals */
.modal-content > .form-actions:last-child,
.modal-form > .form-actions:last-child,
.modal-form > form > .form-actions:last-child {
  position: sticky;
  bottom: -24px;
  margin: 20px -24px -24px;
  padding: 14px 24px;
  background: #141414;
  border-top: 1px solid #1e1e1e;
  z-index: 5;
}
[data-theme="light"] .modal-content > .form-actions:last-child,
[data-theme="light"] .modal-form > .form-actions:last-child,
[data-theme="light"] .modal-form > form > .form-actions:last-child {
  background: var(--modal-bg);
  border-top-color: var(--border);
}

/* Checkbox group */
.checkbox-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #ccc !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #10b981;
  cursor: pointer;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 3px;
}

/* Conceptos / Lineas factura & presupuesto */
.conceptos-section {
  margin: 16px 0;
  padding: 16px;
  background: var(--bg-input);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.conceptos-section h4 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.concepto-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.concepto-residuo-select {
  flex: 2;
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 6px;
  padding: 8px 10px;
  color: #e0e0e0;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.concepto-desc {
  flex: 2;
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 6px;
  padding: 8px 10px;
  color: #e0e0e0;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.concepto-tn,
.concepto-precio {
  width: 90px;
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 6px;
  padding: 8px 10px;
  color: #e0e0e0;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.concepto-total {
  width: 80px;
  text-align: right;
  color: #10b981;
  font-weight: 600;
  font-size: 13px;
}

.concepto-desc:focus,
.concepto-tn:focus,
.concepto-precio:focus {
  border-color: #10b981;
}

/* Contrato linea rows */
.contrato-linea-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.contrato-linea-row select,
.contrato-linea-row input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.contrato-linea-row > input { flex: none; width: 100px; }
.contrato-linea-row .ler-search-wrap input { flex: 1; width: 100% !important; }

.contrato-linea-row select:focus,
.contrato-linea-row input:focus {
  border-color: var(--accent);
}

.contrato-linea-row .ler-search-wrap {
  flex: 2; position: relative; min-width: 200px;
}
.contrato-linea-row .ler-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  max-height: 200px; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 8px 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: none;
}
.contrato-linea-row .ler-dropdown-item {
  padding: 6px 10px; cursor: pointer; font-size: 12px; color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.contrato-linea-row .ler-dropdown-item:hover { background: var(--accent-bg); }
.contrato-linea-row .ler-dropdown-item code { color: var(--accent); font-weight: 600; }

/* Contrato steps flow */
.contrato-steps-indicator {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  padding: 0;
}
.contrato-step-dot {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #777;
  background: transparent;
  border: 1px solid #1e1e1e;
  transition: all 0.2s;
  cursor: default;
  white-space: nowrap;
}
.contrato-step-dot span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1e1e1e;
  color: #777;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}
.contrato-step-dot.active {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}
.contrato-step-dot.active span {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.contrato-step-dot.done {
  color: #10b981;
  background: transparent;
  border-color: #10b98155;
}
.contrato-step-dot.done span {
  background: #10b98125;
  color: #10b981;
}
.contrato-step-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 4px 0 8px;
  text-align: left;
}
.contrato-step-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #10b981;
  margin-bottom: 8px;
}
.contrato-step-card select {
  width: 100%;
  max-width: 400px;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 12px 14px;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.contrato-step-card select:focus {
  border-color: #10b981;
}
.btn-link {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 13px;
  margin-top: 12px;
  padding: 4px 8px;
}
.btn-link:hover {
  color: #10b981;
}
.contrato-resumen {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  background: #0f0f0f;
  border: 1px solid #1e1e1e;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #ccc;
}
.contrato-resumen strong {
  color: #888;
}
.contrato-resumen-item {
  display: flex;
  gap: 6px;
}

/* Light theme overrides */
[data-theme="light"] .contrato-step-dot { background: transparent; border-color: var(--border-light); color: var(--text-muted); }
[data-theme="light"] .contrato-step-dot span { background: var(--badge-bg); color: var(--text-muted); }
[data-theme="light"] .contrato-step-dot.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.25); }
[data-theme="light"] .contrato-step-dot.active span { background: rgba(255,255,255,0.3); color: #fff; }
[data-theme="light"] .contrato-step-dot.done { background: transparent; border-color: #10b98155; color: var(--accent); }
[data-theme="light"] .contrato-step-dot.done span { background: #10b98120; color: var(--accent); }
[data-theme="light"] .contrato-step-card { background: transparent; border: none; }
[data-theme="light"] .contrato-step-label { color: var(--accent); }
[data-theme="light"] .contrato-step-card select { background: var(--bg); border-color: var(--border-light); color: var(--text-primary); }
[data-theme="light"] .contrato-resumen { background: var(--surface); border-color: var(--border-light); color: var(--text-primary); }
[data-theme="light"] .contrato-resumen strong { color: var(--text-secondary); }

.factura-totales {
  margin: 16px 0;
  padding: 16px;
  background: #0f0f0f;
  border-radius: 10px;
  border: 1px solid #1e1e1e;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  color: #999;
}

.total-final {
  padding-top: 10px;
  margin-top: 8px;
  border-top: 1px solid #1e1e1e;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.total-final span:last-child {
  color: #10b981;
}

/* Workflow actions */
.workflow-actions {
  margin: 16px 0;
  padding: 16px;
  background: #0f0f0f;
  border-radius: 10px;
  border: 1px solid #1e1e1e;
}

.workflow-actions h4 {
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.workflow-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Agrupar albaranes list */
.agrupar-list {
  margin: 16px 0;
  padding: 16px;
  background: #0f0f0f;
  border-radius: 10px;
  border: 1px solid #1e1e1e;
  max-height: 300px;
  overflow-y: auto;
}

.agrupar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #1a1a1a;
  font-size: 13px;
}

.agrupar-item:last-child {
  border-bottom: none;
}

.agrupar-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #10b981;
}

.agrupar-item-info {
  flex: 1;
}

.agrupar-item-importe {
  color: #10b981;
  font-weight: 600;
}

/* =============================================
   CORREO LAYOUT
   ============================================= */
.correo-layout {
  display: flex;
  height: calc(100vh - 0px);
  margin: -32px;
  background: var(--bg-card);
}

.correo-sidebar {
  width: 360px;
  min-width: 360px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.correo-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.correo-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 3px;
}

.tab {
  padding: 7px 10px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 6px;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.email-list {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.email-item:hover {
  background: var(--bg-input);
}

.email-item.active {
  background: var(--accent-bg);
  border-left-color: var(--accent);
}

.email-item-from {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.email-item-from::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.email-item.active .email-item-from::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.email-item-subject {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  padding-left: 14px;
}

.email-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 14px;
}

.email-item-date {
  font-size: 11px;
  color: var(--text-secondary);
  float: right;
  font-weight: 500;
}

.correo-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-input);
}

.email-view {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  background: var(--bg-card);
  margin: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.email-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.email-subject-title {
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.email-sender-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  gap: 12px;
}

.email-sender-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.email-from-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.email-cc-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.email-date-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.email-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Read/unread email status */
.email-item.read .email-item-from::before {
  background: var(--border);
}

.email-item.read .email-item-from {
  font-weight: 400;
}

/* Move buttons */
.btn-mover-activo,
.btn-mover-realizado {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-mover-activo:hover,
.btn-mover-realizado:hover {
  background: var(--bg-hover);
}

.email-body {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-top: 16px;
}

.email-actions {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

/* Reply Panel */
.reply-panel {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 20px;
  max-height: 45vh;
  display: flex;
  flex-direction: column;
  margin: 0 12px 12px;
  border-radius: 0 0 12px 12px;
}

.reply-panel.reply-panel-full {
  flex: 1;
  max-height: none;
  border-top: none;
  overflow-y: auto;
}

.reply-panel.reply-panel-full #reply-text {
  flex: 1;
  min-height: 50vh;
}

.reply-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.reply-header h3 {
  font-size: 13px;
  color: var(--text-secondary);
}

.cc-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.cc-field label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  min-width: 38px;
}

.cc-field input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.cc-field input:focus {
  border-color: #10b981;
}

#reply-text {
  flex: 1;
  min-height: 100px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 10px;
  padding: 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.6;
}

#reply-text:focus {
  border-color: #10b981;
}

.reply-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

.ai-icon {
  font-size: 15px;
}

.ai-status {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.ai-status.error {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}

/* =============================================
   EMPTY STATES & LOADING
   ============================================= */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  gap: 12px;
}

.loading {
  padding: 40px;
  text-align: center;
  color: #555;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #10b981;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

/* Invoice data */
#invoice-data {
  background: #0a0a0a;
  padding: 16px;
  border-radius: 8px;
  font-size: 13px;
  color: #ccc;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #222;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* =============================================
   CONTABILIDAD
   ============================================= */

.contab-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-select-inline {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #e0e0e0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  min-width: 160px;
}
.form-select-inline:focus {
  outline: none;
  border-color: #10b981;
}

.contab-tabs {
  display: flex;
  gap: 4px;
  margin: 20px 0 0;
  border-bottom: 1px solid #1e1e1e;
  padding-bottom: 0;
}

.contab-tab {
  background: none;
  border: none;
  color: #888;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.contab-tab:hover {
  color: #e0e0e0;
}
.contab-tab.active {
  color: #10b981;
  border-bottom-color: #10b981;
}

.contab-panel {
  margin-top: 16px;
}

.contab-panel-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Libro Mayor */
.mayor-resumen {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.mayor-card {
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.mayor-label {
  color: #888;
  font-size: 13px;
}
.mayor-value {
  font-size: 24px;
  font-weight: 700;
}

/* Balance grid */
.balance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.balance-col {
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  padding: 16px;
}
.balance-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #1e1e1e;
  color: #e0e0e0;
}
.total-row {
  background: #1a1a1a;
  font-weight: 600;
}
.total-row td {
  border-top: 2px solid #2a2a2a;
}

/* PyG resultado */
.pyg-resultado {
  margin-top: 20px;
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
}
.pyg-resultado-valor {
  font-size: 28px;
  font-weight: 700;
}

/* Fiscal */
.fiscal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.fiscal-grid > .dash-card:last-child {
  grid-column: 1 / -1;
}
.fiscal-resumen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fiscal-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}
.fiscal-item-total {
  padding: 12px 0;
  font-size: 16px;
  font-weight: 600;
}
.fiscal-label {
  color: #aaa;
  font-size: 14px;
}
.fiscal-value {
  font-size: 18px;
  font-weight: 600;
}
.fiscal-divider {
  height: 1px;
  background: #2a2a2a;
  margin: 4px 0;
}

.fiscal-modelos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.modelo-card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modelo-num {
  font-size: 24px;
  font-weight: 700;
  color: #10b981;
}
.modelo-desc {
  font-size: 12px;
  color: #888;
}

/* Asiento lineas en modal */
.asiento-lineas-container {
  background: #0e0e0e;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  padding: 12px;
}
.asiento-lineas-container .data-table th,
.asiento-lineas-container .data-table td {
  padding: 6px 8px;
}
.asiento-lineas-container input,
.asiento-lineas-container select {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #e0e0e0;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
}
.asiento-lineas-container input:focus,
.asiento-lineas-container select:focus {
  outline: none;
  border-color: #10b981;
}

.modal-large {
  max-width: 900px;
}

/* =============================================
   PLANIFICACION
   ============================================= */
.plan-week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.plan-week-label {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan-grid-container {
  overflow-x: auto;
}
.plan-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.plan-zone-header {
  width: 160px;
  min-width: 160px;
  background: var(--bg-card);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
}
.plan-day-header {
  background: var(--bg-card);
  padding: 10px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  min-width: 110px;
}
.plan-day-header:last-child { border-right: none; }
.plan-day-header.plan-today {
  background: var(--accent-bg);
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.plan-day-date {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
}
.plan-day-header.plan-today .plan-day-date { color: var(--accent); }
.plan-zone-name {
  background: var(--bg-card);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.plan-zone-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.plan-cell {
  background: var(--bg-body);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 6px;
  vertical-align: top;
  min-height: 90px;
  height: 90px;
  cursor: pointer;
  transition: background 0.15s;
}
.plan-cell:last-child { border-right: none; }
.plan-cell:hover { background: var(--accent-bg); }
.plan-cell.plan-today-col { background: rgba(16,185,129,0.03); }
.plan-cell.plan-today-col:hover { background: var(--accent-bg); }

.plan-task {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.3;
}
.plan-task:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.plan-task-desc { font-weight: 600; color: var(--text-primary); }
.plan-task-meta { color: var(--text-tertiary); font-size: 10px; margin-top: 2px; }
.plan-task[data-tipo="descarga"] { border-left-color: var(--accent); }
.plan-task[data-tipo="recogida"] { border-left-color: var(--blue); }
.plan-task[data-tipo="tratamiento"] { border-left-color: var(--orange); }
.plan-task[data-tipo="mantenimiento"] { border-left-color: var(--purple); }
.plan-task[data-tipo="otro"] { border-left-color: var(--text-tertiary); }
.plan-task[data-tipo="registrada"] { border-left-color: var(--accent); background: var(--accent-bg); opacity: 0.85; }
.plan-task[data-tipo="registrada"] .plan-task-desc { color: var(--accent); }

.plan-cell-add {
  display: none;
  font-size: 18px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px;
  cursor: pointer;
}
.plan-cell:hover .plan-cell-add { display: block; }

/* Albaran a Factura - Asiento section */
.af-asiento-section {
  margin-top: 16px;
  background: #0e0e0e;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  padding: 16px;
}
.af-asiento-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.af-asiento-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #888;
  font-size: 13px;
  padding: 12px 0;
}
.spinner-small {
  width: 18px;
  height: 18px;
  border: 2px solid #333;
  border-top: 2px solid #10b981;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.btn-small {
  padding: 4px 12px;
  font-size: 12px;
}

/* Presupuesto modal */
.modal-xlarge { max-width: 1050px; }

/* Wizard steps */
.wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid #1e1e1e;
}
.wizard-step {
  flex: 1;
  padding: 12px 16px;
  font-size: 13px;
  color: #555;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.wizard-step.active {
  color: #10b981;
  border-bottom-color: #10b981;
}
.wizard-step.done {
  color: #888;
  border-bottom-color: #333;
}
.wizard-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: #1e1e1e;
  color: #555;
}
.wizard-step.active .wizard-num {
  background: #10b981;
  color: #000;
}
.wizard-step.done .wizard-num {
  background: #333;
  color: #10b981;
}
.wizard-panel {
  min-height: 250px;
}
.wizard-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #1e1e1e;
}
.wizard-resumen {
  background: #0e0e0e;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  padding: 12px 16px;
}

.pre-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #10b981;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1e1e1e;
}
.pre-section-title:first-of-type { margin-top: 8px; }

.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.pre-lineas-section {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.pre-lineas-header {
  display: flex;
  gap: 8px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  border-bottom: 1px solid #1e1e1e;
  margin-bottom: 6px;
}
/* Lineas como tarjetas */
.lineas-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.linea-card {
  background: #141414;
  border: 1px solid #1e1e1e;
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
  transition: border-color 0.2s;
}
.linea-card:focus-within {
  border-color: #10b981;
}
.linea-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.linea-card-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1e1e1e;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.linea-card:focus-within .linea-card-num {
  background: #10b981;
  color: #000;
}
.linea-card-desc {
  flex: 1;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  color: #e0e0e0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
  width: 100%;
}
.linea-card-desc:focus {
  outline: none;
  border-color: #10b981;
}
.linea-card-desc::placeholder {
  color: #444;
}
.linea-card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
}
.linea-card-remove:hover {
  color: #ef4444;
}
.linea-card-ler {
  font-size: 11px;
  color: #10b981;
  min-height: 16px;
  margin: 4px 0 8px 36px;
}
.linea-card-fields {
  display: flex;
  gap: 12px 16px;
  align-items: flex-end;
  margin-left: 36px;
  flex-wrap: wrap;
}
.linea-card-fields label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.linea-card-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.linea-card-fields input, .linea-card-fields select {
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  color: #e0e0e0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.linea-card-fields input:focus, .linea-card-fields select:focus {
  outline: none;
  border-color: #10b981;
}
.linea-card-base {
  font-weight: 700;
  color: #10b981;
  font-size: 14px;
  min-width: 80px;
  text-align: right;
  padding: 6px 0;
}
.lineas-add-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.pre-linea-tipo-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-right: 4px;
}
.pre-linea-tipo-residuo { background: rgba(16,185,129,0.15); color: #10b981; }
.pre-linea-tipo-transporte { background: rgba(59,130,246,0.15); color: #3b82f6; }
.pre-linea-tipo-servicio { background: rgba(245,158,11,0.15); color: #f59e0b; }

/* Albaran post-DI banner */
.albaran-di-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 14px;
  color: #10b981;
}

.stats-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Nivel indentation for plan de cuentas */
.cuenta-nivel-1 { font-weight: 700; background: #1a1a1a; }
.cuenta-nivel-2 { padding-left: 20px; font-weight: 600; }
.cuenta-nivel-3 { padding-left: 40px; }
.cuenta-nivel-4 { padding-left: 60px; font-size: 13px; color: #aaa; }

/* =============================================
   SEARCH DROPDOWNS & CARDS (theme-aware)
   ============================================= */
.search-dropdown {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 100;
  max-height: 280px; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-size: 13px; line-height: 1.35;
}
.search-dropdown-item {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover { background: var(--accent-bg); }
.search-dropdown-item-name { font-size: 13px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.search-dropdown-item-info { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.search-dropdown-item.is-reciman { background: linear-gradient(90deg, rgba(16,185,129,0.07), transparent 60%); }

/* Badge RECIMAN — distingue rol (productor / operador / gestor) */
.reciman-badge {
  display: inline-flex; align-items: center;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; line-height: 1.2;
  border: 1px solid transparent;
}
.reciman-badge-productor { background: #f59e0b20; color: #b45309; border-color: #f59e0b55; }
.reciman-badge-operador  { background: #3b82f620; color: #1d4ed8; border-color: #3b82f655; }
.reciman-badge-gestor    { background: #10b98120; color: #047857; border-color: #10b98166; }
[data-theme="dark"] .reciman-badge-productor { color: #fbbf24; }
[data-theme="dark"] .reciman-badge-operador  { color: #60a5fa; }
[data-theme="dark"] .reciman-badge-gestor    { color: #34d399; }
.selected-card {
  margin-top: 10px; padding: 10px 14px;
  background: var(--accent-bg); border: 1px solid var(--accent-border); border-radius: 8px;
}
.selected-card-name { font-weight: 600; color: var(--accent); }
.selected-card-btn {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 3px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}

/* Tarjeta tercero seleccionado en contrato (con detalles) */
.tercero-selected-card {
  margin-top: 12px;
  padding: 0;
  overflow: hidden;
}
.tercero-selected-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--accent-bg);
  border-bottom: 1px solid var(--accent-border);
}
.tercero-selected-card .selected-card-name { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tercero-selected-check { color: #10b981; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.tercero-selected-detalles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 16px;
  padding: 12px 14px;
  background: var(--bg-card);
}
.tercero-selected-detalles:empty { display: none; }
.tercero-detalle-row {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
.tercero-detalle-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--text-secondary);
}
.tercero-detalle-value {
  font-size: 13px; color: var(--text-primary); font-weight: 500;
  word-break: break-word;
}
[data-theme="light"] .tercero-selected-detalles { background: #fff; }

/* Badge tipo albarán (entrada/salida) */
.tipo-badge {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px; line-height: 1.2; white-space: nowrap;
  border: 1px solid transparent;
}
.tipo-badge.tipo-entrada { background: #3b82f620; color: #1d4ed8; border-color: #3b82f655; }
.tipo-badge.tipo-salida  { background: #f59e0b20; color: #b45309; border-color: #f59e0b55; }
[data-theme="dark"] .tipo-badge.tipo-entrada { color: #60a5fa; }
[data-theme="dark"] .tipo-badge.tipo-salida  { color: #fbbf24; }
.tipo-btn {
  flex: 1; padding: 20px; font-size: 16px;
  border: 2px solid var(--border); border-radius: 10px;
  background: var(--bg-input); color: var(--text-primary); cursor: pointer;
}
.tipo-btn.active, .tipo-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.ct-card {
  padding: 12px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: border-color 0.2s;
}
.ct-card:hover, .ct-card.active { border-color: var(--accent); }
.ct-card-title { font-weight: 600; color: var(--text-primary); }
.ct-card-info { font-size: 12px; color: var(--text-secondary); }
.panel-section {
  padding: 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
}

/* =============================================
   MI PERFIL — empresa propia
   ============================================= */
.empresa-form { max-width: 900px; display: flex; flex-direction: column; gap: 16px; }
.empresa-section {
  padding: 20px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.empresa-section h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--accent);
}
.empresa-hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.empresa-section .form-grid { margin-bottom: 0; }

/* =============================================
   ALBARAN — tabla de líneas
   ============================================= */
.alb-lineas-table {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card);
}
.alb-lineas-head,
.alb-linea-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 90px 80px 110px 90px 120px 32px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
}
.alb-lineas-head {
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
}
.alb-linea-row { border-bottom: 1px solid var(--border); }
.alb-linea-row:last-child { border-bottom: none; }
.alb-linea-row input,
.alb-linea-row select {
  width: 100%;
  padding: 7px 9px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  box-sizing: border-box;
}
.alb-linea-row input.alb-l-cant,
.alb-linea-row input.alb-l-precio,
.alb-linea-row input.alb-l-importe { text-align: right; font-variant-numeric: tabular-nums; }
.alb-linea-row input.alb-l-importe { font-weight: 700; background: var(--accent-bg); border-color: var(--accent-border); }
.alb-linea-row .alb-l-del {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; width: 28px; height: 28px;
  color: var(--text-secondary); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.alb-linea-row .alb-l-del:hover { background: #fef2f2; color: #ef4444; border-color: #ef4444; }
[data-theme="dark"] .alb-linea-row .alb-l-del:hover { background: rgba(239,68,68,0.15); }

.alb-totales {
  margin-top: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.alb-totales-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.alb-totales-row span:last-child { font-weight: 600; color: var(--text-primary); }
.alb-totales-final {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 2px solid var(--accent);
  font-size: 15px;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 700;
}
.alb-totales-final span:last-child {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

/* =============================================
   VEHICULO RECONOCIDO — premium pill card
   ============================================= */
.vehiculo-pill {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent-bg) 0%, rgba(16,185,129,0.02) 100%);
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(16,185,129,0.08);
  animation: vehiculo-pill-in 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes vehiculo-pill-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.vehiculo-pill-badge {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(16,185,129,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}
.vehiculo-pill-body { flex: 1; min-width: 0; }
.vehiculo-pill-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.vehiculo-pill-details {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.vehiculo-pill-matricula {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700; font-size: 13px; letter-spacing: 0.6px;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.04);
}
.vehiculo-pill-tipo {
  font-size: 12px; color: var(--text-secondary); font-weight: 500;
  text-transform: capitalize;
}
.vehiculo-pill-tipo::before { content: "·  "; color: var(--text-secondary); opacity: 0.5; }
.vehiculo-pill-transp {
  font-size: 13px; color: var(--text-primary); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.vehiculo-pill-transp::before { content: "·  "; color: var(--text-secondary); opacity: 0.5; font-weight: 400; }

/* =============================================
   VEHICULO NUEVO — panel con buscador
   ============================================= */
.vehiculo-nuevo-panel {
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px dashed #f59e0b;
  border-radius: 12px;
  animation: vehiculo-pill-in 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.vehiculo-nuevo-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px; flex-wrap: wrap;
}
.vehiculo-nuevo-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: #f59e0b; font-size: 14px;
}
.vehiculo-nuevo-plus {
  width: 22px; height: 22px; border-radius: 50%;
  background: #f59e0b; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; line-height: 1;
}
.vehiculo-nuevo-sub {
  font-size: 11px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.4px;
}

/* =============================================
   UTILITY
   ============================================= */
.hidden {
  display: none !important;
}

.text-green { color: var(--accent); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-orange { color: var(--orange); }

/* =============================================
   THEME TOGGLE
   ============================================= */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0 10px 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.theme-toggle:hover {
  background: var(--nav-active-bg);
  color: var(--accent);
}

/* =============================================
   LIGHT THEME OVERRIDES
   ============================================= */
[data-theme="light"] .nav-sidebar { border-right: 1px solid var(--border); }
[data-theme="light"] .nav-logo { background: linear-gradient(135deg, #059669, #047857); }

[data-theme="light"] .main-content { background: var(--bg-body); }
[data-theme="light"] .view { background: var(--bg-body); }

[data-theme="light"] .stat-card,
[data-theme="light"] .dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

[data-theme="light"] .stat-icon { opacity: 0.9; }

[data-theme="light"] .data-table { border-collapse: collapse; }
[data-theme="light"] .data-table th {
  background: var(--table-header-bg);
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}
[data-theme="light"] .data-table td {
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
[data-theme="light"] .data-table tr:hover td { background: var(--bg-hover); }

[data-theme="light"] .modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
[data-theme="light"] .modal {
  background: rgba(0,0,0,0.3);
}

[data-theme="light"] .form-group input,
[data-theme="light"] .form-group select,
[data-theme="light"] .form-group textarea {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}
[data-theme="light"] .form-group input:focus,
[data-theme="light"] .form-group select:focus,
[data-theme="light"] .form-group textarea:focus {
  border-color: var(--accent);
}
[data-theme="light"] .form-group label { color: var(--text-secondary); }

[data-theme="light"] .btn-primary { background: var(--accent); color: #fff; }
[data-theme="light"] .btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  color: var(--text-primary);
}
[data-theme="light"] .btn-action { color: var(--blue); }
[data-theme="light"] .btn-action.delete { color: var(--red); }

[data-theme="light"] .search-bar input {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}
[data-theme="light"] .filter-btn {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-secondary);
}
[data-theme="light"] .filter-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme="light"] .badge { background: var(--badge-bg); color: var(--text-secondary); }

[data-theme="light"] .view-header h1 { color: var(--text-primary); }
[data-theme="light"] .view-subtitle { color: var(--text-tertiary); }

[data-theme="light"] .nav-user-name { color: var(--text-primary); }
[data-theme="light"] .nav-user-role { color: var(--text-tertiary); }
[data-theme="light"] .nav-user-avatar {
  background: var(--accent-bg);
  color: var(--accent);
}
[data-theme="light"] .nav-badge { background: var(--red); color: #fff; }

/* Light theme: cards, panels, sections */
[data-theme="light"] .linea-card {
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
[data-theme="light"] .linea-card-desc {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}
[data-theme="light"] .linea-card-num { background: var(--badge-bg); color: var(--text-secondary); }
[data-theme="light"] .linea-card:focus-within .linea-card-num { background: var(--accent); color: #fff; }
[data-theme="light"] .linea-card-fields input,
[data-theme="light"] .linea-card-fields select {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}
[data-theme="light"] .linea-card-base { color: var(--accent); }

[data-theme="light"] .factura-totales { color: var(--text-primary); background: var(--bg-input); border-color: var(--border); }
[data-theme="light"] .total-row { border-color: var(--border); color: var(--text-secondary); }
[data-theme="light"] .total-final { color: var(--text-primary); border-top-color: var(--border); }
[data-theme="light"] .total-final span:last-child { color: var(--accent); }

[data-theme="light"] .wizard-steps { border-bottom-color: var(--border); }
[data-theme="light"] .wizard-step { color: var(--text-muted); }
[data-theme="light"] .wizard-step.active { color: var(--accent); border-bottom-color: var(--accent); }
[data-theme="light"] .wizard-num { background: var(--badge-bg); color: var(--text-muted); }
[data-theme="light"] .wizard-step.active .wizard-num { background: var(--accent); color: #fff; }
[data-theme="light"] .wizard-nav { border-top-color: var(--border); }
[data-theme="light"] .wizard-resumen { background: var(--bg-input); border-color: var(--border); }

[data-theme="light"] .pre-resumen-cliente,
[data-theme="light"] .pre-resumen-residuo {
  background: var(--pre-section-bg);
  border-color: var(--pre-section-border);
}
[data-theme="light"] .pre-input-sm {
  background: var(--bg-card);
  border-color: var(--border-input);
  color: var(--text-primary);
}
[data-theme="light"] .pre-lineas-section input,
[data-theme="light"] .pre-lineas-section select {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}

[data-theme="light"] .contab-tabs { border-bottom-color: var(--border); }
[data-theme="light"] .contab-tab { color: var(--text-muted); }
[data-theme="light"] .contab-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

[data-theme="light"] .mayor-card,
[data-theme="light"] .balance-col,
[data-theme="light"] .af-asiento-section,
[data-theme="light"] .asiento-lineas-container {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="light"] .form-select-inline {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}

[data-theme="light"] .pre-section-title { color: var(--accent); border-bottom-color: var(--border); }

[data-theme="light"] .modelo-card {
  background: var(--bg-input);
  border-color: var(--border-input);
}
[data-theme="light"] .fiscal-divider { background: var(--border); }

[data-theme="light"] .albaran-di-banner {
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

/* Email views in light mode */
[data-theme="light"] .email-item { border-bottom-color: var(--border); }
[data-theme="light"] .email-item:hover { background: var(--bg-hover); }
[data-theme="light"] .email-view { background: var(--bg-card); border-color: var(--border); }
[data-theme="light"] .reply-panel { background: var(--bg-card); border-color: var(--border); }
[data-theme="light"] .reply-panel textarea {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}

/* Admin grid */
[data-theme="light"] .admin-grid .dash-card { background: var(--bg-card); border-color: var(--border); }

/* =============================================
   LIGHT THEME - COMPREHENSIVE OVERRIDES
   ============================================= */

/* Force all dark backgrounds to light */
[data-theme="light"] .main-content,
[data-theme="light"] .view,
[data-theme="light"] section { background: var(--bg-body); color: var(--text-primary); }

/* All cards, panels, containers */
[data-theme="light"] .stat-card,
[data-theme="light"] .dash-card,
[data-theme="light"] .modal-content,
[data-theme="light"] .linea-card,
[data-theme="light"] .mayor-card,
[data-theme="light"] .balance-col,
[data-theme="light"] .af-asiento-section,
[data-theme="light"] .asiento-lineas-container,
[data-theme="light"] .wizard-resumen,
[data-theme="light"] .modelo-card,
[data-theme="light"] .contab-panel,
[data-theme="light"] .pre-resumen-cliente,
[data-theme="light"] .pre-resumen-residuo {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

/* Deep backgrounds (inputs areas, nested panels) */
[data-theme="light"] .pre-lineas-section,
[data-theme="light"] .asiento-lineas-container,
[data-theme="light"] .af-asiento-section,
[data-theme="light"] #presupuesto-centro-form,
[data-theme="light"] #nc-centro-form,
[data-theme="light"] #pre-email-centro-form,
[data-theme="light"] .panel-section,
[data-theme="light"] .contrato-resumen,
[data-theme="light"] .cuenta-nivel-1 {
  background: var(--bg-input) !important;
  border-color: var(--border) !important;
}

/* Comprehensive light theme fix for all dark backgrounds */
[data-theme="light"] .modal-content,
[data-theme="light"] .contrato-step-card,
[data-theme="light"] .pre-resumen-cliente,
[data-theme="light"] .pre-resumen-residuo,
[data-theme="light"] .pre-resumen-grid,
[data-theme="light"] .contrato-linea-row select,
[data-theme="light"] .contrato-linea-row input,
[data-theme="light"] .contrato-linea-row .ler-search-wrap input {
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-input) !important;
}

[data-theme="light"] .contrato-linea-row .ler-dropdown {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
}

[data-theme="light"] .contrato-linea-row .ler-dropdown-item {
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

[data-theme="light"] .contrato-linea-row .ler-dropdown-item:hover {
  background: var(--accent-bg) !important;
}

[data-theme="light"] .di-option-btn {
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

/* ALL inputs, selects, textareas */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: var(--bg-input) !important;
  border-color: var(--border-input) !important;
  color: var(--text-primary) !important;
}
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  border-color: var(--accent) !important;
}
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder { color: var(--text-tertiary) !important; }
[data-theme="light"] input:disabled,
[data-theme="light"] select:disabled { opacity: 0.5; }

/* ALL table elements */
[data-theme="light"] .data-table { background: var(--bg-card); }
[data-theme="light"] .data-table th {
  background: var(--table-header-bg) !important;
  color: var(--text-secondary) !important;
  border-bottom: 2px solid var(--border) !important;
}
[data-theme="light"] .data-table td {
  border-bottom: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
}
[data-theme="light"] .data-table tr:nth-child(even) td { background: var(--table-stripe); }
[data-theme="light"] .data-table tr:hover td { background: var(--bg-hover) !important; }
[data-theme="light"] .table-empty { color: var(--text-tertiary) !important; }
[data-theme="light"] .total-row { background: var(--bg-input) !important; }
[data-theme="light"] .total-row td { border-top: 2px solid var(--border) !important; }

/* ALL text colors */
[data-theme="light"] h1, [data-theme="light"] h2, [data-theme="light"] h3, [data-theme="light"] h4 { color: var(--text-primary); }
[data-theme="light"] .view-subtitle { color: var(--text-tertiary); }
[data-theme="light"] .stat-label { color: var(--text-secondary); }
[data-theme="light"] .stat-value { color: var(--text-primary); }
[data-theme="light"] label { color: var(--text-secondary); }
[data-theme="light"] strong { color: var(--text-primary); }
[data-theme="light"] p { color: var(--text-secondary); }

/* Buttons */
[data-theme="light"] .btn-primary {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
[data-theme="light"] .btn-secondary {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-input) !important;
  color: var(--text-primary) !important;
}
[data-theme="light"] .btn-secondary:hover {
  background: var(--bg-hover) !important;
}
[data-theme="light"] .btn-action { color: var(--blue); }
[data-theme="light"] .btn-action.delete { color: var(--red); }
[data-theme="light"] .btn-action.accept { color: var(--accent); }
[data-theme="light"] .btn-action.launch { color: var(--orange); }
[data-theme="light"] .btn-icon { color: var(--text-tertiary); }
[data-theme="light"] .btn-icon:hover { color: var(--text-primary); }

/* Filter bar, search bar */
[data-theme="light"] .filter-btn {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-input) !important;
  color: var(--text-secondary) !important;
}
[data-theme="light"] .filter-btn:hover { background: var(--bg-hover) !important; }
[data-theme="light"] .filter-btn.active {
  background: var(--accent-bg) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
[data-theme="light"] .search-bar input {
  background: var(--bg-card) !important;
  border-color: var(--border-input) !important;
  color: var(--text-primary) !important;
}

/* Badges */
[data-theme="light"] .badge {
  background: var(--badge-bg) !important;
  color: var(--text-secondary) !important;
}
[data-theme="light"] .badge-completado, [data-theme="light"] .badge-aceptado, [data-theme="light"] .badge-pagada {
  background: rgba(5,150,105,0.12) !important;
  color: var(--accent) !important;
}
[data-theme="light"] .badge-cancelado, [data-theme="light"] .badge-rechazado, [data-theme="light"] .badge-anulado {
  background: rgba(220,38,38,0.1) !important;
  color: var(--red) !important;
}

/* Modal overlay */
[data-theme="light"] .modal { background: rgba(0,0,0,0.25) !important; }

/* Nav footer & user */
[data-theme="light"] .nav-footer { border-top: 1px solid var(--border); }
[data-theme="light"] .nav-user-avatar { background: var(--accent-bg); color: var(--accent); }

/* Contab tabs */
[data-theme="light"] .contab-tab { color: var(--text-muted); }
[data-theme="light"] .contab-tab:hover { color: var(--text-primary); }
[data-theme="light"] .contab-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Fiscal */
[data-theme="light"] .fiscal-label { color: var(--text-secondary); }
[data-theme="light"] .fiscal-value { color: var(--text-primary); }
[data-theme="light"] .fiscal-divider { background: var(--border); }

/* PyG resultado */
[data-theme="light"] .pyg-resultado {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text-primary);
}

/* Email module */
[data-theme="light"] .email-list { background: var(--bg-card); border-color: var(--border); }
[data-theme="light"] .email-item { border-bottom-color: var(--border); color: var(--text-primary); }
[data-theme="light"] .email-item:hover { background: var(--bg-hover); }
[data-theme="light"] .email-item.active { background: var(--accent-bg); }
[data-theme="light"] .email-view { background: var(--bg-card); border-color: var(--border); color: var(--text-primary); }
[data-theme="light"] .reply-panel { background: var(--bg-card); border-color: var(--border); }

/* Linea card fields */
[data-theme="light"] .linea-card-desc {
  background: var(--bg-input) !important;
  border-color: var(--border-input) !important;
  color: var(--text-primary) !important;
}
[data-theme="light"] .linea-card-fields label { color: var(--text-tertiary); }
[data-theme="light"] .linea-card-remove { color: var(--text-muted); }
[data-theme="light"] .linea-card-remove:hover { color: var(--red); }

/* Pre lineas header */
[data-theme="light"] .pre-lineas-header { border-bottom-color: var(--border); color: var(--text-tertiary); }

/* Wizard */
[data-theme="light"] .wizard-step.done { color: var(--text-secondary); border-bottom-color: var(--border-input); }
[data-theme="light"] .wizard-step.done .wizard-num { background: var(--accent-bg); color: var(--accent); }

/* Scrollbars */
[data-theme="light"] ::-webkit-scrollbar { width: 8px; }
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg-body); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border-input); border-radius: 4px; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* Typeahead (autocompletar de escribir) */
.typeahead-wrap { position: relative; }
.typeahead-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.typeahead-list.open { display: block; }
.typeahead-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.typeahead-item:last-child { border-bottom: none; }
.typeahead-item:hover, .typeahead-item.active {
  background: var(--accent-bg);
  color: var(--accent);
}
.typeahead-item .th-sub { font-size: 11px; color: var(--text-secondary); }
.typeahead-empty { padding: 10px 12px; color: var(--text-muted); font-size: 12px; font-style: italic; }

/* Selector de contratos tipo tarjetas */
.ct-card {
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color .15s, transform .05s;
  display: flex; flex-direction: column; gap: 6px;
}
.ct-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.ct-card.selected { border-color: var(--accent); background: var(--accent-bg); }
.ct-card.caducado { opacity: .6; }
.ct-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 2px; }
.ct-card-num { font-weight: 700; color: var(--accent); font-size: 14px; }
.ct-card-apodo { font-size: 13px; font-weight: 600; line-height: 1.3; }
.ct-card-meta { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }

/* Campos solo-lectura (val-box) en modal ver entrada */
.lbl-mini { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; display: block; margin-bottom: 4px; }
.val-box { padding: 8px 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text-primary); min-height: 18px; }

/* Adjunto chip */
.adj-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.adj-chip .adj-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adj-chip .adj-size { color: var(--text-muted); }
.adj-chip .adj-del { color: var(--red); cursor: pointer; background: none; border: none; font-size: 16px; padding: 0 4px; }

/* ---- Buscador de terceros (contratos): relevancia, teclado, alta inline ---- */
.search-dropdown { max-height: 380px; }
.ts-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; }
.ts-item.ts-active, .ts-add.ts-active { background: var(--accent-bg); box-shadow: inset 3px 0 0 var(--accent); }
.ts-avatar { width: 32px; height: 32px; border-radius: 8px; background: var(--accent-bg); color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.ts-body { flex: 1; min-width: 0; }
.ts-body .search-dropdown-item-name { font-size: 14px; }
.ts-body .search-dropdown-item-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-sep { margin: 0 6px; opacity: .5; }
.ts-apodo { font-weight: 500; color: var(--text-secondary); }
.ts-warn { color: #b45309; font-weight: 600; }
.ts-chips { display: flex; gap: 4px; flex-shrink: 0; }
.ts-chip { font-size: 10px; font-weight: 600; letter-spacing: .3px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); background: var(--bg-input); }
.ts-chip-main { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.search-dropdown mark { background: #fde68a; color: inherit; padding: 0; border-radius: 2px; }
[data-theme="dark"] .search-dropdown mark { background: #854d0e; }
.ts-header { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; color: var(--text-secondary); padding: 8px 12px 4px; }
.ts-header-warn { color: #b45309; text-transform: none; letter-spacing: 0; font-weight: 600; }
.ts-empty { padding: 12px; color: var(--text-secondary); font-size: 13px; }
.ts-more { padding: 6px 12px; font-size: 11.5px; color: var(--text-secondary); border-top: 1px dashed var(--border); }
.ts-add { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; border-top: 1px solid var(--border); color: var(--accent); font-weight: 600; font-size: 13px; background: var(--bg-card); position: sticky; bottom: 26px; }
.ts-add:hover { background: var(--accent-bg); }
.ts-add-plus { width: 28px; height: 28px; border-radius: 8px; border: 1.5px dashed var(--accent); display: flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1; }
.ts-add-hint { margin-left: auto; font-weight: 400; font-size: 11px; color: var(--text-secondary); }
.ts-footer { font-size: 10.5px; color: var(--text-secondary); padding: 5px 12px; border-top: 1px solid var(--border); background: var(--bg-input); position: sticky; bottom: 0; }
.ts-footer kbd { font-family: inherit; font-size: 10px; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-right: 2px; background: var(--bg-card); }

/* ================= Wizard Nuevo Contrato (rediseño) ================= */
#modal-contrato .modal-content { max-width: 880px; }
#modal-contrato .modal-header { margin-bottom: 8px; }
#modal-contrato .modal-header h3 { font-size: 22px; letter-spacing: -0.01em; }

/* Stepper */
#modal-contrato .cw-stepper { display: flex; gap: 0; margin: 6px 0 26px; padding: 0; position: relative; }
#modal-contrato .cw-stepper .contrato-step-dot {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; padding: 0; position: relative; color: var(--text-secondary); font-size: 12px; font-weight: 500; box-shadow: none;
}
#modal-contrato .cw-stepper .contrato-step-dot::before {
  content: ''; position: absolute; top: 14px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0;
}
#modal-contrato .cw-stepper .contrato-step-dot:last-child::before { display: none; }
#modal-contrato .cw-stepper .contrato-step-dot.done::before { background: var(--accent); }
#modal-contrato .cw-stepper .contrato-step-dot span {
  position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 2px solid var(--border); color: var(--text-secondary); font-size: 12px; font-weight: 700; margin: 0;
}
#modal-contrato .cw-stepper .contrato-step-dot em { font-style: normal; white-space: nowrap; }
#modal-contrato .cw-stepper .contrato-step-dot.active { color: var(--accent); font-weight: 700; background: none; box-shadow: none; }
#modal-contrato .cw-stepper .contrato-step-dot.active span { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-bg); }
#modal-contrato .cw-stepper .contrato-step-dot.done { color: var(--text-primary); }
#modal-contrato .cw-stepper .contrato-step-dot.done span { border-color: var(--accent); background: var(--accent); color: #fff; font-size: 0; }
#modal-contrato .cw-stepper .contrato-step-dot.done span::after { content: ''; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }

/* Cabecera de paso */
.cw-step-head { margin: 0 0 14px; }
.cw-step-title { margin: 0 0 4px; font-size: 17px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.cw-req { color: #dc2626; font-weight: 700; }
.cw-step-help { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.45; max-width: 68ch; }

/* Buscador */
#modal-contrato .contrato-step-card { padding: 0; }
#modal-contrato .contrato-step-label { font-size: 11px; letter-spacing: .6px; color: var(--text-secondary); margin-bottom: 6px; }
.cw-search-wrap { position: relative; }
.cw-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); pointer-events: none; }
#modal-contrato .cw-search-input {
  width: 100%; font-size: 15px; padding: 13px 14px 13px 42px; border-radius: 10px;
  border: 1.5px solid var(--border-input); background: var(--bg-input); color: var(--text-primary); outline: none; box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
#modal-contrato .cw-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); }
#modal-contrato .search-dropdown { border-radius: 12px; top: calc(100% + 6px); box-shadow: 0 12px 32px rgba(0,0,0,.14); }

/* Tarjeta de seleccionado */
#modal-contrato .tercero-selected-card { margin-top: 0; border: 1px solid var(--accent-border); border-radius: 12px; background: var(--bg-card); }
#modal-contrato .tercero-selected-head { padding: 12px 14px; gap: 10px; background: var(--accent-bg); border-bottom: 1px solid var(--accent-border); }
#modal-contrato .tercero-selected-check { display: flex; color: var(--accent); font-size: 0; line-height: 0; }
#modal-contrato .tercero-selected-card .selected-card-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
#modal-contrato .cw-change { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent-border); background: var(--bg-card); cursor: pointer; }
#modal-contrato .cw-change:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
#modal-contrato .tercero-selected-detalles { padding: 14px 16px; gap: 10px 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
#modal-contrato .tercero-detalle-label { font-size: 10px; letter-spacing: .5px; }
#modal-contrato .tercero-detalle-value { font-size: 13.5px; }
#modal-contrato .tercero-detalle-value .selected-card-btn { padding: 3px 10px; font-size: 12px; border-radius: 6px; }
.cw-skip-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.cw-skip-hint { font-size: 12px; color: var(--text-secondary); }
#modal-contrato .selected-card:not(.hidden) ~ .cw-skip-row { display: none; }

/* Partes (paso 4) */
#modal-contrato .cw-partes { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; gap: 8px; margin-bottom: 18px; color: inherit; }
.cw-parte { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
.cw-parte:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.cw-parte-rol { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
.cw-parte-nombre { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cw-parte-nombre.cw-parte-vacio { color: var(--text-secondary); font-weight: 500; font-style: italic; }
.cw-parte-arrow { color: var(--text-secondary); font-size: 14px; flex-shrink: 0; }

/* Secciones */
.cw-section { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; background: var(--bg-card); }
.cw-section-title { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; display: flex; align-items: baseline; gap: 10px; }
.cw-section-sub { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-secondary); font-size: 12px; }
#modal-contrato .cw-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
#modal-contrato .cw-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { #modal-contrato .cw-grid-3, #modal-contrato .cw-grid-2 { grid-template-columns: 1fr; } }
#modal-contrato .cw-section .form-group { margin: 0; }
#modal-contrato .cw-section .form-group label { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }

/* ===== Modal Subproducto (misma estética que contratos) ===== */
#modal-subproducto .cw-section .form-group { margin: 0; }
#modal-subproducto .cw-section .form-group label { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 6px; display: block; }
#modal-subproducto .cw-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { #modal-subproducto .cw-grid-2 { grid-template-columns: 1fr; } }
#modal-subproducto .cw-search-input {
  width: 100%; font-size: 15px; padding: 13px 14px 13px 42px; border-radius: 10px;
  border: 1.5px solid var(--border-input); background: var(--bg-input); color: var(--text-primary); outline: none; box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
#modal-subproducto .cw-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); }
#modal-subproducto .search-dropdown { border-radius: 12px; top: calc(100% + 6px); box-shadow: 0 12px 32px rgba(0,0,0,.14); }
#modal-subproducto .tercero-selected-card { margin-top: 10px; border: 1px solid var(--accent-border); border-radius: 12px; background: var(--bg-card); }
#modal-subproducto .tercero-selected-head { padding: 12px 14px; gap: 10px; background: var(--accent-bg); border-radius: 12px; }
#modal-subproducto .tercero-selected-check { display: flex; color: var(--accent); }
#modal-subproducto .tercero-selected-card .selected-card-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
#modal-subproducto .cw-change { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent-border); background: var(--bg-card); cursor: pointer; margin-left: auto; }
#modal-subproducto .cw-change:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
#modal-subproducto .sub-importe-box { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-radius: 12px; background: var(--accent-bg); border: 1px solid var(--accent-border); }
#modal-subproducto .sub-importe-box span:first-child { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
#modal-subproducto .sub-importe-box span:last-child { font-size: 22px; font-weight: 800; color: var(--accent); }
#modal-subproducto select, #modal-subproducto input[type="date"], #modal-subproducto input[type="number"], #modal-subproducto input[type="text"]:not(.cw-search-input) {
  border-radius: 10px; border: 1.5px solid var(--border-input); padding: 11px 12px;
}

/* Líneas del contrato: fila principal + panel de precios desplegable */
#modal-contrato .cw-lineas-head, #modal-contrato .cl-main {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) 150px 32px; gap: 8px; align-items: center;
}
#modal-contrato .cw-lineas-head { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); padding: 0 0 6px; }
#modal-contrato .contrato-linea-row { display: block; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: var(--bg-card); }
#modal-contrato .cl-main { width: 100%; }
#modal-contrato .contrato-linea-row .ler-search-wrap { min-width: 0; }
#modal-contrato .contrato-linea-row select, #modal-contrato .contrato-linea-row input { border-radius: 8px; padding: 9px 10px; min-width: 0; }
#modal-contrato .contrato-linea-remove { width: 32px; height: 32px; border-radius: 8px; color: var(--text-secondary); }
#modal-contrato .contrato-linea-remove:hover { color: #dc2626; background: #fee2e2; }

/* Botón toggle de precios */
#modal-contrato .cl-precios-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border-input); border-radius: 8px;
  background: var(--bg-input); color: var(--text-primary); font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: border-color .15s, background .15s;
}
#modal-contrato .cl-precios-toggle:hover { border-color: var(--accent); }
#modal-contrato .cl-precios-resumen.cl-vacio { color: var(--text-secondary); font-weight: 500; }
#modal-contrato .cl-chevron { flex-shrink: 0; transition: transform .18s ease; color: var(--text-secondary); }
#modal-contrato .cl-abierto .cl-chevron { transform: rotate(180deg); }

/* Panel de precios: se desliza */
#modal-contrato .cl-precios-panel {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .22s ease, opacity .18s ease, margin-top .22s ease, padding-top .22s ease;
}
#modal-contrato .cl-abierto .cl-precios-panel { max-height: 140px; opacity: 1; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
#modal-contrato .cl-precios-panel .form-group { margin: 0; }
#modal-contrato .cl-precios-panel label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 5px; }
#modal-contrato .cl-precios-panel input { width: 100%; }

.cw-add-linea { margin-top: 4px; }
@media (max-width: 700px) {
  #modal-contrato .cw-lineas-head { display: none; }
  #modal-contrato .cl-main { grid-template-columns: 1fr 1fr; }
  #modal-contrato .cl-precios-panel { grid-template-columns: 1fr; }
}

/* Inputs con unidad y grandes */
.cw-input-unit { display: flex; align-items: stretch; }
.cw-input-unit input { flex: 1; border-radius: 8px 0 0 8px !important; }
.cw-input-unit span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-input); border-left: none; border-radius: 0 8px 8px 0; background: var(--bg-input); color: var(--text-secondary); font-size: 13px; font-weight: 600; }
#modal-contrato .cw-input-lg { font-size: 16px; padding: 13px 14px; }
.cw-final-resumen { margin-top: 16px; }
.cw-final-title { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.cw-final-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 16px; }
.cw-final-grid div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cw-final-grid span { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
.cw-final-grid strong { font-size: 13px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Navegación */
#modal-contrato .cw-nav { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.cw-nav-counter { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
/* El desplegable del buscador del wizard va en flujo (el modal recorta lo absoluto) */
#modal-contrato .cw-search-wrap .search-dropdown { position: static; margin-top: 8px; max-height: 360px; }
#modal-contrato .cw-search-wrap .ts-add, #modal-contrato .cw-search-wrap .ts-footer { position: static; }
#modal-tercero { z-index: 150; } /* se abre sobre el wizard de contrato */

/* Botón "Nuevo X" fijo junto al buscador */
.cw-search-row { display: flex; gap: 10px; align-items: flex-start; }
.cw-search-row .cw-search-wrap { flex: 1; min-width: 0; }
#modal-contrato .cw-nuevo { flex-shrink: 0; height: 50px; padding: 0 16px; border-radius: 10px; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; border: 1.5px dashed var(--accent); color: var(--accent); background: var(--bg-card); text-transform: capitalize; }
#modal-contrato .cw-nuevo:hover { background: var(--accent); color: #fff; border-style: solid; }
.cw-nuevo-plus { font-size: 18px; line-height: 1; font-weight: 700; }

/* ---- Acciones de fila integradas (tablas) ---- */
.action-btns.ra { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; white-space: nowrap; }
.ra-primary { height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--accent-border); background: var(--accent-bg); color: var(--accent); font-weight: 600; font-size: 12.5px; cursor: pointer; font-family: inherit; margin-right: 4px; white-space: nowrap; }
.ra-primary:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.ra-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; transition: background .12s, color .12s, border-color .12s; }
.ra-btn:hover { background: var(--bg-input); border-color: var(--border); color: var(--text-primary); }
.ra-btn.ra-danger:hover { background: #fee2e2; border-color: #fecaca; color: #dc2626; }
[data-theme="dark"] .ra-btn.ra-danger:hover { background: rgba(220,38,38,.18); border-color: rgba(220,38,38,.35); color: #f87171; }
.ra-btn:focus-visible, .ra-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ================= Asistente Generar DI ================= */
#modal-generar-di .modal-content.diw { max-width: 760px; }
.diw-ctx { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.diw-ctx-num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: var(--accent); background: var(--accent-bg); border: 1px solid var(--accent-border); border-radius: 6px; padding: 2px 8px; }
.diw-ctx-chain { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.diw-ctx-rol { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.diw-ctx-chain strong { color: var(--text-primary); font-weight: 600; }
.diw-ctx-arrow { opacity: .5; }
#modal-generar-di .diw-stepper { margin: 14px 0 22px; }
#modal-generar-di .diw-stepper .contrato-step-dot { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; padding: 0; position: relative; color: var(--text-secondary); font-size: 12px; font-weight: 500; box-shadow: none; }
#modal-generar-di .diw-stepper .contrato-step-dot::before { content: ''; position: absolute; top: 14px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
#modal-generar-di .diw-stepper .contrato-step-dot:last-child::before { display: none; }
#modal-generar-di .diw-stepper .contrato-step-dot.done::before { background: var(--accent); }
#modal-generar-di .diw-stepper .contrato-step-dot span { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 2px solid var(--border); color: var(--text-secondary); font-size: 12px; font-weight: 700; margin: 0; }
#modal-generar-di .diw-stepper .contrato-step-dot em { font-style: normal; }
#modal-generar-di .diw-stepper .contrato-step-dot.active { color: var(--accent); font-weight: 700; background: none; }
#modal-generar-di .diw-stepper .contrato-step-dot.active span { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-bg); }
#modal-generar-di .diw-stepper .contrato-step-dot.done span { border-color: var(--accent); background: var(--accent); color: #fff; font-size: 0; }
#modal-generar-di .diw-stepper .contrato-step-dot.done span::after { content: ''; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.diw-opt { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-secondary); margin-left: 4px; }

/* Tarjetas de residuo */
.diw-residuos { display: grid; grid-template-columns: 1fr; gap: 8px; }
.diw-residuo { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--bg-card); cursor: pointer; font-family: inherit; transition: border-color .12s, box-shadow .12s; }
.diw-residuo:hover { border-color: var(--accent); }
.diw-residuo.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); background: var(--accent-bg); }
.diw-ler { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; font-size: 15px; letter-spacing: 1px; color: var(--accent); background: var(--bg-card); border: 1px solid var(--accent-border); border-radius: 8px; padding: 6px 10px; flex-shrink: 0; }
.diw-ler-sm { font-size: 12px; padding: 1px 6px; }
.diw-residuo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.diw-residuo-desc { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.diw-residuo-op { font-size: 12px; color: var(--text-secondary); }
.diw-peligroso { align-self: flex-start; margin-top: 3px; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: #b45309; background: #fef3c7; border-radius: 4px; padding: 1px 6px; }
.diw-residuo-check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; color: transparent; flex-shrink: 0; }
.diw-residuo.active .diw-residuo-check { border-color: var(--accent); background: var(--accent); color: #fff; }
.diw-otro { margin: 8px 0 12px; font-size: 12.5px; padding: 2px 0; }
#modal-generar-di .cw-section { margin-bottom: 12px; }

/* Matrícula */
.diw-matricula-group { max-width: 280px; }
#modal-generar-di .diw-matricula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 24px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; text-align: center; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--border-input); background: var(--bg-input); color: var(--text-primary); width: 100%; box-sizing: border-box; }
#modal-generar-di .diw-matricula:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); outline: none; }
#modal-generar-di .vehiculo-pill, #modal-generar-di .vehiculo-nuevo-panel { margin-top: 12px; }
.diw-matricula-sm { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: 1.5px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; }

/* Resumen y zonas */
.diw-resumen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 18px; }
.diw-res-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.diw-res-k { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
.diw-res-v { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.diw-res-s { font-size: 11.5px; color: var(--text-secondary); }
.diw-zonas { display: flex; gap: 6px; }
.diw-zona { flex: 1; padding: 9px 8px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg-card); color: var(--text-secondary); font-weight: 600; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.diw-zona.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
@media (max-width: 700px) { .diw-resumen { grid-template-columns: 1fr 1fr; } }

.ra-primary-danger { color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.ra-primary-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.ra-done { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 8px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-secondary); font-size: 12px; font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ra-done svg { color: var(--accent); }
a.ra-btn { text-decoration: none; }

/* ================= Selector de fecha propio ================= */
.rdp-wrap { position: relative; }
.rdp-native { position: absolute !important; opacity: 0; width: 1px; height: 1px; pointer-events: none; left: 0; top: 0; }
.rdp-field { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; font-family: inherit; font-size: 14px; color: var(--text-primary); background: var(--bg-input); border: 1px solid var(--border-input); border-radius: 8px; padding: 9px 12px; cursor: pointer; box-sizing: border-box; min-height: 40px; }
.rdp-field:hover { border-color: var(--accent); }
.rdp-active .rdp-field, .rdp-field:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); outline: none; }
.rdp-empty .rdp-text { color: var(--text-secondary); }
.rdp-icon { color: var(--text-secondary); display: flex; }
.rdp-wrap .rdp-field[disabled] { opacity: .6; cursor: default; }
.rdp-pop { position: fixed; z-index: 500; display: none; width: 292px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.18); padding: 12px; font-family: inherit; }
.rdp-pop.rdp-open { display: block; animation: rdp-in .12s ease-out; }
@keyframes rdp-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .rdp-pop.rdp-open { animation: none; } }
.rdp-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.rdp-nav { width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.rdp-nav:hover { background: var(--bg-input); border-color: var(--border); color: var(--text-primary); }
.rdp-title { display: flex; gap: 4px; flex: 1; justify-content: center; }
.rdp-title select { appearance: none; -webkit-appearance: none; border: 1px solid transparent; background: transparent; font-family: inherit; font-weight: 700; font-size: 14px; color: var(--text-primary); padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.rdp-title select:hover { background: var(--bg-input); border-color: var(--border); }
.rdp-dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 10.5px; font-weight: 700; letter-spacing: .5px; color: var(--text-secondary); margin-bottom: 4px; }
.rdp-dow span:nth-child(6), .rdp-dow span:nth-child(7) { color: #b45309; }
.rdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.rdp-day { height: 34px; border-radius: 8px; border: 1px solid transparent; background: transparent; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text-primary); cursor: pointer; font-variant-numeric: tabular-nums; }
.rdp-day:hover { background: var(--accent-bg); color: var(--accent); }
.rdp-day:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rdp-out { color: var(--text-secondary); opacity: .5; }
.rdp-we { color: #b45309; }
.rdp-today-day { border-color: var(--accent); font-weight: 700; }
.rdp-sel, .rdp-sel:hover { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; box-shadow: 0 2px 8px rgba(16,185,129,.35); }
.rdp-dis { opacity: .3; cursor: not-allowed; }
.rdp-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.rdp-link { background: none; border: none; color: var(--text-secondary); font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.rdp-link:hover { background: var(--bg-input); color: var(--text-primary); }
.rdp-today { color: var(--accent); }
.rdp-today:hover { background: var(--accent-bg); color: var(--accent); }

/* ================= Previsualización de planificación (DI paso 3) ================= */
.diw-preview { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.diw-pv-day { border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg-card); min-height: 120px; display: flex; flex-direction: column; cursor: pointer; transition: border-color .12s, box-shadow .12s; overflow: hidden; }
.diw-pv-day:hover { border-color: var(--accent); }
.diw-pv-day-sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.diw-pv-day-we { background: var(--bg-input); }
.diw-pv-head { display: flex; align-items: baseline; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.diw-pv-dow { font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--text-secondary); }
.diw-pv-num { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.diw-pv-day-hoy .diw-pv-num { color: var(--accent); }
.diw-pv-total { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--text-secondary); }
.diw-pv-body { padding: 6px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.diw-pv-item { border-radius: 7px; padding: 5px 7px; background: var(--bg-input); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.diw-pv-item.diw-pv-new { background: var(--accent-bg); border: 1.5px dashed var(--accent); }
.diw-pv-zona { font-size: 9px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--text-secondary); }
.diw-pv-new .diw-pv-zona { color: var(--accent); }
.diw-pv-name { font-size: 11px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diw-pv-tn { font-size: 10px; color: var(--text-secondary); }
.diw-pv-empty { font-size: 11px; color: var(--text-secondary); opacity: .7; text-align: center; padding: 10px 0; }
.diw-pv-loading { grid-column: 1 / -1; padding: 20px; text-align: center; color: var(--text-secondary); font-size: 13px; }
.diw-preview-legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11.5px; color: var(--text-secondary); }
.diw-pv-dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; margin-left: 10px; }
.diw-pv-dot.diw-pv-new { background: var(--accent-bg); border: 1.5px dashed var(--accent); margin-left: 0; }
.diw-pv-dot.diw-pv-ex { background: var(--bg-input); border: 1px solid var(--border); }
#modal-generar-di .modal-content.diw { max-width: 860px; }
@media (max-width: 760px) { .diw-preview { grid-template-columns: repeat(4, 1fr); } }

.diw-pv-day { min-height: 96px; }
.diw-pv-day-past { opacity: .45; }
.diw-pv-num small { font-size: 10px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; }
.diw-preview-legend { justify-content: flex-end; }

/* ================= Planificación: tablero semanal (rediseño) ================= */
#view-planificacion .plan-week-nav { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 16px; }
#view-planificacion .plan-week-label span:first-child { font-size: 17px; }
#view-planificacion .plan-grid-container { overflow: visible; }
#view-planificacion .plan-grid { table-layout: fixed; width: 100%; border-radius: 14px; background: var(--bg-card); }
#view-planificacion .plan-zone-header { width: 170px; min-width: 0; font-size: 10.5px; letter-spacing: .6px; padding: 12px 14px; vertical-align: bottom; }
#view-planificacion .plan-day-header { min-width: 0; padding: 10px 6px 8px; vertical-align: bottom; position: relative; }
#view-planificacion .plan-day-name { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
#view-planificacion .plan-day-date { display: block; font-size: 11px; font-weight: 500; color: var(--text-secondary); margin-top: 1px; }
#view-planificacion .plan-day-count { position: absolute; top: 8px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-secondary); font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
#view-planificacion .plan-day-header.plan-today { background: var(--accent-bg); }
#view-planificacion .plan-day-header.plan-today .plan-day-name, #view-planificacion .plan-day-header.plan-today .plan-day-date { color: var(--accent); }
#view-planificacion .plan-day-header.plan-today .plan-day-count { background: var(--accent); border-color: var(--accent); color: #fff; }
#view-planificacion .plan-day-header[data-day="6"], #view-planificacion .plan-day-header[data-day="0"] { background: var(--bg-input); }
#view-planificacion .plan-zone-name { display: table-cell; padding: 10px 14px; vertical-align: top; white-space: normal; background: var(--bg-card); }
.plan-zone { display: flex; align-items: center; gap: 10px; }
.plan-zone-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.plan-zone-nom { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.plan-zone-sub { font-size: 11px; color: var(--text-secondary); }
#view-planificacion .plan-cell { height: auto; min-height: 0; padding: 6px; vertical-align: top; background: var(--bg-body); }
#view-planificacion .plan-cell[data-day="6"], #view-planificacion .plan-cell[data-day="0"] { background: var(--bg-input); }
#view-planificacion .plan-cell.plan-today-col { background: rgba(16,185,129,.05); box-shadow: inset 0 0 0 1px var(--accent-border); }
#view-planificacion .plan-cell:hover { background: var(--accent-bg); }
#view-planificacion tbody tr td { height: 118px; }
#view-planificacion .plan-task { border-radius: 8px; border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 6px 8px; margin-bottom: 5px; background: var(--bg-card); }
#view-planificacion .plan-task:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.plan-task-top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.plan-task-hora { font-size: 10px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; flex-shrink: 0; }
#view-planificacion .plan-task-desc { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.plan-task-ok { color: var(--accent); display: flex; flex-shrink: 0; }
#view-planificacion .plan-task-meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 3px; font-size: 10px; }
.plan-task-ler { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: var(--accent); background: var(--accent-bg); border-radius: 4px; padding: 0 4px; }
.plan-task-tn { color: var(--text-secondary); font-weight: 600; }
.plan-task-prod { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.plan-task-cta { margin-top: 4px; font-size: 10px; font-weight: 700; color: #b45309; }
.plan-task-pendiente { border-left-color: #f59e0b; background: #fffbeb; }
[data-theme="dark"] .plan-task-pendiente { background: rgba(245,158,11,.12); }
#view-planificacion .plan-task[data-tipo="registrada"] { opacity: 1; background: var(--accent-bg); }
#view-planificacion .plan-cell-add { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--text-secondary); border: 1.5px dashed var(--border); border-radius: 8px; padding: 6px; opacity: 0; transition: opacity .12s; }
#view-planificacion .plan-cell:hover .plan-cell-add { opacity: 1; color: var(--accent); border-color: var(--accent); }
#view-planificacion .plan-cell:not(:has(.plan-task)) .plan-cell-add { opacity: .55; }
@media (max-width: 1100px) { #view-planificacion .plan-zone-sub { display: none; } #view-planificacion .plan-zone-header { width: 120px; } }

/* ================= Botón y flujo "Nueva entrada de residuo" ================= */
.nav-cta-wrap { padding: 12px 12px 4px; }
.nav-cta { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: none; cursor: pointer; font-family: inherit; text-align: left; color: #fff; background: linear-gradient(135deg, var(--accent), #047857); box-shadow: 0 6px 16px rgba(16,185,129,.28); transition: transform .12s, box-shadow .12s; }
.nav-cta:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(16,185,129,.35); }
.nav-cta:active { transform: none; }
.nav-cta-icon { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-cta-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.nav-cta-txt span { font-size: 13.5px; font-weight: 700; }
.nav-cta-txt small { font-size: 10.5px; opacity: .85; font-weight: 500; }
.nav-sidebar.collapsed .nav-cta-txt { display: none; }

#modal-nueva-entrada .modal-content.ne { max-width: 720px; }
.ne-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; max-width: 60ch; }
.ne-flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 18px; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); }
.ne-flow-step { padding: 4px 10px; border-radius: 999px; background: var(--bg-input); border: 1px solid var(--border); }
.ne-flow-step.ne-flow-on { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.ne-flow-arrow { opacity: .5; }
.ne-q { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
.ne-back { margin: 0; padding: 2px 6px; font-size: 12.5px; }
.ne-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ne-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; padding: 20px 20px 18px; min-height: 190px; border: 1.5px solid var(--border); border-radius: 16px; background: var(--bg-card); cursor: pointer; font-family: inherit; transition: border-color .12s, box-shadow .12s, transform .12s; }
.ne-choice:hover, .ne-choice:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); transform: translateY(-1px); outline: none; }
.ne-choice-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-bg); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.ne-choice-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.ne-choice-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.ne-choice-hint { margin-top: auto; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--accent); }
.ne-ct-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 420px; overflow-y: auto; }
.ne-ct { display: grid; grid-template-columns: 1fr auto auto 24px; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--bg-card); cursor: pointer; font-family: inherit; }
.ne-ct:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.ne-ct-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ne-ct-apodo { font-size: 14px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ne-ct-prod { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ne-ct-lers { display: flex; gap: 4px; align-items: center; }
.ne-ct-more { font-size: 11px; color: var(--text-secondary); font-weight: 600; }
.ne-ct-num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--text-secondary); }
.ne-ct-go { color: var(--text-secondary); display: flex; }
.ne-ct:hover .ne-ct-go { color: var(--accent); }
@media (max-width: 640px) { .ne-choices { grid-template-columns: 1fr; } .ne-ct { grid-template-columns: 1fr 24px; } .ne-ct-lers, .ne-ct-num { display: none; } }
#modal-nueva-entrada .cw-search-input { width: 100%; font-size: 15px; padding: 13px 14px 13px 42px; border-radius: 10px; border: 1.5px solid var(--border-input); background: var(--bg-input); color: var(--text-primary); outline: none; box-sizing: border-box; }
#modal-nueva-entrada .cw-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); }
#modal-nueva-entrada .cw-nuevo { flex-shrink: 0; height: 50px; padding: 0 16px; border-radius: 10px; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; border: 1.5px dashed var(--accent); color: var(--accent); background: var(--bg-card); }
#modal-nueva-entrada .cw-nuevo:hover { background: var(--accent); color: #fff; border-style: solid; }

/* Nombre resaltado como un único elemento (el contenedor es flex) y lupa anclada al campo */
.ts-name { display: inline; white-space: normal; }
.ts-name mark, .ts-apodo mark, .search-dropdown-item-info mark { display: inline; }
#modal-contrato .cw-search-wrap .cw-search-icon, #modal-nueva-entrada .cw-search-wrap .cw-search-icon { top: 25px; transform: translateY(-50%); }

#modal-contrato .cw-invalid { border-color: #dc2626 !important; box-shadow: 0 0 0 3px #fee2e2 !important; }

.diw-sin-lineas { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1.5px dashed #f59e0b; background: #fffbeb; border-radius: 12px; margin-bottom: 12px; }
[data-theme="dark"] .diw-sin-lineas { background: rgba(245,158,11,.1); }
.diw-sin-lineas-txt { flex: 1; font-size: 13px; color: var(--text-primary); line-height: 1.45; }
.diw-sin-lineas .btn { flex-shrink: 0; }
#modal-generar-di .cw-grid-2 select, #modal-generar-di .cw-grid-2 input { width: 100%; min-width: 0; box-sizing: border-box; }
#modal-generar-di .cw-grid-2 .form-group { min-width: 0; }
#di-wizard-next[disabled] { opacity: .5; cursor: not-allowed; }

.ne-ct-sinler { border-style: dashed; background: var(--bg-input); }
.ne-ct-warn { font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: #b45309; background: #fef3c7; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

/* ================= Ficha de entrada programada ================= */
#modal-plan-entrada .modal-content.pe { max-width: 680px; }
.pe-head { min-width: 0; }
.pe-kicker { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.pe-kicker-warn { color: #b45309; }
#pe-titulo { font-size: 22px; letter-spacing: -0.01em; }
.pe-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pe-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-secondary); display: inline-flex; gap: 6px; align-items: center; }
.pe-chip-di { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-border); }
.pe-chip-di a { color: var(--accent); text-decoration: underline; font-family: inherit; }
.pe-chip-ext { color: #b45309; background: #fef3c7; border-color: #fcd34d; }
.pe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); margin: 16px 0; }
.pe-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pe-k { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
.pe-v { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.pe-s { font-size: 11.5px; color: var(--text-secondary); }
.pe-repro { border: 1.5px dashed var(--accent); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; background: var(--accent-bg); }
.pe-repro .form-group { margin: 0; }
.pe-repro-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.pe-actions { display: flex; align-items: center; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pe-danger { color: #dc2626; }
.pe-danger:hover { background: #fee2e2; border-color: #fecaca; }
.pe-primary { padding: 10px 18px; font-weight: 700; }
@media (max-width: 640px) { .pe-grid { grid-template-columns: 1fr 1fr; } }

/* ================= Registrar llegada / pesaje ================= */
#modal-plan-registrar .modal-content.reg { max-width: 720px; }
.reg-ctx { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }
.reg-ctx > span:first-child { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: var(--accent); }
.reg-ctx-sep { opacity: .5; }
.reg-pesaje { border: 1.5px solid var(--accent-border); background: var(--accent-bg); border-radius: 14px; padding: 16px 18px; margin: 14px 0; }
.reg-pesaje-title { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.reg-pesaje-grid { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 14px; align-items: end; }
.reg-pesaje-grid .form-group { margin: 0; }
.reg-pesaje-grid .form-group label { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
#modal-plan-registrar .reg-num { font-size: 22px; font-weight: 700; text-align: right; padding: 10px 12px; font-variant-numeric: tabular-nums; }
.reg-neto { background: var(--bg-card); border: 2px solid var(--accent); border-radius: 12px; padding: 8px 14px; text-align: right; }
.reg-neto-label { font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--text-secondary); }
#plan-reg-neto { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.1; font-variant-numeric: tabular-nums; }
#modal-plan-registrar .reg-matricula { font-size: 20px; padding: 10px 12px; }
#modal-plan-registrar .cw-section .form-group { margin: 0; }
.reg-externo { border-color: #fcd34d; background: #fffbeb; }
[data-theme="dark"] .reg-externo { background: rgba(245,158,11,.1); }
.reg-adjuntos { display: grid; gap: 6px; margin-top: 8px; }
@media (max-width: 640px) { .reg-pesaje-grid { grid-template-columns: 1fr; } }
.reg-pesaje-grid > * { min-width: 0; }
.reg-pesaje-grid .cw-input-unit input, #modal-plan-registrar .cw-grid-2 select, #modal-plan-registrar .cw-grid-2 input { width: 100%; min-width: 0; box-sizing: border-box; }
#modal-plan-registrar .cw-grid-2 > * { min-width: 0; }
.reg-neto { min-width: 0; overflow: hidden; }

.diw-matriculas { display: grid; grid-template-columns: 280px 280px; gap: 14px; }
#modal-generar-di .diw-matricula-sec { font-size: 18px; letter-spacing: 2px; }
@media (max-width: 700px) { .diw-matriculas { grid-template-columns: 1fr; } }

/* ================= Wizard Presupuesto (mismo sistema visual) ================= */
#modal-presupuesto .modal-content { max-width: 920px; }
#modal-presupuesto .modal-header h3 { font-size: 22px; letter-spacing: -0.01em; }
#modal-presupuesto .wizard-steps.cw-stepper { display: flex; gap: 0; margin: 6px 0 26px; padding: 0; border: none; background: none; }
#modal-presupuesto .cw-stepper .wizard-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; border-bottom: none; padding: 0; position: relative; color: var(--text-secondary); font-size: 12px; font-weight: 500; box-shadow: none; }
#modal-presupuesto .cw-stepper .wizard-step::before { content: ''; position: absolute; top: 14px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
#modal-presupuesto .cw-stepper .wizard-step:last-child::before { display: none; }
#modal-presupuesto .cw-stepper .wizard-step.done::before { background: var(--accent); }
#modal-presupuesto .cw-stepper .wizard-num { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 2px solid var(--border); color: var(--text-secondary); font-size: 12px; font-weight: 700; margin: 0; }
#modal-presupuesto .cw-stepper .wizard-step em { font-style: normal; white-space: nowrap; }
#modal-presupuesto .cw-stepper .wizard-step.active { color: var(--accent); font-weight: 700; background: none; border-bottom: none; }
#modal-presupuesto .cw-stepper .wizard-step.active .wizard-num { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-bg); }
#modal-presupuesto .cw-stepper .wizard-step.done { color: var(--text-primary); }
#modal-presupuesto .cw-stepper .wizard-step.done .wizard-num { border-color: var(--accent); background: var(--accent); color: #fff; font-size: 0; }
#modal-presupuesto .cw-stepper .wizard-step.done .wizard-num::after { content: ''; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
#modal-presupuesto .contrato-step-card { padding: 0; }
#modal-presupuesto .contrato-step-label { font-size: 11px; letter-spacing: .6px; color: var(--text-secondary); margin-bottom: 6px; display: block; font-weight: 700; text-transform: uppercase; }
#modal-presupuesto .cw-search-input { width: 100%; font-size: 15px; padding: 13px 14px 13px 42px; border-radius: 10px; border: 1.5px solid var(--border-input); background: var(--bg-input); color: var(--text-primary); outline: none; box-sizing: border-box; }
#modal-presupuesto .cw-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); }
#modal-presupuesto .cw-search-wrap .cw-search-icon { top: 25px; transform: translateY(-50%); }
#modal-presupuesto .cw-search-wrap .search-dropdown { position: static; margin-top: 8px; max-height: 360px; border-radius: 12px; }
#modal-presupuesto .cw-search-wrap .ts-add, #modal-presupuesto .cw-search-wrap .ts-footer { position: static; }
#modal-presupuesto .cw-nuevo { flex-shrink: 0; height: 50px; padding: 0 16px; border-radius: 10px; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; border: 1.5px dashed var(--accent); color: var(--accent); background: var(--bg-card); }
#modal-presupuesto .cw-nuevo:hover { background: var(--accent); color: #fff; border-style: solid; }
#modal-presupuesto .tercero-selected-card { margin-top: 0; border: 1px solid var(--accent-border); border-radius: 12px; background: var(--bg-card); }
#modal-presupuesto .tercero-selected-head { padding: 12px 14px; gap: 10px; background: var(--accent-bg); border-bottom: 1px solid var(--accent-border); }
#modal-presupuesto .tercero-selected-check { display: flex; color: var(--accent); font-size: 0; line-height: 0; }
#modal-presupuesto .tercero-selected-card .selected-card-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
#modal-presupuesto .cw-change { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent-border); background: var(--bg-card); cursor: pointer; }
#modal-presupuesto .cw-change:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
#modal-presupuesto .tercero-selected-detalles { padding: 14px 16px; gap: 10px 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
#modal-presupuesto .cw-section { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin: 14px 0 0; background: var(--bg-card); }
#modal-presupuesto .cw-section .form-group { margin: 0; }
#modal-presupuesto .cw-section .form-group label { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
#modal-presupuesto .cw-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
#modal-presupuesto .cw-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
#modal-presupuesto .cw-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#modal-presupuesto .cw-grid-4 > *, #modal-presupuesto .cw-grid-3 > *, #modal-presupuesto .cw-grid-2 > * { min-width: 0; }
@media (max-width: 800px) { #modal-presupuesto .cw-grid-4, #modal-presupuesto .cw-grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { #modal-presupuesto .cw-grid-4, #modal-presupuesto .cw-grid-3, #modal-presupuesto .cw-grid-2 { grid-template-columns: 1fr; } }
#modal-presupuesto #presupuesto-numero[disabled], #modal-presupuesto #presupuesto-centro[disabled] { opacity: 1; color: var(--text-secondary); background: var(--bg-input); }
.cw-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-primary); cursor: pointer; margin-top: 10px; }
.cw-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.cw-inline-new { border-style: dashed; border-color: var(--accent); background: var(--accent-bg); }
.cw-inline-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#modal-presupuesto .lineas-add-bar { margin-top: 12px; }
#modal-presupuesto .factura-totales { border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; background: var(--bg-card); }
#modal-presupuesto .cw-final-resumen { margin-top: 14px; }
#modal-presupuesto .cw-final-grid { grid-template-columns: repeat(4, 1fr); }
#modal-presupuesto .cw-final-total { color: var(--accent); font-size: 15px; }
#modal-presupuesto .cw-nav { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Paso 1 de presupuesto sin scroll: tarjeta compacta y opciones avanzadas plegadas */
#modal-presupuesto .tercero-selected-detalles { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 14px; }
#modal-presupuesto .tercero-selected-detalles .tercero-detalle-row { flex-direction: row; gap: 6px; align-items: baseline; }
#modal-presupuesto .tercero-selected-detalles .tercero-detalle-label::after { content: ":"; }
#modal-presupuesto .tercero-selected-detalles .tercero-detalle-value { font-size: 12.5px; font-weight: 500; }
#modal-presupuesto .tercero-selected-detalles .tercero-detalle-row:last-child { margin-left: auto; }
.cw-details { padding: 0; overflow: hidden; }
.cw-summary { cursor: pointer; list-style: none; padding: 14px 18px; margin: 0; display: flex; align-items: center; gap: 10px; user-select: none; }
.cw-summary::-webkit-details-marker { display: none; }
.cw-summary::before { content: ""; width: 8px; height: 8px; border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .15s; flex-shrink: 0; }
.cw-details[open] .cw-summary::before { transform: rotate(45deg); }
.cw-details[open] .cw-summary { border-bottom: 1px solid var(--border); }
.cw-details > *:not(summary) { margin-left: 18px; margin-right: 18px; }
.cw-details > *:last-child { margin-bottom: 16px; }
#modal-presupuesto .cw-details .cw-section-title { padding: 0; }
/* Opciones avanzadas del presupuesto: bloque uniforme, sin fondo gris ni sangrías desiguales */
#modal-presupuesto #presupuesto-centro-form { background: transparent !important; border: none !important; padding: 0; margin-top: 12px; }
#modal-presupuesto .cw-details > *:not(summary) { margin-left: 18px; margin-right: 18px; }
#modal-presupuesto .cw-details .cw-section-title { margin: 14px 18px 10px; padding: 0; }
#modal-presupuesto .cw-details .form-grid { margin-top: 0; }
#modal-presupuesto .cw-details .cw-check { margin-top: 10px; }
#modal-presupuesto .cw-details #presupuesto-centro-form .form-group label { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
#modal-presupuesto .cw-details > .form-group:last-of-type { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
/* Presupuesto · paso Líneas: tarjeta de línea y totales integrados */
#modal-presupuesto .linea-card { border-radius: 12px; padding: 14px 16px 14px; }
#modal-presupuesto .linea-card-remove { top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--text-secondary); }
#modal-presupuesto .linea-card-remove:hover { background: #fee2e2; color: #dc2626; }
#modal-presupuesto .linea-card-header { margin-right: 36px; }
#modal-presupuesto .linea-card-ler { margin: 6px 0 10px 36px; font-weight: 600; }
#modal-presupuesto .linea-card-fields { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-left: 36px; }
#modal-presupuesto .linea-card-field:has(.pre-linea-ler-select), #modal-presupuesto .linea-card-field:has(.pre-linea-producto-select) { flex: 1 1 220px; min-width: 0; }
#modal-presupuesto .pre-linea-ler-select, #modal-presupuesto .pre-linea-producto-select { width: 100% !important; min-width: 0; }
#modal-presupuesto .linea-card-field:has(.linea-card-base) { margin-left: auto; align-items: flex-end; }
#modal-presupuesto .linea-card-fields label { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: var(--text-secondary); }
#modal-presupuesto .linea-card-fields input, #modal-presupuesto .linea-card-fields select { border-radius: 8px; padding: 9px 10px; font-size: 13.5px; height: 38px; box-sizing: border-box; }
#modal-presupuesto .linea-card-base { font-size: 16px; padding: 0 0 7px; min-width: 90px; }
#modal-presupuesto .factura-totales { margin: 14px 0 0; padding: 4px 18px 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; }
#modal-presupuesto .factura-totales .total-row { justify-content: flex-end; gap: 24px; padding: 8px 0; background: none !important; color: var(--text-secondary); font-size: 13.5px; border: none; }
#modal-presupuesto .factura-totales .total-row span:last-child { min-width: 120px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
#modal-presupuesto .factura-totales .total-final { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 16px; color: var(--text-primary); }
#modal-presupuesto .factura-totales .total-final span:last-child { color: var(--accent); font-size: 20px; font-weight: 800; }
#modal-presupuesto .lineas-add-bar .btn-primary { border-radius: 10px; }
#modal-presupuesto .lineas-add-bar .btn-secondary { border-radius: 999px; }

/* DI: quién aporta el documento */
.diw-doc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.diw-doc-opt { display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--bg-card); cursor: pointer; font-family: inherit; }
.diw-doc-opt:hover { border-color: var(--accent); }
.diw-doc-opt.active { border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 0 0 3px var(--accent-bg); }
.diw-doc-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; color: transparent; flex-shrink: 0; margin-top: 1px; }
.diw-doc-opt.active .diw-doc-check { border-color: var(--accent); background: var(--accent); color: #fff; }
.diw-doc-body { display: flex; flex-direction: column; gap: 2px; }
.diw-doc-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.diw-doc-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.diw-doc-ext { margin-top: 12px; padding: 12px 14px; border: 1.5px dashed #f59e0b; border-radius: 12px; background: #fffbeb; }
[data-theme="dark"] .diw-doc-ext { background: rgba(245,158,11,.1); }
.diw-doc-ext-txt { font-size: 12.5px; color: var(--text-primary); margin-bottom: 8px; }
.diw-doc-files { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.diw-doc-file { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 6px 10px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--border); }
.diw-doc-file span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .diw-doc { grid-template-columns: 1fr; } }

/* Bloque de facturación y trazabilidad en el DI */
.diw-tz { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px; }
.diw-tz-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.diw-tz-k { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
.diw-tz-v { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.diw-tz-v em { font-style: normal; color: #b45309; }
.diw-tz-s { font-size: 11.5px; color: var(--text-secondary); }
.diw-traza-ext { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-bg); }
.diw-traza-ext .diw-tz-main .diw-tz-v { font-size: 16px; }
@media (max-width: 640px) { .diw-tz { grid-template-columns: 1fr; } }

/* Origen del contrato (propio / externo) */
#modal-contrato .diw-doc-wrap { margin-bottom: 16px; }
.ct-ext-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ct-ext-status { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
#modal-contrato .diw-doc-ext { margin-top: 12px; }

/* ===== Diálogo de confirmación y toasts (sustituyen alert/confirm nativos) ===== */
#ui-dialog-layer { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }
.ui-dialog-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity .18s ease; pointer-events: auto; backdrop-filter: blur(1.5px); }
.ui-dialog-overlay.ui-dialog-show { opacity: 1; }
.ui-dialog { width: 100%; max-width: 420px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.28); padding: 22px 22px 18px; transform: translateY(8px) scale(.98); transition: transform .18s ease; }
.ui-dialog-show .ui-dialog { transform: none; }
.ui-dialog-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; color: var(--text-primary); }
.ui-dialog-msg { font-size: 14px; line-height: 1.5; color: var(--text-primary); white-space: pre-line; }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.ui-dialog-actions .btn { padding: 9px 18px; font-size: 14px; }
.ui-dialog-danger { background: #dc2626; color: #fff; border: none; }
.ui-dialog-danger:hover { background: #b91c1c; }

#ui-toast-layer { position: fixed; top: 18px; right: 18px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; max-width: min(400px, calc(100vw - 36px)); }
.ui-toast { display: flex; align-items: flex-start; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-left-width: 4px; border-radius: 12px; padding: 12px 14px; box-shadow: 0 12px 32px rgba(0,0,0,.18); font-size: 13.5px; color: var(--text-primary); opacity: 0; transform: translateX(20px); transition: opacity .22s ease, transform .22s ease; pointer-events: auto; }
.ui-toast-show { opacity: 1; transform: none; }
.ui-toast-txt { line-height: 1.4; white-space: pre-line; }
.ui-toast-ico { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; margin-top: 1px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; }
.ui-toast-ok { border-left-color: #10b981; }
.ui-toast-ok .ui-toast-ico { background: #10b981; }
.ui-toast-ok .ui-toast-ico::after { content: '✓'; }
.ui-toast-error { border-left-color: #dc2626; }
.ui-toast-error .ui-toast-ico { background: #dc2626; }
.ui-toast-error .ui-toast-ico::after { content: '!'; }
.ui-toast-info { border-left-color: var(--accent); }
.ui-toast-info .ui-toast-ico { background: var(--accent); }
.ui-toast-info .ui-toast-ico::after { content: 'i'; font-style: italic; }

/* Buscador de LER en líneas del presupuesto (estética del contrato) */
.pre-ler-wrap { position: relative; }
.pre-ler-wrap .cw-search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); pointer-events: none; }
.pre-ler-wrap .pre-linea-ler-search {
  width: 100%; box-sizing: border-box; padding: 9px 10px 9px 34px; border-radius: 8px;
  border: 1.5px solid var(--border-input); background: var(--bg-input); color: var(--text-primary);
  font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.pre-ler-wrap .pre-linea-ler-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.pre-ler-wrap .ler-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 100;
  max-height: 220px; overflow-y: auto; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.14); display: none;
}
.pre-ler-wrap .ler-dropdown-item { padding: 7px 11px; cursor: pointer; font-size: 12.5px; color: var(--text-primary); border-bottom: 1px solid var(--border); }
.pre-ler-wrap .ler-dropdown-item:last-child { border-bottom: none; }
.pre-ler-wrap .ler-dropdown-item:hover { background: var(--accent-bg); }
.pre-ler-wrap .ler-dropdown-item code { color: var(--accent); font-weight: 600; }

/* ===== Dashboard de Residuos ===== */
.res-actions-top { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.res-action { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg-card); cursor: pointer; text-align: left; font-family: inherit; transition: border-color .15s, box-shadow .15s, transform .05s; }
.res-action:hover { border-color: var(--accent); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.res-action:active { transform: translateY(1px); }
.res-action-ico { flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.res-action-in .res-action-ico { background: var(--accent-bg); color: var(--accent); }
.res-action-out .res-action-ico { background: #fef3c7; color: #b45309; }
.res-action-txt { display: flex; flex-direction: column; gap: 2px; }
.res-action-txt strong { font-size: 15px; color: var(--text-primary); }
.res-action-txt small { font-size: 12px; color: var(--text-secondary); }

.res-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.res-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 22px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg-card); cursor: pointer; text-align: left; font-family: inherit; transition: border-color .15s, box-shadow .15s, transform .05s; }
.res-card:hover { border-color: var(--accent); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.res-card:active { transform: translateY(1px); }
.res-card-ico { width: 48px; height: 48px; border-radius: 12px; background: var(--accent-bg); color: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.res-card-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.res-card-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.45; }

.res-panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.res-panel-head h2 { flex: 1; margin: 0; font-size: 20px; color: var(--text-primary); }
@media (max-width: 700px) { .res-actions-top, .res-cards { grid-template-columns: 1fr; } }

/* ===== Menú ERP: grupos colapsables ===== */
.nav-group { display: flex; flex-direction: column; }
.nav-group-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 14px; background: none; border: none; border-radius: 8px;
  color: var(--text-secondary); font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  cursor: pointer; font-family: inherit; text-align: left; transition: color .15s, background .15s;
}
.nav-group-head:hover { color: var(--text-primary); }
.nav-group-head > svg:first-child { opacity: .7; flex-shrink: 0; }
.nav-group-head span { flex: 1; }
.nav-group-chevron { transition: transform .18s ease; opacity: .6; }
.nav-group-collapsed .nav-group-chevron { transform: rotate(-90deg); }
.nav-group-body { display: flex; flex-direction: column; gap: 2px; overflow: hidden; padding-left: 8px; margin-left: 12px; border-left: 1.5px solid var(--border); }
.nav-group-collapsed .nav-group-body { display: none; }
.nav-group-body .nav-item { font-size: 13.5px; padding: 8px 12px; }
.nav-group-body .nav-item svg { opacity: .75; }

/* ===== Dashboard de Contabilidad (tarjetas) ===== */
.contab-dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 4px; }
.contab-dash-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg-card); cursor: pointer; text-align: left; font-family: inherit; transition: border-color .15s, box-shadow .15s, transform .05s; }
.contab-dash-card:hover { border-color: var(--accent); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.contab-dash-card:active { transform: translateY(1px); }
.cdc-ico { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-bg); color: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 2px; }
.cdc-t { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.cdc-d { font-size: 12px; color: var(--text-secondary); line-height: 1.35; }
.contab-tab-home { font-weight: 700; color: var(--accent); }

/* ===== Contabilidad: secciones individuales con la nueva estética ===== */
.contab-section-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 14px; }
.contab-section-head h2 { flex: 1; margin: 0; font-size: 20px; color: var(--text-primary); }
.contab-panel { margin-top: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-card); padding: 16px 18px; }
.contab-panel .contab-panel-header { margin-bottom: 14px; }
.contab-panel .search-bar { margin-bottom: 0; }
.contab-panel .search-bar input { width: 100%; }
.contab-panel .table-container { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.contab-panel .filter-bar { margin-bottom: 12px; }
#contab-panel-libro-mayor .cw-search-input { padding: 11px 12px 11px 40px; font-size: 14px; }
#contab-panel-libro-mayor .search-dropdown { border-radius: 10px; top: calc(100% + 4px); box-shadow: 0 12px 32px rgba(0,0,0,.14); }

/* ===== Modal Ver Asiento ===== */
.va-body { padding: 4px 2px 2px; }
.va-info { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.va-info-cell { background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.va-lbl { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
.va-val { font-size: 14.5px; font-weight: 700; color: var(--text-primary); }
.va-info-cell .badge { align-self: flex-start; }
.va-concepto { font-size: 14.5px; font-weight: 600; color: var(--text-primary); }
.va-docref { margin-top: 6px; font-size: 12.5px; color: var(--text-secondary); }
.va-cta-nombre { font-size: 12px; color: var(--text-secondary); }
.va-tabla tfoot .va-totales td { background: var(--accent-bg); border-top: 2px solid var(--accent-border); font-weight: 800; color: var(--text-primary); padding: 10px 12px; }
.va-cuadrado { margin-left: 8px; font-size: 11px; font-weight: 700; color: var(--accent); }
.va-descuadrado { margin-left: 8px; font-size: 11px; font-weight: 700; color: #dc2626; }
@media (max-width: 700px) { .va-info { grid-template-columns: 1fr 1fr; } }
.mc-rol { font-size: 11px; font-weight: 600; color: var(--text-secondary); }

/* ===== Repaso global de modales: inputs y foco consistentes con la nueva estética ===== */
.modal-form .form-group input, .modal-form .form-group select, .modal-form .form-group textarea {
  border-radius: 10px; padding: 10px 12px; border-width: 1.5px;
}
.modal-form .form-group input:focus, .modal-form .form-group select:focus, .modal-form .form-group textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.modal-form .cw-section { margin-bottom: 14px; }
/* Campos apilados dentro de una tarjeta de sección: separados entre sí,
   sin margen extra en el último ni dentro de un grid (el gap ya separa) */
.modal-form .cw-section .form-group { margin-bottom: 14px; }
.modal-form .cw-section .form-grid > .form-group,
.modal-form .cw-section .form-group:last-child { margin-bottom: 0; }

/* ===== Modal Nueva Factura ===== */
#modal-factura .fx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 700px) { #modal-factura .fx-grid { grid-template-columns: 1fr; } }
.fx-conceptos-head, #modal-factura .concepto-row {
  display: grid; grid-template-columns: minmax(0, 3fr) 90px 104px 88px 80px 32px; gap: 8px; align-items: center;
}
.fx-conceptos-head { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); padding: 0 0 6px; }
.fx-conceptos-head span:nth-child(5) { text-align: right; }
#modal-factura .concepto-row { margin-bottom: 8px; }
#modal-factura .concepto-row input, #modal-factura .concepto-row select { min-width: 0; border-radius: 8px; padding: 9px 10px; }
#modal-factura .concepto-total { text-align: right; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
#modal-factura .concepto-remove { width: 32px; height: 32px; border-radius: 8px; color: var(--text-secondary); }
#modal-factura .concepto-remove:hover { color: #dc2626; background: #fee2e2; }
@media (max-width: 700px) { .fx-conceptos-head { display: none; } #modal-factura .concepto-row { grid-template-columns: 1fr 1fr; } }

/* Totales destacados (factura y agrupar) */
.fx-totales { background: var(--accent-bg); border: 1px solid var(--accent-border); border-radius: 12px; padding: 12px 16px; }
.fx-totales .total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13.5px; color: var(--text-primary); }
.fx-totales .total-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.fx-totales .total-final { border-top: 1.5px dashed var(--accent-border); margin-top: 6px; padding-top: 10px; font-size: 16px; font-weight: 800; }
.fx-totales .total-final span:last-child { color: var(--accent); font-size: 20px; font-weight: 800; }

/* Lista de albaranes del modal Agrupar */
.agrupar-list { max-height: 300px; overflow-y: auto; }
.agrupar-list label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.agrupar-list label:hover { border-color: var(--accent); background: var(--accent-bg); }
/* Buscador con lupa dentro de cualquier modal */
.modal-form .cw-search-wrap { position: relative; width: 100%; }
.modal-form .cw-search-wrap .cw-search-input { width: 100%; box-sizing: border-box; padding: 11px 12px 11px 40px; font-size: 14px; border-radius: 10px; border: 1.5px solid var(--border-input); background: var(--bg-input); color: var(--text-primary); outline: none; transition: border-color .15s, box-shadow .15s; }
.modal-form .cw-search-wrap .cw-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.cw-search-wrap:has(.cw-search-input.hidden) .cw-search-icon { display: none; }
/* Agrupar: fila de albarán con la estética clara */
.agrupar-list { margin: 0; padding: 0; background: transparent; border: none; }
.agrupar-item { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--bg-input); color: var(--text-primary); }
.agrupar-item strong { color: var(--text-primary); }
.agrupar-item-importe { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.agrupar-item input[type="checkbox"] { accent-color: var(--accent); width: 17px; height: 17px; }

/* ===== KPIs financieros formales ===== */
.fin-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.fin-kpi { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; display: flex; flex-direction: column; gap: 6px; }
.fin-kpi-lbl { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--text-secondary); }
.fin-kpi-val { font-size: 22px; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.fin-kpi-rojo { color: #b91c1c; }
@media (max-width: 700px) { .fin-kpis { grid-template-columns: 1fr; } }

/* Números tabulares en todas las tablas de datos */
.data-table td { font-variant-numeric: tabular-nums; }

/* ===== Filtros de Facturas ===== */
.fact-filtros { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 12px; padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; }
.fact-filtro { display: flex; flex-direction: column; gap: 4px; }
.fact-filtro label { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }
.fact-filtro input, .fact-filtro select { border: 1.5px solid var(--border-input); border-radius: 9px; padding: 8px 10px; background: var(--bg-input); color: var(--text-primary); font-size: 13px; outline: none; min-width: 120px; }
.fact-filtro input:focus, .fact-filtro select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.fact-filtro select#ff-cliente { max-width: 220px; }
.fact-resumen { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 12px; padding: 10px 16px; background: var(--accent-bg); border: 1px solid var(--accent-border); border-radius: 10px; font-size: 13px; color: var(--text-primary); }
.fact-resumen strong { font-variant-numeric: tabular-nums; }

/* ===== Balances: estética formal sin verde ===== */
.bal-head { background: #334155; color: #fff; padding: 9px 14px; font-weight: 700; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; display: flex; justify-content: space-between; }
[data-theme="dark"] .bal-head { background: #1e293b; }
/* Sumas y Saldos: columnas bien repartidas, importes a la derecha */
#tabla-balance-sumas { table-layout: fixed; min-width: 820px; }
#tabla-balance-sumas th:nth-child(1), #tabla-balance-sumas td:nth-child(1) { width: 90px; }
#tabla-balance-sumas th:nth-child(2), #tabla-balance-sumas td:nth-child(2) { width: auto; }
#tabla-balance-sumas th:nth-child(n+3), #tabla-balance-sumas td:nth-child(n+3) { width: 120px; text-align: right; }
#balance-sumas-saldos .table-container { overflow-x: auto; }
#tabla-balance-sumas tfoot td { background: var(--bg-input); border-top: 2px solid var(--border); }
/* PyG: importes a la derecha */
#tabla-pyg-ingresos th:nth-child(3), #tabla-pyg-ingresos td:nth-child(3),
#tabla-pyg-gastos th:nth-child(3), #tabla-pyg-gastos td:nth-child(3) { text-align: right; }

/* Autocompletar de los filtros de lista */
.fact-filtro { position: relative; }
.ff-dd { position: absolute; top: 100%; left: 0; min-width: 100%; z-index: 130; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.14); max-height: 240px; overflow-y: auto; }
.ff-dd-item { padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--text-primary); border-bottom: 1px solid var(--border); white-space: nowrap; }
.ff-dd-item:last-child { border-bottom: none; }
.ff-dd-item:hover { background: var(--bg-hover); }

/* ===== PyG: cascada analítica (EBITDA/EBIT/BAI) ===== */
.pyg-cascada { max-width: 640px; margin: 0 auto 20px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-card); }
.pyg-c-title { background: #334155; color: #fff; padding: 9px 16px; font-weight: 700; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; }
[data-theme="dark"] .pyg-c-title { background: #1e293b; }
.pyg-c-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 16px; font-size: 13.5px; color: var(--text-primary); border-bottom: 1px solid var(--border); }
.pyg-c-row:last-child { border-bottom: none; }
.pyg-c-sub { background: var(--bg-input); font-weight: 700; }
.pyg-c-total { background: var(--bg-input); font-weight: 800; font-size: 15px; border-top: 2px solid #334155; }

/* ===== Analítica: dashboard formal ===== */
.ana-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .ana-cards { grid-template-columns: 1fr 1fr; } }
.ana-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 0 0 10px; overflow: hidden; }
.ana-card-head { background: #334155; color: #fff; padding: 8px 14px; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; margin-bottom: 8px; }
[data-theme="dark"] .ana-card-head { background: #1e293b; }
.ana-card-total { border-color: #334155; }
.ana-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 14px; font-size: 13px; color: var(--text-primary); }
.ana-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.ana-row-margen { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 8px; font-weight: 700; }
.ana-row-margen span:last-child { font-size: 15px; font-weight: 800; }
.ana-row-pct span:last-child { font-weight: 700; }
.ana-mini { padding: 6px 14px 0; font-size: 11px; color: var(--text-secondary); }
.ana-mini strong { font-variant-numeric: tabular-nums; }

.ana-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
@media (max-width: 900px) { .ana-charts { grid-template-columns: 1fr; } }
.ana-chart { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ana-chart-title { background: #334155; color: #fff; padding: 8px 14px; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; }
[data-theme="dark"] .ana-chart-title { background: #1e293b; }
.ana-chart-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 7px; }
.ana-bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-primary); }
.ana-bar-mes { width: 34px; flex-shrink: 0; font-weight: 600; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ana-bar { flex: 1; height: 14px; background: var(--bg-card); border-radius: 7px; overflow: hidden; display: flex; }
.ana-bar i { display: block; height: 100%; }
.ana-seg-res { background: #10b981; }
.ana-seg-gal { background: #f59e0b; }
.ana-seg-com { background: #64748b; }
.ana-seg-neutro { background: #475569; border-radius: 7px; }
.ana-bar-total { width: 110px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; flex-shrink: 0; }
.ana-leyenda { display: flex; gap: 16px; padding: 0 14px 12px; font-size: 11.5px; color: var(--text-secondary); }
.ana-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.ana-dot-res { background: #10b981; } .ana-dot-gal { background: #f59e0b; } .ana-dot-com { background: #64748b; }
.ana-vacio { color: var(--text-secondary); font-size: 12.5px; padding: 6px 0; }

/* Cobros y Pagos: conmutador de vista destacado (segmented control) */
#tes-vista { background: var(--bg-input); border: 1.5px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; display: inline-flex; }
#tes-vista .filter-btn { border: none; background: transparent; font-size: 14px; font-weight: 700; padding: 9px 22px; border-radius: 9px; color: var(--text-secondary); transition: background .15s, color .15s; }
#tes-vista .filter-btn:hover { color: var(--text-primary); }
#tes-vista .filter-btn.active { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; box-shadow: 0 2px 10px rgba(16,185,129,.35); }
/* El modo (Cobros/Pagos) también gana un poco de presencia */
#tes-modo .filter-btn { font-weight: 700; padding: 9px 18px; }
#tes-modo .filter-btn.active { background: #334155 !important; color: #fff !important; border-color: #334155 !important; }
[data-theme="dark"] #tes-modo .filter-btn.active { background: #1e293b !important; border-color: #1e293b !important; }

/* Libro Mayor: buscador y botón Cargar juntos */
#contab-panel-libro-mayor .contab-panel-header { gap: 10px; align-items: center; }
#contab-panel-libro-mayor .contab-panel-header .form-group { margin: 0 !important; flex: 0 1 440px !important; min-width: 260px !important; width: auto !important; }
#contab-panel-libro-mayor #btn-cargar-mayor { flex-shrink: 0; }

/* Nota de paginación bajo las listas largas */
.lista-pager {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin: 14px 0 4px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Checkboxes del modal de módulos por usuario */
.mod-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  margin: 4px 0;
}

/* Importes siempre en una sola línea (celdas numéricas alineadas a la derecha) */
.data-table td[style*="text-align:right"],
.data-table th[style*="text-align:right"],
.data-table td[style*="text-align: right"],
.data-table th[style*="text-align: right"] {
  white-space: nowrap;
}

/* Los hijos de un grid no deben desbordarlo: un select/input con contenido largo
   (p. ej. el LER "020304 - Materiales inadecuados...") encoge en vez de empujar el modal */
.form-grid > .form-group,
.form-grid-2 > .form-group,
.form-grid-3 > .form-group,
.form-grid-4 > .form-group {
  min-width: 0;
}
.form-group select,
.form-group input {
  max-width: 100%;
}

/* Editor de albarán: cabecera y filas de líneas */
.ea-lineas-head, .ea-linea {
  display: grid;
  grid-template-columns: 1fr 76px 64px 90px 78px 100px 30px;
  gap: 8px;
  align-items: center;
}
.ea-linea > * { min-width: 0; }
.ea-lineas-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.ea-linea { margin-bottom: 8px; }
.ea-linea .ea-l-base { opacity: 0.75; font-weight: 600; }
.ea-linea .ea-l-del { color: var(--red); font-size: 18px; }

/* Inputs de las líneas del editor de albarán: mismo acabado que los form-group */
.ea-linea input, .ea-linea select {
  background: #0a0a0a;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  padding: 8px 10px;
  color: #e0e0e0;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}
[data-theme="light"] .ea-linea input,
[data-theme="light"] .ea-linea select {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}
.ea-linea .ea-l-base { font-weight: 600; }

/* Separación de campos dentro de las tarjetas de sección: los form-group apilados
   se pegaban (el margen solo existía para hijos directos de .modal-form) */
.cw-section .form-group {
  margin-bottom: 14px;
}
.cw-section .form-grid > .form-group,
.cw-section .form-group:last-child {
  margin-bottom: 0;
}

/* Grupos de filtros de trazabilidad: etiqueta arriba y separador entre grupos */
.traz-grupo-lbl {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin: 0 2px 6px;
}
.traz-grupo-sep {
  border-left: 1px solid var(--border, #d1d5db);
  padding-left: 22px;
}

/* Menú plano del perfil operador: los grupos son botones directos, sin desplegable */
.nav-group-plano .nav-group-body { display: none; }
.nav-group-plano .nav-group-chevron { display: none; }
.nav-group-plano .nav-group-head { cursor: pointer; }
.nav-group-plano .nav-group-head.active {
  color: var(--accent, #059669);
}

/* Paso transportista de la recogida: chips de vehículos habituales y tarjeta de empresa */
.veh-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border, #d1d5db);
  background: var(--bg-card, #fff);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #111827);
  transition: border-color .15s, background .15s, transform .05s;
}
.veh-chip:hover { border-color: var(--accent, #059669); background: var(--accent-bg, #ecfdf5); }
.veh-chip:active { transform: scale(.97); }
.veh-chip svg { color: var(--accent, #059669); flex-shrink: 0; }
.veh-chip .veh-chip-mat {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  letter-spacing: .5px;
}
.veh-chip.veh-chip-activa { border-color: var(--accent, #059669); background: var(--accent-bg, #ecfdf5); box-shadow: 0 0 0 1px var(--accent, #059669) inset; }

.transp-card {
  margin-top: 14px;
  border: 1px solid var(--accent-border, #a7f3d0);
  background: var(--accent-bg, #ecfdf5);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.transp-card-check { color: var(--accent, #059669); flex-shrink: 0; margin-top: 2px; }
.transp-card-empresa { font-weight: 700; font-size: 14px; color: var(--text-primary, #111827); }
.transp-card-linea { font-size: 12.5px; color: var(--text-secondary, #4b5563); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.transp-card-linea strong { color: var(--text-primary, #111827); font-weight: 600; }
.transp-card .transp-card-veh {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  letter-spacing: .5px;
  margin-top: 6px;
  color: var(--text-secondary, #4b5563);
}

/* Ficha de tercero */
.tf-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.tf-avatar {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  background: var(--accent-bg, #ecfdf5); color: var(--accent, #059669);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; letter-spacing: .5px;
  border: 1px solid var(--accent-border, #a7f3d0);
}
.tf-head h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.15; }
.tf-datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; margin-top: 4px; }
@media (max-width: 900px) { .tf-datos { grid-template-columns: 1fr 1fr; } }
.tf-campo-lbl { font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--text-secondary, #6b7280); margin-bottom: 3px; }
.tf-campo-val { font-size: 13.5px; color: var(--text-primary, #111827); font-weight: 500; word-break: break-word; }
.tf-campo-val code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.tf-acciones { display: flex; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border, #e5e7eb); }

/* Ficha tercero: cifras contables en cajas y estados vacíos con marco */
.tf-stat { background: var(--bg-input, #f3f4f6); border: 1px solid var(--border, #e5e7eb); border-radius: 10px; padding: 10px 14px; }
.tf-stat .tf-stat-lbl { font-size: 11px; color: var(--text-secondary, #6b7280); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.tf-stat .tf-stat-val { font-size: 17px; font-weight: 700; margin-top: 2px; }
.tf-stat.tf-stat-saldo { background: var(--accent-bg, #ecfdf5); border-color: var(--accent-border, #a7f3d0); }
.tf-stat.tf-stat-saldo .tf-stat-val { font-size: 24px; }
.tf-empty {
  border: 1.5px dashed var(--border, #d1d5db); border-radius: 12px;
  padding: 34px 20px; text-align: center; color: var(--text-secondary, #6b7280);
  font-size: 13.5px; background: var(--bg-card, #fff);
}

/* ============ Correo estilo Gmail ============ */
.gm-layout { display: grid; grid-template-columns: 430px 1fr; gap: 0; height: calc(100vh - 40px); background: var(--bg-card, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 14px; overflow: hidden; }
.gm-rail { border-right: 1px solid var(--border, #e5e7eb); padding: 14px 10px; display: flex; flex-direction: column; gap: 14px; background: var(--bg-main, #f8fafc); }
.gm-redactar { display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 999px; border: none; background: var(--accent, #059669); color: #fff; font-weight: 700; font-size: 13.5px; cursor: pointer; box-shadow: 0 2px 8px rgba(5,150,105,.35); }
.gm-redactar:hover { filter: brightness(1.06); }
.gm-carpetas { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.gm-carpeta { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 0 999px 999px 0; border: none; background: none; font-size: 13px; color: var(--text-primary, #111827); cursor: pointer; text-align: left; }
.gm-carpeta:hover { background: var(--bg-input, #eef2f7); }
.gm-carpeta.active { background: var(--accent-bg, #ecfdf5); color: var(--accent, #059669); font-weight: 700; }
.gm-carpeta svg { flex-shrink: 0; opacity: .75; }
.gm-carpeta-badge { margin-left: auto; font-size: 11px; font-weight: 800; color: var(--accent, #059669); }
.gm-sync-estado { font-size: 11px; color: var(--text-secondary, #6b7280); text-align: center; margin-top: 6px; min-height: 14px; }
.gm-lista-col { border-right: 1px solid var(--border, #e5e7eb); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.gm-buscador { padding: 10px; border-bottom: 1px solid var(--border, #e5e7eb); }
.gm-buscador input { width: 100%; box-sizing: border-box; padding: 9px 13px; border-radius: 999px; border: 1px solid var(--border-input, #d1d5db); background: var(--bg-input, #f3f4f6); font-size: 13px; color: var(--text-primary); }
.gm-lista { overflow-y: auto; flex: 1; }
.gm-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border, #f1f5f9); cursor: pointer; align-items: flex-start; position: relative; }
.gm-item:hover { background: var(--bg-input, #f8fafc); }
.gm-item.active { background: var(--accent-bg, #ecfdf5); }
.gm-item-main { flex: 1; min-width: 0; }
.gm-item-l1 { display: flex; align-items: baseline; gap: 6px; }
.gm-item-from { font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.gm-noleido .gm-item-from, .gm-noleido .gm-item-l2 { font-weight: 800; }
.gm-noleido::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent, #059669); }
.gm-item-fecha { font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }
.gm-hilo-n { font-size: 10.5px; color: var(--text-secondary); background: var(--bg-input, #eef2f7); border-radius: 8px; padding: 0 6px; flex-shrink: 0; }
.gm-item-l2 { font-size: 12.5px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.gm-item-l3 { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.gm-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-bg, #ecfdf5); color: var(--accent, #059669); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.gm-avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.gm-avatar-lg { width: 42px; height: 42px; font-size: 17px; }
.gm-star { border: none; background: none; font-size: 16px; color: #cbd5e1; cursor: pointer; padding: 2px; align-self: center; }
.gm-star.on { color: #f59e0b; }
.gm-star-big { border: none; background: none; font-size: 22px; color: #cbd5e1; cursor: pointer; }
.gm-star-big.on { color: #f59e0b; }
.gm-lectura { overflow: hidden; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.gm-view { padding: 18px 22px; flex: 1; overflow-y: auto; min-height: 0; }
.gm-view-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.gm-view-head h2 { margin: 0; font-size: 19px; flex: 1; line-height: 1.3; }
.gm-view-tools { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.gm-chip { border: 1px solid var(--border, #d1d5db); background: var(--bg-card, #fff); border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--text-primary); }
.gm-chip:hover { border-color: var(--accent, #059669); color: var(--accent, #059669); }
.gm-chip.on { background: var(--accent-bg, #ecfdf5); border-color: var(--accent, #059669); color: var(--accent, #059669); font-weight: 700; }
.gm-prev { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; margin-bottom: 6px; cursor: pointer; background: var(--bg-main, #f8fafc); }
.gm-prev:hover { border-color: var(--accent, #059669); }
.gm-prev-from { font-size: 12.5px; font-weight: 700; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.gm-prev-snip { font-size: 12px; color: var(--text-secondary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gm-prev-fecha { font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }
.gm-msg-card { border: 1px solid var(--border, #e5e7eb); border-radius: 12px; padding: 16px 18px; background: var(--bg-card, #fff); }
.gm-msg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border, #f1f5f9); }
.gm-msg-quien { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; font-size: 13px; }
.gm-msg-quien #email-cc { font-size: 12px; color: var(--text-secondary); }
.gm-msg-fecha { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.gm-acciones { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.gm-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-secondary); gap: 10px; }
.gm-empty.hidden { display: none; }
@media (max-width: 1100px) {
  .gm-layout { grid-template-columns: 340px 1fr; }
}

/* Modal cerrar recogida: pesaje en 4 columnas */
#modal-cerrar-recogida .cw-grid-2 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { #modal-cerrar-recogida .cw-grid-2 { grid-template-columns: 1fr 1fr; } }
#modal-cerrar-recogida .cw-section .form-group { margin: 0; }
#modal-cerrar-recogida .cw-section .form-group label { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-secondary); }

/* Filas de servicios extra / descuentos (recogida y cierre) */
.extra-fila { display: flex; gap: 10px; align-items: center; background: var(--bg-input, #f3f4f6); border: 1px solid var(--border, #e5e7eb); border-radius: 10px; padding: 8px 10px; }
.extra-fila .badge { flex-shrink: 0; }
.extra-fila input { border: 1px solid var(--border-input, #d1d5db); background: var(--bg-card, #fff); border-radius: 8px; padding: 8px 11px; font-size: 13px; color: var(--text-primary); }
.extra-fila input[type="text"] { flex: 1; min-width: 0; }
.extra-fila .extra-importe { width: 130px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.extra-fila .extra-del { width: 26px; height: 26px; border-radius: 50%; border: none; background: none; color: #dc2626; font-size: 17px; line-height: 1; cursor: pointer; flex-shrink: 0; }
.extra-fila .extra-del:hover { background: #fee2e2; }
#modal-cerrar-recogida .sub-importe-box { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-radius: 12px; background: var(--accent-bg, #ecfdf5); border: 1px solid var(--accent-border, #a7f3d0); font-weight: 600; }


/* Barra compacta con desplegable de carpetas */
.gm-toolbar { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border, #e5e7eb); }
.gm-toolbar .gm-redactar { padding: 9px 11px; border-radius: 12px; box-shadow: none; }
.gm-carpeta-dd { position: relative; }
.gm-carpeta-btn { display: flex; align-items: center; gap: 7px; padding: 9px 13px; border-radius: 999px; border: 1px solid var(--border, #d1d5db); background: var(--bg-card, #fff); font-size: 13px; font-weight: 700; color: var(--text-primary); cursor: pointer; white-space: nowrap; }
.gm-carpeta-btn:hover { border-color: var(--accent, #059669); }
.gm-carpeta-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; background: var(--bg-card, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 6px; min-width: 210px; display: flex; flex-direction: column; gap: 2px; }
.gm-carpeta-menu .gm-carpeta { border-radius: 8px; width: 100%; }
.gm-carpeta-sep { height: 1px; background: var(--border, #e5e7eb); margin: 4px 6px; }
/* Acciones flotando al pie de la lectura */
.gm-lectura { position: relative; }
.gm-acciones { flex-shrink: 0; background: var(--bg-card, #fff); border-top: 1px solid var(--border, #e5e7eb); padding: 12px 16px; box-shadow: 0 -6px 18px rgba(0,0,0,.06); }
.gm-acciones.hidden { display: none; }

/* ============ Existencias ============ */
.ex-fecha-ctrl { display: flex; align-items: center; gap: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; color: var(--text-secondary); }
.ex-fecha-ctrl input[type="date"] { background: transparent; border: none; color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none; }
.ex-fecha-btn { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; transition: all .15s; }
.ex-fecha-btn:hover { color: var(--accent); border-color: var(--accent); }

.ex-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 24px; }
.ex-card { position: relative; overflow: hidden; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; transition: transform .15s, box-shadow .15s; }
.ex-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.ex-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--ex-c); }
.ex-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.ex-ico { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--ex-c) 14%, transparent); color: var(--ex-c); }
.ex-cta { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--ex-c); background: color-mix(in srgb, var(--ex-c) 10%, transparent); border: 1px solid color-mix(in srgb, var(--ex-c) 25%, transparent); border-radius: 20px; padding: 3px 10px; }
.ex-kg { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.ex-eur { font-size: 14px; font-weight: 600; color: var(--ex-c); margin-top: 2px; min-height: 18px; }
.ex-lbl { font-size: 13.5px; font-weight: 600; color: var(--text-primary); margin-top: 10px; }
.ex-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.ex-ambar { --ex-c: #f59e0b; }
.ex-verde { --ex-c: #10b981; }
.ex-violeta { --ex-c: #8b5cf6; }
.ex-total { --ex-c: #059669; background: linear-gradient(135deg, color-mix(in srgb, var(--ex-c) 10%, var(--bg-card)), var(--bg-card) 60%); }

.ex-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; }
.ex-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ex-panel-head h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); margin: 0; }
.ex-panel-head p { font-size: 12.5px; color: var(--text-secondary); margin: 3px 0 0; }
.ex-panel-count { font-size: 12px; font-weight: 700; color: #f59e0b; background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); border-radius: 20px; padding: 4px 12px; white-space: nowrap; }
.ex-lote { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 13px 4px; border-top: 1px solid var(--border); }
.ex-lote:first-child { border-top: none; }
.ex-lote-fecha { width: 46px; height: 46px; border-radius: 12px; background: var(--bg-input); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.ex-lote-fecha b { font-size: 16px; color: var(--text-primary); }
.ex-lote-fecha span { font-size: 10px; text-transform: uppercase; color: var(--text-secondary); letter-spacing: .5px; }
.ex-lote-info { min-width: 0; }
.ex-lote-nom { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-lote-nom small { font-weight: 500; color: var(--text-secondary); }
.ex-lote-res { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.ex-lote-barra { height: 6px; border-radius: 4px; background: var(--bg-input); margin-top: 7px; overflow: hidden; }
.ex-lote-barra i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #f59e0b, #10b981); }
.ex-lote-der { text-align: right; }
.ex-lote-kg { font-size: 14px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.ex-lote-kg small { font-weight: 500; color: var(--text-secondary); }
.ex-lote-dias { display: inline-block; margin-top: 5px; font-size: 11.5px; font-weight: 700; border-radius: 20px; padding: 2px 10px; white-space: nowrap; color: #f59e0b; background: rgba(245,158,11,.12); }
.ex-lote-dias.ex-listo { color: #10b981; background: rgba(16,185,129,.12); }
.ex-empty { text-align: center; color: var(--text-secondary); font-size: 13.5px; padding: 26px 0 14px; border-top: 1px dashed var(--border); }
.ex-nota { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 13px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.ex-nota::before { content: 'ℹ'; flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.ex-count-violeta { color: #8b5cf6; background: rgba(139,92,246,.12); border-color: rgba(139,92,246,.3); }
.ex-mov-tipo { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; border-radius: 20px; padding: 2px 9px; }
.ex-mov-compra { color: #10b981; background: rgba(16,185,129,.12); }
.ex-mov-venta { color: #ef4444; background: rgba(239,68,68,.12); }
.ex-mov-kg-mas { color: #10b981; }
.ex-mov-kg-menos { color: #ef4444; }
.ex-lote-stock { font-size: 11.5px; color: var(--text-secondary); margin-top: 4px; white-space: nowrap; }

/* Menú plano: los ítems de primer nivel con el mismo estilo que las cabeceras de grupo */
.nav-menu > .nav-item {
  font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
}
.nav-menu > .nav-item svg { opacity: .7; }

/* ============ Chat IA ============ */
.chatia-panel { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 420px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.chatia-mensajes { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.chatia-burbuja { max-width: 72%; padding: 11px 15px; border-radius: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chatia-ia { align-self: flex-start; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-primary); border-bottom-left-radius: 4px; }
.chatia-usuario { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chatia-pensando { align-self: flex-start; color: var(--text-secondary); font-size: 13px; padding: 6px 2px; }
.chatia-pensando i { display: inline-block; animation: chatia-p 1.2s infinite; font-style: normal; }
.chatia-pensando i:nth-child(2) { animation-delay: .2s; } .chatia-pensando i:nth-child(3) { animation-delay: .4s; }
@keyframes chatia-p { 0%,60%,100% { opacity: .25 } 30% { opacity: 1 } }
.chatia-input-row { display: flex; gap: 10px; align-items: flex-end; padding: 14px 16px; border-top: 1px solid var(--border); background: var(--bg-card); }
.chatia-input-row textarea { flex: 1; resize: none; max-height: 140px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; font-size: 14px; font-family: inherit; color: var(--text-primary); outline: none; }
.chatia-input-row textarea:focus { border-color: var(--accent); }
.chatia-ia { white-space: normal; }
.chatia-burbuja p { margin: 0; }
.chatia-burbuja ul { margin: 4px 0; padding-left: 20px; }
.chatia-burbuja li { margin: 2px 0; }
.chatia-sep { height: 8px; }
.chatia-burbuja code { background: rgba(127,127,127,.14); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.chatia-quote { margin: 6px 0; padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; font-size: 13.5px; line-height: 1.6; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.chatia-adjunto { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text-primary); transition: border-color .15s, transform .15s; }
.chatia-adjunto:hover { border-color: var(--accent); transform: translateY(-1px); }
.chatia-adj-ico { width: 38px; height: 38px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chatia-adj-info { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.chatia-adj-info b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatia-adj-info small { font-size: 11.5px; color: var(--text-secondary); }
button.chatia-adjunto { cursor: pointer; font-family: inherit; text-align: left; width: 100%; }
.chatia-opciones { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.chatia-opcion { text-align: left; padding: 9px 14px; background: var(--bg-card); border: 1px solid var(--accent); color: var(--accent); border-radius: 10px; font-size: 13.5px; font-weight: 600; font-family: inherit; cursor: pointer; transition: all .15s; }
.chatia-opcion:hover:not(:disabled) { background: var(--accent); color: #fff; }
.chatia-opcion:disabled { opacity: .45; cursor: default; }
.chatia-opcion-elegida { opacity: 1 !important; background: var(--accent); color: #fff; }
.chatia-layout { display: grid; grid-template-columns: 250px 1fr; gap: 14px; align-items: stretch; }
.chatia-lista-col { display: flex; flex-direction: column; gap: 8px; height: calc(100vh - 170px); min-height: 420px; }
.chatia-nueva { padding: 11px 14px; background: var(--accent); color: #fff; border: none; border-radius: 12px; font-size: 13.5px; font-weight: 700; font-family: inherit; cursor: pointer; }
.chatia-nueva:hover { filter: brightness(1.08); }
.chatia-convs { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.chatia-conv { display: flex; align-items: center; gap: 6px; padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color .15s; }
.chatia-conv:hover { border-color: var(--accent); }
.chatia-conv-activa { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-card)); }
.chatia-conv-info { flex: 1; min-width: 0; }
.chatia-conv-titulo { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatia-conv-fecha { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.chatia-conv-borrar { flex-shrink: 0; background: none; border: none; color: var(--text-secondary); font-size: 15px; cursor: pointer; padding: 2px 5px; border-radius: 6px; opacity: 0; transition: opacity .15s; }
.chatia-conv:hover .chatia-conv-borrar { opacity: 1; }
.chatia-conv-borrar:hover { color: #ef4444; background: rgba(239,68,68,.1); }
@media (max-width: 900px) { .chatia-layout { grid-template-columns: 1fr; } .chatia-lista-col { height: auto; max-height: 180px; } }
.chatia-punto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.chatia-nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 800; border-radius: 20px; padding: 1px 7px; }
.chatia-lista-head { display: flex; gap: 8px; }
.chatia-lista-head .chatia-nueva { flex: 1; }
.chatia-refrescar { width: 42px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; color: var(--text-secondary); cursor: pointer; transition: all .15s; }
.chatia-refrescar:hover { color: var(--accent); border-color: var(--accent); }
.chatia-refrescar:disabled { opacity: .5; cursor: default; }
.chatia-refrescar.girando svg { animation: chatia-giro 1s linear infinite; }
@keyframes chatia-giro { to { transform: rotate(360deg); } }

/* ============ Barra de formato del correo ============ */
.fmt-toolbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--bg-input); border: 1px solid var(--border); border-bottom: none; border-radius: 10px 10px 0 0; flex-wrap: wrap; }
.fmt-toolbar button { min-width: 30px; height: 28px; padding: 0 7px; background: none; border: 1px solid transparent; border-radius: 6px; color: var(--text-primary); font-size: 13.5px; cursor: pointer; font-family: inherit; }
.fmt-toolbar button:hover { background: var(--bg-card); border-color: var(--border); }
.fmt-toolbar select { height: 28px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); font-size: 12.5px; font-family: inherit; padding: 0 6px; }
.fmt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }
.reply-editor { min-height: 180px; max-height: 45vh; overflow-y: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: 0 0 10px 10px; padding: 12px 14px; font-size: 14px; line-height: 1.55; color: var(--text-primary); outline: none; }
.reply-editor:focus { border-color: var(--accent); }
.reply-editor:empty::before { content: attr(data-placeholder); color: var(--text-secondary); pointer-events: none; }
.mail-cita { color: var(--text-secondary); font-size: 13px; }
.mail-cita-head { margin-bottom: 4px; }
.mail-cita blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--text-secondary); }

/* ============ Hilo de correo estilo Gmail ============ */
.gm-hilo-msg { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.gm-hilo-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; min-width: 0; }
.gm-hilo-head:hover { background: var(--bg-input); }
.gm-hilo-from { font-weight: 600; font-size: 13.5px; color: var(--text-primary); white-space: nowrap; }
.gm-hilo-snip { flex: 1; min-width: 0; font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gm-hilo-abierto .gm-hilo-snip { visibility: hidden; }
.gm-hilo-fecha { font-size: 12px; color: var(--text-secondary); white-space: nowrap; flex-shrink: 0; }
.gm-hilo-body { padding: 2px 16px 14px 50px; font-size: 14px; line-height: 1.6; color: var(--text-primary); white-space: pre-wrap; word-break: break-word; }

/* Estética simple tipo Gmail en la lectura */
.gm-view .gm-msg-card { background: transparent; border: none; border-radius: 0; box-shadow: none; padding-left: 0; padding-right: 0; }
.gm-hilo-msg { background: transparent; border: none; border-radius: 0; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.gm-hilo-head { padding: 13px 4px; }
.gm-hilo-head:hover { background: color-mix(in srgb, var(--bg-input) 60%, transparent); }
.gm-hilo-body { padding-left: 44px; }
.gm-view-head h2 { font-size: 21px; font-weight: 600; }
.gm-pills { display: flex; gap: 10px; margin-top: 22px; }
.gm-pills button { padding: 9px 18px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); border-radius: 22px; font-size: 13.5px; font-weight: 600; font-family: inherit; cursor: pointer; transition: all .15s; }
.gm-pills button:hover { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-card)); }
/* Barra flotante: responder siempre a la vista; los accesos rápidos de IA se quitan */
#gm-acciones-bar #btn-presupuesto-email, #gm-acciones-bar #btn-destruccion, #gm-acciones-bar #btn-logistica { display: none; }
.email-html-frame { width: 100%; border: none; background: #fff; border-radius: 10px; display: block; min-height: 120px; }
/* El cuerpo del correo va a sangre, sin el marco gris (el HTML del mensaje manda) */
.gm-view .email-body { background: transparent; border: none; border-radius: 0; padding: 0; }
/* Campo de texto del correo más grande (y a pantalla completa, que aproveche el alto) */
.reply-editor { min-height: 300px; max-height: 60vh; }
.reply-panel-full .reply-editor { min-height: calc(100vh - 520px); max-height: none; }
/* Redactando: la lista se cierra y se gana su espacio (como Gmail); al cerrar/enviar vuelve */
.gm-layout.gm-solo-redactor { grid-template-columns: 1fr; }
.gm-layout.gm-solo-redactor .gm-lista-col { display: none; }

/* ============ Adjuntar en el correo ============ */
.adjuntar-wrap { position: relative; }
.adjuntar-menu { position: absolute; bottom: calc(100% + 6px); left: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.14); z-index: 40; min-width: 210px; overflow: hidden; }
.adjuntar-menu button { display: block; width: 100%; text-align: left; padding: 10px 14px; background: none; border: none; font-size: 13.5px; color: var(--text-primary); cursor: pointer; font-family: inherit; }
.adjuntar-menu button:hover { background: var(--bg-input); }
.reply-adjuntos-extra { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.adj-chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 9px; font-size: 12.5px; color: var(--text-primary); max-width: 260px; }
.adj-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adj-chip button { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 14px; padding: 0 2px; }
.adj-chip button:hover { color: #ef4444; }
.adjprog-cats { display: flex; gap: 8px; margin-bottom: 10px; }
.adjprog-cat { flex: 1; padding: 10px; border: 1px solid var(--border); background: var(--bg-card); border-radius: 10px; font-size: 14px; font-weight: 700; color: var(--text-secondary); cursor: pointer; font-family: inherit; }
.adjprog-cat-activa { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--bg-card)); }
.adjprog-tipos { display: flex; gap: 6px; flex-wrap: wrap; }
.adjprog-tipo { padding: 6px 12px; border: 1px solid var(--border); background: var(--bg-card); border-radius: 18px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; font-family: inherit; }
.adjprog-tipo-activo { border-color: var(--accent); color: #fff; background: var(--accent); }
.adjprog-lista { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.adjprog-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.adjprog-item:last-child { border-bottom: none; }
.adjprog-item:hover { background: var(--bg-input); }
.adjprog-item b { white-space: nowrap; }
.adjprog-item span { flex: 1; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adjprog-item .adjprog-ok { color: var(--accent); font-weight: 700; }
/* Estética del selector de archivos del programa */
#modal-adjuntar-programa .modal-content { border-radius: 16px; }
#modal-adjuntar-programa .modal-body { padding-top: 14px; }
#adjprog-buscar { width: 100%; padding: 11px 16px; font-size: 14px; font-family: inherit; color: var(--text-primary); background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; outline: none; margin: 12px 0 !important; }
#adjprog-buscar:focus { border-color: var(--accent); background: var(--bg-card); }
#adjprog-buscar::placeholder { color: var(--text-secondary); }
.adjprog-cats { margin-bottom: 12px; }
.adjprog-cat { padding: 12px; border-radius: 12px; font-size: 14.5px; }
.adjprog-tipos { gap: 8px; }
.adjprog-tipo { padding: 8px 14px; font-size: 13px; }
.adjprog-lista { border-radius: 12px; }
.adjprog-item { padding: 12px 16px; font-size: 13.5px; gap: 12px; }
.adjprog-item b { color: var(--text-primary); }
#modal-adjuntar-programa .modal-footer { display: flex; align-items: center; gap: 10px; padding: 14px 0 0; border-top: 1px solid var(--border); margin-top: 14px; }
.adj-chip span[data-ver-adj] { cursor: pointer; }
.adj-chip span[data-ver-adj]:hover { color: var(--accent); }
#reply-attachment-name { cursor: pointer; }
#reply-attachment-name:hover { color: var(--accent); }
/* Menú Adjuntar: más grande y cuidado */
.adjuntar-menu { min-width: 290px; border-radius: 14px; padding: 6px; box-shadow: 0 10px 34px rgba(0,0,0,.16); }
.adjuntar-menu button { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; }
.adjm-ico { width: 38px; height: 38px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.adjm-txt { display: flex; flex-direction: column; line-height: 1.25; }
.adjm-txt b { font-size: 14px; color: var(--text-primary); }
.adjm-txt small { font-size: 12px; color: var(--text-secondary); }
/* Mejorar con IA en amarillo pastel */
#btn-ia-redactar { background: #fef3c7 !important; color: #b45309 !important; border: 1px solid #fcd34d !important; box-shadow: none; }
#btn-ia-redactar:hover { background: #fde68a !important; }
#btn-ia-redactar .ai-icon { color: #b45309; }
.reply-fecha { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; text-transform: capitalize; }

/* Login con contraseña */
.login-user-activa { border-color: var(--accent, #059669) !important; }
.login-pass-row { display: flex; gap: 8px; margin: 6px 0 10px; }
.login-pass-input { flex: 1; padding: 11px 14px; border: 1px solid var(--border, #e2e5e9); border-radius: 10px; font-size: 14px; font-family: inherit; outline: none; }
.login-pass-input:focus { border-color: var(--accent, #059669); }
.login-pass-entrar { padding: 11px 18px; background: var(--accent, #059669); color: #fff; border: none; border-radius: 10px; font-weight: 700; font-size: 13.5px; cursor: pointer; font-family: inherit; }
.login-pass-entrar:disabled { opacity: .6; }
/* Filtros y estados del circuito de firma de contratos */
.ct-filtros { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.ct-filtro { padding: 7px 14px; border: 1px solid var(--border); background: var(--bg-card); border-radius: 18px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; font-family: inherit; }
.ct-filtro-activo { border-color: var(--accent); color: #fff; background: var(--accent); }
.badge-enviado { background: #f59e0b; color: #fff; }
.badge-firmado { background: #059669; color: #fff; }

/* ===== Chat interno de oficina ===== */
.chatint-head-left { margin-top: 10px; padding: 8px 4px 5px; font-weight: 800; font-size: 11.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--text-secondary); border-top: 1px solid var(--border); }
.chatint-lista { max-height: 38%; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.chatint-user-activo { background: var(--accent) !important; }
.chatint-user-activo b, .chatint-user-activo small { color: #fff !important; }
.chatint-user { display: flex; align-items: center; gap: 10px; padding: 9px 10px; background: none; border: none; border-radius: 10px; cursor: pointer; text-align: left; font-family: inherit; width: 100%; }
.chatint-user:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
.chatint-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.chatint-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chatint-user-info b { font-size: 13px; color: var(--text-primary); }
.chatint-user-info small { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatint-badge { background: #dc2626; color: #fff; font-size: 11px; font-weight: 800; border-radius: 10px; padding: 2px 7px; }
.chatint-conv-head { display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 800; font-size: 14.5px; }
.chatint-conv-tag { font-size: 10.5px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; color: #fff; background: var(--accent); border-radius: 7px; padding: 3px 8px; }
.chatint-mensajes { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px; display: flex; flex-direction: column; gap: 7px; background: var(--bg-main); border-radius: 10px; }
.chatint-mensajes.hidden, #chatint-input-row.hidden, .chatint-conv-head.hidden { display: none; }
.chatint-msg { position: relative; max-width: 62%; padding: 8px 12px 5px; border-radius: 11px; font-size: 13.5px; line-height: 1.45; }
.chatint-mio { align-self: flex-end; background: #d3ecd9; border-bottom-right-radius: 4px; }
.chatint-suyo { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chatint-meta { font-size: 10px; color: var(--text-secondary); text-align: right; margin-top: 2px; }
.chatint-fw-tag { font-size: 10.5px; color: var(--text-secondary); font-style: italic; margin-bottom: 2px; }
.chatint-eliminado { color: var(--text-secondary); font-size: 12.5px; }
.chatint-acciones { position: absolute; top: 2px; right: 4px; background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 14px; padding: 0 3px; opacity: 0; transition: opacity .15s; }
.chatint-msg:hover .chatint-acciones { opacity: 1; }
.chatint-menu { position: absolute; top: 20px; right: 4px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.14); z-index: 30; display: flex; flex-direction: column; min-width: 130px; overflow: hidden; }
.chatint-menu button { background: none; border: none; padding: 9px 13px; text-align: left; font-size: 12.5px; cursor: pointer; font-family: inherit; color: var(--text-primary); }
.chatint-menu button:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
.chatint-input-row { display: flex; gap: 7px; padding: 9px; border-top: 1px solid var(--border); align-items: flex-end; }
.chatint-input-row textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px; font-size: 13px; font-family: inherit; background: var(--bg-main); color: var(--text-primary); }
.chatint-enviar { background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 8px 11px; cursor: pointer; display: flex; align-items: center; }
.burbuja-reenviar { position: absolute; top: 6px; right: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 3px 6px; cursor: pointer; color: var(--text-secondary); opacity: 0; transition: opacity .15s; }
.chatia-burbuja { position: relative; }
.chatia-burbuja:hover .burbuja-reenviar { opacity: 1; }
.reenviar-preview { background: var(--bg-main); border-left: 3px solid var(--accent); border-radius: 8px; padding: 9px 12px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 12px; max-height: 90px; overflow: hidden; }
.reenviar-usuarios { display: flex; flex-direction: column; gap: 4px; }


/* Orden de módulos por usuario (admin) */
.mod-row { display: flex; align-items: center; gap: 8px; }
.mod-row .mod-check { flex: 1; }
.mod-flechas { display: flex; gap: 3px; }
.mod-flecha { background: var(--bg-main); border: 1px solid var(--border); border-radius: 7px; padding: 2px 8px; cursor: pointer; font-size: 11px; color: var(--text-secondary); }
.mod-flecha:hover:not(:disabled) { background: var(--accent); color: #fff; }
.mod-flecha:disabled { opacity: .4; cursor: default; }
.mod-orden-nota { font-size: 12px; color: var(--text-secondary); margin: 8px 0 0; }

/* ===== Asistente de conciliación uno a uno ===== */
.conc-wizard { position: fixed; inset: 0; z-index: 300; background: #eef1ef; display: flex; flex-direction: column; }
.conc-w-top { display: flex; align-items: center; gap: 18px; padding: 14px 22px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.conc-w-titulo { font-weight: 800; font-size: 15px; }
.conc-w-prog-wrap { flex: 1; display: flex; align-items: center; gap: 12px; }
.conc-w-barra { flex: 1; max-width: 420px; height: 8px; background: var(--border); border-radius: 6px; overflow: hidden; }
#conc-w-barra-fill { height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .25s; }
#conc-w-prog { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.conc-w-cerrar { background: none; border: 1px solid var(--border); border-radius: 9px; font-size: 20px; line-height: 1; padding: 4px 11px; cursor: pointer; color: var(--text-secondary); }
.conc-w-centro { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.conc-w-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 8px 30px rgba(0,0,0,.08); padding: 34px 38px; width: 560px; max-width: 94vw; text-align: center; }
.conc-w-fecha { font-size: 13px; font-weight: 700; color: var(--text-secondary); letter-spacing: .4px; }
.conc-w-importe { font-size: 44px; font-weight: 800; margin: 6px 0 2px; letter-spacing: -1px; }
.conc-w-verde { color: #059669; }
.conc-w-rojo { color: #dc2626; }
.conc-w-concepto { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; overflow-wrap: anywhere; }
.conc-w-match { background: var(--bg-main); border-radius: 13px; padding: 16px 18px; margin-bottom: 22px; text-align: left; }
.conc-w-match-lbl { font-size: 11px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.conc-w-prop { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.conc-w-prop b { font-size: 15.5px; }
.conc-w-prop span { color: var(--text-secondary); }
.conc-w-prop-imp { margin-left: auto; font-weight: 800; color: var(--text-primary) !important; }
.conc-w-select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; background: var(--bg-card); }
.conc-w-aviso { margin-top: 10px; font-size: 12.5px; color: #92400e; background: #fef3c7; border-radius: 9px; padding: 9px 12px; line-height: 1.45; }
.conc-w-nomatch { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.conc-w-acciones { display: flex; flex-direction: column; gap: 8px; }
.conc-w-btn { padding: 13px 18px; font-size: 15px; border-radius: 11px; }
.conc-w-quitar { color: #dc2626; }
.conc-w-fin { text-align: center; }

/* Candidatas clicables del asistente de conciliación */
.conc-w-emisor { display: block; font-weight: 800; font-size: 15.5px; color: var(--text-primary); margin-bottom: 2px; }
.conc-w-conc-txt { display: block; }
.conc-w-cands { display: flex; flex-direction: column; gap: 7px; }
.conc-w-cand { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 14px; background: var(--bg-card); border: 2px solid var(--border); border-radius: 11px; cursor: pointer; font-family: inherit; font-size: 14px; transition: border-color .12s; }
.conc-w-cand:hover { border-color: var(--accent); }
.conc-w-cand-sel { border-color: var(--accent); background: #eef7f0; }
.conc-w-cand-num { font-weight: 800; white-space: nowrap; }
.conc-w-cand-terc { flex: 1; color: var(--text-secondary); min-width: 0; }
.conc-w-cand-ok { color: #059669; font-weight: 700; font-size: 12px; }
.conc-w-cand-imp { font-weight: 800; white-space: nowrap; }
.conc-w-emisor-na { color: var(--text-secondary); font-weight: 600; font-size: 13px; font-style: italic; }

/* Lista de conciliación: tabla formal */
#contab-panel-conciliacion .table-container { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
#contab-panel-conciliacion table { table-layout: auto; width: 100%; border-collapse: collapse; }
#contab-panel-conciliacion thead th { text-align: left; font-size: 11px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--text-secondary); padding: 12px 14px; background: var(--bg-main); border-bottom: 1px solid var(--border); }
#contab-panel-conciliacion thead th { white-space: nowrap; }
#contab-panel-conciliacion thead th:nth-child(3) { text-align: right; }
#contab-panel-conciliacion thead th:nth-child(5) { text-align: right; }
.conc-fila td { padding: 14px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.conc-fila:last-child td { border-bottom: none; }
.conc-fila:hover td { background: rgba(0,0,0,.015); }
.conc-td-fecha { white-space: nowrap; color: var(--text-secondary); font-size: 13px; font-variant-numeric: tabular-nums; }
.conc-td-banco { max-width: 300px; }
.conc-td-banco b { display: block; font-size: 13.5px; }
.conc-td-banco small { display: block; color: var(--text-secondary); font-size: 12.5px; margin-top: 2px; }
.conc-td-importe { white-space: nowrap; text-align: right; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.conc-td-casado { min-width: 220px; }
.conc-prop { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; max-width: 100%; flex-wrap: wrap; }
.conc-prop b { white-space: nowrap; }
.conc-prop-terc { color: var(--text-secondary); }
.conc-prop-imp { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.conc-select { max-width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; font-family: inherit; background: var(--bg-card); }
.conc-tag { display: inline-block; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.conc-tag-aviso { display: block; width: fit-content; background: #fef3c7; color: #92400e; margin: 6px 0 0; font-weight: 700; border-radius: 7px; padding: 3px 9px; font-size: 11.5px; }
.conc-td-acciones { white-space: nowrap; text-align: right; }
.conc-td-acciones .btn-small { margin-right: 8px; }
.conc-quitar { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--text-secondary); font-size: 12px; }
.conc-quitar:hover { border-color: #dc2626; color: #dc2626; }

/* Zona de importar con tarjeta de fondo; filas hechas en verde pastel */
.conc-import-card { background: var(--bg-main); border: 1px solid var(--border); border-radius: 13px; padding: 18px 20px; }
.conc-fila-hecha td { background: #e9f6ee; }
.conc-fila-hecha:hover td { background: #e0f1e6; }
.conc-hecho-badge { display: inline-block; background: #059669; color: #fff; font-size: 12px; font-weight: 800; border-radius: 8px; padding: 5px 11px; }

/* Clip de adjuntos del chat IA */
.chatia-clip { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; cursor: pointer; color: var(--text-secondary); display: flex; align-items: center; }
.chatia-clip:hover { color: var(--accent); border-color: var(--accent); }
.chatia-adj-chip { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 6px; background: var(--bg-main); border: 1px solid var(--border); border-radius: 9px; padding: 6px 11px; font-size: 12.5px; }
.chatia-adj-chip button { background: none; border: none; cursor: pointer; font-size: 15px; color: var(--text-secondary); padding: 0 2px; }

/* Tablas markdown del chat IA */
.chatia-tabla { border-collapse: collapse; margin: 8px 0; font-size: 12.5px; width: 100%; background: var(--bg-card); border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.chatia-tabla th { background: var(--bg-main); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); padding: 7px 11px; text-align: left; border-bottom: 1px solid var(--border); }
.chatia-tabla td { padding: 7px 11px; border-bottom: 1px solid var(--border); }
.chatia-tabla tr:last-child td { border-bottom: none; }
.chatia-tabla td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
