/* ==========================================================================
   Zambulin Village — "Хотхоны дэвтэр" загвар
   Хар хөх + алт (лого), дулаан цаасан дэвсгэр, serif толгой, нарийн зураас
   ========================================================================== */
:root {
  --ink: #131a2b;          /* хар хөх */
  --ink-2: #1e2740;
  --gold: #c9a96a;
  --gold-2: #a8874a;
  --gold-soft: #f1e6cf;
  --paper: #f6f2ea;        /* дэвсгэр */
  --paper-2: #efe9dd;
  --card: #fffdf9;
  --text: #1f2430;
  --muted: #6b6f7b;
  --line: #e4dccb;
  --line-2: #d3c8ae;
  --ok: #2f7a4a; --ok-soft: #e3efe3; --ok-line: #b9d6bd;
  --bad: #b3412f; --bad-soft: #f8e4df; --bad-line: #e8bcb3;
  --warn: #9a6b12; --warn-soft: #f8edd2;
  --future: #f3efe6; --na: #e9e3d6;
  --primary: var(--ink); --primary-dark: #0c1220; --primary-soft: #e9e4d6;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(19,26,43,.04), 0 10px 30px -18px rgba(19,26,43,.25);
  --font-display: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-body); color: var(--text); font-size: 15px; line-height: 1.55;
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 500px at 50% -200px, rgba(201,169,106,.16), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .05 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}
a { color: var(--ink); text-decoration-color: var(--gold); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; font-family: var(--font-display); font-weight: 700; font-stretch: 87.5%; letter-spacing: .01em; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
b { font-weight: 700; }

/* --- Толгой --- */
.topbar {
  background: var(--ink); color: #efe6d3; padding: .85rem 0; position: relative; overflow: hidden;
  border-bottom: 1px solid rgba(201,169,106,.55);
}
.topbar::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(600px 220px at 15% 50%, rgba(201,169,106,.22), transparent 70%), radial-gradient(500px 200px at 90% 0%, rgba(201,169,106,.12), transparent 70%);
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent); opacity: .9; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; position: relative; }
.topbar .brand { display: flex; align-items: center; gap: 1rem; }
.topbar .logo { height: 62px; width: 62px; object-fit: contain; border-radius: 12px; background: var(--ink); box-shadow: 0 0 0 1px rgba(201,169,106,.45), 0 8px 20px -10px rgba(0,0,0,.6); }
.topbar h1 { font-size: 1.5rem; margin: 0; color: var(--gold); font-weight: 700; font-stretch: 87.5%; letter-spacing: .02em; }
.topbar .sub { opacity: .75; font-size: .82rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 500; }
.topbar a { color: #efe6d3; text-decoration: none; }
.topbar .small > a { display: inline-block; padding: .4rem .9rem; border: 1px solid rgba(201,169,106,.55); border-radius: 999px; color: var(--gold); font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; transition: background .2s, color .2s; }
.topbar .small > a:hover { background: var(--gold); color: var(--ink); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 1.25rem; }

/* --- Дансны мэдээлэл --- */
.bankbar { background: var(--gold-soft); border-bottom: 1px solid #e2cf9f; color: var(--ink); font-size: .88rem; }
.bankbar .wrap { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding-top: .45rem; padding-bottom: .45rem; }
.bankbar .bank-label { font-weight: 700; color: var(--gold-2); text-transform: uppercase; letter-spacing: .06em; font-size: .74rem; }
.bankbar #bankInfo { font-weight: 600; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.bankbar .bank-copy { margin-left: auto; padding: .2rem .6rem; font-size: .76rem; min-height: 0; }
.footer-bank { font-weight: 600; color: var(--ink); margin-bottom: .35rem; letter-spacing: .02em; }

/* --- Цэс --- */
.tabs { background: rgba(255,253,249,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.tabs .wrap { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; }
.tabs .wrap::-webkit-scrollbar { display: none; }
.tabs button, .tabs a.tab-link {
  background: none; border: none; border-bottom: 2px solid transparent; padding: .9rem .95rem .8rem; font: inherit; font-size: .9rem;
  cursor: pointer; color: var(--muted); white-space: nowrap; font-weight: 600; letter-spacing: .02em; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem;
  transition: color .2s, border-color .2s;
}
.tabs button:hover, .tabs a.tab-link:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--gold); }
.tabs a.tab-link { color: var(--gold-2); }
.tabs .ti { display: none; }
.tabs .tl-short { display: none; }

main { padding: 1.5rem 0 3.5rem; }
section[hidden] { display: none; }

/* --- Карт --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin-bottom: 1.1rem; position: relative; }
.card h2 { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .9rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.card h2::before { content: ""; width: 10px; height: 10px; border: 1.5px solid var(--gold); transform: rotate(45deg); flex-shrink: 0; }
.card h2 .spacer { flex: 1; }
.card h2 .muted, .card h2 select { font-family: var(--font-body); font-weight: 500; }
main > section > .card, main > section > .stats { animation: rise .5s ease both; }
main > section > :nth-child(2) { animation-delay: .06s; } main > section > :nth-child(3) { animation-delay: .12s; } main > section > :nth-child(4) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --- Үзүүлэлт --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem .9rem; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; left: 1.15rem; right: 1.15rem; top: 0; height: 2px; background: var(--gold); opacity: .8; }
.stat .label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; font-weight: 700; }
.stat .value { font-family: var(--font-display); font-size: clamp(1.25rem, 1.5vw, 1.6rem); font-weight: 700; font-stretch: 87.5%; margin-top: .25rem; color: var(--ink); letter-spacing: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .hint { color: var(--muted); font-size: .83rem; margin-top: .1rem; }
.stat.ok .value { color: var(--ok); } .stat.bad .value { color: var(--bad); } .stat.primary .value { color: var(--ink); }
.stat.primary::after { background: var(--ink); }

.notice { background: var(--warn-soft); border: 1px solid #ead9a8; border-left: 4px solid var(--gold); padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; white-space: pre-wrap; }

/* --- Форм, товч --- */
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; min-width: 160px; }
input, select, textarea, button { font: inherit; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,169,106,.25); }
select { appearance: none; -webkit-appearance: none; padding-right: 2rem; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b6f7b' stroke-width='1.6'/></svg>"); background-repeat: no-repeat; background-position: right .7rem center; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .25rem; font-weight: 600; letter-spacing: .02em; }
.field { margin-bottom: .75rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem .9rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field { display: flex; flex-direction: column; justify-content: flex-end; margin-bottom: 0; }
.form-grid .field label { flex: 0 0 auto; }
.btn { font-family: var(--font-body); display: inline-flex; align-items: center; gap: .35rem; padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); cursor: pointer; font-weight: 600; white-space: nowrap; font-size: .9rem; transition: background .18s, color .18s, border-color .18s, transform .1s; }
.btn:hover { background: var(--paper-2); border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--gold); }
.btn.primary:hover { background: var(--primary-dark); color: #f3e9d2; }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.sm { padding: .32rem .7rem; font-size: .82rem; min-height: 30px; }
.btn:disabled { opacity: .6; cursor: default; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* --- Хүснэгт --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: .6rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: transparent; font-weight: 700; color: var(--muted); white-space: nowrap; font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; border-bottom: 1px solid var(--line-2); }
tbody tr:hover td { background: rgba(201,169,106,.06); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: var(--paper-2); border-top: 1px solid var(--line-2); }
tr.total td { font-weight: 700; }

/* --- Төлбөрийн хүснэгт --- */
.pay-grid { font-size: .86rem; }
.pay-grid th, .pay-grid td { padding: .38rem .5rem; }
.pay-grid th { font-size: .7rem; }
.pay-grid th.mcol, .pay-grid td.mcell { text-align: center; min-width: 40px; padding-left: .2rem; padding-right: .2rem; }
.pay-grid td.mcell { font-weight: 700; user-select: none; border-left: 1px solid rgba(255,255,255,.6); }
.pay-grid td.paid { background: var(--ok-soft); color: var(--ok); }
.pay-grid td.unpaid { background: var(--bad-soft); color: var(--bad); }
.pay-grid td.future { background: var(--future); color: #b4ad9c; }
.pay-grid td.na { background: var(--na); color: #a9a292; }
.pay-grid td.mcell.thismonth, .pay-grid th.mcol.thismonth { box-shadow: inset 0 0 0 2px var(--gold); }
.pay-grid th.mcol.thismonth { color: var(--ink); }
.pay-grid.editable td.mcell { cursor: pointer; transition: filter .1s; }
.pay-grid.editable td.mcell:hover { filter: brightness(.93); outline: 2px solid var(--ink); outline-offset: -2px; }
.pay-grid .sticky-col { position: sticky; left: 0; background: var(--card); z-index: 1; font-weight: 700; white-space: nowrap; font-family: var(--font-display); font-size: .9rem; }
.pay-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--card); }
.pay-grid thead th.sticky-col { z-index: 3; }
.pay-grid tr.mine td { background-color: var(--gold-soft); }
.pay-grid tr.mine td.paid { background: #cfe6d1; } .pay-grid tr.mine td.unpaid { background: #f1cdc6; }
.pay-grid tr.mine .sticky-col { background: var(--gold-soft); }
.pay-grid tfoot td { text-align: center; font-size: .75rem; }
.grid-scroll { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin: .4rem 0 .7rem; }
.legend span::before { content: ""; display: inline-block; width: 13px; height: 13px; border-radius: 3px; margin-right: .4rem; vertical-align: -2px; }
.legend .l-paid::before { background: var(--ok-soft); border: 1px solid var(--ok-line); }
.legend .l-unpaid::before { background: var(--bad-soft); border: 1px solid var(--bad-line); }
.legend .l-future::before { background: var(--future); border: 1px solid var(--line-2); }
.legend .l-na::before { background: var(--na); border: 1px solid var(--line-2); }
.legend .l-mine::before { background: var(--gold-soft); border: 1px solid var(--gold); }

/* --- Тэмдэг --- */
.badge { font-family: var(--font-body); display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; letter-spacing: .03em; }
.badge.planned { background: var(--paper-2); color: #5d6170; border: 1px solid var(--line-2); }
.badge.in_progress { background: var(--warn-soft); color: var(--warn); border: 1px solid #ead9a8; }
.badge.done { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line); }
.badge.cancelled { background: var(--paper-2); color: #a9a292; text-decoration: line-through; }
.badge.type { background: transparent; color: var(--ink); border: 1px solid var(--line-2); font-weight: 600; }

/* --- Төлөвлөгөө --- */
.plan { display: grid; grid-template-columns: 52px 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.plan:last-child { border-bottom: none; }
.plan .no { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--gold); color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; background: var(--card); }
.plan .title { font-family: var(--font-display); font-weight: 700; font-stretch: 87.5%; font-size: 1.12rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.plan .desc { color: #4b505c; margin: .25rem 0 .5rem; white-space: pre-wrap; }
.plan .meta { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.plan .meta b { color: var(--text); }
.progress { height: 6px; background: var(--paper-2); border-radius: 999px; overflow: hidden; margin-top: .55rem; max-width: 460px; border: 1px solid var(--line); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.progress > div.over { background: var(--bad); }

/* --- Зөвлөлийн гишүүд --- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; }
.member { border: 1px solid var(--line); border-radius: 12px; padding: .85rem 1rem; display: flex; gap: .85rem; align-items: flex-start; background: #fff; transition: border-color .2s, transform .2s; }
.member:hover { border-color: var(--gold); transform: translateY(-2px); }
.member .avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: var(--gold); font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.member .name { font-weight: 700; font-size: 1rem; }
.member .pos { color: var(--gold-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.member .contact { font-size: .9rem; margin-top: .35rem; color: #4b505c; }
.member .contact a { text-decoration: none; font-weight: 600; }

/* --- Санал хүсэлт --- */
.fb { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.fb:last-child { border-bottom: none; }
.fb .who { font-weight: 700; } .fb .when { color: var(--muted); font-size: .8rem; margin-left: .5rem; }
.fb .msg { margin: .35rem 0; white-space: pre-wrap; padding-left: .9rem; border-left: 2px solid var(--gold); font-size: 1rem; }
.fb .reply { background: var(--paper-2); border: 1px solid var(--line); padding: .6rem .85rem; border-radius: 10px; margin-top: .5rem; white-space: pre-wrap; margin-left: .9rem; }
.fb .reply .rlabel { font-size: .72rem; color: var(--gold-2); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; margin-bottom: .15rem; }
.fb.hidden-fb { opacity: .55; }

.mine-box { background: linear-gradient(135deg, #fbf4e3, #f3e7cb); border-color: #e2cf9f; }
.mine-box h2::before { border-color: var(--gold-2); }
.empty { color: var(--muted); text-align: center; padding: 1.75rem 1rem; font-style: italic; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.error { color: var(--bad); font-size: .9rem; margin-top: .4rem; }
.right { text-align: right; }
.logo-preview { height: 120px; width: 120px; object-fit: contain; background: var(--ink); border-radius: 14px; border: 1px solid var(--gold); }

#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(6px); background: var(--ink); color: #f3e9d2; padding: .65rem 1.1rem; border-radius: 999px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); z-index: 100; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: 90vw; border: 1px solid rgba(201,169,106,.5); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); } #toast.err { background: var(--bad); border-color: transparent; } #toast.ok { background: var(--ok); border-color: transparent; }

dialog { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 0; max-width: 640px; width: calc(100% - 2rem); box-shadow: 0 30px 80px -20px rgba(19,26,43,.5); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(19,26,43,.55); backdrop-filter: blur(2px); }
dialog .dlg { padding: 1.4rem; }
dialog .dlg h3 { margin-bottom: 1rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); font-size: 1.25rem; }
dialog .dlg .actions { justify-content: flex-end; margin-top: 1.1rem; }

.login { max-width: 400px; margin: 3.5rem auto; }
.login h2 { justify-content: center; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem 2rem; letter-spacing: .04em; }
footer::before { content: "✦"; display: block; color: var(--gold); margin-bottom: .5rem; }

/* --- Splash --- */
body.landing-body { overflow: hidden; background: var(--ink); }
.splash { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: flex-start; color: #f3e9d2; }
.landing-admin { position: absolute; top: 1rem; right: 1.1rem; z-index: 2; color: rgba(243,233,210,.8); text-decoration: none; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; border: 1px solid rgba(201,169,106,.45); border-radius: 999px; padding: .35rem .8rem; }
.landing-admin:hover { background: var(--gold); color: var(--ink); }
.landing-actions { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.landing-fb { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.35); color: #fff; text-decoration: none; }
.landing-fb:hover { background: rgba(255,255,255,.18); border-color: #fff; }
.splash-bg { position: absolute; inset: 0; background-size: cover; background-position: center 35%; animation: kenburns 9s ease-out both; }
@keyframes kenburns { from { transform: scale(1.06); } to { transform: scale(1); } }
.splash-veil { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(19,26,43,.15) 0%, rgba(19,26,43,.05) 40%, rgba(19,26,43,.78) 78%, rgba(19,26,43,.95) 100%); }
.splash-content { position: relative; padding: 0 clamp(1.25rem, 6vw, 5rem) clamp(2rem, 6vh, 4rem); max-width: 760px; animation: rise .8s .25s ease both; }
.splash-logo { height: 64px; width: 64px; object-fit: contain; border-radius: 12px; box-shadow: 0 0 0 1px rgba(201,169,106,.5); margin-bottom: 1rem; }
.splash-kicker { color: var(--gold); text-transform: uppercase; letter-spacing: .28em; font-size: .75rem; font-weight: 700; margin-bottom: .4rem; }
.splash-title { font-family: var(--font-display); font-weight: 800; font-stretch: 80%; font-size: clamp(2.2rem, 6vw, 4rem); color: #fff; margin: 0 0 .5rem; line-height: 1.05; text-shadow: 0 6px 30px rgba(0,0,0,.4); }
.splash-sub { color: rgba(243,233,210,.85); font-size: .95rem; letter-spacing: .04em; margin-bottom: 1.4rem; }
.splash-btn { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 700; padding: .7rem 1.4rem; font-size: 1rem; }
.splash-btn:hover { background: #dcbf85; border-color: #dcbf85; }
a.splash-btn { text-decoration: none; }

/* --- Дүрэм журам --- */
.doc-list { display: grid; gap: .6rem; }
.doc { display: flex; align-items: center; gap: .9rem; padding: .7rem .9rem .7rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; transition: border-color .2s, transform .2s; }
.doc:hover { border-color: var(--gold); transform: translateX(3px); }
.doc-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: .9rem; text-decoration: none; color: var(--text); }
.doc-icon { font-size: 1.5rem; width: 40px; text-align: center; flex-shrink: 0; }
.doc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-title { font-family: var(--font-display); font-weight: 700; font-stretch: 87.5%; font-size: 1.02rem; }
.doc-meta { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-dl { flex-shrink: 0; text-decoration: none; }

/* ==================== Мобайл ==================== */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .wrap { padding: 0 .7rem; }
  .topbar { padding: .5rem 0; }
  .topbar .wrap { flex-wrap: nowrap; gap: .5rem; }
  .topbar .brand { gap: .6rem; min-width: 0; flex: 1 1 auto; }
  .topbar .brand > div { min-width: 0; }
  .topbar .logo { height: 42px; width: 42px; border-radius: 9px; }
  .topbar h1 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .sub { display: none; }
  .topbar .wrap > .small { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
  .topbar .small > a { padding: .3rem .7rem; font-size: .72rem; }
  .topbar .wrap > .small .btn { padding: .25rem .65rem; border-radius: 999px; background: transparent !important; border-color: rgba(201,169,106,.6) !important; color: var(--gold) !important; min-height: 0; font-size: .74rem; }
  main { padding: .8rem 0 2rem; }
  .bankbar { font-size: .82rem; }
  .bankbar .wrap { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .1rem .5rem; padding-top: .4rem; padding-bottom: .45rem; }
  .bankbar .bank-label { font-size: .68rem; }
  .bankbar #bankInfo { grid-column: 1 / -1; line-height: 1.35; }
  .bankbar .bank-copy { grid-row: 1; grid-column: 2; margin: 0; }
  /* Цэс: хажуу тийш гүйлгэдэг chip-үүд */
  .tabs { position: sticky; top: 0; }
  .tabs::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 28px; background: linear-gradient(90deg, rgba(255,253,249,0), rgba(255,253,249,.95)); pointer-events: none; }
  .tabs .wrap { display: flex; flex-wrap: nowrap; gap: .4rem; padding: .5rem .7rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
  .tabs button, .tabs a.tab-link { flex: 0 0 auto; padding: .45rem .85rem; border: 1px solid var(--line-2); border-radius: 999px; background: #fff; color: var(--ink); font-size: .84rem; font-weight: 600; scroll-snap-align: start; }
  .tabs button.active { background: var(--ink); color: var(--gold); border-color: var(--ink); }
  .tabs .ti { display: inline; font-size: .95rem; line-height: 1; }
  .tabs a.tab-link { background: var(--gold-soft); border-color: #e2cf9f; color: var(--gold-2); }
  .tabs .tl-full { display: none; } .tabs .tl-short { display: inline; }
  .card { padding: .95rem .85rem; margin-bottom: .75rem; }
  .card h2 { font-size: 1.12rem; }
  .card h2 .btn { flex: 1 1 auto; justify-content: center; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: .55rem; margin-bottom: .75rem; }
  .stat { padding: .7rem .8rem .65rem; }
  .stat .label { font-size: .64rem; letter-spacing: .1em; } .stat .value { font-size: 1.3rem; } .stat .hint { font-size: .74rem; }
  .toolbar { gap: .45rem; }
  .toolbar > * { flex: 1 1 100%; max-width: none !important; }
  .toolbar .btn { justify-content: center; }
  .toolbar select { width: 100%; }
  th, td { padding: .45rem .5rem; }
  table { font-size: .85rem; }
  .pay-grid { font-size: .78rem; }
  .pay-grid th, .pay-grid td { padding: .3rem .3rem; }
  .pay-grid th.mcol, .pay-grid td.mcell { min-width: 31px; padding-left: .1rem; padding-right: .1rem; }
  .pay-grid td.mcell { height: 36px; }
  .pay-grid .sticky-col { font-size: .88rem; }
  .pay-grid .col-type { display: none; }
  .pay-grid td.col-owner { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grid-scroll { max-height: 72vh; }
  .legend { gap: .6rem; font-size: .76rem; }
  .plan { grid-template-columns: 34px 1fr; gap: .6rem; padding: .75rem 0; }
  .plan .no { width: 32px; height: 32px; font-size: .95rem; }
  .plan .title { font-size: 1rem; }
  .plan .meta { gap: .3rem .8rem; font-size: .8rem; }
  .member-grid { grid-template-columns: 1fr; gap: .5rem; }
  .form-grid { grid-template-columns: 1fr; }
  dialog { width: calc(100% - .8rem); max-height: 94vh; overflow: auto; margin: auto; }
  dialog .dlg { padding: 1rem; }
  dialog .dlg .actions .btn { flex: 1; justify-content: center; }
  .fb .actions .btn { flex: 1; justify-content: center; }
  .login { margin: 1.5rem auto; }
  footer { font-size: .76rem; }
  #toast { bottom: .75rem; width: calc(100% - 1.5rem); text-align: center; }
  .splash-bg { background-position: 22% 30%; }
  .splash-logo { height: 52px; width: 52px; }
  .landing-actions .btn { flex: 1 1 100%; justify-content: center; }
  .doc { padding: .7rem .75rem; gap: .6rem; }
  .doc-dl { display: none; }
}
@media (max-width: 400px) { .stats { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
