/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-m);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 18px;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: .75; transform: scale(.97); }

.btn--primary { background: var(--color-accent); color: #fff; }
.btn--ghost { background: var(--color-surface-2); color: var(--color-text); }
.btn--danger { background: rgba(255,59,48,.1); color: var(--color-expense); }
.btn--icon {
  background: var(--color-surface-2);
  width: 40px; height: 40px;
  border-radius: 50%;
  padding: 0;
  font-size: 18px;
}
.btn--fab {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(0,122,255,.35);
  padding: 0;
}

/* ── Summary ─────────────────────────────────────────── */

.summary {
  display: flex;
  justify-content: space-around;
  padding: 16px;
}

.summary__item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.summary__label { font-size: 11px; color: var(--color-text-2); text-transform: uppercase; letter-spacing: .5px; }
.summary__value { font-size: 18px; font-weight: 700; }
.summary__item--income .summary__value { color: var(--color-income); }
.summary__item--expense .summary__value { color: var(--color-expense); }
.summary__item--balance .summary__value { color: var(--color-text); }

/* ── Donut ───────────────────────────────────────────── */

.donut {
  padding: 16px;
}

.donut__svg {
  display: block;
  width: 160px;
  height: 160px;
  margin: 0 auto 12px;
}

.donut__track {
  fill: none;
  stroke: var(--color-surface-2);
  stroke-width: 20;
}

.arc {
  fill: none;
  stroke-width: 20;
  cursor: pointer;
  transition: stroke-width .15s;
}
.arc:hover { stroke-width: 24; }

.arc-0  { stroke: var(--arc-0); }
.arc-1  { stroke: var(--arc-1); }
.arc-2  { stroke: var(--arc-2); }
.arc-3  { stroke: var(--arc-3); }
.arc-4  { stroke: var(--arc-4); }
.arc-5  { stroke: var(--arc-5); }
.arc-6  { stroke: var(--arc-6); }
.arc-7  { stroke: var(--arc-7); }
.arc-8  { stroke: var(--arc-8); }
.arc-9  { stroke: var(--arc-9); }
.arc-10 { stroke: var(--arc-10); }
.arc-11 { stroke: var(--arc-11); }

.donut__total-label {
  text-anchor: middle;
  font-size: 9px;
  fill: var(--color-text-2);
}
.donut__total-value {
  text-anchor: middle;
  font-size: 14px;
  font-weight: 700;
  fill: var(--color-text);
}

/* Chart toggle */
.chart-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-m);
  margin: 0 auto 8px;
  width: fit-content;
  border: none;
}

.chart-toggle__btn {
  border: none;
  background: none;
  padding: 5px 14px;
  border-radius: calc(var(--radius-m) - 2px);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-2);
  transition: background .15s, color .15s;
}
.chart-toggle__btn--active,
.chart-toggle__btn[data-mode]:is([data-active]) {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* Legend */
.legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 4px;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: background .1s;
}
.legend__item:hover { background: var(--color-surface-2); }
.legend__item--active { background: var(--color-surface-2); }

.legend__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend__dot--0  { background: var(--arc-0); }
.legend__dot--1  { background: var(--arc-1); }
.legend__dot--2  { background: var(--arc-2); }
.legend__dot--3  { background: var(--arc-3); }
.legend__dot--4  { background: var(--arc-4); }
.legend__dot--5  { background: var(--arc-5); }
.legend__dot--6  { background: var(--arc-6); }
.legend__dot--7  { background: var(--arc-7); }
.legend__dot--8  { background: var(--arc-8); }
.legend__dot--9  { background: var(--arc-9); }
.legend__dot--10 { background: var(--arc-10); }
.legend__dot--11 { background: var(--arc-11); }

.legend__name { flex: 1; font-size: 13px; }
.legend__val { font-size: 13px; font-weight: 600; color: var(--color-text-2); }

/* ── Transaction list ───────────────────────────────── */

.tx-section { margin-bottom: 4px; }

.tx-section__title {
  font-size: 12px;
  color: var(--color-text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 4px 4px;
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-m);
  background: var(--color-surface);
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
}

.tx-row--pending { opacity: .75; border-left: 3px solid var(--color-pending); }

.tx-row__icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.tx-row--withdrawal .tx-row__icon { background: rgba(255,59,48,.12); color: var(--color-expense); }
.tx-row--deposit    .tx-row__icon { background: rgba(52,199,89,.12); color: var(--color-income); }
.tx-row--transfer   .tx-row__icon { background: rgba(0,122,255,.12); color: var(--color-transfer); }

.tx-row__body { flex: 1; min-width: 0; }
.tx-row__desc { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-row__meta { font-size: 12px; color: var(--color-text-2); }

.tx-row__amount { font-size: 15px; font-weight: 700; white-space: nowrap; }
.tx-row--withdrawal .tx-row__amount { color: var(--color-expense); }
.tx-row--deposit    .tx-row__amount { color: var(--color-income); }
.tx-row--transfer   .tx-row__amount { color: var(--color-transfer); }

.tx-row__delete {
  background: none;
  border: none;
  color: var(--color-text-2);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  line-height: 1;
  flex-shrink: 0;
}
.tx-row__delete:hover { background: var(--color-surface-2); }

.tx-row--tappable {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tx-row--tappable:active {
  background: var(--color-surface-2);
  transform: scale(.985);
}

.tx-row__chevron {
  color: var(--color-text-2);
  font-size: 20px;
  flex-shrink: 0;
  margin-left: 2px;
  opacity: .4;
}

.tx-empty {
  text-align: center;
  padding: 32px;
  color: var(--color-text-2);
  font-size: 14px;
}

/* ── Forms ───────────────────────────────────────────── */

.form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; color: var(--color-text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

.form-control {
  background: var(--color-surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-m);
  padding: 11px 14px;
  font-family: var(--font);
  font-size: 16px;
  color: var(--color-text);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.form-control:focus { border-color: var(--color-accent); }

.form-control--amount {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -.5px;
}

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%236b6b80'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.type-tabs {
  display: flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-m);
  padding: 3px;
  gap: 3px;
}

.type-tab {
  flex: 1;
  border: none;
  background: none;
  padding: 8px;
  border-radius: calc(var(--radius-m) - 1px);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-2);
  transition: background .15s, color .15s;
}
.type-tab--active { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.type-tab--withdrawal.type-tab--active { color: var(--color-expense); }
.type-tab--deposit.type-tab--active { color: var(--color-income); }
.type-tab--transfer.type-tab--active { color: var(--color-transfer); }

/* ── Toast ───────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: calc(var(--bottom-bar-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--color-text);
  color: var(--color-surface);
  padding: 10px 18px;
  border-radius: var(--radius-m);
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(var(--max-w) - 32px);
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--success { background: var(--color-income); color: #fff; }
.toast--error { background: var(--color-expense); color: #fff; }
