/* Personal Finance Dashboard V2 — Mobile-First Dark Premium */
:root {
  --bg-base: #0A0A0F;
  --bg-elevated: #111116;
  --bg-surface: #1a1a1f;
  --bg-hover: #22222a;
  --accent: #D4AF37;
  --accent-glow: rgba(212, 175, 55, 0.15);
  --accent-dim: rgba(212, 175, 55, 0.6);
  --text-primary: #FFFFFF;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;
  --success: #22C55E;
  --danger: #EF4444;
  --warning: #F59E0B;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --nubank: #8A05BE;
  --bradesco: #CC092F;
  --itau: #003882;
  --santander: #EC0000;
  --header-h: 52px;
  --tabbar-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

/* ── Layout ─────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

.header-logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.titular-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pill {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
  transition: all 0.15s;
}

.pill.active {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* ── Main Content ───────────────────────────────────────── */
.main {
  flex: 1;
  padding: calc(var(--header-h) + 12px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  overflow-y: auto;
}

/* ── Bottom Tab Bar ─────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 20;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  min-width: 56px;
  min-height: 44px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
}

.tab.active { color: var(--accent); }
.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { font-size: 10px; font-weight: 500; }

/* ── More Menu ──────────────────────────────────────────── */
.more-menu { position: fixed; inset: 0; z-index: 30; }
.more-menu.hidden { display: none; }

.more-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.more-menu-sheet {
  position: absolute;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 8px 0;
}

.more-item {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}

.more-item:hover { background: var(--bg-hover); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}

.card:hover { border-color: var(--border-hover); }

.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-value.gold { color: var(--accent); }
.card-value.success { color: var(--success); }
.card-value.danger { color: var(--danger); }

.card-sm { padding: 12px; }
.card-sm .card-value { font-size: 18px; }

/* ── Grid ───────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.grid-1 { margin-bottom: 12px; }

/* ── Bank Cards ─────────────────────────────────────────── */
.bank-card { position: relative; overflow: hidden; }

.bank-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 4px 0 0 4px;
}

.bank-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  padding-left: 12px;
}

.bank-balance {
  font-size: 18px;
  font-weight: 700;
  padding-left: 12px;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

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

.amount-inflow { color: var(--success); }
.amount-outflow { color: var(--danger); }

/* ── Badge ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--bg-surface);
  cursor: pointer;
  min-height: 28px;
}

.badge-bucket {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-necessidades { background: rgba(59,130,246,0.15); color: #60A5FA; }
.badge-desejos { background: rgba(236,72,153,0.15); color: #F472B6; }
.badge-investimentos { background: rgba(20,184,166,0.15); color: #2DD4BF; }

/* ── Filters ────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-input, .filter-select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  min-height: 44px;
}

.filter-input:focus, .filter-select:focus { border-color: var(--accent-dim); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}

.btn:hover { border-color: var(--accent-dim); }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { opacity: 0.9; }

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

/* ── Chart Container ────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

/* ── Health Score Gauge ─────────────────────────────────── */
.health-gauge {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 8px;
}

.health-gauge canvas { width: 100% !important; height: 100% !important; }

.health-gauge-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: 700;
}

.health-gauge-label {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* ── Progress Bar ───────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-surface);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

/* ── Status Badge ───────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.status-safe { background: rgba(34,197,94,0.15); color: var(--success); }
.status-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-danger { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ── Alert Card ─────────────────────────────────────────── */
.alert-card {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border-left: 3px solid var(--warning);
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Settings ───────────────────────────────────────────── */
.setting-group { margin-bottom: 16px; }

.setting-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.setting-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 16px;
  min-height: 44px;
}

.setting-input:focus { border-color: var(--accent-dim); outline: none; }

/* ── Sync Badge ─────────────────────────────────────────── */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.sync-dot.error { background: var(--danger); }

/* ── Banner ─────────────────────────────────────────────── */
.banner {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 12px;
  text-align: center;
}

/* ── View ───────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

.page-header { margin-bottom: 16px; }
.page-title { font-size: 20px; font-weight: 700; }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Loading ────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

/* ── Month Selector ─────────────────────────────────────── */
.month-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.month-selector button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.month-selector span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 120px;
  text-align: center;
}

/* ── Responsive (Desktop) ───────────────────────────────── */
@media (min-width: 768px) {
  .main { max-width: 600px; margin: 0 auto; }
  .grid-2 { gap: 16px; }
}
