/* تصميم إدارة مدارج العلم: لوحة عمل هادئة بلون زمردي، أرقام واضحة، جداول قابلة للتمرير على الجوال */
:root {
  --bg: #e7edec;
  --surface: #ffffff;
  --surface-2: #f1f6f5;
  --ink: #0b1a18;
  --muted: #3d4f4b;
  --line: #b9c8c4;
  --line-soft: #d6e0dd;
  --accent: #075a51;
  --accent-ink: #ffffff;
  --accent-soft: #d3ece8;
  --good: #11663f;
  --good-soft: #d6f0e1;
  --warn: #8a4a00;
  --warn-soft: #fbe8c8;
  --bad: #a31d16;
  --bad-soft: #fbdcd9;
  --shadow: 0 8px 28px rgba(10, 40, 36, .18);
  --f-display: var(--f-body);
  /* سلّم أحجام موحّد */
  --fs-xs: 13.5px; --fs-sm: 15px; --fs-md: 16px; --fs-lg: 19px; --fs-num: 25px; --fs-h1: 27px;
  --f-body: "Readex Pro", system-ui, Tahoma, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1413; --surface: #15211f; --surface-2: #1c2b29; --ink: #f1f7f6; --muted: #b9cac6;
    --line: #3f5651; --line-soft: #2c403c; --accent: #5ad2c1; --accent-ink: #04201b; --accent-soft: #14463f;
    --good: #6fdc9f; --good-soft: #14402a; --warn: #f0b862; --warn-soft: #43320f; --bad: #ff9a92; --bad-soft: #4a1f1c;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
--bg: #0b1413; --surface: #15211f; --surface-2: #1c2b29; --ink: #f1f7f6; --muted: #b9cac6;
  --line: #3f5651; --line-soft: #2c403c; --accent: #5ad2c1; --accent-ink: #04201b; --accent-soft: #14463f;
  --good: #6fdc9f; --good-soft: #14402a; --warn: #f0b862; --warn-soft: #43320f; --bad: #ff9a92; --bad-soft: #4a1f1c;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.65; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; margin: 0; text-wrap: balance; }
h1 { font-size: var(--fs-h1); line-height: 1.3; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: 1rem; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font: inherit; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 8px; }
.muted { color: var(--muted); }
.hint { font-size: .8rem; color: var(--muted); }

/* الشريط العلوي */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin-inline: auto; padding: 6px 16px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; flex-direction: column; line-height: 1.2; flex: none; }
.brand b { font-family: var(--f-display); font-size: 1.1rem; color: var(--accent); }
.brand span { font-size: .72rem; color: var(--muted); letter-spacing: .04em; }
#nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav a { white-space: nowrap; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
#nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sync { display: flex; align-items: center; gap: 4px; flex: none; }
.sync-state { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.icon-btn { border: 0; background: transparent; width: 38px; height: 38px; border-radius: 8px; font-size: 1.15rem; color: var(--muted); line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
a.icon-btn { display: inline-grid; place-items: center; text-decoration: none; cursor: pointer; }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }
@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; row-gap: 0; }
  .brand span { display: none; }
  #nav { order: 3; flex-basis: 100%; padding-bottom: 4px; }
  .sync { margin-inline-start: auto; }
  .sync-state { display: none; }
}

#banner { background: var(--warn-soft); border-bottom: 1px solid var(--warn); padding: 8px 16px; font-size: .9rem; text-align: center; }
#banner.bad { background: var(--bad-soft); border-color: var(--bad); }

main { max-width: 1180px; margin-inline: auto; padding: 18px 16px 60px; display: flex; flex-direction: column; gap: 18px; outline: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.page-head p { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* أزرار */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 16px; font-weight: 500; min-height: 40px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.danger-solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.small { padding: 4px 12px; min-height: 32px; font-size: .88rem; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border: 2px solid var(--accent-ink); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.primary).busy::after { border-color: var(--accent); border-top-color: transparent; }

/* بطاقات ولوحات */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel > h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 16px; min-width: 0; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.kpi small { display: block; color: var(--muted); font-size: .82rem; }
.kpi b { display: block; font-size: var(--fs-num); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.kpi .sub { color: var(--muted); font-size: .78rem; }
.kpi.owe b { color: var(--bad); }
.kpi.credit b { color: var(--good); }
.kpi.main b { color: var(--accent); }

.empty-state { text-align: center; padding: 28px 16px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty-state b { color: var(--ink); font-size: 1.05rem; }

.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.bal small { font-size: .75rem; color: var(--muted); }
.bal.owe { color: var(--bad); font-weight: 600; }
.bal.credit { color: var(--good); font-weight: 600; }
.bal.zero { color: var(--muted); }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* الجداول */
.dt { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dt-search { flex: 1 1 200px; max-width: 360px; min-height: 40px; border: 1px solid var(--line); border-radius: 9px; padding: 6px 12px; background: var(--surface); }
.dt-search:focus { border-color: var(--accent); outline: 0; }
.dt-count { color: var(--muted); font-size: .82rem; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sorted { color: var(--accent); }
th.sorted::after { content: " " attr(data-dir); font-size: .65rem; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--surface-2); }
tr.dim td { color: var(--muted); }
tr.voided td { text-decoration: line-through; color: var(--muted); }
td.num-col, th.num-col { text-align: end; }
.empty-cell { text-align: center; color: var(--muted); padding: 24px; }
tfoot td { background: var(--surface-2); font-weight: 600; border-top: 2px solid var(--line); border-bottom: 0; }

/* النماذج */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 14px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld.wide { grid-column: 1 / -1; }
.fld > label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.req { color: var(--bad); }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=search], input[type=password], input[type=url], select, textarea {
  width: 100%; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; min-height: 42px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
input[type=number], input[type=time], input[data-num] { direction: ltr; text-align: end; }
input.invalid, select.invalid { border-color: var(--bad); }
.hint.lock { color: var(--warn); }
.form-error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 12px; font-size: .88rem; }
.form-note { background: var(--warn-soft); border-radius: 8px; padding: 8px 12px; font-size: .86rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; min-width: 0; }
legend { padding-inline: 6px; color: var(--muted); font-size: .82rem; font-weight: 600; }
.days-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.seg label { position: relative; min-width: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 8px 6px; border-radius: 7px; font-weight: 500; font-size: .9rem; line-height: 1.35; }
.seg small { display: block; font-size: .72rem; opacity: .8; font-weight: 400; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.stepper { display: grid; grid-template-columns: 38px minmax(44px, 1fr) 38px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; width: 140px; max-width: 100%; }
.stepper button { border: 0; background: var(--surface-2); height: 40px; font-size: 1.2rem; font-weight: 600; color: var(--accent); }
.stepper button:hover { background: var(--accent-soft); }
.stepper input { width: 100%; min-width: 0; text-align: center !important; border: 0 !important; border-radius: 0; background: transparent; font-weight: 700; height: 40px; min-height: 40px; box-shadow: none !important; -moz-appearance: textfield; padding: 0; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper.sm { width: 112px; grid-template-columns: 30px 1fr 30px; }
.stepper.sm button, .stepper.sm input { height: 34px; min-height: 34px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.chip span { display: block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 500; }
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* خيار صح/خطأ بنص توضيحي (مثل: حصة المعلم بعد الزيادة) */
.share-increase { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.share-increase input { flex: 0 0 auto; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.share-increase > span { display: flex; flex-direction: column; gap: 2px; font-weight: 500; line-height: 1.45; }
.share-increase .hint { font-weight: 400; }

/* النوافذ */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(8, 20, 18, .55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px 12px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: var(--shadow); display: flex; flex-direction: column; margin-block: auto; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.confirm-text { line-height: 1.8; }

#toast { position: fixed; inset-inline: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); margin-inline: auto; width: fit-content; max-width: min(100%, 560px); background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 12px; font-size: .9rem; opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 80; }
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: var(--bad); color: #fff; }
#toast.good { background: var(--good); color: #fff; }

/* الخطوات والحاسبة */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: st; display: flex; flex-direction: column; }
.steps li { counter-increment: st; display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; padding: 12px 0; border-top: 1px solid var(--line); align-items: baseline; }
.steps li:first-child { border-top: 0; padding-top: 0; }
.steps li::before { content: counter(st); width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; display: grid; place-items: center; align-self: start; }
.steps .t { font-weight: 600; }
.steps .r { font-weight: 700; color: var(--accent); white-space: nowrap; }
.steps .f { grid-column: 2 / -1; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.steps .f .num { color: var(--ink); }
.dates { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.dates span { font-size: .75rem; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); line-height: 1.5; }
.dates span.off { background: transparent; border: 1px dashed var(--line); color: var(--muted); text-decoration: line-through; }
.band { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: grid; grid-template-columns: repeat(3, 1fr); }
.band > div { padding: 14px; min-width: 0; }
.band > div + div { border-inline-start: 1px solid var(--line); }
.band small { color: var(--muted); display: block; font-size: .8rem; }
.band b { font-size: var(--fs-num); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.band .main b { color: var(--accent); }
.status { font-size: .85rem; border-radius: 8px; padding: 6px 12px; background: var(--accent-soft); }
.status.warn { background: var(--warn-soft); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.cols-calc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 900px) { .cols-calc { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } }
.group { display: flex; flex-direction: column; gap: 10px; }
.group + .group { border-top: 1px solid var(--line); padding-top: 16px; }
.q { font-weight: 600; }
.adj { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; }
.adj + .adj { border-top: 1px dashed var(--line); padding-top: 10px; }
.adj .txt { display: flex; flex-direction: column; min-width: 0; flex: 1 1 150px; }
.adj .txt b { font-weight: 600; }

/* الشهر */
.month-row-input { width: 74px; min-height: 34px; padding: 4px 8px; text-align: center !important; }
.month-table td { white-space: nowrap; }
.month-table td.wrap { white-space: normal; min-width: 150px; }
.sticky-foot { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; box-shadow: var(--shadow); z-index: 5; }

.statement .debit { color: var(--bad); }
.statement .credit { color: var(--good); }

.kv { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding-block: 4px; border-bottom: 1px dashed var(--line); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list-plain li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.list-plain li:first-child { border-top: 0; }
.list-plain button.link { background: none; border: 0; padding: 0; text-align: start; color: var(--accent); font-weight: 600; }
.list-plain button.link:hover { text-decoration: underline; }
.code { direction: ltr; text-align: left; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; white-space: pre; }
.loading { padding: 60px 16px; text-align: center; color: var(--muted); }

@media (max-width: 560px) {
  .band { grid-template-columns: 1fr; }
  .band > div + div { border-inline-start: 0; border-top: 1px solid var(--line); }
  .band > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .modal-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001s !important; transition-duration: .001s !important; } }

/* تنقل الأشهر */
.monthnav { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.monthnav button { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 8px; font-size: 1.2rem; color: var(--ink); }
.monthnav button:hover { background: var(--accent-soft); }
.monthnav .lbl { min-width: 138px; text-align: center; font-weight: 600; font-size: var(--fs-md); }
td .num, th .num { white-space: nowrap; }
.month-table th, .month-table td { padding: 8px 8px; }
.stepper.sm { width: 104px; }

/* ───────── الواجهة المبسّطة ───────── */
a.brand { text-decoration: none; }
.sync-state.saving { color: var(--accent); font-weight: 600; }
#nav a { display: flex; align-items: center; gap: 6px; }
.nav-ico { display: none; }

/* أزرار العمليات السريعة */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick .btn { min-height: 52px; font-size: 1rem; font-weight: 600; }
.strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 12px; padding: 10px 14px; }

/* بطاقات الأرقام */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.tiles.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; text-align: start; min-width: 0; }
button.tile { cursor: pointer; }
button.tile:hover { border-color: var(--accent); }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile b, .tile .bal { font-size: var(--fs-num); font-weight: 600; line-height: 1.45; }
.tile small { color: var(--muted); font-size: .8rem; }
.tile.owe b { color: var(--bad); }
.tile.credit b { color: var(--good); }
.tile.main b { color: var(--accent); }
.amounts { display: flex; flex-direction: column; gap: 0; }
.amounts b { font-weight: 600; font-size: var(--fs-num); line-height: 1.45; }
li > .amounts, .acct .amounts { align-items: flex-end; }
.amt-zero { color: var(--muted); font-weight: 600; font-size: var(--fs-num); line-height: 1.45; }
li.late { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 14px; align-items: center; }
li.late .bal { font-size: var(--fs-md); }
li.voided { text-decoration: line-through; color: var(--muted); }
.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: -6px; }
.meter i { display: block; height: 100%; background: var(--good); border-radius: 999px; }

/* بطاقات الحسابات (الأموال) */
.accts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.acct { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.acct.main { border-color: var(--accent); background: var(--accent-soft); }
.acct-name { font-weight: 600; font-size: var(--fs-md); }
.acct .amounts { align-items: flex-start; flex: 1; }

/* رسم الأشهر */
.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; height: 170px; }
.bar-col { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 4px; text-align: center; opacity: .75; }
.bar-col.on { opacity: 1; }
.bar-col small { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.bar-pair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar-pair i, .legend i { display: inline-block; width: 40%; max-width: 22px; min-height: 2px; border-radius: 4px 4px 0 0; }
.bar-pair i.due, .legend i.due { background: var(--line); border: 1px solid var(--muted); }
.bar-pair i.got, .legend i.got { background: var(--good); }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); }
.legend i { width: 12px; height: 12px; min-height: 12px; border-radius: 3px; vertical-align: -1px; }

tr.pending td, li.pending { opacity: .55; }
.tool-pane, .data-pane { display: flex; flex-direction: column; gap: 18px; }
.tool-pane .page-head { display: none; }
.data-pane { margin-top: 4px; }
details.panel > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-lg); }
details.panel[open] > summary { margin-bottom: 8px; }

/* الجوال: شريط تنقل سفلي، وجداول بشكل بطاقات */
@media (max-width: 760px) {
  .topbar { position: sticky; }
  .topbar-in { flex-wrap: nowrap; }
  #nav { position: fixed; inset-inline: 0; bottom: 0; order: 0; flex: none; background: var(--surface); border-top: 1px solid var(--line); z-index: 40;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; overflow: visible; }
  #nav a { flex-direction: column; gap: 1px; padding: 6px 2px; font-size: .68rem; text-align: center; border-radius: 10px; line-height: 1.25; }
  .nav-ico { display: block; }
  main { padding-bottom: 96px; }
  #toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .sticky-foot { bottom: 70px; }
  h1 { font-size: 1.3rem; }
  .tile b, .tile .bal, .amounts b, .amt-zero { font-size: 1.25rem; }
  li.late { grid-template-columns: 1fr auto; }
  li.late .actions { grid-column: 1 / -1; }
}

/* توحيد الخط: عائلة واحدة، والأرقام والمبالغ ترث حجم النص حولها */
html, body, button, input, select, textarea, table, h1, h2, h3, b, strong, small { font-family: var(--f-body); }
.bal small, .tile small { font-size: var(--fs-xs); font-weight: 400; }
td b, li b { font-weight: 600; }
.bal { font-size: inherit; }

/* سلّم الأحجام النهائي: 12.5 للتفاصيل، 14 للعناوين الفرعية والأزرار الصغيرة، 15 للنص، 18 للعناوين، 22 للأرقام، 24 للعنوان الرئيسي */
.hint, small, .badge, th, .dt-count, .legend, .bar-col small, .tile small, .bal small, .fld > label, .hint.lock, .dates span, .stepper + .hint { font-size: var(--fs-xs); }
.tile-label, .btn.small, .seg span, .page-head p, .form-note, .form-error, .status, .dt-search { font-size: var(--fs-sm); }
.btn, table, td, .kv, .kv dt, .kv dd, .list-plain, .acct-name, .monthnav .lbl, input, select, textarea, .empty-state p, .confirm-text { font-size: var(--fs-md); }
.empty-state b { font-size: var(--fs-lg); }
.bal.zero, .bal.owe, .bal.credit { font-size: var(--fs-md); }
.tile .bal { font-size: var(--fs-num); }
.badge { font-weight: 500; }
@media (max-width: 760px) { #nav a { font-size: 12.5px; } h1 { font-size: 23px; } }
.fld > select + input[type="text"] { margin-top: 6px; }

/* ───── تحسينات الجوال ───── */
h2 .actions { margin-inline-start: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; vertical-align: middle; }
.panel > h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
@media (max-width: 760px) {
  /* حقول بحجم 16px: يمنع تكبير الصفحة تلقائياً في آيفون، وارتفاع مريح للمس */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; min-height: 38px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  .btn { min-height: 38px; }
  .btn.small { min-height: 38px; padding-inline: 14px; }
  .icon-btn { width: 42px; height: 42px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head .actions { display: flex; }
  .page-head .actions .btn { flex: 1; }
  .tiles > .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tile b, .tile .bal { overflow-wrap: anywhere; }
  .panel { padding: 14px; }
  .dt-bar, .dt-toolbar { flex-wrap: wrap; }
  .dt-search { flex: 1 1 100%; }
  .monthnav { width: 100%; justify-content: space-between; }

  /* النافذة كشاشة سفلية: الرأس والأزرار ثابتة والمحتوى يتمرر */
  .backdrop { padding: 0; align-items: flex-end; overflow: hidden; }
  .modal, .modal.wide { max-width: none; width: 100%; max-height: 94dvh; margin: 0; border-radius: 18px 18px 0 0; overflow: hidden; }
  .modal-head { flex: none; padding: 12px 16px; }
  .modal-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 14px 16px; }
  .modal-actions { flex: none; border-radius: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); flex-wrap: nowrap; }
  .modal-actions .btn { flex: 1 1 0; }
  .modal-actions .btn.danger { flex: 0 0 auto; margin-inline-end: 0 !important; }
  .form-grid { grid-template-columns: 1fr; }
  .days-grid { grid-template-columns: repeat(2, 1fr); }
}
.mobile-only { display: none; }
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; align-self: flex-start; }
  .list-plain button.link, button.link { min-height: 40px; display: inline-flex; align-items: center; }
  .empty-state b { font-size: var(--fs-md); }
}

/* بطاقات بدل الجداول على الجوال والتابلت */
@media (max-width: 900px) {
  table.stack, table.stack tbody { display: block; }
  table.stack thead { display: none; }
  table.stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: flex; flex-direction: column; border: 0; padding: 2px 0; text-align: start; min-width: 0; }
  table.stack td::before { content: attr(data-label); font-size: .72rem; color: var(--muted); }
  table.stack td:first-child, table.stack td:last-child, table.stack td.wrap { grid-column: 1 / -1; }
  table.stack td:not([data-label])::before, table.stack td[data-label=""]::before { content: none; }
  table.stack td.num-col { text-align: start; }
  table.stack tr { cursor: pointer; }
  table.stack tr:active { background: var(--surface-2); }
  table.stack td:first-child { font-weight: 600; }
  table.stack td input[type="text"], table.stack td input[type="number"] { width: 100% !important; min-width: 0 !important; }
  table.stack td .actions { display: flex; gap: 8px; }
  table.stack td .actions .btn { flex: 1; }
}
@media (min-width: 600px) and (max-width: 900px) { table.stack tr { grid-template-columns: repeat(3, 1fr); } }
ul.vars li { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 0; }
ul.vars .code { padding: 2px 8px; display: inline-block; }
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
@media (max-width: 900px) { table.stack td:first-child::before { content: none; } }

/* ───── لمسة التصميم النهائية ───── */
:root { --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --sp: 16px; }
body { background: var(--bg); }
.topbar { backdrop-filter: saturate(1.2) blur(6px); }
.panel, .tile, .kpi, .acct { border-radius: var(--r-md); box-shadow: 0 1px 2px rgba(10, 40, 36, .04); }
.panel > h2, .sect-head h2 { font-size: var(--fs-lg); }
.panel h3 { font-size: var(--fs-md); font-weight: 600; color: var(--muted); }
.sect-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.month-stats { display: flex; flex-direction: column; gap: 14px; padding-top: 10px; border-top: 1px dashed var(--line); margin-top: 4px; }
.tile { transition: border-color .15s, box-shadow .15s, transform .1s; }
button.tile:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(10, 40, 36, .08); }
button.tile:active { transform: scale(.985); }
.btn { border-radius: var(--r-sm); }
.btn.primary { box-shadow: 0 1px 2px rgba(10, 40, 36, .18); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.page-head h1 { letter-spacing: 0; }
.strip { border-radius: var(--r-md); }
@media (min-width: 900px) {
  main { padding: 26px 24px 70px; gap: 22px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .panel { padding: 20px; }
  .grid.cols-2 { gap: 22px; }
}
@media (max-width: 760px) {
  main { padding: 14px 14px 100px; gap: 14px; }
  .sect-head { flex-direction: column; align-items: stretch; }
  .sect-head .actions { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
  .quick { grid-template-columns: 1fr 1fr; }
  .seg { width: 100%; }
}

/* ───── أحجام مريحة للقراءة ───── */
body { font-size: 16px; line-height: 1.65; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=search], input[type=password], input[type=url], select, textarea { min-height: 44px; padding: 8px 12px; border-radius: 10px; font-size: 16px; border-width: 1.5px; }
textarea { min-height: 72px; }
.btn { min-height: 44px; padding: 8px 18px; border-radius: 10px; font-weight: 600; }
.btn.small { min-height: 36px; padding: 4px 14px; }
.dt-search { min-height: 44px; }
.dt { gap: 12px; }
th, td { padding: 11px 14px; }
table { font-size: 1rem; }
.form-grid { gap: 14px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.fld { gap: 5px; }
.fld > label { font-size: .92rem; color: var(--ink); font-weight: 600; }
.hint { font-size: .85rem; line-height: 1.5; }
.inrow { display: flex; gap: 6px; align-items: stretch; min-width: 0; }
.inrow > input, .inrow > select:first-child { flex: 1 1 auto; }
/* الحقول الرقمية قصيرة: 3 إلى 4 خانات عادةً */
.fld.numf { max-width: 100%; }
.fld.numf .inrow > input[data-num] { width: 6.5em; max-width: 6.5em; flex: 0 0 auto; }
.inrow > select.unit-sel { width: 4.2em; flex: 0 0 auto; padding-inline: 6px; text-align: center; font-weight: 600; }
.modal-body { padding: 12px 16px; }
.panel { padding: 12px 14px; }
.page-head { margin-bottom: 10px; }

/* بطاقات القوائم (الحلقات والطلاب) */
th.card-col, td.card-col { display: none; }
.rc { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rc-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rc-top b { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rc-id { flex: none; font-size: .82rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 0 7px; line-height: 1.7; }
.rc-sub { font-size: .8rem; color: var(--muted); }
.rc-meta { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: .8rem; }
.rc-sched { font-size: .74rem; color: var(--muted); }
@media (max-width: 900px) {
  table.stack.cards td:not(.card-col) { display: none; }
  table.stack.cards td.card-col { display: block; grid-column: 1 / -1; }
  table.stack.cards td.card-col::before { content: none; }
  table.stack.cards tr { display: block; padding: 8px 12px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
  .fld.wide, fieldset.fld { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn { min-height: 38px; }
  .modal-body { padding: 10px 14px; }
}
table.stack.cards td.card-col { font-weight: 400; }
.seg span { padding: 6px 4px; font-size: .85rem; }
.rc-act { display: flex; gap: 8px; margin-top: 4px; }
.rc-act .btn { flex: 0 0 auto; min-width: 84px; }
.rc-meta .muted { color: var(--muted); }
.form-grid { align-items: start; }
.fld .hint { display: block; }
.fld.wide .hint, fieldset .hint { display: block; }
@media (max-width: 760px) { .days-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } .days-grid input[type=time] { padding-inline: 4px; font-size: 13px; } }
.amounts.sm { display: inline-flex; flex-direction: column; align-items: flex-end; font-weight: 500; }
table.mini th, table.mini td { padding: 4px 8px; vertical-align: top; }
table.mini tr.on td { background: var(--accent-soft); font-weight: 600; }
table.mini td:not(:first-child), table.mini th:not(:first-child) { text-align: end; }
.kv dd { text-align: end; }
/* وسوم (chips) لتفاصيل عناصر القوائم */
.rc { gap: 5px; }
.rc-chips { display: flex; flex-wrap: wrap; gap: 4px 5px; }
.rc-chips > .ch { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 1px 11px; font-size: .88rem; line-height: 1.7; white-space: nowrap; }
.rc-chips > .ch.t { color: var(--ink); font-weight: 500; }
.rc-chips > .ch.k { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.rc-chips > .ch.w { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.rc-chips > .ch.d { background: transparent; font-size: .82rem; padding: 0 8px; }
.rc-chips > .ch.big { font-size: .85rem; font-weight: 600; }
.rc-chips.sm { gap: 3px 4px; }

/* ═════════ قراءة أوضح: تباين أعلى، أحجام أكبر، بطاقات وقوائم أوضح ═════════ */
:root { --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); --card-shadow: 0 1px 2px rgba(7, 40, 36, .10), 0 3px 10px rgba(7, 40, 36, .06); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
::placeholder { color: var(--muted); opacity: .8; }
select { cursor: pointer; }

/* الشريط العلوي والتنقل */
.topbar { border-bottom: 2px solid var(--line); box-shadow: 0 2px 8px rgba(7, 40, 36, .06); }
.topbar-in { padding: 8px 18px; }
.brand b { font-size: 1.25rem; font-weight: 700; }
.brand span { font-size: .8rem; color: var(--muted); }
#nav a { padding: 9px 14px; font-size: 1rem; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; border-radius: 10px; }
#nav a:hover { color: var(--ink); background: var(--surface-2); }
#nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.sync-state { font-size: .85rem; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; font-size: 1.3rem; color: var(--ink); border: 1px solid transparent; }
.icon-btn:hover { border-color: var(--line); }

/* رأس الصفحة */
.page-head h1 { font-size: var(--fs-h1); font-weight: 700; }
.page-head p { font-size: 1rem; color: var(--muted); margin-top: 4px; }
main { gap: 22px; }

/* اللوحات والعناوين: شريط لوني يفصل الأقسام */
.panel { border: 1.5px solid var(--line); box-shadow: var(--card-shadow); padding: 18px 20px; gap: 14px; }
.panel > h2, .sect-head h2 { font-size: var(--fs-lg); font-weight: 700; position: relative; padding-inline-start: 14px; }
.panel > h2::before, .sect-head h2::before { content: ""; position: absolute; inset-inline-start: 0; top: .2em; bottom: .2em; width: 5px; border-radius: 4px; background: var(--accent); }
.panel h3 { font-size: 1rem; font-weight: 700; color: var(--ink); }

/* البطاقات الرقمية: شريط ملوّن على الجانب يدلّ على المعنى */
.tile, .kpi { border: 1.5px solid var(--line); box-shadow: var(--card-shadow); padding: 16px 18px; border-inline-start-width: 6px; border-inline-start-color: var(--line); gap: 6px; }
.tile.owe, .kpi.owe { border-inline-start-color: var(--bad); }
.tile.credit, .kpi.credit { border-inline-start-color: var(--good); }
.tile.main, .kpi.main { border-inline-start-color: var(--accent); }
.tile-label { color: var(--ink); font-size: 1rem; font-weight: 600; }
.tile small, .kpi small { color: var(--muted); font-size: .9rem; }
.tile b, .tile .bal, .amounts b, .amt-zero { font-size: var(--fs-num); font-weight: 700; }
button.tile:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(7, 40, 36, .16); }
.tile.owe b { color: var(--bad); }
.tile.credit b { color: var(--good); }
.tile.main b { color: var(--accent); }
.amt-zero { color: var(--muted); }

/* الأزرار */
.btn { border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.12); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: var(--bad-soft); }
.quick .btn { min-height: 56px; font-size: 1.05rem; }

/* الشارات: نقطة لونية + نص بخط أوضح، فلا يعتمد المعنى على اللون وحده */
.badge { font-size: .88rem; font-weight: 600; padding: 2px 12px 2px 10px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* الأرصدة: حبّة ملوّنة تُقرأ بنظرة */
.bal.owe, .bal.credit { display: inline-flex; align-items: baseline; gap: 6px; padding: 2px 12px; border-radius: 999px; font-weight: 700; }
.bal.owe { background: var(--bad-soft); color: var(--bad); }
.bal.credit { background: var(--good-soft); color: var(--good); }
.bal.zero { color: var(--muted); font-weight: 600; }
.bal small { color: inherit; opacity: .9; font-size: .85rem; font-weight: 600; }

/* الجداول */
.table-scroll { border: 1.5px solid var(--line); box-shadow: var(--card-shadow); border-radius: 12px; }
th { background: var(--accent-soft); color: var(--ink); font-size: .92rem; font-weight: 700; border-bottom: 2px solid var(--line); }
th.sorted { color: var(--accent); }
td { border-bottom: 1px solid var(--line-soft); }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
tr.clickable:hover td { background: var(--accent-soft); }
tr.dim td { color: var(--muted); }
.dt-count { color: var(--muted); font-size: .92rem; font-weight: 600; }
.dt-search { border-width: 1.5px; font-size: 1rem; }
.empty-cell { font-size: 1.05rem; }

/* قوائم عادية */
.list-plain li { padding: 12px 0; border-top: 1px solid var(--line-soft); font-size: 1rem; }
.list-plain button.link { font-size: 1.05rem; font-weight: 700; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 4px; }
.kv > div { padding-block: 8px; border-bottom: 1px dashed var(--line); }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { font-weight: 700; }

/* بطاقات الحسابات والتنبيهات */
.acct { border: 1.5px solid var(--line); background: var(--surface); box-shadow: var(--card-shadow); padding: 14px 16px; }
.acct.main { border-color: var(--accent); background: var(--accent-soft); }
.acct-name { font-weight: 700; }
.strip { border-width: 1.5px; font-size: 1rem; padding: 12px 16px; }
#banner { font-size: 1rem; padding: 10px 16px; font-weight: 600; }
.form-note, .form-error, .status { font-size: .95rem; padding: 10px 14px; border: 1px solid transparent; }
.form-note { border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--ink); }
.form-error { border-color: color-mix(in srgb, var(--bad) 35%, transparent); font-weight: 600; }
.empty-state { padding: 36px 16px; font-size: 1rem; }

/* النماذج والنوافذ */
.modal { border: 1.5px solid var(--line); }
.modal-head { padding: 14px 20px; background: var(--surface-2); border-radius: 14px 14px 0 0; }
.modal-head h2 { font-size: 1.2rem; font-weight: 700; }
.modal-body { padding: 18px 20px; gap: 16px; }
.modal-actions { padding: 14px 20px; }
.backdrop { background: rgba(5, 14, 12, .65); }
fieldset { border-width: 1.5px; }
legend { color: var(--ink); font-size: .95rem; font-weight: 700; }
.hint { color: var(--muted); }
.req { color: var(--bad); font-weight: 700; }
.seg { border-width: 1.5px; }
.seg span { font-size: 1rem; font-weight: 600; padding: 10px 8px; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.chip span { font-size: 1rem; border-width: 1.5px; font-weight: 600; }
.monthnav { border-width: 1.5px; }

/* بطاقات القوائم (الطلاب والحلقات) */
table.stack.cards tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.rc { gap: 8px; }
.rc-top b { font-size: 1.1rem; font-weight: 700; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.4; }
.rc-chips { gap: 6px 6px; }
.rc-chips > .ch.k { font-weight: 600; }
.rc-chips > .ch.t { background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.rc-sub, .rc-meta { font-size: .92rem; }
@media (max-width: 900px) {
  table.stack.cards tbody { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
  table.stack.cards tr { border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--card-shadow); }
  table.stack.cards tr:active { background: var(--accent-soft); }
  .table-scroll:has(table.stack.cards) { border: 0; box-shadow: none; background: transparent; }
  tbody tr:nth-child(even) td { background: transparent; }
}

/* الجوال */
@media (max-width: 760px) {
  main { padding: 16px 14px 104px; gap: 18px; }
  #nav { border-top: 2px solid var(--line); box-shadow: 0 -4px 14px rgba(7, 40, 36, .10); padding-top: 6px; }
  #nav a { font-size: 12.5px; padding: 6px 2px; border-bottom: 0; }
  #nav a[aria-current="page"] { background: var(--accent); }
  .nav-ico svg { width: 24px; height: 24px; }
  .panel { padding: 16px; }
  .tile b, .tile .bal, .amounts b, .amt-zero { font-size: 1.45rem; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-body { padding: 16px; }
  .quick .btn { min-height: 54px; }
}
@media (max-width: 380px) { .form-grid { grid-template-columns: 1fr; } }

/* حقول جديدة: ملء تلقائي وقوائم */
.fld.auto > label::after { content: " · تلقائي"; font-weight: 500; font-size: .8rem; color: var(--accent); }
.fld .suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.fld .suggest button { border: 1.5px dashed var(--accent); background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 12px; font-size: .88rem; font-weight: 600; min-height: 30px; }
.fld .suggest button:hover { background: var(--accent); color: var(--accent-ink); }
.age-pill { display: inline-flex; align-self: flex-start; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 12px; font-weight: 700; font-size: .92rem; }
.phone-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px; }
.phone-row select { direction: ltr; text-align: start; }

/* فرز الجداول */
.dt-sort{min-height:42px;border:1px solid var(--line);border-radius:10px;padding:0 10px;background:var(--surface,#fff);color:var(--ink);font:inherit;max-width:100%}
.dt-dir{min-height:42px;min-width:42px;border:1px solid var(--line);border-radius:10px;background:var(--surface,#fff);color:var(--ink);font-size:18px;cursor:pointer}
