/**
 * Calculadora PROVIND — página workbench (no modal)
 * Sin cambios de lógica de cálculo.
 */
:root {
  --calc-navy: #1b263b;
  --calc-blue: #0e75ae;
  --calc-border: #e2e8f0;
  --calc-muted: #64748b;
  --calc-surface: #f1f5f9;
  --calc-rail-w: 260px;
}

* { box-sizing: border-box; }

body.calc-app {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  color: #0f172a;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 60% at 15% 0%, rgba(14, 117, 174, 0.14), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(27, 38, 59, 0.1), transparent 45%),
    #e8eef3;
}

/* ── Layout: rail + main ── */
.calc-layout {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
}

.calc-main {
  flex: 1;
  min-width: 0;
  padding: 10px 10px 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Rail / drawer de sistemas */
.calc-rail {
  width: var(--calc-rail-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--calc-border);
  display: flex;
  flex-direction: column;
  z-index: 60;
}

.calc-rail-head {
  position: relative;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--calc-border);
}
.calc-rail-head .brand-name {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--calc-navy);
}
.calc-rail-head .brand-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--calc-muted);
}
.calc-rail-close {
  display: none;
  position: absolute;
  top: 14px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--calc-surface);
  color: var(--calc-navy);
  cursor: pointer;
}

.calc-menu {
  list-style: none;
  margin: 0;
  padding: 10px 10px 18px;
  overflow-y: auto;
  flex: 1;
}
.calc-menu li { margin: 0 0 4px; }
.calc-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.calc-menu button i {
  width: 18px;
  text-align: center;
  color: var(--calc-muted);
  font-size: 13px;
}
.calc-menu button:hover {
  background: rgba(14, 117, 174, 0.08);
  color: var(--calc-blue);
}
.calc-menu button.is-active {
  background: rgba(14, 117, 174, 0.12);
  color: var(--calc-blue);
}
.calc-menu button.is-active i { color: var(--calc-blue); }
.calc-menu .menu-exit {
  margin-top: 8px;
  border-top: 1px solid var(--calc-border);
  padding-top: 12px;
}
.calc-menu .menu-exit button { color: #94a3b8; font-weight: 600; }

.calc-scrim {
  display: none;
}

@media (max-width: 899px) {
  .calc-rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.18);
  }
  .calc-rail.is-open { transform: translateX(0); }
  .calc-rail-close { display: inline-flex; align-items: center; justify-content: center; }

  .calc-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .calc-scrim.is-open {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ── Workbench ── */
/* Temporal: crece con el contenido (sin recorte 100dvh) para poder verificar despiece */
.calc-workbench {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
  display: flex;
  flex-direction: column;
  overflow: visible;
  height: auto;
  max-height: none;
}

/* Header dentro del card: volver + título centrado + sistemas */
.calc-wb-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--calc-border);
  background: #fff;
}

.calc-wb-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  border: 1px solid var(--calc-border);
  background: #fff;
  color: var(--calc-navy);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  justify-self: start;
  width: fit-content;
  transition: border-color 0.15s, color 0.15s;
}
.calc-wb-back:hover {
  border-color: var(--calc-blue);
  color: var(--calc-blue);
}
.calc-wb-back span { display: none; }
@media (min-width: 420px) {
  .calc-wb-back span { display: inline; }
}

.calc-wb-brand {
  justify-self: center;
  text-align: center;
  min-width: 0;
  max-width: 100%;
}
.calc-wb-title {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  color: var(--calc-navy);
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calc-wb-sub {
  margin: 1px 0 0;
  font-size: 10px;
  color: var(--calc-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-wb-menu {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--calc-border);
  background: var(--calc-navy);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  justify-self: end;
  width: fit-content;
  transition: background 0.15s;
}
.calc-wb-menu:hover { background: var(--calc-blue); }
.calc-wb-menu span { display: none; }
@media (min-width: 420px) {
  .calc-wb-menu span { display: inline; }
}
@media (min-width: 900px) {
  .calc-wb-menu { display: none; }
}

/* Pestañas Manual | Plano */
.calc-mode-tabs {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 12px 0;
  background: #fff;
}
.calc-mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  border: 1px solid var(--calc-border);
  border-radius: 12px;
  background: var(--calc-surface);
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.calc-mode-tab.is-active {
  background: rgba(14, 117, 174, 0.12);
  border-color: var(--calc-blue);
  color: var(--calc-blue);
}
.calc-mode-tab i { font-size: 12px; }

.calc-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.calc-results-head .calc-results-title { margin: 0; }
.calc-source-badge {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid var(--calc-border);
  max-width: 58%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calc-source-badge.is-plano {
  background: rgba(14, 117, 174, 0.1);
  color: var(--calc-blue);
  border-color: rgba(14, 117, 174, 0.25);
}
.calc-source-badge.is-wait {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.3);
}

/* Elegir un sistema tras leer el plano */
.calc-card--sistemas {
  padding: 12px 14px;
}
.calc-sistemas-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--calc-muted);
  margin: 0 0 8px;
}
.calc-sistemas-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.calc-sistema-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--calc-border);
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
  text-align: left;
}
.calc-sistema-btn i { font-size: 11px; color: #64748b; }
.calc-sistema-btn.is-suggested {
  border-color: rgba(14, 117, 174, 0.35);
  background: rgba(14, 117, 174, 0.06);
}
.calc-sistema-btn.is-active {
  border-color: var(--calc-blue);
  background: rgba(14, 117, 174, 0.14);
  color: var(--calc-blue);
}
.calc-sistema-btn.is-active i { color: var(--calc-blue); }
.calc-sistema-tag {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--calc-blue);
  background: rgba(14, 117, 174, 0.12);
  padding: 2px 5px;
  border-radius: 999px;
}

/* Body: setup + despiece (todo visible; la página scrollea si hace falta) */
.calc-body {
  flex: none;
  min-height: auto;
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 10px 12px 12px;
  background: linear-gradient(180deg, #fff 0%, var(--calc-surface) 100%);
  gap: 10px;
}

.calc-setup {
  flex-shrink: 0;
}

/* Lector — compacto en móvil (se mantiene para trabajar hoy) */
.calc-lector {
  position: relative;
  margin-bottom: 10px;
  border-radius: 14px;
  border: 1.5px dashed rgba(14, 117, 174, 0.35);
  background: rgba(14, 117, 174, 0.04);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  outline: none;
}
.calc-lector:hover,
.calc-lector:focus-visible {
  border-color: var(--calc-blue);
  background: rgba(14, 117, 174, 0.07);
  box-shadow: 0 0 0 3px rgba(14, 117, 174, 0.1);
}

.calc-lector-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--calc-blue);
  background: #fff;
  border: 1px solid rgba(14, 117, 174, 0.2);
  padding: 2px 7px;
  border-radius: 999px;
  z-index: 1;
}

.calc-dropzone {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  padding: 18px 14px;
  gap: 12px;
  min-height: 80px;
}

.calc-dropzone-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--calc-border);
  color: var(--calc-blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.calc-dropzone-copy { min-width: 0; }
.calc-dropzone-title {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--calc-navy);
  letter-spacing: -0.01em;
}
.calc-dropzone-sub {
  margin: 1px 0 0;
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  line-height: 1.3;
}

.calc-lector.is-loading {
  pointer-events: none;
  opacity: 0.75;
  border-style: solid;
}
.calc-lector.is-loading .calc-dropzone-icon i {
  animation: calc-spin 0.9s linear infinite;
}
.calc-lector.is-dragover {
  border-color: var(--calc-blue);
  background: rgba(14, 117, 174, 0.1);
  box-shadow: 0 0 0 3px rgba(14, 117, 174, 0.12);
}
.calc-lector.has-file .calc-lector-badge {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.25);
}

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

.calc-lector-banner {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(14, 117, 174, 0.08);
  border: 1px solid rgba(14, 117, 174, 0.18);
  font-size: 12px;
  line-height: 1.45;
  color: #1e293b;
}
.calc-lector-banner.is-warn {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
}
.calc-lector-banner strong {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--calc-blue);
  margin-bottom: 4px;
}
.calc-lector-banner.is-warn strong { color: #b45309; }
.calc-lector-banner ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.calc-lector-banner li { margin: 2px 0; }

/* Cards / fields */
.calc-card {
  background: #fff;
  border: 1px solid var(--calc-border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.calc-card--inputs { padding: 12px 14px; }
.calc-card--results {
  flex: none;
  min-height: auto;
  display: flex;
  flex-direction: column;
  overflow: visible;
  margin-bottom: 0;
}

.calc-field { margin-bottom: 14px; }
.calc-field:last-child { margin-bottom: 0; }

.calc-field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e293b;
  margin-bottom: 8px;
}

.calc-field input[type='number'] {
  width: 100px;
  border: 0;
  border-bottom: 2px solid var(--calc-blue);
  background: transparent;
  text-align: right;
  font-size: 1rem;
  font-weight: 700;
  color: var(--calc-navy);
  padding: 4px 2px;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.calc-field input[type='number']:focus {
  border-bottom-color: var(--calc-navy);
}

.calc-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.calc-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.calc-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.calc-chip span {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--calc-border);
  background: var(--calc-surface);
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.calc-chip:hover span {
  border-color: rgba(14, 117, 174, 0.4);
  color: var(--calc-blue);
}
.calc-chip input:checked + span {
  background: rgba(14, 117, 174, 0.12);
  border-color: var(--calc-blue);
  color: var(--calc-blue);
  box-shadow: 0 0 0 2px rgba(14, 117, 174, 0.12);
  font-weight: 700;
}
.calc-chip input:focus-visible + span {
  outline: 2px solid var(--calc-blue);
  outline-offset: 2px;
}

.calc-hint {
  font-size: 0.72rem;
  color: var(--calc-muted);
  margin-top: 8px;
  line-height: 1.4;
}

.calc-results-title {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--calc-muted);
  margin: 0 0 6px;
  flex-shrink: 0;
}

#results-list {
  flex: none;
  min-height: auto;
  overflow: visible;
}

.calc-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
}
.calc-result-row:last-child { border-bottom: 0; }
.calc-result-row .label { font-weight: 700; color: #1e293b; }
.calc-result-row .qty {
  font-weight: 700;
  color: var(--calc-navy);
  font-variant-numeric: tabular-nums;
}

.calc-group-title {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--calc-blue);
  background: rgba(14, 117, 174, 0.08);
  border: 1px solid rgba(14, 117, 174, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
  margin: 10px 0 2px;
}
.calc-group-title:first-child { margin-top: 0; }

.calc-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--calc-border);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #334155;
  line-height: 1.4;
  flex-shrink: 0;
}

.calc-empty {
  text-align: center;
  color: var(--calc-muted);
  font-size: 0.88rem;
  padding: 24px 8px;
}

/* Footer CTA */
.calc-cta-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--calc-border);
  background: var(--calc-surface);
}
.calc-cta-copy { flex: 1; min-width: 0; }
.calc-cta-label {
  margin: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--calc-muted);
}
.calc-cta-text {
  margin: 2px 0 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--calc-navy);
  line-height: 1.3;
}
.calc-cta-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.calc-pdf-btn,
.calc-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}
.calc-pdf-btn {
  background: #fff;
  color: var(--calc-navy);
  border: 1px solid var(--calc-border);
}
.calc-pdf-btn.is-disabled,
.calc-pdf-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.calc-share-btn {
  background: #10b981;
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.calc-share-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

/* Toast */
.calc-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(90vw, 360px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--calc-navy);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
  text-align: center;
}

@media (max-width: 480px) {
  .calc-main { padding: 6px 6px 10px; }
  .calc-workbench {
    border-radius: 16px;
    height: auto;
    max-height: none;
  }
  .calc-cta-copy { display: none; }
  .calc-cta-actions { width: 100%; }
  .calc-pdf-btn,
  .calc-share-btn { flex: 1; }
}

@media (min-width: 900px) {
  .calc-main {
    padding: 24px 28px 40px;
    align-items: flex-start;
  }
  .calc-workbench {
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .calc-body {
    flex: none;
    min-height: auto;
    overflow: visible;
  }
  .calc-card--results {
    flex: none;
    min-height: auto;
    overflow: visible;
  }
  #results-list {
    flex: none;
    overflow: visible;
  }
  .calc-dropzone {
    flex-direction: column;
    text-align: center;
    justify-content: center;
    padding: 22px 20px;
  }
  .calc-dropzone-icon {
    width: 44px;
    height: 44px;
    font-size: 16px;
    margin: 0 auto 4px;
  }
  .calc-wb-title { font-size: 16px; }
}
