/* ── TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --sidebar-bg: #090909;
  --sidebar-hover: #1a1a1a;
  --sidebar-active: #c8b89a;
  --sidebar-text: #999;
  --sidebar-text-active: #090909;

  --primary: #c8b89a;
  --primary-dark: #b0a080;
  --primary-light: #f4efe7;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --body-bg: #f4efe7;
  --card-bg: #ffffff;
  --border: #e5dfd5;
  --text: #1a1a1a;
  --muted: #7a7570;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
}

/* ── RESET / BASE ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  padding: 1.75rem;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1030;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.5rem 1.25rem 1.25rem;
  text-decoration: none;
  border-bottom: 1px solid #1f1f1f;
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #090909;
  flex-shrink: 0;
}
.sidebar-brand .brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}
.sidebar-brand .brand-sub {
  font-size: 0.65rem;
  color: var(--sidebar-text);
  line-height: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  list-style: none;
  margin: 0;
}

.sidebar-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #444;
  padding: 0.75rem 0.5rem 0.35rem;
  display: block;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all .15s ease;
  margin-bottom: 2px;
}
.sidebar-nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #d0c8b8;
}
.sidebar-nav a.active {
  background: var(--primary);
  color: #090909;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(200,184,154,.35);
}

.sidebar-footer {
  border-top: 1px solid #1f1f1f;
  padding: 1rem 1.25rem;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: #090909; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e0d8cc;
  line-height: 1.2;
}
.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--sidebar-text);
}
.btn-logout {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid #333;
  color: var(--sidebar-text);
  font-size: 0.78rem;
  cursor: pointer;
  width: 100%;
  transition: all .15s;
  text-decoration: none;
}
.btn-logout:hover {
  background: #1a1a1a;
  color: #e0d8cc;
  border-color: #444;
}

/* ── PAGE HEADER ─────────────────────────────────────────────────────────── */
.page-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.page-title i { color: var(--primary-dark); }

/* ── CARDS ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }

/* ── STAT CARDS ──────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.success { background: #d1fae5; color: var(--success); }
.stat-icon.danger  { background: #fee2e2; color: var(--danger); }
.stat-icon.info    { background: #dbeafe; color: var(--info); }
.stat-icon.primary { background: var(--primary-light); color: var(--primary-dark); }

.stat-label { font-size: 0.75rem; color: var(--muted); font-weight: 500; margin-bottom: 0.2rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.stat-value.success { color: var(--success); }
.stat-value.danger  { color: var(--danger); }
.stat-value.info    { color: var(--info); }
.stat-value.primary { color: var(--primary-dark); }

/* ── TABLES ──────────────────────────────────────────────────────────────── */
.table {
  font-size: 0.85rem;
  margin: 0;
}
.table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #faf7f3;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  white-space: nowrap;
}
.table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #f0ebe3;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #faf7f3; }

/* ── BADGES ──────────────────────────────────────────────────────────────── */
.badge {
  font-weight: 500;
  font-size: 0.7rem;
  padding: 0.3em 0.65em;
  border-radius: 0.35rem;
}
.badge-receita { background: #d1fae5; color: #065f46; }
.badge-despesa { background: #fee2e2; color: #991b1b; }
.badge-realizado { background: #dbeafe; color: #1e40af; }
.badge-previsto { background: #fef3c7; color: #92400e; }

/* ── FORMS ───────────────────────────────────────────────────────────────── */
.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  background-color: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(200,184,154,.2);
  outline: none;
}
.form-control::placeholder { color: #c0b8b0; }
.input-group-text {
  background: #faf7f3;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  transition: all .15s;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #090909;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #090909;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200,184,154,.45);
}
.btn-outline-secondary {
  border-color: var(--border);
  color: var(--muted);
}
.btn-outline-secondary:hover { background: #f4efe7; color: var(--text); }
.btn-outline-danger:hover { box-shadow: 0 2px 8px rgba(239,68,68,.25); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.btn-lg { padding: 0.65rem 1.5rem; font-size: 0.95rem; }

/* ── MODALS ──────────────────────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  background: #faf7f3;
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-title { font-size: 0.95rem; font-weight: 700; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 0.875rem 1.25rem;
  background: #faf7f3;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── TABS ────────────────────────────────────────────────────────────────── */
.nav-tabs {
  border-bottom: 2px solid var(--border);
  gap: 0.25rem;
}
.nav-tabs .nav-link {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.625rem 1rem;
  border-radius: 0;
  margin-bottom: -2px;
  transition: color .15s;
}
.nav-tabs .nav-link:hover { color: var(--primary-dark); background: none; }
.nav-tabs .nav-link.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
  background: none;
  font-weight: 600;
}

/* ── TOAST NOTIFICATIONS ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  min-width: 280px;
  max-width: 380px;
  font-size: 0.875rem;
  animation: toast-in .25s ease;
}
.toast-item.success { border-left-color: var(--success); }
.toast-item.danger  { border-left-color: var(--danger); }
.toast-item.warning { border-left-color: var(--warning); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-item.success .toast-icon { color: var(--success); }
.toast-item.danger  .toast-icon { color: var(--danger); }
.toast-item.warning .toast-icon { color: var(--warning); }
.toast-item.info    .toast-icon { color: var(--primary-dark); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(1rem); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── FLATPICKR OVERRIDES ─────────────────────────────────────────────────── */
.flatpickr-calendar {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border) !important;
  font-family: inherit !important;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #090909 !important;
}
.flatpickr-day:hover { background: var(--primary-light) !important; }
.flatpickr-months { background: #090909 !important; border-radius: var(--radius) var(--radius) 0 0 !important; }
.flatpickr-month { color: var(--primary) !important; }
.flatpickr-prev-month, .flatpickr-next-month { color: var(--primary) !important; fill: var(--primary) !important; }
.flatpickr-current-month { color: var(--primary) !important; }
.flatpickr-weekday { color: var(--muted) !important; font-weight: 600 !important; }

/* ── LOGIN PAGE ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: #090909;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--card-bg);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.6);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.login-header {
  background: #090909;
  padding: 2rem 2rem 1.5rem;
  text-align: center;
  border-bottom: 2px solid var(--primary);
}
.login-logo {
  width: 64px; height: 64px;
  background: rgba(200,184,154,.12);
  border-radius: 1rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem; color: var(--primary);
  margin: 0 auto 1rem;
  border: 1px solid rgba(200,184,154,.25);
}
.login-title { color: #fff; font-size: 1.4rem; font-weight: 700; margin: 0; }
.login-sub   { color: var(--primary); font-size: 0.85rem; margin: 0.25rem 0 0; opacity: 0.8; }
.login-body  { padding: 1.75rem 2rem 2rem; }

/* ── SETUP PAGE ──────────────────────────────────────────────────────────── */
.setup-page {
  min-height: 100vh;
  background: #090909;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.setup-card {
  background: var(--card-bg);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.6);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
}

/* ── MISC UTILITIES ──────────────────────────────────────────────────────── */
.text-primary { color: var(--primary-dark) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-muted   { color: var(--muted) !important; }
.fw-semibold  { font-weight: 600; }

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}
.empty-state i { font-size: 2.5rem; opacity: .4; display: block; margin-bottom: 0.75rem; }
.empty-state p { margin: 0; font-size: 0.9rem; }

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
  font-size: 0.8rem;
  text-decoration: none;
}
.action-btn:hover.edit   { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary); }
.action-btn:hover.delete { background: #fee2e2; color: var(--danger); border-color: var(--danger); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0c8b8; border-radius: 3px; }

/* ── FILTER CARD ─────────────────────────────────────────────────────────── */
.filter-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ── AMOUNT DISPLAY ──────────────────────────────────────────────────────── */
.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.amount.positive { color: var(--success); }
.amount.negative { color: var(--danger); }

/* ── MOBILE BOTTOM NAV ───────────────────────────────────────────────────── */
.mobile-nav { display: none; }

@media (max-width: 767.98px) {
  /* Sidebar → oculto */
  .sidebar { display: none; }

  /* Layout principal ocupa tela toda */
  .main-content {
    margin-left: 0;
    padding-bottom: 64px;
  }

  .page-body { padding: 0.875rem; }

  .page-header { padding: 0.75rem 0.875rem; gap: 0.5rem; }
  .page-title  { font-size: 0.95rem; }

  .stat-card  { padding: 0.875rem; gap: 0.75rem; }
  .stat-value { font-size: 1.1rem; }
  .stat-icon  { width: 40px; height: 40px; font-size: 1.15rem; }

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

  .modal-dialog { margin: 0.5rem; }

  .page-header { flex-wrap: wrap; }

  .page-header .btn-label-mobile { display: none; }

  .toast-container { bottom: 4.75rem; right: 0.75rem; left: 0.75rem; }
  .toast-item { min-width: unset; max-width: unset; width: 100%; }

  .cat-list-body { height: calc(100dvh - 14rem) !important; }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--sidebar-bg);
    border-top: 1px solid #1f1f1f;
    z-index: 1030;
    align-items: stretch;
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 0.58rem;
    font-weight: 500;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item i    { font-size: 1.25rem; line-height: 1; }
  .mobile-nav-item.active { color: var(--primary); }
  .mobile-nav-item:hover  { color: #d0c8b8; }
}
