:root {
  --bg: #0f172a;
  --bg-2: #111827;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #0b1220;
  --ink-2: #475569;
  --brand: #1d4ed8;
  --brand-2: #0ea5e9;
  --brand-ink: #ffffff;
  --accent: #10b981;
  --danger: #dc2626;
  --warning: #f59e0b;
  --warning-ink: #92400e;
  --ok: #15803d;
  --c-danger: #dc2626;
  --c-ok: #15803d;
  --c-warning-ink: #92400e;
  --c-border: #e2e8f0;
  --c-ink: #0b1220;
  --border: #e2e8f0;
  --shadow: 0 8px 24px rgba(15,23,42,0.08);
  --header-blue: #355d98;
  --header-blue-dark: #2f558d;
  --cta-green: #91bf16;
  --cta-green-dark: #7ca50f;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--panel-2);
  font-size: 14px;
  line-height: 1.45;
}

code {
  background: #eef2ff;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #3730a3;
}

.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.big   { font-size: 28px; font-weight: 700; margin: 8px 0; color: var(--ink); }
.hidden { display: none !important; }

/* ================= LOGIN ================= */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 10% 0%, #1e3a8a22, transparent 60%),
    radial-gradient(800px 500px at 100% 100%, #0ea5e922, transparent 60%),
    linear-gradient(160deg, var(--bg) 0%, #1e293b 100%);
  color: #e2e8f0;
}

.login-card {
  width: min(420px, 92vw);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148,163,184,0.2);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(2,6,23,0.5);
}

.login-brand { text-align: center; margin-bottom: 20px; }
.logo-mark {
  display: inline-grid; place-items: center;
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 800; letter-spacing: 1px;
  margin: 0 auto 12px;
}
.login-brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.2px; }
.login-brand h1 span { color: var(--brand-2); }
.tagline { color: #94a3b8; font-size: 12.5px; margin: 6px 0 0; }

.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form label { font-size: 12px; color: #cbd5e1; font-weight: 600; }
.login-form input {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(15,23,42,0.6);
  color: #f1f5f9;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-form input:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.18);
}
.login-form .remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #cbd5e1;
  font-weight: 500;
  margin: 2px 0 4px;
  user-select: none;
}
.login-form .remember-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--brand-2);
  cursor: pointer;
}

#btn-login {
  margin-top: 6px;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
#btn-login:active { transform: translateY(1px); }

.form-msg { min-height: 18px; margin: 4px 0 0; font-size: 12.5px; }
.form-msg.err { color: #fecaca; }
.form-msg.ok  { color: #bbf7d0; }

.login-foot { margin-top: 18px; padding-top: 14px; border-top: 1px dashed rgba(148,163,184,0.2); }
.login-foot p { margin: 0; color: #94a3b8; font-size: 12px; }
.login-foot code { background: #334155; color: #e2e8f0; }

/* ================= NAVBAR + SHELL ================= */
.navbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px;
  background: linear-gradient(180deg, var(--header-blue) 0%, var(--header-blue-dark) 100%);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 28px rgba(27,48,84,0.18);
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}
.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.brand-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.72);
}
.brand-text { color: #fff; font-size: 19px; line-height: 1.05; }
.brand-text strong { color: #fff; font-weight: 800; letter-spacing: 0.1px; }

.nav-links {
  list-style: none; display: flex; gap: 4px;
  padding: 0; margin: 0 auto 0 20px;
  flex-wrap: wrap;
}
.nav-link {
  display: inline-block; padding: 9px 14px; border-radius: 10px;
  color: rgba(255,255,255,0.88); text-decoration: none; font-weight: 700; font-size: 13px;
  background: transparent;
  border: 1px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-link.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-color: rgba(255,255,255,0.1);
}

.nav-user { display: flex; align-items: center; gap: 10px; }
.user-email { color: rgba(255,255,255,0.88); font-size: 12.5px; font-weight: 600; }
.btn-logout {
  padding: 7px 12px; border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.1);
  border-radius: 8px; color: #fff; font-weight: 700; font-size: 12.5px; cursor: pointer;
}
.btn-logout:hover { background: rgba(255,255,255,0.18); }

.app-shell {
  max-width: 1600px;
  margin: 18px auto;
  padding: 0 28px 160px;
}

.section-head { margin-bottom: 14px; }
.section-head h2 { margin: 0 0 4px; font-size: 31px; color: #0d5788; }
.section-head p { max-width: 1100px; }
.section-head-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
}
.section-head-copy {
  min-width: 0;
}
.section-head-action {
  flex: 0 0 auto;
  margin-bottom: 2px;
}

.intake-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
  margin-bottom: 14px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.card.empty { min-height: 180px; display: grid; place-items: center; color: var(--ink-2); }

.intake-card {
  min-height: 178px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 22px 20px 18px;
}
.intake-title {
  margin: 0 0 8px !important;
  font-size: 22px !important;
  font-weight: 800 !important;
  color: #0d5788 !important;
}
.intake-copy {
  margin: 0 0 14px !important;
  min-height: 34px;
}
.intake-form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.upload-form-slot {
  display: inline-flex;
  align-items: center;
}
.upload-inline-form {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.upload-inline-form input[type="file"] {
  max-width: 100%;
  font: inherit;
  color: var(--ink-2);
}
.upload-inline-form input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 10px 14px;
  border: 1px solid #cfd8e6;
  border-radius: 10px;
  background: #fff;
  color: #355d98;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.upload-inline-form input[type="file"]::file-selector-button:hover {
  background: #f8fbff;
}
.intake-status {
  margin-top: auto;
  padding-top: 12px;
}
.intake-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--c-ink);
}
.intake-input {
  flex: 1;
  min-width: 240px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--c-border);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.intake-input:focus {
  border-color: #005387;
  box-shadow: 0 0 0 3px rgba(0,83,135,0.12);
}
.mp-intake-form-row {
  align-items: flex-end;
}

.card ul { padding-left: 18px; }
.card ul li { margin: 4px 0; }

.mb-10 { margin-bottom: 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.strong { font-weight: 700; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ================= MATCHING BADGES / CHIPS / TABLE ================= */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
}
.badge-ok        { background: #10b981; }
.badge-revisar   { background: #f59e0b; color: #111827; }
.badge-warn      { background: #f59e0b; color: #111827; border: 1px solid #d97706; }
.badge-sin-match { background: #dc2626; }
.badge-excluido  { background: #64748b; }

.badge-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}
.badge-dot-ok        { background: #10b981; }
.badge-dot-revisar   { background: #f59e0b; }
.badge-dot-sin-match { background: #dc2626; }
.badge-dot-excluido  { background: #64748b; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.chip:hover { background: #f8fafc; }
.chip.active {
  background: #eff6ff;
  color: var(--brand);
  border-color: #bfdbfe;
}

.table-wrap {
  max-height: 92vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

/* ============= TABLAS ABAJO COTIZACIÓN (Codigo VC / Nombre VC || Operación) ============= */
.tablas-detalle-row { display: none; }
.tabla-detalle {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.tabla-detalle table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
}
.tabla-detalle thead {
  background: #1d6fa5;
  color: #fff;
}
.tabla-detalle th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.1px;
  border-right: 1px solid rgba(255,255,255,0.15);
}
.tabla-detalle th:last-child { border-right: 0; }
.tabla-detalle td {
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.2;
}
.tabla-detalle tr:nth-child(even) td { background: #f8fafc; }
.tabla-detalle td.codigo-vc {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #0c4a6e;
  font-weight: 600;
  width: 96px;
  white-space: nowrap;
}
.tabla-detalle td.num-vc {
  width: 36px;
  color: var(--ink-2);
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.tabla-detalle .detalle-name-cell {
  word-break: break-word;
}
.tabla-detalle .empty-td {
  color: #94a3b8;
  text-align: center;
  font-style: italic;
  padding: 12px;
}
.matching-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.matching-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1f5f9;
}
.matching-table th,
.matching-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  text-align: left;
}
.matching-table th {
  font-weight: 700;
  color: var(--ink-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.matching-table tbody tr:hover { background: #f8fafc; }
.matching-table td.desc-col       { max-width: 280px; }
.matching-table td.criterio-col   { max-width: 160px; }
.matching-table td.col-acc        { width: 84px; }

.btn-revisar {
  padding: 4px 10px;
  font-size: 11.5px;
  border-radius: 6px;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  cursor: not-allowed;
  opacity: 0.75;
}

/* ================= TOASTS ================= */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #0b1220;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  animation: toastIn .22s ease-out;
}
.toast-success { border-left: 4px solid #8cb811; }
.toast-error   { border-left: 4px solid #dc2626; color: #7f1d1d; }
.toast-warning { border-left: 4px solid #f59e0b; color: #92400e; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ================= OVERLAY LOADING ================= */
.overlay {
  position: relative;
}
.overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.72);
  border-radius: 14px;
  z-index: 4;
  backdrop-filter: blur(2px);
}
.overlay-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #e2e8f0;
  border-top-color: #005387;
  animation: spin .8s linear infinite;
  z-index: 5;
}
.overlay-message {
  position: absolute;
  top: calc(50% + 34px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  color: #005387;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  max-width: 80%;
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ================= COSTEO ================= */
.costeo-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(170px, 0.8fr) minmax(190px, 0.9fr) auto auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}
.costeo-field { display: flex; flex-direction: column; gap: 6px; }
.costeo-field label {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.costeo-field select,
.costeo-field input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.costeo-field select:focus,
.costeo-field input:focus {
  border-color: #005387;
  box-shadow: 0 0 0 3px rgba(0,83,135,0.12);
}
.costeo-field-static {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  background: #f8fafc;
  min-height: 39px;
  display: flex;
  align-items: center;
}
.costeo-toolbar > .btn-verde {
  min-height: 39px;
  white-space: nowrap;
}
.costeo-toolbar > .btn-secundario {
  min-height: 39px;
  white-space: nowrap;
}
.hidden-accessory-control {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.btn-verde {
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--cta-green);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
  box-shadow: 0 8px 20px rgba(145,191,22,0.24);
}
.btn-verde:hover:not(:disabled) { background: var(--cta-green-dark); }
.btn-verde:active:not(:disabled) { transform: translateY(1px); }
.btn-verde:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  color: #64748b;
  box-shadow: none;
}
.btn-primary-action {
  min-width: 240px;
  min-height: 42px;
  justify-content: center;
  text-align: center;
}
.btn-verde .spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

#mp-import-status.status-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#mp-import-status.status-loading::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid rgba(146, 64, 14, 0.22);
  border-top-color: #92400e;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}

.import-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.import-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(2px);
}
.import-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(460px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid rgba(0, 83, 135, 0.14);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
  padding: 28px 24px 22px;
  text-align: center;
}
.import-modal-spinner {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 999px;
  border: 5px solid rgba(0, 83, 135, 0.12);
  border-top-color: #005387;
  animation: spin 0.85s linear infinite;
}
.import-modal-title {
  font-size: 24px;
  line-height: 1.15;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 8px;
}
.import-modal-text {
  font-size: 15px;
  line-height: 1.45;
  color: #1e293b;
  font-weight: 600;
}
.import-modal-subtext {
  margin-top: 10px;
  font-size: 13px;
  color: #64748b;
}
.import-modal-dialog-error {
  max-width: 520px;
}
.import-modal-icon-error {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
}
.import-modal-title-error {
  font-size: 22px;
}
.import-modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.btn-secundario {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #005387;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, border-color .15s ease;
}
.btn-secundario:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #005387;
}
.btn-secundario:active:not(:disabled) { transform: translateY(1px); }
.btn-secundario:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}

.costeo-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}
.costeo-summary .badge {
  font-size: 13px;
  padding: 5px 12px;
}
.badge-ok-green { background: #8cb811; }
.badge-revisar-amber { background: #f59e0b; color: #111827; }
.badge-error-red { background: #dc2626; }

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.stat-pill strong { color: var(--ink); }

#costeo-table-wrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.costeo-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.costeo-block-title {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: #fff;
  background: #005387;
}
.costeo-block:nth-of-type(2) .costeo-block-title {
  background: #1d6fa5;
}
.costeo-block:nth-of-type(3) .costeo-block-title {
  background: #0f766e;
}
.rentabilidad-totales {
  background: #f3f4f6;
  font-weight: 700;
  border-top: 2px solid var(--ink-2);
}
.rentabilidad-totales td.num.strong {
  font-weight: 700;
  color: var(--ink);
}
.td-totales-label {
  background: #dbeafe;
  text-align: right;
  padding-right: 14px;
  font-size: 14px;
  letter-spacing: 0.5px;
}
.costeo-table-wrap-inner {
  max-height: 52vh;
  overflow: auto;
}
.costeo-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.costeo-table thead { position: sticky; top: 0; z-index: 2; background: #f1f5f9; }
.costeo-table th, .costeo-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  text-align: left;
}
.costeo-table th {
  font-weight: 700;
  color: var(--ink-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.costeo-table tbody tr[data-estado^="EXCLUIDO_T"] { background: #f5f5f5; }
.costeo-table tbody tr[data-estado^="SIN_COSTO"],
.costeo-table tbody tr[data-estado^="EXCLUIDO_XX"] { background: #fff9e6; }
.costeo-table tbody tr[data-estado^="ERROR"] { background: #fde7e9; }
.costeo-table tbody tr:hover:not([class*="bg-"]) { background: #f8fafc; }
.costeo-table td.col-n { width: 48px; }
.costeo-table td.dash { color: #94a3b8; text-align: center; }

/* ================= COTIZACIÓN (pestaña principal V0+) ================= */
.cotizacion-header {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px 24px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg,#eff6ff 0%, #fff 100%);
  margin-bottom: 12px;
}
.cotizacion-header-left, .cotizacion-header-right {
  display: flex; flex-direction: column; gap: 6px;
}
.cliente-row { display: flex; align-items: baseline; gap: 8px; }
.cliente-label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.3px;
  font-weight: 700; color: var(--ink-2); min-width: 170px; width: 170px;
}
.cliente-val {
  font-size: 13.5px; color: var(--ink); font-weight: 500; word-break: break-word;
}
.cliente-val.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; }

.cotizacion-search,
.cotizacion-filter {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}
.cotizacion-search:focus,
.cotizacion-filter:focus {
  border-color: #005387;
  box-shadow: 0 0 0 3px rgba(0,83,135,0.12);
}
.cotizacion-view-tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 0 4px;
  border-bottom: 1px solid #d7dee8;
}
.cotizacion-view-tab {
  border: 1px solid transparent;
  border-bottom: 4px solid transparent;
  background: #eef3f8;
  color: #64748b;
  border-radius: 12px 12px 0 0;
  padding: 10px 16px 9px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: -1px;
}
.cotizacion-view-tab.active {
  background: #ffffff;
  border-color: #d7dee8;
  border-bottom-color: #0d5788;
  color: #0d5788;
  box-shadow: 0 8px 20px rgba(13, 87, 136, 0.08);
}
.cotizacion-panel.hidden {
  display: none;
}
.productos-panel-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin: 0 0 12px;
}
.productos-add-btn {
  min-width: 156px;
}
.cotizacion-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.cotizacion-table thead { position: sticky; top: 0; z-index: 2; background: #005387; color: #fff; }
.cotizacion-table th {
  padding: 7px 7px; font-weight: 700; letter-spacing: 0;
  font-size: 10.5px; text-align: left; border-bottom: 1px solid var(--border);
}
.cotizacion-table th.num, .cotizacion-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cotizacion-table td {
  padding: 6px 6px; border-bottom: 1px solid #dbe3ee; vertical-align: top; text-align: left; color: var(--ink);
  line-height: 1.2; font-size: 11.5px;
}
.cotizacion-table tbody tr[data-estado^="EXCLUIDO_T"] { background: #f5f5f5; }
.cotizacion-table tbody tr[data-estado^="SIN_COSTO"],
.cotizacion-table tbody tr[data-estado^="EXCLUIDO_XX"],
.cotizacion-table tbody tr[data-estado="SIN_MATCH"] { background: #fff9e6; }
.cotizacion-table tbody tr[data-estado^="ERROR"] { background: #fde7e9; }
.cotizacion-table tbody tr.cotizacion-extra-row { background: #f8fbff; }
.cotizacion-table tbody tr:hover:not([class*="bg-"]) { background: #f8fafc; }
.cotizacion-table th.col-n,
.cotizacion-table td.col-n { width: 26px; }
.cotizacion-table th.col-item,
.cotizacion-table td.desc-col { width: 22%; max-width: 210px; }
.cotizacion-table th.col-cant,
.cotizacion-table td.col-cant { width: 48px; }
.cotizacion-table th.col-unit-base,
.cotizacion-table td.col-unit-base { width: 88px; }
.cotizacion-table th.col-unit-final,
.cotizacion-table td.col-unit-final { width: 108px; }
.cotizacion-table th.col-total,
.cotizacion-table td.col-total { width: 88px; }
.cotizacion-table th.col-oferta,
.cotizacion-table td.col-oferta { width: 24%; min-width: 220px; }
.cotizacion-table th.col-vc-code,
.cotizacion-table td.col-vc-code { width: 98px; }
.cotizacion-table th.col-vc-name,
.cotizacion-table td.col-vc-name { width: 18%; min-width: 170px; }
.cotizacion-table td.col-img { width: 72px; text-align: center; color: #94a3b8; font-size: 11px; }
.cotizacion-desc-main { margin-bottom: 3px; }
.cotizacion-desc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cotizacion-extra-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e0ecf7;
  color: #0d5788;
  font-size: 10px;
  font-weight: 800;
}
.cotizacion-extra-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.remove-extra-btn {
  border: 0;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
}
.remove-extra-btn {
  background: #e2e8f0;
  color: #334155;
}
.remove-extra-btn:hover:not(:disabled) {
  background: #cbd5e1;
}
.cotizacion-table td.desc-col,
.cotizacion-table td.col-vc-name {
  word-break: break-word;
}
.cotizacion-table th.col-vc-code,
.cotizacion-table th.col-vc-name {
  background: #667f49;
  color: #ffffff;
}
.cotizacion-table td.col-vc-code,
.cotizacion-table td.col-vc-name {
  background: #dfead4;
  color: #1f3521;
}
.cotizacion-table td.col-vc-code {
  font-weight: 700;
}
.cotizacion-table td.col-unit-final.is-provisional {
  color: #b45309;
  background: #fff7ed;
  font-weight: 700;
}
.price-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 16px;
}
.price-loading-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #cbd5e1;
  border-top-color: #005387;
  border-radius: 999px;
  animation: price-spin 0.75s linear infinite;
}
@keyframes price-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.detalle-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 10.5px;
  font-weight: 700;
  color: #005387;
  cursor: pointer;
}
.detalle-toggle:hover { text-decoration: underline; }
.detalle-toggle.expanded { color: #0f766e; }
.cotizacion-detail-row td {
  padding: 0;
  background: #f8fbff;
  border-bottom: 1px solid #dbe3ee;
}
.cotizacion-detail-panel {
  padding: 10px 12px;
}
.cotizacion-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.cotizacion-detail-card {
  background: #fff;
  border: 1px solid #d9e5f0;
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 62px;
}
.cotizacion-detail-card-vc {
  background: #edf5e6;
  border-color: #c7d9b8;
}
.cotizacion-detail-card-vc .cotizacion-detail-label {
  color: #4f6a34;
}
.cotizacion-detail-label {
  font-size: 10px;
  letter-spacing: 0;
  color: #64748b;
  font-weight: 800;
  margin-bottom: 4px;
}
.cotizacion-detail-value {
  font-size: 11px;
  line-height: 1.3;
  color: #0f172a;
  font-weight: 600;
  word-break: break-word;
}
.cotizacion-detail-value.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.cotizacion-table select.item-oferta {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #d7dee8;
  border-radius: 6px;
  background: #f9fbfd;
  font-size: 11px;
  color: var(--ink);
  outline: none;
}
.cotizacion-table select.item-oferta:focus {
  border-color: #005387;
  box-shadow: 0 0 0 3px rgba(0,83,135,0.12);
}
.item-oferta-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.item-oferta-wrap select {
  min-width: 0;
  flex: 1 1 auto;
}
.manual-add-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #7aa30d;
  background: #97c20f;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.manual-add-btn:hover:not(:disabled) {
  background: #7fab0c;
}
.manual-add-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.qty-extra-input {
  width: 74px;
  padding: 4px 6px;
  border: 1px solid #d7dee8;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  text-align: right;
}
.qty-extra-input:focus {
  border-color: #005387;
  box-shadow: 0 0 0 3px rgba(0,83,135,0.12);
  outline: none;
}
.cotizacion-table tfoot tr td {
  padding: 8px 10px; border-top: 2px solid #e2e8f0; border-bottom: 0; background: #fefefe;
  font-size: 11.5px;
}
.cotizacion-table tfoot tr.total-neto td.num { font-size: 12px; }
.cotizacion-table tfoot tr.total-iva td.num { color: var(--ink-2); }
.cotizacion-table tfoot tr.total-final td { background: #005387; color: #fff; border-top: 2px solid #00426a; }
.cotizacion-table tfoot tr.total-final td.num strong { color: #fff; }
.cotizacion-table tfoot tr.total-final td:not(.num) { color: #fff; }

.picker-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
}
.picker-modal.hidden {
  display: none;
}
.picker-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
}
.picker-modal-dialog {
  position: relative;
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.picker-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.picker-modal-head h3 {
  margin: 0 0 4px;
  color: #0d5788;
}
.picker-target-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.picker-target-label {
  font-size: 12px;
  font-weight: 800;
  color: #475569;
}
.picker-results {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  min-height: 220px;
}
.picker-result-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #dbe3ee;
  background: #fff;
  padding: 12px 14px;
  text-align: left;
  display: grid;
  grid-template-columns: 118px minmax(220px, 1.2fr) minmax(220px, 1fr);
  gap: 12px;
  cursor: pointer;
}
.picker-result-row:hover {
  background: #eff6ff;
}
.picker-result-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #0d5788;
}
.picker-result-ricardo,
.picker-result-vc {
  font-size: 12.5px;
  color: var(--ink);
}
.transport-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.transport-pill {
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #dbe3ee;
  min-width: 150px;
}
.transport-pill-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  margin-bottom: 2px;
}
.transport-pill-value {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
}
.picker-result-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.25px;
  color: var(--ink-2);
  margin-bottom: 2px;
}

@media (max-width: 1280px) {
  .intake-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .cotizacion-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .navbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
  }
  .nav-links {
    order: 3;
    width: 100%;
    margin: 0;
  }
  .nav-user {
    margin-left: auto;
  }
  .section-head h2 {
    font-size: 26px;
  }
  .section-head-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .section-head-action {
    align-self: flex-end;
    margin-bottom: 0;
  }
  .intake-form-row {
    align-items: stretch;
  }
  .upload-form-slot,
  .upload-form-slot form {
    width: 100%;
  }
  .btn-primary-action,
  .btn-secundario,
  .intake-input {
    width: 100%;
    min-width: 0;
  }
  .import-modal-dialog {
    padding: 24px 18px 18px;
  }
  .import-modal-title {
    font-size: 20px;
  }
  .costeo-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }
  .cotizacion-detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .picker-result-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
