:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --positive: #16a34a;
  --negative: #dc2626;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  background: var(--card);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.auth-card h1 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.auth-card p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.auth-card input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.auth-card button {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.auth-card button:hover {
  background: var(--primary-dark);
}

.error {
  color: var(--negative);
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.app {
  min-height: 100vh;
}

.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  font-size: 1.25rem;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}

.main {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.filters {
  margin-bottom: 1.5rem;
}

.filters label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.filters select {
  margin-left: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.card-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }

.chart-section,
.transactions-section {
  background: var(--card);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chart-section h2,
.transactions-section h2 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

.category-chart {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.category-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.category-name {
  width: 120px;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-track {
  flex: 1;
  height: 24px;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
}

.category-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 12px;
  transition: width 0.5s ease;
}

.category-value {
  width: 90px;
  text-align: right;
  font-size: 0.875rem;
  font-weight: 500;
}

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

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

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 500;
}

tbody tr:hover {
  background: var(--bg);
}

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

  .category-name {
    width: 90px;
  }

  .category-value {
    width: 70px;
  }
}

.user-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-card input[type="email"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 1rem;
}

/* ===== Auth + Dashboard pages (login.html / dashboard.html) ===== */

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

a.btn-secondary {
  text-decoration: none;
  font-size: 0.875rem;
}

.text-muted {
  color: var(--text-muted);
}

/* Donut chart */
.donut-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.donut {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.donut-hole {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-total {
  font-weight: 600;
  font-size: 0.95rem;
}

.donut-caption {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.donut-legend {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.donut-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.donut-legend-pct {
  color: var(--text-muted);
  width: 48px;
  text-align: right;
}

.donut-legend-value {
  width: 100px;
  text-align: right;
  font-weight: 500;
}

/* Botão flutuante "+ Lançamento" */
.fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.fab:hover {
  background: var(--primary-dark);
}

@media (min-width: 640px) {
  .donut-wrapper {
    flex-direction: row;
    align-items: flex-start;
  }

  .donut-legend {
    flex: 1;
  }
}
