/* Debt Tracker — after the Apple (España) Refero style
   (styles.refero.design/style/c9cabb96-32fa-4896-837a-f2497ce1c856):
   a monochrome hall of white space. Sections alternate #fff / #f5f5f7 with
   no divider lines, cards are 28px round with no shadow, controls are pills,
   blue #0071e3 is only ever a filled CTA and #0066cc only a text link. The
   pastel finish swatches carry the colour, as person avatars. Ember #b64400
   marks overdue and destructive actions. */

:root {
  --ink: #1d1d1f;
  --mid: #707070;
  --deep: #474747;
  --hair: #d6d6d6;
  --canvas: #f5f5f7;
  --paper: #ffffff;
  --wash: #e8e8ed;
  --faded: #fafafc;
  --blue: #0071e3;
  --link: #0066cc;
  --ember: #b64400;

  --sky: #c8d8e0;
  --citrus: #dddc8c;
  --starlight: #f0e4d3;
  --silver: #e3e4e5;
  --blush: #e8d0d0;
  --indigo: #596680;
  --midnight: #2e3642;

  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, Inter, "Helvetica Neue", Arial, sans-serif;
  --text: "SF Pro Text", -apple-system, BlinkMacSystemFont, Inter, "Helvetica Neue", Arial, sans-serif;
  --max: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.47 var(--text);
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: var(--link); text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.amount { font-variant-numeric: tabular-nums; }
.muted { color: var(--mid); }
.ember { color: var(--ember); }
.caption { font-size: 14px; line-height: 1.29; letter-spacing: -0.016em; }

/* ------------------------------------------------------------ type */

.display {
  font-family: var(--display);
  font-weight: 700;
  font-size: 96px;
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin-top: 4px;
}
.display--long { font-size: 80px; }
h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 56px;
  line-height: 1.07;
  letter-spacing: -0.005em;
}
h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 40px;
  line-height: 1.2;
  letter-spacing: 0;
}
.eyebrow { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.lede {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.38;
  letter-spacing: 0.011em;
  color: var(--mid);
  margin-top: 16px;
}
.lede--tight { font-size: 17px; margin-top: 8px; letter-spacing: -0.022em; }

/* ------------------------------------------------------------ layout */

.wrap { max-width: var(--max); margin: 0 auto; }
.band { padding: 100px 40px; }
.band--white { background: var(--paper); }
.band--canvas { background: var(--canvas); }
.band__title { margin-bottom: 28px; }
.band__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 28px;
}
.hero { text-align: center; padding-top: 88px; }
.hero--left { text-align: left; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.hero .actions { justify-content: center; }
.hero--left .actions { justify-content: flex-start; }
.meta-links { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 24px; }
.hero:not(.hero--left) .meta-links { justify-content: center; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px 24px; flex-wrap: wrap; margin-bottom: 32px;
}
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 24px;
}
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.debt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

.gate { min-height: 100vh; display: grid; place-items: center; }

/* ------------------------------------------------------------ nav */

.nav {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: rgba(250, 250, 252, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.nav__in {
  max-width: var(--max); margin: 0 auto; height: 44px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
}
.nav__brand { font-size: 14px; font-weight: 600; color: var(--ink); margin-right: auto; white-space: nowrap; }
.nav__links { display: flex; gap: 4px; }
.nav__link {
  display: inline-flex; align-items: center; height: 44px; padding: 0 10px;
  font-size: 12px; color: var(--ink); opacity: 0.8;
  background: none; border: 0; cursor: pointer; white-space: nowrap;
}
.nav__link[aria-current="page"] { opacity: 1; font-weight: 600; }

.demo {
  background: var(--canvas); color: var(--deep);
  text-align: center; font-size: 14px; padding: 10px 20px;
}
.demo .link { font-size: 14px; }

/* ------------------------------------------------------------ controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 11px 22px;
  border-radius: 980px; border: 1px solid transparent;
  font-size: 17px; font-weight: 400; line-height: 1.17;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color 0.2s ease;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn--danger { background: var(--ember); color: #fff; }
.btn--wide { width: 100%; }

.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--link); font-size: 17px; text-align: left;
}
.link--danger { color: var(--ember); }

@media (hover: hover) {
  .btn--primary:hover:not(:disabled) { background: #0077ed; }
  .btn--ghost:hover:not(:disabled) { background: var(--wash); }
  .btn--danger:hover:not(:disabled) { background: #a33d00; }
  .link:hover, a.link:hover { text-decoration: underline; }
  .nav__link:hover { opacity: 1; }
  a.row:hover .row__title { text-decoration: underline; }
}

.search {
  height: 44px; width: min(320px, 100%);
  border-radius: 999px; border: 1px solid var(--hair); background: var(--paper);
  padding: 0 18px; font-size: 17px;
  -webkit-appearance: none; appearance: none;
}
.search:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2); }

.seg {
  display: inline-flex; gap: 2px; padding: 3px; max-width: 100%; overflow-x: auto;
  background: var(--wash); border-radius: 999px;
}
.seg__btn {
  height: 38px; padding: 0 16px; border: 0; border-radius: 999px;
  background: transparent; color: var(--deep); font-size: 14px; cursor: pointer; white-space: nowrap;
}
.seg__btn[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 600; }
.seg__n { margin-left: 6px; color: var(--mid); font-weight: 400; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ cards & rows */

.card { border-radius: 28px; padding: 28px; }
.band--white .card, .band--white .rows--card { background: var(--canvas); }
.band--canvas .card, .band--canvas .rows--card { background: var(--paper); }
.card__title { font-size: 21px; font-weight: 600; line-height: 1.38; letter-spacing: 0.011em; }
.card__empty { margin-top: 12px; }

.rows { list-style: none; margin: 0; padding: 0; }
.card .rows { margin-top: 8px; }
.rows--card { border-radius: 28px; padding: 4px 28px; }
.rows > li + li { border-top: 1px solid var(--hair); }
.row {
  display: flex; align-items: center; gap: 14px;
  min-height: 72px; padding: 14px 0; color: var(--ink);
}
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row__title, .row__sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__title { font-weight: 600; }
.row__sub { font-size: 14px; color: var(--mid); letter-spacing: -0.016em; }
.row__end { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.row__end--stack { flex-direction: column; align-items: flex-end; gap: 4px; }
.chev { color: var(--mid); font-size: 24px; line-height: 1; }
.empty { padding: 32px 0; text-align: center; color: var(--mid); }

.avatar {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: 15px; font-size: 15px; font-weight: 600; letter-spacing: 0;
  color: var(--ink);
}
.avatar--sky { background: var(--sky); }
.avatar--citrus { background: var(--citrus); }
.avatar--starlight { background: var(--starlight); }
.avatar--silver { background: var(--silver); }
.avatar--blush { background: var(--blush); }
.avatar--indigo { background: var(--indigo); color: #fff; }
.avatar--midnight { background: var(--midnight); color: #fff; }
.avatar--xl { width: 80px; height: 80px; border-radius: 28px; font-size: 28px; }

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 36px; border: 1px solid transparent;
  font-size: 12px; line-height: 1.33; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap;
}
.badge--open { border-color: var(--hair); color: var(--deep); }
.badge--overdue { background: var(--ember); color: #fff; }
.badge--paid { background: var(--wash); color: var(--deep); }

.person-head { display: flex; align-items: center; gap: 24px; margin: 28px 0 56px; }
.person-head__text { min-width: 0; }
.person-head .lede { margin-top: 6px; }

.debt { display: flex; flex-direction: column; gap: 4px; }
.debt__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.debt__figure { font-family: var(--display); font-size: 40px; font-weight: 600; line-height: 1.2; margin-top: 8px; }
.debt__unit { font-family: var(--text); font-size: 17px; font-weight: 400; color: var(--mid); }
.bar { height: 4px; border-radius: 4px; background: var(--wash); overflow: hidden; margin: 10px 0 8px; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: inherit; }
.debt__actions {
  display: flex; flex-wrap: wrap; gap: 4px 20px;
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--hair);
}
.debt__actions .link { font-size: 15px; padding: 8px 0; }
.caption + .debt__actions { margin-top: 14px; }

/* ------------------------------------------------------------ forms & sheets */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field__label { font-size: 14px; font-weight: 600; color: var(--deep); letter-spacing: -0.016em; }
.field__hint { font-size: 12px; color: var(--mid); letter-spacing: -0.01em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-aside { margin: -6px 0 16px; }
.field-aside .link { font-size: 15px; }

.input {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--hair); background: var(--paper);
  font-size: 17px; color: var(--ink);
  -webkit-appearance: none; appearance: none;
}
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2); }
.input:disabled { background: var(--canvas); color: var(--mid); }
select.input {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23707070' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
textarea.input { resize: vertical; line-height: 1.4; }

.form-err { color: var(--ember); font-size: 14px; margin: 4px 0 14px; }
.form-ok { background: var(--canvas); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 4px 0 14px; }

.scrim {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: rgba(0, 0, 0, 0.36);
  animation: fade 0.18s ease;
}
.sheet {
  width: min(520px, 100%); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--paper); border-radius: 28px; padding: 32px;
  animation: rise 0.22s ease;
}
.sheet__title { font-family: var(--display); font-size: 28px; font-weight: 600; line-height: 1.14; margin-bottom: 20px; }
.sheet__text { color: var(--deep); margin-bottom: 16px; }
.sheet__links { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; margin-top: 8px; }
.sheet__actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.auth__card { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; }
.auth__card .btn { margin-top: 8px; }
.auth__toggle { align-self: center; margin-top: 20px; font-size: 15px; }
.auth__alt { text-align: center; margin-top: 28px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 12px 22px; font-size: 14px; text-align: center;
  animation: fade 0.18s ease;
}
.toast--err { background: var(--ember); }

/* ------------------------------------------------------------ small screens */

@media (max-width: 1068px) {
  .display { font-size: 80px; }
  .display--long { font-size: 64px; }
}

@media (max-width: 734px) {
  .band { padding: 56px 20px; }
  .hero { padding-top: 48px; }
  .display { font-size: 56px; }
  .display--long { font-size: 40px; }
  h1 { font-size: 40px; }
  .lede { font-size: 17px; }
  /* minmax(0, …) not 1fr: a bare 1fr track grows to its min-content, and a
     nowrap row title then widens the whole page past the phone screen. */
  .grid2, .debt-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 24px 20px; }
  .rows--card { padding: 2px 20px; }
  .row { gap: 12px; }
  .person-head { gap: 16px; margin: 24px 0 40px; }
  .avatar--xl { width: 64px; height: 64px; border-radius: 22px; font-size: 22px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { width: 100%; }
  .seg { align-self: flex-start; }
  .nav__in { padding: 0 max(12px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); gap: 0; }
  .nav__link { padding: 0 8px; }

  .scrim { place-items: end center; padding: 0; }
  .sheet {
    width: 100%; max-height: 92vh; border-radius: 28px 28px 0 0;
    padding: 28px 20px calc(20px + env(safe-area-inset-bottom));
  }
  .sheet__actions .btn { flex: 1; }
}
