/* Layout: sticky header with role-aware tabs; each tab is a stack of panels; vouchers open as paper-style documents */
:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --line: #dde3e6;
  --fg: #14202a;
  --muted: #5d6b75;
  --accent: #1c6e8c;
  --accent-ink: #ffffff;
  --accent-soft: #e2eff4;
  --in: #1f7a4d;
  --in-soft: #e3f3ea;
  --out: #b23a3a;
  --out-soft: #f8e6e5;
  --warn: #9a6a00;
  --warn-soft: #fbf0d6;
  --f-display: "Readex Pro", "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #0f161b; --surface: #172129; --line: #26333d; --fg: #e6edf1; --muted: #93a3ad;
  --accent: #5bb3d3; --accent-ink: #0b1418; --accent-soft: #1a3542;
  --in: #5fcf94; --in-soft: #16302a; --out: #f08a84; --out-soft: #3a1f21;
  --warn: #e8b54a; --warn-soft: #362c14; color-scheme: dark } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 15px; line-height: 1.6; padding-bottom: env(safe-area-inset-bottom, 0px); -webkit-tap-highlight-color: transparent; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.gut { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.pos { color: var(--in); } .neg { color: var(--out); } .warnc { color: var(--warn); }

/* header */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar-in, .tabs, .wrap { max-width: 1112px; margin: 0 auto; }
.bar-in { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 10px 2px; }
.brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.brand-name { font-family: var(--f-display); font-weight: 700; font-size: 1.25rem; }
.round-tag { background: var(--accent-soft); color: var(--accent); padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who .nm { font-weight: 600; font-size: 0.9rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9rem; }
.who .rl { font-size: 0.75rem; color: var(--muted); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs a[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.badge { background: var(--out); color: #fff; border-radius: 999px; font-size: 0.72rem; padding: 0 7px; line-height: 1.6; }

.wrap { padding-block: 20px 64px; display: grid; gap: 16px; }
main { display: grid; gap: 18px; min-width: 0; }
.notice { padding: 10px 14px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-size: 0.92rem; }

/* auth */
.auth { min-height: 100dvh; display: grid; place-items: center; padding-block: calc(env(safe-area-inset-top, 0px) + 24px) 24px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: grid; gap: 16px; }
.auth-logo { width: 56px; height: 56px; border-radius: 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* summary */
.summary { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.summary > div { padding: 16px 18px; display: grid; gap: 2px; min-width: 0; align-content: start; }
.summary > div + div { border-inline-start: 1px solid var(--line); }
.summary .label { color: var(--muted); font-size: 0.82rem; }
.summary .big { font-family: var(--f-display); font-size: 2rem; font-weight: 700; line-height: 1.2; }
.summary .mid { font-family: var(--f-display); font-size: 1.25rem; font-weight: 600; }
.cur { font-size: 0.75rem; color: var(--muted); font-weight: 500; margin-inline-start: 4px; }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead { color: var(--muted); font-size: 0.92rem; max-width: 62ch; }

/* forms */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 8px; border-radius: 6px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"].in { background: var(--in-soft); color: var(--in); }
.seg button[aria-pressed="true"].out { background: var(--out-soft); color: var(--out); }
.seg button[aria-pressed="true"].neutral { background: var(--surface); color: var(--fg); }
form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > label, .field > .lbl { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; }
input[type="email"], input[type="password"] { direction: ltr; text-align: right; }
input[type="email"]:placeholder-shown, input[type="password"]:placeholder-shown { direction: rtl; }
textarea { resize: vertical; min-height: 64px; }
input.money { font-variant-numeric: tabular-nums; text-align: right; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 4px 10px; border-radius: 999px; font: inherit; font-size: 0.85rem; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.btn { border: 0; border-radius: 8px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--accent); color: var(--accent-ink); white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.sm { padding: 5px 10px; font-size: 0.85rem; }
.btn.ok { background: var(--in); color: #fff; }
.btn.danger { background: var(--out); color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-msg { min-height: 1.4em; font-size: 0.88rem; }
.photo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo .thumb { width: 64px; height: 64px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--line); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 0.75rem; flex: none; }
.photo .thumb img { width: 100%; height: 100%; object-fit: cover; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* avatars + lists */
.av { display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden; color: #fff; font-weight: 700; flex: none; font-family: var(--f-display); }
.av img { width: 100%; height: 100%; object-fit: cover; }
.list { display: grid; }
.item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .name { font-weight: 600; overflow-wrap: anywhere; }
.item .sub { font-size: 0.8rem; color: var(--muted); }
.item .end { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: 0.78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--in-soft); color: var(--in); }
.pill.part, .pill.wait { background: var(--warn-soft); color: var(--warn); }
.pill.no { background: var(--out-soft); color: var(--out); }
.pill.role { background: var(--accent-soft); color: var(--accent); }
.progress { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--in); border-radius: 999px; }

.cats { display: grid; gap: 8px; }
.cat { display: grid; grid-template-columns: 7rem minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 0.9rem; }
.bar-h { height: 10px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar-h > span { display: block; height: 100%; background: var(--out); opacity: 0.75; }

/* claims */
.stack { display: grid; gap: 10px; }
.claim { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; }
.claim-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.claim-who { display: flex; gap: 10px; align-items: center; min-width: 0; }
.claim-amt { font-family: var(--f-display); font-weight: 700; font-size: 1.2rem; }
.claim-body { display: flex; gap: 12px; align-items: start; }
.claim-body .txt { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.att { width: 56px; height: 56px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); padding: 0; background: var(--bg); cursor: zoom-in; flex: none; }
.att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.confirm { background: var(--bg); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; font-size: 0.9rem; }

/* tables */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .filters input { width: auto; }
.filters input { min-width: 10rem; flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { text-align: start; padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 500; border-top: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg); }
tr.void td { color: var(--muted); text-decoration: line-through; }
td.amt { font-weight: 600; white-space: nowrap; }
.kind { font-size: 0.78rem; font-weight: 600; padding: 1px 8px; border-radius: 4px; white-space: nowrap; }
.kind.receipt { background: var(--in-soft); color: var(--in); }
.kind.payment { background: var(--out-soft); color: var(--out); }
.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }

/* members */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; background: var(--surface); align-content: start; }
.card-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 0.86rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }

/* voucher document */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgb(8 14 18 / 0.5); overflow-y: auto; display: grid; place-items: start center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 24px) max(16px, env(safe-area-inset-left, 0px)); }
.modal { width: min(640px, 100%); display: grid; gap: 10px; }
.modal-bar { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.voucher { background: var(--surface); border-radius: var(--r); padding: 24px; display: grid; gap: 14px; position: relative; overflow: hidden; border: 1px solid var(--line); }
.voucher::before { content: ""; position: absolute; inset: 0 0 auto; height: 6px; background: var(--k); }
.v-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; border-bottom: 2px solid var(--fg); padding-bottom: 12px; flex-wrap: wrap; }
.v-title { font-family: var(--f-display); font-size: 1.5rem; font-weight: 700; color: var(--k); }
.v-org { font-size: 0.85rem; color: var(--muted); }
.v-no { text-align: end; font-size: 0.85rem; color: var(--muted); }
.v-no b { display: block; font-size: 1.3rem; color: var(--fg); font-family: var(--f-display); }
.v-rows { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; font-size: 0.95rem; margin: 0; }
.v-rows dt { color: var(--muted); white-space: nowrap; }
.v-rows dd { margin: 0; border-bottom: 1px dotted var(--line); padding-bottom: 4px; overflow-wrap: anywhere; }
.v-amount { display: inline-flex; gap: 8px; align-items: baseline; border: 2px solid var(--fg); border-radius: 6px; padding: 6px 14px; font-size: 1.5rem; font-weight: 700; font-family: var(--f-display); max-width: 100%; justify-self: start; }
.v-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 18px; }
.v-sign div { border-top: 1px solid var(--muted); padding-top: 6px; text-align: center; font-size: 0.82rem; color: var(--muted); }
.v-img { max-height: 320px; width: auto; border-radius: 8px; border: 1px solid var(--line); justify-self: start; }
.stamp { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%) rotate(-14deg); border: 3px solid var(--out); color: var(--out); font-family: var(--f-display); font-size: 2.2rem; font-weight: 700; padding: 2px 22px; border-radius: 8px; opacity: 0.7; pointer-events: none; background: var(--surface); }
.big-img { max-width: 100%; max-height: 80vh; border-radius: var(--r); justify-self: center; background: var(--surface); }

@media (max-width: 820px) {
  .grid2 { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr 1fr; }
  .summary > div:first-child { grid-column: 1 / -1; }
  .summary > div:nth-child(2) { border-inline-start: 0; }
  .summary > div + div { border-top: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .row2 { grid-template-columns: 1fr; }
  .cat { grid-template-columns: 5.5rem minmax(0, 1fr) auto; }
  .who .nm { max-width: 6rem; }
  .voucher { padding: 18px; }
}
@media (prefers-reduced-motion: no-preference) { .progress > span, .bar-h > span { transition: width .3s ease; } }
