/* Fluxo — tokens e componentes compartilhados (landing + app) */

:root {
  color-scheme: dark;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;

  --bg: #0a0b0f;
  --surface: #111319;
  --surface-2: #171a22;
  --surface-3: #1f232d;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f2f3f5;
  --text-2: #b4b9c5;
  --muted: #7b8190;

  --accent: #c6f432;
  --accent-hover: #d4fa5c;
  --accent-ink: #0d1203;
  --accent-soft: rgba(198, 244, 50, 0.12);

  --income: #2fd27a;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --warning: #fab219;

  /* séries dos gráficos (paleta validada para fundo escuro) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #23262e;
  --axis: #383835;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f4f0;
  --surface: #ffffff;
  --surface-2: #f7f7f4;
  --surface-3: #ededea;
  --border: rgba(11, 11, 11, 0.08);
  --border-strong: rgba(11, 11, 11, 0.16);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #77756f;

  --accent: #c6f432;
  --accent-hover: #b6e620;
  --accent-ink: #0d1203;
  --accent-soft: rgba(132, 170, 0, 0.14);

  --income: #067a34;
  --danger: #c62828;
  --danger-soft: rgba(198, 40, 40, 0.09);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px -16px rgba(0, 0, 0, 0.18);
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

img,
svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ botões */

.btn {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: progress;
  transform: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-ink);
  box-shadow: 0 8px 24px -10px rgba(198, 244, 50, 0.55);
}

.btn-primary:hover {
  --btn-bg: var(--accent-hover);
}

.btn-ghost {
  --btn-bg: transparent;
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  --btn-bg: var(--surface-2);
}

.btn-danger {
  --btn-bg: var(--danger-soft);
  --btn-fg: var(--danger);
}

.btn-lg {
  height: 52px;
  padding: 0 26px;
  font-size: 16px;
}

.btn-sm {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ------------------------------------------------------------------- campos */

.field {
  display: grid;
  gap: 6px;
}

.field > span,
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.input,
.select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23888' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

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

.input:hover,
.select:hover {
  border-color: var(--muted);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.field.has-error .input,
.field.has-error .select {
  border-color: var(--danger);
}

.field-error {
  min-height: 0;
  font-size: 12.5px;
  color: var(--danger);
}

.field-error:empty {
  display: none;
}

.form-error {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13.5px;
}

.form-error:empty {
  display: none;
}

.input-money {
  position: relative;
}

.input-money::before {
  content: 'R$';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
}

.input-money .input {
  padding-left: 44px;
}

/* segmented control (Entrada | Saída etc.) */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-3);
}

.segmented button {
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* -------------------------------------------------------------------- modal */

dialog.modal {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.7);
  overflow: auto;
}

dialog.modal[open] {
  animation: modal-in 0.35s var(--ease);
}

dialog.modal::backdrop {
  background: rgba(5, 6, 9, 0.6);
  backdrop-filter: blur(6px);
}

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

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 0;
}

.modal-head h2 {
  font-size: 22px;
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 20px 24px 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 420px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------------- toast */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-3);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in 0.35s var(--ease);
}

.toast.is-leaving {
  animation: toast-out 0.25s ease forwards;
}

.toast-msg {
  flex: 1;
}

.toast button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

:root[data-theme='light'] .toast button {
  color: var(--text);
  text-decoration: underline;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* -------------------------------------------------------------------- marca */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-dot {
  color: var(--accent);
}

:root[data-theme='light'] .brand-dot {
  color: inherit;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
