:root {
  --bg: #f5f7fb;
  --card: #fff;
  --text: #17202a;
  --muted: #707780;
  --line: #e7eaf0;
  --accent: #d82d8b;
  --accent-hover: #bd2478;
  --accent-soft: #fceaf4;
  --good: #13865c;
  --bad: #cf4545;
  --shadow: 0 8px 28px #17202a0d;
  --radius: 18px
}

* {
  box-sizing: border-box
}

html,
body,
#app {
  min-height: 100%
}

body {
  margin: 0;
  font: 14px system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text)
}

button,
input,
select,
textarea {
  font: inherit
}

.shell {
  min-height: 100vh
}

.top {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  transition: transform .32s cubic-bezier(.22,1,.36,1), background-color .25s ease, box-shadow .25s ease, backdrop-filter .25s ease;
  will-change: transform
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.4px
}

.content {
  padding: 18px 18px 96px
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow)
}

.label,
.muted {
  color: var(--muted);
  font-size: 10px
}

.muted.custom {
  font-weight: 500;
}

.money {
  font-size: clamp(17px, 5.5vw, 22px);
  font-weight: 800;
  margin-top: 7px;
  line-height: 1.15;
  overflow-wrap: anywhere
}

.good {
  color: var(--good)
}

.bad {
  color: var(--bad)
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 2px 10px
}

.section-head.custom {
  margin: 24px 2px 10px
}

.section-head h2 {
  font-size: 16px;
  margin: 0
}

.link-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer
}

.debt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer
}

.debt:last-child {
  border: 0
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  font-weight: 800
}

.grow {
  flex: 1;
  min-width: 0
}

.name {
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.amount {
  font-weight: 800;
  text-align: right;
  white-space: nowrap
}

.pill {
  display: inline-block;
  font-size: 10px;
  border-radius: 20px;
  padding: 4px 8px;
  background: #f1f3f5;
  margin-top: 5px
}

.app-fab {
  position: fixed;
  right: 20px;
  bottom: 82px;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  font-size: 29px;
  box-shadow: 0 10px 30px #d82d8b55;
  cursor: pointer;
  z-index: 7
}

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  z-index: 6
}

.nav button {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 8px 10px;
  min-width: 70px
}

.nav button.active {
  color: var(--accent);
  font-weight: 750
}

.modal {
  position: fixed;
  inset: 0;
  background: #1118;
  display: grid;
  align-items: end;
  z-index: 20
}

.sheet {
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 20px;
  max-height: 92vh;
  overflow: auto
}

.form-grid {
  display: grid;
  gap: 13px
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--card);
  color: var(--text)
}

.types {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px
}

.types button,
.primary,
.secondary {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer
}

.types button.active,
.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent)
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px
}

.actions>* {
  flex: 1
}

.empty {
  text-align: center;
  padding: 35px 10px;
  color: var(--muted)
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 2px
}

.pagination button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  cursor: pointer
}

.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff
}

.pagination button:disabled {
  opacity: .4;
  cursor: default
}

.history {
  margin-top: 4px
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line)
}

.history-row:last-child {
  border: 0
}

.desktop-side {
  display: none
}

body.dark {
  --bg: #101316;
  --card: #181c20;
  --text: #edf1f5;
  --muted: #9aa3ad;
  --line: #2a3036;
  --accent: #ee5ca9;
  --accent-hover: #f278b8;
  --accent-soft: #3b1c2f;
  --shadow: none
}

body.dark .pill {
  background: #252b31
}


/* V4 mobile header: auto-hide + subtle native-like glass when revealed after scrolling. */
@media(max-width:767px) {
  .shell > .top {
    -webkit-backdrop-filter: blur(0);
    backdrop-filter: blur(0)
  }

  .shell > .top.mobile-header-hidden {
    transform: translate3d(0, -100%, 0);
    box-shadow: none
  }

  .shell > .top:not(.mobile-header-hidden) {
    box-shadow: 0 4px 18px #17202a0a
  }

  .shell > .top.mobile-header-scrolled:not(.mobile-header-hidden) {
    background: rgba(255, 255, 255, .9);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    backdrop-filter: blur(8px) saturate(120%);
    box-shadow: 0 6px 22px rgba(15, 23, 42, .07)
  }

  body.dark .shell > .top.mobile-header-scrolled:not(.mobile-header-hidden) {
    background: rgba(24, 28, 32, .9);
    box-shadow: 0 6px 22px rgba(0, 0, 0, .18)
  }
}

@media(min-width:768px) {
  .content {
    padding: 26px 28px 104px
  }

  .summary {
    grid-template-columns: repeat(4, minmax(0, 1fr))
  }

  .money {
    font-size: clamp(17px, 2.4vw, 23px)
  }

  .sheet {
    width: min(560px, calc(100vw - 40px));
    margin: auto;
    border-radius: 24px;
    align-self: center
  }

  .modal {
    align-items: center
  }

  .app-fab {
    right: 34px
  }

  .card {
    padding: 18px
  }

  .debt {
    padding: 16px 0
  }
}

@media(min-width:1200px) {
  .shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: 72px minmax(calc(100vh - 72px), auto)
  }

  .desktop-side {
    display: block;
    grid-column: 1;
    grid-row: 1/3;
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--card);
    border-right: 1px solid var(--line);
    padding: 10px 18px 26px
  }

  .desktop-side .brand {
    margin: 0 8px 30px
  }

  .desktop-side button {
    width: 100%;
    text-align: left;
    border: 0;
    background: none;
    color: var(--muted);
    padding: 12px 14px;
    border-radius: 11px;
    margin: 3px 0;
    cursor: pointer
  }

  .desktop-side button.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 750
  }

  .top {
    grid-column: 2;
    grid-row: 1;
    height: 60px;
    padding: 0 34px
  }

  .main {
    grid-column: 2;
    grid-row: 2;
    min-width: 0
  }

  .content {
    width: min(1220px, 100%);
    margin: 0 auto;
    padding: 32px 34px 48px
  }

  .summary {
    gap: 16px
  }

  .card {
    padding: 20px
  }

  .nav {
    display: none
  }

  .app-fab {
    right: max(34px, calc((100vw - 240px - 1220px)/2 + 34px));
    bottom: 34px
  }

  .section-head {
    margin-top: 30px
  }

  .debt {
    padding: 17px 0
  }

  .money {
    font-size: 23px
  }
}

@media(max-width:430px) {
  .content {
    padding-left: 14px;
    padding-right: 14px
  }

  .card {
    padding: 14px
  }

  .summary {
    gap: 10px
  }

  .label {
    font-size: 11px
  }

  .amount {
    font-size: 12px
  }

  .debt {
    gap: 10px
  }

  .avatar {
    width: 40px;
    height: 40px;
    flex-basis: 40px
  }

  .nav button {
    font-size: 11px;
    min-width: 0
  }
}

/* V1.2: sticky modal header, money inputs, toast */
.modal-head {
  position: sticky;
  top: -20px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -20px -20px 14px;
  padding: 8px 20px 8px;
  background: var(--card);
  border-bottom: 1px solid var(--line)
}

.modal-head h2 {
  font-size: 16px;
  margin: 0
}

.close-btn {
  width: 30px;
  height: 35px;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  /* color: var(--text); */
  color: var(--accent);
  cursor: pointer;
  font-size: 17px
}

.money-field {
  position: relative
}

.money-field input {
  padding-right: 42px !important;
  font-weight: 700
}

.money-field span {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 800;
  color: var(--muted);
  pointer-events: none
}

.money-preview {
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 700
}

.field-help {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px
}

.balance-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 14px
}

.balance-card strong {
  display: block;
  margin-top: 5px;
  font-size: 16px
}

.danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, var(--line))
}

.toast-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: grid;
  gap: 8px;
  pointer-events: none
}

.toast {
  min-width: 240px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--text);
  color: var(--card);
  box-shadow: 0 12px 35px #0003;
  opacity: 0;
  transform: translateY(-10px);
  transition: .22s ease;
  font-weight: 650
}

.toast.show {
  opacity: 1;
  transform: none
}

.toast.error {
  background: #b42318;
  color: #fff
}

@media(max-width:767px) {
  .sheet {
    padding-top: 20px
  }

  .modal-head {
    top: -20px
  }

  .toast-wrap {
    top: 12px;
    left: 12px;
    right: 12px
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%
  }
}

/* V1.3: search/filter + editable payment history */
.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 10px;
  margin: 0 0 14px
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 12px 0
}

.filters select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--card);
  color: var(--text)
}

.people-filter {
  grid-template-columns: minmax(220px, 520px)
}

.pill-bad {
  background: #fff0f0;
  color: var(--bad)
}

.pill.status-active {
  background: #eaf8f1;
  color: var(--good);
  font-weight: 750
}

.pill.status-completed {
  background: #f1f3f5;
  color: var(--muted);
  font-weight: 750
}

.pill.status-overdue {
  background: #fff0f0;
  color: var(--bad);
  font-weight: 750
}

body.dark .pill.status-active {
  background: #17372c;
  color: #66d2a7
}

body.dark .pill.status-completed {
  background: #252b31;
  color: #aab2bb
}

body.dark .pill.status-overdue {
  background: #3a2020;
  color: #ff8b8b
}

.history-right {
  text-align: right
}

.mini-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 5px
}

.mini-actions button {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 11px;
  padding: 2px;
  cursor: pointer
}

.mini-actions .danger-text {
  color: var(--bad)
}

.paid-note {
  grid-column: 1/-1;
  font-size: 11px;
  color: var(--good);
  margin-top: 2px
}

.submodal {
  z-index: 30
}

.small-sheet {
  width: min(430px, calc(100vw - 28px)) !important
}

.field input:disabled {
  opacity: .6;
  cursor: not-allowed
}

@media(max-width:767px) {
  .filters {
    grid-template-columns: 1fr 1fr
  }

  .search-box {
    grid-column: 1/-1
  }

  .filters .secondary {
    grid-column: 1/-1
  }

  .people-filter {
    grid-template-columns: 1fr
  }

  .people-filter .search-box {
    grid-column: auto
  }

  .filters select {
    min-height: 44px
  }

  .history-row {
    align-items: flex-start
  }
}

/* V1.4: Vietnamese search, person detail, empty states, custom confirm */
.person-row {
  cursor: pointer
}

.row-arrow {
  font-size: 25px;
  color: var(--muted);
  padding-left: 8px
}

.back-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 750;
  padding: 0;
  margin: 2px 0 14px;
  cursor: pointer
}

.person-hero {
  display: flex;
  align-items: center;
  gap: 14px
}

.person-hero h2 {
  margin: 0 0 4px;
  font-size: 20px
}

.person-avatar {
  width: 54px;
  height: 54px;
  flex-basis: 54px;
  font-size: 18px
}

.person-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px
}

.net-card {
  grid-column: 1/-1
}

.person-tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  margin: 0 0 12px;
  padding-bottom: 2px
}

.person-tabs button {
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  padding: 5px 10px;
  white-space: nowrap;
  cursor: pointer
}

.person-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700
}

.empty {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 130px
}

.empty-icon {
  font-size: 24px;
  color: var(--muted)
}

.no-pointer {
  cursor: default
}

.confirm-modal {
  z-index: 60;
  place-items: center;
  padding: 18px
}

.confirm-box {
  width: min(390px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 22px 70px #0004
}

.confirm-box h3 {
  margin: 10px 0 7px;
  font-size: 18px
}

.confirm-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5
}

.confirm-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: auto;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
  font-size: 19px
}

.danger-icon {
  background: #fff0f0;
  color: var(--bad)
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px
}

.confirm-danger {
  padding: 12px;
  border: 1px solid var(--bad);
  border-radius: 12px;
  background: var(--bad);
  color: #fff;
  cursor: pointer
}

@media(min-width:768px) {
  .person-summary {
    grid-template-columns: 1fr 1fr 1.35fr
  }

  .net-card {
    grid-column: auto
  }

  .person-hero {
    padding: 22px
  }

  .person-tabs {
    margin-bottom: 14px
  }
}

@media(max-width:430px) {
  .person-summary .money {
    font-size: 17px
  }

  .person-summary .card {
    padding: 13px
  }

  .person-row .muted {
    white-space: normal;
    line-height: 1.45
  }
}

/* V1.5: settings, local data management, contact profile */
.settings-stack {
  display: grid;
  gap: 12px
}

.settings-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 10px 3px 0
}

.settings-card {
  padding-top: 4px;
  padding-bottom: 4px
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line)
}

.setting-row:last-child {
  border-bottom: 0
}

.setting-row select {
  max-width: 170px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  padding: 10px
}

.setting-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--accent-soft)
}

.full-btn {
  width: 100%;
  margin: 8px 0 12px
}

.full-btn:disabled {
  opacity: .55;
  cursor: not-allowed
}

.local-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px
}

.local-stats .card {
  text-align: center;
  padding: 16px 8px
}

.local-stats strong {
  display: block;
  font-size: 21px
}

.local-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px
}

.app-meta {
  text-align: center;
  padding: 8px 0 2px
}

.compact {
  padding: 8px 11px;
  white-space: nowrap
}

.contact-line {
  font-size: 12px;
  margin-top: 4px
}

.person-hero .secondary {
  flex: 0 0 auto
}

@media(max-width:430px) {
  .setting-row {
    align-items: flex-start
  }

  .setting-row select {
    max-width: 145px
  }

  .local-stats {
    gap: 7px
  }

  .local-stats strong {
    font-size: 18px
  }

  .person-hero {
    align-items: flex-start
  }

  .person-hero .compact {
    padding: 7px 9px
  }
}

/* V1.6: Admin UI mock */
.admin-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0
}

.admin-back-app {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer
}

.admin-back-app:active {
  transform: scale(.97)
}

.admin-shell {
  min-height: 100vh;
  background: var(--bg)
}

.admin-side {
  display: none
}

.admin-top {
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line)
}

.admin-demo-pill {
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .06em;
  padding: 6px 9px;
  border-radius: 999px;
  background: #fff4d8;
  color: #8a5b00
}

.admin-main {
  min-width: 0
}

.admin-content {
  padding: 20px 16px 92px
}

.admin-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px
}

.admin-title h1 {
  font-size: 23px;
  margin: 0 0 4px
}

.admin-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px
}

.admin-stats .card span,
.admin-stats .card small {
  display: block;
  color: var(--muted);
  font-size: 11px
}

.admin-stats .card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 24px;
  margin: 7px 0 3px
}

.admin-grid {
  display: grid;
  gap: 16px
}

.admin-table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow)
}

.admin-table-head {
  display: none
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer
}

.admin-user-row:last-child {
  border-bottom: 0
}

.admin-user-row>strong:nth-of-type(1),
.admin-user-row>span:nth-of-type(2) {
  display: none
}

.status-dot {
  font-size: 10px;
  font-weight: 750;
  padding: 5px 8px;
  border-radius: 999px;
  white-space: nowrap
}

.status-dot.active {
  background: #eaf8f1;
  color: var(--good)
}

.status-dot.inactive {
  background: #f1f3f5;
  color: var(--muted)
}

.admin-activity {
  padding-top: 6px;
  padding-bottom: 6px
}

.admin-activity>div {
  display: grid;
  gap: 3px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line)
}

.admin-activity>div:last-child {
  border: 0
}

.admin-activity span,
.admin-activity small {
  color: var(--muted);
  font-size: 11px
}

.admin-mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 68px;
  z-index: 9;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line)
}

.admin-mobile-nav button {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px
}

.admin-mobile-nav button.active {
  color: var(--accent);
  font-weight: 800
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 14px
}

.admin-profile h2 {
  margin: 0 0 5px
}

.user-stats {
  margin-top: 12px
}

.date-stat {
  font-size: 16px !important
}

.admin-info {
  margin-top: 12px
}

.admin-info>div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line)
}

.admin-info>div:last-child {
  border: 0
}

.admin-info span {
  color: var(--muted)
}

.admin-info strong {
  text-align: right
}

.admin-note {
  margin-top: 12px;
  padding: 14px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5
}

.audit-head {
  display: none
}

.audit-row {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line)
}

.audit-row:last-child {
  border: 0
}

.audit-row span {
  font-size: 11px;
  color: var(--muted)
}

@media(min-width:768px) {
  .admin-content {
    padding: 28px 28px 100px
  }

  .admin-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr))
  }

  .admin-user-row {
    grid-template-columns: minmax(220px, 1.4fr) 140px 70px 140px 28px
  }

  .admin-user-row>strong:nth-of-type(1),
  .admin-user-row>span:nth-of-type(2) {
    display: block
  }

  .admin-table-head {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) 140px 70px 140px 28px;
    gap: 12px;
    padding: 11px 16px;
    background: var(--bg);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase
  }

  .audit-head,
  .audit-row {
    display: grid;
    grid-template-columns: 1.2fr 1.5fr 1fr 140px;
    gap: 12px;
    align-items: center
  }

  .audit-head {
    padding: 11px 16px;
    background: var(--bg);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase
  }
}

@media(min-width:1200px) {
  .admin-back-app {
    display: none
  }

  .admin-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-rows: 72px minmax(calc(100vh - 72px), auto)
  }

  .admin-side {
    display: flex;
    flex-direction: column;
    grid-column: 1;
    grid-row: 1/3;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 16px;
    background: var(--card);
    border-right: 1px solid var(--line)
  }

  .admin-brand {
    font-size: 18px;
    font-weight: 850;
    margin: 0 8px 26px
  }

  .admin-brand span {
    font-size: 8px;
    background: var(--accent);
    color: #fff;
    border-radius: 5px;
    padding: 3px 5px;
    vertical-align: middle
  }

  .admin-side button {
    border: 0;
    background: none;
    color: var(--muted);
    padding: 12px 13px;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    margin: 2px 0
  }

  .admin-side button.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 800
  }

  .admin-side-bottom {
    margin-top: auto
  }

  .admin-top {
    grid-column: 2;
    grid-row: 1;
    height: 72px;
    padding: 0 32px
  }

  .admin-main {
    grid-column: 2;
    grid-row: 2
  }

  .admin-content {
    width: min(1280px, 100%);
    margin: auto;
    padding: 32px
  }

  .admin-mobile-nav {
    display: none
  }

  .admin-grid {
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr);
    align-items: start
  }

  .admin-title h1 {
    font-size: 27px
  }

  .admin-stats {
    gap: 14px
  }
}

@media(max-width:520px) {
  .admin-stats .card {
    padding: 13px
  }

  .admin-stats .card strong {
    font-size: 20px
  }

  .admin-info>div {
    display: grid;
    gap: 5px
  }

  .admin-info strong {
    text-align: left
  }

  .admin-profile {
    align-items: flex-start;
    flex-wrap: wrap
  }

  .admin-profile .status-dot {
    margin-left: 68px
  }
}

/* V1.7 polish: magenta accent, soft interactions, long-data safety */
a,
button,
.debt,
.person-row,
.admin-user-row,
.close-btn,
.admin-back-app,
.setting-icon,
.avatar {
  transition: transform .16s ease, background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, opacity .18s ease
}

@media (hover:hover) {

  button:not(:disabled):hover,
  .link-btn:hover,
  .back-btn:hover {
    transform: translateY(-1px)
  }

  .primary:hover,
  .types button.active:hover,
  .app-fab:hover {
    background: var(--accent-hover);
    box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 32%, transparent)
  }

  .secondary:hover,
  .close-btn:hover,
  .admin-back-app:hover,
  .pagination button:not(:disabled):hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    background: var(--accent-soft);
    color: var(--accent)
  }

  .debt:hover,
  .person-row:hover,
  .admin-user-row:hover {
    background: color-mix(in srgb, var(--accent-soft) 55%, transparent)
  }

  .nav button:hover,
  .admin-mobile-nav button:hover,
  .desktop-side button:hover,
  .admin-side button:hover {
    color: var(--accent)
  }

  .mini-actions button:hover,
  .link-btn:hover,
  .back-btn:hover {
    text-decoration: none;
    color: var(--accent-hover)
  }
}

button:not(:disabled):active,
.debt:active,
.person-row:active,
.admin-user-row:active {
  transform: scale(.985)
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent);
  outline-offset: 2px
}

.nav button,
.admin-mobile-nav button {
  font-size: 12px
}

.nav button::first-line,
.admin-mobile-nav button::first-line {
  font-size: 14px
}

.close-btn {
  font-size: 19px
}

.app-fab {
  font-weight: 300
}

.name,
.admin-user-row strong,
.admin-user-row .muted,
.audit-row span,
.contact-line {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.debt .muted {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.long-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0
}

.char-count {
  text-align: right;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px
}

.char-count.near-limit {
  color: var(--bad);
  font-weight: 700
}

/* V1.8 polish: consistent primary back controls + rounded search focus */
.admin-back-app,
.back-btn {
  color: var(--accent)
}

.admin-back-app {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-soft);
  font-weight: 800
}

.search-box {
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)
}

.search-box input:focus,
.search-box input:focus-visible {
  outline: none !important;
  box-shadow: none !important
}

.truncate-title {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.debt .grow,
.person-hero .grow {
  overflow: hidden
}

@media(max-width:430px) {
  .name {
    max-width: 100%
  }

  .section-head h2 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
  }

  .row-arrow {
    flex: 0 0 auto
  }
}

.header-avatar,
.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%
}

.google-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  background: var(--accent-soft)
}

.google-avatar-fallback,
.google-avatar-img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%
}

.google-avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 800;
  line-height: 1
}

.google-avatar-img {
  display: block;
  object-fit: cover;
  border-radius: inherit
}

.header-account {
  display: flex;
  align-items: center
}

.account-avatar {
  width: 42px;
  height: 42px
}

/* V2.3: live Firestore admin */
.admin-demo-pill {
  background: #eaf8f1;
  color: var(--good)
}

.admin-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700
}

.admin-user-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0
}

.admin-avatar {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
  object-fit: cover
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0
}

.admin-debt-list {
  overflow: hidden
}

.admin-debt-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border, #e5e7eb)
}

.admin-debt-row:last-child {
  border-bottom: 0
}

.admin-debt-row>div:last-child {
  text-align: right
}

.admin-actions .secondary {
  min-width: 170px
}

.admin-error {
  max-width: 720px;
  margin: 30px auto;
  padding: 24px
}

.admin-error h2 {
  margin: 0 0 8px
}

.admin-error p {
  color: var(--muted);
  line-height: 1.5
}

.admin-error-code {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg);
  font: 12px/1.5 monospace;
  overflow: auto
}

.admin-error-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px
}

.admin-debt-detail {
  margin-bottom: 12px;
  padding: 0;
  overflow: hidden
}

.admin-debt-detail .admin-debt-row {
  padding: 16px
}

.admin-subsection {
  border-top: 1px solid var(--line);
  padding: 12px 16px
}

.admin-subtitle {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px
}

.admin-history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 12px
}

.admin-history-row span {
  color: var(--muted)
}

/* V2.4.5 Admin polish */
.admin-user-finance-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, minmax(110px, 150px)) 28px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer
}

.admin-user-finance-row:last-child {
  border-bottom: 0
}

.admin-user-finance-row:hover {
  background: var(--accent-soft)
}

.admin-user-finance-row>strong {
  text-align: right
}

.admin-user-finance-head {
  grid-template-columns: minmax(0, 1fr) repeat(3, minmax(110px, 150px)) 28px
}

.admin-debt-click {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  cursor: pointer;
  color: var(--text);
  background: var(--card);
  margin-bottom: 12px
}

.admin-debt-click:last-child {
  margin-bottom: 0
}

.admin-debt-click:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-soft)
}

.admin-debt-click .admin-debt-row {
  border-bottom: 0;
  align-items: center
}

.admin-debt-meta {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px;
  color: var(--muted);
  font-size: 11px
}

.admin-debt-meta span {
  padding: 5px 8px;
  background: var(--bg);
  border-radius: 999px
}

.admin-modal-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: var(--accent-soft);
  padding: 14px;
  border-radius: 14px;
  margin-bottom: 14px
}

.admin-modal-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px
}

.admin-modal-summary strong {
  display: block;
  margin-top: 5px;
  font-size: 16px
}

.admin-modal-section {
  padding: 14px 0;
  border-top: 1px solid var(--line)
}

.admin-modal-section:first-of-type {
  border-top: 0
}

.compact-info {
  margin-top: 0
}

.compact-info>div {
  padding: 8px 0
}

.admin-actions .danger {
  border-color: color-mix(in srgb, var(--bad) 35%, var(--line));
  color: var(--bad)
}

@media(max-width:767px) {
  .admin-user-finance-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px
  }

  .admin-user-finance-row>strong {
    display: none
  }

  .admin-user-finance-head {
    display: none
  }

  .admin-modal-summary {
    grid-template-columns: 1fr 1fr
  }

  .admin-modal-summary>div:last-child {
    grid-column: 1/-1
  }

  .admin-debt-row {
    gap: 9px
  }

  .admin-debt-row .row-arrow {
    font-size: 21px
  }
}

/* V2.4.5 Admin finance/timeline polish */
.admin-finance-cell {
  min-width: 0;
  text-align: right
}

.admin-finance-cell strong {
  display: block
}

.admin-finance-cell small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px
}

.admin-stats-finance {
  grid-template-columns: repeat(5, minmax(0, 1fr))
}

.admin-detail-sheet {
  max-width: 900px;
  margin: auto
}

.admin-payment-list {
  display: grid;
  gap: 8px
}

.admin-payment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card)
}

.admin-payment-row div {
  display: grid;
  gap: 2px
}

.admin-payment-row span {
  font-size: 11px;
  color: var(--muted)
}

.admin-timeline {
  display: grid;
  gap: 14px
}

.admin-timeline-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  position: relative
}

.admin-timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 20px;
  bottom: -18px;
  width: 1px;
  background: var(--line)
}

.admin-timeline-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  z-index: 1
}

.admin-timeline-content {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--card)
}

.admin-timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center
}

.admin-timeline-head span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap
}

.admin-timeline-delta {
  margin-top: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700
}

.admin-before-after {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 10px
}

.admin-before-after>div:not(.timeline-arrow) {
  padding: 10px;
  border-radius: 11px;
  background: var(--bg);
  min-width: 0
}

.admin-before-after span,
.admin-before-after small {
  display: block;
  color: var(--muted);
  font-size: 10px
}

.admin-before-after strong {
  display: block;
  margin: 4px 0;
  font-size: 14px
}

.timeline-arrow {
  text-align: center;
  color: var(--muted);
  font-size: 17px
}

.admin-timeline-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted)
}

@media(max-width:1100px) {
  .admin-stats-finance {
    grid-template-columns: repeat(3, minmax(0, 1fr))
  }
}

@media(max-width:767px) {
  .admin-stats-finance {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }

  .admin-stats-finance .card:last-child {
    grid-column: 1/-1
  }

  .admin-finance-cell {
    display: none
  }

  .admin-detail-sheet {
    padding: 16px
  }

  .admin-before-after {
    grid-template-columns: 1fr
  }

  .timeline-arrow {
    transform: rotate(90deg)
  }
}

.admin-user-timeline {
  margin-bottom: 18px
}

.admin-user-timeline .admin-timeline-debt {
  color: var(--muted);
  font-weight: 500
}

.admin-user-timeline .admin-timeline-head>div {
  min-width: 0
}

.admin-user-timeline .admin-timeline-head strong {
  overflow-wrap: anywhere
}

.timeline-more {
  text-align: center;
  padding: 8px 0 2px
}

@media(max-width:767px) {
  .admin-user-timeline .admin-timeline-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px
  }

  .admin-user-timeline .admin-timeline-head>span {
    white-space: normal
  }
}

/* V2.4.6: offline status and simple user timeline filters */
.network-pill {
  font-size: 9px;
  font-weight: 800;
  padding: 5px 8px;
  border-radius: 999px;
  margin-right: 8px
}

.network-pill.online {
  background: #eaf8f1;
  color: var(--good)
}

.network-pill.offline {
  background: #fff1f0;
  color: var(--bad)
}

.timeline-filters {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: -2px 0 12px
}

.timeline-filters button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 11px
}

.timeline-filters button.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  font-weight: 750
}

.sync-card {
  margin-top: -4px
}

.full-btn {
  width: 100%;
  margin-top: 10px
}

.admin-demo-pill {
  white-space: nowrap
}

@media(max-width:520px) {
  .network-pill {
    display: none
  }
}

/* V2.4.9 UI polish: compact timeline, pagination, aligned finance columns, toasts */
.admin-user-finance-head,
.admin-user-finance-row {
  grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(145px, 180px)) 28px
}

.admin-user-finance-head>span:not(:first-child) {
  text-align: right
}

.admin-user-finance-row .admin-finance-cell {
  text-align: right;
  justify-self: stretch
}

.admin-user-finance-row .row-arrow {
  text-align: center
}

.admin-debt-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 170px) 28px;
  align-items: center;
  gap: 14px
}

.admin-debt-row .grow {
  overflow-wrap: anywhere;
}

.admin-debt-amount {
  text-align: right;
  min-width: 0
}

.admin-debt-amount strong {
  display: block
}

.admin-debt-amount .muted {
  white-space: nowrap
}

.admin-debt-click:nth-child(odd) {
  background: var(--card)
}

.admin-debt-click:nth-child(even) {
  background: var(--accent-soft)
}

.admin-debt-click:nth-child(even):hover {
  background: color-mix(in srgb, var(--accent-soft) 78%, var(--card))
}

.admin-debt-click {
  transition: background-color .18s ease, border-color .18s ease, transform .12s ease
}

.admin-debt-click:active {
  transform: translateY(1px)
}

.status-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 750;
  white-space: nowrap
}

.admin-user-row>.status-dot {
  justify-self: start
}

.timeline-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin: 10px 0 2px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer
}

.timeline-toggle:hover {
  background: var(--accent-soft)
}

.admin-timeline {
  overflow: visible
}

.admin-timeline-content {
  min-width: 0
}

.toast-wrap {
  top: 16px;
  right: 16px;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px))
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  color: var(--text);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 34px #0002;
  font-weight: 650
}

.toast.error {
  background: color-mix(in srgb, #b42318 86%, transparent);
  border-color: color-mix(in srgb, #b42318 35%, transparent);
  color: #fff
}

.toast.warning {
  background: color-mix(in srgb, #a66b00 82%, transparent);
  border-color: color-mix(in srgb, #a66b00 35%, transparent);
  color: #fff
}

.toast.info {
  background: color-mix(in srgb, #315f9b 82%, transparent);
  border-color: color-mix(in srgb, #315f9b 35%, transparent);
  color: #fff
}

.toast-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 850
}

.toast-message {
  min-width: 0;
  flex: 1;
  line-height: 1.35
}

.toast-close {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 0;
  background: transparent;
  color: currentColor;
  opacity: .72;
  border-radius: 7px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1
}

.toast-close:hover {
  opacity: 1;
  background: #0001
}

@media(max-width:767px) {

  .admin-user-finance-head,
  .admin-user-finance-row {
    grid-template-columns: minmax(0, 1fr) auto
  }

  .admin-user-finance-row .admin-finance-cell {
    display: none
  }

  .admin-debt-row {
    grid-template-columns: minmax(0, 1fr) auto 24px
  }

  .toast-wrap {
    top: 12px;
    left: 12px;
    right: 12px;
    max-width: none
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%
  }
}

/* V2.4.10 UI polish: semantic toasts, aligned timeline toggles, compact pagination */
.timeline-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px
}

.timeline-toggle-icon {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  box-sizing: border-box;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transform-origin: center
}

.timeline-toggle-icon.is-open {
  transform: rotate(225deg) translateY(-1px)
}

.timeline-toggle span:last-child {
  line-height: 1.2
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 14px 0 4px
}

.pagination button,
.pagination-ellipsis {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  box-sizing: border-box
}

.pagination button {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  cursor: pointer
}

.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 800
}

.pagination button:disabled {
  opacity: .38;
  cursor: not-allowed
}

.pagination-ellipsis {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700
}

.toast {
  border-width: 1px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: blur(16px) saturate(145%);
  -webkit-backdrop-filter: blur(16px) saturate(145%);
  box-shadow: 0 14px 36px #0002
}

.toast.success {
  background: color-mix(in srgb, #16834b 88%, transparent);
  border-color: color-mix(in srgb, #8be0b2 58%, transparent);
  color: #fff
}

.toast.error {
  background: color-mix(in srgb, #c62828 88%, transparent);
  border-color: color-mix(in srgb, #ffb0b0 55%, transparent);
  color: #fff
}

.toast.warning {
  background: color-mix(in srgb, #b77900 88%, transparent);
  border-color: color-mix(in srgb, #ffd27a 55%, transparent);
  color: #fff
}

.toast.info {
  background: color-mix(in srgb, #2869a6 88%, transparent);
  border-color: color-mix(in srgb, #a9d6ff 55%, transparent);
  color: #fff
}

.toast-icon {
  background: #fff2;
  border-color: #fff8
}

.toast-close {
  color: currentColor
}

@media(max-width:520px) {
  .pagination {
    gap: 5px
  }

  .pagination button,
  .pagination-ellipsis {
    width: 34px;
    height: 34px
  }

  .timeline-toggle {
    width: 100%
  }
}

/* V2.4.11: pagination stays on one row; narrow screens scroll horizontally instead of wrapping. */
.pagination {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  justify-content: center;
  max-width: 100%;
  padding: 2px 4px 5px;
  scrollbar-width: none;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box
}

.pagination::-webkit-scrollbar {
  display: none
}

.pagination button,
.pagination-ellipsis {
  flex: 0 0 36px
}

@media(max-width:767px) {
  .pagination {
    justify-content: flex-start
  }

  .pagination button,
  .pagination-ellipsis {
    flex-basis: 34px
  }
}

/* V2.4.11: consistent select text/icon spacing. */
.filters select,
.setting-row select,
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-left: 12px;
  padding-right: 38px;
  background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23707780' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) center;
  background-size: 14px 14px
}

body.dark .filters select,
body.dark .setting-row select,
body.dark .field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa3ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
}


/* V2.4.13: backup / restore */
.backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 4px
}

.backup-actions button {
  min-width: 0
}

.backup-help {
  font-size: 11px;
  line-height: 1.4;
  padding: 2px 0 10px
}

@media(max-width:420px) {
  .backup-actions {
    grid-template-columns: 1fr
  }
}


/* V2.4.20: stable restore + auth feedback + loading skeleton */
.skeleton {
  display: block;
  background: linear-gradient(90deg, color-mix(in srgb, var(--line) 55%, transparent) 25%, color-mix(in srgb, var(--card) 92%, var(--line)) 50%, color-mix(in srgb, var(--line) 55%, transparent) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.25s ease-in-out infinite;
  border-radius: 8px
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0
  }

  100% {
    background-position: -200% 0
  }
}

.skeleton-line {
  height: 13px
}

.skeleton-title {
  width: min(220px, 60%);
  height: 20px
}

.skeleton-meta {
  width: min(180px, 48%);
  margin-top: 8px
}

.skeleton-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: 0 0 44px
}

.skeleton-pill {
  width: 64px;
  height: 24px;
  border-radius: 999px
}

.skeleton-box {
  width: 110px;
  height: 20px;
  border: 0;
  background: transparent
}

.skeleton-actions {
  display: flex;
  gap: 10px
}

.skeleton-button {
  height: 38px;
  width: 136px;
  border-radius: 10px
}

.skeleton-stat {
  min-height: 82px
}

.skeleton-small {
  width: 90px;
  height: 11px
}

.skeleton-money {
  width: 120px;
  height: 22px;
  margin-top: 9px
}

.skeleton-info {
  display: grid;
  gap: 16px
}

.skeleton-info>div {
  display: flex;
  justify-content: space-between;
  gap: 20px
}

.skeleton-value {
  width: 90px;
  height: 14px
}

.skeleton-count {
  width: 50px;
  height: 13px
}

.skeleton-block {
  height: 72px;
  border-radius: 12px
}

.skeleton-dashboard-block {
  min-height: 180px
}

.skeleton-timeline .admin-timeline-content {
  width: 100%
}

.admin-page-skeleton {
  display: grid;
  gap: 18px
}

.admin-page-skeleton .admin-title {
  margin-bottom: 0
}

@media(max-width:767px) {
  .skeleton-actions {
    flex-wrap: wrap
  }

  .skeleton-button {
    flex: 1;
    min-width: 130px
  }
}


/* V2.4.21: detail history timeline + global/modal scroll-to-top */
.history-card {
  position: relative;
  padding: 10px 12px
}

.history-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 12px 8px
}

.history-row.history-extra {
  display: none
}

.history-row.history-extra.is-visible {
  display: flex
}

.history-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  margin-left: 2px
}

.history-row:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 25px;
  bottom: -1px;
  width: 1px;
  background: var(--line);
  z-index: 0
}

.history-row>.grow {
  position: relative;
  z-index: 1
}

.history-right {
  position: relative;
  z-index: 1;
  background: var(--card);
  padding-left: 4px
}

.history-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 40px;
  margin: 10px 0 2px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer
}

.history-toggle:hover {
  background: var(--accent-soft)
}

.scroll-top {
  position: fixed;
  right: 20px;
  bottom: 150px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  color: var(--text);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px #0002;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: .2s ease;
  z-index: 25
}

.scroll-top.show {
  opacity: 1;
  visibility: visible;
  transform: none
}

.scroll-top:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line))
}

.confirm-box {
  max-height: min(80vh, 520px);
  overflow: auto
}

.confirm-actions {
  position: sticky;
  bottom: 0;
  background: var(--card);
  padding-top: 10px
}

@media(max-width:767px) {
  .scroll-top {
    right: 16px;
    bottom: 140px;
    width: 40px;
    height: 40px
  }

  .history-row {
    align-items: flex-start
  }

  .history-dot {
    margin-top: 7px
  }

  .history-right {
    margin-left: auto
  }
}

/* V2.4.23: unified admin security actions + confirmation UI */
.confirm-box {
  position: relative;
  overflow: hidden
}

.confirm-box.success .confirm-icon {
  background: #eaf8f1;
  color: var(--good)
}

.confirm-box.info .confirm-icon {
  background: var(--accent-soft);
  color: var(--accent)
}

.confirm-box.warning .confirm-icon {
  background: #fff7df;
  color: #a56a00
}

.confirm-box.danger .confirm-icon {
  background: #fff0f0;
  color: var(--bad)
}

.confirm-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4
}

.confirm-actions button:disabled {
  opacity: .55;
  cursor: wait
}

.confirm-actions .primary:disabled,
.confirm-actions .confirm-danger:disabled {
  filter: saturate(.7)
}

.toast {
  border: 1px solid #ffffff2b;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: #17202add
}

.toast.success {
  background: #13865cdd;
  color: #fff
}

.toast.error {
  background: #cf3f45dd;
  color: #fff
}

.toast.warning {
  background: #b87912dd;
  color: #fff
}

.toast.info {
  background: #3478badd;
  color: #fff
}

.toast-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid #ffffff55;
  border-radius: 50%;
  display: grid;
  place-items: center
}

.toast-message {
  flex: 1
}

.toast-close {
  border: 0;
  background: none;
  color: inherit;
  opacity: .8;
  font-size: 17px;
  cursor: pointer
}

.admin-actions .secondary:disabled {
  opacity: .48;
  cursor: not-allowed
}

/* V2.4.25: global UI polish + persistent scroll-top + audit paging — consistent scroll-to-top, skeletons, actions and responsive rows */
.scroll-top {
  z-index: 45;
  right: 22px;
  bottom: 156px;
  transition: opacity .22s ease, visibility .22s ease, transform .22s ease, background-color .18s ease, border-color .18s ease
}

.scroll-top[aria-hidden="true"] {
  pointer-events: none
}

@media(max-width:767px) {
  .scroll-top {
    right: 16px;
    bottom: 146px;
    width: 40px;
    height: 40px
  }
}

/* Keep admin user rows aligned on small screens: arrow stays on the same row. */
@media(max-width:767px) {
  .admin-user-row {
    grid-template-columns: minmax(0, 1fr) auto 28px;
    column-gap: 8px
  }

  .admin-user-row>.status-dot {
    grid-column: 2;
    grid-row: 1;
    align-self: center
  }

  .admin-user-row>.row-arrow {
    grid-column: 3;
    grid-row: 1;
    display: grid;
    place-items: center;
    padding: 0;
    margin: 0;
    font-size: 21px;
    line-height: 1
  }
}

.row-arrow {
  display: grid;
  place-items: center;
  line-height: 1;
  min-width: 24px
}

/* Timeline toggle: icon has its own fixed box so text/icon never drift apart. */
.timeline-toggle {
  gap: 8px;
  min-height: 42px
}

.timeline-toggle-icon {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  margin-top: -4px;
  transform: rotate(45deg);
}

.timeline-toggle-icon.is-open {
  margin-top: 3px;
  transform: rotate(225deg)
}

.history-toggle {
  gap: 8px
}

/* Payment history actions are real touch-friendly app buttons, not inline text. */
.mini-actions {
  align-items: center;
  gap: 6px;
  margin-top: 7px
}

.mini-actions button {
  min-width: 44px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer
}

.mini-actions .danger-text {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 28%, var(--line))
}

.mini-actions button:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line))
}

.mini-actions .danger-text:hover {
  background: #fff0f0;
  border-color: color-mix(in srgb, var(--bad) 42%, var(--line))
}

/* Disabled means no data has changed yet. */
.primary:disabled,
.secondary:disabled,
.types button:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important
}

.form-grid>.primary:disabled {
  filter: saturate(.65)
}

/* More transparent semantic toasts: the page remains visible underneath. */
.toast {
  background: rgba(23, 32, 42, .78);
  border-color: rgba(255, 255, 255, .22);
  backdrop-filter: blur(14px) saturate(135%);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .16)
}

.toast.success {
  background: rgba(19, 134, 92, .78);
  border-color: rgba(184, 246, 213, .46)
}

.toast.error {
  background: rgba(207, 63, 69, .78);
  border-color: rgba(255, 205, 205, .46)
}

.toast.warning {
  background: rgba(184, 121, 18, .78);
  border-color: rgba(255, 225, 155, .46)
}

.toast.info {
  background: rgba(52, 120, 186, .78);
  border-color: rgba(198, 227, 255, .46)
}

.toast-icon {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .55)
}

/* App loading skeleton, used while the first Firestore state is loading. */
.app-page-skeleton {
  display: grid;
  gap: 14px
}

.app-page-skeleton>.skeleton-title {
  width: min(220px, 55%);
  margin-top: 4px
}

.app-page-skeleton>.skeleton-meta {
  width: min(160px, 42%)
}

.skeleton-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px
}

.skeleton-list {
  padding: 8px 14px;
  overflow: hidden
}

.skeleton-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  border-bottom: 1px solid var(--line)
}

.skeleton-list-row:last-child {
  border-bottom: 0
}

.skeleton-list-name {
  width: min(180px, 65%);
  height: 13px
}

.skeleton-list-meta {
  width: min(130px, 48%);
  height: 11px;
  margin-top: 7px
}

.skeleton-list-amount {
  width: 80px;
  height: 17px;
  flex: 0 0 80px
}

@media(min-width:768px) {
  .skeleton-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr))
  }
}

@media(max-width:430px) {
  .skeleton-list {
    padding: 8px 10px
  }

  .skeleton-list-amount {
    width: 68px;
    flex-basis: 68px
  }
}

/* Audit table: full date + time stays aligned with the header. */
@media(min-width:768px) {

  .audit-head,
  .audit-row {
    grid-template-columns: minmax(180px, 1.15fr) minmax(210px, 1.5fr) minmax(180px, 1fr) 175px
  }

  .audit-row>span:last-child {
    white-space: nowrap
  }
}

/* V2.5.0 daily features: quick payment, reminders, receipt sharing, person aggregation */
.reminder-card {
  margin-bottom: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  background: linear-gradient(135deg, var(--card), var(--accent-soft))
}

.reminder-card .section-head {
  margin: 0 0 4px
}

.reminder-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: var(--text);
  cursor: pointer
}

.reminder-row:first-of-type {
  border-top: 0
}

.reminder-row>strong:last-child {
  margin-left: auto
}

.reminder-row .muted,
.reminder-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px
}

.debt-row-enhanced {
  position: relative;
  padding-right: 92px
}

.debt-row-actions {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 5px;
  align-items: center
}

.icon-action {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px #00000008
}

.icon-action:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line))
}

.quick-pay-btn {
  color: var(--good);
  padding: 0 9px;
  min-width: 46px;
  width: auto
}

.quick-pay-icon {
  font-size: 12px;
  line-height: 1
}

.quick-pay-label {
  font-size: 10px;
  line-height: 1
}

.share-debt-btn {
  color: var(--accent)
}

.quick-payment-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 13px;
  border-radius: 14px;
  background: var(--accent-soft);
  margin-bottom: 14px
}

.quick-payment-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px
}

.quick-payment-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 15px
}

.quick-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px
}

.quick-presets button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--text);
  font-size: 11px;
  cursor: pointer
}

.quick-presets button:hover {
  border-color: var(--accent);
  color: var(--accent)
}

.share-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px
}

.share-option {
  display: grid;
  grid-template-columns: 32px 1fr;
  text-align: left;
  align-items: center;
  column-gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  cursor: pointer;
  color: var(--text)
}

.share-option span {
  grid-row: 1/3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent)
}

.share-option strong {
  font-size: 12px
}

.share-option small {
  color: var(--muted);
  font-size: 10px
}

.share-option.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 10%, transparent)
}

.receipt-preview {
  padding: 14px;
  border-radius: 16px;
  background: var(--bg);
  margin-bottom: 14px
}

.receipt-mini {
  min-height: 180px;
  border-radius: 14px;
  padding: 18px;
  background: linear-gradient(145deg, #fff, #fff5fb);
  border: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 7px;
  box-shadow: 0 8px 24px #00000008
}

.receipt-mini strong {
  font-size: 21px;
  color: #173c73
}

.receipt-mini span {
  font-weight: 700
}

.receipt-mini b {
  font-size: 21px;
  color: var(--good)
}

.receipt-mini small {
  color: var(--muted)
}

.reminder-settings-card input[type=checkbox] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent)
}

@media(max-width:520px) {
  .debt-row-enhanced {
    padding-right: 80px
  }

  .debt-row-actions {
    right: 7px
  }

  .icon-action {
    width: 32px;
    height: 32px
  }

  .quick-payment-summary {
    grid-template-columns: 1fr 1fr
  }

  .quick-payment-summary>div:last-child {
    grid-column: 1/-1
  }

  .share-options {
    grid-template-columns: 1fr
  }
}

/* V2.5.1 quick payment + receipt review polish */
.receipt-brand {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px
}

.receipt-brand strong {
  font-size: 21px;
  color: #173c73
}

.receipt-brand span {
  font-size: 10px;
  color: var(--muted);
  padding-top: 4px
}

.receipt-person {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px
}

.receipt-person span {
  font-weight: 800
}

.receipt-person small,
.receipt-mini-stats small,
.receipt-mini-meta span {
  color: var(--muted);
  font-size: 10px
}

.receipt-mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line)
}

.receipt-mini-stats div {
  min-width: 0
}

.receipt-mini-stats b {
  display: block;
  font-size: 12px;
  margin-top: 3px
}

.receipt-mini-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px
}

.receipt-mini-meta span {
  padding: 8px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line)
}

.receipt-mini-meta b {
  display: block;
  color: var(--text);
  margin-top: 2px
}

.receipt-mini-history {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line)
}

.receipt-mini-history>strong {
  font-size: 11px;
  color: var(--accent)
}

.receipt-preview-event {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line)
}

.receipt-preview-event:last-child {
  border-bottom: 0
}

.receipt-event-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 7px
}

.receipt-preview-event strong {
  display: block;
  font-size: 10px
}

.receipt-preview-event small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  margin-top: 2px
}

.receipt-preview-event b {
  font-size: 10px;
  white-space: nowrap
}

.share-sheet .receipt-preview {
  max-height: 430px;
  overflow: auto
}

@media(max-width:520px) {
  .debt-row-enhanced {
    padding-right: 92px
  }

  .quick-pay-btn {
    min-width: 38px;
    padding: 0 7px
  }

  .quick-pay-label {
    font-size: 9px
  }

  .receipt-mini-stats b {
    font-size: 11px
  }

  .receipt-mini-meta b {
    font-size: 9px
  }
}

/* V2.5.2 UI polish: reminder CTA, compact debt rows, mobile action placement and receipt timeline */
.reminder-view-all {
  font-size: 12px;
  padding: 0;
  white-space: nowrap
}

.debt-row-enhanced {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 3px;
  align-items: center;
  padding-right: 0
}

.debt-row-enhanced>.avatar {
  grid-column: 1;
  grid-row: 1/3;
  align-self: center
}

.debt-row-enhanced>.grow {
  grid-column: 2;
  grid-row: 1/3;
  min-width: 0
}

.debt-row-enhanced>.amount {
  grid-column: 3;
  grid-row: 1;
  align-self: end;
  max-width: min(180px, 30vw);
  overflow-wrap: anywhere
}

.debt-row-enhanced>.debt-row-actions {
  grid-column: 3;
  grid-row: 2;
  position: static;
  transform: none;
  justify-content: flex-end;
  align-self: start;
  display: flex;
  gap: 6px;
  margin-top: 2px
}

.debt-row-enhanced .debt-row-actions .icon-action {
  flex: 0 0 auto
}

.quick-pay-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 20%, transparent);
  padding: 0 10px;
  min-width: 58px
}

.quick-pay-btn:hover {
  background: var(--accent-hover);
  color: #fff;
  border-color: var(--accent-hover)
}

.quick-pay-icon {
  font-size: 11px
}

.quick-pay-label {
  font-size: 10px;
  font-weight: 800
}

.share-debt-btn {
  background: var(--card);
  color: var(--accent)
}

.receipt-mini-history {
  position: relative;
  padding-left: 14px
}

.receipt-mini-history:before {
  content: "";
  position: absolute;
  left: 3px;
  top: 31px;
  bottom: 7px;
  width: 1px;
  background: color-mix(in srgb, var(--accent) 30%, var(--line))
}

.receipt-preview-event {
  position: relative;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 8px 0
}

.receipt-event-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  z-index: 1
}

.receipt-preview-event .grow {
  min-width: 0
}

.receipt-preview-event strong {
  overflow-wrap: anywhere;
  line-height: 1.25
}

.receipt-preview-event small {
  white-space: normal;
  line-height: 1.25
}

.receipt-preview-event b {
  white-space: nowrap;
  text-align: right
}

@media(max-width:767px) {
  .app-fab {
    left: 50%;
    right: auto;
    bottom: 14px;
    transform: translateX(-50%);
    width: 54px;
    height: 54px;
    border-radius: 18px;
    z-index: 8
  }

  .scroll-top {
    right: 12px;
    bottom: 88px;
    width: 40px;
    height: 40px
  }

  .debt-row-enhanced {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    column-gap: 10px;
    padding-right: 0
  }

  .debt-row-enhanced>.amount {
    max-width: 135px;
    font-size: 13px
  }

  .quick-pay-btn {
    min-width: 58px;
    padding: 0 8px
  }

  .debt-row-actions {
    gap: 5px
  }
}

@media(max-width:430px) {
  .debt-row-enhanced>.amount {
    max-width: 120px;
    font-size: 12px
  }

  .debt-row-enhanced .name {
    white-space: nowrap
  }

  .debt-row-enhanced>.grow .muted {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
  }

  .quick-pay-btn {
    min-width: 56px
  }
}

@media(min-width:768px) {
  .debt-row-enhanced>.amount {
    max-width: 220px
  }

  .debt-row-enhanced>.debt-row-actions {
    margin-top: 1px
  }
}

/* V2.5.3 UI polish: raised mobile navigation + unified money presets */
.money-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px
}

.money-preset {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: .18s ease
}

.money-preset:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft)
}

.quick-pay-btn {
  min-width: 66px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px
}

.quick-pay-label {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap
}

.nav-add {
  display: none !important
}

@media(max-width:767px) {
  .nav {
    height: 55px;
    align-items: center;
    gap: 0;
    padding: 7px 8px max(7px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 26px #17202a12
  }

  .nav button {
    position: relative;
    height: 55px;
    min-width: 0;
    flex: 1;
    padding: 8px 5px;
    border-radius: 16px
  }

  .nav button.active {
    /* background: var(--accent-soft); */
    /* box-shadow: inset 0 2px 0 var(--accent) */
    border-top: 2px solid var(--accent);
  }

  .nav-add {
    display: grid !important;
    place-items: center;
    flex: 0 0 58px !important;
    width: 58px;
    height: 58px !important;
    margin: -10px 10px 0;
    border: 0 !important;
    border-radius: 18px !important;
    background: var(--accent) !important;
    color: #fff !important;
    font-size: 28px !important;
    font-weight: 300 !important;
    box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 36%, transparent)
  }

  .nav-add:hover {
    background: var(--accent-hover) !important;
    color: #fff !important
  }

  .app-fab {
    display: none
  }
}

@media(min-width:768px) {
  .nav {
    display: none
  }

  .nav-add {
    display: none !important
  }
}

/* V2.5.5 UI polish: compact actions, raised admin nav, stronger add button,
   deterministic history order, and clean screen reset behavior. */
.debt-row-enhanced>.amount {
  margin-bottom: 4px;
  align-self: end
}

.debt-row-enhanced>.debt-row-actions {
  gap: 4px;
  margin-top: 0
}

.debt-row-enhanced .icon-action {
  width: 32px;
  height: 32px;
  border-radius: 10px
}

.debt-row-enhanced .quick-pay-btn {
  min-width: 52px;
  height: 28px;
  padding: 0 8px;
  border-radius: 10px
}

.debt-row-enhanced .quick-pay-label {
  font-size: 10px;
  line-height: 1;
  white-space: nowrap
}

.debt-row-enhanced .share-debt-btn {
  width: 32px;
  height: 32px;
  font-size: 13px
}

@media(max-width:520px) {
  .debt-row-enhanced>.amount {
    margin-bottom: 4px
  }

  .debt-row-enhanced>.debt-row-actions {
    gap: 4px
  }

  .debt-row-enhanced .quick-pay-btn {
    min-width: 38px;
    padding: 0 7px
  }

  .debt-row-enhanced .quick-pay-label {
    font-size: 9px
  }

  .debt-row-enhanced .share-debt-btn {
    width: 31px;
    height: 31px
  }
}

/* Stronger + button: still keeps the same action and dimensions. */
@media(max-width:767px) {
  .nav-add {
    width: 30px !important;
    height: 30px !important;
    flex-basis: 45px !important;
    border-radius: 12px !important;
    font-size: 30px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 42%, transparent), 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent) !important
  }

  .nav-add:active {
    transform: translateY(-1px) scale(.96) !important
  }
}

/* Admin mobile navigation mirrors the user navigation: raised, rounded, active accent. */
@media(max-width:1199px) {
  .admin-mobile-nav {
    height: 78px !important;
    align-items: center;
    gap: 0;
    padding: 7px 8px max(7px, env(safe-area-inset-bottom)) !important;
    border-top: 1px solid var(--line) !important;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 26px #17202a12 !important;
    background: var(--card) !important
  }

  .admin-mobile-nav button {
    position: relative;
    height: 58px;
    min-width: 0;
    padding: 8px 5px;
    border-radius: 16px;
    font-size: 12px;
    line-height: 1.2
  }

  .admin-mobile-nav button.active {
    background: var(--accent-soft);
    box-shadow: inset 0 2px 0 var(--accent);
    color: var(--accent)
  }
}

/* V2.5.6: compact mobile footer typography for narrow devices. */
@media(max-width:430px) {
  .nav button {
    font-size: 11px;
    line-height: 1.15;
    padding: 7px 3px;
    white-space: nowrap
  }

  .nav .nav-icon {
    display: block;
    font-size: 16px;
    line-height: 20px;
    margin-bottom: 2px
  }

  .nav .nav-label {
    display: block;
    font-size: 10px;
    line-height: 14px
  }
}

@media(max-width:380px) {
  .nav {
    padding-left: 5px;
    padding-right: 5px
  }

  .nav button {
    padding-left: 2px;
    padding-right: 2px
  }

  .nav .nav-icon {
    font-size: 16px
  }

  .nav .nav-label {
    font-size: 9px
  }

  .nav-add {
    flex-basis: 40px !important;
    width: 30px;
    height: 30px !important
  }
}

/* V2.6.2 UI/settings/source polish: keep regular users focused on essential settings. */
.theme-select {
  width: 138px;
  max-width: 138px !important;
  padding: 8px 28px 8px 10px !important;
  font-size: 12px !important;
  line-height: 1.2
}

.app-logo {
  width: 40px;
  height: 40px;
  display: block;
  flex: 0 0 40px
}

.brand-with-logo {
  display: flex;
  align-items: center;
  gap: 8px
}

@media(max-width:430px) {
  .theme-select {
    width: 132px;
    max-width: 132px !important;
    font-size: 11px !important
  }

  .app-logo {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }
}


/* V2.6.4 receipt + long-content polish */
.receipt-mini-stats {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line)
}

.receipt-mini-stats>div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word
}

.receipt-mini-stats b {
  margin-top: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  text-align: right
}

.receipt-brand {
  display: flex;
  align-items: center;
  justify-content: left;
  gap: 8px;
  min-width: 0;
  text-align: left
}

.receipt-brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  object-fit: contain;
  border-radius: 10px
}

.receipt-brand>div {
  min-width: 0
}

.receipt-brand .custom-span {
  display: flex;
  padding-top: 0;
  margin-top: -2px;
}

.receipt-brand strong,
.receipt-brand span,
.receipt-person span,
.receipt-person small,
.receipt-mini-meta span,
.receipt-mini-meta b {
  overflow-wrap: anywhere;
  word-break: break-word
}

.receipt-preview-event strong,
.receipt-preview-event small,
.receipt-preview-event b {
  overflow-wrap: anywhere;
  word-break: break-word
}

.receipt-preview-event b {
  white-space: normal
}

.name,
.muted,
.label,
.field label,
.field-help,
.section-head h2,
.person-hero h2,
.contact-line,
.audit-row span,
.admin-user-row strong,
.admin-user-row .muted {
  overflow-wrap: anywhere;
  word-break: break-word
}

.section-head .custom-h2 {
  flex: 0 0 82%;
}

.reminder-row>div {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word
}

.debt-row-enhanced>.grow {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word
}

.debt-row-enhanced>.amount {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  text-align: right
}

.quick-pay-label,
.share-debt-btn {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal
}
/* Local Font Awesome icon system: preserves existing icon box dimensions. */
.fas,
.far,
.app-fab {
  font-style: normal;
  display: inline-block;
  line-height: .3;
  flex: 0 0 auto;
}
.nav-icon .fas,
.nav-icon .far,
.admin-side button > .fas,
.admin-mobile-nav button > .fas {
  width: 1em;
  text-align: center;
}
.scroll-top > .fas {
  font-size: .6em;
  line-height: 1;
}
.toast-icon > .fas,
.confirm-icon > .fas,
.close-btn > .fas,
.icon-action > .fas,
.link-btn > .fas,
.row-arrow > .fas {
  pointer-events: none;
}


/* V3 icon polish: keep add controls' original geometry while using Font Awesome glyphs. */
.app-fab > .fas,
.nav-add > .fas {
  display: inline-block;
  width: .8em;
  height: .6em;
  line-height: .6;
  font-size: .6em;
  font-weight: 900;
  text-align: center;
  flex: 0 0 auto;
}

/* V3 mobile: only the raised bottom-navigation add button is shown.
   The desktop FAB stays desktop-only to prevent two + controls overlapping. */
@media (max-width: 767px) {
  .app-fab {
    display: none !important;
  }
}



/* V4.1: subtle attention animation for the reminder bell. */
.reminder-bell {
  display: inline-block;
  color: var(--accent);
  transform-origin: 50% 12%;
  animation: reminder-bell-ring 2.4s ease-in-out infinite;
}

@keyframes reminder-bell-ring {
  0%, 72%, 100% { transform: rotate(0deg); }
  76% { transform: rotate(9deg); }
  80% { transform: rotate(-9deg); }
  84% { transform: rotate(6deg); }
  88% { transform: rotate(-4deg); }
  92% { transform: rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .reminder-bell { animation: none; }
}

/* V3.1: app-native dropdowns on mobile. Native select popups are browser-owned
   and can leave a large white surface over the page, so mobile uses a small
   in-app list while desktop keeps the native select behavior. */
.custom-select-wrap {
  position: relative;
  min-width: 0
}

.custom-select-trigger,
.custom-select-menu {
  display: none
}

@media(max-width:767px) {
  .custom-select-wrap > select {
    position: absolute !important;
    inset: 0;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .custom-select-trigger {
    width: 100%;
    min-height: 35px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    text-align: left;
    cursor: pointer;
  }

  .custom-select-trigger .fas {
    color: var(--muted);
    font-size: 11px;
    flex: 0 0 auto;
  }

  .custom-select-wrap.open .custom-select-trigger {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent)
  }

  .custom-select-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 5px);
    display: none;
    max-height: 220px;
    overflow: auto;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--card);
    box-shadow: 0 14px 32px #17202a22;
    z-index: 40;
  }

  .custom-select-wrap.open .custom-select-menu {
    display: grid;
    gap: 2px;
  }

  .custom-select-option {
    width: 100%;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    padding: 10px 11px;
    text-align: left;
    font: inherit;
    cursor: pointer;
  }

  .custom-select-option.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 750;
  }

  .custom-select-option:active {
    transform: scale(.99)
  }

  .theme-select-wrap {
    width: 138px;
    max-width: 138px;
    flex: 0 0 138px;
  }

  .theme-select-wrap .custom-select-trigger {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 12px;
  }
}

@media(max-width:430px) {
  .theme-select-wrap {
    width: 132px;
    max-width: 132px;
    flex-basis: 132px;
  }

  .theme-select-wrap .custom-select-trigger {
    font-size: 11px;
  }
}

/* Admin detail follows the same bottom-sheet behavior as user popups on phones. */
.admin-debt-modal {
  align-items: flex-end;
}

.admin-debt-modal .admin-detail-sheet {
  width: min(900px, calc(100vw - 40px));
  max-height: 92vh;
  overflow: auto;
  margin: auto;
}

@media(max-width:767px) {
  .admin-debt-modal {
    align-items: flex-end;
  }

  .admin-debt-modal .admin-detail-sheet {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    margin: 0;
    border-radius: 24px 24px 0 0;
    padding: 20px;
  }
}

/* Smooth attention cue for the primary add action. */
@keyframes nav-add-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(.8); }
}

.app-fab > .fas,
.nav-add > .fas {
  animation: nav-add-pulse 1.8s ease-in-out infinite;
  transform-origin: center;
}

.app-fab:active > .fas,
.nav-add:active > .fas {
  animation: none;
  transform: scale(.94);
}

@media(prefers-reduced-motion: reduce) {
  .nav-add > .fas {
    animation: none;
  }
}

.fas.fa-chevron-right {
  font-size: 10px;
}

/* V5.1 responsive navigation fix:
   - <=767px: keep the existing mobile raised navigation.
   - 768px..1199px: show a dedicated tablet bottom navigation.
   - >=1200px: keep the existing desktop sidebar navigation. */
@media (min-width: 768px) and (max-width: 1199px) {
  .nav {
    display: flex;
    height: 74px;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 3vw, 34px);
    padding: 8px clamp(18px, 5vw, 56px) max(8px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--card) 96%, transparent);
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 26px #17202a0d;
    -webkit-backdrop-filter: blur(10px) saturate(115%);
    backdrop-filter: blur(10px) saturate(115%);
  }

  .nav button:not(.nav-add) {
    flex: 0 1 180px;
    min-width: 112px;
    height: 54px;
    padding: 8px 14px;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 13px;
    line-height: 1.15;
    transition: background-color .2s ease, color .2s ease, transform .2s ease;
  }

  .nav button:not(.nav-add).active {
    /* background: var(--accent-soft); */
    color: var(--accent);
    /* box-shadow: inset 0 2px 0 var(--accent); */
    border-top: 2px solid var(--accent);
  }

  .nav .nav-icon,
  .nav .nav-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav .nav-icon {
    font-size: 15px;
  }

  .nav-add {
    display: none !important;
  }

  .content {
    padding-bottom: 118px;
  }

  .app-fab {
    display: grid;
    place-items: center;
    bottom: 88px;
  }
}

/* V6.1: in-app user guide + settings entry. */
.settings-link-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.settings-link-row .name,
.settings-link-row .muted {
  display: block;
}

.settings-link-row .row-arrow {
  margin-left: auto;
  color: var(--muted);
}

.help-entry-icon,
.help-intro-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.help-page {
  display: grid;
  gap: 14px;
  padding-bottom: 18px;
}

.help-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.help-head h2,
.help-section h3 {
  margin: 0;
}

.help-back {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.help-intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
}

.help-intro p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.help-jump {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 1px 1px 5px;
  scrollbar-width: none;
}

.help-jump::-webkit-scrollbar {
  display: none;
}

.help-jump button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.help-jump button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.help-section {
  padding: 18px;
  scroll-margin-top: 92px;
}

.help-section-title {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 14px;
}

.help-section-title > span {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 7px 16px color-mix(in srgb, var(--accent) 22%, transparent);
}

.help-section-title h3 {
  font-size: 17px;
}

.help-section-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.help-section-title em {
  display: inline-block;
  margin-left: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-style: normal;
  font-size: 10px;
  vertical-align: 2px;
}

.help-steps {
  margin: 14px 0 0;
  padding-left: 24px;
  display: grid;
  gap: 9px;
}

.help-steps li {
  padding-left: 3px;
  line-height: 1.55;
  color: var(--text);
  font-size: 13px;
}

.help-steps li::marker {
  color: var(--accent);
  font-weight: 800;
}

.help-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 13px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.help-note .fas {
  color: var(--accent);
  margin-top: 2px;
}

.guide-image-wrap {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg);
}

.guide-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 13px;
}

.guide-visual {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 82%, var(--card));
  padding: 14px;
  overflow: hidden;
}

.guide-alert {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 10px 11px;
  border-radius: 12px;
  background: var(--accent-soft);
}

.guide-alert .fas {
  color: var(--accent);
}

.guide-alert span,
.guide-alert b {
  font-size: 11px;
}

.guide-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 9px 0;
}

.guide-stats > div {
  min-width: 0;
  padding: 11px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
}

.guide-stats small,
.guide-row small,
.reminder-visual small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
}

.guide-stats strong {
  display: block;
  margin-top: 5px;
  font-size: 13px;
}

.guide-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
}

.guide-row > div {
  min-width: 0;
  flex: 1;
}

.guide-row > strong {
  font-size: 12px;
  white-space: nowrap;
}

.guide-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  font-weight: 800;
}

.add-visual {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.add-visual > .fas {
  color: var(--muted);
}

.guide-plus {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 21px;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 24%, transparent);
}

.guide-form {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 10px;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--line);
}

.guide-tabs {
  display: flex;
  gap: 6px;
  font-size: 10px;
}

.guide-tabs b,
.guide-tabs span {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  text-align: center;
}

.guide-tabs b {
  background: var(--accent-soft);
  color: var(--accent);
}

.guide-tabs span {
  background: var(--bg);
  color: var(--muted);
}

.guide-input,
.guide-search {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--muted);
  padding: 8px 9px;
  font-size: 10px;
}

.people-visual {
  display: grid;
  gap: 7px;
}

.guide-search {
  display: flex;
  align-items: center;
  gap: 7px;
}

.people-visual .guide-row > .fas {
  color: var(--muted);
  font-size: 10px;
}

.reminder-visual {
  display: grid;
  gap: 1px;
  padding: 0;
  background: var(--card);
}

.reminder-visual > div {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
}

.reminder-visual > div:last-child {
  border-bottom: 0;
}

.reminder-visual > div > .fas {
  color: var(--accent);
}

.guide-check {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.guide-chip {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 10px;
}

.backup-visual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.backup-visual button {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  padding: 11px;
  font: inherit;
  font-size: 11px;
}

.backup-visual .fas {
  color: var(--accent);
  margin-right: 5px;
}

.admin-visual {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.admin-visual > div {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 13px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 10px;
  text-align: center;
}

.admin-visual .fas {
  color: var(--accent);
  font-size: 17px;
}

.money-preset-max, button.money-preset-max {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

@media(max-width: 767px) {
  .help-section {
    scroll-margin-top: 78px;
  }

  .help-section,
  .help-intro {
    padding: 14px;
  }
}

@media(max-width: 430px) {
  .help-page {
    gap: 12px;
  }

  .help-head {
    align-items: flex-start;
  }

  .help-head h2 {
    font-size: 18px;
  }

  .help-section-title h3 {
    font-size: 16px;
  }

  .help-section-title p,
  .help-steps li {
    font-size: 12px;
  }

  .guide-stats {
    grid-template-columns: 1fr;
  }

  .guide-row > strong {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .add-visual {
    grid-template-columns: auto auto 1fr;
    gap: 8px;
    padding: 10px;
  }

  .guide-plus {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .guide-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .backup-visual,
  .admin-visual {
    grid-template-columns: 1fr;
  }
}

/* V7.1: guide payment/share visual refinements. */
.payment-visual {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
}

.guide-payment-card,
.guide-share-modal {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.guide-payment-head,
.guide-share-title {
  display: flex;
  align-items: center;
  gap: 9px;
}

.guide-payment-head > span {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.guide-payment-head > div,
.guide-share-title > div {
  min-width: 0;
  flex: 1;
}

.guide-payment-head b,
.guide-share-title b {
  display: block;
  font-size: 12px;
}

.guide-payment-head small,
.guide-share-title small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.guide-payment-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 9px;
  padding: 8px;
  border-radius: 10px;
  background: var(--accent-soft);
}

.guide-payment-summary span {
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
}

.guide-payment-summary b {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 10px;
  white-space: nowrap;
}

.guide-money-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 9px;
}

.guide-money-field b {
  color: var(--text);
  white-space: nowrap;
}

.guide-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.guide-preset-row span,
.guide-preset-row strong {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 8px;
  font-weight: 600;
}

.guide-preset-row strong {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent);
}

.guide-payment-action {
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
}

.guide-history-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
}

.guide-history-line .fas {
  color: var(--accent);
}

.guide-payment-or {
  display: grid;
  place-items: center;
}

.guide-payment-or span {
  padding: 5px 7px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.share-guide-visual {
  display: grid;
  gap: 8px;
}

.guide-share-source .guide-row {
  position: relative;
  padding-right: 40px;
}

.guide-share-icon {
  position: absolute;
  right: 9px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--accent);
  background: var(--card);
}

.guide-share-arrow {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 11px;
}

.guide-share-title {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.guide-share-title > .fas {
  color: var(--muted);
  font-size: 11px;
}

.guide-share-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.guide-share-options > div {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.guide-share-options > div.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 8%, transparent);
}

.guide-share-options > div > .fas {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
}

.guide-share-options span,
.guide-share-options b,
.guide-share-options small {
  min-width: 0;
}

.guide-share-options b {
  display: block;
  font-size: 9px;
}

.guide-share-options small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.guide-receipt {
  margin-top: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(145deg, #fff, #fff6fb);
  box-shadow: 0 5px 16px #00000008;
}

[data-theme="dark"] .guide-receipt {
  background: color-mix(in srgb, var(--card) 88%, var(--accent-soft));
}

.guide-receipt > b {
  display: block;
  margin-top: 7px;
  font-size: 11px;
}

.guide-receipt > small,
.guide-receipt-brand small {
  color: var(--muted);
  font-size: 8px;
}

.guide-receipt-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.guide-receipt-brand span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
}

.guide-receipt-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 8px;
}

.guide-receipt-stats span {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted);
  font-size: 7px;
}

.guide-receipt-stats b {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 8px;
  white-space: nowrap;
}

.guide-receipt-history {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.guide-receipt-history > .fas {
  color: var(--accent);
  font-size: 7px;
}

.guide-receipt-history span {
  display: block;
}

.guide-receipt-history b,
.guide-receipt-history small {
  display: block;
  font-size: 8px;
}

.guide-receipt-history small {
  margin-top: 2px;
  color: var(--muted);
}

.guide-share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.guide-share-actions span,
.guide-share-actions strong {
  padding: 8px;
  border-radius: 9px;
  font-size: 9px;
  text-align: center;
}

.guide-share-actions span {
  border: 1px solid var(--line);
  background: var(--card);
}

.guide-share-actions strong {
  background: var(--accent);
  color: #fff;
}

.guide-share-actions .fas {
  margin-right: 4px;
}

@media(max-width: 700px) {
  .payment-visual {
    grid-template-columns: 1fr;
  }

  .guide-payment-or {
    min-height: 18px;
  }

  .guide-payment-or span {
    position: relative;
  }

  .guide-payment-card,
  .guide-share-modal {
    padding: 10px;
  }
}

@media(max-width: 430px) {
  .guide-payment-summary,
  .guide-share-options,
  .guide-share-actions {
    grid-template-columns: 1fr 1fr;
  }

  .guide-receipt-stats {
    grid-template-columns: 1fr;
  }

  .guide-share-source .guide-row > strong {
    max-width: 92px;
  }
}
