/* =============================================================================
   Calculadora de ROI Alltech
   Marca: turquesa #0082a1 (principal), cinza #414042, laranja #f15a22 (acessoria)
   Fonte: stack de sistema com SF Pro Display em primeiro (padrao da casa)
   ============================================================================= */
:root {
  --primary: #0082a1;
  --primary-soft: rgba(0, 130, 161, 0.14);
  --accent: #f15a22;
  --danger: #c0392b;
  --gray: #414042;
  --bg: #15181a;
  --panel: #1f2427;
  --panel-2: #262c30;
  --border: #32393e;
  --text: #f2f4f5;
  --text-dim: #9aa4aa;
  --ok: #2ecc71;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, 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.45;
}
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: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0));
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(6px);
}
#topbar img { height: 26px; display: block; }
#topbar .top-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 12px; font-size: 13px; font-weight: 600;
}
.icon-btn:active { transform: scale(0.97); }

/* ---------------------------------------------------------------- layout */
#screen { max-width: 760px; margin: 0 auto; padding: 8px 18px 90px; }
.fade-in { animation: fadeSlide 0.35s ease both; }
@keyframes fadeSlide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.fade-back { animation: fadeBack 0.35s ease both; }
@keyframes fadeBack { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in, .fade-back { animation: none; } }

/* ---------------------------------------------------------------- story */
.story {
  min-height: calc(100dvh - 170px);
  display: flex; flex-direction: column; justify-content: center;
  gap: 18px; padding: 12px 0;
}
.kicker {
  color: var(--primary); font-size: 12px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.story h1 { font-size: clamp(26px, 6vw, 40px); font-weight: 800; line-height: 1.15; }
.story p { color: var(--text-dim); font-size: clamp(15px, 4vw, 18px); max-width: 56ch; }
.story-list { display: grid; gap: 10px; margin-top: 4px; }
.story-list .item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; font-size: 14px;
}
.story-list .item .ic { font-size: 18px; line-height: 1.3; }
.dots { display: flex; gap: 6px; margin-top: 8px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dots span.on { background: var(--primary); }

/* ---------------------------------------------------------------- botoes */
.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn {
  border: none; border-radius: 12px; padding: 14px 26px;
  font-size: 16px; font-weight: 700;
  background: var(--primary); color: #fff;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.98); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.accent { background: var(--accent); }
.btn.small { padding: 9px 16px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------------------------------------------------------------- cards de escolha (perfil/BU) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 16px; }
.choice {
  text-align: left; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover, .choice.on { border-color: var(--primary); background: var(--primary-soft); }
.choice .ic { font-size: 26px; }
.choice .tt { font-weight: 700; font-size: 16px; }
.choice .dd { color: var(--text-dim); font-size: 13px; }

.page-title { font-size: clamp(22px, 5vw, 30px); font-weight: 800; margin-top: 10px; }
.page-sub { color: var(--text-dim); margin-top: 6px; font-size: 15px; }

/* ---------------------------------------------------------------- form */
.progress { height: 4px; background: var(--border); border-radius: 2px; margin: 12px 0 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s; }
.step-count { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }

.form-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-top: 12px;
  border-top: 4px solid var(--primary);
}
.form-card h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.form-card .hint { color: var(--text-dim); font-size: 13.5px; margin: 8px 0 4px; }
.fields { display: grid; gap: 14px; margin-top: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 13px 14px; font-size: 17px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.field .suffix { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .two-col { grid-template-columns: 1fr; } }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 6px;
}
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 20px;
  background: var(--border); 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;
  transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.skip-label { font-size: 14px; color: var(--text-dim); }

.seg { display: flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; padding: 11px 8px; font-size: 13.5px; font-weight: 600; background: transparent; color: var(--text-dim); border: none; }
.seg button.on { background: var(--primary); color: #fff; }

.nav-bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  display: flex; gap: 10px; justify-content: space-between;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, var(--bg) 65%, transparent);
  max-width: 760px; margin: 0 auto;
}

/* ---------------------------------------------------------------- resultado */
.hero {
  background: linear-gradient(135deg, #016079, var(--primary));
  border-radius: var(--radius); padding: 22px; margin-top: 12px;
  display: grid; gap: 16px; grid-template-columns: 1fr 1fr;
}
@media (max-width: 520px) { .hero { grid-template-columns: 1fr; } }
.hero .kpi .lbl { font-size: 12.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.hero .kpi .val { font-size: clamp(28px, 7vw, 38px); font-weight: 800; line-height: 1.1; margin-top: 4px; }
.hero .kpi .sub { font-size: 13px; opacity: 0.85; margin-top: 3px; }

.badge {
  display: flex; gap: 10px; align-items: flex-start;
  background: rgba(46, 204, 113, 0.12); border: 1px solid rgba(46, 204, 113, 0.4);
  color: #b8ecd0; border-radius: 12px; padding: 11px 14px;
  font-size: 13.5px; margin-top: 10px;
}
.badge .ic { flex: none; }

.rcard {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-top: 14px;
  border-top: 4px solid var(--primary);
}
.rcard h3 { font-size: 16px; display: flex; gap: 8px; align-items: center; }
.rcard .nota { font-size: 12px; color: var(--text-dim); margin-top: 10px; }
.rcard table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.rcard th { text-align: left; color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.rcard td { padding: 9px 6px; border-bottom: 1px solid var(--border); }
.rcard tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--ok); font-weight: 700; }
.neg { color: #e57368; font-weight: 700; }

.compare { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 12px; }
.compare .box { background: var(--panel-2); border-radius: 12px; padding: 14px; text-align: center; }
.compare .box .v { font-size: clamp(20px, 5vw, 26px); font-weight: 800; margin-top: 4px; }
.compare .arrow { font-size: 22px; color: var(--primary); }
.compare .box .l { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.compare .box.new { outline: 2px solid var(--primary); }
.compare .box.new .v { color: #4fc3dd; }

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

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; 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: 18px; padding: 18px;
  border-left: 4px solid var(--accent); background: var(--panel);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 16px; font-weight: 600; font-style: italic;
}
.perfil-frase { margin-top: 10px; color: var(--text-dim); font-size: 14px; }

.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 18px; }

/* ---------------------------------------------------------------- simulacoes salvas */
.sim-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-top: 10px;
}
.sim-item .tt { font-weight: 700; }
.sim-item .dd { font-size: 12.5px; color: var(--text-dim); 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: 360px; text-align: center; display: grid; gap: 14px; }
#gate img { height: 34px; margin: 0 auto 6px; }
#gate input {
  width: 100%; padding: 14px; font-size: 17px; text-align: center;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; outline: none;
}
#gate input:focus { border-color: var(--primary); }
#gate .err { color: #e57368; font-size: 13px; min-height: 18px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 12px 18px;
  font-size: 14px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  max-width: 90vw;
}

/* =============================================================================
   PRINT: relatorio claro para PDF
   ============================================================================= */
@media print {
  :root {
    --bg: #ffffff; --panel: #ffffff; --panel-2: #f2f5f6;
    --border: #d5dbde; --text: #1c2022; --text-dim: #5b6569;
  }
  body { background: #fff; color: #1c2022; }
  #topbar, .nav-bottom, .actions-grid, #toast, .no-print { display: none !important; }
  #screen { max-width: 100%; padding: 0; }
  .hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rcard, .form-card { break-inside: avoid; border: 1px solid #d5dbde; }
  .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: #5b6569; text-align: right; }
  .print-disclaimer { display: block !important; margin-top: 18px; padding-top: 10px; border-top: 1px solid #d5dbde; font-size: 10.5px; color: #5b6569; }
  .badge { border: 1px solid #2ecc71; color: #1e7a46; background: #eafaf1; }
}
.print-header, .print-disclaimer { display: none; }
