:root {
  --bg: #0b1326;
  --card: #131b2e;
  --border: #222a3d;
  --primary: #4edea3;
  --primary-strong: #10b981;
  --coral: #ffb3b0;
  --ink: #dae2fd;
  --muted: #bbcabf;
  --dim: #86948a;
  --ring: 301.59289474462014; /* 2π * 48 */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  color-scheme: dark;
}

.font-headline { font-family: 'Hanken Grotesk', sans-serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

.view-pane {
  display: none;
  animation: fadeIn 0.22s ease;
}
.view-pane.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.accent-green { border-left: 3px solid var(--primary-strong); }
.accent-coral { border-left: 3px solid var(--coral); }
.accent-top-coral { border-top: 3px solid rgba(255, 179, 176, 0.55); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-radius: 0.9rem;
  border: none;
  background: var(--primary);
  color: #003824;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(78, 222, 163, 0.22);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:hover { filter: brightness(1.05); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}
.chip-coral {
  border: 1px solid rgba(255, 179, 176, 0.45);
  color: var(--coral);
}
.chip-coral:hover { background: rgba(255, 179, 176, 0.08); }
.chip-green {
  border: 1px solid rgba(78, 222, 163, 0.45);
  color: var(--primary);
}
.chip-green:hover { background: rgba(78, 222, 163, 0.08); }

.progress-track {
  height: 0.55rem;
  border-radius: 999px;
  background: #060e20;
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-strong), var(--primary));
  transition: width 0.45s ease;
}

.input-money {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.85rem;
  background: #060e20;
  border: 1.5px solid var(--primary-strong);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}
.input-money-muted {
  border-color: var(--border);
}
.input-money-prefix {
  flex: 0 0 auto;
}
.input-money-value {
  /* width:0 + flex força o input a respeitar o container (Safari iOS) */
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  max-width: 100%;
  background: transparent !important;
  background-color: transparent !important;
  border: 0;
  outline: none;
  margin: 0;
  padding: 0.15rem 0;
  text-align: right;
  color: #dae2fd !important;
  -webkit-text-fill-color: #dae2fd;
  caret-color: #4edea3;
  font-family: 'Hanken Grotesk', sans-serif;
  font-weight: 800;
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  line-height: 1.25;
  box-sizing: border-box;
  color-scheme: dark;
  /* remove aparência nativa clara no iOS */
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}
.input-money-value-sm {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: clamp(1rem, 4vw, 1.2rem);
}
.input-money-value::placeholder {
  color: #64748b;
  -webkit-text-fill-color: #64748b;
  opacity: 1;
}
/* Autofill iOS/Safari pinta de branco — força fundo escuro */
.input-money-value:-webkit-autofill,
.input-money-value:-webkit-autofill:hover,
.input-money-value:-webkit-autofill:focus,
.input-money-value:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #060e20 inset !important;
  box-shadow: 0 0 0 1000px #060e20 inset !important;
  -webkit-text-fill-color: #dae2fd !important;
  caret-color: #4edea3;
  transition: background-color 99999s ease-in-out 0s;
}

.input-field {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 0.75rem;
  background: #060e20 !important;
  background-color: #060e20 !important;
  border: 1px solid var(--border);
  color: #dae2fd !important;
  -webkit-text-fill-color: #dae2fd;
  outline: none;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
}
.input-field:focus { border-color: var(--primary); }
.input-field:-webkit-autofill,
.input-field:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #060e20 inset !important;
  -webkit-text-fill-color: #dae2fd !important;
}

.input-cost {
  width: 7.5rem;
  text-align: right;
  padding: 0.45rem 0.6rem;
  border-radius: 0.6rem;
  background: #060e20;
  border: 1px solid var(--border);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  outline: none;
}
.input-cost:focus { border-color: var(--primary); }

.cost-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.badge-primary {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(78, 222, 163, 0.12);
  color: var(--primary);
  white-space: nowrap;
}
.badge-expense {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 600;
  background: rgba(255, 179, 176, 0.12);
  color: var(--coral);
}

.slider {
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: #060e20;
  outline: none;
}
.slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(78, 222, 163, 0.2);
}
.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

.ring-track {
  fill: none;
  stroke: #222a3d;
  stroke-width: 10;
}
.ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0.75rem;
  color: #86948a;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
}
.nav-item.active { color: var(--primary); }
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
}
.nav-item.active .nav-icon {
  background: rgba(78, 222, 163, 0.15);
}

.safe-bottom {
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.modal-backdrop {
  background: rgba(11, 19, 38, 0.82);
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease;
}
.modal-hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  animation: splashPulse 1.4s ease-in-out infinite;
}
@keyframes splashPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.04); opacity: 0.92; }
}
.splash-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
  display: inline-block;
}
.splash-dots span.active { background: #64748b; }

#toast-container {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(92vw, 24rem);
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: 0.85rem;
  background: #10b981;
  color: #003824;
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.25s ease;
}
.toast.warn { background: #f59e0b; color: #1c1000; }
.toast.info { background: #222a3d; color: var(--ink); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.lancamento-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.85rem;
  background: rgba(6, 14, 32, 0.55);
  border: 1px solid rgba(34, 42, 61, 0.8);
}
.lancamento-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.lancamento-icon.gain { background: rgba(78, 222, 163, 0.12); color: var(--primary); }
.lancamento-icon.loss { background: rgba(255, 179, 176, 0.12); color: var(--coral); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Mobile shell (default) */
.desktop-sidebar,
.desktop-header {
  display: none;
}

.app-shell {
  min-height: 100dvh;
  padding-bottom: 6rem;
  max-width: 32rem;
  margin-left: auto;
  margin-right: auto;
}

.app-content {
  min-width: 0;
}

/* Métricas detalhadas */
.period-toggle {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 0.65rem;
  background: #060e20;
  border: 1px solid var(--border);
}
.period-btn {
  border: none;
  background: transparent;
  color: var(--dim);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
}
.period-btn.active {
  background: rgba(78, 222, 163, 0.15);
  color: var(--primary);
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.metric-tile {
  padding: 0.85rem;
  border-radius: 0.85rem;
  background: rgba(6, 14, 32, 0.55);
  border: 1px solid rgba(34, 42, 61, 0.9);
}
.metric-tile.accent-metric-green {
  border-color: rgba(78, 222, 163, 0.25);
  background: rgba(78, 222, 163, 0.06);
}
.metric-ico {
  font-size: 1.15rem !important;
  color: var(--dim);
  margin-bottom: 0;
}
.metric-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
  border-radius: 999px;
  border: 1px solid rgba(78, 222, 163, 0.45);
  background: rgba(78, 222, 163, 0.12);
  color: #4edea3 !important;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  line-height: 1;
  position: relative;
  z-index: 2;
  -webkit-tap-highlight-color: rgba(78, 222, 163, 0.3);
  touch-action: manipulation;
}
.info-btn::before {
  content: "";
  position: absolute;
  inset: -8px;
}
.info-btn .material-symbols-outlined {
  font-size: 1.05rem !important;
  color: #4edea3 !important;
  line-height: 1;
  pointer-events: none;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.info-btn:hover,
.info-btn:focus-visible,
.info-btn:active {
  border-color: #4edea3;
  background: rgba(78, 222, 163, 0.22);
  outline: none;
}
.info-btn-xs {
  width: 1.4rem;
  height: 1.4rem;
  min-width: 1.4rem;
  min-height: 1.4rem;
}
.info-btn-xs .material-symbols-outlined {
  font-size: 0.9rem !important;
}
.metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
  margin: 0 0 0.35rem;
}
.metric-value {
  font-family: 'Hanken Grotesk', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
}

.insights-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.day-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  background: rgba(6, 14, 32, 0.5);
}
.day-chip-best {
  color: #003824;
  background: var(--primary);
  border-color: transparent;
}

@media (min-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
  }
  .metric-value {
    font-size: 1.15rem;
  }
  .insights-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
}

@media (min-width: 1100px) {
  .insights-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.alerta-manut {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.alerta-manut:hover { filter: brightness(1.08); }
.alerta-critico {
  background: rgba(144, 24, 34, 0.35);
  border-color: rgba(255, 179, 176, 0.45);
  color: #ffb3b0;
}
.alerta-aviso {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.revisao-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(6, 14, 32, 0.5);
}
.revisao-row.rev-late {
  border-color: rgba(255, 179, 176, 0.45);
  background: rgba(144, 24, 34, 0.2);
}
.revisao-row.rev-soon {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}
.revisao-row.rev-done {
  opacity: 0.65;
}

@media (min-width: 768px) {
  body {
    background:
      radial-gradient(ellipse at top right, rgba(16, 185, 129, 0.07), transparent 45%),
      radial-gradient(ellipse at bottom left, rgba(30, 58, 95, 0.35), transparent 50%),
      var(--bg);
  }

  .app-shell {
    display: flex;
    max-width: none;
    margin: 0;
    padding-bottom: 0;
    min-height: 100dvh;
  }

  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    padding: 1.5rem 1rem;
    background: #131b2e;
    border-right: 1px solid var(--border);
    z-index: 40;
  }

  .app-content {
    flex: 1;
    margin-left: 260px;
    min-width: 0;
    max-width: none;
  }

  .mobile-header,
  .mobile-bottom-nav {
    display: none !important;
  }

  .desktop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.75rem 2rem 0.5rem;
  }

  .app-main {
    padding: 1rem 2rem 2.5rem !important;
    max-width: 1120px;
  }

  .side-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: none;
    border-radius: 0.75rem;
    background: transparent;
    color: var(--dim);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .side-nav-item:hover {
    background: rgba(78, 222, 163, 0.06);
    color: var(--ink);
  }
  .side-nav-item.active {
    background: rgba(78, 222, 163, 0.12);
    color: var(--primary);
  }

  .dash-top {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1rem;
  }
  .dash-stats {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  .dash-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .registro-layout {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1.25rem;
    align-items: start;
  }
  .registro-layout.space-y-4 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 0;
  }

  .metas-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  .metas-layout.space-y-4 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 0;
  }
  .metas-save {
    grid-column: 1 / -1;
    max-width: 320px;
    justify-self: start;
  }

  .historico-layout {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1.25rem;
    align-items: start;
  }
  .historico-lista {
    max-height: calc(100dvh - 10rem);
    overflow-y: auto;
  }

  .perfil-layout {
    max-width: 920px;
  }
  .perfil-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
  }
  .perfil-revisoes {
    grid-column: 1 / -1;
  }
  .perfil-reset {
    grid-column: 1 / -1;
  }

  #toast-container {
    left: auto;
    right: 2rem;
    transform: none;
    bottom: 2rem;
  }

  .modal-backdrop {
    align-items: center !important;
  }
  #modal-rapido .card {
    margin-bottom: 0 !important;
  }
}

@media (min-width: 1280px) {
  .desktop-sidebar {
    width: 280px;
  }
  .app-content {
    margin-left: 280px;
  }
  .app-main {
    max-width: 1200px;
  }
}

