/* ==========================================================================
   DESIGN SYSTEM & VARIABLES: CORVUS LIGHT ORANGE & WHITE THEME
   ========================================================================== */
:root {
  /* Color Palette (Zincamur Style Manual Guidelines) */
  --bg-primary: #f4f5f7;          /* Soft concrete/industrial gray */
  --bg-secondary: #ffffff;        /* Pure White */
  --border-color: rgba(74, 74, 74, 0.25); /* Subtle Steel Gray border */
  --border-focus: #0078E2;        /* Zincamur Blue Light */
  
  --text-primary: #1c1c1c;        /* Deep near-black for body text */
  --text-secondary: #4a4a4a;      /* Steel Gray for paragraphs and labels */
  --text-muted: #7d7d7d;          /* Concrete Gray for helper text/subtitles */
  
  /* Brand Specific and Status Colors */
  --color-primary: #005CAA;       /* Zincamur Blue (Corporate) */
  --color-primary-hover: #0078E2; /* Zincamur Blue Light */
  --color-accent: #FFB400;        /* Zincamur Accent (Industrial Yellow/Orange) */
  --color-accent-hover: #0078E2;  /* Focus hover */
  --color-warning: #FFB400;       /* Warning/In Progress */
  --color-danger: #ef4444;        /* Danger/Remove */
  --color-info: #0078E2;          /* Info/Done */

  /* Fonts (Google Fonts: Montserrat for Headings, Roboto for Body) */
  --font-title: 'Montserrat', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Roboto', 'Segoe UI', system-ui, sans-serif;
  
  /* Spacing & Borders (0px straight line concept, soft 4px corner round) */
  --border-radius-lg: 4px;
  --border-radius-md: 4px;
  --border-radius-sm: 4px;
  --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --box-shadow-premium: 0 2px 6px rgba(0, 0, 0, 0.08); /* Minimal card shadow */
  --box-shadow-hover: 0 4px 12px rgba(0, 57, 122, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 13.5px;
}
@media (min-width: 1200px) {
  html {
    font-size: 14.5px;
  }
}
@media (min-width: 1440px) {
  html {
    font-size: 15.5px;
  }
}
@media (min-width: 1600px) {
  html {
    font-size: 16px;
  }
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  color: var(--text-primary);
  margin-bottom: 4px;
}

h1 { font-size: 48px; line-height: 1.2; font-weight: 600; font-display: swap; }
h2 { font-size: 36px; line-height: 1.3; font-weight: 600; font-display: swap; }
h3 { font-size: 28px; line-height: 1.3; font-weight: 600; font-display: swap; }
h4 { font-size: 22px; line-height: 1.4; font-weight: 500; font-display: swap; }
h5 { font-size: 18px; line-height: 1.4; font-weight: 500; font-display: swap; }
h6 { font-size: 16px; line-height: 1.4; font-weight: 400; font-display: swap; }

/* Custom Scrollbar for Light Theme */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================================================
   COMPONENTS: UTILITIES, BUTTONS, BADGES, CARDS
   ========================================================================== */
.glassmorphism {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--box-shadow-premium);
  border-radius: var(--border-radius-lg);
  transition: var(--transition-smooth);
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.5;
  padding: 10px 18px;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
  background-color: var(--color-accent); /* #FFB400 - Zincamur Accent */
  color: var(--bg-secondary); /* #FFFFFF */
  border-color: var(--color-accent);
}
.btn-primary:hover {
  background-color: var(--color-primary-hover); /* #0078E2 - Zincamur Blue Light */
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 120, 226, 0.2);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid rgba(74, 74, 74, 0.4); /* Steel Gray border */
}
.btn-secondary:hover {
  background: var(--bg-primary);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.btn-accent {
  background-color: var(--color-primary); /* Zincamur Blue */
  color: var(--bg-secondary);
  border-color: var(--color-primary);
}
.btn-accent:hover {
  background-color: var(--color-primary-hover); /* Zincamur Blue Light */
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 92, 170, 0.2);
}

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
}
.btn-danger:hover {
  background: #b91c1c;
}

.btn-text {
  background: transparent;
  color: var(--color-primary);
  padding: 6px 12px;
}
.btn-text:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

.btn-icon {
  background: var(--color-primary);
  border-radius: var(--border-radius-sm);
  padding: 6px;
  color: white;
}
.btn-icon:hover {
  background: var(--color-primary-hover);
}

.btn-block {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Badges */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(249, 115, 22, 0.1);
  color: var(--color-primary-hover);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-accent {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

/* Form Controls */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-family: var(--font-title);
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

input, select, textarea {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--border-radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: var(--transition-smooth);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

/* ==========================================================================
   HEADER SECTION
   ========================================================================== */
.main-header {
  border-bottom: 2px solid var(--color-primary); /* Solid #005CAA bottom line */
  background: #ffffff; /* White background to let the blue logo stand out */
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.header-container {
  max-width: 1600px; /* Aligned with dashboard-container */
  margin: 0 auto;
  padding: 8px 24px 8px 12px; /* Reduced left padding to move hamburger more to the left */
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  height: 38px; /* Sized up from 32px to 38px */
  width: auto;
  object-fit: contain;
}

.logo-text h1 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--color-primary); /* Zincamur Corporate Blue */
  line-height: 1.1;
}

.logo-text p {
  font-size: 0.68rem;
  color: var(--text-muted); /* #7D7D7D Concrete Gray */
  font-weight: 500;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

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

/* Header button overrides */
.main-header .btn {
  padding: 8px 16px;
  font-size: 0.88rem;
}

.main-header .btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid rgba(74, 74, 74, 0.4);
}
.main-header .btn-secondary:hover {
  background: var(--bg-primary);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

/* Header Badges with High Contrast on White */
.main-header .badge {
  background: rgba(0, 92, 170, 0.08) !important;
  color: var(--color-primary) !important; /* #005CAA */
  border: 1px solid rgba(0, 92, 170, 0.15) !important;
  font-size: 0.75rem;
  padding: 4px 10px;
}

.main-header .badge-accent {
  background: rgba(255, 180, 0, 0.12) !important;
  color: #92400e !important; /* Premium dark amber with 4.8:1 contrast on white */
  border: 1px solid rgba(255, 180, 0, 0.25) !important;
  font-size: 0.75rem;
  padding: 4px 10px;
}

/* ==========================================================================
   DASHBOARD GRID & PANES
   ========================================================================== */
.dashboard-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* Grid Top (Ingestion and Master Data) - 12-column layout as per manual */
.grid-top {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
  width: 100%;
}

.pane-ingestion {
  grid-column: span 6;
}

.pane-master-data {
  grid-column: span 6;
}

.pane-admin,
.pane-albaranes {
  grid-column: span 12;
}

@media (max-width: 1024px) {
  .pane-ingestion,
  .pane-master-data,
  .pane-admin,
  .pane-albaranes {
    grid-column: span 12;
  }
}

.card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.card-header h2 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Ingestion Form */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

.lineas-container {
  margin-bottom: 16px;
  background: #f8fafc;
  padding: 16px;
  border-radius: var(--border-radius-md);
  border: 1px dashed #cbd5e1;
}

.table-ingestion-lineas th {
  padding: 10px 8px;
  font-weight: 600;
  color: #004A8F;
  border-bottom: 2px solid #e2e8f0;
}

.table-ingestion-lineas td {
  padding: 6px;
  vertical-align: middle;
}

.table-ingestion-lineas input {
  transition: all 0.2s ease-in-out;
}

.table-ingestion-lineas input:focus {
  border-color: #0078E2 !important;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 120, 226, 0.15);
}

.btn-remove-line {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Master Data Tabs */
.tab-buttons {
  display: flex;
  background: #f1f5f9;
  border-radius: var(--border-radius-sm);
  padding: 3px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-title);
  padding: 6px 14px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.scroll-pane {
  max-height: 330px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-content.active {
  display: flex;
}

.list-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.list-item-db {
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--color-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.list-item-db h4 {
  font-weight: 700;
  color: var(--text-primary);
}

.list-item-db p {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 2px;
}

.list-item-db .price-tag {
  font-weight: 700;
  color: var(--color-primary); /* #005CAA - Zincamur Blue */
  background: rgba(0, 92, 170, 0.08);
  padding: 4px 8px;
  border-radius: 4px;
}

.form-quick-add {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-quick-add h3 {
  font-family: var(--font-title);
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 700;
}

.form-row-three {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 40px;
  gap: 8px;
}

/* Collapsible Panels */
.collapsible-header {
  cursor: pointer;
  user-select: none;
}
.collapsible-header:hover h2 {
  color: var(--color-primary-hover);
}
.collapse-arrow {
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}
.card.collapsed .card-body {
  display: none !important;
}
.card.collapsed {
  padding-bottom: 14px;
}
.card.collapsed .collapse-arrow {
  transform: rotate(-90deg);
}

/* ==========================================================================
   KANBAN BOARD SECTION
   ========================================================================== */
.kanban-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 32px; /* Adds clear spacing above the 'Volver' button at Level 3 */
}

.section-header-row {
  border-left: 4px solid var(--color-primary);
  padding-left: 14px;
}

.section-header-row h2 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}

.kanban-col {
  background: #f4f5f7;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg); /* 4px */
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 480px;
}

#col-RECEPCIONADO { border-top: 4px solid #7d7d7d; } /* Concrete Gray */
#col-EN_PROCESO { border-top: 4px solid #FFB400; }     /* Industrial Yellow (Accent) */
#col-TERMINADO { border-top: 4px solid #0078E2; }      /* Zincamur Blue Light */
#col-EXPEDICION { border-top: 4px solid #005CAA; }     /* Zincamur Blue Dark */

.col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(74, 74, 74, 0.15);
  padding-bottom: 10px;
}

.col-header h3 {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary) !important; /* Dark text for perfect contrast */
}

.col-count {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}

.col-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 400px;
  padding-bottom: 60px;
}

/* Kanban Cards (Light Theme Premium) */
.kanban-card {
  background: #ffffff; /* pure-white */
  border: 1px solid #4a4a4a; /* steel-gray */
  border-left: 4px solid #005caa; /* zincamur-blue */
  border-radius: var(--border-radius-md); /* 4px */
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: grab;
  position: relative;
  transition: var(--transition-smooth);
  box-shadow: var(--box-shadow-premium);
}

.kanban-card:hover {
  transform: translateY(-2px);
  border-color: #0078e2; /* zincamur-blue-light */
  box-shadow: var(--box-shadow-hover);
}

.card-hierarchy-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #004a8f; /* zincamur-blue-dark */
  border-left: 3px solid #005caa; /* zincamur-blue */
  border-radius: 2px;
  padding: 6px;
  font-size: 0.7rem;
  margin-bottom: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
  color: #ffffff;
}

.card-hierarchy-banner span {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff !important;
}

.card-hierarchy-banner .cli-part {
  color: #ffffff !important;
  font-weight: 700;
}

.card-hierarchy-banner .trk-part {
  color: #ffb400 !important; /* zincamur-accent yellow/orange */
  font-weight: 600;
}

.card-hierarchy-banner .ped-part {
  color: #ffffff !important;
  font-family: monospace;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 2px;
  width: fit-content;
}

.card-top-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.card-prod-ref {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.card-pedido,
.card-pedido-label {
  font-size: 0.75rem;
  color: var(--color-primary-hover);
  background: rgba(249, 115, 22, 0.08);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--border-radius-sm);
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.card-mid-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 8px;
}

.card-cant {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}

.card-serie {
  font-size: 0.7rem;
  font-family: monospace;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-serie-badge {
  display: inline-block;
  background: rgba(0, 92, 170, 0.12);
  color: var(--primary-color, #005caa);
  font-size: 0.62rem;
  font-family: inherit;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 3px;
  cursor: help;
  font-weight: 600;
  vertical-align: middle;
}

.card-actions-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}

.card-actions-row .btn-sm {
  padding: 5px 10px;
  font-size: 0.75rem;
  border-radius: var(--border-radius-sm);
}

.hierarchy-indicator {
  font-size: 0.65rem;
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

/* ==========================================================================
   EXPEDITION SHIPPING & CARS
   ========================================================================== */
.expedition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
}

.expedition-card-client {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.02);
}

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

.expedition-client-header h3 {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.expedition-order-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
  padding: 12px;
  border-radius: var(--border-radius-md);
  border: 1px solid #f1f5f9;
}

.order-title {
  font-family: var(--font-title);
  font-size: 0.85rem;
  color: var(--color-primary-hover);
  font-weight: 700;
}

.order-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.order-items-table th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
}

.order-items-table td {
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
}

.order-items-table .text-right {
  text-align: right;
}

.expedition-client-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.total-value {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary-hover);
}

/* ==========================================================================
   MODAL WINDOW STYLING
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
@media (max-height: 700px) {
  .modal-overlay {
    align-items: flex-start;
  }
  .modal-content {
    margin-top: 20px;
    margin-bottom: 20px;
  }
}

.modal-content {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: modalEnter 0.25s ease-out;
}

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

@keyframes modalEnter {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.split-info {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 14px 16px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.split-info div {
  color: var(--text-secondary);
}

.split-info span {
  color: var(--text-primary);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   INVOICE / OUTBOUND NOTE BOX (PRINT STYLE FOR SCREEN)
   ========================================================================== */
.invoice-box {
  background: #ffffff;
  color: #334155;
  padding: 24px;
  border: 1px solid #cbd5e1;
  border-radius: var(--border-radius-md);
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1.5;
}

.invoice-header {
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 12px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: start;
  flex-wrap: wrap;
  gap: 12px;
}

.invoice-logo {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--color-primary-hover);
}

.invoice-meta {
  text-align: right;
}

.invoice-meta h4 {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 18px;
}

.party-col h5 {
  font-family: var(--font-title);
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
  font-size: 0.8rem;
}

.invoice-table th {
  background: #f8fafc;
  color: var(--text-primary);
  font-weight: 700;
  text-align: left;
  padding: 8px;
  border: 1px solid #cbd5e1;
}

.invoice-table td {
  padding: 8px;
  border: 1px solid #e2e8f0;
}

.invoice-table .num-col {
  text-align: right;
}

.invoice-total-row {
  border-top: 2px solid #cbd5e1;
  padding-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.invoice-grand-total {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-primary-hover);
}

/* ==========================================================================
   TOAST NOTIFICATION & FOOTER
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  border: 1px solid var(--color-primary);
  border-left: 5px solid var(--color-primary);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  border-radius: var(--border-radius-md);
  padding: 14px 20px;
  color: var(--text-primary);
  z-index: 2000;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.dashboard-footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  margin-top: 60px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
}

/* ==========================================================================
   STRICT RESPONSIVENESS AND SCREEN ADAPTATIONS
   ========================================================================== */

/* 1. Pantallas Medianas (Tablets y Desktop pequeños: max 1024px) */
@media (max-width: 1024px) {
  .grid-top {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .kanban-board {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  
  .kanban-col {
    min-height: 420px;
  }
}

/* 2. Pantallas de Tablets pequeñas (max 768px) */
@media (max-width: 768px) {
  .header-container {
    padding: 10px 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  
  .header-actions .btn {
    flex: 1;
    min-width: 120px;
    font-size: 0.85rem;
    padding: 8px 12px;
  }
  
  .dashboard-container {
    padding: 16px;
    gap: 20px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .linea-row {
    grid-template-columns: 1.5fr 1fr 0.8fr 30px;
    gap: 4px;
  }

  .form-row-three {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  
  .form-row-three .btn-icon {
    width: 100%;
    height: 38px;
    border-radius: var(--border-radius-md);
  }
  
  .invoice-parties {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .invoice-meta {
    text-align: left;
  }
}

/* 3. Pantallas Móviles (max 480px) */
@media (max-width: 480px) {
  .logo-text h1 {
    font-size: 1.3rem;
  }
  
  .kanban-board {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .kanban-col {
    min-height: auto;
    padding: 12px;
  }
  
  .col-cards {
    min-height: auto;
    padding-bottom: 20px;
  }

  .linea-row {
    grid-template-columns: 1fr;
    background: #ffffff;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    position: relative;
  }
  
  .btn-remove-line {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 1.2rem;
  }
  
  .expedition-grid {
    grid-template-columns: 1fr;
  }
  
  .expedition-card-client {
    padding: 14px;
  }
  
  .invoice-box {
    padding: 12px;
  }
  
  .invoice-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

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

/* ==========================================================================
   AUTH SCREEN & ADMIN CONSOLE STYLES
   ========================================================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(rgba(0, 74, 143, 0.7), rgba(74, 74, 74, 0.8)), url('concrete_texture.jpg') no-repeat center center;
  background-size: cover;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  padding: 32px;
  border-radius: var(--border-radius-lg); /* 4px */
  border: 1px solid rgba(74, 74, 74, 0.2);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-logo-icon {
  font-size: 3rem;
  filter: drop-shadow(0 4px 10px rgba(249, 115, 22, 0.25));
}

.login-header h2 {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.login-demo-credentials {
  background: #f8fafc;
  padding: 14px 16px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.login-demo-credentials h4 {
  font-family: var(--font-title);
  color: var(--text-primary);
  margin-bottom: 6px;
  font-weight: 700;
}

.login-demo-credentials ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-demo-credentials code {
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--color-primary-hover);
  font-weight: 600;
}

/* Consola de Administración (Admin Grid) */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
}

.admin-sub-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-sub-card h3 {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-primary-hover);
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.splits-audit-container, .danger-zone-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.splits-audit-container {
  flex: 1;
}

.danger-zone-container {
  background: #fff5f5;
  border: 1px solid #fee2e2;
  border-radius: var(--border-radius-md);
  padding: 14px;
  margin-top: 10px;
}

.danger-zone-container h3 {
  color: var(--color-danger);
  border-bottom: 1px solid #fecaca;
  padding-bottom: 6px;
}

.audit-log-item {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  line-height: 1.45;
  margin-bottom: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.audit-log-item span.highlight {
  font-weight: 700;
  color: var(--color-primary-hover);
}

/* Micro-animación de error de Login (shake) */
.shake-anim {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ==========================================================================
   COLOR POR CLIENTE — 8 slots asignados por hash del nombre de empresa
   El mismo cliente siempre recibe el mismo color en cualquier sesión.
   Se aplica al borde izquierdo de la tarjeta + tinte del banner superior.
   ========================================================================== */

/* [Slot overrides removed to enforce uniform Zincamur branding per style manual] */

/* ==========================================================================
   PRINT MEDIA STYLES
   ========================================================================== */
@media print {
  body {
    background: white !important;
    color: black !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* Ocultar todo menos el modal del albarán */
  body > *:not(#modal-albaran-salida) {
    display: none !important;
  }
  
  /* Asegurar que el modal sea visible y ocupe toda la página */
  #modal-albaran-salida {
    position: static !important;
    display: block !important;
    background: white !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }
  
  /* Ocultar la cabecera del modal y las acciones (botones) */
  #modal-albaran-salida .modal-header,
  #modal-albaran-salida .modal-actions {
    display: none !important;
  }
  
  /* Adaptar el contenedor del contenido para impresión */
  #modal-albaran-salida .modal-content {
    background: white !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .invoice-box {
    border: none !important;
    padding: 0 !important;
  }
}

/* ==========================================================================
   NAVIGATION FLOW & CLIENT GRID STYLES (NIVEL 1 & 2)
   ========================================================================== */
.flow-view {
  animation: fadeIn 0.3s ease-in-out;
}

.flow-view.hidden {
  display: none !important;
}

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.client-card {
  padding: 24px;
  cursor: pointer;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  box-shadow: var(--box-shadow-premium);
  position: relative;
  overflow: hidden;
}

.client-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-primary);
  opacity: 0.5;
  transition: var(--transition-smooth);
}

.client-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--box-shadow-hover);
  border-color: var(--color-primary);
}

.client-card:hover::before {
  opacity: 1;
  width: 6px;
}

.client-card.global-card {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.05), rgba(234, 88, 12, 0.05));
  border: 2px solid var(--color-primary);
}

.client-card.global-card::before {
  background: linear-gradient(to bottom, var(--color-primary), #ea580c);
  opacity: 1;
  width: 6px;
}

.client-card h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-card .client-cif {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.client-card .pending-badge {
  align-self: flex-start;
  margin-top: 12px;
  background: rgba(249, 115, 22, 0.1);
  color: var(--color-primary-hover);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid rgba(249, 115, 22, 0.2);
}

.client-card.global-card .pending-badge {
  background: var(--color-primary);
  color: #ffffff;
  border: none;
}

.action-card {
  transition: var(--transition-smooth);
}

.action-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--box-shadow-hover);
}

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

/* ==========================================================================
   ZINCAMUR HIGH-FIDELITY PRINT STYLES
   ========================================================================== */
.zincamur-invoice {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: #1e293b;
  background: #ffffff;
  padding: 24px;
  max-width: 800px;
  margin: 0 auto;
}

.zincamur-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.zincamur-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zincamur-logo-container {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.zincamur-logo-img {
  height: 65px; /* Altura proporcional exacta a la del PDF original */
  width: auto;
  object-fit: contain;
  display: block;
}

.zincamur-contact-info {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-top: 6px;
  gap: 2px;
}

.zincamur-locations {
  display: flex;
  gap: 30px;
  font-size: 0.75rem;
  color: #334155;
  line-height: 1.4;
}

.loc-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loc-col strong {
  color: #0284c7;
  font-weight: 700;
  margin-bottom: 2px;
}

.zincamur-wave-container {
  margin: 14px 0;
  border-bottom: 3px solid #0284c7;
}

.zincamur-doc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 4px 0;
}

.zincamur-doc-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.zincamur-doc-number {
  color: #ef4444; /* Red color for number */
  font-size: 1.5rem;
  font-weight: 800;
}

.zincamur-doc-date {
  font-size: 1.1rem;
  font-weight: 600;
  color: #334155;
}

.zincamur-doc-date span {
  border-bottom: 1px solid #94a3b8;
  padding: 0 8px;
  font-family: monospace;
}

.zincamur-client-box {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
  background: #f8fafc;
}

.client-row {
  display: flex;
  gap: 16px;
}

.client-field {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0284c7;
  width: 90px;
  flex-shrink: 0;
}

.field-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f172a;
  border-bottom: 1px dashed #cbd5e1;
  flex-grow: 1;
  padding-bottom: 2px;
}

.zincamur-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.zincamur-table th {
  background: #0284c7;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.zincamur-table td {
  padding: 12px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
  vertical-align: top;
}

.concepto-title {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.9rem;
}

.concepto-pedido {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
  font-weight: 600;
}

.zincamur-total-container {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.zincamur-total-box {
  border: 2px solid #0284c7;
  border-radius: 6px;
  padding: 10px 20px;
  background: #f0f9ff;
  display: flex;
  align-items: center;
  gap: 16px;
}

.total-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: #0284c7;
}

.total-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: #0f172a;
}

.zincamur-footer {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
  margin-top: 36px;
}

/* Print specific adjustments for the modal content */
@media print {
  /* Hide shadows, borders and background in print */
  #modal-albaran-salida .modal-content {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }
  
  .zincamur-invoice {
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .zincamur-client-box {
    background: transparent !important;
  }
  
  .zincamur-total-box {
    background: transparent !important;
  }
}

/* ==========================================================================
   ZINCAMUR WATERMARK & SIGNATURE STYLES
   ========================================================================== */
.zincamur-watermark {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  width: 380px;
  height: 380px;
  opacity: 0.025; /* Muy sutil para pantalla e impresión */
  pointer-events: none;
  z-index: 0;
}

.zincamur-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 50px;
  margin-bottom: 20px;
  gap: 60px;
  z-index: 1;
  position: relative;
}

.signature-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sig-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #0284c7;
  letter-spacing: 0.5px;
  margin-bottom: 45px; /* Espacio para firmar a mano */
  text-transform: uppercase;
}

.sig-line {
  width: 80%;
  border-bottom: 1px solid #94a3b8;
  margin-bottom: 6px;
}

.sig-sub {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 600;
}

/* Asegurar que la factura tenga posición relativa para posicionar la marca de agua */
.zincamur-invoice {
  position: relative;
}

/* Premium PDF Generation Overlay */
.pdf-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  color: #ffffff;
  animation: fadeIn 0.25s ease-out;
}

.pdf-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-left-color: #0284c7; /* Zincamur Blue */
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.pdf-loading-text {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.pdf-loading-subtext {
  font-size: 0.85rem;
  color: #94a3b8;
}

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

/* Hidden Print Container specifically for PDF Generation */
#pdf-render-temp-container {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 794px; /* A4 standard width at 96 DPI */
  background: #ffffff;
}

#pdf-render-temp-container .zincamur-invoice {
  width: 100% !important;
  max-width: 100% !important;
  padding: 30px !important;
  margin: 0 !important;
  box-shadow: none !important;
  border: none !important;
}

/* ==========================================================================
   RESPONSIVE INVOICE & PRINT MODAL (UX/UI ADAPTATIONS)
   ========================================================================== */

/* Solo se aplica en pantalla (screen) para no afectar la impresión (print) ni la exportación a PDF */
@media screen and (max-width: 680px) {
  .zincamur-invoice {
    padding: 16px !important;
  }

  .zincamur-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
  }

  .zincamur-locations {
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
    width: 100%;
  }

  .zincamur-doc-meta {
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
  }

  .zincamur-doc-title {
    font-size: 1.1rem;
  }

  .zincamur-client-box {
    padding: 12px;
    gap: 12px;
  }

  .client-row {
    flex-direction: column;
    gap: 10px;
  }

  .client-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
  }

  .field-label {
    width: auto;
    font-size: 0.75rem;
  }

  .field-value {
    width: 100%;
    font-size: 0.85rem;
  }

  .zincamur-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .zincamur-total-container {
    justify-content: center;
    width: 100%;
  }

  .zincamur-total-box {
    width: 100%;
    justify-content: space-between;
    padding: 10px 14px;
  }

  .zincamur-signatures {
    flex-direction: column;
    gap: 40px;
    align-items: center;
    margin-top: 30px;
  }

  .signature-box {
    width: 100%;
    max-width: 280px;
  }
}

/* Adaptación de botones de acción en pantallas pequeñas */
@media screen and (max-width: 600px) {
  .modal-actions {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .modal-actions .btn {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
  }
}

/* Adaptación general de modales en móviles */
@media screen and (max-width: 480px) {
  .modal-overlay {
    padding: 8px;
  }

  .modal-content {
    padding: 14px;
    gap: 14px;
    border-radius: 8px;
  }

  .modal-header h3 {
    font-size: 1.1rem;
  }
}

/* ==========================================================================
   ZINCAMUR LOGIN BUTTON COLOR OVERRIDE & DARK MODE STYLING
   ========================================================================== */

/* Login box primary button color override (corporate blue instead of accent yellow) */
.login-box .btn-primary {
  background-color: var(--color-primary) !important; /* Zincamur Blue - #005CAA */
  border-color: var(--color-primary) !important;
  color: #ffffff !important;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.login-box .btn-primary:hover {
  background-color: var(--color-primary-hover) !important; /* Zincamur Blue Light - #0078E2 */
  border-color: var(--color-primary-hover) !important;
  transform: translateY(-1px);
}

/* Premium Dark Mode Variables and Redefinitions */
.dark-theme {
  --bg-primary: #121214;          /* Dark concrete/charcoal gray background */
  --bg-secondary: #1e1e24;        /* Dark gray card/section background */
  --border-color: rgba(255, 255, 255, 0.15); /* Translucent white borders */
  --border-focus: #0078E2;
  
  --text-primary: #f1f5f9;        /* Light slate for readable text */
  --text-secondary: #94a3b8;      /* Muted gray for labels and paragraphs */
  --text-muted: #64748b;          /* Darker gray for helpers/subtitles */
}

/* Specific component overrides for Dark Theme */
.dark-theme .modal-content,
.dark-theme .login-box,
.dark-theme .zincamur-invoice {
  background: #1e1e24;
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.15);
}

.dark-theme .main-header {
  background: #1e1e24;
  border-bottom: 2px solid var(--color-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  color: #f1f5f9;
}

.dark-theme .main-header .logo-text h1 {
  color: #ffffff;
}

.dark-theme .main-header .logo-text p {
  color: #94a3b8;
}

.dark-theme .main-header .btn-secondary {
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.dark-theme .main-header .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #ffffff;
}

.dark-theme .main-header .badge {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

.dark-theme .main-header .badge-accent {
  background: rgba(255, 180, 0, 0.15) !important;
  color: #ffb400 !important;
  border: 1px solid rgba(255, 180, 0, 0.3) !important;
}

.dark-theme input,
.dark-theme select,
.dark-theme textarea {
  background: #121214;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f1f5f9;
}
.dark-theme input:focus,
.dark-theme select:focus {
  border-color: var(--border-focus);
  outline: 2px solid var(--border-focus);
}

.dark-theme .list-item-db,
.dark-theme .kanban-col,
.dark-theme .admin-sub-card,
.dark-theme .expedition-order-group,
.dark-theme .split-info,
.dark-theme .invoice-box,
.dark-theme .login-demo-credentials,
.dark-theme .audit-log-item {
  background: #121214;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
}

.dark-theme .kanban-card {
  background: #1e1e24;
  border-color: rgba(255, 255, 255, 0.15);
}
.dark-theme .kanban-card:hover {
  border-color: #0078e2;
}

.dark-theme .card-hierarchy-banner {
  background: #121214;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}
.dark-theme .card-hierarchy-banner .cli-part {
  color: #f1f5f9 !important;
}
.dark-theme .card-hierarchy-banner .ped-part {
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8 !important;
}

.dark-theme .client-card {
  border-color: rgba(255, 255, 255, 0.15);
}
.dark-theme .client-card:hover {
  border-color: var(--color-primary);
}

.dark-theme .dashboard-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  background: #1e1e24;
  color: #94a3b8;
}

.dark-theme .btn-secondary {
  background: #1e1e24;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.dark-theme .btn-secondary:hover {
  background: #121214;
  border-color: var(--color-primary);
}

.dark-theme .tab-buttons {
  background: #121214;
  border-color: rgba(255, 255, 255, 0.15);
}
.dark-theme .tab-btn.active {
  background: #1e1e24;
  color: var(--color-primary-hover);
}

.dark-theme .lineas-container {
  background: #1e1e24;
  border-color: rgba(255, 255, 255, 0.2);
}

.dark-theme .expedition-card-client {
  background: #1e1e24;
  border-color: rgba(255, 255, 255, 0.15);
}

.dark-theme .total-value {
  color: #ffb400;
}

.dark-theme .col-count {
  background: #121214;
  border-color: rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
}

.dark-theme .toast {
  background: #1e1e24;
  color: #f1f5f9;
  border-color: var(--color-primary);
}

/* --- ESTILOS DE INGESTA INTELIGENTE --- */
.upload-dropzone {
  border: 2px dashed var(--border-color, #e2e8f0);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.25s ease;
  cursor: pointer;
  margin-top: 10px;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--color-primary);
  background: rgba(2, 132, 199, 0.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.upload-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.upload-dropzone h3 {
  margin: 0 0 8px 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.upload-dropzone p {
  font-size: 0.85rem;
  color: var(--text-secondary, #64748b);
  margin: 0 0 16px 0;
}

.split-container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  min-height: 580px;
  height: calc(100vh - 280px);
  transition: grid-template-columns 0.3s ease;
}

.split-container.manual-mode-full {
  grid-template-columns: 1fr;
}

.split-container.manual-mode-full .pdf-viewer-panel {
  display: none !important;
}

@media (max-width: 992px) {
  .split-container {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }
}

.pdf-viewer-panel {
  background: #0f172a;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.pdf-header {
  padding: 10px 16px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #f1f5f9;
}

.pdf-frame {
  width: 100%;
  flex-grow: 1;
  border: none;
  background: #0f172a;
}

.form-editor-panel {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 20px;
  overflow-y: auto;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Integrar con variables de modo oscuro */
.dark-theme .upload-dropzone {
  border-color: rgba(255, 255, 255, 0.15);
}

.dark-theme .upload-dropzone:hover, .dark-theme .upload-dropzone.dragover {
  border-color: var(--color-primary);
  background: rgba(2, 132, 199, 0.1);
}

.dark-theme .pdf-viewer-panel {
  border-color: rgba(255, 255, 255, 0.15);
}

.dark-theme .form-editor-panel {
  border-color: rgba(255, 255, 255, 0.15);
  background: #16161a;
}
/* --- REESTRUCTURACIÓN DEL DASHBOARD CON SIDEBAR IZQUIERDO DESPLEGABLE --- */
.dashboard-container {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
}

.dashboard-main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  width: 100%;
}

.dashboard-sidebar-left {
  position: fixed;
  top: 62px; /* Justo debajo del header */
  left: 0;
  bottom: 0;
  width: 300px;
  z-index: 1200;
  background: var(--bg-card, #ffffff);
  border-right: 1px solid var(--border-color, #e2e8f0);
  border-radius: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 6px 0 20px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.3s;
  opacity: 1;
  transform: translateX(0);
  visibility: visible;
  overflow-y: auto;
}

/* Estado Colapsado de la Barra Lateral Izquierda */
.dashboard-sidebar-left.collapsed-sidebar {
  transform: translateX(-100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.dark-theme .dashboard-sidebar-left {
  background: #16161a;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 6px 0 25px rgba(0, 0, 0, 0.3);
}

/* --- BOTÓN HAMBURGUESA EN CABECERA --- */
.btn-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1.5px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  box-sizing: border-box;
  outline: none;
  align-self: center;
  margin-right: 0; /* Let flex gap handle spacing */
  z-index: 1000;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.dark-theme .btn-hamburger {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-hamburger:hover {
  background: rgba(0, 92, 170, 0.04);
  border-color: var(--color-primary, #005CAA);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.dark-theme .btn-hamburger:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Icono hamburguesa: un único SVG elegante, siempre visible */
.btn-hamburger .hamburger-icon {
  width: 20px;
  height: 20px;
  color: var(--color-primary, #005CAA);
  display: block;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.dark-theme .btn-hamburger .hamburger-icon {
  color: #f1f5f9;
}

.btn-hamburger .hb-line {
  transition: stroke-dashoffset 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}

/* Hover: la línea del medio crece hasta la misma anchura que las demás */
.btn-hamburger:hover .hb-line-mid {
  x2: 20;
}

/* Active: pequeño impacto visual al pulsar */
.btn-hamburger:active .hamburger-icon {
  transform: scale(0.88);
}

/* Cuando el sidebar está abierto: la línea media se encoge levemente como feedback */
.btn-hamburger.open .hb-line-top {
  transform: translateY(1px);
  opacity: 0.7;
}
.btn-hamburger.open .hb-line-mid {
  opacity: 1;
}
.btn-hamburger.open .hb-line-bot {
  transform: translateY(-1px);
  opacity: 0.7;
}

/* Bloquear scroll del body cuando el sidebar está abierto en móvil */
body.sidebar-open {
  overflow: hidden;
}

/* Botón de cerrar sidebar (visible solo en móviles/tablets) */
.btn-sidebar-close {
  display: none;
}

@media (max-width: 992px) {
  .btn-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    z-index: 1300;
    transition: all 0.25s ease;
  }
  
  .btn-sidebar-close:hover,
  .btn-sidebar-close:active {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
    transform: scale(1.05);
  }
  
  .btn-sidebar-close svg {
    width: 18px;
    height: 18px;
  }
  
  .dark-theme .btn-sidebar-close {
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.05);
  }
  
  .dark-theme .btn-sidebar-close:hover,
  .dark-theme .btn-sidebar-close:active {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
  }
}

/* Info del usuario en la parte superior del sidebar */
.sidebar-user-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.dark-theme .sidebar-user-section {
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

.sidebar-user-avatar {
  font-size: 2.2rem;
}

.sidebar-user-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-user-details strong {
  font-size: 1.05rem;
  color: var(--text-primary);
}

/* Títulos y menú del sidebar */
.sidebar-menu-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary, #64748b);
  letter-spacing: 0.05em;
  margin: 12px 0 8px 0;
  font-weight: 700;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #64748b);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.sidebar-menu .menu-item:hover {
  background: rgba(2, 132, 199, 0.05);
  color: var(--color-primary);
}

.sidebar-menu .menu-item.active {
  background: var(--color-primary);
  color: #ffffff !important;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

.sidebar-menu .menu-item-danger {
  color: var(--color-danger);
}

.sidebar-menu .menu-item-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-danger);
}

/* Área de acciones rápidas de admin */
.sidebar-system-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.dark-theme .sidebar-system-actions {
  border-top-color: rgba(255, 255, 255, 0.15);
}

/* Adaptación de los apartados al espacio disponible (Ancho completo) */
#card-ingestion, #card-catalogos, #card-admin {
  grid-column: span 12 !important;
  width: 100% !important;
}

/* Adaptabilidad móvil: sidebar a pantalla completa */
@media (max-width: 992px) {
  .dashboard-container {
    padding: 12px;
    gap: 16px;
  }
  
  .dashboard-sidebar-left {
    top: 0;
    right: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-right: none;
    padding: 72px 24px 24px 24px;
    box-shadow: none;
    -webkit-overflow-scrolling: touch;
  }

  .dark-theme .dashboard-sidebar-left {
    background: #0f0f13;
  }

  /* Centrar y ampliar contenido del sidebar en pantalla completa */
  .dashboard-sidebar-left .sidebar-user-section {
    padding: 16px 0 20px 0;
    gap: 16px;
  }

  .dashboard-sidebar-left .sidebar-user-avatar {
    font-size: 2.6rem;
  }

  .dashboard-sidebar-left .sidebar-user-details strong {
    font-size: 1.15rem;
  }

  .dashboard-sidebar-left .sidebar-menu {
    gap: 8px;
  }

  .dashboard-sidebar-left .sidebar-menu .menu-item {
    padding: 14px 18px;
    font-size: 1rem;
    border-radius: 10px;
  }

  .dashboard-sidebar-left .sidebar-menu-title {
    font-size: 0.85rem;
    margin: 16px 0 10px 0;
  }

  .dashboard-sidebar-left .sidebar-system-actions {
    padding-top: 20px;
    gap: 12px;
  }

  .dashboard-sidebar-left .sidebar-system-actions .btn {
    padding: 12px 16px;
    font-size: 0.95rem;
  }

  .dashboard-main-content {
    width: 100%;
    min-width: 0;
  }
}

/* --- ESTILOS DE ICONOS SVG INTEGRADOS --- */
svg.icon-inline {
  display: inline-block;
  vertical-align: middle;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  width: 1.1em;
  height: 1.1em;
  position: relative;
  top: -1px;
  transition: transform 0.2s ease;
}

.menu-item svg.icon-inline {
  width: 18px;
  height: 18px;
  margin-right: 8px;
}

.btn svg.icon-inline {
  width: 15px;
  height: 15px;
  margin-right: 6px;
}

.badge svg.icon-inline {
  width: 12px;
  height: 12px;
  margin-right: 4px;
}

.card-header h2 svg.icon-inline,
.card-header h3 svg.icon-inline,
.modal-header h3 svg.icon-inline,
.admin-sub-card h3 svg.icon-inline {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}

.btn-icon svg.icon-inline {
  margin-right: 0;
  width: 14px;
  height: 14px;
}

/* --- REESTRUCTURACIÓN DE LA PANTALLA PRINCIPAL CON MENU LATERAL ABIERTO EN ESCRITORIO --- */
@media (min-width: 992px) {
  /* Añadimos transición suave a las propiedades de diseño de la pantalla principal */
  .dashboard-main-content {
    transition: padding-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Si el menú lateral está abierto en escritorio, desplazamos el contenido para no taparlo */
  .dashboard-sidebar-left:not(.collapsed-sidebar) ~ .dashboard-main-content {
    padding-left: 300px; /* Desplazamiento equivalente al ancho del sidebar */
  }
}

/* Limitar altura del preview del albarán para evitar desbordamiento del modal en pantallas medianas/pequeñas */
#invoice-content {
  max-height: 65vh;
  overflow-y: auto;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.dark-theme #invoice-content {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Permitir que el catálogo de clientes y productos se muestre completo sin limitar su altura */
#card-catalogos .card-body {
  max-height: none !important;
}

/* Estilos para el historial de albaranes emitidos */
.table-albaranes-emitidos {
  width: 100%;
  border-collapse: collapse;
}

.table-albaranes-emitidos th {
  padding: 12px 14px;
  font-weight: 600;
  color: #004A8F;
  border-bottom: 2px solid #e2e8f0;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

.table-albaranes-emitidos td {
  padding: 12px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.dark-theme .table-albaranes-emitidos th {
  color: #0284c7;
  border-bottom-color: #334155;
}

.dark-theme .table-albaranes-emitidos td {
  border-bottom-color: #1e293b;
  color: #cbd5e1;
}

.table-albaranes-emitidos tr:hover {
  background-color: rgba(2, 132, 199, 0.02);
}

.dark-theme .table-albaranes-emitidos tr:hover {
  background-color: rgba(2, 132, 199, 0.05);
}

/* Page break styles for high-fidelity PDF printing */
#pdf-render-temp-container .zincamur-table {
  page-break-inside: auto !important;
}

#pdf-render-temp-container .zincamur-table tr {
  page-break-inside: avoid !important;
  page-break-after: auto !important;
}

#pdf-render-temp-container .zincamur-table td, 
#pdf-render-temp-container .zincamur-table th {
  page-break-inside: avoid !important;
}

#pdf-render-temp-container .zincamur-signatures {
  page-break-inside: avoid !important;
}

#pdf-render-temp-container .zincamur-total-container {
  page-break-inside: avoid !important;
}

#pdf-render-temp-container .zincamur-footer {
  page-break-inside: avoid !important;
}
