/* ============================================================
   Design System CSS - Dark-first Glassmorphism
   Sistema Financeiro - Allan Cabral
   ============================================================ */

/* ── Importacao de fonte ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variaveis (Design Tokens) ───────────────────────────── */
:root {
  /* Cores de fundo */
  --bg-gradient: linear-gradient(135deg, #0a0a0f, #0d1117, #0f0a1a);
  --bg-body: #0a0a0f;

  /* Glass card */
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-blur: 20px;
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-radius: 16px;

  /* Texto */
  --text-primary: #fff;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --text-muted: rgba(255, 255, 255, 0.35);

  /* Cores de destaque */
  --accent-blue: #3b82f6;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --accent-gold: #facc3c;

  /* Variantes de destaque com transparencia */
  --accent-blue-soft: rgba(59, 130, 246, 0.15);
  --accent-green-soft: rgba(52, 211, 153, 0.15);
  --accent-red-soft: rgba(248, 113, 113, 0.15);
  --accent-gold-soft: rgba(250, 204, 60, 0.15);

  /* Modal / Popup - fundo opaco, SEM backdrop-filter */
  --modal-bg: rgba(22, 27, 34, 0.97);
  --modal-overlay: rgba(0, 0, 0, 0.7);

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 68px;

  /* Espacamento */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Bordas */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* Tipografia */
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-xs: 0.75rem;
  --font-sm: 0.8125rem;
  --font-base: 0.875rem;
  --font-md: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;
  --font-3xl: 2rem;

  /* Transicoes - valores reutilizaveis */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Z-index */
  --z-sidebar: 100;
  --z-modal-overlay: 200;
  --z-modal-content: 210;
  --z-toast: 300;
  --z-tooltip: 400;

  /* Formularios */
  --input-bg: rgba(255, 255, 255, 0.06);
  --input-border: rgba(255, 255, 255, 0.1);
  --input-focus-border: var(--accent-blue);
  --input-radius: var(--radius-md);

  /* Tabelas */
  --table-row-bg: rgba(255, 255, 255, 0.02);
  --table-row-alt-bg: rgba(255, 255, 255, 0.04);
  --table-header-bg: rgba(255, 255, 255, 0.06);
}

/* ── Reset e base ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ── Glass Card ──────────────────────────────────────────── */
/* IMPORTANTE: NUNCA usar transition: all aqui */
/* IMPORTANTE: NUNCA animar border-color em elementos com backdrop-filter */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-md);
}

/* ── Layout: Sidebar ─────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: rgba(8, 10, 16, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--glass-border);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Header com logo ── */
.sidebar-header {
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
}

.sidebar-logo-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.sidebar-brand-name {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.01em;
  line-height: 1.2;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.sidebar-brand-sub {
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* ── Navegacao ── */
.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-base);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  text-decoration: none;
}

/* Borda de destaque ativo a esquerda */
.sidebar-link.active {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-blue);
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-icon svg {
  width: 20px;
  height: 20px;
}

.sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* ── Footer ── */
.sidebar-footer {
  padding: var(--space-sm);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.sidebar-collapse-icon {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logout-btn {
  color: var(--text-secondary);
}

.sidebar-logout-btn:hover {
  color: var(--accent-red) !important;
  background: rgba(248, 113, 113, 0.08) !important;
}

/* ── Tooltip (visivel apenas quando colapsado) ── */
.sidebar-link[data-tooltip] {
  position: relative;
}

.sidebar-link[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  background: rgba(22, 27, 34, 0.97);
  color: var(--text-primary);
  font-size: var(--font-xs);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 9999;
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ── Estado colapsado (desktop) ── */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-brand-name,
.sidebar.collapsed .sidebar-brand-sub,
.sidebar.collapsed .sidebar-label {
  opacity: 0;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-collapse-icon {
  transform: rotate(180deg);
}

/* Tooltip aparece apenas quando colapsado */
.sidebar.collapsed .sidebar-link[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* Ajuste do main-content quando sidebar colapsa */
.sidebar-is-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* ── Overlay para mobile ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Botao hamburger mobile ── */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: var(--space-md);
  left: var(--space-md);
  z-index: calc(var(--z-sidebar) + 1);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── Layout: Conteudo principal ──────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  padding: var(--space-lg) var(--space-xl);
  min-height: 100vh;
}

.page-header {
  margin-bottom: var(--space-xl);
}

.page-header h1,
.page-header .page-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.page-header p,
.page-header .page-subtitle {
  font-size: var(--font-base);
  color: var(--text-secondary);
}

/* ── Botoes ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-base);
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.btn-primary:hover:not(:disabled) {
  background: #2563eb;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
  background: var(--glass-bg);
  color: var(--text-primary);
  border-color: var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
}

.btn-danger:hover:not(:disabled) {
  background: #ef4444;
  box-shadow: 0 0 20px rgba(248, 113, 113, 0.3);
}

.btn-success {
  background: var(--accent-green);
  color: #0a0a0f;
  border-color: var(--accent-green);
}

.btn-success:hover:not(:disabled) {
  background: #2dd4a0;
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-icon svg {
  flex-shrink: 0;
}

.btn-icon:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.2);
}

.btn-icon.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
  color: var(--accent-red);
  border-color: rgba(248, 113, 113, 0.2);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-sm);
}

.btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-md);
}

/* ── Formularios ─────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  color: var(--text-primary);
  font-size: var(--font-base);
  line-height: 1.5;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
select:focus,
textarea:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.35)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
  cursor: pointer;
  font-weight: 500;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

select:hover {
  background-color: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

select:focus {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Estilo das opcoes do dropdown nativo */
select option {
  background: #111520;
  color: rgba(255, 255, 255, 0.85);
  padding: 8px 12px;
  font-weight: 400;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

select option:checked {
  background: linear-gradient(0deg, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0.25) 100%);
  color: #fff;
  font-weight: 500;
}

select option:hover,
select option:focus {
  background: rgba(255, 255, 255, 0.06);
}

/* ── Custom Select Dropdown Panel ──────────────────────── */
.csd-panel {
  position: absolute;
  z-index: 9500;
  min-width: 120px;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(14, 17, 23, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
              0 2px 8px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(255, 255, 255, 0.03);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.18s ease;
  pointer-events: none;
}

.csd-panel.csd-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.csd-panel.csd-up {
  transform: translateY(4px);
}

.csd-panel.csd-up.csd-open {
  transform: translateY(0);
}

/* Scrollbar do painel */
.csd-panel::-webkit-scrollbar {
  width: 5px;
}

.csd-panel::-webkit-scrollbar-track {
  background: transparent;
}

.csd-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.csd-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Opcao individual */
.csd-item {
  position: relative;
  padding: 9px 14px 9px 16px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.55);
  font-size: var(--font-base);
  font-weight: 450;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csd-item:hover,
.csd-item.csd-focused {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

/* Item selecionado — barra azul esquerda */
.csd-item.csd-selected {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
  font-weight: 550;
  padding-left: 19px;
}

.csd-item.csd-selected::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent-blue);
}

.csd-item.csd-selected:hover,
.csd-item.csd-selected.csd-focused {
  background: rgba(59, 130, 246, 0.18);
}

.csd-item.csd-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.form-error {
  font-size: var(--font-xs);
  color: var(--accent-red);
  margin-top: var(--space-xs);
}

.form-row {
  display: flex;
  gap: var(--space-md);
}

.form-row > * {
  flex: 1;
}

/* Checkbox e radio personalizados */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

/* ── Tabelas ─────────────────────────────────────────────── */
.tabela-relatorio {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-base);
}

.tabela-relatorio thead th {
  text-align: left;
  padding: 12px var(--space-md);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.tabela-relatorio tbody tr {
  transition: background-color 0.12s ease;
}

.tabela-relatorio tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tabela-relatorio tbody td {
  padding: 14px var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: middle;
  font-weight: 450;
}

.tabela-relatorio .td-descricao {
  color: var(--text-primary);
  font-weight: 500;
}

.tabela-relatorio .td-valor {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tabela-relatorio .td-usd {
  color: var(--accent-blue);
}

.tabela-relatorio .td-right {
  text-align: right;
}

.tabela-relatorio .td-center {
  text-align: center;
}

/* Badge de categoria na tabela */
.badge-cat {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Badge inline de origem (WhatsApp/Web) */
.source-badge-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-sm);
  font-weight: 500;
}

.source-badge-inline.source-whatsapp {
  color: var(--accent-green);
}

.source-badge-inline.source-web {
  color: var(--accent-blue);
}

.source-badge-inline svg {
  flex-shrink: 0;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.badge-default {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.badge-blue {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
}

.badge-green {
  background: var(--accent-green-soft);
  color: var(--accent-green);
}

.badge-red {
  background: var(--accent-red-soft);
  color: var(--accent-red);
}

.badge-gold {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

/* ── Modais ──────────────────────────────────────────────── */
/* IMPORTANTE: fundo opaco, SEM backdrop-filter */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-overlay);
  z-index: var(--z-modal-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

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

.modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  z-index: var(--z-modal-content);
  box-shadow: var(--shadow-lg);
  /* SEM backdrop-filter - fundo opaco */
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--glass-border);
}

.modal-header h2,
.modal-header .modal-title {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-header .modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--font-xl);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  background: none;
  border: none;
}

.modal-header .modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--glass-border);
}

/* ── Cards layout (Dashboard) ────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.stat-card {
  padding: var(--space-lg);
}

.stat-card .stat-label {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.stat-card .stat-value {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card .stat-change {
  font-size: var(--font-xs);
  margin-top: var(--space-sm);
}

.stat-card .stat-change.positive {
  color: var(--accent-green);
}

.stat-card .stat-change.negative {
  color: var(--accent-red);
}

/* ── Dashboard: Categorias ───────────────────────────────── */
.categoria-bar {
  margin-bottom: var(--space-md);
}

.categoria-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
  font-size: var(--font-sm);
}

.categoria-info .categoria-nome {
  color: var(--text-primary);
  font-weight: 500;
}

.categoria-info .categoria-valor {
  color: var(--text-secondary);
}

.bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent-blue);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ── Dashboard: Itens de despesa ─────────────────────────── */
.despesa-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.despesa-item:last-child {
  border-bottom: none;
}

.despesa-desc {
  font-size: var(--font-base);
  color: var(--text-primary);
  font-weight: 500;
}

.despesa-valor {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.despesa-valor.negativo {
  color: var(--accent-red);
}

.despesa-valor.positivo {
  color: var(--accent-green);
}

/* Badges de origem (Web/WhatsApp) */
.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  flex-shrink: 0;
}

.source-whatsapp {
  color: var(--accent-green);
  background: rgba(52, 211, 153, 0.1);
}

.source-web {
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

/* ── Dashboard: Assinatura item ──────────────────────────── */
.assinatura-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.assinatura-item:last-child {
  border-bottom: none;
}

/* ── Linhas de listagem ──────────────────────────────────── */
.despesa-row,
.assinatura-row,
.equipamento-row,
.usuario-row,
.categoria-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.despesa-row:hover,
.assinatura-row:hover,
.equipamento-row:hover,
.usuario-row:hover,
.categoria-row:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-sm);
}

.row-info {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-subtitle {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.row-value {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* ── Calendario ──────────────────────────────────────────── */
.calendario-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendario-header {
  text-align: center;
  padding: var(--space-sm);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.calendario-dia {
  position: relative;
  min-height: 80px;
  padding: var(--space-sm);
  background: var(--table-row-bg);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
  cursor: pointer;
}

.calendario-dia:hover {
  background: rgba(255, 255, 255, 0.06);
}

.calendario-dia.hoje {
  outline: 2px solid var(--accent-blue);
  outline-offset: -2px;
  background: rgba(59, 130, 246, 0.08);
}

.calendario-dia.com-assinatura {
  background: rgba(250, 204, 60, 0.04);
}

.calendario-dia.outro-mes {
  opacity: 0.3;
}

.dia-numero {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.ass-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent-gold);
  display: inline-block;
  margin: 1px;
}

/* Contador de assinaturas no dia */
.ass-count {
  position: absolute;
  bottom: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Dia selecionado */
.calendario-dia.selecionado {
  background: rgba(59, 130, 246, 0.12);
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.calendario-dia.selecionado .dia-numero {
  color: var(--accent-blue);
}

/* ── Navegacao do calendario ── */
.calendario-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.calendario-nav-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calendario-titulo {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
  margin: 0;
}

.cal-btn-hoje {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.cal-btn-hoje:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* ── Detalhes do dia selecionado ── */
.cal-detalhe-panel {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

.cal-detalhe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--glass-border);
}

.cal-detalhe-data {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

.cal-detalhe-total {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.cal-detalhe-vazio {
  color: var(--text-muted);
  font-size: var(--font-sm);
  text-align: center;
  padding: var(--space-sm) 0;
  margin: 0;
}

.cal-detalhe-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
}

.cal-detalhe-item + .cal-detalhe-item {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.cal-detalhe-nome {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.cal-detalhe-valor {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Secoes internas ─────────────────────────────────────── */
.section {
  margin-bottom: var(--space-xl);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.section-title {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Separadores ─────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--glass-border);
  margin: var(--space-lg) 0;
}

/* ── Toast / Notificacao ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--modal-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: var(--font-sm);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 420px;
  animation: toast-in 0.3s ease forwards;
}

.toast.toast-success {
  border-left: 3px solid var(--accent-green);
}

.toast.toast-error {
  border-left: 3px solid var(--accent-red);
}

.toast.toast-warning {
  border-left: 3px solid var(--accent-gold);
}

.toast.toast-info {
  border-left: 3px solid var(--accent-blue);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Loading / Spinner ───────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-blue);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-secondary);
  font-size: var(--font-base);
  gap: var(--space-md);
}

/* ── Vazio / Empty state ─────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.3;
}

.empty-state .empty-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.empty-state .empty-text {
  font-size: var(--font-base);
  color: var(--text-muted);
  max-width: 360px;
}

/* ── Filtros / Toolbar ───────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input input {
  padding-left: var(--space-xl);
}

.search-input .search-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: var(--font-base);
}

/* ── Paginacao ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
}

.pagination-btn {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  background: none;
  border: none;
}

.pagination-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.pagination-btn.active {
  background: var(--accent-blue);
  color: #fff;
}

/* ── Utilitarios de texto ────────────────────────────────── */
.text-muted {
  color: var(--text-muted);
}

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

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

.text-blue {
  color: var(--accent-blue);
}

.text-green {
  color: var(--accent-green);
}

.text-red {
  color: var(--accent-red);
}

.text-gold {
  color: var(--accent-gold);
}

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

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

.text-sm {
  font-size: var(--font-sm);
}

.text-xs {
  font-size: var(--font-xs);
}

.text-lg {
  font-size: var(--font-lg);
}

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

.text-medium {
  font-weight: 500;
}

.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Utilitarios de layout ───────────────────────────────── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

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

.flex-1 {
  flex: 1;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

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

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

/* Gap utilities */
.gap-xs {
  gap: var(--space-xs);
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.gap-xl {
  gap: var(--space-xl);
}

/* Spacing utilities */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

/* Display */
.hidden {
  display: none;
}

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

/* Controle de acesso */
.admin-only {
  display: block;
}

/* Overflow */
.overflow-auto {
  overflow: auto;
}

.overflow-hidden {
  overflow: hidden;
}

/* Largura */
.w-full {
  width: 100%;
}

/* ── Scrollbar personalizada ─────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Responsivo (breakpoint 768px) ───────────────────────── */
@media (max-width: 768px) {
  /* Sidebar esconde no mobile e volta ao tamanho completo */
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
  }

  .sidebar.collapsed .sidebar-brand-name,
  .sidebar.collapsed .sidebar-brand-sub,
  .sidebar.collapsed .sidebar-label {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar.collapsed .sidebar-collapse-icon {
    transform: none;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* Esconde botao de colapsar e mostra hamburger */
  .sidebar-collapse-btn {
    display: none;
  }

  .sidebar-mobile-toggle {
    display: flex;
  }

  /* Conteudo principal ocupa largura total */
  .main-content {
    margin-left: 0;
    padding: var(--space-md);
    padding-top: calc(var(--space-md) + 56px);
  }

  .sidebar-is-collapsed .main-content {
    margin-left: 0;
  }

  /* Grids em coluna unica */
  .cards-grid {
    grid-template-columns: 1fr;
  }

  /* Calendario reduzido */
  .calendario-dia {
    min-height: 48px;
    padding: var(--space-xs);
  }

  .dia-numero {
    font-size: var(--font-xs);
  }

  /* Formularios em coluna */
  .form-row {
    flex-direction: column;
  }

  /* Toolbar empilha */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    min-width: 100%;
  }

  /* Tabela com scroll horizontal */
  .tabela-relatorio {
    display: block;
    overflow-x: auto;
  }

  /* Linhas de listagem empilham */
  .despesa-row,
  .assinatura-row,
  .equipamento-row,
  .usuario-row,
  .categoria-row {
    flex-wrap: wrap;
  }

  /* Modal em largura total */
  .modal-content {
    max-width: 100%;
    max-height: 90vh;
    margin: var(--space-md);
  }

  /* Page header */
  .page-header h1,
  .page-header .page-title {
    font-size: var(--font-xl);
  }

  /* Toast */
  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
  }

  .toast {
    min-width: auto;
    max-width: 100%;
  }
}

/* ── Media query para telas muito pequenas ───────────────── */
@media (max-width: 480px) {
  :root {
    --space-lg: 16px;
    --space-xl: 24px;
  }

  .calendario-grid {
    gap: 1px;
  }

  .calendario-header {
    font-size: 0.625rem;
    padding: var(--space-xs);
  }

  .calendario-dia {
    min-height: 36px;
  }
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .sidebar,
  .sidebar-toggle,
  .sidebar-mobile-toggle,
  .sidebar-overlay,
  .toast-container,
  .modal-overlay {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 0;
  }

  .glass-card,
  .despesa-row,
  .assinatura-row,
  .equipamento-row,
  .usuario-row,
  .categoria-row {
    background: transparent;
    backdrop-filter: none;
    border: 1px solid #ddd;
  }
}
