/* budget-trim 専用 — ロック行の共通トークンは sugudasu.css（.sg-lock-row*） */
.bt-counter {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 1rem 1.125rem;
  border-radius: 0.75rem;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  box-shadow: 0 4px 16px rgb(15 23 42 / 0.06);
}
.bt-counter__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  font-weight: 800;
  font-size: clamp(1.125rem, 2.5vw, 1.5rem);
  line-height: 1.35;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}
.bt-counter__cap-input {
  width: 9rem;
  max-width: 40vw;
  font-size: inherit;
  font-weight: 800;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.2rem 0.45rem;
  background: #fff;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.bt-counter__status {
  margin-top: 0.5rem;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 900;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.bt-counter--over {
  border-color: #f87171;
  background: #fef2f2;
}
.bt-counter--over .bt-counter__status {
  color: #b91c1c;
  animation: bt-flash 0.7s ease-in-out infinite;
}
.bt-counter--under {
  border-color: #86efac;
  background: #ecfdf5;
}
.bt-counter--under .bt-counter__status {
  color: #047857;
}
.bt-counter--neutral .bt-counter__status {
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 600;
}
@keyframes bt-flash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}
@media (prefers-reduced-motion: reduce) {
  .bt-counter--over .bt-counter__status {
    animation: none;
  }
}

.bt-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* B-1: 1行完結ワークスペース */
.bt-item {
  border: 1px solid var(--sg-border, #e2e8f0);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem 0.5rem 0.5rem;
}
.bt-item.sg-lock-row--on {
  border-color: #cbd5e1;
}

.bt-item__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(6.5rem, 9.5rem) auto auto;
  align-items: center;
  column-gap: 0.5rem;
  row-gap: 0.35rem;
}

.bt-item__name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: #0f172a;
  overflow-wrap: anywhere;
  min-width: 0;
}

.bt-item__idx {
  font-variant-numeric: tabular-nums;
  color: var(--sg-muted, #64748b);
  font-weight: 600;
  margin-right: 0.2rem;
}

.bt-item__amount {
  width: 100%;
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
}

.bt-item__yen {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
}

/* B-2: 未ロック＝オレンジ強調 / ロック中＝後退 */
.bt-lock {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}
.bt-lock--open {
  border-color: color-mix(in srgb, var(--sg-lock-open-accent, #ff851b) 55%, #fff);
  background: color-mix(in srgb, var(--sg-lock-open-accent, #ff851b) 14%, #fff);
  color: #9a3412;
}
.bt-lock--open:hover {
  background: color-mix(in srgb, var(--sg-lock-open-accent, #ff851b) 22%, #fff);
}
.bt-lock--closed {
  border-color: #cbd5e1;
  background: transparent;
  color: #64748b;
  font-weight: 600;
}
.bt-lock--closed:hover {
  background: #f8fafc;
}

.bt-hint {
  font-size: 0.6875rem;
  color: #64748b;
  margin: 0;
}
.bt-empty {
  font-size: 0.75rem;
  color: #64748b;
  padding: 0.75rem 0.25rem;
}

@media (max-width: 520px) {
  .bt-item__row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .bt-item__amount {
    grid-column: 2 / 3;
    grid-row: 2;
  }
  .bt-item__yen {
    grid-column: 3;
    grid-row: 2;
  }
  .bt-lock {
    grid-column: 1 / -1;
    justify-self: end;
  }
}
