:root {
  --bg: #f2f4fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #7a8399;
  --accent: #4f6df5;
  --accent-dark: #3b55cc;
  --danger: #e5534b;
  --ok: #2f9e6e;
  --warn: #e8963c;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.app { max-width: 520px; margin: 0 auto; padding: 16px 16px 100px; }
header { padding: 12px 4px 4px; }
h1 { font-size: 24px; }
.subtitle { color: var(--muted); font-size: 14px; margin-top: 4px; }

.profile-btn {
  margin-top: 8px;
  border: none;
  background: var(--card);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  box-shadow: 0 1px 3px rgba(30,40,80,.08);
  cursor: pointer;
}

.tabs { display: flex; gap: 6px; margin: 16px 0; background: #e6e9f5; padding: 4px; border-radius: 12px; }
.tab {
  flex: 1; border: none; background: transparent; padding: 10px 4px;
  border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(30,40,80,.12); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: 0 1px 4px rgba(30,40,80,.07); }
.stat-value { display: block; font-weight: 700; font-size: 17px; }
.stat-label { font-size: 11px; color: var(--muted); }

.notify-btn {
  width: 100%; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; padding: 12px; border-radius: 14px; font-size: 15px; margin-bottom: 14px; cursor: pointer;
}

.list { display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 15px; }

.item {
  background: var(--card); border-radius: 16px; padding: 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 4px rgba(30,40,80,.07);
}
.item.paid { opacity: .55; }
.item.paid .item-name { text-decoration: line-through; }
.item-cat {
  font-size: 22px; width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border-radius: 12px; flex-shrink: 0;
}
.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; margin-left: 6px; }
.badge.danger { background: #fdeceb; color: var(--danger); }
.badge.warn { background: #fdf3e7; color: var(--warn); }
.badge.ok { background: #e9f7f0; color: var(--ok); }
.item-right { text-align: right; flex-shrink: 0; }
.item-amount { font-weight: 700; font-size: 16px; }
.item-actions { margin-top: 4px; display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { border: none; background: var(--bg); border-radius: 8px; width: 30px; height: 30px; font-size: 14px; cursor: pointer; }
.icon-btn.pay { background: #e9f7f0; }
.icon-btn.big { width: 40px; height: 40px; font-size: 20px; }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.month-nav strong { font-size: 17px; text-transform: capitalize; }

.progress-wrap { height: 10px; background: #e6e9f5; border-radius: 6px; overflow: hidden; margin-bottom: 18px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 6px; transition: width .3s; }
.progress-bar.over { background: linear-gradient(90deg, var(--warn), var(--danger)); }

.section-title { font-size: 15px; margin: 18px 0 10px; color: var(--muted); }
.cat-bar-wrap { height: 6px; background: #e6e9f5; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.cat-bar { height: 100%; background: var(--accent); border-radius: 4px; }

.fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-size: 30px; box-shadow: 0 6px 16px rgba(79,109,245,.4); cursor: pointer;
}

.modal { position: fixed; inset: 0; background: rgba(20,25,45,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card); width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
.modal-card h2 { font-size: 18px; }
label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
input, select { font-size: 16px; padding: 10px 12px; border: 1px solid #dde1ec; border-radius: 10px; background: #fafbfe; outline-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.btn { flex: 1; padding: 12px; border-radius: 12px; font-size: 15px; border: none; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--bg); color: var(--text); }

.user-card { align-items: center; text-align: center; }
.user-hint { font-size: 13px; color: var(--muted); }
.user-choice { display: flex; gap: 12px; width: 100%; margin-top: 6px; }
.user-option {
  flex: 1; border: 2px solid #dde1ec; background: #fafbfe; border-radius: 14px;
  padding: 18px 10px; font-size: 40px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.user-option span { font-size: 15px; font-weight: 600; color: var(--text); }
.user-option:active { border-color: var(--accent); }
