:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-strong: #edf6f3;
  --text: #182523;
  --muted: #60716d;
  --line: #d7e1de;
  --green: #1f8a64;
  --green-dark: #146348;
  --red: #bc3f3f;
  --blue: #266c9e;
  --amber: #b26b16;
  --ink-soft: #2f4240;
  --shadow: 0 18px 48px rgba(18, 36, 32, 0.11);
  --shadow-soft: 0 8px 24px rgba(18, 36, 32, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #e8f2ef 0%, rgba(245, 247, 248, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  align-content: center;
  gap: 22px;
}

.brand-block {
  display: grid;
  gap: 9px;
}

.brand-block h1,
.topbar h1 {
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted,
.status-text {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.pin-panel,
.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.pin-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.pin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.pin-row button {
  min-width: 92px;
}

.app-view {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}

.ghost-button {
  min-width: 64px;
  background: transparent;
  color: var(--green-dark);
  border: 1px solid var(--line);
}

.month-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  gap: 6px;
  background: #e5edeb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px;
  overflow-x: auto;
}

.tab {
  min-height: 42px;
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
  white-space: nowrap;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 3px 12px rgba(20, 50, 45, 0.08);
}

.tab-panel {
  display: grid;
  gap: 14px;
}

.copilot-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid rgba(31, 138, 100, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(237, 246, 243, 0.96), rgba(255, 255, 255, 0.98)),
    var(--surface);
  box-shadow: var(--shadow);
}

.copilot-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--amber));
}

.copilot-panel h2 {
  margin-top: 4px;
  font-size: 1.32rem;
  letter-spacing: 0;
}

.copilot-summary {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.55;
}

.analysis-copilot {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(237, 246, 243, 0.88)),
    var(--surface);
}

.status-pill {
  align-self: start;
  min-width: 92px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #e6f3ee;
  color: var(--green-dark);
  text-align: center;
  font-size: 0.76rem;
  font-weight: 900;
}

.status-pill.warn {
  background: #fff3e2;
  color: var(--amber);
}

.status-pill.bad {
  background: #ffecec;
  color: var(--red);
}

.action-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-strip span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 850;
}

.highlight-panel {
  background: #f8fcfb;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.metric span,
.quality-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric strong,
.quality-grid strong {
  font-size: 1.35rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.metric-income strong {
  color: var(--green-dark);
}

.metric-expense strong {
  color: var(--red);
}

.metric-balance strong {
  color: var(--blue);
}

.visual-panel {
  background: #fbfdfc;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.chart-card {
  display: grid;
  gap: 10px;
  min-height: 148px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.chart-title strong {
  color: var(--text);
}

.stack-chart {
  display: flex;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ef;
}

.stack-segment.essential,
.legend-dot.essential,
.compass-track i.living {
  background: var(--green);
}

.stack-segment.partial,
.legend-dot.partial,
.compass-track i.debt {
  background: var(--amber);
}

.stack-segment.discretionary,
.legend-dot.discretionary {
  background: var(--red);
}

.compass-track i.freedom {
  background: var(--blue);
}

.stack-segment.unclassified,
.legend-dot.unclassified {
  background: var(--muted);
}

.chart-legend {
  display: grid;
  gap: 8px;
}

.chart-legend div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
}

.chart-legend small {
  color: var(--muted);
  font-weight: 750;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.spark-bars {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  align-items: end;
  gap: 6px;
  min-height: 112px;
  padding-top: 8px;
}

.spark-item {
  display: grid;
  align-items: end;
  justify-items: center;
  gap: 5px;
  min-width: 0;
}

.spark-bar {
  width: 100%;
  min-height: 8px;
  max-width: 18px;
  border-radius: 6px 6px 2px 2px;
  background: var(--green);
}

.spark-bar.bad {
  background: var(--red);
}

.spark-item span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
}

.compass-bars {
  display: grid;
  gap: 10px;
}

.compass-row {
  display: grid;
  gap: 5px;
}

.compass-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.compass-row strong {
  color: var(--text);
}

.compass-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ef;
}

.compass-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.compass-track b {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: var(--text);
  opacity: 0.55;
}

.panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.category-list {
  display: grid;
  gap: 9px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.category-row small {
  color: var(--muted);
  font-weight: 700;
}

.bar-track {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  background: #e8eeee;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: 999px;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.quality-grid div {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 12px;
  background: var(--surface-strong);
  border-radius: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.decision-grid,
.weekly-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.decision-card {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.decision-card.warn {
  border-left-color: var(--amber);
}

.decision-card.bad {
  border-left-color: var(--red);
}

.decision-card span,
.decision-card small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.decision-card strong {
  font-size: 1.05rem;
  line-height: 1.2;
}

.compact-card {
  display: grid;
  gap: 5px;
  min-height: 76px;
  padding: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.compact-card strong {
  font-size: 1.05rem;
}

.routine-list {
  display: grid;
  gap: 8px;
}

.routine-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.routine-row > span {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--green-dark);
  font-size: 0.75rem;
  font-weight: 900;
}

.routine-row strong,
.routine-row small {
  display: block;
}

.routine-row small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.routine-row.atencao > span {
  color: var(--amber);
}

.routine-row.bloqueado > span {
  color: var(--red);
}

.year-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.timeline-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(104px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.timeline-item {
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 10px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.timeline-item.warn {
  border-top-color: var(--amber);
}

.timeline-item.bad {
  border-top-color: var(--red);
}

.timeline-item span,
.timeline-item small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
}

.timeline-item strong {
  font-size: 0.92rem;
}

.month-card {
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.month-card span,
.month-card small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.month-card strong {
  font-size: 1.02rem;
}

.month-card.warn {
  border-left: 4px solid var(--amber);
}

.month-card.bad {
  border-left: 4px solid var(--red);
}

.list-block {
  display: grid;
  gap: 8px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.list-row .title {
  font-weight: 850;
}

.list-row .desc {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions button,
.small-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.danger-button {
  background: var(--red);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
}

.full-input {
  width: 100%;
}

.insight-list {
  display: grid;
  gap: 8px;
}

.insight-card {
  padding: 12px;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
  line-height: 1.4;
}

.insight-card.warn {
  border-left-color: var(--amber);
}

.insight-card.bad {
  border-left-color: var(--red);
}

.score-ring {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border-radius: 999px;
  border: 12px solid #dfe8e5;
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--green-dark);
}

.score-ring.good {
  border-color: rgba(45, 148, 112, 0.22);
  color: var(--green-dark);
}

.score-ring.warn {
  border-color: rgba(189, 116, 34, 0.24);
  color: var(--amber);
}

.score-ring.bad {
  border-color: rgba(190, 55, 69, 0.22);
  color: var(--red);
}

.score-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.score-label {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.35;
}

.score-factor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.score-factor {
  display: grid;
  gap: 5px;
  min-height: 104px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.score-factor.warn {
  border-left-color: var(--amber);
}

.score-factor.bad {
  border-left-color: var(--red);
}

.score-factor span,
.score-factor small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.35;
}

.score-factor strong {
  font-size: 1.15rem;
}

.qa-answer {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-strong);
  line-height: 1.45;
}

.consultant-panel textarea {
  width: 100%;
  min-height: 94px;
  resize: vertical;
  line-height: 1.45;
}

.consultant-box {
  display: grid;
  gap: 10px;
}

.consultant-answer {
  min-height: 56px;
}

.consultant-result {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.consultant-result.warn {
  border-left-color: var(--amber);
}

.consultant-result.bad {
  border-left-color: var(--red);
}

.consultant-verdict {
  display: grid;
  gap: 8px;
}

.consultant-verdict strong {
  font-size: 1.05rem;
}

.consultant-verdict div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.consultant-verdict span {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.consultant-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.consultant-columns > div {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.consultant-columns h3 {
  margin-bottom: 7px;
  font-size: 0.86rem;
}

.consultant-columns ul {
  display: grid;
  gap: 6px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.csv-box {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.good {
  color: var(--green-dark);
}

.bad {
  color: var(--red);
}

.warn {
  color: var(--amber);
}

.wide,
.primary-action {
  grid-column: 1 / -1;
}

.toggle-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--text);
}

.toggle-row input {
  width: 20px;
  min-height: 20px;
}

.primary-action {
  margin-top: 2px;
  background: var(--green-dark);
}

.status-text.error {
  color: var(--red);
}

.status-text.success {
  color: var(--green-dark);
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 28px;
  }

  .login-view {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: center;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: 1.1fr 0.9fr 1fr;
  }

  .field-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tabs {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }

  .year-map {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .wide {
    grid-column: span 2;
  }
}

@media (max-width: 520px) {
  .copilot-panel {
    grid-template-columns: 1fr;
  }

  .status-pill {
    justify-self: start;
  }

  .month-row {
    grid-template-columns: 1fr 1fr;
  }

  .month-row button {
    grid-column: 1 / -1;
  }

  .metric-grid,
  .quality-grid,
  .field-grid,
  .filter-grid,
  .compact-grid,
  .decision-grid,
  .weekly-grid,
  .score-summary,
  .score-factor-grid,
  .consultant-columns {
    grid-template-columns: 1fr;
  }

  .score-ring {
    margin: 0 auto;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(92px, 1fr));
  }

  .list-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .wide,
  .primary-action {
    grid-column: auto;
  }
}
