:root {
  /* Tokyo Night VSCode (enkia) colors */
  --bg: #1a1b26;
  --bg-dark: #16161e;
  --card: #1e202e;
  --line: rgba(84,92,126,0.32);
  --text: #a9b1d6;
  --muted: #787c99;
  --blue: #6183bb;
  --blue-soft: rgba(61,89,161,0.30);
  --blue-border: rgba(84,92,126,0.55);
  --blue-glow: rgba(97,131,187,0.28);
  --white-soft: rgba(126,131,178,0.10);
  --white-mid: rgba(126,131,178,0.18);
  --white-high: rgba(172,176,208,0.28);
  --danger: #f7768e;
  --danger-soft: rgba(247,118,142,0.18);
  --success: #9ece6a;
  /* Spacing scale */
  --space-1: 2px; --space-2: 4px; --space-3: 6px; --space-4: 8px;
  --space-5: 10px; --space-6: 12px; --space-7: 14px; --space-8: 16px;
  --space-9: 18px; --space-10: 22px; --space-11: 24px; --space-12: 28px;
  --space-13: 32px; --space-14: 40px;
  /* Radius scale */
  --radius-sm: 10px; --radius-md: 14px; --radius-lg: 16px;
  --radius-xl: 18px; --radius-2xl: 20px; --radius-3xl: 22px;
  --radius-4xl: 24px; --radius-pill: 999px;
  /* Shadows */
  --shadow-card: inset 0 1px 0 rgba(172,176,208,0.04), 0 14px 30px rgba(0,0,0,0.22);
  --shadow-card-sm: inset 0 1px 0 rgba(172,176,208,0.05), 0 10px 24px rgba(0,0,0,0.26);
  --shadow-income: inset 0 1px 0 var(--line), 0 14px 32px rgba(61,89,161,0.18);
  --shadow-savings: inset 0 1px 0 var(--line), 0 14px 32px rgba(115,218,202,0.14);
  /* Typography */
  --text-xs: 11px; --text-sm: 12px; --text-md: 13px; --text-base: 14px;
  --text-lg: 15px; --text-xl: 16px; --text-2xl: 17px; --text-3xl: 18px;
  --text-4xl: 22px; --text-5xl: 24px; --text-6xl: 28px; --text-7xl: 40px;
  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.32,0.72,0,1);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top, #202330 0%, #1a1b26 42%, #16161e 100%);
  color: var(--text);
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  padding-top: env(safe-area-inset-top);
  overscroll-behavior: none;
}
#app { max-width: 460px; margin: 0 auto; min-height: 100vh; padding: 8px 14px max(28px, calc(env(safe-area-inset-bottom) + 12px)); }
.header { display:flex; align-items:center; justify-content:space-between; padding: 2px 0 10px; min-height: 32px; }
.header-home { min-height: 6px; padding: 0; }
.app-title { font-size: 18px; font-weight: 700; }
.icon-btn, .back-btn, .pill-btn, .bottom-btn, .primary-btn, .danger-btn {
  border: 1px solid var(--line); color: var(--text); background: var(--line); border-radius: 18px; padding: 12px 16px; cursor:pointer;
}
.top-spacer { height: 6px; }
.section { margin-top: 14px; }
.chart-card, .card, .big-card, .form-card, .modal-box {
  background: rgba(30,32,46,0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius-4xl);
  box-shadow: var(--shadow-card);
}
.chart-card {
  padding: 18px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.chart-card-large {
  padding: 6px 10px 6px;
  min-height: 306px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
.chart-wrap { display:flex; align-items:center; gap:16px; }
.chart-wrap-large {
  justify-content:center;
  width: 100%;
  padding-top: 0;
  margin-top: -4px;
}
#pieCanvas { width: 284px; height: 284px; max-width: 100%; display:block; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; filter: none; }
.legend { flex:1; display:flex; flex-direction:column; gap:8px; }
.legend-row { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:14px; }
.legend-left { display:flex; align-items:center; gap:8px; min-width:0; }
.swatch { width:10px; height:10px; border-radius:99px; }
.card-list { display:flex; flex-direction:column; gap:10px; margin-top: 14px; }
.big-card {
  padding: 18px 18px;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  border-radius: var(--radius-4xl);
  min-height: 82px;
}
.big-card-left { display:flex; align-items:center; gap:14px; min-width:0; }
.big-card-emoji { font-size: 28px; }
.big-card-title { font-size: 18px; font-weight: 700; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
.big-card-right { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.amount-badge {
  min-width: 84px; max-width: 116px; text-align:right; padding: 0; border-radius: 0; background: transparent; font-size: 14px; line-height: 1.2; font-weight: 800; white-space: normal; word-break: break-word; box-shadow: none;
}
.chev { opacity: 0.7; font-size: 20px; }
.bottom-actions { display:flex; flex-direction:column; gap:12px; margin-top:16px; padding-bottom: env(safe-area-inset-bottom); }
.bottom-btn { font-size: 18px; text-align:left; padding: 18px 18px; border-radius: 22px; }
.bottom-btn .plus { font-size: 34px; margin-right: 12px; vertical-align: middle; }
.screen-title { font-size: 22px; font-weight:700; margin: 8px 0 12px; }
.cat-total { padding: 18px 18px; display:flex; align-items:center; justify-content:space-between; gap: 12px; font-size:18px; margin-bottom:14px; border-radius: 22px; }
.cat-total-title { font-size: 17px; font-weight: 600; }
.cat-total-amount { font-size: 28px; font-weight: 800; white-space: nowrap; }
.chips { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
.chip { padding: 10px 12px; border-radius: 14px; border:1px solid var(--line); background: rgba(126,131,178,0.10); color: var(--text); cursor:pointer; font-size:15px; }
.chip.active { background: var(--blue-soft); border-color: var(--blue-border); }
.chip-add { width:40px; text-align:center; padding: 10px 0; }
.label { display:block; margin: 14px 0 8px; font-size: 16px; color: var(--muted); }
.input, .select, textarea {
  width: 100%; padding: 16px 16px; font-size: 17px; border-radius: 18px; border:1px solid var(--line); background: var(--line); color: var(--text); outline:none;
}
.input:focus-visible,
.select:focus-visible,
textarea:focus-visible,
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-glow);
  border-color: var(--blue);
}
.input-large, .select-symbol {
  height: 60px;
  min-height: 60px;
}
.input-large { font-size: 18px; }
.select-symbol {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  padding-left: 12px;
  padding-right: 12px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
}
.select-symbol::-ms-expand { display: none; }
textarea { min-height: 108px; resize: vertical; }
.row { display:flex; align-items:center; gap:12px; }
.primary-btn { background: linear-gradient(180deg, #6183bb, #3d59a1); border: none; width:100%; font-size:18px; padding:16px; border-radius: 18px; }
.primary-btn-compact { margin-top: 10px; }
.primary-btn-large { min-height: 62px; font-size: 19px; }
.expense-form-card { background: rgba(30,32,46,0.72); border: 1px solid var(--line); border-radius: 22px; padding: 16px; }
.expense-form-card-large { padding: 18px; border-radius: 24px; }
.input-row { display: flex; gap: 10px; align-items: flex-end; }
.input-col { min-width: 0; }
.input-col-main { flex: 1; }
.input-col-currency { width: 92px; }
.input-col-currency .label { text-align: center; }
.transactions { margin-top: 18px; }
.category-chart-card {
  margin-top: 14px;
  background: rgba(30,32,46,0.72);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}
.category-chart-title { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.category-chart-list { display: flex; flex-direction: column; gap: 10px; }
.category-chart-row { display: flex; flex-direction: column; gap: 6px; }
.category-chart-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.category-chart-name { color: var(--text); }
.category-chart-amount { color: var(--muted); white-space: nowrap; }
.category-chart-track {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.category-chart-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7aa2f7 0%, #bb9af7 100%);
}
.tx-row { display:flex; align-items:center; justify-content:space-between; padding: 16px 2px; border-bottom: 1px solid var(--line); gap: 12px; }
.tx-left { min-width:0; }
.tx-sub { font-size: 18px; }
.tx-note { font-size: 12px; color: var(--muted); margin-top:4px; }
.tx-meta { font-size: 11px; font-weight: 300; color: var(--muted); margin-top: 4px; }
.tx-right { display:flex; align-items:center; gap:12px; flex-shrink:0; }
.tx-amount { font-size: 18px; font-weight:700; }
.tx-del { color: #f7768e; background:none; border:none; font-size: 24px; cursor:pointer; }
.modal {
  position: fixed; inset: 0; background: rgba(22,22,30,0.72); display:none; align-items:flex-end; justify-content:center; padding:16px;
}
.modal.show { display:flex; }
.modal-box { width:100%; max-width:460px; padding:18px; border-radius: 24px; }
.modal-title { font-size: 18px; font-weight:700; margin-bottom:10px; }
.modal-actions { display:flex; gap:10px; margin-top:14px; }
.modal-actions > * { flex:1; }
.colors { display:flex; flex-wrap:wrap; gap:10px; margin-top:10px; }
.color-dot { width:34px; height:34px; border-radius:999px; border:2px solid var(--white-high); cursor:pointer; }
.color-dot.active { outline: 3px solid var(--blue-glow); }
.small-note { color: var(--muted); font-size: 13px; margin-top:8px; }
.hidden { display:none; }
@media (max-width: 380px) {
  #app { padding: 8px 10px 24px; }
  .chart-card-large { min-height: 340px; padding: 18px 10px 20px; }
  #pieCanvas { width: 300px; height: 300px; }
  .big-card { padding: 15px; min-height: 76px; }
  .big-card-title { font-size:16px; }
  .amount-badge { min-width: 58px; padding: 8px 10px; font-size: 14px; }
  .chip { font-size: 14px; padding: 9px 10px; }
  .cat-total-amount { font-size: 24px; }
  .input-row { gap: 8px; }
  .input-col-currency { width: 78px; }
  .select-symbol { font-size: 22px; }
  .bottom-btn { font-size:16px; }
}

.users-modal-box { max-height: 88vh; overflow: auto; }
.users-list { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.user-card { background: var(--white-soft); border: 1px solid var(--line); border-radius: 20px; padding: 14px; }
.user-card-main { margin-bottom: 12px; }
.user-name-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.user-name { font-size: 17px; font-weight: 700; }
.user-meta { font-size: 13px; color: var(--muted); margin-top: 6px; word-break: break-word; }
.user-actions { display: flex; gap: 10px; align-items: center; }
.user-role-select { flex: 1; min-width: 0; }
.user-delete-btn { width: auto; padding: 14px 16px; border-radius: 16px; }
.role-badge { display:inline-flex; align-items:center; justify-content:center; border-radius:999px; padding:6px 10px; font-size:12px; font-weight:700; }
.role-owner { background: rgba(224,175,104,0.18); color: #e0af68; }
.role-admin { background: var(--blue-soft); color: var(--blue); }
.role-user { background: var(--white-mid); color: var(--text); }

.chart-card-empty { min-height: 320px; justify-content: center; text-align: center; gap: 10px; }
.chart-empty-icon { font-size: 44px; opacity: 0.9; }
.chart-empty-title { font-size: 22px; font-weight: 800; }
.chart-empty-text { color: var(--muted); font-size: 14px; line-height: 1.45; max-width: 260px; margin: 0 auto; }
.donut-shell { position: relative; width: 320px; height: 320px; display:flex; align-items:center; justify-content:center; }

.chart-top-row { display:flex; justify-content:flex-end; margin-bottom: 2px; }
.chart-top-row-left { justify-content:flex-start; }
.chart-top-row-split { justify-content:space-between; align-items:flex-start; gap:10px; margin-bottom: 0; padding: 0 8px; }
.chart-balance-chip { display:inline-flex; align-items:center; justify-content:center; padding:8px 12px; border-radius:18px; background: var(--white-soft); border: 1px solid var(--line); color: var(--text); font-size: 13px; font-weight: 700; white-space: nowrap; }
.donut-shell-large { width: 320px; height: 320px; }

.month-switcher { display:flex; align-items:center; justify-content:space-between; gap:10px; margin: 0 0 6px; }
.month-nav-btn { width:40px; height:40px; border:none; border-radius:14px; background: var(--line); color: var(--text); font-size:24px; line-height:1; }
.month-label { flex:1; text-align:center; font-size:15px; font-weight:700; text-transform:capitalize; }
.chart-balance-chip-stack { display:flex; flex-direction:column; align-items:flex-start; justify-content:center; gap:2px; min-height:52px; }
.chart-balance-chip-stack strong { font-size:15px; line-height:1.1; }
.chart-balance-chip-stack span { font-size:12px; color: var(--muted); }
.chart-balance-chip-right { align-items:flex-end; text-align:right; }

.chart-card-premium { background: transparent; border-color: transparent; box-shadow: none; }
.income-card {  box-shadow: var(--shadow-income);}

.double-donut-svg { width: 320px; height: 320px; max-width: 100%; display: block; }
.donut-segment { transition: opacity 0.2s ease; }

.month-label-wide { width: 100%; }
.header-home .app-title { font-size: 0; min-height: 0; }


.chart-balance-plain { background: transparent; border: none; padding: 0; min-height: auto; }
.chart-balance-plain span { display: none; }
.chart-balance-plain strong { font-size: 18px; }

.amount-subnote { font-size: 11px; color: var(--muted); margin-top: 4px; }
.savings-card {  box-shadow: var(--shadow-savings);}
.donut-center-block { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; padding: 0 72px; }
.donut-center-progress { font-size: 40px; font-weight: 800; line-height: 1; }

.amount-badge-savings { max-width: 132px; }
.savings-inline-note { margin: 4px 0 12px; }

.input-row-no-labels { margin-top: 2px; }
#noteInput { margin-top: 10px; }

.select-trigger { display:flex; align-items:center; justify-content:center; }
.currency-picker { display:grid; grid-template-columns: repeat(4, 1fr); gap:8px; margin: 10px 0 8px; }
.currency-option { border:1px solid var(--line); background: rgba(126,131,178,0.10); color: var(--text); border-radius:16px; min-height:46px; font-size:24px; font-weight:700; }
.currency-option.active { background: var(--blue-soft); border-color: var(--blue-border); }

.currency-picker.hidden { display: none; }



.donut-percent-label { fill: var(--text); font-size: 13px; font-weight: 800; paint-order: stroke; stroke: rgba(22,22,30,0.82); stroke-width: 4px; stroke-linejoin: round; }


.chips-compact { gap:5px; margin-bottom:12px; }
.chip-compact { padding: 6px 9px; border-radius: 11px; font-size: 13px; line-height: 1.1; min-height: 34px; }
.subchip-wrap { display:inline-flex; align-items:center; gap:3px; max-width: 100%; }
.subchip-wrap .chip-compact { max-width: 100%; }
.subchip-wrap.editing .chip-compact { padding-right: 6px; }
.subchip-del { width:18px; height:18px; border:none; border-radius:999px; background: var(--danger-soft); color:#f7768e; font-size:12px; line-height:1; padding:0; }

.chip-icon { min-width: 34px; width: 34px; text-align: center; padding-left: 0; padding-right: 0; }

/* Session cards */
.sessions-list { display:flex; flex-direction:column; gap:8px; margin-top:8px; }
.session-card {
  background: rgba(30,32,46,0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.session-current { background: rgba(158,206,106,0.10); }
.session-card-main { flex: 1; min-width: 0; }
.session-suffix { font-size: 14px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.session-badge { background: #9ece6a; color: var(--text); font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.session-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; word-break: break-word; }
.session-dates { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 1px; margin-top: 4px; }
.session-delete-btn { padding: 8px 12px; font-size: 12px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(180deg, #6183bb, #3d59a1);
  color: var(--text);
}

.inline-edit-mode {
  background: rgba(30,32,46,0.94) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow-card) !important;
  padding: 10px 14px !important;
  min-height: auto !important;
  display: flex;
  align-items: center;
  position: relative;
}
.inline-edit-single {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.inline-edit-single input {
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  outline: none;
  width: 100%;
}

.inline-edit-color-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  border: 2px solid var(--blue-border);
  box-shadow: 0 0 0 3px var(--line);
  padding: 0;
  cursor: pointer;
}

.inline-edit-palette {
  position: absolute;
  right: 54px;
  top: calc(100% + 8px);
  z-index: 50;
  flex-wrap: wrap;
  gap: 8px;
  width: 172px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(30,32,46,0.98);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}

.inline-edit-color {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--white-high);
  padding: 0;
  cursor: pointer;
}
