/* ===== CSS Custom Properties / Theming ===== */
:root,
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-sidebar: #1e293b;
  --bg-sidebar-hover: #334155;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --bg-modal-overlay: rgba(0, 0, 0, 0.5);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;
  --border-color: #e2e8f0;
  --border-input: #cbd5e1;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-light: rgba(13, 148, 136, 0.1);
  --income-color: #22c55e;
  --income-bg: rgba(34, 197, 94, 0.1);
  --expense-color: #ef4444;
  --expense-bg: rgba(239, 68, 68, 0.1);
  --warning-color: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --success-color: #22c55e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --sidebar-width: 240px;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --bg-modal-overlay: rgba(0, 0, 0, 0.7);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #f1f5f9;
  --border-color: #334155;
  --border-input: #475569;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--accent);
}

.nav-links {
  padding: 0.75rem 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: var(--text-sidebar);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 0;
  transition: all 0.15s;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.nav-link svg {
  flex-shrink: 0;
}

/* ===== Mobile Header ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-sidebar);
  color: #fff;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  z-index: 90;
}

.menu-toggle {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
  max-width: 1200px;
}

/* ===== Pages ===== */
.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.income-card .card-icon { background: var(--income-bg); color: var(--income-color); }
.expense-card .card-icon { background: var(--expense-bg); color: var(--expense-color); }
.balance-card .card-icon { background: var(--accent-light); color: var(--accent); }
.savings-card .card-icon { background: #dbeafe; color: #0ea5e9; }
.budget-left-card .card-icon { background: var(--warning-bg); color: var(--warning-color); }

.card-info {
  display: flex;
  flex-direction: column;
}

.card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.card-amount {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 2px;
}

.income-card .card-amount { color: var(--income-color); }
.expense-card .card-amount { color: var(--expense-color); }

/* ===== Charts ===== */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.chart-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.chart-container {
  position: relative;
  height: 260px;
}

.chart-container.chart-wide {
  height: 300px;
}

/* ===== Budget Progress ===== */
.budget-progress-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.budget-progress-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.budget-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.budget-progress-header span:first-child {
  font-weight: 600;
}

.budget-progress-header .budget-amounts {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.progress-bar {
  height: 8px;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* ===== Transactions List ===== */
.transaction-list {
  display: flex;
  flex-direction: column;
}

.transaction-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.transaction-item:last-child {
  border-bottom: none;
}

.txn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.txn-details {
  flex: 1;
  min-width: 0;
}

.txn-description {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.txn-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.txn-amount {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.txn-amount.income { color: var(--income-color); }
.txn-amount.expense { color: var(--expense-color); }
.txn-amount.savings { color: #0ea5e9; }

.txn-actions {
  display: flex;
  gap: 0.25rem;
}

.txn-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  border-radius: 4px;
  transition: all 0.15s;
}

.txn-actions button:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* ===== Budgets Grid ===== */
.budgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.budget-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.budget-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.budget-card-header h4 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.budget-cat-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.budget-card .budget-amounts {
  text-align: right;
}

.budget-card .budget-spent {
  font-size: 1.25rem;
  font-weight: 700;
}

.budget-card .budget-limit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.budget-card .progress-bar {
  margin: 0.75rem 0;
  height: 10px;
}

.budget-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.budget-card-footer .remaining {
  font-weight: 600;
}

.budget-card-footer .remaining.over { color: var(--expense-color); }
.budget-card-footer .remaining.under { color: var(--income-color); }

.budget-card-actions {
  display: flex;
  gap: 0.25rem;
}

.budget-card-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  border-radius: 4px;
  font-size: 0.85rem;
}

.budget-card-actions button:hover {
  color: var(--text-primary);
  background: var(--bg-input);
}

/* ===== Members Grid ===== */
.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.member-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.member-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.member-card h4 {
  font-size: 1rem;
  font-weight: 600;
}

.member-card .member-stats {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.member-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.member-card-actions button {
  background: none;
  border: 1px solid var(--border-color);
  cursor: pointer;
  padding: 4px 10px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  transition: all 0.15s;
}

.member-card-actions button:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* ===== Settings ===== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.settings-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  gap: 1rem;
  font-size: 0.9rem;
}

.setting-row.danger {
  color: var(--expense-color);
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  max-height: 240px;
  overflow-y: auto;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.category-item:hover {
  background: var(--bg-input);
}

.cat-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.category-item span {
  flex: 1;
}

.category-item button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  font-size: 1rem;
  line-height: 1;
}

.category-item button:hover {
  color: var(--expense-color);
}
.category-item .cat-edit-btn {
  font-size: 0.85rem;
}
.category-item .cat-edit-btn:hover {
  color: var(--accent);
}

.category-child {
  padding-left: 1.75rem;
}
.category-child .cat-color-dot {
  width: 10px;
  height: 10px;
}

.add-category-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.add-category-row input[type="text"] {
  flex: 1;
}

.add-category-row input[type="color"] {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
}

/* ===== Filters ===== */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 0;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 140px;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== Top Expenses ===== */
.top-expenses-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-expense-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-expense-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.top-expense-item .txn-details { flex: 1; }

.top-expense-item .txn-amount {
  font-weight: 700;
  color: var(--expense-color);
}

/* ===== Report Controls ===== */
.report-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-danger {
  background: var(--expense-color);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

/* ===== Form Elements ===== */
select,
input[type="text"],
input[type="number"],
input[type="date"],
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.15s;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

textarea { resize: vertical; }

/* ===== Modal ===== */
[hidden] {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s ease;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-small {
  max-width: 380px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

/* ===== Import ===== */
.import-file-input {
  width: 100%;
  padding: 0.75rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  cursor: pointer;
  font-size: 0.9rem;
}

.import-preview-table {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.import-preview-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.import-preview-table th,
.import-preview-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

.import-preview-table th {
  background: var(--bg-input);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.import-preview-table tr.income-row { color: var(--income-color); }
.import-preview-table tr.expense-row { color: var(--expense-color); }

/* Import steps bar */
.import-steps-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.import-step-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-input);
}
.import-step-indicator.active {
  background: var(--accent);
  color: #fff;
}
.import-step-indicator.done {
  background: var(--income-color);
  color: #fff;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  font-size: 0.8rem;
  font-weight: 700;
}

/* Allocate list — full page, no max-height */
.import-allocate-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.allocate-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.allocate-item .alloc-date {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  min-width: 75px;
}

.allocate-item .alloc-desc {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.allocate-item .alloc-amount {
  font-weight: 600;
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}

.allocate-item .alloc-amount.income { color: var(--income-color); }
.allocate-item .alloc-amount.expense { color: var(--expense-color); }
.allocate-item .alloc-amount.savings { color: #0ea5e9; }

/* Category search picker */
.cat-search-wrap {
  position: relative;
  min-width: 180px;
}
.cat-search-wrap input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
}
.cat-search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13,148,136,0.15);
}
.cat-search-wrap input.has-value {
  border-color: var(--accent);
  background: rgba(13,148,136,0.05);
}
.cat-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: none;
}
.cat-search-dropdown.open {
  display: block;
}
.cat-search-option {
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cat-search-option:hover,
.cat-search-option.highlighted {
  background: var(--bg-hover);
}
.cat-search-option .cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.txn-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.txn-badge.transfer {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.txn-badge.imported {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

/* ===== Budget Table ===== */
.budget-table-wrapper {
  overflow-x: auto;
}

.budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.budget-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.budget-table th.col-amount,
.budget-table td.col-amount {
  text-align: right;
}

.budget-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.budget-table tr:last-child td {
  border-bottom: none;
}

.budget-section-header {
  background: var(--bg-input);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-left: 4px solid var(--accent);
}

.budget-section-header td {
  padding: 0.7rem 0.75rem;
}

.budget-category-row td {
  font-weight: 600;
}

.budget-sub-row td:first-child {
  padding-left: 2rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.budget-table .variance-positive {
  color: var(--income-color);
  font-weight: 600;
}

.budget-table .variance-negative {
  color: var(--expense-color);
  font-weight: 600;
}

.budget-table .set-budget-link {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.budget-table .set-budget-link:hover {
  color: var(--accent);
}

.budget-table .budget-actions-cell {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.budget-table .budget-actions-cell button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  color: var(--text-muted);
  border-radius: 4px;
  font-size: 0.8rem;
}

.budget-table .budget-actions-cell button:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.member-budget-cell,
.budget-inline-cell {
  cursor: pointer;
  transition: background 0.15s;
}
.member-budget-cell:hover,
td:has(.budget-inline-cell):hover,
td:has(.set-budget-link):hover {
  background: rgba(13, 148, 136, 0.08);
}
.budget-inline-cell {
  display: inline-block;
}

.budget-parent-row td {
  font-weight: 700;
  background: rgba(13, 148, 136, 0.03);
}

.budget-subtitle {
  color: var(--accent);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Budget Total Row */
.budget-total-row td {
  font-weight: 800;
  font-size: 0.95rem;
  border-top: 3px solid var(--accent);
  background: rgba(13, 148, 136, 0.06);
  padding: 0.8rem 0.75rem;
}

/* Budget Sub-Tabs */
.budget-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 1.5rem;
}

.budget-tab {
  padding: 0.5rem 1.25rem;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.budget-tab:hover {
  background: rgba(13, 148, 136, 0.08);
}

.budget-tab.active {
  background: var(--accent);
  color: white;
}

.budget-tab-connector {
  width: 32px;
  height: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

.budget-tab-content {
  display: none;
}

.budget-tab-content.active {
  display: block;
}

/* Discussion Cards */
.discussion-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
  font-size: 0.95rem;
  margin: -1rem -1rem 1rem -1rem;
}

.discussion-card-header span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.discussion-card-header svg {
  stroke: white;
}

.discussion-count {
  font-weight: 400;
  opacity: 0.85;
  margin-left: 0.5rem;
}

.discussion-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.discussion-card {
  padding: 1rem;
}

.add-discussion-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.add-discussion-row input[type="text"] {
  flex: 1;
}

.discussion-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.discussion-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.discussion-item:hover {
  background: var(--bg-input);
}

.discussion-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.discussion-item .item-text {
  flex: 1;
}

.discussion-item .item-text.completed {
  text-decoration: line-through;
  color: var(--text-muted);
}

.discussion-item .delete-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.discussion-item:hover .delete-item-btn {
  opacity: 1;
}

.discussion-item .delete-item-btn:hover {
  color: var(--expense-color);
}

.empty-state-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.75rem 0;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.4rem;
  font-size: 0.9rem;
}

.event-item:hover {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.event-date {
  font-weight: 600;
  color: var(--accent);
  min-width: 60px;
  font-size: 0.85rem;
}

.event-item .delete-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s;
}

.event-item:hover .delete-item-btn {
  opacity: 1;
}

/* Analysis Tab */
.analysis-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.analysis-chart-card {
  padding: 1.25rem;
}

.analysis-chart-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.analysis-donut-wrap {
  position: relative;
  height: 220px;
}

.goal-edit-link {
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

.goal-edit-link:hover {
  color: var(--accent);
}

/* Budget Comparison Bars */
.comparison-row {
  margin-bottom: 1.25rem;
}

.comparison-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
}

.comparison-bar {
  display: flex;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-input);
}

.comparison-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  min-width: 0;
  transition: width 0.3s;
}

.comparison-legend {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
}

.comparison-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.comparison-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

@media (max-width: 768px) {
  .discussion-row {
    grid-template-columns: 1fr;
  }
  .analysis-charts-row {
    grid-template-columns: 1fr;
  }
  .budget-tabs {
    flex-wrap: wrap;
  }
  .budget-tab-connector {
    display: none;
  }
  .budget-tabs {
    gap: 0.5rem;
  }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(56px + 1rem);
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .summary-cards {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    min-width: unset;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .report-controls {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .budgets-grid {
    grid-template-columns: 1fr;
  }

  .members-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
