/* ==========================================================================
   SISTEMA DE DISEÑO DUAL (DARK SLATE MINIMALISTA / LIGHT EJECUTIVO)
   Inversiones Coes SpA - Cotizador Inteligente Mercado Público
   ========================================================================== */

/* ── MODO OSCURO MINIMALISTA (Slate Pro) ─────────────────────────────────── */
:root {
  --bg-body: #0b0f19;
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #334155;
  --bg-card: rgba(30, 41, 59, 0.75);
  --bg-card-hover: rgba(51, 65, 85, 0.85);
  --bg-input: #0f172a;
  --border-color: rgba(148, 163, 184, 0.16);
  --border-subtle: rgba(148, 163, 184, 0.08);
  --border-focus: #3b82f6;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.2);

  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --btn-secondary-bg: rgba(255, 255, 255, 0.05);
  --btn-secondary-hover: rgba(255, 255, 255, 0.1);
  --btn-secondary-border: rgba(148, 163, 184, 0.2);
  --btn-secondary-text: #e2e8f0;

  --table-header-bg: #1e293b;
  --table-row-hover: rgba(59, 130, 246, 0.05);
  --table-border: rgba(148, 163, 184, 0.12);

  --bottom-bar-bg: rgba(15, 23, 42, 0.95);
  --modal-bg: #1e293b;
  --modal-header-bg: #0f172a;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.35);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── MODO CLARO EJECUTIVO (Ecosistema COES Unificado) ─────────────────────── */
[data-theme="light"], :root:not([data-theme="dark"]) {
  --bg-body: #f8fafc;
  --bg-primary: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;
  --border-focus: #2563eb;

  --primary: #1e293b;
  --primary-hover: #0f172a;
  --primary-glow: rgba(30, 41, 59, 0.15);

  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #dc2626;

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

  --btn-secondary-bg: #f1f5f9;
  --btn-secondary-hover: #e2e8f0;
  --btn-secondary-border: #e2e8f0;
  --btn-secondary-text: #0f172a;

  --table-header-bg: #f8fafc;
  --table-row-hover: #f1f5f9;
  --table-border: #e2e8f0;

  --bottom-bar-bg: rgba(255, 255, 255, 0.98);
  --modal-bg: #ffffff;
  --modal-header-bg: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 80px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 4px;
  opacity: 0.5;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Barra Superior de Navegación del Ecosistema ────────────────────────── */
.ecosystem-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.4rem 1.5rem;
  font-size: 0.8rem;
  z-index: 50;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ecosystem-links {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.eco-link {
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.eco-link:hover {
  color: var(--text-main);
  background-color: var(--bg-input);
}

.eco-link.current {
  background-color: var(--bg-input);
  color: var(--text-main);
  font-weight: 600;
  border: 1px solid var(--border-color);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 10px 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.header-inner {
  width: 100%;
  max-width: 100%;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 5px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.brand-logo {
  height: 22px;
  width: auto;
  display: block;
}

/* Visibilidad según tema */
html[data-theme="dark"] .brand-logo-light {
  display: none;
}
html[data-theme="dark"] .brand-logo-dark {
  display: block;
}

html[data-theme="light"] .brand-logo-dark {
  display: none;
}
html[data-theme="light"] .brand-logo-light {
  display: block;
}
html[data-theme="light"] .brand-logo-container {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

.brand-pro-badge {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #ffffff;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.8px;
  padding: 3px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  box-shadow: 0 1px 3px rgba(225, 29, 72, 0.35);
  line-height: 1;
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-text p {
  font-size: 11px;
  color: var(--text-muted);
}

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

.catalog-status-badge {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--accent-emerald);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.catalog-status-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
}

/* Interruptor de Tema */
.theme-toggle-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-main);
  font-size: 14px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--border-focus);
}

/* ── Layout & Containers (Ancho Completo y Márgenes Amplios COES) ───────── */
.container {
  width: 100%;
  max-width: 100%;
  margin: 1.25rem 0;
  padding: 0 1.5rem;
}

.top-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  margin-bottom: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Formularios ─────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
  align-items: start;
}

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

.form-group.full-width {
  grid-column: span 2;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 16px;
  line-height: 16px;
  margin: 0;
}

.label-hint {
  font-size: 9.5px;
  font-weight: 500;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
}

.form-group input,
.form-group select {
  height: 38px;
  box-sizing: border-box;
}

.margin-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.margin-input-group input {
  width: 85px;
  flex-shrink: 0;
}

.margin-input-group .btn {
  flex: 1;
  height: 38px;
  white-space: nowrap;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-grid-footer {
  grid-column: span 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-top: 2px;
}

[data-theme="light"] .form-grid-footer {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.formula-badge {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.iva-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
}

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* ── Tarjetas KPI ────────────────────────────────────────────────────────── */
.kpi-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
}

.kpi-card.blue::after { background: var(--primary); }
.kpi-card.emerald::after { background: var(--accent-emerald); }
.kpi-card.amber::after { background: var(--accent-amber); }
.kpi-card.purple::after { background: var(--primary); }

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* ── Pestañas de Importación ──────────────────────────────────────────────── */
.tabs-nav {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--btn-secondary-bg);
  color: var(--primary);
  border: 1px solid var(--border-color);
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

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

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid var(--btn-secondary-border);
}
.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--accent-emerald);
  color: white;
}
.btn-success:hover {
  opacity: 0.9;
}

/* ── Tabla de Productos ──────────────────────────────────────────────────── */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.table-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.table-responsive {
  overflow-x: auto;
  max-height: 560px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  background: var(--table-header-bg);
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--table-border);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--table-border);
  vertical-align: middle;
}

tr:hover td {
  background: var(--table-row-hover);
}

.item-desc-cell {
  min-width: 250px;
}

.item-desc-input {
  width: 100%;
  font-weight: 600;
}

.provider-match {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 230px;
}

.provider-name-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  outline: none;
  min-width: 0;
  transition: all 0.15s ease;
}

.provider-name-input:focus {
  border-color: var(--border-focus);
}

.btn-unlink-sku {
  background: none;
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--accent-rose);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-unlink-sku:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--accent-rose);
}

.item-link-box {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}

.item-link-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 11px;
  padding: 2px 4px;
  outline: none;
  min-width: 0;
}

.item-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  background: var(--btn-secondary-bg);
  color: var(--primary);
  border-radius: 4px;
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.item-link-btn:hover {
  background: var(--primary);
  color: #ffffff;
}

.item-link-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.num-cell {
  text-align: right;
  font-family: 'SF Mono', Consolas, monospace;
}

.bold-green {
  color: var(--accent-emerald);
  font-weight: 700;
}

/* ── Barra Flotante Inferior ─────────────────────────────────────────────── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bottom-bar-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  padding: 10px 0;
  z-index: 100;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.bottom-bar-inner {
  width: 100%;
  max-width: 100%;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bottom-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bottom-actions .btn {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.bottom-actions .btn-ficha {
  border-color: #0284c7;
  color: #0284c7;
}

[data-theme="dark"] .bottom-actions .btn-ficha {
  color: #38bdf8;
  border-color: #0284c7;
}

.budget-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}
.budget-alert.ok { color: var(--accent-emerald); }
.budget-alert.warning { color: var(--accent-rose); }

/* ── Modales ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 780px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  color: var(--text-main);
}

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

.modal-body {
  padding: 16px;
  overflow-y: auto;
}

/* ── Pestañas del Buscador Inteligente (Pastillas Modernas) ──────────────── */
.search-tabs-container {
  display: flex;
  gap: 10px;
  padding: 10px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.search-tab-pill {
  flex: 1;
  max-width: 200px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.search-tab-pill:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
  border-color: rgba(59, 130, 246, 0.4);
}

.search-tab-pill.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
}

[data-theme="light"] .search-tab-pill {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #64748b;
}

[data-theme="light"] .search-tab-pill:hover {
  background: #f1f5f9;
  color: #0f172a;
}

[data-theme="light"] .search-tab-pill.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.25);
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-result-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--primary);
}

/* ── Panel de Proveedores ─────────────────────────────────────────────────── */
.provider-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-card);
  transition: background 0.15s, border-color 0.15s;
}

.provider-file-row:hover {
  background: var(--bg-surface-hover);
  border-color: var(--primary);
}

.provider-file-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.provider-file-info {
  flex: 1;
  min-width: 0;
}

.provider-file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.provider-file-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.provider-delete-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 6px;
  transition: all 0.15s;
}

.provider-delete-btn:hover {
  color: var(--accent-rose);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}

/* ── Modal de Staging / Extractor Inteligente ────────────────────────────── */
.staging-meta-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.staging-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.staging-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  outline: none;
}

.staging-input:focus {
  border-color: var(--border-focus);
}

.staging-table-wrap {
  flex: 1;
  max-height: 48vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.staging-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.staging-table th {
  position: sticky;
  top: 0;
  background: var(--table-header-bg);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.staging-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

/* ── Historial de Cotizaciones ────────────────────────────────────────── */
.badge-count {
  display: inline-block;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-color);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--primary);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.history-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-card-client {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-card-date {
  font-size: 11px;
  color: var(--text-dim);
}

.history-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.history-stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-stat-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

.history-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.status-badge.Cotizada {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.25);
}

.status-badge.Adjudicada {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.25);
}

.status-badge.Presentada {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.25);
}

.status-badge.Perdida {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-rose);
  border-color: rgba(239, 68, 68, 0.25);
}

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

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(15px);
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-left: 3px solid var(--accent-emerald); }
.toast.error { border-left: 3px solid var(--accent-rose); }
.toast.info { border-left: 3px solid var(--primary); }

/* ── Visor de Previsualización de Ficha Técnica ─────────────────────────── */
.sheet-preview-container {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  font-family: var(--font-sans);
}

[data-theme="light"] .sheet-preview-container {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.sheet-preview-header {
  margin-bottom: 20px;
}

.sheet-preview-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 12px;
}

.sheet-preview-table th {
  background: #1F497D !important;
  color: #ffffff !important;
  font-weight: 700;
  text-align: center;
  padding: 8px 10px;
  border: 1px solid #1e3a5f;
  font-size: 11px;
  letter-spacing: 0.03em;
}

.sheet-preview-table td {
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  vertical-align: middle;
  color: var(--text-main);
  background: var(--bg-surface);
}

[data-theme="light"] .sheet-preview-table td {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #1e293b;
}

.sheet-preview-img-box {
  width: 110px;
  height: 95px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
  padding: 4px;
}

.sheet-preview-img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sheet-preview-signature-block {
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Autocomplete Dropdown para Organismos Estatales */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  max-height: 240px;
  overflow-y: auto;
  z-index: 150;
  backdrop-filter: blur(12px);
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  transition: all 0.15s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(59, 130, 246, 0.18);
}

.autocomplete-item-name {
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-item-rut {
  font-family: monospace;
  font-size: 11px;
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
}

/* Banner de Recuperación de Borrador Inteligente */
.draft-recovery-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(30, 58, 138, 0.38);
  border: 1px solid rgba(59, 130, 246, 0.5);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  animation: slideDown 0.25s ease;
  flex-wrap: wrap;
  gap: 12px;
}

[data-theme="light"] .draft-recovery-banner {
  background: #eff6ff;
  border-color: #93c5fd;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.1);
}

.draft-recovery-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.draft-recovery-icon {
  font-size: 20px;
}

.draft-recovery-text strong {
  font-size: 12.5px;
  color: #93c5fd;
}

[data-theme="light"] .draft-recovery-text strong {
  color: #1e40af;
}

.draft-recovery-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Alerta de Duplicidad de Licitación */
.duplicate-warning-box {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(120, 53, 15, 0.45);
  border: 1px solid rgba(245, 158, 11, 0.6);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  z-index: 120;
  animation: slideDown 0.2s ease;
}

[data-theme="light"] .duplicate-warning-box {
  background: #fffbeb;
  border-color: #fcd34d;
  box-shadow: 0 10px 25px rgba(245, 158, 11, 0.15);
}

.duplicate-warning-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: #fcd34d;
  margin-bottom: 4px;
}

[data-theme="light"] .duplicate-warning-header {
  color: #b45309;
}

.btn-close-dup {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.duplicate-warning-body {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
}

[data-theme="light"] .duplicate-warning-body {
  color: #78350f;
}

.duplicate-warning-footer {
  display: flex;
  gap: 8px;
}

.btn-sm {
  font-size: 10.5px !important;
  padding: 3px 8px !important;
}

/* ── Pestañas de Modales (Tabs) ───────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  gap: 6px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.3);
}

.modal-tab-btn {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.modal-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(59, 130, 246, 0.06);
}

.modal-tab-content {
  display: none;
}

.modal-tab-content.active {
  display: block;
}

/* ── Tarjetas y Configuración de Descuentos por Proveedor ─────────────────── */
.discount-provider-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.discount-provider-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
}

.discount-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.discount-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.discount-badge.tiered {
  background: rgba(147, 51, 234, 0.15);
  color: #c084fc;
  border-color: rgba(147, 51, 234, 0.3);
}

.tier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.tier-table th {
  text-align: left;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-dim);
  font-weight: 600;
  border-radius: 4px;
}

.tier-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.tier-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-main);
  padding: 4px 8px;
  font-size: 11.5px;
  width: 100%;
}

.tier-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* ── Tags de Descuento en Búsqueda de Catálogo ────────────────────────────── */
.search-price-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.search-discount-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
}

.search-list-price {
  font-size: 10.5px;
  color: var(--text-dim);
  text-decoration: line-through;
}

.search-net-price {
  font-size: 14.5px;
  font-weight: 800;
  color: #34d399;
}

/* ── Banner de Oportunidad de Volumen de Proveedores ─────────────────────── */
.volume-opportunity-banner {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.4), rgba(55, 48, 163, 0.3));
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  animation: slideDown 0.25s ease;
}

[data-theme="light"] .volume-opportunity-banner {
  background: linear-gradient(135deg, #eff6ff, #eef2ff);
  border-color: #bfdbfe;
}

.volume-opportunity-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-main);
}

.volume-tier-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 9999px;
  background: #3b82f6;
  color: #ffffff;
}

.table-discount-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 1px 5px;
  border-radius: 4px;
  margin-top: 2px;
}


