:root {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #1a2336;
  --bg-elevated: #1e293b;
  --bg-input: #0f172a;
  --border-color: #1f2937;
  --border-light: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --rose: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.12);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.14);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.12);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.14);

  --bradesco: #cc092f;
  --santander: #ec0000;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-elevated: #e2e8f0;
  --bg-input: #f8fafc;
  --border-color: #cbd5e1;
  --border-light: #94a3b8;
  --text-primary: #0f172a;
  --text-secondary: #1e293b;
  --text-muted: #475569;
  --emerald: #059669;
  --emerald-bg: rgba(5, 150, 105, 0.14);
  --rose: #e11d48;
  --rose-bg: rgba(225, 29, 72, 0.14);
  --amber: #d97706;
  --amber-bg: rgba(217, 119, 6, 0.15);
  --blue: #2563eb;
  --blue-bg: rgba(37, 99, 235, 0.14);
  --purple: #7c3aed;
  --purple-bg: rgba(124, 58, 237, 0.14);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT SHELL ─────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 256px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  padding: 1.25rem 0.9rem;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-title span {
  color: var(--emerald);
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: block;
  font-weight: 500;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.72rem 0.85rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.nav-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-btn.active {
  background: var(--emerald-bg);
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.28);
}

.nav-btn .nav-icon {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.7rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
}

.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sync-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.76rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

.sync-dot.online {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

/* ── MAIN CONTENT AREA ────────────────────────────────────── */
.main-area {
  flex: 1;
  margin-left: 256px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: 4rem;
}

/* ── TOP HEADER BAR ───────────────────────────────────────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

[data-theme="light"] .top-bar {
  background: rgba(255, 255, 255, 0.88);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.month-selector {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.2rem;
}

.month-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.month-nav-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.month-current-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0 0.5rem;
  cursor: pointer;
  outline: none;
}

.filter-select {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.52rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
}

.btn-danger {
  background: var(--rose-bg);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--rose);
}

.btn-danger:hover {
  background: var(--rose);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* ── PAGE SECTIONS ────────────────────────────────────────── */
.view-section {
  display: none;
  padding: 1.5rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}

.view-section.active {
  display: block;
}

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

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── INSIGHTS BANNER ──────────────────────────────────────── */
.insights-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.35rem;
}

.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.insight-card.warn {
  border-left-color: var(--amber);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.07) 0%, var(--bg-card) 100%);
}

.insight-card.danger {
  border-left-color: var(--rose);
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.08) 0%, var(--bg-card) 100%);
}

.insight-card.good {
  border-left-color: var(--emerald);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.07) 0%, var(--bg-card) 100%);
}

.insight-icon {
  font-size: 1.3rem;
  line-height: 1.2;
}

.insight-body h4 {
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.insight-body p {
  font-size: 0.79rem;
  color: var(--text-secondary);
}

/* ── KPI CARDS ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  position: relative;
  overflow: hidden;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}

.kpi-value {
  font-size: 1.48rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.kpi-foot {
  font-size: 0.76rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ── BANK & CREDIT CARD STRIP ─────────────────────────────── */
.accounts-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.bank-card {
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 148px;
}

.bank-card.bradesco {
  background: linear-gradient(135deg, #990622 0%, #cc092f 55%, #e11d48 100%);
}

.bank-card.santander {
  background: linear-gradient(135deg, #990000 0%, #dc2626 60%, #ef4444 100%);
}


.bank-card.itau {
  background: linear-gradient(135deg, #c2410c 0%, #ea580c 55%, #f97316 100%);
}
.bank-card.nubank {
  background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 55%, #8b5cf6 100%);
}
.bank-card.inter {
  background: linear-gradient(135deg, #b45309 0%, #d97706 55%, #f59e0b 100%);
}
.bank-card.bb {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 55%, #2563eb 100%);
}
.bank-card.caixa {
  background: linear-gradient(135deg, #0c4a6e 0%, #0284c7 55%, #0ea5e9 100%);
}

.bank-card.credit-bradesco {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 55%, #831843 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.bank-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.bank-name {
  font-weight: 800;
  font-size: 0.96rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.bank-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
}

.bank-balance-label {
  font-size: 0.74rem;
  opacity: 0.85;
  margin-top: 0.65rem;
}

.bank-balance-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.bank-card-footer {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  opacity: 0.92;
}

/* ── CHARTS & PANELS GRID ─────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.15rem;
  margin-bottom: 1.35rem;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
}

.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-12 { grid-column: span 12; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel-title {
  font-size: 0.96rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.chart-container {
  position: relative;
  height: 270px;
  width: 100%;
}

/* ── CATEGORY RANKING LIST ────────────────────────────────── */
.cat-rank-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.cat-rank-item {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.cat-rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}

.cat-rank-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.progress-track {
  width: 100%;
  height: 7px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ── TABLES & TRANSACTIONS ────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  padding: 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.search-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
}

.search-input:focus, .form-control:focus {
  border-color: var(--emerald);
}

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th {
  text-align: left;
  padding: 0.8rem 1rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.4);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-expense { background: var(--rose-bg); color: var(--rose); }
.badge-income { background: var(--emerald-bg); color: var(--emerald); }
.badge-transfer { background: var(--blue-bg); color: var(--blue); }
.badge-member { background: var(--purple-bg); color: var(--purple); }
.badge-account { background: var(--bg-elevated); color: var(--text-primary); }

.amount-pos { color: var(--emerald); font-weight: 700; }
.amount-neg { color: var(--rose); font-weight: 700; }
.amount-neutral { color: var(--blue); font-weight: 700; }

/* ── IMPORT DROPZONE ──────────────────────────────────────── */
.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.25rem;
}

.dropzone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--emerald);
  background: var(--emerald-bg);
}

.dropzone-icon {
  font-size: 2.4rem;
  margin-bottom: 0.6rem;
}

/* ── BUDGET / PLANNING CARDS ──────────────────────────────── */
.budget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.budget-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ── FORMS & MODALS ───────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.78);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.4rem;
  box-shadow: var(--shadow-lg);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.58rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  outline: none;
  width: 100%;
}

/* ── FLOATING ACTION BUTTON & MOBILE NAV ──────────────────── */
.fab-add {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  font-size: 1.65rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.45);
  cursor: pointer;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
}

.fab-add:hover {
  transform: scale(1.07);
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  z-index: 55;
  padding: 0.35rem 0.25rem;
  justify-content: space-around;
}

.mob-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.66rem;
  font-weight: 600;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.mob-nav-btn.active {
  color: var(--emerald);
}

.mob-nav-btn span.icon {
  font-size: 1.15rem;
}

/* ── TOAST NOTIFICATION ───────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid var(--emerald);
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.2s ease;
}

/* ── RESPONSIVE BREAKPOINTS ───────────────────────────────── */
@media (max-width: 1024px) {
  .col-8, .col-6, .col-4 {
    grid-column: span 12;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main-area {
    margin-left: 0;
    padding-bottom: 5.5rem;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .fab-add {
    bottom: 4.5rem;
    right: 1rem;
  }
  .top-bar {
    padding: 0.7rem 1rem;
  }
  .view-section {
    padding: 1rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}


/* ── INTERACTIVE CATEGORY RANKING & DASHBOARD FILTERS ──── */
.cat-rank-item {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.cat-rank-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
}

.cat-rank-item.rank-active {
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--emerald);
}

.dash-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--emerald);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--emerald);
  font-weight: 600;
}

.dash-chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}

/* ── CENTRAL DE RELATÓRIOS INTELIGENTES ─────────────────── */
.modal-card.modal-lg {
  max-width: 920px;
}

.report-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.report-preset-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.report-preset-card:hover {
  border-color: var(--emerald);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.report-preset-card.active {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 0 1px var(--emerald);
}

.preset-icon {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.preset-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.preset-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}


/* ── OTIMIZAÇÕES NATIVAS MOBILE (ANDROID & iOS / iPHONE) ────── */
.mobile-header-row {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.55rem;
  margin-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-color);
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.mobile-brand-title {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.1;
  color: var(--text-primary);
}

.mobile-brand-title span {
  color: var(--emerald);
}

.mobile-brand-sub {
  font-size: 0.68rem;
  color: var(--emerald);
  font-weight: 600;
}

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

html, body {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

@media (max-width: 768px) {
  .mobile-header-row {
    display: flex;
  }

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 0.85rem 0.65rem 0.85rem;
  }

  .top-bar-left {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    width: 100%;
  }

  .top-bar-left .filter-select,
  .top-bar-left .month-selector {
    width: 100%;
    font-size: 0.78rem;
    padding: 0.42rem 0.55rem;
  }

  .top-bar-right {
    display: none;
  }

  .main-area {
    padding-bottom: calc(5.8rem + env(safe-area-inset-bottom, 0px));
  }

  .mobile-bottom-nav {
    display: flex;
    padding: 0.35rem 0.15rem calc(0.35rem + env(safe-area-inset-bottom, 0px)) 0.15rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .mob-nav-btn {
    flex: 1;
    min-width: 0;
    font-size: 0.62rem;
    padding: 0.28rem 0.15rem;
  }

  .fab-add {
    bottom: calc(4.8rem + env(safe-area-inset-bottom, 0px));
    right: 1rem;
    width: 54px;
    height: 54px;
  }

  /* Evita zoom automático do Safari no iOS ao focar em inputs */
  .form-control,
  .search-input,
  .filter-select,
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="month"],
  input[type="url"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Modais estilo Bottom-Sheet nativo no celular */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    padding: 1.15rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px)) 1rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .kpi-value {
    font-size: 1.18rem;
  }

  .bank-cards-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 768px) {
  #chart-cashflow {
    min-height: 320px !important;
  }
}


/* ── RESPONSIVIDADE COMPLETA MOBILE (ALINHAMENTO, BOTÕES E TEXTOS) ── */
.mobile-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
}

.mobile-quick-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  width: 100%;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border-color);
}

.mobile-quick-bar .btn {
  width: 100%;
  padding: 0.4rem 0.25rem;
  font-size: 0.74rem;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    overflow-y: auto;
    max-width: 100vw;
    height: auto;
    min-height: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .main-area {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    overflow: visible;
    height: auto;
    min-height: 100vh;
    padding-bottom: 5.5rem;
  }

  .view-section {
    max-width: 100%;
    overflow: visible;
    height: auto;
  }

  .panel {
    max-width: 100%;
    overflow: visible;
  }

  .mobile-header-row {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.35rem;
  }

  .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
  }

  .mobile-header-actions .btn {
    padding: 0.34rem 0.52rem;
    font-size: 0.74rem;
  }

  /* Filtros superiores alinhados em 2 colunas sem estourar */
  .top-bar-left {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.4rem;
    width: 100%;
  }

  #global-period-type {
    grid-column: 1 / -1;
  }

  #month-selector-box {
    grid-column: 1 / -1;
    justify-content: space-between;
    width: 100%;
  }

  .top-bar-left .filter-select {
    width: 100%;
    min-width: 0;
    font-size: 0.78rem !important;
    padding: 0.42rem 0.5rem;
    text-overflow: ellipsis;
  }

  /* Títulos e cabeçalhos de seção responsivos */
  .section-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.65rem;
    margin-bottom: 1rem;
  }

  .section-title {
    font-size: 1.12rem;
    line-height: 1.25;
    word-break: break-word;
  }

  .section-subtitle {
    font-size: 0.78rem;
    line-height: 1.35;
    word-break: break-word;
  }

  /* Alinha os botões de ação do cabeçalho em grade uniforme no celular */
  .section-header > div:last-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.45rem !important;
    width: 100%;
  }

  .section-header > div:last-child > .btn {
    flex: 1 1 calc(50% - 0.45rem);
    min-width: 135px;
    justify-content: center;
    text-align: center;
    white-space: normal !important;
    line-height: 1.2;
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
  }

  /* Permite que qualquer botão com texto longo quebre linha sem extrapolar a tela */
  .btn {
    white-space: normal;
    word-break: break-word;
    text-align: center;
    line-height: 1.25;
    max-width: 100%;
  }

  /* Painéis e cabeçalhos internos */
  .panel {
    padding: 0.9rem;
    border-radius: var(--radius-md);
  }

  .panel-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .panel-title {
    font-size: 0.9rem;
    line-height: 1.3;
    word-break: break-word;
  }

  /* KPIs: 1º Card (Saldo Consolidado) em linha inteira + demais em grade 2x2 */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem !important;
  }

  #view-dashboard > .kpi-grid > .kpi-card:first-child,
  #planning-summary-kpis > .kpi-card:first-child {
    grid-column: 1 / -1;
  }

  .kpi-card {
    padding: 0.85rem 0.9rem;
    min-width: 0;
  }

  .kpi-label {
    font-size: 0.7rem;
    line-height: 1.2;
    word-break: break-word;
  }

  .kpi-value {
    font-size: 1.15rem !important;
    word-break: break-word;
  }

  .kpi-foot {
    font-size: 0.71rem;
    line-height: 1.3;
    flex-wrap: wrap;
    word-break: break-word;
  }

  /* Cards de Contas e Cartões 100% encaixados na tela */
  .accounts-strip,
  .import-grid,
  .budget-grid,
  .insights-strip,
  .report-presets-grid,
  #categories-manager-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .bank-card {
    padding: 0.95rem 1rem;
    min-height: auto;
  }

  .bank-card-header {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .bank-name {
    font-size: 0.88rem;
  }

  .bank-balance-value {
    font-size: 1.28rem;
  }

  .bank-card-footer {
    flex-wrap: wrap !important;
    gap: 0.35rem 0.65rem !important;
    font-size: 0.72rem;
  }

  /* Ranking de Categorias sem cortar valores ou metas */
  .cat-rank-row {
    flex-wrap: wrap;
    gap: 0.2rem 0.5rem;
    font-size: 0.78rem;
  }

  /* Barra de filtros da aba Lançamentos e Regras */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .filters-bar .search-input,
  .filters-bar .filter-select,
  .filters-bar .btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Gráficos responsivos no mobile */
  #chart-cashflow {
    min-height: 310px !important;
  }

  #chart-categories {
    min-height: 340px !important;
  }
}
