/* Staff screens of «اقرأ معي».
   Brand blue #0f4c75 (white on it: 9:1). The logo is used reversed on the blue bar:
   white book, blue title. Quiet by design: paper background, hairlines, few boxes. */
:root {
  --paper: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --ink: #1f1d19;
  --ink-2: #5f5a50;
  --ink-3: #8a8478;
  --line: #e2ddd2;
  --line-strong: #cfc8b9;
  --brand: #0f4c75;
  --brand-2: #0a3756;
  --brand-ink: #ffffff;
  --brand-soft: #eaf1f7;
  --ok: #1d6b3a;    --ok-soft: #eef6f0;
  --warn: #8a5300;  --warn-soft: #fcf4e6;
  --bad: #a8261b;   --bad-soft: #fbefed;
  --radius: 6px;
  /* one family for everything: Readex Pro (Arabic and Latin digits drawn to sit together) */
  --sans: "Readex Pro", "Segoe UI", Tahoma, system-ui, sans-serif;
  --serif: var(--sans);
  --sidebar: 232px;
  /* older names used by the dashboard stylesheet */
  --bg: var(--paper);
  --font: var(--sans);
  --shadow: none;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.7; font-weight: 400;
       -webkit-text-size-adjust: 100%; }
a { color: var(--brand); text-underline-offset: 3px; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
kbd { font: 500 .75rem/1 var(--sans); padding: .1rem .3rem; border: 1px solid var(--line-strong); border-radius: 3px;
      background: var(--surface); color: var(--ink-2); }

/* ── blue bar: logo and account only ─────────────────────── */
.topbar { display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; background: var(--brand); color: var(--brand-ink);
          min-height: 60px; position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; padding: .45rem 0; }
.brand-logo { display: block; height: 40px; width: auto; }
.brand-text { display: grid; line-height: 1.35; }
.brand-text b { font-weight: 600; font-size: 1rem; }
.brand-text small { font-size: .78rem; opacity: .75; }
.who { margin-inline-start: auto; display: flex; align-items: center; gap: .9rem; font-size: .88rem; }
.who form, .drawer-who form { margin: 0; }
.who .link { color: inherit; opacity: .85; }

/* ── side panel (wide screens) ───────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); align-items: start; }
.sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; background: var(--surface);
           border-inline-end: 1px solid var(--line); padding: 1rem 0 2rem; }
.nav-group { display: grid; padding: .35rem 0 .75rem; }
.nav-group + .nav-group { border-top: 1px solid var(--line); padding-top: .75rem; }
.nav-title { font-size: .75rem; font-weight: 500; color: var(--ink-3); padding: 0 1.25rem .3rem; }
.nav-group a { display: block; padding: .45rem 1.25rem; color: var(--ink-2); text-decoration: none; font-size: .95rem;
               border-inline-start: 3px solid transparent; }
.nav-group a:hover { background: var(--paper); color: var(--ink); }
.nav-group a[aria-current] { color: var(--brand); font-weight: 600; background: var(--brand-soft); border-inline-start-color: var(--brand); }
.nav-foot a { font-size: .88rem; }

/* ── drawer (phones and narrow screens) ──────────────────── */
.menu { display: none; }
.menu > summary { display: flex; align-items: center; gap: .5rem; list-style: none; cursor: pointer; padding: .45rem .6rem;
                  border-radius: 4px; font-weight: 500; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: rgb(255 255 255 / .15); }
.menu-icon { width: 18px; height: 12px; border-top: 2px solid; border-bottom: 2px solid; position: relative; }
.menu-icon::after { content: ""; position: absolute; inset-inline: 0; top: 3px; border-top: 2px solid; }
.drawer { position: fixed; inset-block: 56px 0; inset-inline-start: 0; width: min(300px, 86vw); background: var(--surface);
          color: var(--ink); overflow-y: auto; padding: .75rem 0 2rem; box-shadow: 0 0 0 100vmax rgb(20 24 30 / .35); z-index: 40; }
.drawer-who { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: .75rem 1.25rem 0;
              padding-top: .75rem; border-top: 1px solid var(--line); font-size: .92rem; color: var(--ink-2); }

main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.75rem 4rem; min-width: 0; }
.messages { display: grid; gap: .4rem; margin-bottom: 1rem; }
.flash { padding: .55rem .8rem; border-inline-start: 3px solid var(--ok); background: var(--ok-soft); color: var(--ok); }
.flash.error { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

/* ── today, in one sentence ─────────────────────────────── */
.today { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1.25rem; padding-bottom: 1rem;
         margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: .95rem; }
.today b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.today .late b { color: var(--bad); }
.today-date { font: 600 1.1rem var(--serif); color: var(--ink); margin-inline-end: .5rem; }

/* ── the desk: three columns, separated by lines, not boxes ─ */
.desk { display: grid; grid-template-columns: 1.15fr 1fr .85fr; align-items: start;
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { padding: 1.1rem 1.25rem 1.4rem; min-width: 0; }
.desk > .panel + .panel { border-inline-start: 1px solid var(--line); }
.panel-head { margin-bottom: .6rem; }
.panel-head h2 { font-size: .85rem; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.panel-body { margin-top: 1rem; min-height: 5rem; }
.panel-action { background: #fbfaf7; align-self: stretch; }

.field { display: grid; gap: .3rem; }
.field > span:not(.sr) { font-size: .88rem; color: var(--ink-2); }
input[type=search], .field input { width: 100%; font: 500 1.1rem var(--sans); padding: .6rem .75rem;
  border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.hint, .empty { color: var(--ink-3); font-size: .92rem; }

/* search results: a plain list */
.results { border-top: 1px solid var(--line); }
.result { width: 100%; display: flex; align-items: baseline; gap: .75rem; padding: .5rem .25rem; border: 0;
  border-bottom: 1px solid var(--line); background: none; font: inherit; color: inherit; text-align: start; cursor: pointer; }
.result:hover, .result:focus-visible { background: var(--brand-soft); outline: none; }
.result-key { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 4.5rem; color: var(--brand); }
.result-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-sub { color: var(--ink-3); font-size: .85rem; }

/* member / book card */
.card { display: grid; gap: .9rem; }
.card-top { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.card-title { font: 600 1.18rem/1.6 var(--serif); }
.callno { font-size: 1.15rem; font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; text-align: right; }
.meta { color: var(--ink-2); font-size: .88rem; display: flex; flex-wrap: wrap; gap: .1rem .9rem; }
.icon-link { font-size: .85rem; white-space: nowrap; }
.sec { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
.note { font-size: .85rem; color: var(--warn); }

/* states: a small square and a word; colour is never the only signal */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 600; }
.badge::before { content: ""; width: .5rem; height: .5rem; border-radius: 1px; background: currentColor; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }

.sub { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; padding: .6rem 0; border-top: 1px solid var(--line);
       border-bottom: 1px solid var(--line); }
.renew { display: flex; gap: .4rem; margin-inline-start: auto; }

.verdict { padding: .55rem .8rem; border-inline-start: 3px solid; display: grid; gap: .3rem; }
.verdict ul { list-style: disc; padding-inline-start: 1.1rem; }
.verdict.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.verdict.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--ink); }
.verdict.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.verdict .meta { color: inherit; opacity: .9; }
.verdict form { margin-top: .4rem; }

.loans { border-top: 1px solid var(--line); }
.loans li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0;
            border-bottom: 1px solid var(--line); }
.loans li.late { border-inline-start: 3px solid var(--bad); padding-inline-start: .6rem; }
.history summary { cursor: pointer; color: var(--ink-2); font-size: .9rem; }
.history ul { margin-top: .4rem; display: grid; gap: .2rem; font-size: .92rem; }

/* buttons */
.btn { font: 600 .95rem var(--sans); padding: .45rem .95rem; border-radius: 4px; border: 1px solid var(--line-strong);
       background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-small { padding: .2rem .6rem; font-size: .85rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: var(--brand-ink); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { color: #fff; filter: brightness(.92); }
.btn-big { width: 100%; padding: .75rem; font-size: 1.05rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline;
        text-underline-offset: 3px; cursor: pointer; }

/* lending form */
#lend-form { display: grid; gap: 1rem; }
.chips { border: 0; padding: 0; margin: 0; display: grid; gap: .3rem; }
.chips legend { font-size: .88rem; color: var(--ink-2); margin-bottom: .35rem; padding: 0; }
.chip { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .95rem; padding: .1rem 0; }
.chip input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--brand); }
.summary { font-size: .95rem; color: var(--ink-3); min-height: 3em; padding-top: .75rem; border-top: 1px solid var(--line); }
.summary.ready { color: var(--ink); }

/* outcome of an action */
#result:not(:empty) { margin-top: 1rem; }
.outcome { padding: .75rem .9rem; display: grid; gap: .4rem; border-inline-start: 3px solid; }
.outcome ul { list-style: disc; padding-inline-start: 1.1rem; }
.outcome.ok { background: var(--ok-soft); border-color: var(--ok); }
.outcome.bad { background: var(--bad-soft); border-color: var(--bad); }
.outcome-title { font: 600 1rem/1.6 var(--serif); }
.outcome.ok .outcome-title { color: var(--ok); }
.outcome.bad .outcome-title { color: var(--bad); }
.due { font-size: 1rem; }
.override { display: grid; gap: .5rem; margin-top: .4rem; }
.loading { opacity: .55; }

/* ── pages: forms, lists ─────────────────────────────────── */
.page { max-width: 820px; margin: 0 auto; display: grid; gap: 1.25rem; }
.page-wide { max-width: 1120px; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem 1rem;
             padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.page-head h1 { font: 600 1.4rem/1.5 var(--serif); }
.page-head .help { flex-basis: 100%; }
.count { font-family: var(--sans); font-size: .8em; font-weight: 500; color: var(--ink-3); }
.count::before { content: "("; } .count::after { content: ")"; }
.form { display: grid; gap: 1.2rem; padding: 1.4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; }
.form-row { display: grid; gap: .3rem; align-content: start; }
.form-row.wide { grid-column: 1 / -1; }
.form-row label { font-weight: 600; font-size: .9rem; }
.form-row input, .form-row select, .form-row textarea { width: 100%; font: 400 1rem var(--sans); padding: .5rem .65rem;
  border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); }
.form-row textarea { resize: vertical; }
.has-error input, .has-error select { border-color: var(--bad); }
.req { color: var(--bad); }
.help { color: var(--ink-2); font-size: .85rem; margin: 0; }
.error { color: var(--bad); font-size: .88rem; margin: 0; font-weight: 600; }
.payment { padding-top: 1rem; border-top: 1px solid var(--line); display: flex !important; flex-wrap: wrap; gap: .3rem 1.5rem; }
.payment legend { flex-basis: 100%; }
.payment .help { flex-basis: 100%; }
.form-actions { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; padding-top: .25rem; }
.form-actions .btn-big { width: auto; padding-inline: 2.25rem; }

.group h2 { font: 600 1.05rem/1.6 var(--serif); padding: 0 0 .5rem; }
.group + .group { margin-top: 1rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: start; font-weight: 600; color: var(--ink-2); font-size: .82rem; padding: .55rem .9rem;
            border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table td { padding: .55rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfaf7; }
.table td .outcome { padding: .2rem .5rem; font-size: .85rem; }
.table td .outcome .btn, .table td .outcome p:not(.outcome-title) { display: none; }
.table td .outcome-title { font: 600 .9rem var(--sans); }
.nowrap { white-space: nowrap; }

/* ── extra pieces ─────────────────────────────────────────── */
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.switches { display: grid; gap: .5rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.roles { border: 0; padding: .75rem 0 0; margin: 0; display: grid; gap: .45rem; border-top: 1px solid var(--line); }
.roles legend, .payment legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: .35rem; }
.amount-field { display: inline-flex; align-items: center; gap: .4rem; }
.amount-field input, .renew input { width: 6.5rem; font: 600 1rem var(--sans); padding: .35rem .5rem; border: 1px solid var(--line-strong); border-radius: 4px; }
.unit { color: var(--ink-2); font-size: .88rem; }
.renew { align-items: center; }
.return-form { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin: 0; }
.return-date { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--ink-2); }
.return-date input { font: 500 .9rem var(--sans); padding: .25rem .4rem; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); }
.more { border-top: 1px solid var(--line); padding-top: .75rem; }
.more > summary { cursor: pointer; font-weight: 600; color: var(--brand); padding: .25rem 0; }
.more[open] > summary { margin-bottom: .9rem; }
.sub-h { font: 600 1rem var(--serif); margin: 1.2rem 0 .6rem; }
.lead-meta { color: var(--ink-2); font-size: 1.05rem; }
.filters-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters-bar .grow { flex: 1 1 16rem; }
.filters-bar input, .filters-bar select { width: 100%; font: 400 1rem var(--sans); padding: .5rem .65rem;
  border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); }
.numbers { font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pager { display: flex; justify-content: center; gap: 1.5rem; margin: 1.25rem 0; color: var(--ink-2); }
.pager a { font-weight: 600; }
.table td.actions { white-space: nowrap; text-align: end; }
.table tr.current td { background: var(--brand-soft); }
.facts-list { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.facts-list dt { color: var(--ink-2); }
.facts-list dd { margin: 0; }

/* ── medium screens ──────────────────────────────────────── */
@media (max-width: 1100px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .menu { display: block; margin-inline-start: -.4rem; }
  .desk { grid-template-columns: 1fr 1fr; }
  .panel-action { grid-column: 1 / -1; border-inline-start: 0 !important; border-top: 1px solid var(--line); }
}

/* ── phones: the app is used mostly on a phone ───────────── */
@media (max-width: 760px) {
  html { font-size: 17px; }
  main { padding: .9rem 14px 5rem; }
  .topbar { padding: 0 14px; gap: .75rem; min-height: 56px; }
  .brand-logo { height: 34px; }
  .brand-text small { display: none; }
  .menu-label { display: none; }
  .who-name { display: none; }
  .drawer { inset-block-start: 56px; }

  .today { font-size: .92rem; gap: .15rem .9rem; }
  .desk { grid-template-columns: 1fr; border-radius: 0; margin-inline: -14px; border-inline: 0; }
  .desk > .panel + .panel { border-inline-start: 0; border-top: 1px solid var(--line); }
  .panel { padding: 1rem 14px 1.2rem; }
  input[type=search], .field input { font-size: 1.1rem; padding: .75rem .8rem; }   /* >= 16px: no zoom on iPhone */
  .result { padding: .7rem .25rem; }                                               /* bigger tap targets */
  .btn { padding: .6rem 1rem; }
  .btn-small { padding: .45rem .8rem; font-size: .92rem; }
  .chip { padding: .35rem 0; font-size: 1rem; }
  .chip input { width: 1.2rem; height: 1.2rem; }
  .card-title { font-size: 1.25rem; }
  .sub { align-items: flex-start; }
  .renew { margin-inline-start: 0; flex-basis: 100%; }
  .loans li { flex-direction: column; align-items: stretch; }
  .return-form { justify-content: space-between; }
  .return-date input { font-size: 1rem; padding: .4rem .5rem; }

  .page-head h1 { font-size: 1.35rem; }
  .form { padding: 1rem 14px; margin-inline: -14px; border-radius: 0; border-inline: 0; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .form-row input, .form-row select, .form-row textarea { font-size: 1rem; padding: .65rem .7rem; }
  .form-actions .btn-big { width: 100%; }

  /* tables become stacked rows: each cell shows its column name */
  .table-wrap { margin-inline: -14px; border-radius: 0; border-inline: 0; }
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: .7rem 14px; border-bottom: 1px solid var(--line); }
  .table.stack td { border: 0; padding: .12rem 0; display: flex; gap: .6rem; align-items: baseline; }
  .table.stack td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: .82rem; min-width: 5.5rem; flex-shrink: 0; }
  .table.stack td.actions { padding-top: .45rem; text-align: start; }
  .table.stack td.actions .return-form { width: 100%; }
}

/* ── members: photos, list, form images ──────────────────── */
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-2); }
.avatar.big { width: 64px; height: 64px; }
.avatar.small { width: 28px; height: 28px; }
.avatar.empty { display: grid; place-items: center; font: 600 1.1rem var(--serif); color: var(--ink-3); }
.card-top { align-items: center; }
.card-who { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.result .avatar.small { align-self: center; }
.people { border-top: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: .8rem; padding: .65rem .25rem; border-bottom: 1px solid var(--line);
          color: inherit; text-decoration: none; }
.person:hover { background: var(--brand-soft); }
.person-main { flex: 1; min-width: 0; display: grid; }
.person-state { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; }
.badge.muted { color: var(--ink-3); }
.sub-h .optional { font: 400 .8rem var(--sans); color: var(--ink-3); }
.image-pick { display: flex; align-items: center; gap: .75rem; }
.image-pick .thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.image-input { display: grid; gap: .25rem; min-width: 0; }
.image-input input[type=file] { font: 400 .9rem var(--sans); max-width: 100%; }

/* ── after an action: next visitor, undo ─────────────────── */
.outcome-actions { margin-top: .3rem; }
.inline-undo { margin: 0; }
.inline-undo .link { font-size: .9rem; color: var(--ink-2); }

/* ── operations log ──────────────────────────────────────── */
.log { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.log li { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .7rem 0;
          border-bottom: 1px solid var(--line); }
.log-main { min-width: 0; display: grid; gap: .15rem; }
.log-summary { font-weight: 500; }
.log li.undone .log-summary { text-decoration: line-through; color: var(--ink-3); }
.log li.is-undo .log-summary { color: var(--ink-2); }
.log-diff summary { cursor: pointer; font-size: .85rem; color: var(--brand); }
.log-diff ul { margin-top: .3rem; font-size: .88rem; display: grid; gap: .15rem; }
.recent { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .5rem; }
.recent h2 { font: 600 1rem var(--serif); }
.recent ul { display: grid; gap: .3rem; font-size: .92rem; }
.recent li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .6rem; }
.recent li.undone { color: var(--ink-3); text-decoration: line-through; }
.recent form { margin: 0; display: inline; }

@media (max-width: 760px) {
  .avatar.big { width: 56px; height: 56px; }
  .person-state { flex-direction: column; align-items: flex-end; gap: .1rem; }
  .log li { flex-direction: column; gap: .4rem; }
  .image-pick { align-items: flex-start; }
}

/* buttons that are links never look like links; a proper file button */
a.btn { text-decoration: none; display: inline-block; }
input[type=file]::file-selector-button { font: 600 .9rem var(--sans); padding: .45rem .9rem; margin-inline-end: .6rem;
  border: 1px solid var(--brand); border-radius: 4px; background: var(--brand-soft); color: var(--brand); cursor: pointer; }
.image-input input[type=file] { padding: .35rem; border: 1px dashed var(--line-strong); border-radius: 4px; background: var(--surface); }

/* checkboxes and radios are never stretched like text fields (it broke the settings page in RTL) */
.form-row input[type=checkbox], .form-row input[type=radio], .table input[type=checkbox] { width: 1.15rem; height: 1.15rem;
  padding: 0; margin: 0; accent-color: var(--brand); flex-shrink: 0; }
.switches .form-row { display: block; }
.switches .chip { justify-content: flex-start; font-weight: 500; }
.table input:not([type=checkbox]), .table select { font: 400 .95rem var(--sans); padding: .35rem .5rem; width: 100%;
  min-width: 7rem; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); }
.table input[type=number] { min-width: 4rem; max-width: 5.5rem; }

/* a member's open loans: title on its own line, then the return date and button */
.loans li { flex-direction: column; align-items: stretch; gap: .4rem; }
.loans .return-form { justify-content: flex-start; }
.form-grid.three { align-items: start; }
@media (max-width: 760px) {
  .table.stack td.cell-title a { font-size: 1.05rem; }
  .table.stack td.cell-sub { color: var(--ink-2); font-size: .92rem; padding-bottom: .3rem; }
}

/* a member's special category on the desk card */
.tag { display: inline-block; font-size: .8rem; font-weight: 500; padding: .05rem .5rem; border-radius: 3px;
       background: var(--brand-soft); color: var(--brand); }
.categories { border: 0; padding: 0; margin: 0; display: grid; gap: .35rem; }
.categories legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: .3rem; }

/* ══ polish: a little warmer and livelier, same calm structure ══════════════════════════════════
   cool light background in tune with the blue, soft radii and shadows, a gold accent line. */
:root {
  --paper: #f3f5f8;
  --surface-2: #eef2f6;
  --line: #e2e7ee;
  --line-strong: #cbd3de;
  --ink: #18212b;
  --ink-2: #536070;
  --ink-3: #8592a1;
  --brand-soft: #e8f0f8;
  --gold: #f2c14e;
  --radius: 12px;
  --radius-sm: 8px;
  --lift: 0 1px 2px rgb(16 40 70 / .05), 0 8px 24px rgb(16 40 70 / .06);
  --ring: 0 0 0 4px rgb(15 76 117 / .14);
  --ease: .16s ease;
}
body { background: var(--paper); }

/* top bar with its gold line */
.topbar { box-shadow: inset 0 -3px 0 var(--gold); }
.brand-logo { filter: drop-shadow(0 1px 1px rgb(0 0 0 / .15)); }

/* side panel: rounded items */
.sidebar { background: var(--surface); padding-top: 1.25rem; }
.nav-title { letter-spacing: .02em; font-size: .72rem; padding-inline: 1.5rem; }
.nav-group a { margin: .1rem .75rem; padding: .5rem .8rem; border-radius: var(--radius-sm); border-inline-start: 0;
               transition: background var(--ease), color var(--ease); }
.nav-group a[aria-current] { background: var(--brand-soft); color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
[dir="rtl"] .nav-group a[aria-current] { box-shadow: inset -3px 0 0 var(--brand); }
.drawer .nav-group a { margin-inline: .6rem; }

/* page titles with a small gold underline */
.page-head { border-bottom: 0; padding-bottom: .4rem; }
.page-head h1 { position: relative; padding-bottom: .45rem; }
.page-head h1::after { content: ""; position: absolute; inset-inline-start: 0; bottom: 0; width: 2.2rem; height: 3px;
                       border-radius: 3px; background: var(--gold); }

/* surfaces */
.desk, .form, .table-wrap { border-radius: var(--radius); box-shadow: var(--lift); border-color: transparent; }
.panel-action { background: #f8fafc; }
.today { background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--lift);
         padding: .75rem 1.1rem; margin-bottom: 1.1rem; }
.today b { color: var(--brand); }
.today .late b { color: var(--bad); }

/* fields and buttons */
input[type=search], .field input, .form-row input, .form-row select, .form-row textarea,
.filters-bar input, .filters-bar select, .table input:not([type=checkbox]), .table select,
.return-date input, .renew input, .amount-field input, .period select, .period input {
  border-radius: var(--radius-sm); transition: border-color var(--ease), box-shadow var(--ease); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.btn { border-radius: var(--radius-sm); transition: background var(--ease), border-color var(--ease), color var(--ease),
       transform var(--ease), box-shadow var(--ease); }
.btn-primary { box-shadow: 0 1px 2px rgb(15 76 117 / .25); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 14px rgb(15 76 117 / .22); }
.btn:active:not(:disabled) { transform: translateY(0); }

/* statuses: soft tinted pills (the word is always written, colour is never alone) */
.badge { padding: .12rem .6rem .12rem .55rem; border-radius: 999px; font-weight: 500; font-size: .8rem; }
.badge::before { border-radius: 50%; width: .42rem; height: .42rem; }
.badge.ok { background: var(--ok-soft); }
.badge.warn { background: var(--warn-soft); }
.badge.bad { background: var(--bad-soft); }
.badge.muted { background: var(--surface-2); }
.tag { border-radius: 999px; padding: .1rem .65rem; }

/* messages and verdicts */
.verdict, .outcome, .flash { border-radius: var(--radius-sm); border-inline-start-width: 4px; }

/* lists and tables */
.table th { background: #f7f9fb; }
.table-wrap { overflow: hidden; }
.table tbody tr { transition: background var(--ease); }
.table tbody tr:hover td { background: var(--brand-soft); }
.result, .person { border-radius: var(--radius-sm); transition: background var(--ease); }
.results, .people { border-top: 0; }
.result, .person { border-bottom-color: transparent; margin-bottom: 2px; }
.result:hover, .person:hover { background: var(--brand-soft); }
.avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.card-title { letter-spacing: -.005em; }
.chip input, .form-row input[type=checkbox], .form-row input[type=radio] { accent-color: var(--brand); }
.log li, .loans li { border-bottom-color: var(--line); }

@media (max-width: 760px) {
  .desk, .form, .table-wrap { border-radius: 0; box-shadow: none; }
  .today { border-radius: var(--radius-sm); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .btn:hover { transform: none !important; } }

/* review, lists, settings links */
.review-kinds { display: flex; flex-wrap: wrap; gap: .4rem; }
.kind { font-size: .85rem; padding: .25rem .7rem; border-radius: 999px; background: var(--surface); box-shadow: var(--lift);
        color: var(--ink-2); text-decoration: none; }
.kind b { color: var(--ink); margin-inline-start: .3rem; }
.kind.error b { color: var(--bad); } .kind.warning b { color: var(--warn); }
.kind.on { background: var(--brand); color: #fff; } .kind.on b { color: #fff; }
.issues li { align-items: flex-start; justify-content: flex-start; }
.pick input { width: 1.15rem; height: 1.15rem; margin-top: .35rem; accent-color: var(--brand); }
.sticky-actions { position: sticky; bottom: 0; background: var(--paper); padding: .75rem 0; }
.merge { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: 1rem; padding: .9rem 1.1rem;
         background: var(--surface); border-radius: var(--radius); box-shadow: var(--lift); }
.merge select { font: 400 .95rem var(--sans); padding: .35rem .5rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.see-also { font-size: .92rem; color: var(--ink-2); }
.tech-link { margin-top: 2rem; padding-top: 1rem; border-top: 1px dashed var(--line-strong); font-size: .85rem; color: var(--ink-3); }

.source { unicode-bidi: plaintext; direction: rtl; }

/* ── overdue list: one card per member ───────────────────── */
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.tabs a { padding: .35rem .85rem; border-radius: 999px; background: var(--surface); box-shadow: var(--lift); color: var(--ink-2);
          text-decoration: none; font-size: .92rem; }
.tabs a span { color: var(--ink-3); margin-inline-start: .25rem; font-size: .85em; }
.tabs a[aria-current] { background: var(--brand); color: #fff; } .tabs a[aria-current] span { color: rgb(255 255 255 / .8); }
.overdue { display: grid; gap: .75rem; }
.late-person { background: var(--surface); border-radius: var(--radius); box-shadow: var(--lift); padding: .9rem 1.1rem;
               display: grid; gap: .6rem; }
.late-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.late-who { display: grid; }
.late-who a { color: inherit; text-decoration: none; font-size: 1.05rem; }
.late-who a:hover b { color: var(--brand); }
.late-books { display: grid; gap: .1rem; border-top: 1px solid var(--line); }
.late-books > li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem 1rem;
                   padding: .55rem 0; border-bottom: 1px solid var(--line); }
.late-books > li:last-child { border-bottom: 0; }
.late-book { display: block; min-width: 0; flex: 1 1 16rem; }
.late-book b { margin-inline-end: .35rem; }
.late-book .meta { display: block; }
.late-actions { display: flex; align-items: center; gap: .6rem; }
.late-actions form { margin: 0; }
.other-date > summary { cursor: pointer; font-size: .85rem; color: var(--ink-2); list-style: none; }
.other-date > summary::-webkit-details-marker { display: none; }
.other-date[open] { flex-basis: 100%; }
.other-date[open] > summary { margin-bottom: .4rem; }
.late-books .outcome { flex-basis: 100%; padding: .4rem .7rem; }
.late-books .outcome .btn, .late-books .outcome .inline-undo { display: none; }
.contact { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn.whatsapp { border-color: #1fa855; color: #137a3c; }
.btn.whatsapp:hover { background: #e8f7ee; color: #0f6a33; border-color: #1fa855; }
@media (max-width: 760px) {
  .late-person { border-radius: var(--radius-sm); padding: .85rem; }
  .late-actions { width: 100%; justify-content: space-between; }
  .contact .btn { flex: 1; text-align: center; padding-block: .55rem; }
}

/* book numbers: a small grey tag, so the title stays the thing you read */
.cn { display: inline-block; font-size: .74rem; font-weight: 500; line-height: 1.5; color: var(--ink-3);
      background: var(--surface-2); border-radius: 4px; padding: 0 .35rem; font-variant-numeric: tabular-nums;
      vertical-align: .1em; white-space: nowrap; }
.title { font-weight: 500; }
.late-book .title { font-size: 1rem; }
.col-cn { width: 1%; white-space: nowrap; }
.outcome .cn { background: rgb(255 255 255 / .6); }
.badge { white-space: nowrap; }
.col-code { width: 1%; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .9rem; }

/* bulk settlement of old overdue loans */
.late-books > li { align-items: flex-start; }
.late-books .pick { padding-top: .2rem; }
.settle-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
              background: var(--surface); border-radius: var(--radius); box-shadow: 0 -2px 18px rgb(16 40 70 / .12);
              padding: .8rem 1.1rem; margin-top: .5rem; }
.settle-bar .help { flex-basis: 100%; margin: 0; }
.settle-bar select { font: 500 .95rem var(--sans); padding: .4rem .6rem; border: 1px solid var(--line-strong);
                     border-radius: var(--radius-sm); background: var(--surface); }

/* staff sign-in */
.login-page { min-height: 100vh; background: radial-gradient(120% 90% at 80% -10%, #1b6aa0 0%, var(--brand) 40%, #0b3b5c 100%); }
.login { max-width: 400px; margin: 0 auto; padding: 12vh 16px 2rem; display: grid; gap: 1.25rem; }
.login-brand { display: flex; align-items: center; gap: .9rem; color: #fff; }
.login-brand img { height: 60px; width: auto; }
.login-brand p { display: grid; line-height: 1.35; }
.login-brand b { font-size: 1.2rem; font-weight: 600; }
.login-brand span { opacity: .8; font-size: .92rem; }
.login-card { background: var(--surface); border-radius: var(--radius); box-shadow: 0 10px 40px rgb(0 0 0 / .25);
              padding: 1.4rem; display: grid; gap: 1rem; border-top: 3px solid var(--gold); }
.login-card input { width: 100%; font: 500 1.05rem var(--sans); padding: .7rem .8rem; border: 1px solid var(--line-strong);
                    border-radius: var(--radius-sm); }
.login-foot { text-align: center; } .login-foot a { color: rgb(255 255 255 / .85); font-size: .9rem; }

/* guarantees: a ruled list, one line per guarantee held */
.g-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.g-list > li { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .4rem 1rem; padding: .75rem 1rem;
               border-bottom: 1px solid var(--line); }
.g-list > li:last-child { border-bottom: 0; }
.g-list > li:target { background: var(--brand-soft); }
.g-list .pick { padding-top: .1rem; }
.g-main { flex: 1 1 18rem; min-width: 0; display: grid; gap: .2rem; }
.g-what { margin: 0; }
.g-what a { color: inherit; }
.g-amount { font-weight: 600; color: var(--brand); white-space: nowrap; }
.meta-inline { color: var(--ink-2); font-size: .85rem; margin-inline-start: .35rem; white-space: nowrap; }
.meta-line { margin: 0; color: var(--ink-2); font-size: .88rem; }
.g-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.g-actions form { margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.g-actions input { font: 400 .95rem var(--sans); padding: .3rem .5rem; border: 1px solid var(--line-strong);
                                         border-radius: var(--radius-sm); }
.g-held { margin: 0; display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; align-items: baseline; color: var(--ink-2); }
.g-held span { color: var(--ink); white-space: nowrap; }
.g-held b { font-size: 1.25rem; font-variant-numeric: tabular-nums; margin-inline-end: .2rem; }
.settle-bar .grow { flex: 1 1 12rem; }
.settle-bar .grow input { width: 100%; font: 400 .95rem var(--sans); padding: .4rem .6rem; border: 1px solid var(--line-strong);
                          border-radius: var(--radius-sm); }
.guarantee-stays { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--ink-2); }
.guarantee-stays input { accent-color: var(--brand); }
@media (max-width: 760px) {
  .g-list { border-radius: 0; border-inline: 0; }
  .g-list > li { padding: .8rem .2rem; }
  .g-actions { width: 100%; }
  .g-actions > form .btn { padding-block: .5rem; }
  .g-actions details[open] { flex-basis: 100%; }
}

/* «مدّد الإعارة»: a quiet link under the return form */
.renew-form { margin: .35rem 0 0; }
