/* =============================================================================
   Calculadora de ROI Alltech · WHITE MODE · MOBILE FIRST
   Mesma linguagem visual do deck de treinamento: Manrope, cards claros,
   turquesa #0082a1 (principal) + laranja #f15a22 (destaque), cinza #414042.
   Base desenhada para 390px; media queries só AMPLIAM para telas maiores.
   ============================================================================= */
:root {
  --primary: #0082a1;
  --primary-dark: #00425c;
  --primary-soft: rgba(0, 130, 161, 0.08);
  --hot: #f15a22;
  --hot-soft: rgba(241, 90, 34, 0.09);
  --gray: #414042;
  --bg: #f4f6f8;
  --card: #ffffff;
  --card-2: #eef1f5;
  --border: rgba(22, 27, 34, 0.10);
  --border-2: rgba(22, 27, 34, 0.18);
  --text: #161b22;
  --text-dim: #5b6672;
  --text-faint: #98a2ad;
  --ok: #16a34a;
  --bad: #dc2626;
  --shadow: 0 6px 24px rgba(22, 27, 34, 0.07);
  --radius: 16px;
  --font: 'Manrope', 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------------------------------------------------------------- topbar */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(244, 246, 248, 0.92);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--border);
}
#topbar img { height: 22px; display: block; }
#topbar .top-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 100px;
  padding: 8px 14px; font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(0.96); }

/* ---------------------------------------------------------------- layout */
#screen { max-width: 720px; margin: 0 auto; padding: 4px 14px 108px; }
.fade-in { animation: fadeSlide 0.3s ease both; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fade-back { animation: fadeSlide 0.3s ease both; }
@media (prefers-reduced-motion: reduce) { .fade-in, .fade-back { animation: none; } }

.kicker {
  color: var(--primary); font-size: 11.5px; font-weight: 800;
  letter-spacing: 0.18em; text-transform: uppercase;
}
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; }
.page-sub { color: var(--text-dim); margin-top: 6px; font-size: 14.5px; }

/* ---------------------------------------------------------------- botões */
.btn-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  border: none; border-radius: 14px; padding: 15px 24px;
  font-size: 16px; font-weight: 800;
  background: var(--primary); color: #fff;
  min-height: 52px;
  box-shadow: 0 8px 22px rgba(0, 130, 161, 0.25);
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border-2); box-shadow: var(--shadow); }
.btn.accent { background: var(--hot); box-shadow: 0 8px 22px rgba(241, 90, 34, 0.28); }
.btn.small { padding: 11px 16px; font-size: 14px; border-radius: 12px; min-height: 44px; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------------------------------------------------------------- form */
.progress { height: 5px; background: var(--card-2); border-radius: 3px; margin: 10px 0 6px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), #57c1e9); border-radius: 3px; transition: width 0.3s; }
.step-count { font-size: 12px; font-weight: 700; color: var(--text-faint); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 10px; }

.form-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 16px 20px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--primary);
}
.form-card h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.form-card .hint { color: var(--text-dim); font-size: 13px; margin: 8px 0 2px; line-height: 1.5; }

.fields { display: grid; gap: 14px; margin-top: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 800; color: var(--text-dim);
  letter-spacing: 0.04em; margin-bottom: 6px;
}
.field input, .field select {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 600;
  background: var(--card); color: var(--text);
  border: 1.5px solid var(--border-2); border-radius: 12px;
  outline: none; min-height: 52px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input::placeholder { color: var(--text-faint); font-weight: 500; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* mobile first: 1 coluna; duas colunas só quando cabe */
.two-col { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 480px) { .two-col { grid-template-columns: 1fr 1fr; gap: 12px; } }

/* slider de arrasto sob o campo numérico */
.field input[type="range"].drag {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 26px; margin: 8px 0 0;
  background: transparent; outline: none;
  border: none; border-radius: 0; padding: 0;
  min-height: 0; box-shadow: none;
}
.field input[type="range"].drag:focus { border: none; box-shadow: none; }
input[type="range"].drag::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary) var(--fill, 0%), var(--card-2) var(--fill, 0%));
}
input[type="range"].drag::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 130, 161, 0.45);
  margin-top: -9px; cursor: pointer;
}
input[type="range"].drag::-moz-range-track { height: 6px; border-radius: 3px; background: var(--card-2); }
input[type="range"].drag::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--primary); }
input[type="range"].drag::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 130, 161, 0.45); cursor: pointer;
}

/* chips de BU: rolagem horizontal no celular, sem esmagar */
.bu-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.bu-chips::-webkit-scrollbar { display: none; }
.bu-chip {
  flex-shrink: 0;
  background: var(--card); color: var(--text-dim);
  border: 1.5px solid var(--border-2); border-radius: 100px;
  padding: 11px 16px; font-size: 14px; font-weight: 700;
  min-height: 44px;
  transition: all 0.15s;
}
.bu-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(0, 130, 161, 0.3); }
@media (min-width: 560px) { .bu-chips { flex-wrap: wrap; overflow: visible; } }
.perfil-chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.perfil-chips::-webkit-scrollbar { display: none; }
@media (min-width: 560px) { .perfil-chips { flex-wrap: wrap; overflow: visible; } }

/* blocos de fonte de ganho */
.fonte-bloco { border-top: 1px solid var(--border); padding: 16px 0 6px; margin-top: 14px; }
.fonte-bloco:first-of-type { border-top: none; margin-top: 6px; padding-top: 6px; }
.fonte-bloco.off .skip-label { opacity: 0.55; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.skip-label { font-size: 15px; color: var(--text); }
.skip-label strong { font-weight: 800; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 20px; background: var(--card-2); border: 1px solid var(--border-2); transition: background 0.2s; cursor: pointer; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(22, 27, 34, 0.25);
  transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(22px); }

.seg { display: flex; background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; padding: 13px 8px; font-size: 14px; font-weight: 700; background: transparent; color: var(--text-dim); border: none; min-height: 48px; }
.seg button.on { background: var(--primary); color: #fff; }

/* barra inferior fixa */
.nav-bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  display: flex; gap: 10px; justify-content: space-between;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, var(--bg) 72%, transparent);
  max-width: 720px; margin: 0 auto;
}
.nav-bottom .btn { flex: 1; }
.nav-bottom .btn.secondary { flex: 0 0 auto; }

/* ---------------------------------------------------------------- resultado */
.hero {
  background: linear-gradient(140deg, var(--primary-dark), var(--primary));
  color: #fff;
  border-radius: var(--radius); padding: 20px 18px; margin-top: 10px;
  display: grid; gap: 18px; grid-template-columns: 1fr;
  box-shadow: 0 14px 34px rgba(0, 130, 161, 0.3);
}
@media (min-width: 560px) { .hero { grid-template-columns: 1fr 1fr; padding: 24px 22px; } }
.hero .kpi .lbl { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.8; }
.hero .kpi .val { font-size: clamp(30px, 8.5vw, 40px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; margin-top: 5px; }
.hero .kpi .sub { font-size: 12.5px; opacity: 0.85; margin-top: 4px; }

.badge {
  display: flex; gap: 10px; align-items: flex-start;
  background: #eafaf1; border: 1px solid rgba(22, 163, 74, 0.35);
  color: #14683a; border-radius: 12px; padding: 12px 14px;
  font-size: 13.5px; font-weight: 600; line-height: 1.45; margin-top: 10px;
}
.badge .ic { flex: none; }

.rcard {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 16px; margin-top: 14px;
  border-top: 4px solid var(--primary);
  box-shadow: var(--shadow);
}
.rcard h3 { font-size: 16px; font-weight: 800; display: flex; gap: 8px; align-items: center; }
.rcard .nota { font-size: 12px; color: var(--text-faint); margin-top: 10px; line-height: 1.5; }
.rcard table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.rcard th { text-align: left; color: var(--text-faint); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 6px; border-bottom: 1px solid var(--border-2); }
.rcard td { padding: 10px 6px; border-bottom: 1px solid var(--border); }
.rcard tr:last-child td { border-bottom: none; }
.num { text-align: right; white-space: nowrap; font-weight: 700; }
.pos { color: var(--ok); font-weight: 800; }
.neg { color: var(--bad); font-weight: 800; }

/* comparativo antes/depois: empilha no celular */
.compare { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
@media (min-width: 480px) { .compare { grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; } }
.compare .box { background: var(--card-2); border-radius: 14px; padding: 16px 12px; text-align: center; }
.compare .box .l { font-size: 10.5px; font-weight: 800; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.compare .box .v { font-size: clamp(22px, 6.5vw, 28px); font-weight: 800; margin-top: 4px; letter-spacing: -0.01em; }
.compare .arrow { font-size: 20px; color: var(--hot); font-weight: 800; text-align: center; }
.compare .box.new { background: linear-gradient(150deg, var(--primary-dark), var(--primary)); color: #fff; }
.compare .box.new .l { color: rgba(255, 255, 255, 0.75); }

.oee-bars { display: grid; gap: 12px; margin-top: 12px; }
.oee-bar .l { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 5px; color: var(--text-dim); }
.oee-bar .track { height: 12px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.oee-bar .fill { height: 100%; border-radius: 6px; background: var(--text-faint); }
.oee-bar.proj .fill { background: var(--primary); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.legend .li { display: flex; gap: 6px; align-items: center; }
.legend .sw { width: 14px; height: 4px; border-radius: 2px; }

.frase-final {
  margin-top: 16px; padding: 16px 18px;
  border-left: 4px solid var(--hot); background: var(--hot-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 15px; font-weight: 700; font-style: italic; line-height: 1.5;
}
.perfil-frase { margin-top: 8px; color: var(--text-dim); font-size: 13.5px; line-height: 1.5; }

.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
@media (min-width: 560px) { .actions-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------------------------------------------------------------- simulações */
.sim-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; margin-top: 10px;
  box-shadow: var(--shadow);
}
.sim-item .tt { font-weight: 800; font-size: 15px; }
.sim-item .dd { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.sim-item .ops { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- gate */
#gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#gate .box { width: 100%; max-width: 340px; text-align: center; display: grid; gap: 14px; }
#gate img { height: 30px; margin: 0 auto 4px; }
#gate h1 { font-size: 22px; font-weight: 800; margin-top: 4px; }
#gate input {
  width: 100%; padding: 15px; font-size: 16px; text-align: center; font-weight: 600;
  background: var(--card); color: var(--text);
  border: 1.5px solid var(--border-2); border-radius: 14px; outline: none;
}
#gate input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
#gate .err { color: var(--bad); font-size: 13px; font-weight: 600; min-height: 18px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: var(--gray); color: #fff;
  border-radius: 12px; padding: 13px 20px;
  font-size: 14px; font-weight: 600; z-index: 60;
  box-shadow: 0 10px 30px rgba(22, 27, 34, 0.3);
  max-width: calc(100vw - 32px); text-align: center;
}

/* =============================================================================
   PRINT: relatório claro para PDF
   ============================================================================= */
@media print {
  body { background: #fff; }
  #topbar, .nav-bottom, .actions-grid, #toast, .no-print, .perfil-chips { display: none !important; }
  #screen { max-width: 100%; padding: 0; }
  .hero, .compare .box.new { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rcard, .form-card { break-inside: avoid; box-shadow: none; }
  .print-header { display: flex !important; justify-content: space-between; align-items: center; border-bottom: 3px solid #0082a1; padding-bottom: 10px; margin-bottom: 14px; }
  .print-header .ph-title { font-size: 18px; font-weight: 800; color: #0082a1; }
  .print-header .ph-meta { font-size: 12px; color: #5b6672; text-align: right; }
  .print-disclaimer { display: block !important; margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--border-2); font-size: 10.5px; color: #5b6672; }
}
.print-header, .print-disclaimer { display: none; }
