/* Font hệ thống ổn định cho đầy đủ dấu tiếng Việt trên Windows, Android và iOS. */
:root,
body,
button,
input,
select,
textarea {
  font-family: "Segoe UI", Arial, "Helvetica Neue", sans-serif !important;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
.brand,
.brand-mark,
.login-card h1,
.lede,
.topbar h2,
.stat strong,
.panel-head h3,
.empty b,
.rank-num,
.section-title h3,
.bill-card h3,
.modal-head h3 {
  font-family: "Segoe UI", Arial, "Helvetica Neue", sans-serif !important;
}

.topbar h2,
.section-title h3,
.panel-head h3,
.bill-card h3,
.modal-head h3 {
  font-weight: 800;
  letter-spacing: -.02em;
}

.help-link {
  display: inline-flex;
  align-items: center;
  color: var(--green);
  text-decoration: none;
  font-weight: 800;
  padding: 10px 6px;
  white-space: nowrap;
}

.guide-intro {
  max-width: 720px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 22px;
}

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

.guide-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
}

.guide-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-weight: 900;
  margin-bottom: 14px;
}

.guide-card h3 {
  margin: 0 0 9px;
  font-size: 1.05rem;
}

.guide-card p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  font-size: .9rem;
}

.guide-note {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 12px;
  background: #e2efe8;
  color: #204d3d;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .top-actions .help-link {
    padding: 9px 2px;
    font-size: .76rem;
  }

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

body {
  background-color: #f7f1e2;
  background-image: radial-gradient(#e8ddc3 1px, transparent 1px);
  background-size: 18px 18px;
  overflow-x: hidden;
}

/* Lấp đầy vùng làm việc trên màn hình desktop lớn. */
.content {
  width: calc(100vw - 240px);
  max-width: 100%;
}

.page {
  width: 100%;
  max-width: none;
}

.chibi-hero {
  min-height: 230px;
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(420px, .85fr);
  align-items: center;
  gap: 18px;
  padding: 26px 30px;
  border-radius: 22px;
  overflow: hidden;
  color: white;
  background: linear-gradient(130deg, #163d31, #276b55 64%, #e9b948);
  box-shadow: 0 16px 34px rgba(24, 63, 50, .2);
  position: relative;
}

.chibi-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 15% 15%, rgba(255,255,255,.17), transparent 28%);
  pointer-events: none;
}

.chibi-copy { position: relative; z-index: 1; }
.chibi-copy h3 { font-size: clamp(1.65rem, 4vw, 2.6rem); margin: 4px 0 10px; }
.chibi-copy p { max-width: 560px; color: #e6f3ed; line-height: 1.55; margin: 0; }
.chibi-hero img { width: 100%; max-height: 260px; object-fit: cover; object-position: center; border-radius: 18px; position: relative; z-index: 1; box-shadow: 0 10px 26px rgba(0,0,0,.22); }

.hall-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 22px; }
.hall-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px; overflow: hidden; }
.hall-card.debtors { background: linear-gradient(180deg, #fff8e2, #fffdf6); }
.hall-card.benefactors { background: linear-gradient(180deg, #e9f7ef, #fffdf6); }
.hall-title { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 12px; }
.hall-title h3 { margin: 0; font-size: 1.25rem; }
.hall-title p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 8px; min-height: 250px; }
.podium-person { text-align: center; min-width: 0; }
.podium-person.first { order: 2; }
.podium-person.second { order: 1; }
.podium-person.third { order: 3; }
.medal-avatar { width: 68px; height: 68px; margin: 0 auto 8px; border-radius: 50%; padding: 4px; position: relative; background: #c78d38; box-shadow: 0 5px 14px rgba(0,0,0,.13); }
.first .medal-avatar { width: 82px; height: 82px; background: linear-gradient(135deg,#ffe28a,#d79a0b); }
.second .medal-avatar { background: linear-gradient(135deg,#f4f6f7,#9da7ad); }
.third .medal-avatar { background: linear-gradient(135deg,#e8ad72,#a95e27); }
.medal-avatar img,.medal-avatar span { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; object-fit: cover; background: #f2ead7; color: var(--ink); font-size: 1.5rem; font-weight: 900; }
.medal-avatar::after { content: attr(data-medal); position: absolute; right: -7px; bottom: -3px; font-size: 1.45rem; }
.medal-avatar { outline: 2px dashed rgba(255,255,255,.95); box-shadow: 0 0 0 4px #b8222e, 0 0 0 7px #1d7b49, 0 7px 18px rgba(0,0,0,.18); }
.medal-avatar::before { content: "🎄"; position: absolute; left: -11px; top: -15px; font-size: 1.25rem; transform: rotate(-12deg); filter: drop-shadow(0 2px 2px rgba(0,0,0,.18)); z-index: 2; }
.podium-person:nth-child(2) .medal-avatar::before { content: "❄️"; }
.podium-person:nth-child(3) .medal-avatar::before { content: "🎁"; }
.podium-person strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-bio { height: 2.7em; margin: 4px 2px 2px; color: var(--muted); font-size: .68rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.podium-person .money { display: block; color: var(--red); font-size: .82rem; margin: 4px 0 8px; }
.benefactors .podium-person .money { color: var(--green); }
.podium-step { border-radius: 9px 9px 4px 4px; display: grid; place-items: center; color: white; font-weight: 900; background: #c7a059; height: 54px; }
.first .podium-step { height: 78px; background: #e0aa21; }
.second .podium-step { height: 61px; background: #aeb8bd; }
.third .podium-step { height: 48px; background: #b77743; }

.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.split-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.split-mode > label { display: flex; flex-direction: row; align-items: flex-start; gap: 9px; background: #eee8dc; border: 2px solid transparent; border-radius: 11px; padding: 12px; cursor: pointer; }
.split-mode input { width: auto; margin-top: 3px; }
.split-mode small { display: block; color: var(--muted); font-weight: 500; margin-top: 3px; line-height: 1.35; }
.split-mode label:has(input:checked) { border-color: var(--green); background: #e5f2eb; }

.profile-grid { display: grid; grid-template-columns: minmax(250px,.7fr) minmax(300px,1.3fr); gap: 20px; }
.profile-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.profile-avatar { width: 130px; height: 130px; margin: 0 auto 18px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: #e8dfca; border: 6px solid #f1bf48; font-size: 2.6rem; font-weight: 900; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-preview-wrap { position: relative; width: fit-content; margin: 0 auto; }
.avatar-preview-wrap .profile-avatar { margin-bottom: 18px; }
.avatar-preview-badge { position: absolute; right: -14px; bottom: 10px; padding: 5px 9px; border-radius: 999px; background: var(--green); color: white; border: 3px solid var(--card); font-size: .7rem; font-weight: 900; box-shadow: 0 4px 12px rgba(0,0,0,.14); }
.avatar-preview-status { margin: 10px 0 0; color: var(--green); font-size: .78rem; font-weight: 750; line-height: 1.4; overflow-wrap: anywhere; }
.bio-field { margin-top: 18px; text-align: left; }
.bio-field textarea { width: 100%; resize: vertical; min-height: 105px; border: 1px solid var(--line); border-radius: 10px; background: white; padding: 12px 13px; font: inherit; line-height: 1.5; outline: none; }
.bio-field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(35,89,71,.12); }
.bio-field small { color: var(--muted); font-size: .72rem; line-height: 1.4; }
.profile-card h3 { text-align: center; margin: 5px 0; }
.profile-card > p { text-align: center; color: var(--muted); margin-top: 0; }
.upload-box { border: 2px dashed var(--line); border-radius: 14px; padding: 16px; margin-top: 15px; }
.upload-box h4 { margin: 0 0 8px; }
.qr-preview { width: min(280px,100%); aspect-ratio: 1; object-fit: contain; display: block; margin: 10px auto; background: white; border-radius: 12px; border: 1px solid var(--line); }
.payment-qr { text-align: center; margin-bottom: 16px; }
.payment-qr img { width: min(290px,100%); aspect-ratio: 1; object-fit: contain; border: 1px solid var(--line); border-radius: 14px; background: white; }
.payment-qr .no-qr { padding: 28px 16px; border-radius: 13px; background: #fff1cf; color: #765515; }
.proof-link { color: var(--green); font-weight: 800; font-size: .75rem; }
.debt-profile-button {
  border: 0;
  background: transparent;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: 9px;
  text-align: left;
  display: grid;
  gap: 3px;
  min-width: 0;
  cursor: pointer;
}
.debt-profile-button:hover,.debt-profile-button:focus-visible { background: #eef4ed; outline: none; }
.view-qr-hint { color: var(--green); font-size: .72rem; font-weight: 800; }
.debt-avatar-trigger { cursor: pointer; }
.creditor-profile-card .profile-avatar { width: 96px; height: 96px; margin-bottom: 10px; }
.member-profile-bio { margin: 12px auto 18px; padding: 12px 14px; max-width: 460px; border-radius: 12px; background: #eef4ed; color: var(--ink); text-align: center; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
#creditorPayBtn { justify-content: center; }
.members-intro { margin: 7px 0 0; color: var(--muted); line-height: 1.5; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(250px,1fr)); gap: 14px; }
.member-card { position: relative; display: grid; grid-template-columns: 66px minmax(0,1fr); gap: 14px; width: 100%; min-height: 145px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); text-align: left; box-shadow: 0 8px 24px rgba(29,45,37,.06); transition: transform .15s, border-color .15s, box-shadow .15s; }
.member-card:hover,.member-card:focus-visible { transform: translateY(-2px); border-color: var(--green); box-shadow: 0 12px 28px rgba(29,45,37,.12); outline: none; }
.member-card-avatar { width: 66px; height: 66px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: #e8dfca; border: 4px solid #f1bf48; font-size: 1.5rem; font-weight: 900; }
.member-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-card-copy h3 { margin: 2px 0 2px; font: 800 1.1rem "Segoe UI",Arial,sans-serif; }
.member-card-copy span { color: var(--muted); font-size: .74rem; }
.member-card-copy p { margin: 9px 0 24px; color: #4f5b55; font-size: .8rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.member-qr-state { position: absolute; left: 98px; bottom: 15px; color: var(--muted); font-size: .7rem; font-weight: 850; }
.member-qr-state.ready { color: var(--green); }
.person-search { margin: 0 0 8px; padding: 9px 11px; background: #fffdf8; }
.transfer-inbox { margin-bottom: 16px; padding: 18px; border: 1px solid #e8c973; border-radius: 15px; background: #fff8df; }
.transfer-inbox h3 { margin: 0 0 12px; }
.transfer-request { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px; border-radius: 12px; background: white; }
.transfer-request p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.transfer-actions { display: flex; gap: 8px; flex-shrink: 0; }
.transfer-pending { color: #9a6b00; font-size: .72rem; font-weight: 800; }
.password-card { display: grid; grid-template-columns: minmax(220px,1.2fr) repeat(3,minmax(170px,1fr)) auto; align-items: end; gap: 14px; margin-top: 20px; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.password-card h3 { margin: 0 0 5px; }
.password-card p { margin: 0; }
.profile-logout { display: flex; justify-content: flex-end; margin-top: 12px; }
.feed-layout { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(300px,.75fr); align-items: start; gap: 20px; }
.feed-column { display: grid; gap: 16px; min-width: 0; }
.feed-composer,.feed-post,.feed-directory { border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 10px 28px rgba(29,45,37,.07); }
.feed-composer { padding: 18px; }
.feed-author { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.feed-composer textarea { width: 100%; resize: vertical; min-height: 90px; border: 1px solid var(--line); border-radius: 13px; padding: 13px; font: inherit; line-height: 1.5; outline: none; }
.feed-composer textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(35,89,71,.12); }
.feed-composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.feed-upload { display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; border-radius: 10px; background: #eef4ed; color: var(--green); cursor: pointer; }
.feed-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.feed-image-preview { width: 100%; max-height: 360px; object-fit: contain; margin-top: 12px; border-radius: 14px; background: #eee8dc; }
.feed-list { display: grid; gap: 16px; }
.feed-post { overflow: hidden; }
.feed-post > header { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.feed-post > header strong,.feed-post > header span { display: block; }
.feed-post > header span { margin-top: 2px; color: var(--muted); font-size: .7rem; }
.post-delete { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f2ece1; color: var(--muted); font-size: 1.2rem; }
.post-text { margin: 3px 18px 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-image { display: block; width: 100%; max-height: 620px; object-fit: contain; background: #17251f; }
.reaction-bar { display: grid; grid-template-columns: repeat(5,1fr); gap: 6px; padding: 12px 16px; }
.reaction-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 40px; border: 1px solid var(--line); border-radius: 999px; background: white; }
.reaction-btn span { font-size: 1.08rem; }
.reaction-btn.active { border-color: var(--green); background: #e5f2eb; box-shadow: 0 0 0 2px rgba(35,89,71,.1); }
.reaction-summary { display: flex; flex-wrap: wrap; gap: 5px 12px; padding: 0 18px 12px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.comment-list { border-top: 1px solid #eee7d9; }
.comment-item { display: grid; grid-template-columns: 32px 1fr; gap: 9px; padding: 10px 18px; }
.comment-item .avatar { width: 32px; height: 32px; }
.comment-item strong { font-size: .78rem; }
.comment-item p { display: inline-block; margin: 3px 0 2px; padding: 8px 10px; border-radius: 10px; background: #f1ede4; font-size: .82rem; line-height: 1.4; }
.comment-item span { display: block; color: var(--muted); font-size: .64rem; }
.comment-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 18px 16px; }
.comment-form input { padding: 10px 12px; }
.comment-form button { border: 0; border-radius: 9px; padding: 0 14px; background: var(--ink); color: white; font-weight: 800; }
.feed-directory { position: sticky; top: 125px; overflow: hidden; }
.feed-directory > .person-search { width: calc(100% - 32px); margin: 14px 16px 5px; }
.member-grid.compact { grid-template-columns: 1fr; gap: 0; max-height: calc(100vh - 260px); overflow: auto; }
.member-grid.compact .member-card { min-height: 112px; border: 0; border-top: 1px solid #eee7d9; border-radius: 0; box-shadow: none; }
.bill-actions { flex-wrap: wrap; }
.bill-actions .btn { min-width: 105px; }

@media (max-width: 900px) {
  .content { width: 100%; }
  .mobile-nav { grid-template-columns: repeat(5,1fr); }
  .chibi-hero { grid-template-columns: 1fr; padding: 22px; }
  .chibi-hero img { max-height: 220px; }
  .hall-grid,.profile-grid { grid-template-columns: 1fr; }
  .feed-layout { grid-template-columns: 1fr; }
  .feed-directory { position: static; }
  .member-grid.compact { max-height: none; }
  .password-card { grid-template-columns: 1fr 1fr; }
  .password-card > div { grid-column: 1 / -1; }
  .page { padding-bottom: 140px; }
  .debt-row .row-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    width: 100%;
    gap: 8px;
    padding-top: 4px;
  }
  .debt-row .row-actions button {
    min-height: 46px;
    padding: 10px 12px;
    font-size: .86rem;
    touch-action: manipulation;
  }
  .person-pair { min-width: 0; }
  .mobile-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .mobile-confirm-actions .btn { min-height: 48px; }
  .transfer-request { align-items: stretch; flex-direction: column; }
  .transfer-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .chibi-hero { min-height: 0; padding: 18px; border-radius: 16px; }
  .chibi-hero img { max-height: 160px; }
  .hall-card { padding: 14px 10px; }
  .podium { min-height: 225px; }
  .medal-avatar { width: 56px; height: 56px; }
  .first .medal-avatar { width: 68px; height: 68px; }
  .podium-person strong { font-size: .76rem; }
  .podium-bio { font-size: .62rem; margin-inline: 0; }
  .podium-person .money { font-size: .7rem; }
  .split-mode { grid-template-columns: 1fr; }
  .top-actions .help-link { font-size: 0; padding: 8px; }
  .top-actions .members-link::before { content: "📰"; font-size: 1rem; }
  .top-actions .profile-link::before { content: "👤"; font-size: 1rem; }
  .top-actions .guide-link { display: none; }
  .member-grid { grid-template-columns: 1fr; }
  .password-card { grid-template-columns: 1fr; padding: 18px; }
  .password-card > div { grid-column: auto; }
  .feed-composer-actions { align-items: stretch; flex-direction: column; }
  .feed-composer-actions > * { width: 100%; justify-content: center; }
  .reaction-bar { gap: 4px; padding-inline: 10px; }
  .reaction-btn { min-width: 0; }
  .reaction-btn span { font-size: 1rem; }
  .debt-row { grid-template-columns: 42px minmax(0,1fr) auto; }
  .modal-card { padding: 20px 17px; }
}
