/* MEIDEI — design system
 *
 * CSS próprio, sem build step: basta enviar o arquivo por FTP.
 * Paleta e tokens centralizados em :root para facilitar ajustes futuros.
 */

:root {
  color-scheme: light;

  /* Marca */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(79, 70, 229, 0.18);
  --brand-accent: #6366f1;
  --brand-mark-shadow: 0 8px 20px rgba(79, 70, 229, 0.28);

  /* Semântica financeira */
  --success: #059669;
  --success-soft: #ecfdf5;
  --success-hover: #047857;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-hover: #b91c1c;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --info: #2563eb;
  --info-soft: #eff6ff;

  /* Superfícies */
  --bg: #f1f5f9;
  --bg-auth: linear-gradient(160deg, #eef2ff 0%, #f8fafc 45%, #f1f5f9 100%);
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-elevated: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --card-hero-bg: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);

  /* Texto */
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --placeholder: #94a3b8;

  /* Bordas e sombras */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 24px -4px rgba(15, 23, 42, 0.08);
  --btn-primary-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
  --btn-success-shadow: 0 1px 2px rgba(5, 150, 105, 0.2);
  --btn-danger-shadow: 0 1px 2px rgba(220, 38, 38, 0.2);

  /* Alertas e tags */
  --alert-error-text: #991b1b;
  --alert-success-text: #166534;
  --alert-info-text: #1e40af;
  --tag-warning-text: #92400e;
  --tag-warning-border: #fde68a;
  --tag-estimated-border: #c7d2fe;
  --ghost-hover-border: #c7d2fe;
  --health-dot-neutral: rgba(148, 163, 184, 0.25);
  --health-dot-success: rgba(5, 150, 105, 0.2);
  --health-dot-warning: rgba(217, 119, 6, 0.2);
  --health-dot-danger: rgba(220, 38, 38, 0.2);

  /* Gráfico */
  --chart-grid: #f1f5f9;

  /* Layout */
  --content-width: 720px;
  --auth-width: 420px;
  --topbar-height: 60px;

  /* Compatibilidade com nomes antigos usados no SVG do gráfico */
  --blue: var(--primary);
  --green: var(--success);
  --red: var(--danger);
  --amber: var(--warning);
  --ink: var(--text);
  --muted-ink: var(--text-muted);
  --card: var(--surface);
  --radius: var(--radius-lg);
  --shadow: var(--shadow-sm);
}

[data-theme="dark"] {
  color-scheme: dark;

  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, 0.14);
  --primary-ring: rgba(129, 140, 248, 0.28);
  --brand-accent: #6366f1;
  --brand-mark-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --success-hover: #6ee7b7;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --danger-hover: #fca5a5;
  --danger-border: rgba(248, 113, 113, 0.35);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.12);

  --bg: #0f172a;
  --bg-auth: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  --surface: #1e293b;
  --surface-muted: #172033;
  --surface-elevated: #243044;
  --topbar-bg: rgba(15, 23, 42, 0.88);
  --card-hero-bg: linear-gradient(135deg, #1e293b 0%, #172033 100%);

  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --placeholder: #64748b;

  --border: #334155;
  --border-strong: #475569;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.45);
  --btn-primary-shadow: 0 1px 3px rgba(99, 102, 241, 0.35);
  --btn-success-shadow: 0 1px 3px rgba(52, 211, 153, 0.25);
  --btn-danger-shadow: 0 1px 3px rgba(248, 113, 113, 0.25);

  --alert-error-text: #fecaca;
  --alert-success-text: #bbf7d0;
  --alert-info-text: #bfdbfe;
  --tag-warning-text: #fde68a;
  --tag-warning-border: rgba(251, 191, 36, 0.35);
  --tag-estimated-border: rgba(129, 140, 248, 0.35);
  --ghost-hover-border: rgba(129, 140, 248, 0.45);
  --health-dot-neutral: rgba(148, 163, 184, 0.35);
  --health-dot-success: rgba(52, 211, 153, 0.3);
  --health-dot-warning: rgba(251, 191, 36, 0.3);
  --health-dot-danger: rgba(248, 113, 113, 0.3);

  --chart-grid: #1e293b;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* Páginas de login/cadastro ------------------------------------------------ */

body.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg-auth);
}

.container {
  width: 100%;
  max-width: var(--auth-width);
  background: var(--surface);
  padding: 32px 28px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.container h1 {
  text-align: center;
  margin: 0 0 4px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.container .brand-mark-lg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--brand-accent) 100%);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: var(--brand-mark-shadow);
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

.link {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.link a {
  font-weight: 500;
  text-decoration: none;
}

.link a:hover { text-decoration: underline; }

/* Layout interno ----------------------------------------------------------- */

.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.page-intro {
  margin-bottom: 16px;
}

.page-intro-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.page-intro-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 2px;
}

.btn-menu {
  width: auto;
  min-width: 42px;
  padding-inline: 12px;
  font-size: 1.25rem;
  line-height: 1;
}

.menu-dropdown {
  position: relative;
}

.menu-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.18));
  z-index: 30;
}

.menu-dropdown-label {
  padding: 4px 14px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.menu-dropdown-item {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}

.menu-dropdown-item:hover {
  background: var(--surface-2);
}

.page-intro-head .btn-new-entry {
  flex-shrink: 0;
  margin-top: 0;
  white-space: nowrap;
}

.entry-form-panel {
  scroll-margin-top: 72px;
}

@media (max-width: 640px) {
  .page-intro-head {
    flex-wrap: wrap;
  }

  .page-intro-actions {
    width: 100%;
    justify-content: stretch;
  }

  .page-intro-actions .btn-new-entry {
    flex: 1;
  }

  .menu-dropdown-panel {
    left: 0;
    right: auto;
  }
}

.page-intro h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Toggle de tema ----------------------------------------------------------- */

.auth-theme {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  background: var(--surface-muted);
  color: var(--primary);
  border-color: var(--border-strong);
  opacity: 1;
}

.theme-toggle:active {
  transform: none;
}

.theme-icon {
  display: block;
  pointer-events: none;
}

.theme-icon-sun { display: none; }

[data-theme="dark"] .theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: block; }

/* Topbar ------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.topbar-inner {
  max-width: calc(var(--content-width) + 32px);
  margin: 0 auto;
  padding: 0 16px;
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  height: 28px;
  width: auto;
}

.brand-logo-lg {
  height: 44px;
  margin: 0 auto 12px;
}

.brand-logo-mei,
.brand-logo-dei {
  transition: fill 0.2s ease;
}

.brand-logo-mei {
  fill: var(--danger);
}

.brand-logo-dei {
  fill: var(--success);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--brand-accent) 100%);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.logout-form { display: inline; margin-left: 4px; }

.topbar-logout {
  width: auto;
  padding: 7px 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  box-shadow: none;
}

.topbar-logout:hover {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
  opacity: 1;
}

/* Cards -------------------------------------------------------------------- */

.card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card-lead { margin: 0; }

.card-hero {
  background: var(--card-hero-bg);
  border-color: var(--border);
}

.card-hero .big-number {
  font-size: 2rem;
  letter-spacing: -0.03em;
  margin: 4px 0 0;
}

/* Tipografia utilitária ---------------------------------------------------- */

h1 { margin: 0; }

.muted {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.big-number {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.positive { color: var(--success); }
.negative { color: var(--danger); }

/* Semáforo de saúde -------------------------------------------------------- */

.health {
  border-left: 4px solid var(--border-strong);
  background: var(--surface-muted);
}

.health-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: none;
  box-shadow: 0 0 0 3px var(--health-dot-neutral);
}

.health-green {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.health-green .health-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--health-dot-success);
}

.health-yellow {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.health-yellow .health-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--health-dot-warning);
}

.health-red {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.health-red .health-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--health-dot-danger);
}

.insights {
  margin: 0;
  padding-left: 18px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.insights li { margin-bottom: 8px; }
.insights li:last-child { margin-bottom: 0; }

.steps {
  margin: 0 0 20px;
  padding-left: 20px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.steps li { margin-bottom: 10px; }

/* Resumo e estatísticas ---------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.stat {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 2px;
  text-align:center;
}

.projection {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  text-align:center;
}

.summary-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.summary-split > div {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2px;
  text-align:right;
}

/* Tags --------------------------------------------------------------------- */

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  vertical-align: middle;
}

.tag-late {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.tag-today {
  background: var(--warning-soft);
  color: var(--tag-warning-text);
  border-color: var(--tag-warning-border);
}

.tag-estimated {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--tag-estimated-border);
}

/* Gráfico ------------------------------------------------------------------ */

.chart-wrap {
  overflow-x: auto;
  margin: 4px -4px 0;
  padding: 4px;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  min-width: 440px;
}

.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-baseline { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--text-muted); font-size: 11px; font-family: 'Inter', sans-serif; }
.chart-month { fill: var(--text-secondary); font-size: 11px; font-family: 'Inter', sans-serif; }
.chart-month-current { fill: var(--text); font-weight: 600; }
.chart-hint { fill: var(--text-muted); font-size: 10px; font-family: 'Inter', sans-serif; }

.chart-bar-income { fill: var(--success); }
.chart-bar-expense { fill: var(--danger); }
.chart-bar-settled { fill-opacity: 1; }
.chart-bar-forecast { fill-opacity: 0.35; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.swatch-income { background: var(--success); }
.swatch-expense { background: var(--danger); }
.swatch-forecast { background: var(--success); opacity: 0.35; }

/* Formulários -------------------------------------------------------------- */

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder { color: var(--placeholder); }

input:hover, select:hover {
  border-color: var(--border-strong);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-row > div { min-width: 0; }

label.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 6px;
  cursor: pointer;
}

label.checkbox input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* Botões ------------------------------------------------------------------- */

button, .btn {
  width: 100%;
  padding: 12px 12px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: var(--btn-primary-shadow);
}

button:hover, .btn:hover {
  background: var(--primary-hover);
  opacity: 1;
}

button:active, .btn:active {
  transform: translateY(1px);
}

.btn-income {
  background: var(--success);
  box-shadow: var(--btn-success-shadow);
}

.btn-income:hover { background: var(--success-hover); }

.btn-expense {
  background: var(--danger);
  box-shadow: var(--btn-danger-shadow);
}

.btn-expense:hover { background: var(--danger-hover); }

.btn-ghost {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-ghost:hover {
  background: var(--primary-soft);
  border-color: var(--ghost-hover-border);
}

.btn-small {
  width: auto;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-small:hover {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.entry-type-hint {
  margin: 6px 0 0;
  font-size: 0.76rem;
}

.entry-type-tabs .entry-type-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.entry-type-tabs .entry-type-btn:disabled:hover {
  opacity: 0.32;
}

.entry-type-tabs .entry-type-btn.is-active:not(:disabled) {
  outline: 2px solid var(--surface);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 28%, transparent);
}

.actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.actions .btn { flex: 1 1 160px; }

/* Avisos ------------------------------------------------------------------- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin-bottom: 14px;
  border: 1px solid transparent;
  line-height: 1.45;
}

.alert-error {
  color: var(--alert-error-text);
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.alert-success {
  color: var(--alert-success-text);
  background: var(--success-soft);
  border-color: rgba(52, 211, 153, 0.35);
}

[data-theme="light"] .alert-success {
  border-color: #bbf7d0;
}

.alert-info {
  color: var(--alert-info-text);
  background: var(--info-soft);
  border-color: rgba(96, 165, 250, 0.35);
}

[data-theme="light"] .alert-info {
  border-color: #bfdbfe;
}

/* Listas de lançamentos ---------------------------------------------------- */

.entries { list-style: none; margin: 0; padding: 0; }

.entry {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.entry:first-child { padding-top: 4px; }
.entry:last-child { border-bottom: none; padding-bottom: 4px; }

.entry-muted { opacity: 0.55; }
.entry-main { min-width: 0; flex: 1; }

.entry-desc {
  font-weight: 600;
  font-size: 0.92rem;
  word-break: break-word;
  color: var(--text);
}

.entry-meta {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 4px;
  line-height: 1.4;
}

.entry-amount {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 8px;
}

.entry-block {
  display: block;
  padding: 16px 0;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.entry-group {
  list-style: none;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 16px 0 4px;
}

.next-dates { margin-top: 8px; }

.pay-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.input-inline {
  width: 92px;
  margin-bottom: 0;
  padding: 6px 10px;
  font-size: 0.82rem;
  text-align: right;
}

/* Blocos expansíveis ------------------------------------------------------- */

details { margin-bottom: 12px; }

details > summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--primary);
  padding: 8px 0;
  list-style: none;
  user-select: none;
}

details > summary::-webkit-details-marker { display: none; }

details > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

.repeat-options {
  padding: 16px;
  margin-bottom: 14px;
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.repeat-options[hidden] {
  display: none;
}

#occurrences-field[hidden] {
  display: none;
}

.series-edit > form,
.series-cancel > form {
  padding: 16px;
  margin-top: 6px;
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.series-edit, .series-cancel { margin: 10px 0 0; }

.series-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.series-item {
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.series-item:last-child {
  border-bottom: none;
}

.series-item > summary.series-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  font-weight: 600;
  color: var(--text);
}

.series-item > summary.series-summary::before {
  color: var(--text-muted);
  flex-shrink: 0;
}

.series-summary-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.series-summary-name {
  font-size: 0.95rem;
}

.series-summary-meta {
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.series-summary-amount {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.series-body {
  padding: 0 0 14px 18px;
}

.series-body > .entry-meta:first-child {
  margin-top: 0;
}
.series-cancel > summary { color: var(--danger); }

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* Plano de contas ---------------------------------------------------------- */

.account-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.account-row input { margin-bottom: 0; }
.account-new { margin-top: 14px; }

/* Navegação de mês --------------------------------------------------------- */

.month-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-xs);
}

.month-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  transition: background 0.15s, color 0.15s;
}

.month-nav a:hover {
  background: var(--surface-muted);
  color: var(--primary);
}

.month-nav-disabled {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  opacity: 0.45;
  cursor: default;
  user-select: none;
}

.month-nav strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

/* Responsivo --------------------------------------------------------------- */

@media (max-width: 640px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    min-height: auto;
    gap: 5px;
  }

  .topbar-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .topbar-nav::-webkit-scrollbar { display: none; }

  .field-row {
    grid-template-columns: 1fr;
  }

  .summary-split {
    grid-template-columns: 1fr;
  }

  .card-hero .big-number {
    font-size: 1.75rem;
  }

  .entry {
    flex-direction: column;
    align-items: stretch;
  }

  .entry-amount {
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
  }

  .entry-actions {
    justify-content: flex-start;
  }
}

@media (min-width: 641px) {
  .content { padding: 24px 20px 48px; }
  .card { padding: 22px 24px; }
}

/* Planilha editável (padrão de relatórios) --------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.table-scroll {
  overflow-x: auto;
  margin: 4px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.data-table thead {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 3px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table td {
  padding: 3px;
  font-size: 0.72rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-muted);
}

.col-date { width: 86px; text-align: center; }
.col-desc { min-width: 180px; }
.col-amount { width: 110px; text-align: right; }
.col-actions { width: 108px; text-align: center; }

.data-table .col-amount,
.data-table td.cell-amount {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cell-date {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cell-desc-block {
  vertical-align: middle;
}

.cell-desc-title {
  font-weight: 500;
  line-height: 1.35;
}

.cell-desc-category {
  margin-top: 2px;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.cell-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 20px !important;
}

.cell-editable {
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s;
}

.cell-editable:hover {
  background: var(--primary-soft);
}

.cell-editable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.cell-editing {
  padding: 4px 6px !important;
  background: var(--surface) !important;
}

.cell-editing .cell-input {
  width: 100%;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
}

.cell-saving {
  opacity: 0.55;
}

.cell-amount-forecast.positive,
.cell-amount-forecast.negative {
  opacity: 0.42;
}

.data-table-total.has-forecast .total-net-cell,
.data-table-total.has-forecast .total-parts-main {
  opacity: 0.65;
}

.cancel-series-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  background: var(--surface);
  color: var(--text);
}

.pay-entry-dialog,
.receipt-upload-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0;
  max-width: 440px;
  width: calc(100% - 32px);
  background: var(--surface);
  color: var(--text);
}

.cancel-series-dialog::backdrop,
.pay-entry-dialog::backdrop,
.receipt-upload-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.cancel-series-form,
.pay-entry-form,
.receipt-upload-form {
  padding: 22px 24px;
}

.cancel-series-form h3,
.pay-entry-form h3,
.receipt-upload-form h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.pay-entry-form label,
.receipt-upload-form label {
  display: block;
  margin-top: 12px;
}

.pay-entry-form input[type="date"],
.pay-entry-form input[type="text"],
.pay-entry-form input[type="file"],
.receipt-upload-form input[type="file"] {
  width: 100%;
  margin-top: 4px;
}


.mei-limit-card {
  margin-top: 0;
}

.mei-limit-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.mei-limit-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.mei-limit-percent {
  font-weight: 600;
  color: var(--muted);
}

.mei-limit-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.mei-limit-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width 0.25s ease;
}

.mei-limit-watch .mei-limit-fill {
  background: var(--warning, #d97706);
}

.mei-limit-danger .mei-limit-fill {
  background: var(--danger);
}

.mei-limit-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
  font-size: 0.95rem;
}

.mei-limit-note {
  margin: 10px 0 0;
}

.card-alert-hint .btn {
  width: auto;
  margin-top: 8px;
}

/* Alertas in-app ----------------------------------------------------------- */

.nav-link-alerts {
  position: relative;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.alert-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.alert-card-head h2 {
  margin: 0;
}

.alert-ack-all-form {
  margin: 0;
}

.alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.alert-item-body {
  flex: 1;
  min-width: 0;
}

.alert-item-title {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.alert-item-message {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--muted);
}

.alert-item-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.alert-ack-form {
  flex-shrink: 0;
  margin: 0;
}

.btn-alert-ok {
  min-width: 44px;
}

.alert-severity-danger {
  border-left: 3px solid var(--danger);
}

.alert-severity-warning {
  border-left: 3px solid var(--warning, #d97706);
}

.alert-severity-info {
  border-left: 3px solid var(--primary);
}

.card-alerts .alert-page-link {
  margin-top: 12px;
  width: auto;
}

.alert-more-link {
  font-size: 0.78rem;
  font-weight: 600;
}

.template-preview {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
}

.preview-details {
  font-size: 0.88rem;
  line-height: 1.45;
}

.alerts-form .btn {
  width: auto;
  margin-top: 12px;
}

.cell-desc-nf {
  font-size: 0.82rem;
  margin-top: 2px;
}

.cell-editable.cell-doc-signal {
  box-shadow: 0 0 0 2px var(--warning-soft), inset 0 0 0 1px var(--warning);
  border-radius: 4px;
  padding: 1px 5px;
  display: inline-block;
}

.icon-btn-signal {
  border: 2px solid var(--warning);
  box-shadow: 0 0 0 2px var(--warning-soft);
  color: var(--warning);
}

.icon-btn-signal:hover {
  border-color: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
  color: var(--warning);
  background: var(--warning-soft);
}

.icon-btn-receipt {
  color: var(--muted);
  text-decoration: none;
}

.icon-btn-receipt:hover {
  color: var(--primary);
}

.icon-btn-receipt-replace {
  color: var(--muted);
}

.icon-btn-receipt-replace:hover {
  color: var(--primary);
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.dialog-actions .btn,
.dialog-actions .btn-expense {
  width: auto;
}

.icon-btn-cut:hover {
  color: var(--danger);
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
}

.data-table tfoot {
  border-top: 2px solid var(--border);
  background: var(--surface-muted);
}

.data-table-total td {
  padding: 10px 12px;
  vertical-align: middle;
}

.cell-total-label {
  line-height: 1.4;
}

.cell-total-label strong {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.total-parts {
  display: block;
  font-size: 0.78rem;
  margin-top: 2px;
}

.data-table-forecast td {
  border-top: 1px dashed var(--border);
}

.account-table .col-desc {
  min-width: 200px;
}

.account-table .col-actions {
  width: 72px;
}

.account-bar-legend {
  margin-top: 8px;
  font-size: 0.78rem;
}

.account-table .cell-account-name {
  position: relative;
  overflow: hidden;
}

.account-bar-track {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.account-bar-fill {
  display: flex;
  height: 100%;
  min-width: 0;
}

.account-bar-paid,
.account-bar-pending {
  height: 100%;
  min-width: 0;
}

.account-bar-income .account-bar-paid {
  background: var(--success);
}

.account-bar-income .account-bar-pending {
  background: var(--success);
  opacity: 0.35;
}

.account-bar-expense .account-bar-paid {
  background: var(--danger);
}

.account-bar-expense .account-bar-pending {
  background: var(--danger);
  opacity: 0.35;
}

.cell-account-label {
  position: relative;
  z-index: 1;
  display: block;
}

.data-row.row-muted .cell-account-name {
  opacity: 0.55;
}

.account-table .cell-account-name.cell-editable:hover {
  background: color-mix(in srgb, var(--primary-soft) 55%, transparent);
}

.icon-btn-toggle:hover {
  color: var(--primary);
}

.action-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

.icon-form {
  display: inline;
  margin: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.icon-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border-strong);
  opacity: 1;
}

.icon-btn:active {
  transform: none;
}

.icon-btn-check:hover {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.35);
}

.icon-btn-danger:hover,
.icon-btn.icon-btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.data-table .tag {
  margin-left: 6px;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }

}

/* Transição suave ao trocar o tema ----------------------------------------- */

html[data-theme] body,
html[data-theme] .topbar,
html[data-theme] .card,
html[data-theme] .container,
html[data-theme] .stat,
html[data-theme] .summary-split > div,
html[data-theme] .month-nav,
html[data-theme] input,
html[data-theme] select,
html[data-theme] .theme-toggle,
html[data-theme] .btn-small,
html[data-theme] .brand-logo-mei,
html[data-theme] .brand-logo-dei {
  transition:
    background-color 0.2s ease,
    color 0.15s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
