:root {
  --ink: #1d1d35;
  --muted: #727287;
  --paper: #f7f7fb;
  --panel: #ffffff;
  --line: #e4e4ef;
  --navy: #020269;
  --navy-2: #11117c;
  --green: #ff6600;
  --green-soft: #fff0e6;
  --mint: #ff9a57;
  --amber: #b64f0b;
  --amber-soft: #fff0e6;
  --red: #b54848;
  --red-soft: #fbeaea;
  --blue: #3030a8;
  --shadow: 0 12px 34px rgba(2, 2, 105, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Poppins", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button, select, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 18px;
  color: white;
  background: linear-gradient(180deg, #0d0d7b 0%, #02024f 100%);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 4px 28px; }
.brand-mark { width: 106px; height: 49px; display: grid; place-items: center; flex: 0 0 auto; padding: 7px 8px; border-radius: 11px; background: #ffffff; box-shadow: 0 8px 20px rgba(0,0,0,.13); }
.brand-mark img { display: block; width: 100%; height: auto; }
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; margin-top: 3px; color: #c2c2e8; font-size: 10px; }

.nav { display: grid; gap: 7px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 12px 13px; border: 1px solid transparent; border-radius: 11px; color: #c2c2e8; background: transparent; text-align: left; transition: 160ms ease; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: rgba(255,102,0,.2); border-color: rgba(255,153,87,.22); box-shadow: inset 3px 0 0 #ff6600; }
.nav-icon { width: 23px; color: #ff9a57; font-size: 10px; font-weight: 800; }
.nav-badge { margin-left: auto; min-width: 22px; padding: 3px 7px; border-radius: 999px; color: #ffffff; background: #ff6600; font-size: 11px; font-weight: 800; text-align: center; }

.sidebar-status { margin-top: auto; display: flex; align-items: flex-start; gap: 10px; padding: 15px; border: 1px solid rgba(255,255,255,.09); border-radius: 13px; background: rgba(255,255,255,.04); }
.status-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: #ff7d28; box-shadow: 0 0 0 4px rgba(255,102,0,.14); }
.sidebar-status strong, .sidebar-status small { display: block; }
.sidebar-status strong { font-size: 12px; }
.sidebar-status small { margin-top: 5px; color: #bdbde2; font-size: 10px; }

.main { min-width: 0; padding: 0 34px 52px; }
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 3px 0 0; font-size: 25px; letter-spacing: -0.035em; }
.eyebrow { margin: 0; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: flex-end; gap: 10px; }
.filter-group { display: flex; align-items: flex-end; gap: 10px; }
.filter-group.hidden { display: none; }
.select-wrap { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.select-wrap select { min-width: 170px; height: 39px; padding: 0 34px 0 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; outline: none; }
.primary-button { height: 39px; padding: 0 16px; border: 0; border-radius: 9px; color: white; background: var(--green); font-weight: 750; box-shadow: 0 7px 18px rgba(255,102,0,.22); }
.primary-button:hover { background: #e95d00; }
.mobile-menu { display: none; }

.view { display: none; padding-top: 24px; }
.view.active { display: block; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 17px; border: 1px solid #ffd2b4; border-radius: 12px; background: var(--green-soft); }
.notice strong, .notice span { display: block; }
.notice strong { margin-bottom: 4px; font-size: 12px; }
.notice span { color: #6e5140; font-size: 12px; }
.notice-tag { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; color: #9b3d00 !important; background: #ffd9bf; font-weight: 800; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; margin-top: 18px; }
.kpi-card, .panel { border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: var(--shadow); }
.kpi-card { min-height: 140px; padding: 19px; }
.kpi-card.featured { color: white; border-color: transparent; background: linear-gradient(145deg, #020269 0%, #19199a 100%); }
.kpi-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; }
.featured .kpi-label { color: #d0d0f2; }
.kpi-card strong { display: block; margin-top: 25px; font-size: 25px; letter-spacing: -.04em; }
.kpi-card small { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.featured small { color: #c8c8ea; }
.tag { padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.tag.neutral { color: #52635f; background: #edf1ef; }
.tag.positive { color: #ffffff; background: #ff6600; }
.tag.negative { color: #944242; background: #f8dfdf; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 15px; margin-top: 15px; }
.panel { padding: 20px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel h2 { margin: 5px 0 0; font-size: 16px; letter-spacing: -.02em; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; }
.revenue-dot { background: #020269; }
.ebitda-dot { background: #ff6600; }
.opex-dot { background: #ff9a57; }
.trend-chart { min-height: 255px; margin-top: 18px; }
.trend-chart svg { width: 100%; height: 255px; overflow: visible; }
.axis-line { stroke: #dfe7e3; stroke-width: 1; }
.grid-line { stroke: #edf1ef; stroke-width: 1; stroke-dasharray: 3 5; }
.chart-label { fill: #71807c; font-size: 10px; }
.chart-value { fill: #344742; font-size: 9px; font-weight: 700; }

.score { color: var(--green); font-size: 24px; font-weight: 800; letter-spacing: -.04em; }
.progress { height: 7px; margin: 20px 0; overflow: hidden; border-radius: 999px; background: #e7ece9; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #020269, #ff6600); }
.quality-list { margin: 0; }
.quality-list div { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #edf1ef; }
.quality-list dt { color: var(--muted); }
.quality-list dd { margin: 0; font-weight: 800; }
.quality-list .warning-row dd { color: var(--amber); }
.text-button { margin-top: 15px; padding: 0; border: 0; color: var(--green); background: transparent; font-weight: 800; }

.summary-panel { margin-top: 15px; }
.subtle { color: var(--muted); font-size: 11px; }
.group-bars { display: grid; gap: 14px; margin-top: 20px; }
.group-row { display: grid; grid-template-columns: minmax(170px, 1.2fr) 3fr 120px; gap: 14px; align-items: center; }
.group-row strong { font-size: 11px; }
.bar-track { height: 9px; overflow: hidden; border-radius: 999px; background: #edf1ef; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #020269, #ff6600); }
.group-row span:last-child { text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }

.section-intro { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 18px; }
.section-intro h2 { margin: 6px 0 7px; font-size: 21px; letter-spacing: -.035em; }
.section-intro p:last-child { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.55; }
.accounting-badge { padding: 8px 11px; border: 1px solid #ffd2b4; border-radius: 999px; color: #9b3d00; background: var(--green-soft); font-size: 11px; font-weight: 800; }
.accounting-badge.warning { color: #8a541b; border-color: #f1d19f; background: var(--amber-soft); }
.calculation-layout { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(300px,.7fr); gap: 15px; }
.bridge { display: grid; gap: 8px; }
.bridge-row { display: grid; grid-template-columns: 1.5fr 2fr 125px; gap: 14px; align-items: center; padding: 9px 0; border-bottom: 1px solid #edf1ef; }
.bridge-row:last-child { border-bottom: 0; }
.bridge-row strong { font-size: 12px; }
.bridge-bar { height: 12px; overflow: hidden; border-radius: 4px; background: #edf1ef; }
.bridge-bar span { display: block; height: 100%; border-radius: inherit; }
.bridge-row.revenue .bridge-bar span { background: #020269; }
.bridge-row.cost .bridge-bar span { background: #ff9a57; }
.bridge-row.total { margin-top: 7px; padding: 15px 12px; border-radius: 10px; border: 0; background: var(--green-soft); }
.bridge-row.total .bridge-bar span { background: var(--green); }
.bridge-row em { text-align: right; font-style: normal; font-weight: 800; }
.excluded-list { display: grid; gap: 1px; margin-top: 17px; }
.excluded-item { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid #edf1ef; }
.excluded-item strong { font-size: 11px; }
.excluded-item span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.excluded-item.locked strong::after { content: "Regra fixa"; display: inline-block; margin-left: 7px; padding: 3px 6px; border-radius: 999px; color: #9b3d00; background: var(--green-soft); font-size: 8px; text-transform: uppercase; }

.search-wrap { min-width: 270px; }
.search-wrap label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.search-wrap input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: white; }
.search-wrap input:focus { border-color: #79bea5; box-shadow: 0 0 0 3px rgba(121,190,165,.14); }
.table-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid #e9eeeb; text-align: left; white-space: nowrap; }
th { color: #ffffff; background: #020269; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
td { font-size: 12px; }
tbody tr:hover { background: #f8faf9; }
tbody tr:last-child td { border-bottom: 0; }
.status-chip { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.status-chip.included { color: #9b3d00; background: var(--green-soft); }
.status-chip.excluded { color: #6a4b1e; background: var(--amber-soft); }
.status-chip.review { color: #944242; background: var(--red-soft); }
.rule-note { color: var(--muted); }

.operations-grid { grid-template-columns: minmax(0, 1.55fr) minmax(310px, .8fr); }
.secondary-kpis { margin-top: 15px; }
.operations-table-panel { margin-top: 15px; }
.operations-table-heading { padding: 20px; }
.operations-table-panel table { border-top: 1px solid var(--line); }
.alert-score { color: var(--red); }
.data-warning { margin: 16px 0 13px; padding: 11px 12px; border-radius: 10px; color: #784343; background: var(--red-soft); font-size: 11px; line-height: 1.5; }
.reason-list { display: grid; gap: 13px; }
.reason-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px; gap: 8px 12px; align-items: center; }
.reason-row strong { font-size: 11px; }
.reason-row em { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 800; text-align: right; }
.reason-track { grid-column: 1 / -1; height: 7px; overflow: hidden; border-radius: 999px; background: #edf1ef; }
.reason-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #020269, #ff6600); }
.coverage-line { height: 8px; margin: 0 0 18px; overflow: hidden; border-radius: 999px; background: #f0dede; }
.coverage-line span { display: block; min-width: 4px; height: 100%; border-radius: inherit; background: var(--red); }
.coverage-line.wide { margin-top: 20px; background: #ececf7; }
.coverage-line.wide span { background: linear-gradient(90deg, #020269, #ff6600); }

.cash-grid { grid-template-columns: minmax(0, 1.35fr) minmax(340px, .85fr); }
.cash-table-panel { margin-top: 15px; }
.capex-list { display: grid; gap: 1px; margin-top: 14px; }
.capex-list > div { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid #edf1ef; }
.capex-list span { color: var(--muted); font-size: 10px; line-height: 1.4; }
.capex-list strong { font-size: 11px; white-space: nowrap; }
.neutral-warning { color: #54546b; background: #f0f0f8; }
.cash-bridge { display: grid; gap: 9px; margin-top: 17px; padding-top: 16px; border-top: 1px solid var(--line); }
.cash-bridge > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 10px; }
.cash-bridge strong { color: var(--ink); font-size: 12px; white-space: nowrap; }
.cash-bridge .cash-total { margin-top: 3px; padding: 12px; border-radius: 10px; color: #71401f; background: var(--green-soft); font-weight: 700; }
.cash-bridge .cash-total strong { color: #9b3d00; font-size: 14px; }
.missing-row td:not(:nth-child(2)) { color: #aaaabd; background: #fafafd; }
.obligations-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.obligation-value { margin-top: 24px; }
.obligation-value strong, .obligation-value span { display: block; }
.obligation-value strong { font-size: 30px; letter-spacing: -.04em; }
.obligation-value span { margin-top: 6px; color: var(--muted); font-size: 11px; }

.strategy-grid { grid-template-columns: minmax(0, 1.45fr) minmax(330px, .8fr); }
.install-dot { background: #020269; }
.cancel-dot { background: #ff6600; }
.chart-footnote { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.priority-list { display: grid; gap: 1px; margin-top: 15px; }
.priority-list > div { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 11px 0; border-bottom: 1px solid #edf1ef; }
.priority-list > div:last-child { border-bottom: 0; }
.priority-list > div > span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--navy); font-size: 10px; font-weight: 800; }
.priority-list > div.done > span { background: var(--green); }
.priority-list p { margin: 0; }
.priority-list strong, .priority-list small { display: block; }
.priority-list strong { font-size: 11px; }
.priority-list small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-top: 15px; }
.insight-card { min-height: 150px; padding: 19px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.insight-card > span { display: inline-flex; padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.insight-card strong { display: block; margin-top: 18px; font-size: 18px; letter-spacing: -.03em; }
.insight-card p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.insight-card.warning > span { color: #944242; background: var(--red-soft); }
.insight-card.positive > span { color: #9b3d00; background: var(--green-soft); }
.insight-card.neutral > span { color: #32327e; background: #ededfa; }

.valuation-hero { position: relative; overflow: hidden; padding: 28px; border-radius: 18px; color: white; background: radial-gradient(circle at 88% 12%, rgba(255,102,0,.34), transparent 30%), linear-gradient(135deg, #02024f, #111190); box-shadow: 0 18px 42px rgba(2,2,105,.18); }
.valuation-hero .eyebrow { color: #ffb17e; }
.valuation-headline { display: flex; flex-wrap: wrap; gap: 24px 48px; align-items: flex-end; margin-top: 18px; }
.valuation-headline > div + div { padding-left: 28px; border-left: 1px solid rgba(255,255,255,.18); }
.valuation-headline span, .valuation-headline strong { display: block; }
.valuation-headline span { color: #c8c8ea; font-size: 11px; }
.valuation-headline strong { margin-top: 5px; font-size: clamp(27px, 4vw, 44px); letter-spacing: -.05em; }
.valuation-headline > div + div strong { color: #ff9a57; font-size: clamp(22px, 3vw, 31px); }
.valuation-hero > p:not(.eyebrow) { max-width: 760px; margin: 15px 0 0; color: #d2d2ee; font-size: 12px; line-height: 1.6; }
.range-label { max-width: 720px; display: flex; justify-content: space-between; margin-top: 22px; color: #d2d2ee; font-size: 10px; }
.range-label strong { color: white; font-size: 12px; }
.valuation-range { width: min(720px, 100%); margin-top: 10px; accent-color: #ff6600; }
.valuation-layout { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(0, 1.3fr); gap: 15px; margin-top: 15px; align-items: start; }
.assumptions-panel h2 { margin-bottom: 20px; }
.assumption-block { padding-top: 18px; margin-top: 18px; border-top: 1px solid #edf1ef; }
.step-label { color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.basis-options { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
.basis-option { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: white; text-align: left; }
.basis-option:hover { border-color: #a9a9d8; }
.basis-option.active { border-color: var(--navy); background: #f0f0fb; box-shadow: 0 0 0 2px rgba(2,2,105,.08); }
.basis-option strong { font-size: 11px; }
.basis-option small { grid-column: 1; color: var(--muted); font-size: 9px; }
.basis-option em { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--navy); font-size: 10px; font-style: normal; font-weight: 800; }
.input-grid { display: grid; gap: 12px; }
.input-field { display: grid; gap: 6px; }
.input-field.hidden { display: none; }
.input-field span { color: var(--ink); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.input-field input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; outline: none; }
.input-field input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(2,2,105,.08); }
.readonly-field input { color: var(--muted); background: #f4f4f8; }
.input-field small { color: var(--muted); font-size: 9px; line-height: 1.4; }
.valuation-results { display: grid; gap: 15px; min-width: 0; }
.valuation-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.valuation-kpis .kpi-card { min-height: 130px; }
.sensitivity-panel { padding: 0; overflow: hidden; }
.sensitivity-panel .panel-heading { padding: 20px; }
.sensitivity-panel tr.selected-scenario td { color: var(--navy); background: #f0f0fb; font-weight: 700; }
.methodology-panel { display: grid; grid-template-columns: minmax(180px,.45fr) minmax(0,1.5fr); gap: 28px; align-items: center; margin-top: 15px; }
.methodology-panel p:last-child { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 360px; padding: 13px 16px; border-radius: 11px; color: white; background: #020269; box-shadow: 0 15px 40px rgba(2,2,105,.24); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .topbar { align-items: flex-start; padding: 24px 0; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .filter-group { flex-wrap: wrap; justify-content: flex-end; }
  .dashboard-grid, .calculation-layout, .operations-grid, .strategy-grid, .valuation-layout, .cash-grid, .obligations-grid { grid-template-columns: 1fr; }
  .insight-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; width: 252px; transform: translateX(-100%); transition: 180ms ease; }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 0 18px 35px; }
  .topbar { display: grid; grid-template-columns: auto 1fr; }
  .topbar-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .mobile-menu { display: inline-flex; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: white; }
  .section-intro { display: block; }
  .search-wrap, .accounting-badge { display: inline-block; margin-top: 16px; }
  .methodology-panel { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 580px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .valuation-kpis { grid-template-columns: 1fr; }
  .topbar-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .filter-group { display: grid; grid-template-columns: 1fr; width: 100%; }
  .filter-group.hidden { display: none; }
  .select-wrap select, .primary-button { width: 100%; }
  .notice { align-items: flex-start; }
  .notice-tag { display: none !important; }
  .group-row { grid-template-columns: 1fr 90px; }
  .group-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .bridge-row { grid-template-columns: 1fr 100px; }
  .bridge-row .bridge-bar { grid-column: 1 / -1; grid-row: 2; }
  .valuation-hero { padding: 22px 18px; }
  .valuation-headline { display: grid; }
  .valuation-headline > div + div { padding: 0; border-left: 0; }
}
