/* FinControl Design System - Light & Dark Themes */
:root {
  --bg: #f4f6f9;
  --bg-elevated: #ffffff;
  --bg-subtle: #eef2f6;
  --bg-hover: #e6ecf2;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: rgba(5, 150, 105, 0.12);

  --income: #10b981;
  --income-soft: rgba(16, 185, 129, 0.12);
  --expense: #ef4444;
  --expense-soft: rgba(239, 68, 68, 0.12);
  --transfer: #3b82f6;
  --transfer-soft: rgba(59, 130, 246, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.14);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-w: 256px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --bg-subtle: #1e293b;
  --bg-hover: #273549;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-soft: #64748b;
  --border: #1e293b;
  --border-strong: #334155;

  --primary: #10b981;
  --primary-hover: #059669;
  --primary-soft: rgba(16, 185, 129, 0.16);

  --income-soft: rgba(16, 185, 129, 0.16);
  --expense-soft: rgba(239, 68, 68, 0.16);
  --transfer-soft: rgba(59, 130, 246, 0.16);
  --warning-soft: rgba(245, 158, 11, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* App Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 20px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28);
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.brand-tag {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-summary {
  margin: 14px 4px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.sidebar-summary-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

.sidebar-summary-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.btn-icon-text {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
}

.btn-icon-text svg {
  width: 17px;
  height: 17px;
}

.btn-icon-text:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

/* Main Wrapper */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  place-items: center;
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
}

.page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Month Picker */
.month-picker {
  display: inline-flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.month-nav-btn {
  border: none;
  background: transparent;
  padding: 8px 10px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

.month-nav-btn svg {
  width: 16px;
  height: 16px;
}

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

.month-current-btn {
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.88rem;
  min-width: 142px;
  text-align: center;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.month-current-btn:hover {
  background: var(--bg-subtle);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

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

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--expense-soft);
  color: var(--expense);
  border-color: rgba(239, 68, 68, 0.25);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 8px;
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

/* Onboarding */
.onboarding-banner {
  margin: 20px 28px 0;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary-soft), rgba(59, 130, 246, 0.08));
  border: 1px solid rgba(5, 150, 105, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.onboarding-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin-bottom: 4px;
}

.onboarding-content h2 {
  margin: 0 0 4px;
  font-size: 1.12rem;
}

.onboarding-content p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 640px;
}

.onboarding-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Main Content */
.main-content {
  padding: 24px 28px 40px;
  max-width: 1400px;
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* Cards & Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-pill {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.kpi-pill.income { background: var(--income-soft); color: var(--income); }
.kpi-pill.expense { background: var(--expense-soft); color: var(--expense); }
.kpi-pill.balance { background: var(--primary-soft); color: var(--primary); }
.kpi-pill.transfer { background: var(--transfer-soft); color: var(--transfer); }

.kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.grid-cards-layout {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.panel-subtitle {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Text Helpers */
.text-income { color: var(--income); }
.text-expense { color: var(--expense); }
.text-transfer { color: var(--transfer); }
.text-muted { color: var(--text-muted); }
.font-mono-num { font-variant-numeric: tabular-nums; }

/* Account Cards */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.account-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.account-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.account-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.account-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.account-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  color: #fff;
  flex-shrink: 0;
}

.account-name {
  font-weight: 700;
  font-size: 0.98rem;
}

.account-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.account-balance {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.account-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Credit Cards Visual */
.credit-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.cc-wrapper {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cc-visual {
  border-radius: 14px;
  padding: 18px 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  min-height: 146px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
}

.cc-visual::after {
  content: '';
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  top: -60px;
  right: -50px;
  pointer-events: none;
}

.cc-visual-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cc-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.cc-brand-badge {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
}

.cc-digits {
  font-size: 0.92rem;
  letter-spacing: 0.14em;
  opacity: 0.9;
  margin: 10px 0;
}

.cc-visual-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 0.8rem;
}

.cc-limit-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cc-limit-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-track {
  height: 8px;
  border-radius: 99px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.3s ease;
}

.progress-fill.warn { background: var(--warning); }
.progress-fill.danger { background: var(--expense); }

.cc-invoice-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cc-invoice-label {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.cc-invoice-amount {
  font-size: 1.15rem;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.74rem;
  font-weight: 600;
}

.status-badge.paid { background: var(--income-soft); color: var(--income); }
.status-badge.open { background: var(--warning-soft); color: var(--warning); }
.status-badge.pending { background: var(--warning-soft); color: var(--warning); }
.status-badge.expense { background: var(--expense-soft); color: var(--expense); }
.status-badge.income { background: var(--income-soft); color: var(--income); }
.status-badge.transfer { background: var(--transfer-soft); color: var(--transfer); }

/* Filters Bar */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.input, .select, .textarea {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.filters-bar .input {
  min-width: 210px;
  flex: 1;
}

/* Table / Transactions List */
.tx-table-wrap {
  overflow-x: auto;
}

.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tx-table th {
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.tx-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tx-table tr:last-child td {
  border-bottom: none;
}

.tx-table tbody tr:hover {
  background: var(--bg-subtle);
}

.tx-desc-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tx-cat-dot {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.tx-title {
  font-weight: 600;
}

.tx-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tx-amount {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tx-row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* Charts */
.chart-box {
  width: 100%;
  min-height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  align-items: center;
  width: 100%;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

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

.legend-val {
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Transfer Preview */
.transfer-preview {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 0.85rem;
}

.transfer-preview-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

/* Categories Grid */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.category-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category-chip-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.empty-state h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 1rem;
}

.empty-state p {
  margin: 0 0 16px;
  font-size: 0.88rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.16s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.modal-close:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

/* Forms */
.form-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}

.form-tab {
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.form-tab.active.expense { background: var(--bg-elevated); color: var(--expense); box-shadow: var(--shadow-sm); }
.form-tab.active.income { background: var(--bg-elevated); color: var(--income); box-shadow: var(--shadow-sm); }
.form-tab.active.transfer { background: var(--bg-elevated); color: var(--transfer); box-shadow: var(--shadow-sm); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group .input,
.form-group .select,
.form-group .textarea {
  width: 100%;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.color-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
}

.color-swatch.selected {
  border-color: var(--text);
  transform: scale(1.1);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  margin-top: 4px;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text);
  color: var(--bg-elevated);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease-out;
}

.toast.success { border-left: 4px solid var(--income); }
.toast.error { border-left: 4px solid var(--expense); }
.toast.info { border-left: 4px solid var(--transfer); }

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

/* Responsive */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 35;
}

@media (max-width: 1060px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-cards-layout { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: grid;
  }
  .topbar {
    padding: 14px 16px;
  }
  .main-content {
    padding: 16px;
  }
  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .donut-legend {
    width: 100%;
  }
}

@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Currency Mask Input */
.currency-input {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Login / Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  position: relative;
  background:
    radial-gradient(circle at 15% 20%, rgba(16, 185, 129, 0.14), transparent 42%),
    radial-gradient(circle at 85% 80%, rgba(59, 130, 246, 0.12), transparent 42%),
    var(--bg);
}

.auth-theme-btn {
  position: absolute;
  top: 18px;
  right: 20px;
}

.auth-card {
  width: 100%;
  max-width: 900px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.auth-brand-pane {
  padding: 40px 36px;
  background: linear-gradient(155deg, #064e3b 0%, #059669 65%, #0d9488 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-brand-pane .brand-logo {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.auth-brand-pane .brand-tag {
  color: rgba(255, 255, 255, 0.8);
}

.auth-headline {
  margin: 0 0 12px;
  font-size: 1.7rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.auth-subtext {
  margin: 0 0 24px;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.55;
}

.auth-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
  font-size: 0.88rem;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-features li span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.auth-form-pane {
  padding: 36px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 9px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-tab.active {
  background: var(--bg-elevated);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.auth-error {
  background: var(--expense-soft);
  color: var(--expense);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap .input {
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  border: none;
  background: transparent;
  padding: 4px;
  font-size: 0.95rem;
  opacity: 0.7;
}

.password-toggle:hover {
  opacity: 1;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Sidebar User Badge */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.sidebar-user:hover {
  background: var(--bg-subtle);
}

.sidebar-user-gear {
  margin-left: auto;
  font-size: 0.85rem;
  opacity: 0.65;
}

/* Budget Items */
.budget-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.budget-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.budget-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
}

/* Sync Badges */
.auth-backend-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.sync-badge.cloud {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(5, 150, 105, 0.25);
}

.sync-badge.warn {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.28);
}

.sidebar-sync-btn {
  margin-top: 8px;
  width: 100%;
  justify-content: center;
}

.auth-notice {
  background: var(--warning-soft);
  color: var(--text);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.82rem;
  margin-bottom: 12px;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-login {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout:hover {
  color: var(--expense);
  background: var(--expense-soft);
}

@media (max-width: 760px) {
  .auth-card {
    grid-template-columns: 1fr;
  }
  .auth-brand-pane {
    padding: 28px 24px;
  }
  .auth-form-pane {
    padding: 28px 24px;
  }
}
