/* دنگ: mobile-first, RTL, light */

@font-face { font-family: "Vazirmatn"; src: url("/fonts/Vazirmatn-FD-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("/fonts/Vazirmatn-FD-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f6f8fa;
  --surface: #fff;
  --text: #14202b;
  --muted: #5b6875;
  --border: #e1e6eb;
  --primary: #0f766e;
  --primary-hover: #0d645d;
  --primary-soft: #e6f4f2;
  --danger: #c2334d;
  --danger-soft: #fdecef;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 32, 43, .06), 0 8px 24px -12px rgba(20, 32, 43, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 "Vazirmatn", system-ui, sans-serif; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
p { margin: 0 0 .5rem; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 1.2rem; }
.me { color: var(--text); background: var(--primary-soft); padding: .2rem .8rem; border-radius: 999px; font-size: .9rem; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1rem; }
.center { text-align: center; margin-top: 1.5rem; }
.muted { color: var(--muted); font-size: .92rem; }

label { display: flex; flex-direction: column; gap: .35rem; font-weight: 700; }
label .muted { font-weight: 400; }
input { font: inherit; width: 100%; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--text); }
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
input[dir="ltr"] { text-align: left; }
input.otp { font-size: 1.8rem; letter-spacing: .6em; text-align: center; padding-inline-start: .6em; }

.btn { font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: .8rem 1rem; background: var(--primary); color: #fff; cursor: pointer; }
.btn:hover { background: var(--primary-hover); }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; }
.link.danger { color: var(--danger); }

.alert { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: .6rem .9rem; }
.notice { background: var(--primary-soft); color: var(--primary); border-radius: 12px; padding: .6rem .9rem; }

.login { margin-top: 8vh; }
.empty { text-align: center; padding: 2.5rem 1rem; }
.empty .big { font-size: 2.5rem; margin: 0; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.list a { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; color: var(--text); font-weight: 700; }

/* Groups (phase 03) */
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.back { display: inline-block; color: var(--muted); font-size: .92rem; margin-bottom: .5rem; padding: .4rem 0; min-height: 44px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.title-row h1 { margin: 0; }
.pill { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .5rem 1rem; font-size: .9rem; min-height: 44px; display: inline-flex; align-items: center; }
.section { margin-top: 1.5rem; }
.card + .card, .card + .section, .section + .card { margin-top: 1rem; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .35rem .9rem; }
.chip.pair { background: var(--primary-soft); border-color: transparent; }
.empty.small { padding: 1.25rem 1rem; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.btn.wide { display: block; width: 100%; text-align: center; min-height: 48px; }
.fab-like { margin-top: 1.25rem; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
.btn.ghost:hover { background: #d5ece8; }
.btn.ghost.danger { background: var(--danger-soft); color: var(--danger); }
.btn.small { padding: .45rem .9rem; font-size: .9rem; min-height: 44px; }
.btn, .link { min-height: 44px; }
.muted-on { opacity: .8; font-weight: 400; font-size: .9rem; }
.or { text-align: center; margin: .25rem 0; }
.inline { display: flex; gap: .5rem; }
.inline input { flex: 1; min-width: 0; }
.inline .btn { flex: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.units { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.unit { display: flex; align-items: center; justify-content: space-between; gap: .5rem; border: 1px solid var(--border); border-radius: 12px; padding: .25rem .75rem; }
.unit-names { display: flex; flex-direction: column; }
.member { color: var(--text); font-weight: 700; padding: .5rem 0; min-height: 44px; }
.member .muted { font-weight: 400; font-size: .85rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.check { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; border: 1px solid var(--border); border-radius: 999px; padding: .4rem .9rem; min-height: 44px; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--primary); }
.check:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); }
.invite input { font-size: .85rem; color: var(--muted); }
@media (max-width: 360px) { .two { grid-template-columns: 1fr; } }

/* Expense sheet + feed (phase 04) */
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.js .nojs { display: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: .75rem; }
select, textarea { font: inherit; width: 100%; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--text); }
textarea { margin-top: .5rem; resize: vertical; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; background: var(--border); border-radius: 12px; padding: .25rem; margin-bottom: 1rem; }
.tabs a { text-align: center; padding: .55rem; border-radius: 10px; color: var(--muted); min-height: 44px; }
.tabs a[aria-current] { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
.amount input { font-size: 2rem; font-weight: 700; text-align: center; padding: .6rem; }
.words { min-height: 1.5em; text-align: center; margin-top: -.4rem; }
.picks { display: flex; flex-wrap: wrap; gap: .5rem; }
.pick { flex: 1 1 auto; }
.pick[open] { flex-basis: 100%; }
.pick summary { list-style: none; cursor: pointer; border: 1px solid var(--border); border-radius: 999px; padding: .45rem .9rem; min-height: 44px; display: flex; align-items: center; gap: .35rem; background: var(--surface); white-space: nowrap; }
.pick summary::-webkit-details-marker { display: none; }
.pick[open] summary { background: var(--primary-soft); border-color: var(--primary); }
.pick.bad summary { border-color: var(--danger); }
.pick-body { border: 1px solid var(--border); border-radius: 12px; padding: .75rem; margin-top: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.opts { display: flex; flex-wrap: wrap; gap: .4rem; }
.opt { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; border: 1px solid var(--border); border-radius: 999px; padding: .35rem .85rem; min-height: 44px; cursor: pointer; }
.opt input { width: 1.15rem; height: 1.15rem; accent-color: var(--primary); }
.opt:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem; }
.seg .opt { justify-content: center; border-radius: 10px; padding: .35rem .4rem; }
.seg .opt input { position: absolute; opacity: 0; }
.shares { display: flex; flex-direction: column; gap: .4rem; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.share-row .opt { flex: 1; border-radius: 12px; }
.w, .x, .w-help, .multi { display: none; }
.pick:has(input[name=mode][value=weights]:checked) .w { display: flex; align-items: center; gap: .25rem; }
.pick:has(input[name=mode][value=weights]:checked) .w-help { display: block; }
.pick:has(input[name=mode][value=exact]:checked) .x { display: block; }
.pick:has(input[name=payer][value=multi]:checked) .multi { display: flex; }
.w input { width: 3.5rem; text-align: center; padding: .5rem .3rem; }
.x input { width: 8.5rem; text-align: center; }
.step { font: inherit; font-weight: 700; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; }
.amt-row { flex-direction: row; align-items: center; justify-content: space-between; font-weight: 400; }
.amt-row input { width: 9rem; text-align: center; }
.treat { align-self: flex-start; }
.note-pick summary { cursor: pointer; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.day { font-size: .9rem; color: var(--muted); margin: 1rem 0 .4rem; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.entry { display: flex; align-items: center; gap: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; color: var(--text); min-height: 56px; }
.entry.treat { border-style: dashed; }
.entry .ico { font-size: 1.4rem; }
.what, .how { display: flex; flex-direction: column; line-height: 1.5; min-width: 0; }
.what { flex: 1; }
.what strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.how { text-align: left; align-items: flex-end; white-space: nowrap; }
.what .muted, .how .muted { font-size: .82rem; }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .25rem; }
.filter { flex: 1 1 8rem; font-weight: 400; }
.filter select { padding: .45rem .6rem; min-height: 44px; font-size: .9rem; }
.fab { position: fixed; left: max(16px, calc(50% - 264px)); bottom: calc(20px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 2rem; line-height: 1; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(15, 118, 110, .4); z-index: 20; }
.wrap:has(.fab) { padding-bottom: 110px; }
.undo { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--text); color: #fff; border-radius: 12px; padding: .3rem .4rem .3rem 1rem; }
.undo .link { color: #8ee6da; font-weight: 700; padding: 0 .75rem; }

/* Balances + settle up + periods (phase 05) */
.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.small { font-size: .85rem; }
.pos { color: var(--primary); }
.neg { color: var(--danger); }
.my { font-weight: 700; font-size: 1.05rem; margin: 0; }
.balances h3 { margin: .5rem 0 0; font-size: 1rem; }
.bal-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 48px; padding: .4rem .75rem; border: 1px solid var(--border); border-radius: 12px; color: var(--text); }
a.bal-row::after { content: '‹'; color: var(--muted); margin-inline-start: .25rem; }
.bal-row .who { flex: 1; min-width: 0; }
.bal { display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; white-space: nowrap; }
.bal .muted { font-weight: 400; }
.plan { border: 1px solid var(--border); border-radius: 12px; padding: .6rem .75rem; display: flex; flex-direction: column; gap: .5rem; }
.plan p { margin: 0; display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.plan .amt { font-weight: 700; white-space: nowrap; }
.cardno { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; background: var(--bg); border-radius: 10px; padding: .4rem .6rem; }
.cardno span { font-family: ui-monospace, monospace; letter-spacing: .03em; }
.ask p { margin: 0 0 .5rem; }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.row-btns .btn { width: 100%; }
.wait { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 44px; }
.wait .link { min-height: 44px; padding: 0 .75rem; }
.close-box { background: var(--primary-soft); border-radius: 12px; padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.close-box p { margin: 0; }
.entry.pending { opacity: .6; border-style: dashed; }
.totals li { display: flex; justify-content: space-between; gap: .75rem; border-bottom: 1px solid var(--border); padding: .35rem 0; }
.links a { display: flex; align-items: center; min-height: 44px; }

/* Profile notices + installed app (phase 07) */
legend { font-weight: 700; padding: 0; margin-bottom: .25rem; }
.radio { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; min-height: 44px; cursor: pointer; }
.radio input { width: 1.2rem; height: 1.2rem; flex: none; accent-color: var(--primary); }
.bar { padding-top: calc(.75rem + env(safe-area-inset-top)); padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
.brand { min-height: 44px; display: inline-flex; align-items: center; }
.me { line-height: 44px; padding-block: 0; }
.wrap { padding-bottom: calc(48px + env(safe-area-inset-bottom)); padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
html { -webkit-tap-highlight-color: transparent; }
@media (display-mode: standalone) { body { overscroll-behavior-y: contain; } }
