* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #17212b;
  --card: #232e3c;
  --card-hover: #2b3846;
  --text: #ffffff;
  --text-secondary: #7d8b99;
  --accent: #5288c1;
  --green: #4fae4e;
  --red: #e53935;
  --orange: #f5a623;
  --border: #101921;
}

body[data-theme="light"] {
  --bg: #f0f4f8;
  --card: #ffffff;
  --card-hover: #f5f5f5;
  --text: #000000;
  --text-secondary: #707579;
  --border: #e0e0e0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
  padding-bottom: 40px;
  -webkit-font-smoothing: antialiased;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

.error {
  text-align: center;
  padding: 40px 20px;
  color: var(--red);
  font-size: 15px;
}

/* Заголовок */
.header {
  text-align: center;
  margin-bottom: 20px;
}

.header h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.updated {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Главная карточка — общий баланс */
.total-card {
  background: linear-gradient(135deg, var(--accent) 0%, #3d6e9e 100%);
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 12px;
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(82, 136, 193, 0.3);
}

.total-card .label {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 6px;
}

.total-card .amount {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

/* Чистый баланс */
.net-card {
  background: var(--card);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.net-card .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.net-card .amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--green);
}

.net-card .amount.negative {
  color: var(--red);
}

.net-card .breakdown {
  text-align: right;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.net-card .breakdown .plus {
  color: var(--green);
}

.net-card .breakdown .minus {
  color: var(--red);
}

/* Разделы */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 20px 0 10px 4px;
}

/* Кошельки */
.wallets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wallet {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  transition: background 0.15s;
}

.wallet:active {
  background: var(--card-hover);
}

.wallet .name {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.wallet .balance {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.wallet .balance.negative {
  color: var(--red);
}

/* Статистика */
.stats {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 10px;
}

.stats .period {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 600;
}

.stats .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.stats .row:last-child {
  border-bottom: none;
}

.stats .income {
  color: var(--green);
  font-weight: 600;
}

.stats .expense {
  color: var(--red);
  font-weight: 600;
}

/* Топ категории */
.top-cats {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.top-cats .cat {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.top-cats .cat .sum {
  color: var(--text);
  font-weight: 600;
}

/* Долги */
.debts-empty {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.debt-block {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
}

.debt-block .debt-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.debt-block .debt-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.debt-block .debt-item:last-child {
  border-bottom: none;
}

.debt-block .debt-item .person {
  color: var(--text);
}

.debt-block .debt-item .amount {
  font-weight: 600;
}

.debt-block.i-owe .amount {
  color: var(--red);
}

.debt-block.owe-me .amount {
  color: var(--green);
}