/* ============================================================
   Cascalho — Editorial Warmth
   Premium cream canvas + forest green + terracotta + serif display
   Loaded LAST to override the legacy inline <style> block.
   ============================================================ */

/* --- Canvas: warm cream, not white --- */
body {
  background: var(--surface-app) !important;
  color: var(--text);
  padding: var(--s-6) !important;
  font-family: var(--font-sans) !important;
  min-height: 100vh;
  position: relative;
}

@media (max-width: 640px) { body { padding: var(--s-3) !important; } }

/* Atmospheric backdrop — warm paper grain + soft golden pools */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(800px 500px at 8% 0%,    rgba(31, 77, 58, 0.10),  transparent 55%),
    radial-gradient(700px 500px at 100% 12%, rgba(200, 169, 81, 0.12), transparent 60%),
    radial-gradient(600px 450px at 10% 100%, rgba(201, 123, 90, 0.09), transparent 55%);
  filter: blur(28px);
}

body::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.035 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.3;
}

body > * { position: relative; z-index: 1; }

[data-theme="dark"] body::before {
  background:
    radial-gradient(800px 500px at 8% 0%,    rgba(127, 179, 154, 0.15), transparent 55%),
    radial-gradient(700px 500px at 100% 12%, rgba(212, 181, 104, 0.08), transparent 60%),
    radial-gradient(600px 450px at 10% 100%, rgba(201, 123, 90, 0.07),  transparent 55%);
}
[data-theme="dark"] body::after { opacity: 0.35; mix-blend-mode: overlay; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body::before {
    background:
      radial-gradient(800px 500px at 8% 0%,    rgba(127, 179, 154, 0.15), transparent 55%),
      radial-gradient(700px 500px at 100% 12%, rgba(212, 181, 104, 0.08), transparent 60%),
      radial-gradient(600px 450px at 10% 100%, rgba(201, 123, 90, 0.07),  transparent 55%);
  }
  html:not([data-theme="light"]) body::after { opacity: 0.35; mix-blend-mode: overlay; }
}

/* --- Display typography: serif for marquee headings --- */
.section-title {
  font-family: var(--font-display) !important;
  font-optical-sizing: auto;
  letter-spacing: -0.015em !important;
}

/* --- Hero numbers: Manrope for tabular legibility --- */
.stat-card .value,
#netWorthCurrent,
#retirementFinal,
#debtTotal {
  font-family: var(--font-number) !important;
  font-weight: 700 !important;
  letter-spacing: -0.025em !important;
  font-feature-settings: 'tnum' 1;
}

.section-title {
  font-weight: 500 !important;
  font-variation-settings: 'opsz' 48;
  font-size: 28px !important;
  line-height: 1.1;
}

/* Monospace for currency inline (e.g. transaction amounts, table rows) */
.mono,
.badge,
.timeline-cell,
code {
  font-family: var(--font-mono) !important;
  font-feature-settings: 'tnum' 1, 'ss01' 1;
}

/* --- Header: flatter, wider, with a warm gold hairline --- */
.header {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-xl) !important;
  box-shadow: 0 1px 0 rgba(200, 169, 81, 0.15), var(--shadow-sm) !important;
  padding: 18px 24px !important;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--accent-gold) 30%,
    var(--primary) 70%,
    transparent 100%
  );
  opacity: 0.6;
}

.header h1 {
  font-family: var(--font-display) !important;
  font-size: 24px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 48;
}

.header h1 .icon-svg { color: var(--primary) !important; }
.header h1 span { font-weight: 500; }

/* --- Person selector: elegant segmented control --- */
.person-selector {
  background: var(--surface-muted) !important;
  padding: 4px !important;
  border-radius: var(--r-full) !important;
  border: 1px solid var(--border) !important;
  gap: 2px !important;
}

.person-btn {
  padding: 7px 14px !important;
  border-radius: var(--r-full) !important;
  color: var(--text-muted) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  background: transparent !important;
  box-shadow: none !important;
  transition: all var(--dur-fast) var(--ease) !important;
  letter-spacing: 0.01em;
}

.person-btn:hover:not(.active) { color: var(--text) !important; }

.person-btn.active {
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: 0 1px 2px rgba(38,35,29,0.08), 0 0 0 1px var(--border-strong) !important;
}

.person-btn.couple.active {
  background: var(--primary) !important;
  color: var(--surface-hero-text) !important;
}

/* --- Profile chip (header): avatar + first name, links to Settings --- */
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.profile-chip:hover,
.profile-chip:focus-visible {
  background: var(--surface-muted);
  border-color: var(--border-strong);
  outline: none;
}

.profile-chip:focus-visible {
  box-shadow: var(--shadow-focus);
}

.profile-chip__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--surface-hero-text);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

[data-theme="dark"] .profile-chip__avatar {
  color: var(--gray-900);
}

.profile-chip__name {
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .profile-chip__name { display: none; }
  .profile-chip { padding: 4px; }
}

/* --- Stats grid: FIRST card is a gradient HERO; rest are elegant tonal cards --- */
.stats-grid {
  gap: 14px !important;
  margin-top: var(--s-6) !important;
  margin-bottom: var(--s-6) !important;
}

.stat-card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-xl) !important;
  padding: 22px !important;
  box-shadow: none !important;
  transition: all var(--dur-base) var(--ease) !important;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px) !important;
  border-color: var(--border-strong) !important;
  box-shadow: 0 12px 30px rgba(38,35,29,0.06) !important;
}

/* Premium gradient hero — first stat card (Patrimônio Total) */
.stats-grid > .stat-card:first-child {
  background: linear-gradient(135deg, var(--surface-hero) 0%, #2d6a4f 100%) !important;
  border-color: var(--surface-hero) !important;
  color: var(--surface-hero-text) !important;
}

.stats-grid > .stat-card:first-child::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(400px 250px at 100% 0%, rgba(200,169,81,0.2), transparent 60%),
    radial-gradient(300px 200px at 0% 100%, rgba(255,255,255,0.06), transparent 60%);
  pointer-events: none;
}

.stats-grid > .stat-card:first-child .icon {
  background: rgba(200, 169, 81, 0.2) !important;
  color: var(--accent-gold) !important;
}

.stats-grid > .stat-card:first-child .label,
.stats-grid > .stat-card:first-child .sublabel,
.stats-grid > .stat-card:first-child .change {
  color: rgba(245, 239, 227, 0.75) !important;
}

.stats-grid > .stat-card:first-child .value {
  color: var(--surface-hero-text) !important;
  font-size: 36px !important;
  font-variation-settings: 'opsz' 144 !important;
}

/* Kill the old gradient-top-stripe ::before on stat cards */
.stat-card::before {
  content: none !important;
}

.stat-card .icon {
  width: 34px !important;
  height: 34px !important;
  border-radius: 10px !important;
  font-size: 15px !important;
  margin-bottom: 14px !important;
  background: var(--surface-tint-green) !important;
  color: var(--primary) !important;
}

.stat-card .icon .icon-svg { width: 17px; height: 17px; }

.stat-card .label {
  color: var(--text-muted) !important;
  font-size: 11px !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase;
  font-weight: 600 !important;
  margin-bottom: 10px !important;
}

.stat-card .value {
  color: var(--text) !important;
  font-size: 28px !important;
  font-weight: 700 !important;
  margin-bottom: 6px !important;
  font-feature-settings: 'tnum' 1;
  line-height: 1.1 !important;
}

.stat-card .change,
.stat-card .sublabel {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  font-weight: 400 !important;
}

/* --- Tabs: refined, with underline-style active state.
       Underline is per-group (segmented) — one hairline under each .tab-group
       wrapper, with a horizontal gap between groups. --- */
.tabs {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  gap: var(--s-4) !important;
  margin-bottom: var(--s-6) !important;
}

.tab-group {
  display: flex;
  min-width: 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 14px 18px !important;
  border-radius: 0 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text-muted) !important;
  border-bottom: 2px solid transparent !important;
  margin-bottom: -1px !important;
  transition: all var(--dur-fast) var(--ease) !important;
  background: transparent !important;
}

.tab:hover:not(.active) {
  color: var(--text) !important;
  background: transparent !important;
}

.tab.active,
.tab[aria-selected="true"] {
  background: transparent !important;
  color: var(--primary) !important;
  border-bottom-color: var(--primary) !important;
}

[data-theme="dark"] .tab.active,
[data-theme="dark"] .tab[aria-selected="true"] {
  color: var(--accent-gold) !important;
  border-bottom-color: var(--accent-gold) !important;
}

.tab .icon-svg { width: 15px; height: 15px; opacity: 0.85; }

/* --- Content area: flat, no heavy box --- */
.content-area {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  min-height: 400px;
}

/* --- Chart containers: tonal tinted backgrounds (NOT pure white) --- */
.chart-container {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-xl) !important;
  padding: 24px !important;
  margin-top: var(--s-5) !important;
  box-shadow: none !important;
  position: relative;
}

.chart-container:first-child { margin-top: 0 !important; }

/* Grid wrappers (.grid-auto / .grid-auto--lg) act as "row" containers for
   chart-containers in the dashboard section flow. They need the same
   sibling-spacing rhythm as chart-containers, and their children must NOT
   add their own margin-top (the grid's gap handles intra-row spacing).

   Same rhythm applies to bare list containers that sit directly under
   chart-containers (expense list under filters, inbox list under tabs, …). */
.content-section > .grid-auto,
.content-section > .grid-auto--lg,
.content-section > .grid-auto--sm,
.content-section > #expensesList,
.content-section > #inboxList,
.content-section > #inboxTabs,
.content-section > #inboxBulkBar {
  margin-top: var(--s-5);
}

.content-section > .grid-auto:first-child,
.content-section > .grid-auto--lg:first-child,
.content-section > .grid-auto--sm:first-child,
.content-section > #expensesList:first-child,
.content-section > #inboxList:first-child {
  margin-top: 0;
}

.grid-auto > .chart-container,
.grid-auto--lg > .chart-container,
.grid-auto--sm > .chart-container {
  margin-top: 0 !important;
}

.chart-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  flex-wrap: wrap;
  gap: var(--s-3);
  padding-bottom: 16px !important;
  margin-bottom: 18px !important;
  border-bottom: 1px dashed var(--border) !important;
}

.chart-title {
  font-family: var(--font-display) !important;
  font-size: 18px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 48;
}

.chart-title .icon-svg { width: 18px; height: 18px; }

.chart-legend { display: none !important; }

/* Net Worth hero card: signature moment */
#netWorthCard {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-tint-green) 100%) !important;
  border: 1px solid var(--border-strong) !important;
  position: relative;
}

#netWorthCurrent {
  font-size: 40px !important;
  font-weight: 500 !important;
  letter-spacing: -0.03em !important;
  font-variation-settings: 'opsz' 144 !important;
  line-height: 1.05;
  color: var(--text) !important;
}

#netWorthDelta {
  font-family: var(--font-mono) !important;
  font-size: 16px !important;
  font-weight: 600 !important;
  font-feature-settings: 'tnum' 1;
}

/* Goals card: celebratory but refined */
#goalsCard {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}

#goalsGrid .stat-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%) !important;
}

/* --- Section header (page titles) --- */
.section-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-bottom: var(--s-6) !important;
  padding-top: 4px;
}

/* --- Buttons: refined, with subtle shine on primary --- */
.btn-primary,
button.btn-primary,
.btn--primary,
button.btn--primary {
  background: var(--primary) !important;
  color: var(--surface-hero-text) !important;
  padding: 11px 20px !important;
  border-radius: var(--r-md) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 0 rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.1) !important;
  border: none !important;
  transition: all var(--dur-fast) var(--ease) !important;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover:not(:disabled),
.btn--primary:hover:not(:disabled) {
  background: var(--primary-500) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31,77,58,0.2), inset 0 1px 0 rgba(255,255,255,0.15) !important;
}

[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn--primary {
  background: var(--primary) !important;
  color: var(--gray-900) !important;
}

.btn-secondary,
button.btn-secondary,
.btn--secondary,
button.btn--secondary {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-strong) !important;
  padding: 11px 20px !important;
  border-radius: var(--r-md) !important;
  font-weight: 500 !important;
  font-size: 13px !important;
}

.btn-secondary:hover,
.btn--secondary:hover {
  background: var(--surface-muted) !important;
}

.btn-success {
  background: var(--primary-500) !important;
  color: #ffffff !important;
  border: none !important;
}

.btn-success:hover:not(:disabled) {
  background: var(--primary-600) !important;
  box-shadow: 0 4px 12px rgba(31, 77, 58, 0.22) !important;
}

.btn-warning {
  background: var(--accent-gold) !important;
  color: var(--gray-900) !important;
  border: none !important;
}

.btn-danger,
.btn--danger {
  background: var(--danger) !important;
  color: #fff !important;
  border: none !important;
}

/* Ghost / icon buttons */
.btn--ghost {
  background: transparent !important;
  color: var(--text-muted) !important;
  border: 1px solid transparent !important;
}

.btn--ghost:hover {
  background: var(--surface-muted) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.btn--icon {
  padding: 8px !important;
  width: 38px;
  height: 38px;
}

/* --- Inputs: refined with warm borders --- */
input[type="text"], input[type="number"], input[type="date"],
input[type="password"], input[type="email"], select, textarea,
.form-input, .form-select, .form-control, .input {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--r-md) !important;
  padding: 11px 14px !important;
  font-size: 14px !important;
  font-family: var(--font-sans) !important;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast) !important;
}

input:focus, select:focus, textarea:focus,
.form-input:focus, .form-select:focus, .input:focus {
  outline: none !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(31,77,58,0.12) !important;
}

.form-label, .form-group label {
  color: var(--text) !important;
  font-weight: 600 !important;
  font-size: 12px !important;
  letter-spacing: 0.02em;
  margin-bottom: 6px !important;
  display: block;
}

/* --- Modal --- */
.modal {
  background: rgba(26, 22, 18, 0.55) !important;
  backdrop-filter: blur(8px);
}

[data-theme="dark"] .modal {
  background: rgba(0, 0, 0, 0.75) !important;
}

.modal-content {
  background: var(--surface-elevated) !important;
  color: var(--text) !important;
  border-radius: var(--r-xl) !important;
  box-shadow: var(--shadow-xl) !important;
  border: 1px solid var(--border);
}

.modal-header {
  border-bottom: 1px solid var(--border) !important;
  font-family: var(--font-display) !important;
}

.modal-title {
  color: var(--text) !important;
  font-family: var(--font-display) !important;
  font-weight: 500 !important;
}

/* --- Notification bell + header icons: warm hover --- */
.bell, .theme-toggle {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--text-muted) !important;
}

.bell:hover, .theme-toggle:hover {
  background: var(--surface-muted) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* --- Investment / credit card / bill list items --- */
.investment-card,
.credit-card-item,
.bill-item {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  border-radius: var(--r-lg) !important;
}

.investment-card:hover,
.bill-item:hover {
  border-color: var(--primary-accent) !important;
  box-shadow: 0 6px 16px rgba(38,35,29,0.06) !important;
}

/* --- Timeline grid (cashflow) --- */
.timeline-row {
  border-color: var(--border) !important;
}

.timeline-cell {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.timeline-cell.positive { color: var(--success) !important; }
.timeline-cell.negative { color: var(--danger) !important; }

.timeline-label {
  color: var(--text-muted) !important;
  background: var(--surface-muted) !important;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* --- ApexCharts: warm-friendly --- */
.apexcharts-legend-text { color: var(--text) !important; font-family: var(--font-sans) !important; }
.apexcharts-tooltip {
  background: var(--surface-elevated) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-md) !important;
  font-family: var(--font-sans) !important;
}
.apexcharts-xaxistooltip, .apexcharts-yaxistooltip {
  background: var(--surface-elevated) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.apexcharts-yaxis-label, .apexcharts-xaxis-label {
  font-family: var(--font-mono) !important;
  font-size: 10px !important;
  fill: var(--text-muted) !important;
}
.apexcharts-gridline { stroke: var(--border) !important; }

/* --- Badge: warm tinted chips --- */
.badge {
  background: var(--surface-muted) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge--success { background: var(--surface-tint-green) !important; color: var(--primary) !important; border-color: var(--primary-accent) !important; }
.badge--warning { background: var(--surface-tint-gold) !important; color: var(--warning-text) !important; border-color: var(--accent-gold) !important; }
.badge--danger  { background: var(--surface-tint-terra) !important; color: var(--danger) !important; border-color: var(--secondary) !important; }

/* --- Person avatars (letter-based, colored ring) --- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}
.avatar--person1 { background: var(--person1-bg); color: var(--person1); box-shadow: inset 0 0 0 2px var(--person1); }
.avatar--person2 { background: var(--person2-bg); color: var(--person2); box-shadow: inset 0 0 0 2px var(--person2); }
.avatar--couple  { background: linear-gradient(135deg, var(--person1-bg), var(--person2-bg)); color: var(--text); box-shadow: inset 0 0 0 2px var(--primary); }

/* --- Setup + Login pages --- */
.setup-container {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 1px 0 rgba(200, 169, 81, 0.2), 0 20px 60px rgba(38,35,29,0.06) !important;
  padding: 44px !important;
  position: relative;
  z-index: 1;
  border-radius: 20px !important;
}

.setup-container::before {
  content: '';
  position: absolute; top: 0; left: 40px; right: 40px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), var(--primary), transparent);
}

.setup-header h1, .login-container h1 {
  font-family: var(--font-display) !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  font-variation-settings: 'opsz' 96;
  letter-spacing: -0.02em;
}

.setup-header p { color: var(--text-muted) !important; }

.person-section {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  padding: 24px !important;
  transition: border-color var(--dur-fast);
}

.person-section:first-of-type { border-left: 3px solid var(--person1) !important; }
.person-section:last-of-type  { border-left: 3px solid var(--person2) !important; }

.person-section h2 {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  white-space: nowrap !important;
  color: var(--text) !important;
  font-family: var(--font-display) !important;
  font-weight: 500 !important;
  font-size: 20px !important;
  font-variation-settings: 'opsz' 48;
  margin-bottom: 20px !important;
}

.person-section:first-of-type h2 .icon-svg { color: var(--person1) !important; }
.person-section:last-of-type  h2 .icon-svg { color: var(--person2) !important; }

/* Raw inputs in auth containers stretch to the full form width so they
   visually match the label above and the primary button below.
   (The design-system `class="input"` already has this behavior via
   components.css — this catches raw inputs without the class.) */
.login-container .form-group input:not([type="checkbox"]):not([type="radio"]),
.setup-container .form-group input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
}

.setup-btn, .login-btn {
  width: 100%;
  justify-content: center;
  background: var(--primary) !important;
  color: var(--surface-hero-text) !important;
  border: none !important;
  border-radius: var(--r-md) !important;
  padding: 14px 22px !important;
  font-family: var(--font-sans) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 0 rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.08) !important;
  transition: all var(--dur-fast) var(--ease) !important;
}

.setup-btn:hover:not(:disabled),
.login-btn:hover:not(:disabled) {
  background: var(--primary-500) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 16px rgba(31,77,58,0.22), inset 0 1px 0 rgba(255,255,255,0.1) !important;
}

[data-theme="dark"] .setup-btn,
[data-theme="dark"] .login-btn {
  background: var(--primary) !important;
  color: var(--gray-900) !important;
}

.login-container {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 1px 0 rgba(200, 169, 81, 0.2), 0 20px 60px rgba(38,35,29,0.06) !important;
  position: relative;
  z-index: 1;
}

.login-container::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), var(--primary), transparent);
}

/* --- Recent transactions / legacy empty states --- */
[style*="color: var(--gray)"] { color: var(--text-muted) !important; }

/* --- Toast & notifications --- */
.toast-container { z-index: 9999; }

/* --- Command palette --- */
.cmdk {
  background: var(--surface-elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
  box-shadow: var(--shadow-xl);
}

.cmdk__input {
  font-family: var(--font-sans) !important;
  font-size: 15px !important;
  color: var(--text) !important;
  background: transparent !important;
}

.cmdk__item {
  color: var(--text) !important;
  font-family: var(--font-sans);
}

.cmdk__item:hover,
.cmdk__item[aria-selected="true"] {
  background: var(--surface-muted) !important;
}

/* --- Telegram pairing walkthrough: numbered step list + code/command helpers --- */
.tg-pairing {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tg-pairing__intro { margin-bottom: 2px; }

.tg-pairing__eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 4px;
}

.tg-pairing__lead {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.tg-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tg-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.tg-step--active {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary) inset;
}

.tg-step--done {
  background: var(--success-bg);
  border-color: var(--success);
}

.tg-step--pending { opacity: 0.72; }

/* Informational step (used in the BotFather setup walkthrough — not a
   state-of-progress indicator, just a numbered instruction). No primary glow,
   no dim; soft primary-tinted marker. */
.tg-step--info { opacity: 1; background: var(--surface); }

.tg-step--info .tg-step__marker {
  background: var(--primary-100);
  color: var(--primary);
  border-color: var(--primary-100);
}

[data-theme="dark"] .tg-step--info .tg-step__marker {
  color: var(--accent-gold);
}

.tg-step__marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-number);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.tg-step--active .tg-step__marker {
  background: var(--primary);
  color: var(--surface-hero-text);
  border-color: var(--primary);
}

[data-theme="dark"] .tg-step--active .tg-step__marker {
  color: var(--gray-900);
}

.tg-step__marker--done {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.tg-step__body { min-width: 0; }

.tg-step__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.35;
}

.tg-step--active .tg-step__title { color: var(--primary); }
[data-theme="dark"] .tg-step--active .tg-step__title { color: var(--accent-gold); }

.tg-step__desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.tg-step__desc code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  color: var(--text);
}

.tg-step__desc strong { color: var(--text); }

.tg-pairing__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.tg-pairing__footnote {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.tg-pairing__footnote:hover { color: var(--text); text-decoration: underline; }

.tg-pairing__linkbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  margin-top: 6px;
  background: var(--primary);
  color: var(--surface-hero-text);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease);
}

[data-theme="dark"] .tg-pairing__linkbtn { color: var(--gray-900); }

.tg-pairing__linkbtn:hover { background: var(--primary-500); }

.tg-pairing__hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.tg-pairing__copy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 6px 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.tg-pairing__command {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

.tg-pairing__copybtn { padding: 4px 8px !important; }

.tg-pairing__codebig {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
}

.tg-pairing__codelabel {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.tg-pairing__codevalue {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--primary);
}

[data-theme="dark"] .tg-pairing__codevalue { color: var(--accent-gold); }

.tg-pairing__waiting {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.tg-pairing__spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: tgPairSpin 1s linear infinite;
}

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

.tg-pairing__waitingmeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.tg-pairing__countdown { font-family: var(--font-mono); color: var(--text); }

/* Paired state */
.tg-pairing--paired { gap: 14px; }

.tg-pairing__success {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--success-bg);
  border: 1px solid var(--success);
  border-radius: var(--r-md);
}

.tg-pairing__successtitle {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  color: var(--text);
}

.tg-pairing__successmeta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tg-pairing__howto {
  padding: 14px 16px;
  background: var(--surface-muted);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

.tg-pairing__usage {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tg-pairing__usage li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.tg-pairing__usage li strong { color: var(--text); }

.tg-pairing__usage li code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  color: var(--text);
}

.tg-pairing__usageicon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 1px;
}

.tg-pairing__usageicon .icon-svg { width: 14px; height: 14px; }

[data-theme="dark"] .tg-pairing__usageicon { color: var(--accent-gold); }

/* Environment-variable code block inside a setup step. */
.tg-pairing__env {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
}

/* BotFather setup — collapsible below the pairing walkthrough. */
.tg-setup {
  margin-top: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.tg-setup[open] { background: var(--surface); }

.tg-setup__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  transition: background var(--dur-fast) var(--ease);
}

/* Hide the default ::-webkit-details-marker triangle */
.tg-setup__summary::-webkit-details-marker { display: none; }
.tg-setup__summary::marker { content: ''; }

.tg-setup__summary:hover,
.tg-setup__summary:focus-visible {
  background: var(--surface-muted);
  outline: none;
}

.tg-setup__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--primary);
  flex-shrink: 0;
}

[data-theme="dark"] .tg-setup__icon { color: var(--accent-gold); }

.tg-setup__icon .icon-svg { width: 15px; height: 15px; }

.tg-setup__summarytext {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.tg-setup__summarytext strong {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}

.tg-setup__summarytext span {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.tg-setup__summarytext code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: var(--r-xs);
  color: var(--text);
}

.tg-setup__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Rotate the nested <svg>. Driven by a JS-added .is-open class instead of
   the :has([open]) / [open] descendant selector — descendant transforms
   under <summary> were unreliable in our target renderer. */
.tg-setup__chevron .icon-svg {
  width: 16px;
  height: 16px;
  transform-origin: center;
  transition: transform var(--dur-fast) var(--ease);
}

.tg-setup.is-open .tg-setup__chevron .icon-svg { transform: rotate(180deg); }

.tg-setup__body {
  padding: 4px 14px 14px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}

/* --- Inline info button: tiny "?" / ⓘ affordance next to terms.
       Click → opens the glossary drawer via data-glossary delegation. --- */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: 4px;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  vertical-align: middle;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.info-btn .icon-svg { width: 13px; height: 13px; }

.info-btn:hover,
.info-btn:focus-visible {
  color: var(--primary);
  background: var(--surface-muted);
  outline: none;
}

.info-btn:focus-visible { box-shadow: var(--shadow-focus); }

/* --- Glossary drawer: right-docked panel over a backdrop.
       Uses the `.modal` class so the existing Modal helper handles focus trap
       + Esc-to-close + body scroll lock automatically. --- */
.modal.glossary-drawer {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-modal);
  justify-content: flex-end;
  align-items: stretch;
}

.modal.glossary-drawer.active {
  display: flex;
  animation: glossaryBackdropFade var(--dur-base) var(--ease);
}

.modal.glossary-drawer .glossary-drawer__panel {
  position: relative;
  width: 440px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-xl);
  padding: 28px 32px 32px;
  overflow-y: auto;
  animation: glossaryDrawerIn var(--dur-base) var(--ease);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal.glossary-drawer .glossary-drawer__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.modal.glossary-drawer .glossary-drawer__close .icon-svg { width: 18px; height: 18px; }

.modal.glossary-drawer .glossary-drawer__close:hover,
.modal.glossary-drawer .glossary-drawer__close:focus-visible {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border);
  outline: none;
}

.glossary-header { margin-top: 8px; }

.glossary-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.glossary-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0;
}

.glossary-short {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  margin: 0;
}

.glossary-section-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.005em;
  color: var(--primary);
  margin: 14px 0 -4px;
  text-transform: none;
}

.glossary-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}

.glossary-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-muted);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  color: var(--text);
}

.glossary-body strong { color: var(--text); }

.glossary-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Index view: list of all terms */
.glossary-index {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.glossary-index__item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.glossary-index__item:hover,
.glossary-index__item:focus-visible {
  background: var(--surface-muted);
  border-color: var(--border);
  outline: none;
}

.glossary-index__term {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.005em;
}

.glossary-index__short {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

@keyframes glossaryBackdropFade {
  from { background-color: rgba(0, 0, 0, 0); }
  to   { background-color: var(--surface-overlay); }
}

@keyframes glossaryDrawerIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@media (max-width: 640px) {
  .modal.glossary-drawer .glossary-drawer__panel {
    width: 100vw;
  }
}

/* --- Dev help: disable glossy transforms on reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .stat-card:hover,
  .btn-primary:hover,
  .btn--primary:hover,
  .setup-btn:hover,
  .login-btn:hover { transform: none !important; }
  .modal.glossary-drawer.active,
  .modal.glossary-drawer .glossary-drawer__panel { animation: none !important; }
}

/* --- Scrollbar warm tint --- */
* { scrollbar-width: thin; scrollbar-color: var(--gray-300) transparent; }
*::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
