:root {
  --bg: #000000;
  --surface: #131519;
  --surface-2: #1b1f24;
  --border: #262b31;
  --text: #ffffff;
  --text-muted: #868e96;
  --positive: #00ff7f;
  --negative: #fa8072;
  --gold: #4169e1;
  --font-body: 'IBM Plex Mono', ui-monospace, monospace;
  --font-mono: 'Neuton', Georgia, serif;
}

* { box-sizing: border-box; }

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

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 84px;
}

/* ---------- Ticker header ---------- */

.topbar {
  padding: 4px 4px 24px;
}

.topbar-label {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.ticker {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
}

.ticker-value {
  font-family: var(--font-mono);
  font-size: 42px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--gold);
}

.ticker-unit {
  font-size: 15px;
  color: var(--text-muted);
}

.ticker-cursor {
  color: var(--gold);
  animation: blink 1.1s step-start infinite;
  font-size: 32px;
  line-height: 1;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ---------- Dual ticker (RUB + USDT on dashboard) ---------- */

.ticker-dual {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
}

.ticker-block {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.ticker-dual .ticker-value {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.ticker-dual .ticker-value.ticker-rub {
  color: #ffffff;
}

.ticker-dual .ticker-value.ticker-gold {
  color: #ffffff;
}

.ticker-dual .ticker-unit {
  font-size: 14px;
  color: var(--text-muted);
}

.group-dots {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.group-dots span.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.card-subtitle {
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.7;
}

/* ---------- Balances list ---------- */

.balances-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.balance-row {
  display: grid;
  grid-template-columns: 1fr auto 44px;
  column-gap: 8px;
  align-items: center;
  font-size: 15.5px;
  padding: 7px 0;
}

.balance-row .name {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  overflow: hidden;
}

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

.acc-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.acc-avatar svg {
  width: 16px;
  height: 16px;
}

.balance-row .amount-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
  min-width: 64px;
}

.balance-row .amount-currency {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
}

.balance-group-header {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  margin-bottom: 2px;
}

.balance-group-header:first-child { margin-top: 0; }

/* ---------- Expense chart (hand-rolled SVG bars) ---------- */

.chart {
  width: 100%;
  height: 100px;
  overflow: visible;
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
}

/* ---------- Donut + legend ---------- */

.donut-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.donut {
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}

.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.legend-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.legend-row .label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-row .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-row .value {
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---------- Recent operations ---------- */

.recent-list {
  display: flex;
  flex-direction: column;
}

.recent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.recent-row:last-child { border-bottom: none; padding-bottom: 0; }
.recent-row:first-child { padding-top: 0; }

.recent-row .left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.recent-row .left-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.recent-row .desc {
  font-size: 15.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-row .meta {
  font-size: 13px;
  color: var(--text-muted);
}

.recent-row .amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15.5px;
  white-space: nowrap;
  padding-left: 10px;
}

.amount.positive { color: var(--positive); }
.amount.negative { color: var(--negative); }
.amount.neutral { color: var(--text); }

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 15.5px;
  padding: 40px 20px;
}

@media (prefers-reduced-motion: reduce) {
  .ticker-cursor { animation: none; }
}

/* ============================================================
   Multi-screen navigation (added for income/expense/accounts/
   categories screens)
   ============================================================ */

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 18px;
}

.screen-title {
  font-size: 24px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.fab {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--gold);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.fab:active {
  transform: scale(0.95);
}

/* ---------- Bottom tab bar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  padding: 7px 1px;
  cursor: pointer;
}

.tab-icon {
  width: 19px;
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.tab-label {
  font-size: 9.5px;
  font-weight: 500;
  text-align: center;
  line-height: 1.15;
}

.tab.active {
  color: var(--gold);
}
  color: var(--gold);
}

.tab.active .tab-label {
  font-weight: 600;
}

/* ---------- Forms ---------- */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15.5px;
  width: 100%;
}

.input:focus {
  outline: none;
  border-color: var(--gold);
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-row {
  display: flex;
  gap: 10px;
}

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

.btn {
  flex: 1;
  padding: 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #ffffff;
}

.btn:active {
  transform: scale(0.98);
}

.form-error {
  color: var(--negative);
  font-size: 13px;
  min-height: 14px;
}

/* ---------- Transaction list (income/expense screens) ---------- */

.tx-list {
  display: flex;
  flex-direction: column;
}

.tx-currency-header {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 0 4px;
}

.tx-currency-header:first-child { margin-top: 0; }

.tx-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 10px 0;
}

.tx-row .left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.tx-row .left-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.tx-row .desc {
  font-size: 15.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-row .meta {
  font-size: 13px;
  color: var(--text-muted);
}

.tx-row .amount-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15.5px;
  white-space: nowrap;
  padding-left: 10px;
  text-align: right;
  color: var(--text);
}

.tx-row .amount-value.positive { color: var(--positive); }
.tx-row .amount-value.negative { color: var(--negative); }

/* ---------- Swipe-to-delete (used by tx rows and account rows) ---------- */

.swipe-item {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

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

.swipe-delete-bg {
  position: absolute;
  inset: 0;
  background: var(--negative);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 18px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.swipe-content {
  position: relative;
  background: var(--surface);
  touch-action: pan-y;
  will-change: transform;
}

/* ---------- Account rows (accounts screen) ---------- */

.balance-row.in-swipe {
  padding: 7px 0;
}

/* ---------- Category rows with limit progress ---------- */

.category-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.category-row:last-child { border-bottom: none; padding-bottom: 0; }
.category-row:first-child { padding-top: 0; }

.category-row .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15.5px;
  margin-bottom: 6px;
}

.category-row .amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.category-row .amount.over-limit {
  color: var(--negative);
}

.category-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.category-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
}

.category-progress-fill.over-limit {
  background: var(--negative);
}

/* ---------- Exchange screen ---------- */

.exchange-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exchange-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.exchange-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.exchange-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exchange-amount {
  text-align: right;
  font-family: var(--font-mono);
  width: 100%;
}

.exchange-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
}

.exchange-rate {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 4px 0;
}

/* ---------- Savings goals screen ---------- */

.goals-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.goal-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.goal-row:last-child { border-bottom: none; padding-bottom: 0; }
.goal-row:first-child { padding-top: 0; }

.goal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.goal-name {
  font-size: 15.5px;
  color: var(--text);
}

.goal-saved {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--positive);
}

.goal-percent-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.goal-saved-input {
  width: 84px;
  text-align: right;
  padding: 5px 6px;
  font-size: 13px;
  font-family: var(--font-mono);
}

.goal-percent-input {
  width: 58px;
  text-align: right;
  padding: 5px 6px;
  font-size: 13px;
  font-family: var(--font-mono);
}

.goal-percent-mini {
  width: 58px;
}

/* ---------- Quick action buttons (dashboard, under the balance) ---------- */

.quick-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.quick-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}

.quick-action:active {
  transform: scale(0.97);
}

.quick-action-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

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

.goal-save-status {
  font-size: 11px;
  color: var(--positive);
  min-width: 60px;
}

/* ---------- History screen ---------- */

.history-period-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.history-period-btn {
  flex: 1;
  padding: 9px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}

.history-period-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #ffffff;
}

input[type="date"].input {
  width: 92%;
  max-width: 92%;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 10px 8px;
  font-size: 14px;
  min-width: 0;
  text-align: center;
}
