.personal-debts {
  max-width: 1180px;
  margin-inline: auto;
}
.debts-head { align-items: center; }
.personal-debts .btn, .debt-dialog .btn { min-height: 42px; }

.debt-totals, .debt-form-direction {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.debt-totals { margin-bottom: 24px; }
.debt-total {
  min-width: 0;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.debt-total > span { color: var(--text); font-weight: 500; }
.debt-total strong, .debt-amount strong, .debt-payment-balance strong {
  display: block;
  font-size: clamp(22px, 2.5vw, 29px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.debt-total strong { margin-block: 7px 4px; }
.debt-total small, .debt-amount > span { font-size: 13px; color: var(--muted); }

.debts-toolbar, .debt-badges, .debt-actions, .debt-due,
.debt-readonly, .debt-card-top, .debt-card-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}
.debts-toolbar { align-items: stretch; gap: 12px; margin-bottom: 14px; }
.debts-toolbar .search-box { flex: 1; min-width: 0; height: 44px; }
.debts-toolbar .search-box input { font-size: 14px; }
.debts-toolbar > .select-control, .debts-toolbar > select { min-width: 215px; }
.debts-filter-row { margin-bottom: 24px; }
.debts-filters {
  display: inline-flex;
  gap: 3px;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.debts-filters button {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--muted);
}
.debts-filters button:hover, .debts-filters button.selected { color: var(--text); }
.debts-filters button.selected { background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.debt-group + .debt-group { margin-top: 28px; }
.debt-group > h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
}
.debt-group > h2 span { font-size: 13px; font-weight: 500; color: var(--muted); }
.debt-list { display: grid; gap: 12px; }
.debt-group-empty, .debt-loading, .personal-debts .empty-state {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.personal-debts .empty-state { padding: 40px 18px; }
.debt-card {
  --debt-bar: var(--green);
  --debt-track: color-mix(in srgb, var(--green) 23%, var(--panel));
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.debt-card.is-overdue {
  --debt-bar: var(--danger);
  --debt-track: color-mix(in srgb, var(--danger) 45%, var(--panel));
}
.debt-card.is-completed { opacity: .8; background: var(--panel); }
.debt-card.is-completed:hover, .debt-card.is-completed:focus-within { opacity: 1; }
.debt-card-top { align-items: flex-start; justify-content: space-between; gap: 16px; }
.debt-card-title { min-width: 0; }
.debt-badges { flex-wrap: wrap; gap: 6px 14px; margin-bottom: 6px; }
.debt-direction, .debt-readonly { font-size: 13px; font-weight: 500; color: var(--muted); }
.debt-readonly { gap: 4px; }
.debt-readonly svg { width: 14px; height: 14px; }
.debt-card h3, .debt-modal-title { font-size: 18px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.debt-person, .debt-due { color: var(--muted); font-size: 14px; line-height: 1.5; }
.debt-person { margin-top: 4px; overflow-wrap: anywhere; }
.debt-amount { flex: 0 1 auto; min-width: 0; text-align: right; }
.debt-amount strong { font-size: 23px; margin-bottom: 3px; }
.debt-description, .debt-detail-description { margin-top: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.debt-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 18px 0 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.debt-progress-label b { color: var(--text); font-weight: 500; }
.debt-progress-label > span:last-child { font-variant-numeric: tabular-nums; }
.debt-progress { height: 7px; overflow: hidden; border-radius: 6px; background: var(--debt-track); }
.debt-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--debt-bar); }
.debt-card-bottom { justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.debt-due > svg, .debt-actions svg { flex-shrink: 0; width: 16px; height: 16px; }
.debt-due strong { display: block; color: var(--danger); font-weight: 600; }
.debt-actions { flex-wrap: wrap; }
.debt-actions .btn { font-size: 13px; padding-inline: 11px; }
.debt-actions .debt-pay-button { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }
.debt-actions .debt-pay-button:hover { background: color-mix(in srgb, var(--green) 11%, var(--card)); }
.debt-dialog form > fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.debt-dialog .field input, .debt-dialog .field textarea { font-size: 16px; }
.debt-dialog .field-grid { margin-bottom: 0; }
.debt-dialog .field textarea { min-height: 88px; }
.debt-dialog input[readonly] { color: var(--muted); background: var(--panel); }
.debt-date-help, .debt-sharing-note, .debt-dialog .help { font-size: 13px; line-height: 1.6; color: var(--muted); }
.debt-date-help, .debt-sharing-note { margin: -4px 0 18px; }
.debt-dialog .form-actions { flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.debt-form-error { color: var(--danger); line-height: 1.6; margin: 16px 0; }
.debt-form-error:empty { display: none; }
.debt-form-direction { margin-bottom: 20px; gap: 8px; }
.debt-form-direction label { position: relative; cursor: pointer; }
.debt-form-direction input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.debt-form-direction span {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
}
.debt-form-direction input:checked + span { background: var(--card); border-color: var(--blue); color: var(--text); }
.debt-form-direction input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 3px; }
.debt-payment-balance { padding: 16px; margin: 18px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.debt-payment-balance > span { color: var(--muted); }
.debt-payment-balance strong { margin-top: 4px; }
.debt-dialog .text-link { min-height: 40px; margin-bottom: 8px; }
.debt-confirm-copy { font-size: 15px; margin-top: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.debt-detail-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.debt-detail-totals span { color: var(--muted); font-size: 13px; }
.debt-detail-totals strong { display: block; margin-top: 4px; color: var(--text); font-size: 16px; overflow-wrap: anywhere; }
.debt-history-title { font-size: 16px; margin: 22px 0 6px; }
.debt-history { list-style: none; padding: 0; margin: 0; }
.debt-history li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.debt-history strong { display: block; font-size: 16px; font-weight: 500; }
.debt-history time, .debt-history small { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 4px; }
.debt-history svg { flex-shrink: 0; color: var(--green); }
.debt-history .is-voided strong { text-decoration: line-through; color: var(--muted); }
.debt-history .is-voided svg { color: var(--muted); }
.debt-celebration { text-align: center; padding: 24px; }
.debt-success-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 50%; background: var(--card); color: var(--green); }
.debt-success-icon svg { width: 25px; height: 25px; }
.debt-celebration p { font-size: 18px; font-weight: 600; }
.debt-celebration small { display: block; margin: 8px 0 20px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.debt-celebration .btn { min-width: 130px; margin-inline: auto; }

@media (max-width: 720px) {
  .personal-debts .btn, .debt-dialog .btn, .debts-filters button { min-height: 44px; }
  .debt-totals { gap: 8px; margin-bottom: 18px; }
  .debt-total { padding: 14px; }
  .debts-toolbar { flex-wrap: wrap; gap: 8px; }
  .debts-toolbar .search-box, .debts-toolbar > .select-control, .debts-toolbar > select { flex-basis: 100%; width: 100%; min-width: 0; }
  .debts-toolbar .search-box input { font-size: 16px; }
  .debts-filters { display: flex; }
  .debts-filters button { flex: 1; padding-inline: 8px; }
  .debt-card { padding: 16px; }
  .debt-card-top { flex-wrap: wrap; gap: 12px; }
  .debt-amount { text-align: left; }
  .debt-actions { width: 100%; gap: 6px; }
  .debt-actions .btn { padding-inline: 10px; }
}
/* Phones: the amount always goes under the title, so the cards look the same whatever the title length. */
@media (max-width: 720px) {
  .debt-card-top > .debt-amount { flex-basis: 100%; }
}
/* The three totals in the history must keep «₽» next to the number on narrow screens. */
@media (max-width: 480px) {
  .debt-detail-totals strong { font-size: clamp(13px, 3.9vw, 16px); overflow-wrap: break-word; }
}
@media (max-width: 480px) {
  /* Totals: keep «₽» on the same line as the amount. */
  .debt-total strong { font-size: clamp(16px, 4.9vw, 23px); overflow-wrap: break-word; }
  /* Tabs take width by their text, so «Мне должны» stays on one line. */
  .debts-filters button { flex: 1 1 auto; padding-inline: 6px; white-space: nowrap; }
}
