:root {
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-indigo: #6366f1;
  --accent-blue: #3b82f6;
  --accent-rose: #f43f5e;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

/* Solarized Light Theme */
body.theme-solarized-light {
  --bg-primary: #fdf6e3;
  --bg-surface: #eee8d5;
  --bg-card: #e0d7c3;
  --bg-card-hover: #d3c7ae;
  --border-color: #d3c7ae;
  --text-primary: #073642;
  --text-secondary: #586e75;
  --text-muted: #657b83;
  --accent-emerald: #859900;
  --accent-amber: #b58900;
  --accent-indigo: #6c71c4;
  --accent-blue: #268bd2;
  --accent-rose: #dc322f;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  font-size: 2rem;
  background: rgba(99, 102, 241, 0.15);
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.brand h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-badge {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-color);
}

.status-badge.success { border-color: rgba(16, 185, 129, 0.4); color: var(--accent-emerald); }
.status-badge.info { border-color: rgba(99, 102, 241, 0.4); color: var(--accent-indigo); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

.btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
}

.btn-theme {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.card-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.card-icon {
  font-size: 1.25rem;
}

.metric-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
}

.text-emerald { color: var(--accent-emerald); }
.text-amber { color: var(--accent-amber); }
.text-indigo { color: var(--accent-indigo); }
.text-blue { color: var(--accent-blue); }
.text-rose { color: var(--accent-rose); }
.text-muted { color: var(--text-muted); font-size: 0.8rem; }

/* Insights Section */
.insights-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
}

.badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-indigo);
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge.warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.4);
}

.badge.success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.4);
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.insight-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 4px solid var(--accent-blue);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.insight-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.insight-card.danger { border-left-color: var(--accent-rose); }
.insight-card.success { border-left-color: var(--accent-emerald); }
.insight-card.info { border-left-color: var(--accent-indigo); }
.insight-card.tip { border-left-color: var(--accent-amber); }

.insight-card h4 {
  font-size: 0.95rem;
  color: var(--text-primary);
}

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

.insight-link-btn {
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Tabs & Main Content */
.main-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tab-bar {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.tab-btn.active {
  background: rgba(99, 102, 241, 0.2);
  color: var(--text-primary);
  font-weight: 600;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Extrato Filter Toolbar */
.filter-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.filter-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.preset-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-preset {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-preset.active, .btn-preset:hover {
  background: rgba(99, 102, 241, 0.2);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.4);
}

.date-inputs {
  display: flex;
  gap: 8px;
}

.extrato-summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.mini-summary-card {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-summary-card span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mini-summary-card strong {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
}

.mini-summary-card.success strong { color: var(--accent-emerald); }
.mini-summary-card.danger strong { color: var(--accent-rose); }
.mini-summary-card.info strong { color: var(--accent-indigo); }

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

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

.page-controls {
  display: flex;
  gap: 8px;
}

/* Chat Wrapper */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 520px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.02);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.chat-header h3 { font-size: 1rem; color: var(--text-primary); }
.chat-header p { font-size: 0.8rem; color: var(--text-muted); }

.chat-quick-prompts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-pill {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.prompt-pill:hover {
  background: rgba(99, 102, 241, 0.2);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.4);
}

.chat-box {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  display: flex;
  max-width: 85%;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message .msg-content {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-message.bot .msg-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.chat-message.user .msg-content {
  background: #4f46e5;
  color: #fff;
}

.chat-input-area {
  display: flex;
  gap: 10px;
}

.chat-input-area input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.chat-input-area input:focus {
  outline: none;
  border-color: var(--accent-indigo);
}

/* Panels, Tables & Categories */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.select-input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.02);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.cat-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.cat-bar-bg {
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #3b82f6);
  border-radius: 4px;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th, .data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.02);
}

.status-tag {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.status-tag.paid { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); }
.status-tag.open_future { background: rgba(59, 130, 246, 0.2); color: var(--accent-blue); }
.status-tag.open_overdue { background: rgba(244, 63, 94, 0.2); color: var(--accent-rose); }
.status-tag.open { background: rgba(245, 158, 11, 0.2); color: var(--accent-amber); }

/* Accounts Grid */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.account-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-box .bank-name {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 1rem;
}

.account-box .balance {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-emerald);
}


/* Scope Selector Buttons for Tabs */
.scope-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.scope-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-indigo);
}

.scope-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--accent-indigo);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
