/* ══════════════════════════════════════════════════════════════
   RedWood — Reforma Tributária | Premium Design System
   ══════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0B0F1A;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --redwood: #8B3A3A;
  --redwood-light: #B85454;
  --redwood-glow: rgba(139, 58, 58, 0.3);
  --gold: #D4A574;
  --gold-dim: rgba(212, 165, 116, 0.15);
  --navy: #1B1F3B;
  --navy-light: #2A2F52;
  --success: #22C55E;
  --success-dim: rgba(34, 197, 94, 0.12);
  --warning: #F59E0B;
  --warning-dim: rgba(245, 158, 11, 0.12);
  --danger: #EF4444;
  --danger-dim: rgba(239, 68, 68, 0.12);
  --info: #3B82F6;
  --info-dim: rgba(59, 130, 246, 0.12);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --beige: #D5C4A1;
  --light-beige: #E8DCC8;
  --font: 'Figtree', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 320px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: url('assets/bg_tree_rings.png') center/cover no-repeat;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}
a { color: var(--gold); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--redwood-light); }
.hidden { display: none !important; }

/* ══ LEAD GATE ══════════════════════════════════════════════ */
#lead-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gate-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--navy) 0%, var(--bg-primary) 50%, var(--redwood) 100%);
  opacity: 0.97;
}

.gate-modal {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fadeInUp 0.6s ease;
}

.gate-logo {
  height: 90px;
  margin-bottom: 1.5rem;
  background: var(--light-beige);
  padding: 12px 20px;
  border-radius: var(--radius-md);
}

.gate-modal h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gate-modal p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.gate-modal .form-group { text-align: left; margin-bottom: 1rem; }

.gate-lgpd {
  text-align: left;
  margin: 1rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gate-lgpd label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
}

.gate-lgpd input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--redwood);
  min-width: 16px;
}

.lgpd-text {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.lgpd-text p { margin-bottom: 0.3rem; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ══ HEADER ═════════════════════════════════════════════════ */
.site-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--redwood) 100%);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.header-logo {
  height: 50px;
}

.header-title h1 {
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.header-title p {
  color: var(--beige);
  font-size: 0.85rem;
  margin: 0.2rem 0 0 0;
}

/* ══ APP LAYOUT ═════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: calc(100vh - 80px);
}

/* ══ SIDEBAR ════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 1.5rem;
  overflow-y: auto;
  border-right: 1px solid var(--border-glass);
}

.sidebar-logo {
  display: block;
  height: 75px;
  margin: 0 auto 1rem;
  background: var(--light-beige);
  padding: 10px 16px;
  border-radius: var(--radius-md);
}

.sidebar-section { margin-bottom: 1rem; }

.sidebar-section h3 {
  color: var(--beige);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 1rem 0;
}

.sidebar .form-group { margin-bottom: 0.75rem; }

.sidebar .form-group label {
  color: white;
  font-size: 0.78rem;
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
}

/* ══ MAIN CONTENT ═══════════════════════════════════════════ */
.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background: var(--bg-primary);
}

/* ══ LANDING ════════════════════════════════════════════════ */
.landing-hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

.landing-hero h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.landing-hero p {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 560px;
  margin: 0 auto;
}

.feature-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 800px;
  margin: 2rem auto;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  transition: var(--transition);
}

.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.feature-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 0.75rem;
}

.feature-icon.navy { background: var(--info-dim); }
.feature-icon.red { background: var(--danger-dim); }
.feature-icon.green { background: var(--success-dim); }

.feature-card h4 { font-size: 1rem; margin-bottom: 0.3rem; }
.feature-card p { color: var(--text-muted); font-size: 0.85rem; }

/* ══ FORM ELEMENTS ══════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 4px; }

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--redwood);
  box-shadow: 0 0 0 3px var(--redwood-glow);
}

.form-group select option { background: var(--bg-secondary); color: var(--text-primary); }
.form-group textarea { resize: vertical; }

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

.quick-fill {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.quick-fill button {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--font);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}

.quick-fill button:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
}

.range-display { display: flex; justify-content: space-between; align-items: center; }
.range-value { font-size: 1rem; font-weight: 700; color: var(--gold); }

.form-group input[type="range"] {
  -webkit-appearance: none; height: 6px; border-radius: 3px;
  background: rgba(255,255,255,0.15); border: none; padding: 0;
}
.form-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--redwood), var(--redwood-light));
  cursor: pointer; box-shadow: 0 2px 8px var(--redwood-glow);
}

.cnpj-row { display: flex; gap: 6px; }
.cnpj-row input { flex: 1; }

.btn-icon {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: white;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }

.btn-primary {
  background: linear-gradient(135deg, var(--redwood), var(--redwood-light));
  color: white; font-weight: 600; padding: 12px 24px; border-radius: var(--radius-md);
  border: none; cursor: pointer; font-size: 0.95rem; font-family: var(--font);
  transition: var(--transition); box-shadow: 0 4px 20px var(--redwood-glow);
  width: 100%; margin-top: 1rem;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--redwood-glow); }

.cnpj-status {
  font-size: 0.8rem; padding: 6px 10px; border-radius: var(--radius-sm);
  margin-bottom: 0.5rem; display: none;
}
.cnpj-status.success { display: block; background: var(--success-dim); color: var(--success); }
.cnpj-status.error { display: block; background: var(--danger-dim); color: var(--danger); }

/* ══ KPI CARDS ══════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border-glass);
  border-radius: var(--radius-md); padding: 1.25rem;
  position: relative; overflow: hidden; transition: var(--transition);
}
.kpi-card::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; }
.kpi-card.navy::before { background: linear-gradient(90deg, var(--info), #60A5FA); }
.kpi-card.red::before { background: linear-gradient(90deg, var(--danger), #F87171); }
.kpi-card.green::before { background: linear-gradient(90deg, var(--success), #4ADE80); }
.kpi-card.amber::before { background: linear-gradient(90deg, var(--warning), #FBBF24); }
.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.kpi-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.kpi-value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi-card.navy .kpi-value { color: var(--info); }
.kpi-card.red .kpi-value { color: var(--danger); }
.kpi-card.green .kpi-value { color: var(--success); }
.kpi-card.amber .kpi-value { color: var(--warning); }
.kpi-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }

/* ══ TABS ═══════════════════════════════════════════════════ */
.tabs {
  display: flex; gap: 6px; margin-bottom: 2rem;
  background: var(--bg-secondary); padding: 6px; border-radius: var(--radius-lg);
  overflow-x: auto; border: 1px solid var(--border-glass);
}
.tab-btn {
  flex: 1; padding: 14px 18px; font-size: 0.95rem; font-weight: 700;
  font-family: var(--font); color: var(--text-muted); background: transparent;
  border: none; border-radius: var(--radius-md); cursor: pointer;
  transition: var(--transition); white-space: nowrap;
  letter-spacing: 0.2px;
}
.tab-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.tab-btn.active {
  color: white; font-size: 0.95rem;
  background: linear-gradient(135deg, var(--redwood), var(--redwood-light));
  box-shadow: 0 4px 16px var(--redwood-glow);
}
.tab-content { display: none; animation: fadeInUp 0.4s ease; }
.tab-content.active { display: block; }

/* ══ IMPACT METER ═══════════════════════════════════════════ */
.impact-meter {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 1.5rem 0;
  text-align: center;
}

.impact-meter h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.impact-bar-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin: 1rem 0;
}

.impact-bar-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 80px;
  text-align: right;
}

.impact-bar-label.right { text-align: left; }

.impact-bar-track {
  flex: 1;
  max-width: 400px;
  height: 32px;
  background: rgba(255,255,255,0.06);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}

.impact-bar-fill {
  height: 100%;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  transition: width 1s ease;
}

.impact-bar-fill.atual { background: linear-gradient(90deg, var(--info), #60A5FA); }
.impact-bar-fill.reforma { background: linear-gradient(90deg, var(--redwood), var(--redwood-light)); }

.impact-big-number {
  font-size: 3rem;
  font-weight: 800;
  margin: 0.5rem 0;
  font-variant-numeric: tabular-nums;
}

.impact-big-number.up { color: var(--danger); }
.impact-big-number.down { color: var(--success); }
.impact-big-number.neutral { color: var(--warning); }

.impact-label {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* ══ GRI Example ════════════════════════════════════════════ */
.esg-card-example {
  font-size: 0.72rem;
  color: var(--gold);
  font-style: italic;
  margin-top: 4px;
  line-height: 1.3;
}

/* ══ TABLES ═════════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; }
.data-table thead th {
  background: var(--navy); color: var(--text-secondary); font-weight: 600;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-glass);
}
.data-table thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; text-align: right; }
.data-table tbody td {
  padding: 9px 14px; border-bottom: 1px solid rgba(255,255,255,0.04); color: var(--text-primary);
}
.data-table tbody td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.data-table tbody tr.zebra { background: rgba(255,255,255,0.02); }
.data-table tbody tr.row-highlight { background: var(--gold-dim); }
.data-table tbody tr.row-highlight td { color: var(--gold); font-weight: 700; }

/* ══ GLASS CARD ═════════════════════════════════════════════ */
.glass-card {
  background: var(--bg-card); backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow); transition: var(--transition);
}
.glass-card:hover { border-color: rgba(255,255,255,0.12); }

.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.compare-card-title {
  display: flex; align-items: center; gap: 8px; font-size: 0.95rem;
  font-weight: 700; margin-bottom: 1rem; padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-glass);
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-navy { background: var(--info); }
.dot-red { background: var(--redwood-light); }

.chart-container {
  position: relative; margin: 1.5rem 0; padding: 1rem;
  background: var(--bg-card); border: 1px solid var(--border-glass); border-radius: var(--radius-md);
}
.chart-container canvas { max-height: 360px; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* ══ ALERT BOX ══════════════════════════════════════════════ */
.alert-box { padding: 1.25rem; border-radius: var(--radius-md); margin: 1.5rem 0; }
.alert-box.warning { background: var(--warning-dim); border: 1px solid rgba(245,158,11,0.25); }
.alert-box.info { background: var(--info-dim); border: 1px solid rgba(59,130,246,0.25); }
.alert-box.success { background: var(--success-dim); border: 1px solid rgba(34,197,94,0.25); }
.alert-box h4 { font-size: 0.92rem; margin-bottom: 6px; }
.alert-box.warning h4 { color: var(--warning); }
.alert-box.info h4 { color: var(--info); }
.alert-box.success h4 { color: var(--success); }
.alert-box p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }

/* ══ ESG ════════════════════════════════════════════════════ */
.esg-category { margin-bottom: 1.5rem; }
.esg-category-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; }
.esg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.75rem; }
.esg-card {
  background: var(--bg-card); border: 1px solid var(--border-glass);
  border-radius: var(--radius-md); padding: 1rem; cursor: pointer; transition: var(--transition);
}
.esg-card:hover { border-color: rgba(255,255,255,0.12); transform: translateY(-2px); }
.esg-card.selected { border-color: var(--success); background: var(--success-dim); }
.esg-card.env { border-left: 3px solid var(--success); }
.esg-card.soc { border-left: 3px solid var(--info); }
.esg-card.gov { border-left: 3px solid #A855F7; }
.esg-card-name { font-weight: 600; font-size: 0.88rem; margin-bottom: 3px; }
.esg-card-desc { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 5px; }
.esg-card-rate {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 100px; background: var(--gold-dim); color: var(--gold);
}

/* ══ CTA BOX ════════════════════════════════════════════════ */
.cta-box {
  background: linear-gradient(135deg, var(--navy), var(--redwood));
  border-radius: var(--radius-xl); padding: 2.5rem 2rem; text-align: center;
  margin: 2rem 0; position: relative; overflow: hidden;
}
.cta-box::before {
  content:''; position:absolute; inset:0;
  background: radial-gradient(ellipse at 50% 0%, rgba(212,165,116,0.1), transparent 70%);
}
.cta-box h3 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; position: relative; }
.cta-box p { color: var(--text-secondary); font-size: 0.9rem; max-width: 480px; margin: 0 auto; position: relative; }

/* ══ FOOTER ═════════════════════════════════════════════════ */
.site-footer {
  border-top: 1px solid var(--border-glass); padding: 1.5rem 2rem;
  text-align: center; color: var(--text-muted); font-size: 0.8rem;
  margin-left: var(--sidebar-width);
}

/* ══ SPINNER ════════════════════════════════════════════════ */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ UTILITY ════════════════════════════════════════════════ */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ══ RESPONSIVE ═════════════════════════════════════════════ */
@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: auto; max-height: none; }
  .site-footer { margin-left: 0; }
  .compare-grid { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .feature-cards { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .tabs { flex-wrap: nowrap; }
  .tab-btn { font-size: 0.72rem; padding: 8px 8px; }
}
