:root {
  color-scheme: light;
  --bg: #f4f7f3;
  --surface: #ffffff;
  --surface-soft: #eef4ec;
  --text: #1f2a24;
  --muted: #667267;
  --line: #d8e2d6;
  --primary: #236b4b;
  --primary-dark: #194d36;
  --danger: #a73434;
  --warning: #8a5b12;
  --shadow: 0 16px 40px rgba(28, 54, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.nav {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1180px;
  padding: 16px 22px;
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.nav-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.nav-links a,
.button-link {
  border-radius: 6px;
  color: var(--text);
  font-weight: 650;
  padding: 8px 10px;
}

.nav-links a:hover,
.button-link:hover {
  background: var(--surface-soft);
  text-decoration: none;
}

.user-chip {
  color: var(--muted);
  font-size: 14px;
}

.container {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px 22px 48px;
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 420px;
  padding: 30px;
  width: 100%;
}

.login-card h1,
.page-title h1 {
  line-height: 1.1;
  margin: 0 0 10px;
}

.page-title {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-title p,
.login-card p {
  color: var(--muted);
  margin: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.metric {
  display: grid;
  gap: 4px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-transform: uppercase;
}

.metric strong {
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.1;
}

.chart-card {
  min-height: 320px;
}

.chart-card h2,
.chart-heading h2 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0 0 14px;
}

.chart-card-wide {
  min-width: 0;
}

.chart-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.chart-heading strong {
  white-space: nowrap;
}

.donut-layout {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: 180px minmax(0, 1fr);
}

.donut-chart {
  display: block;
  height: auto;
  max-width: 180px;
  width: 100%;
}

.chart-donut-bg,
.chart-donut-segment {
  fill: none;
  stroke-width: 26;
}

.chart-donut-bg {
  stroke: #e6eee4;
}

.chart-center-label,
.chart-axis-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.chart-center-value {
  fill: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.chart-center-label,
.chart-center-value {
  text-anchor: middle;
}

.chart-legend {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

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

.chart-legend span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-legend strong {
  font-size: 13px;
  white-space: nowrap;
}

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

.color-0 {
  background: #236b4b;
}

.color-1 {
  background: #4f8f65;
}

.color-2 {
  background: #d9a441;
}

.color-3 {
  background: #5a7da8;
}

.color-4 {
  background: #9b6a45;
}

.color-5 {
  background: #7f5aa8;
}

.color-6 {
  background: #2f8f9d;
}

.color-7 {
  background: #a85a5a;
}

.line-chart {
  display: block;
  height: auto;
  width: 100%;
}

.chart-grid-line {
  stroke: #dfe8dc;
  stroke-width: 1;
}

.line-chart-area {
  fill: rgba(35, 107, 75, 0.11);
}

.line-chart-path {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.line-chart-point {
  fill: var(--primary);
}

.chart-axis-label-end {
  text-anchor: end;
}

.positive {
  color: #176f45;
}

.negative {
  color: var(--danger);
}

.form {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  gap: 8px;
}

label {
  color: #344138;
  font-size: 14px;
  font-weight: 700;
}

.help-text {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #cbd8c8;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 107, 75, 0.14);
  outline: 0;
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button,
.button {
  background: var(--primary);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 750;
  min-height: 40px;
  padding: 10px 14px;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.button-secondary {
  background: #e4ece1;
  color: var(--text);
}

.button-secondary:hover {
  background: #d5e2d1;
}

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

.button-danger:hover {
  background: #7e2424;
}

.notice,
.danger {
  border-radius: 6px;
  font-weight: 650;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.notice {
  background: #e5f4eb;
  color: #145c39;
}

.danger {
  background: #fde8e8;
  color: var(--danger);
}

.warning-box {
  background: #fff6df;
  border: 1px solid #efd28f;
  border-radius: 6px;
  color: var(--warning);
  font-weight: 650;
  padding: 12px 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.right {
  text-align: right;
}

.tag {
  background: var(--surface-soft);
  border-radius: 999px;
  color: #395342;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.muted {
  color: var(--muted);
}

.empty {
  color: var(--muted);
  padding: 18px 0;
}

.inline-form {
  display: inline;
}

.cell-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-22 {
  margin-top: 22px;
}

.checkbox-input {
  min-height: auto;
  width: auto;
}

@media (max-width: 820px) {
  .nav,
  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .chart-legend {
    width: 100%;
  }

  .nav-links {
    align-items: flex-start;
  }
}

/* Responsive refinement: same production palette, no hidden financial fields. */
body { font-size: 15px; }
.app-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.app-header { border-bottom: 0; border-right: 1px solid var(--line); }
.nav { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; display: flex; flex-direction: column; align-items: stretch; gap: 30px; padding: 28px 18px; }
.brand { font-size: 19px; letter-spacing: -.5px; padding: 0 8px; white-space: nowrap; }
.nav-links { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.nav-links a, .nav-links button { display: flex; align-items: center; gap: 14px; min-height: 46px; padding: 11px 14px; font-size: 14px; font-weight: 500; }
.nav-links a[aria-current="page"] { background: var(--surface-soft); color: var(--primary-dark); font-weight: 750; }
.nav-links img, .nav-toggle img { flex: 0 0 20px; }
.nav-links .inline-form { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 18px; }
.nav-links button { width: 100%; }
.nav-toggle { display: none; }
.container { width: 100%; min-width: 0; max-width: 1500px; padding: 44px 30px 56px; }
.page-title { align-items: center; margin-bottom: 28px; }
.page-title h1 { font-size: clamp(27px, 2.6vw, 36px); letter-spacing: -.7px; margin-bottom: 8px; }
.page-title p { max-width: 72ch; }
.card { min-width: 0; padding: 24px; border-radius: 8px; box-shadow: 0 5px 22px rgba(28,54,38,.035); }
.card h2 { margin: 0 0 22px; font-size: 20px; line-height: 1.25; letter-spacing: -.35px; }
.grid, .grid > *, .form, .form-row { min-width: 0; }
.page-stack { grid-template-columns: minmax(0,1fr); gap: 24px; }
.entry-form { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 18px 20px; }
.entry-form .form-pair { display: contents; }
.entry-form .description-row { grid-column: span 3; }
.entry-form textarea { min-height: 46px; height: 46px; }
.entry-form > button { grid-column: 1 / -1; justify-self: start; margin-top: 4px; }
.form-row { gap: 6px; }
input, select, textarea { min-width: 0; max-width: 100%; min-height: 46px; font-size: 16px; }
input[type="file"] { padding: 8px; font-size: 14px; }
button, .button { min-height: 44px; justify-content: center; align-items: center; gap: 10px; }
.form > button { justify-self: start; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.table-wrap { max-width: 100%; overflow: visible; }
table { table-layout: fixed; font-size: 14px; }
th, td { padding: 16px 10px; overflow-wrap: anywhere; }
th { background: var(--surface-soft); font-size: 12px; letter-spacing: 0; text-transform: none; }
tbody tr:last-child td { border-bottom: 0; }
.cell-label { display: none; }
.cell-value { min-width: 0; }
.cell-value .positive, td.positive .cell-value, td.negative .cell-value { font-weight: 650; }
.cell-actions { align-items: stretch; }
.cell-actions button { font-size: 13px; padding: 8px; }
.help-text { font-size: 13px; }
.selection-detail, .notice, .danger, .warning-box, .empty, .login-card, .chart-heading { overflow-wrap: anywhere; }
.metric strong { font-size: clamp(24px, 2.7vw, 36px); overflow-wrap: anywhere; }
.dashboard-charts { grid-template-columns: repeat(2,minmax(0,1fr)); }
.dashboard-charts .chart-card-wide { grid-column: 1 / -1; }
.chart-card { min-height: 0; }
.donut-layout { grid-template-columns: minmax(110px,160px) minmax(0,1fr); }
.chart-legend span:nth-child(2) { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
.chart-legend li { grid-template-columns: 10px minmax(0,1fr); gap: 4px 8px; }
.chart-legend strong { grid-column: 2; white-space: normal; overflow-wrap: anywhere; }
.line-chart { max-height: 320px; }
.chart-heading { flex-wrap: wrap; }
.chart-heading strong { white-space: normal; }
@media (min-width:901px) and (max-width:1150px) {
  .app-shell { grid-template-columns: 200px minmax(0,1fr); }
  .nav { padding: 24px 12px; }
  .brand { font-size: 17px; }
  .container { padding: 32px 22px 48px; }
  .entry-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .entry-form .description-row { grid-column: auto; }
  .donut-layout { grid-template-columns: minmax(0,1fr); justify-items: center; }
  .chart-legend { width:100%; }
}
@media (max-width:900px) {
  .app-shell { display: block; }
  .app-header { border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { position: static; max-height: none; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
  .brand { font-size: 18px; padding: 0; }
  .nav-enhanced .nav-toggle { display: inline-flex; }
  .nav-links { width: 100%; align-items: stretch; }
  .nav-enhanced:not(.is-open) .nav-links { display: none; }
  .nav-links .inline-form { margin-top: 4px; padding-top: 10px; }
  .container { padding: 28px 20px 40px; }
  .page-title { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 22px; }
  .entry-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .entry-form .description-row { grid-column: auto; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0,1fr); }
  .dashboard-charts { grid-template-columns: minmax(0,1fr); }
  .responsive-table, .responsive-table tbody { display: block; width: 100%; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .responsive-table tbody tr { display: block; border-bottom: 1px solid var(--line); padding: 16px 0; }
  .responsive-table tbody tr:first-child { padding-top: 0; }
  .responsive-table tbody tr:last-child { border-bottom: 0; padding-bottom: 0; }
  .responsive-table td { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0,1.2fr); gap: 14px; border: 0; padding: 5px 0; text-align: left; }
  .cell-label { display: block; color: var(--muted); font-weight: 500; }
  .cell-value { overflow-wrap: anywhere; }
  .cell-actions { flex-direction: column; }
  .cell-actions button { width: 100%; }
}
@media (max-width:540px) {
  .nav { padding: 10px 16px; }
  .nav-toggle { padding: 8px 10px; gap: 6px; font-size: 14px; }
  .container { padding: 24px 16px 36px; }
  .page-title h1 { font-size: 28px; }
  .page-title p { font-size: 14px; }
  .card { padding: 18px 16px; }
  .card h2 { font-size: 19px; margin-bottom: 18px; }
  .entry-form { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .entry-form .description-row { grid-column: 1; }
  .entry-form > button, .form > button { justify-self: stretch; }
  .entry-form textarea { min-height: 46px; }
  .donut-layout { grid-template-columns: minmax(0,1fr); justify-items: center; }
  .chart-legend { width: 100%; }
  .metric strong { font-size: 30px; }
  .actions { width: 100%; }
  .actions > .button { flex: 1 1 auto; }
  .login-shell { padding: 16px; }
  .login-card { padding: 24px 18px; }
}
@media print {
  .app-shell { display: block; }
  .app-header { display: none; }
  .container { max-width: none; padding: 0; }
  .card { box-shadow: none; }
}

.chart-scale, .chart-dates { display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px 20px; color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
.chart-scale { margin-bottom:4px; }

/* Resumo: saldos, movimento mensal e atividade recente. */
.summary-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.summary-balance { background: var(--surface-soft); display: flex; flex-direction: column; align-items: flex-start; }
.summary-balance h2 { font-size: 16px; margin-bottom: 12px; }
.summary-amount { font-size: clamp(28px, 3.2vw, 44px); line-height: 1.2; letter-spacing: -1px; overflow-wrap: anywhere; max-width: 100%; }
.summary-balance p { color: var(--muted); margin: 8px 0 12px; font-size: 14px; }
.summary-balance .summary-future { color: var(--warning); margin-top: 0; }
.summary-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; font-size: 14px; }
.summary-balance .summary-link { margin-top: auto; }
.summary-box-list { margin: 0; }
.summary-box-list > div { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.summary-box-list > div:first-child { border-top: 0; padding-top: 0; }
.summary-box-list > div:last-child { padding-bottom: 0; }
.summary-box-list dt { font-weight: 500; overflow-wrap: anywhere; }
.summary-box-list dd { margin: 0; font-size: 24px; font-weight: 750; overflow-wrap: anywhere; }
.summary-month .section-toolbar { margin-bottom: 20px; }
.summary-month .section-toolbar h2, .summary-recent .section-toolbar h2 { margin: 0; }
.summary-month .section-toolbar > span { font-size: 13px; }
.summary-month-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin: 0; }
.summary-month-grid > div { min-width: 0; padding-left: 20px; border-left: 1px solid var(--line); }
.summary-month-grid > div:first-child { padding-left: 0; border-left: 0; }
.summary-month-grid dt { color: var(--muted); font-size: 14px; }
.summary-month-grid dd { margin: 6px 0 0; font-size: clamp(24px, 2.4vw, 32px); font-weight: 750; line-height: 1.2; overflow-wrap: anywhere; }
.summary-month-grid p { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.summary-detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.summary-detail .chart-heading h2 { margin-bottom: 8px; }
.summary-chart-caption { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.summary-detail .chart-scale { font-size: 12px; }
.summary-recent .section-toolbar { gap: 8px 16px; margin-bottom: 12px; }
.summary-activity { list-style: none; padding: 0; margin: 0; }
.summary-activity li { padding: 16px 0; border-top: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.summary-activity li:first-child { border-top: 0; padding-top: 0; }
.summary-activity li:last-child { padding-bottom: 0; }
.activity-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; }
.activity-heading > strong { font-weight: 650; }
.activity-heading > span { font-weight: 750; }
.summary-activity p { margin: 6px 0; font-size: 14px; }
.summary-activity small { color: var(--muted); font-size: 12px; }
.report-period-links { margin-bottom: 20px; }
@media (max-width:1150px) {
  .summary-detail { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width:640px) {
  .summary-overview, .summary-month-grid { grid-template-columns: minmax(0, 1fr); }
  .summary-month-grid { gap: 14px; }
  .summary-month-grid > div { border-left: 0; border-top: 1px solid var(--line); padding: 14px 0 0; }
  .summary-month-grid > div:first-child { border-top: 0; padding-top: 0; }
  .summary-month-grid dd { font-size: 28px; }
  .summary-box-list dd { font-size: 23px; }
  .summary-amount { font-size: 34px; }
}

.nav-admin { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 16px; }
.nav-section-label { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; margin: 0 14px 6px; }
.section-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px 24px; margin-bottom: 20px; }
.section-toolbar h2 { margin: 0; }
.filter-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }
.filter-form select { width: auto; max-width: 100%; }
.danger-confirm { min-width: 0; width: 100%; }
.danger-confirm summary { color: var(--danger); font-size: 13px; font-weight: 650; cursor: pointer; min-height: 44px; padding: 10px 8px; border: 1px solid var(--line); border-radius: 6px; }
.danger-confirm[open] summary { margin-bottom: 8px; }
.danger-confirm p { font-size: 13px; margin: 0 0 10px; color: var(--text); overflow-wrap: anywhere; }
.danger-confirm form { display: grid; }
@media (max-width:540px) {
  .section-toolbar, .filter-form { align-items: stretch; flex-direction: column; width: 100%; }
  .filter-form select { width: 100%; }
}

/* Login messages belong to the centered card, including logout and errors. */
.login-card .login-feedback { margin: 20px 0 0; font-size: 14px; font-weight: 500; line-height: 1.5; }
