:root {
  --ink: #14241c;
  --ink-soft: #3d5246;
  --brand: #1f4d3a;
  --brand-deep: #123328;
  --leaf: #3f7a5c;
  --gold: #b8923a;
  --mist: #d9e6dc;
  --paper: #f3f7f4;
  --line: rgba(20, 36, 28, 0.12);
  --danger: #9b2c2c;
  --ok: #1f6b45;
  --shadow: 0 18px 50px rgba(18, 51, 40, 0.12);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Sora", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background: #cfdcd3;
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 12% -10%, rgba(184, 146, 58, 0.28), transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 8%, rgba(63, 122, 92, 0.35), transparent 50%),
    linear-gradient(165deg, #e7efe9 0%, #c8d7cc 42%, #b7c8bc 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(20, 36, 28, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 36, 28, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 20%, #000 20%, transparent 75%);
}

.hidden {
  display: none !important;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.03em;
  color: var(--brand-deep);
  margin: 0;
  line-height: 1;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.1;
}

h2 {
  font-size: 1.55rem;
}

.lede {
  color: var(--ink-soft);
  max-width: 38rem;
  margin: 0.75rem 0 0;
}

.eyebrow {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--leaf);
}

.erro {
  color: var(--danger);
  margin: 0;
  font-size: 0.9rem;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}

.login-stage {
  width: min(440px, 100%);
  animation: rise 0.7s ease both;
}

.login-stage h1 {
  margin-top: 0.85rem;
}

.login-form {
  margin-top: 1.75rem;
  display: grid;
  gap: 0.9rem;
  padding: 1.35rem;
  background: rgba(243, 247, 244, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.login-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

label {
  display: grid;
  gap: 0.35rem;
}

label span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input,
button,
.chip {
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
}

input:focus {
  outline: 2px solid rgba(63, 122, 92, 0.35);
  border-color: var(--leaf);
}

input:read-only {
  background: rgba(31, 77, 58, 0.06);
  color: var(--ink-soft);
  cursor: default;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.25rem;
  background: var(--brand);
  color: #f5faf7;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

button:hover {
  background: var(--brand-deep);
  transform: translateY(-1px);
}

button.secondary {
  background: transparent;
  color: var(--brand);
  border: 1px solid rgba(31, 77, 58, 0.35);
}

button.ghost {
  background: transparent;
  color: var(--brand-deep);
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
}

button.ghost:hover {
  background: rgba(31, 77, 58, 0.08);
  transform: none;
}

button.danger {
  background: transparent;
  color: var(--danger);
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
}

button.danger-solid {
  background: var(--danger);
  color: #fff;
}

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

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--brand-deep);
  border: 1px solid transparent;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.icon-btn:hover {
  background: rgba(31, 77, 58, 0.1);
  transform: none;
}

.icon-btn-primary {
  background: var(--brand);
  color: #f5faf7;
}

.icon-btn-primary:hover {
  background: var(--brand-deep);
}

.icon-btn-danger {
  color: var(--danger);
}

.icon-btn-danger:hover {
  background: rgba(155, 44, 44, 0.1);
}

.row-acoes {
  display: inline-flex;
  gap: 0.15rem;
  align-items: center;
}

.col-acoes {
  width: 1%;
  text-align: right;
}

/* App shell */
.app-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
  animation: rise 0.55s ease both;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

.topbar-brand .brand-mark {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

.topbar-sub {
  display: block;
  margin-top: 0.25rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr auto;
  gap: 1.5rem;
  align-items: center;
  padding: 0.5rem 0 1.75rem;
}

.hero-ring {
  position: relative;
  width: 148px;
  height: 148px;
}

.hero-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(31, 77, 58, 0.12);
  stroke-width: 10;
}

.ring-fg {
  fill: none;
  stroke: var(--gold);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.ring-label strong {
  font-family: var(--font-display);
  font-size: 1.7rem;
  line-height: 1;
}

.ring-label span {
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.prazo-faixa {
  display: grid;
  grid-template-columns: 1fr auto 1.2fr 1fr;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: rgba(31, 77, 58, 0.09);
  border: 1px solid rgba(31, 77, 58, 0.18);
}

.prazo-faixa > div {
  min-width: 0;
}

.prazo-faixa span {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}

.prazo-faixa strong {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.prazo-origem strong {
  color: var(--ink-soft);
}

.prazo-agora strong {
  color: var(--brand-deep);
}

.prazo-agora em {
  display: block;
  margin-top: 0.25rem;
  font-style: normal;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.prazo-corte strong {
  color: var(--gold);
}

.prazo-seta {
  font-size: 1.6rem;
  color: var(--leaf);
  font-weight: 600;
  text-align: center;
  padding-top: 0.9rem;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.kpis article {
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: rgba(243, 247, 244, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  animation: rise 0.6s ease both;
}

.kpis article:nth-child(2) { animation-delay: 0.05s; }
.kpis article:nth-child(3) { animation-delay: 0.1s; }
.kpis article:nth-child(4) { animation-delay: 0.15s; }
.kpis article:nth-child(5) { animation-delay: 0.2s; }
.kpis article:nth-child(6) { animation-delay: 0.25s; }

.kpis span {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

.kpis strong {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.4vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel {
  margin-bottom: 1.25rem;
  padding: 1.35rem 1.4rem 1.5rem;
  border-radius: calc(var(--radius) + 4px);
  background: rgba(243, 247, 244, 0.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel.muted {
  box-shadow: none;
  background: rgba(243, 247, 244, 0.5);
}

.panel-head {
  margin-bottom: 1.1rem;
}

.panel-head p {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  max-width: 46rem;
}

.panel-head.row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem 1rem;
}

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

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

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.cenario-controls {
  display: grid;
  gap: 0.85rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.slider-label strong {
  font-family: var(--font-display);
  font-size: 1.45rem;
}

#slider-meta {
  width: 100%;
  accent-color: var(--brand);
}

.cenario-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  border: 1px solid rgba(31, 77, 58, 0.22);
  background: rgba(255, 255, 255, 0.55);
  color: var(--brand-deep);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.chip:hover,
.chip.active {
  background: var(--brand);
  color: #f5faf7;
  border-color: var(--brand);
}

.cenario-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 0.4rem 0 0;
}

.cenario-stats div {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(31, 77, 58, 0.06);
}

.cenario-stats dt {
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.cenario-stats dd {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
}

.charts figure {
  margin: 0;
  padding: 0.85rem 0.9rem 0.6rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
}

.charts figcaption {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

.chart-box {
  position: relative;
  width: 100%;
  height: 220px;
  max-height: 220px;
}

.chart-box-wide {
  height: 200px;
  max-height: 200px;
}

.chart-box canvas {
  display: block;
  max-width: 100%;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 14, 0.55);
  backdrop-filter: blur(3px);
  animation: fade-in 0.2s ease both;
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  padding: 1.25rem 1.35rem 1.4rem;
  border-radius: calc(var(--radius) + 4px);
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 28px 80px rgba(8, 20, 14, 0.35);
  animation: modal-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.modal-head h2 {
  font-size: 1.35rem;
}

.modal-lede {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.modal-panel.hidden {
  display: none !important;
}

.modal-dialog .form-grid {
  grid-template-columns: 1fr 1fr;
}

.modal-dialog .form-grid .span-2 {
  grid-column: span 2;
}

.tipo-lancamento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.tipo-btn {
  border-radius: 12px;
  border: 1px solid rgba(31, 77, 58, 0.22);
  background: rgba(255, 255, 255, 0.65);
  color: var(--brand-deep);
  padding: 0.7rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.tipo-btn:hover {
  background: rgba(31, 77, 58, 0.08);
  transform: none;
}

.tipo-btn.active {
  background: var(--brand);
  color: #f5faf7;
  border-color: var(--brand);
}

body.modal-open {
  overflow: hidden;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.foot {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
}

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

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-ring {
    justify-self: start;
  }

  .prazo-faixa {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .prazo-seta {
    display: none;
  }

  .kpis,
  .cenario-stats {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid,
  .form-grid.compact,
  .charts {
    grid-template-columns: 1fr;
  }

  .span-2,
  .charts .span-2 {
    grid-column: span 1;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .kpis {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: calc(100% - 1.2rem);
  }

  .chart-box {
    height: 180px;
    max-height: 180px;
  }

  .chart-box-wide {
    height: 170px;
    max-height: 170px;
  }
}
