:root {
  color-scheme: light;
  --bg: #eef1f8;
  --bg-accent: #e1e8ff;
  --surface: #ffffff;
  --surface-alt: #f7f9ff;
  --text: #1a202c;
  --muted: #4a5568;
  --border: #e2e8f0;
  --primary: #4c6fff;
  --primary-hover: #3b5bdb;
  --danger: #e53e3e;
  --danger-hover: #c53030;
  --success: #2f855a;
  --warning: #718096;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
  --shadow-soft: 0 4px 18px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  margin: 0;
  padding: 32px 24px 48px;
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg) 40%, var(--bg-accent) 100%);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  text-align: left;
  align-items: flex-start;
}

.page-header-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title-shell {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-title-icon {
  font-size: 26px;
}

.page-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

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

.pwa-install {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  border: 1px solid rgba(76, 111, 255, 0.25);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.95) 0%, rgba(237, 242, 255, 0.9) 100%);
}

.pwa-install-text {
  flex: 1 1 320px;
  display: grid;
  gap: 6px;
}

.pwa-install-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pwa-install-hint {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.card-spacing {
  margin-bottom: 24px;
}

.auth-card {
  width: 100%;
  max-width: 100%;
  margin: 0;
  display: grid;
  gap: 12px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-card {
  padding: 20px 24px;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}

.filter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-header h3 {
  margin: 0;
  font-size: 16px;
}

.filter-body {
  margin-top: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
}

.filter-card.collapsed .filter-body {
  display: none;
}

.section-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.section-helper {
  margin: 0;
  color: var(--muted);
}

.font-bold {
  font-weight: 700;
}

.text-slate-800 {
  color: #1e293b;
}

.text-slate-500 {
  color: #64748b;
}

.mb-4 {
  margin-bottom: 16px;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.gap-2 {
  gap: 8px;
}

.gap-1 {
  gap: 4px;
}

.form-group {
  margin-bottom: 12px;
  position: relative;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 111, 255, 0.15);
  background: #ffffff;
}

.autocomplete {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  z-index: 10;
  padding: 0;
  margin: 0;
  list-style: none;
  display: none;
  box-shadow: var(--shadow-soft);
}

.autocomplete-list li {
  padding: 10px 12px;
  cursor: pointer;
}

.autocomplete-list li:hover {
  background-color: #edf2ff;
  color: var(--text);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
}

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

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 8px 16px rgba(76, 111, 255, 0.2);
}

.btn-logout {
  background: var(--danger);
  color: #fff;
  border: 1px solid rgba(229, 62, 62, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
}

.btn-logout svg {
  color: currentColor;
}

.btn-logout.btn-fab {
  font-size: 16px;
}

.btn-logout:hover {
  background: var(--danger-hover);
  border-color: rgba(197, 48, 48, 0.8);
  box-shadow: 0 8px 16px rgba(229, 62, 62, 0.22);
}

.btn-cancel {
  background: var(--warning);
  color: white;
}

.btn-cancel:hover {
  background: #4a5568;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 14px;
}

.btn-ghost:hover {
  background: #edf2ff;
  color: var(--text);
}

.fab-stack {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.btn-fab {
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  line-height: 1;
  z-index: 1;
}

.btn-fab-icon {
  font-size: 22px;
  line-height: 1;
}

.form-buttons {
  display: flex;
  gap: 12px;
}

.form-buttons button {
  flex: 1;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 16px;
}

.header-title h2 {
  margin: 0;
  font-size: 20px;
}

.header-title .subtitle {
  margin-top: 4px;
}

@media (max-width: 640px) {
  .app-header {
    align-items: stretch;
  }

  .page-header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .header-title {
    width: 100%;
  }

  .fab-stack {
    position: fixed;
    right: 16px;
    bottom: 16px;
    flex-direction: column;
    align-items: flex-end;
    z-index: 30;
  }

  .btn-fab {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    font-size: 28px;
  }

  .btn-fab-label {
    display: none;
  }

  .btn-logout.btn-fab {
    padding: 0;
    font-size: 18px;
  }
}

.investimento-list {
  display: grid;
  gap: 16px;
}

#lista {
  gap: 16px;
}

.investimento-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.investimento-list-header h3 {
  margin: 0;
}

.investimento-resumo {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

#lista-conteudo {
  display: grid;
  gap: 16px;
  margin-top: 0;
}

.investimento-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 12px;
  position: relative;
}

.investimento-main {
  display: grid;
  gap: 16px;
}

.investimento-info {
  display: grid;
  gap: 12px;
}

.investimento-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.investimento-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.investimento-subtitle {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.investimento-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.investimento-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge.neutral {
  background: #edf2ff;
  color: var(--muted);
}

.investimento-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 16px;
}

.investimento-meta .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

.investimento-meta .value {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.investimento-acoes {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-self: stretch;
  flex-wrap: nowrap;
  align-items: center;
  width: 100%;
}

.investimento-acoes button {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
  border-radius: 999px;
}

.investimento-acoes .btn-editar {
  background: #38a169;
  color: white;
}

.investimento-acoes .btn-editar:hover {
  background: #2f855a;
}

.investimento-acoes .btn-excluir {
  background: #e53e3e;
  color: white;
}

.investimento-acoes .btn-excluir:hover {
  background: #c53030;
}

.error {
  color: var(--danger);
  margin-top: 8px;
}

.success {
  color: var(--success);
  margin-top: 8px;
}

.error,
.success {
  font-weight: 600;
}

.info {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  margin-top: 12px;
}

.hidden {
  display: none;
}

.radio-inline {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 4px;

}

.radio-inline label {
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 4px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 32px 24px;
  text-align: center;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.empty-state span {
  font-size: 28px;
}

.empty-state p {
  margin: 0;
  font-weight: 600;
}

.empty-state small {
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #edf2ff;
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
}

.small-btn {
  width: auto;
  padding: 10px 16px;
  font-size: 14px;
}

.totais-grid {
  display: grid;
  gap: 20px;
  align-items: stretch;
  margin: 20px 0;
}

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

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

.totais-card-hero {
  background: linear-gradient(135deg, rgba(76, 111, 255, 0.18) 0%, rgba(76, 111, 255, 0.08) 100%);
  color: var(--text);
  border: 1px solid rgba(76, 111, 255, 0.25);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.totais-card-hero::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 200px;
  height: 200px;
  background: rgba(76, 111, 255, 0.2);
  border-radius: 50%;
  filter: blur(4px);
}

.totais-hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.totais-hero-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 6px;
}

.totais-hero-value {
  margin: 0;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
}

.totais-card-hero .btn-ghost {
  border-color: rgba(76, 111, 255, 0.4);
  color: var(--primary);
  background: rgba(76, 111, 255, 0.1);
}

.totais-card-hero .btn-ghost:hover {
  background: rgba(76, 111, 255, 0.2);
  color: var(--primary);
}

.totais-hero-footer {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  position: relative;
  z-index: 1;
}

.totais-hero-footer span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 6px;
}

.totais-hero-footer strong {
  font-size: 18px;
}

.totais-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.totais-card h3.mb-4 {
  margin-bottom: 16px;
}

.totais-resumo {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.totais-concentracao {
  display: grid;
  gap: 12px;
}

.totais-concentracao-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(64px, max-content) minmax(96px, max-content);
  align-items: center;
  column-gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f4f6ff;
  border: 1px solid var(--border);
}

.totais-concentracao-item span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.totais-concentracao-item span::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--border);
}

.totais-concentracao-item.fixa span::before {
  background: var(--primary);
}

.totais-concentracao-item.variavel span::before {
  background: #38a169;
}

.totais-concentracao-item.diaria span::before {
  background: #0ea5e9;
}

.totais-concentracao-item.vencimento span::before {
  background: #f59e0b;
}

.totais-concentracao-item strong {
  font-size: 18px;
  text-align: right;
  white-space: nowrap;
}

.totais-concentracao-item small {
  color: var(--muted);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.totais-concentracao-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #edf2ff;
}

.totais-concentracao-fill {
  height: 100%;
}

.totais-concentracao-fill.fixa {
  background: var(--primary);
}

.totais-concentracao-fill.variavel {
  background: #38a169;
}

.totais-concentracao-fill.diaria {
  background: #0ea5e9;
}

.totais-concentracao-fill.vencimento {
  background: #f59e0b;
}

.totais-kpi {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #f4f6ff;
}

.totais-kpi span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.totais-kpi strong {
  font-size: 18px;
}

.totais-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.totais-table th,
.totais-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

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

.totais-table td:last-child,
.totais-table th:last-child {
  text-align: right;
}

.totais-table td:nth-child(2),
.totais-table th:nth-child(2) {
  text-align: center;
}

@media (min-width: 768px) {
  .investimento-main {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: flex-start;
  }

  .investimento-acoes {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    align-self: flex-start;
    width: auto;
  }

  .investimento-acoes button {
    min-width: 120px;
    width: auto;
    flex: 0 0 auto;
    padding: 8px 14px;
  }

  .totais-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }

  .totais-card-wide {
    grid-column: span 3;
  }
}

.toast-container {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 999;
}

.toast {
  min-width: 240px;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 4px;
  animation: slideIn 0.2s ease;
}

.toast strong {
  font-size: 14px;
}

.toast p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.info {
  border-left: 4px solid var(--primary);
}

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

@media (max-width: 640px) {
  body {
    padding: 24px 16px 32px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    width: 100%;
    max-width: none;
  }
}
