#debt-app .debt-page-head,
#debt-app .debt-form-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0 14px;
}
#debt-app .debt-page-head { justify-content: space-between; }
#debt-app .debt-page-head h2,
#debt-app .debt-form-head h2 { margin: 0 0 3px; font-size: 24px; }
#debt-app .debt-page-head .section-subtitle,
#debt-app .debt-form-head .section-subtitle { margin: 0; }
#debt-app .debt-overview { display: grid; gap: 10px; margin-bottom: 14px; }
#debt-app .debt-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
#debt-app .debt-metric { min-width: 0; display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 82px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
#debt-app .debt-metric .metric-icon { grid-row: auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; }
#debt-app .debt-metric .metric-icon svg { width: 21px; height: 21px; }
#debt-app .debt-metric.pending .metric-icon { color: var(--expense); background: var(--expense-soft); }
#debt-app .debt-metric.paid .metric-icon { color: var(--income); background: var(--success-soft); }
#debt-app .debt-metric.next .metric-icon { color: var(--brand); background: var(--brand-soft); }
#debt-app .debt-metric p { margin: 0 0 4px; color: var(--muted); font-size: 10px; font-weight: 800; line-height: 1.1; }
#debt-app .debt-metric strong { color: var(--ink); overflow-wrap: anywhere; font-size: clamp(11px, 2.7vw, 14px); font-weight: 850; line-height: 1.15; }
#debt-app .debt-progress-card { display: grid; gap: 10px; }
#debt-app .debt-progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#debt-app .debt-progress-heading h2 { margin: 0; font-size: 14px; }
#debt-app .debt-progress-heading > strong { color: var(--brand); font-size: 13px; }
#debt-app .debt-progress-content { display: flex; align-items: center; gap: 14px; }
#debt-app .debt-ring { width: 76px; height: 76px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(var(--brand) var(--debt-progress), var(--brand-soft) 0); }
#debt-app .debt-ring::before { content: ""; grid-area: 1 / 1; width: 58px; height: 58px; border-radius: inherit; background: var(--surface); }
#debt-app .debt-ring > span { z-index: 1; grid-area: 1 / 1; display: grid; justify-items: center; color: var(--brand); font-size: 13px; font-weight: 850; line-height: 1.05; }
#debt-app .debt-ring small { margin-top: 3px; color: var(--muted); font-size: 8px; font-weight: 650; }
#debt-app .debt-progress-detail { display: grid; gap: 3px; }
#debt-app .debt-progress-detail strong { color: var(--ink); font-size: 15px; }
#debt-app .debt-progress-detail span { color: var(--muted); font-size: 10px; }
#debt-app .debt-feedback { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
#debt-app .debt-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
#debt-app .debt-summary-head p { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
#debt-app .debt-summary-head strong { color: var(--ink); font-size: clamp(24px, 4vw, 32px); font-weight: 900; line-height: 1.1; }
#debt-app .debt-add-trigger { min-height: 36px; display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 8px 12px; font-size: 12px; }
#debt-app .debt-add-trigger svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#debt-app .debt-back svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#debt-app .debt-summary-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
#debt-app .debt-overall-progress { margin-top: 14px; }
#debt-app .debt-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--brand-soft);
}
#debt-app .debt-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .2s ease; }
#debt-app .debt-progress-copy { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 11px; }
#debt-app .debt-section-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
#debt-app .debt-section-heading h2 { margin: 0; font-size: 15px; }
#debt-app .debt-add-inline { display: inline-flex; align-items: center; gap: 4px; }
#debt-app .debt-add-inline svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#debt-app .debt-list { display: grid; gap: 10px; }
#debt-app .debt-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
#debt-app .debt-card-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
#debt-app .debt-card-title { display: flex; align-items: center; justify-content: flex-start; gap: 10px; min-width: 0; }
#debt-app .debt-card-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--brand);
  background: var(--brand-soft);
}
#debt-app .debt-card-icon svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#debt-app .debt-card-copy { min-width: 0; }
#debt-app .debt-card-heading { display: flex; align-items: center; gap: 6px; min-width: 0; }
#debt-app .debt-card-heading h3 { overflow: hidden; margin: 0; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
#debt-app .debt-card-copy p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.25; }
#debt-app .debt-status { flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; color: var(--muted); background: var(--surface-2); font-size: 9px; font-weight: 800; }
#debt-app .debt-status.paid { color: var(--income); background: var(--success-soft); }
#debt-app .debt-status.late { color: var(--danger); background: var(--expense-soft); }
#debt-app .debt-status.soon { color: var(--warning); background: color-mix(in srgb, var(--warning) 16%, var(--surface)); }
#debt-app .debt-pending-badge { min-width: 112px; display: grid; justify-items: start; gap: 4px; padding: 8px 9px; border: 1px solid color-mix(in srgb, var(--expense) 22%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--expense-soft) 78%, var(--surface)); }
#debt-app .debt-pending-badge span { color: var(--muted); font-size: 9px; }
#debt-app .debt-pending-badge strong { color: var(--expense); font-size: 12px; font-weight: 850; overflow-wrap: anywhere; }
#debt-app .debt-card-bottom { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
#debt-app .debt-item-progress { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
#debt-app .debt-item-progress .debt-progress { flex: 1; min-width: 38px; }
#debt-app .debt-item-progress small { flex: 0 0 auto; color: var(--muted); font-size: 9px; white-space: nowrap; }
#debt-app .debt-pay-link { min-height: 28px; display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; padding: 4px 1px; border: 0; border-radius: 0; background: transparent; font-size: 10px; white-space: nowrap; }
#debt-app .debt-pay-link svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#debt-app .debt-pay-link:disabled { color: var(--muted); cursor: default; }
#debt-app .debt-empty-state { display: grid; gap: 4px; color: var(--muted); }
#debt-app .debt-empty-state p { margin: 0; color: var(--ink); font-size: 13px; font-weight: 800; }
#debt-app .debt-empty-state span { font-size: 11px; }
#debt-app .debt-empty-state .debt-add-trigger { justify-self: start; margin-top: 6px; }
#debt-app .debt-add-section[hidden],
#debt-app .debt-list-section[hidden],
#debt-app .debt-page-head[hidden],
#debt-app .debt-empty-state[hidden],
#debt-app .debt-overview[hidden] { display: none; }
#debt-app .debt-form { display: grid; gap: 14px; }
#debt-app .debt-form > label { display: grid; gap: 6px; color: var(--ink); font-size: 12px; font-weight: 750; }
#debt-app .debt-form input:not([type="checkbox"]) {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-weight: 500;
}
#debt-app .debt-money-input { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
#debt-app .debt-money-input > span { padding: 0 11px; color: var(--muted); font-weight: 700; }
#debt-app .debt-money-input input:not([type="checkbox"]) { border: 0; border-left: 1px solid var(--line); border-radius: 0; }
#debt-app .debt-form input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 30%, transparent); outline-offset: 1px; }
#debt-app .debt-form input:disabled { opacity: .55; }
#debt-app .debt-form .debt-check-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 600; }
#debt-app .debt-check-row input { width: 16px; height: 16px; accent-color: var(--brand); }
#debt-app .debt-form-note,
#debt-app .debt-payment-note { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
#debt-app .debt-error { min-height: 0; margin: 0; color: var(--danger); font-size: 11px; }
#debt-app .debt-form-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
#debt-app .debt-back { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); }
#debt-app .debt-payment-modal { max-width: 440px; }
#debt-app .debt-payment-modal form { display: grid; gap: 12px; }
#debt-app .debt-payment-modal .field-label { display: grid; gap: 5px; font-size: 12px; font-weight: 750; }
#debt-app .debt-payment-modal .input-shell:has(input[type="date"]) { min-height: 42px; grid-template-columns: minmax(0, 1fr); }
#debt-app .debt-payment-modal .input-shell input[type="date"] { width: 100%; min-width: 0; min-height: 40px; padding: 10px 11px; border-left: 0; color: var(--ink); font-size: 12px; font-weight: 500; color-scheme: light; }
#debt-app .debt-payment-modal .debt-payment-money-input { width: 100%; grid-template-columns: auto minmax(0, 1fr); }
#debt-app .debt-payment-modal .debt-payment-money-input .input-prefix { min-width: 0; padding: 0 11px; color: var(--muted); font-size: 12px; font-weight: 700; }
#debt-app .debt-payment-modal .debt-payment-money-input input[name="amount"] { width: 100%; min-height: 42px; padding: 8px 9px; border: 0; border-left: 1px solid var(--line); border-radius: 0; color: var(--ink); background: transparent; font: inherit; font-size: 12px; font-weight: 500; }
#debt-app .debt-payment-modal .debt-payment-money-input input[name="amount"]::placeholder { color: var(--muted); font-size: 12px; font-weight: 500; }
#dashboard .debt-home-card { grid-column: 1 / -1; display: grid; gap: 10px; }
#dashboard .debt-home-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#dashboard .debt-home-head h2 { margin: 0; font-size: 15px; }
#dashboard .debt-home-count { flex: 0 0 auto; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: 10px; font-weight: 850; }
#dashboard .debt-home-overview { display: grid; grid-template-columns: minmax(0, 1fr) 78px; align-items: center; gap: 10px; min-height: 102px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--brand-soft); }
#dashboard .debt-home-total { display: grid; gap: 5px; min-width: 0; }
#dashboard .debt-home-total-label { color: var(--muted); font-size: 11px; font-weight: 750; }
#dashboard .debt-home-total-value { display: flex; align-items: center; gap: 8px; min-width: 0; }
#dashboard .debt-home-total-icon { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--expense); background: var(--expense-soft); }
#dashboard .debt-home-total-icon svg { width: 16px; height: 16px; }
#dashboard .debt-home-total-value > strong { color: var(--expense); overflow-wrap: anywhere; font-size: clamp(18px, 2.4vw, 23px); line-height: 1.05; font-weight: 900; }
#dashboard .debt-home-ring { position: relative; width: 76px; height: 76px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--brand) var(--home-debt-progress), var(--line) 0); }
#dashboard .debt-home-ring::before { position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); content: ""; }
#dashboard .debt-home-ring > span { z-index: 1; display: grid; justify-items: center; color: var(--ink); line-height: 1; }
#dashboard .debt-home-ring strong { font-size: 15px; font-weight: 900; }
#dashboard .debt-home-ring small { margin-top: 3px; color: var(--muted); font-size: 8px; font-weight: 700; }
#dashboard .debt-home-upcoming { width: 100%; min-width: 0; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto 14px; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); text-align: left; }
#dashboard .debt-home-upcoming:hover { background: var(--surface-2); }
#dashboard .debt-home-upcoming-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); background: var(--brand-soft); }
#dashboard .debt-home-upcoming-icon svg { width: 17px; height: 17px; }
#dashboard .debt-home-upcoming-copy { min-width: 0; display: grid; gap: 3px; }
#dashboard .debt-home-upcoming-copy strong { color: var(--ink); font-size: 11px; font-weight: 850; }
#dashboard .debt-home-upcoming-copy > span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
#dashboard .debt-home-upcoming-amount { color: var(--ink-soft); font-size: 11px; font-weight: 850; text-align: right; }
#dashboard .debt-home-chevron { display: grid; place-items: center; color: var(--brand); }
#dashboard .debt-home-chevron svg { width: 15px; height: 15px; }
#dashboard .debt-home-detail { justify-self: start; min-height: 30px; display: inline-flex; align-items: center; gap: 5px; padding: 2px 0; color: var(--brand); font-size: 11px; font-weight: 850; }
#dashboard .debt-home-detail svg { width: 14px; height: 14px; }

@media (max-width: 760px) {
  #app .tabs:has(.tab[data-view="debts"]) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #debt-app .debt-page-head { margin: 2px 0 10px; }
  #debt-app .debt-page-head h2,
  #debt-app .debt-form-head h2 { font-size: 22px; }
  #debt-app .debt-metrics { gap: 6px; }
  #debt-app .debt-metric { grid-template-columns: 30px minmax(0, 1fr); gap: 8px; min-height: 78px; padding: 9px; }
  #debt-app .debt-metric .metric-icon { width: 30px; height: 30px; }
  #debt-app .debt-metric .metric-icon svg { width: 16px; height: 16px; }
  #debt-app .debt-metric p { font-size: 8.8px; }
  #debt-app .debt-metric strong { font-size: clamp(10px, 2.8vw, 12px); }
  #debt-app .debt-ring { width: 68px; height: 68px; }
  #debt-app .debt-ring::before { width: 52px; height: 52px; }
  #dashboard .debt-home-card { grid-column: 1 / -1; gap: 8px; }
  #dashboard .debt-home-overview { grid-template-columns: minmax(0, 1fr) 66px; min-height: 86px; padding: 10px; }
  #dashboard .debt-home-total-label { font-size: 9px; }
  #dashboard .debt-home-total-value { gap: 6px; }
  #dashboard .debt-home-total-icon { width: 26px; height: 26px; }
  #dashboard .debt-home-total-icon svg { width: 14px; height: 14px; }
  #dashboard .debt-home-total-value > strong { font-size: clamp(16px, 4.4vw, 19px); }
  #dashboard .debt-home-ring { width: 64px; height: 64px; }
  #dashboard .debt-home-ring::before { inset: 6px; }
  #dashboard .debt-home-ring strong { font-size: 13px; }
  #dashboard .debt-home-upcoming { grid-template-columns: 32px minmax(0, 1fr) auto 12px; gap: 7px; padding: 8px; }
  #dashboard .debt-home-upcoming-icon { width: 30px; height: 30px; }
  #dashboard .debt-home-upcoming-icon svg { width: 15px; height: 15px; }
  #dashboard .debt-home-upcoming-copy strong { font-size: 10px; }
  #dashboard .debt-home-upcoming-copy > span { font-size: 9px; }
  #dashboard .debt-home-upcoming-amount { max-width: 96px; font-size: 9px; }
  #dashboard .debt-home-detail { font-size: 10px; }
  #debt-app .debt-card { padding: 10px; }
  #debt-app .debt-card-top { gap: 7px; }
  #debt-app .debt-card-title { gap: 8px; }
  #debt-app .debt-card-icon { width: 32px; height: 32px; }
  #debt-app .debt-card-icon svg { width: 18px; height: 18px; }
  #debt-app .debt-card-heading { gap: 4px; }
  #debt-app .debt-card-heading h3 { font-size: 12px; }
  #debt-app .debt-card-copy p { font-size: 9px; }
  #debt-app .debt-status { padding: 3px 6px; font-size: 8px; }
  #debt-app .debt-pending-badge { min-width: 104px; padding: 7px 8px; }
  #debt-app .debt-pending-badge span { font-size: 8px; }
  #debt-app .debt-pending-badge strong { font-size: 10.5px; }
  #debt-app .debt-card-bottom { gap: 6px; margin-top: 7px; }
  #debt-app .debt-pay-link { min-height: 26px; font-size: 9px; }
  #debt-app .debt-pay-link svg { width: 11px; height: 11px; }
  #debt-app .debt-payment-modal .debt-payment-money-input input[name="amount"] { min-height: 38px; }
  #debt-app .debt-payment-modal .debt-payment-money-input .input-prefix { font-size: 11px; }
  #debt-app .debt-payment-modal .input-shell:has(input[type="date"]) { min-height: 38px; }
  #debt-app .debt-payment-modal .input-shell input[type="date"] { min-height: 36px; padding: 8px 9px; }
  #debt-app .debt-payment-modal .field-label { font-size: 11px; }
  #debt-app .debt-form { gap: 11px; }
  #debt-app .debt-form > label { font-size: 11px; }
  #debt-app .debt-form input:not([type="checkbox"]) { min-height: 38px; padding: 8px 9px; font-size: 12px; }
}

body[data-theme="dark"] #debt-app .debt-metric.pending .metric-icon { background: rgba(255, 99, 116, .16); }
body[data-theme="dark"] #debt-app .debt-metric.paid .metric-icon { background: rgba(25, 216, 145, .16); }
body[data-theme="dark"] #debt-app .debt-metric.next .metric-icon { background: rgba(31, 213, 255, .16); }
