/* ============================================================
   Calculadora de Valuation — estilos
   ============================================================ */

:root {
  /* Tema padrão: navy escuro + verde vibrante (estilo plataforma de investimentos) */
  --color-bg: #141a2a;
  --color-surface: #1b2338;
  --color-surface-alt: #212b44;
  --color-border: #313d5c;
  --color-text: #f1f4fa;
  --color-text-muted: #8f9ab3;
  --color-primary: #0e1424;
  --color-primary-hover: #1b2338;
  --color-primary-soft: rgba(0, 226, 138, 0.14);
  --color-accent: #00e28a;
  --color-accent-hover: #1dffa8;
  --color-accent-soft: rgba(0, 226, 138, 0.14);
  --color-negative: #ff5d75;
  --color-negative-soft: rgba(255, 93, 117, 0.14);
  --color-warning: #f5b13d;
  --color-warning-soft: rgba(245, 177, 61, 0.14);
  --color-input-bg: #10162880;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.2);
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  /* Explicitamente igual ao padrão — mantido para o botão de alternância. */
  --color-bg: #141a2a;
  --color-surface: #1b2338;
  --color-surface-alt: #212b44;
  --color-border: #313d5c;
  --color-text: #f1f4fa;
  --color-text-muted: #8f9ab3;
  --color-primary: #0e1424;
  --color-primary-hover: #1b2338;
  --color-primary-soft: rgba(0, 226, 138, 0.14);
  --color-accent: #00e28a;
  --color-accent-hover: #1dffa8;
  --color-accent-soft: rgba(0, 226, 138, 0.14);
  --color-negative: #ff5d75;
  --color-negative-soft: rgba(255, 93, 117, 0.14);
  --color-input-bg: #10162880;
}

:root[data-theme="light"] {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-border: #dfe4ea;
  --color-text: #1a2333;
  --color-text-muted: #5c6b7a;
  --color-primary: #14355e;
  --color-primary-hover: #0d2745;
  --color-primary-soft: #e2fbf1;
  --color-accent: #0f9d68;
  --color-accent-hover: #0c7d53;
  --color-accent-soft: #e5f6ee;
  --color-negative: #c23b3b;
  --color-negative-soft: #fbeaea;
  --color-warning: #b3760f;
  --color-warning-soft: #fdf1dd;
  --color-input-bg: #ffffff;
  --shadow-card: 0 1px 3px rgba(20, 30, 50, 0.08), 0 1px 2px rgba(20, 30, 50, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------- Header ---------------- */

.app-header {
  background: var(--color-primary);
  color: #fff;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* Formas triangulares decorativas, ecoando o visual de plataformas de
   investimento (navy + verde em blocos geométricos angulados). */
.app-header::before,
.app-header::after {
  content: "";
  position: absolute;
  top: -40%;
  bottom: -40%;
  width: 340px;
  z-index: -1;
  pointer-events: none;
}

.app-header::before {
  right: -60px;
  background: var(--color-accent);
  opacity: 0.9;
  clip-path: polygon(60% 0%, 100% 0%, 40% 100%, 0% 100%);
}

.app-header::after {
  right: -180px;
  background: var(--color-bg);
  opacity: 0.55;
  clip-path: polygon(60% 0%, 100% 0%, 40% 100%, 0% 100%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  gap: 16px;
  position: relative;
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 10px;
  background: var(--color-accent);
  color: #06251a;
  font-weight: 800;
  font-size: 20px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.22); }

/* ---------------- Layout ---------------- */

main.container {
  padding-top: 24px;
  padding-bottom: 48px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 22px 22px 26px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  color: var(--color-accent);
}

.model-desc {
  margin: 0 0 18px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  max-width: 70ch;
}

/* ---------------- Shared panel ---------------- */

.shared-panel { margin-bottom: 18px; }

/* ---------------- Tabs ---------------- */

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 20px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 0 0 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }

.tab-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #06251a;
}

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

/* ---------------- Forms ---------------- */

.field-grid {
  display: grid;
  gap: 16px 20px;
  margin-bottom: 18px;
}

.field-grid-2 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.field-grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.req { color: var(--color-negative); font-weight: 700; }
.ref { color: var(--color-text-muted); font-weight: 400; font-size: 0.78rem; }

.field input[type="text"] {
  background: var(--color-input-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.95rem;
  color: var(--color-text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input[type="text"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.hint {
  color: var(--color-text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.hint.status-erro { color: var(--color-negative); font-weight: 600; }
.hint.status-ok { color: var(--color-accent); font-weight: 600; }

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input { flex: 1; min-width: 0; }

.btn-buscar {
  white-space: nowrap;
  padding: 10px 16px;
  flex-shrink: 0;
}

.btn-buscar:disabled {
  opacity: 0.6;
  cursor: default;
}

.radio-field { margin-bottom: 20px; }

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--color-surface-alt);
  user-select: none;
}

.radio-pill:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: 600;
}

.radio-pill input { accent-color: var(--color-accent); }

.quick-dy { margin-bottom: 18px; }
.quick-dy-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 6px;
}

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.checkbox-group input { accent-color: var(--color-accent); width: 16px; height: 16px; }

/* ---------------- Buttons ---------------- */

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn-secondary:hover { border-color: var(--color-text-muted); color: var(--color-text); }

.btn-chip {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
}
.btn-chip:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* ---------------- Results ---------------- */

.result { margin-top: 4px; }

.placeholder {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  font-style: italic;
  margin: 0;
}

.hidden { display: none !important; }

.result-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 16px;
}

.result-banner.status-positivo {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.result-banner.status-negativo {
  background: var(--color-negative-soft);
  color: var(--color-negative);
}

.result-banner .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.metric .metric-label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.metric .metric-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
}

.metric .metric-value.positive { color: var(--color-accent); }
.metric .metric-value.negative { color: var(--color-negative); }

.result-note {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: -8px 0 16px;
}

.table-wrap { overflow-x: auto; margin-bottom: 16px; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 480px;
}

.results-table th, .results-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.results-table th {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.results-table tbody tr:last-child td { border-bottom: none; }

.results-table tr.row-terminal {
  background: var(--color-primary-soft);
  font-weight: 700;
}

.error-box {
  background: var(--color-negative-soft);
  color: var(--color-negative);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------------- Footer ---------------- */

.app-footer {
  border-top: 1px solid var(--color-border);
  padding: 18px 0 32px;
}

.app-footer p {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  text-align: center;
  margin: 0;
}

.footer-privacidade {
  max-width: 640px;
  margin: 16px auto 0;
  text-align: left;
}
.footer-privacidade summary { text-align: center; }

/* ---------------- Responsive ---------------- */

@media (max-width: 620px) {
  .header-inner { padding: 14px 16px; }
  .app-header h1 { font-size: 1.05rem; }
  .subtitle { display: none; }
  .card { padding: 18px 16px 20px; }
  .field-grid { gap: 14px; }
  .actions .btn { flex: 1 1 auto; text-align: center; }
}

/* ---------------- Tutorial (details/summary) ---------------- */

.tutorial {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.tutorial summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-accent);
  list-style: none;
  user-select: none;
}

.tutorial summary::-webkit-details-marker { display: none; }

.tutorial summary::after {
  content: "▸";
  float: right;
  transition: transform 0.15s;
  color: var(--color-text-muted);
}

.tutorial[open] summary::after { transform: rotate(90deg); }

.tutorial-content {
  padding: 0 16px 16px;
  font-size: 0.88rem;
  color: var(--color-text);
  line-height: 1.55;
}

.tutorial-content p { margin: 0 0 12px; }
.tutorial-content p:last-of-type { margin-bottom: 14px; }

.tutorial-content a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tutorial-content a:hover,
.tutorial-content a:focus-visible { color: var(--color-accent-hover); }

.disclaimer-box {
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.5;
}

/* ---------------- Glossário (tooltips) ---------------- */

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  border: 1px solid var(--color-text-muted);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  padding: 0;
  vertical-align: middle;
}

.info-btn:hover, .info-btn:focus-visible, .info-btn.active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  outline: none;
}

.glossario-tooltip {
  position: fixed;
  max-width: 280px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--color-text);
  z-index: 50;
  pointer-events: none;
}

/* ---------------- Ranking ---------------- */

.cluster {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  overflow: hidden;
}

.cluster.cluster-consenso {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.cluster-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--color-surface-alt);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.cluster.cluster-consenso .cluster-header {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: 700;
}

.cluster-header .cluster-valor {
  font-weight: 700;
  font-size: 0.95rem;
}

.avaliador-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.avaliador-row:first-of-type { border-top: none; }

.avaliador-nome { font-weight: 600; }

.avaliador-meta {
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

.avaliador-valor { font-weight: 700; white-space: nowrap; }

/* ---------------- Minhas Avaliações ---------------- */

.historico-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.historico-info { display: flex; flex-direction: column; gap: 2px; }
.historico-info .historico-ticker { font-weight: 700; }
.historico-info .historico-meta { color: var(--color-text-muted); font-size: 0.78rem; }

.historico-valores { display: flex; gap: 18px; flex-wrap: wrap; }
.historico-valores .valor-item { text-align: right; }
.historico-valores .valor-label { display: block; font-size: 0.7rem; color: var(--color-text-muted); text-transform: uppercase; }
.historico-valores .valor-num { font-weight: 700; }

.btn-remover {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-negative);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-remover:hover { border-color: var(--color-negative); }

/* ---------------- Minha Conta / Pro ---------------- */

.conta-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.pro-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  vertical-align: middle;
  margin-left: 6px;
}

.pro-badge.pro-badge-ativo {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.upgrade-box {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px dashed var(--color-accent);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
}

.upgrade-box p { margin: 0 0 12px; font-size: .9rem; }

/* ---------------- Portal de acesso (cadastro obrigatório) ---------------- */

.auth-gate {
  max-width: 480px;
  margin: 40px auto;
}
.auth-gate h2 { color: var(--color-accent); margin-bottom: 8px; }

/* ---------------- Overlay de recurso exclusivo Pro ---------------- */

.pro-gate-overlay {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--color-accent);
}
.pro-gate-overlay h2 { color: var(--color-accent); font-size: 1.3rem; margin-bottom: 10px; }
.pro-gate-overlay .model-desc { margin: 0 auto 20px; max-width: 48ch; }

.btn-link-perigo {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-text-muted);
  font-size: .78rem;
  text-decoration: underline;
  cursor: pointer;
}
.btn-link-perigo:hover { color: var(--color-negative); }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-text-muted);
  font-size: .82rem;
  text-decoration: underline;
  cursor: pointer;
}
.btn-link:hover { color: var(--color-accent); }

