/* ==========================================================
   Staff portal (shares tokens with styles.css)
   ========================================================== */
.admin-body {
  --bg: #f4f5fa; --surface: #fff; --soft: #f7f8fc; --ring: rgba(35,42,124,.14);
  --side-w: 264px; --radius-lg: 18px; --radius-md: 12px;
  --shadow-1: 0 1px 2px rgba(22,26,82,.06), 0 8px 24px -16px rgba(22,26,82,.25);
  --amber: #b26a00; --amber-100: #fff3dc; --blue: #2f5fd0; --blue-100: #e8eefc; --red: #c53030; --red-100: #fdecec;
  background: var(--bg); min-height: 100vh; color: var(--ink); font-size: 15px;
}
.admin-body .ico { flex-shrink: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); margin: 0; }
.admin-body .btn:hover { transform: none; }
.btn--sm { padding: .5em 1.05em; font-size: .87rem; }
.btn--icon { gap: .45em; }
.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { background: #9b1c1c; }
.admin-body .btn { border-radius: 12px; padding: .62em 1.15em; font-size: .95rem; }
.admin-body .btn--lg { padding: .85em 1.4em; font-size: 1rem; }
.admin-body .btn--outline { border: 1.5px solid var(--line); background: #fff; color: var(--navy); }
.admin-body .btn--outline:hover { border-color: var(--navy); background: var(--navy-100); color: var(--navy); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(180deg, var(--navy-900), var(--navy)); color: #fff; padding: 18px 14px; z-index: 40;
}
.side__brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.side__logo { flex-shrink: 0; width: 48px; height: 48px; border-radius: 14px; background: #fff; display: grid; place-items: center; padding: 5px; }
.side__logo img { width: 100%; height: auto; }
.side__brand b { display: block; font-size: 1.05rem; }
.side__brand span { display: block; font-size: .8rem; opacity: .65; }
.side__close { display: none; margin-inline-start: auto; background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; }
.side__nav { display: grid; gap: 4px; padding-top: 8px; }
.side__label { margin: 14px 10px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; opacity: .5; }
.side__nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: rgba(255,255,255,.82);
  text-decoration: none; font-weight: 700; transition: background .15s, color .15s;
}
.side__nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side__nav a.is-active { background: #fff; color: var(--navy); box-shadow: 0 6px 18px -8px rgba(0,0,0,.4); }
.side__nav a.is-active .ico { color: var(--green); }
.side__user {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,.08);
}
.side__user form { margin: 0 auto 0 0; }
html[dir="rtl"] .side__user form { margin: 0; margin-inline-start: auto; }
.side__who { min-width: 0; }
.side__who b { display: block; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__who span { display: block; font-size: .78rem; opacity: .7; }
.side-scrim { display: none; }

.avatar {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green); color: #fff; font-weight: 800; font-size: 1rem; line-height: 1;
}
.avatar--sm { width: 34px; height: 34px; font-size: .9rem; }
.avatar--lg { width: 72px; height: 72px; font-size: 1.8rem; }
.avatar--m { background: var(--navy-100); color: var(--navy); }
.avatar--f { background: #fde9f1; color: #a3245a; }

.shell__main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.admin-main { padding: 28px clamp(16px, 3vw, 36px) 56px; width: 100%; max-width: 1440px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--navy); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--navy); background: var(--navy-100); }
.icon-btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; }
.icon-btn.is-off { opacity: .28; cursor: default; }
.icon-btn.is-off:hover { border-color: var(--line); background: #fff; }
.icon-btn--sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn--ghost { background: transparent; border-color: rgba(255,255,255,.18); color: #fff; }
.icon-btn--ghost:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.35); }
.icon-btn--green { color: var(--green-700); }
.icon-btn--green:hover { border-color: var(--green); background: var(--green-100); }
.icon-btn--navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.icon-btn--navy:hover { background: var(--navy-900); border-color: var(--navy-900); }
.icon-btn--danger { color: var(--red); }
.icon-btn--danger:hover { border-color: var(--red); background: var(--red-100); }
.link-btn { background: none; border: 0; padding: 0; color: var(--navy); font: 700 .88rem var(--font-body); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- tooltip (see admin.js) ---------- */
.tip {
  position: fixed; z-index: 100; max-width: 240px; padding: 6px 10px; border-radius: 8px; pointer-events: none;
  background: var(--navy-900); color: #fff; font: 700 .8rem/1.35 var(--font-body); white-space: nowrap;
  box-shadow: 0 8px 20px -8px rgba(22,26,82,.6); opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s;
}
.tip.is-in { opacity: 1; transform: none; }
.tip::after {
  content: ""; position: absolute; top: 100%; left: var(--arrow, 50%); margin-left: -5px;
  border: 5px solid transparent; border-top-color: var(--navy-900);
}
.tip.is-below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--navy-900); }
.tip.is-below { transform: translateY(-3px); }
.tip.is-below.is-in { transform: none; }
@media (hover: none) { .tip { display: none; } }

/* ---------- page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); margin: 0 0 4px; color: var(--navy); }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { margin: 0 0 6px; font-size: .88rem; color: var(--muted); }
.crumbs a { color: var(--green-700); font-weight: 700; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-1); margin: 0; min-width: 0; }
.panel--flush { padding: 0; overflow: hidden; }
.panel__title { display: flex; align-items: center; gap: 10px; float: inline-start; width: 100%; padding: 0; margin: 0 0 16px; font-weight: 800; color: var(--navy); font-size: 1.05rem; }
.panel__title + * { clear: both; }
.panel__title .ico { color: var(--green); }
.step { width: 28px; height: 28px; border-radius: 9px; background: var(--navy-100); color: var(--navy); display: inline-grid; place-items: center; font-size: .9rem; }

/* ---------- toasts ---------- */
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 18px; border-radius: var(--radius-md);
  background: var(--green-100); color: var(--green-700); font-weight: 700; border: 1px solid #bfe3cd;
  animation: toastIn .3s ease; transition: opacity .3s, transform .3s;
}
.toast--error { background: var(--red-100); color: #9b1c1c; border-color: #f5c2c2; }
.toast--static { align-items: flex-start; }
.toast.is-hiding { opacity: 0; transform: translateY(-6px); }
/* success/error messages float above the page so nothing jumps when they disappear */
.toast[data-toast] {
  position: fixed; z-index: 90; top: 18px; inset-inline-start: 50%; transform: translateX(50%); margin: 0;
  width: min(92vw, 460px); box-shadow: 0 14px 34px -14px rgba(22,26,82,.45); animation: toastFloatIn .3s ease;
}
@keyframes toastFloatIn { from { opacity: 0; transform: translate(50%, -8px); } }
html[dir="ltr"] .toast[data-toast] { transform: translateX(-50%); }
.toast[data-toast].is-hiding { opacity: 0; transform: translate(50%, -8px); }
@media (min-width: 901px) { .toast[data-toast] { inset-inline-start: calc(50% + var(--side-w) / 2); } } /* centre of the content area, beside the sidebar */
@media (max-width: 900px) { .toast[data-toast] { top: 70px; } }
.toast__close { margin-inline-start: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; padding: 4px; display: grid; }
.toast__close:hover { opacity: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.kpi__icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--navy-100); color: var(--navy); flex-shrink: 0; }
.kpi--amber .kpi__icon { background: var(--amber-100); color: var(--amber); }
.kpi--green .kpi__icon { background: var(--green-100); color: var(--green-700); }
.kpi--blue .kpi__icon { background: var(--blue-100); color: var(--blue); }
.kpi b { display: block; font-size: 1.45rem; line-height: 1.1; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi span:not(.kpi__icon) { font-size: .85rem; color: var(--muted); }

.kpi--link { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.kpi--link:hover { border-color: var(--navy); transform: translateY(-2px); }
.trend { font-style: normal; font-weight: 800; font-size: .78rem; margin-inline-start: 4px; }
.trend--up { color: var(--green-700); }
.trend--down { color: var(--red); }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.dash__wide { grid-column: 1 / -1; }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.panel__head h2 { margin: 0; font-size: 1.05rem; color: var(--navy); }
.panel__head--pad { padding: 18px 20px 0; margin-bottom: 8px; }
.columns { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; align-items: end; height: 220px; }
.columns__item { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 6px; height: 100%; }
.columns__bar {
  align-self: end; width: min(100%, 38px); height: max(var(--h), 3px); border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--green), var(--green-700)); transition: filter .15s;
}
.columns__item:last-child .columns__bar { background: linear-gradient(180deg, var(--navy), var(--navy-900)); }
.columns__item:hover .columns__bar { filter: brightness(1.12); }
.columns__value { font-size: .8rem; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.columns__label { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.stack { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: #eef0f5; gap: 2px; margin-bottom: 16px; }
.stack .stack__seg { width: var(--w); background: currentColor; min-width: 4px; padding: 0; border-radius: 0; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.legend li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed #eceef4; }
.legend a { text-decoration: none; }
.legend b { color: var(--navy); font-variant-numeric: tabular-nums; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 48px; align-items: center; gap: 10px; }
.hbars__label { font-weight: 700; font-size: .88rem; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.hbars__label:hover { color: var(--green-700); text-decoration: underline; }
.hbars__track { height: 10px; border-radius: 999px; background: #eef0f5; overflow: hidden; }
.hbars__fill { display: block; height: 100%; width: max(var(--w), 2%); border-radius: inherit; background: var(--navy); }
.hbars--green .hbars__fill { background: var(--green); }
.hbars--blue .hbars__fill { background: var(--blue); }
.hbars b { text-align: end; color: var(--navy); font-variant-numeric: tabular-nums; font-size: .9rem; }
.split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.split__item { padding: 12px; border-radius: 12px; background: var(--soft); display: grid; gap: 2px; text-align: center; }
.split__item b { font-size: 1.25rem; color: var(--navy); }
.split__item span { font-size: .78rem; color: var(--muted); }
.split__item--f { background: #fde9f1; } .split__item--f b { color: #a3245a; }
.split__item--m { background: var(--navy-100); }
.mini-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.mini-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; }
.mini-list li:hover { background: var(--soft); }
.mini-list li > div { flex: 1; min-width: 0; display: grid; }
.mini-list li > div a { color: var(--navy); font-weight: 800; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list li > div a:hover { text-decoration: underline; }
.mini-list li > div span { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mini-empty { padding: 24px 20px; text-align: center; }

/* ---------- filters ---------- */
.filters { margin-bottom: 18px; display: grid; gap: 12px; padding: 14px; }
.filters__main { display: flex; gap: 10px; flex-wrap: wrap; }
.search-field {
  flex: 2 1 260px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1.5px solid var(--line);
  border-radius: 12px; background: var(--soft); color: var(--muted); transition: border-color .15s, box-shadow .15s, background .15s;
}
.search-field--id { flex: 1 1 210px; }
.search-field:focus-within { border-color: var(--navy); background: #fff; box-shadow: 0 0 0 4px var(--ring); }
.search-field input { flex: 1; min-width: 0; border: 0; background: none; padding: .78em 0; font: 500 .97rem var(--font-body); color: var(--ink); outline: none; }
.filters__more { border-top: 1px dashed var(--line); padding-top: 10px; }
.filters__more summary {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-weight: 700; color: var(--navy);
  padding: 6px 10px; border-radius: 10px; font-size: .92rem; user-select: none;
}
.filters__more summary::-webkit-details-marker { display: none; }
.filters__more summary:hover { background: var(--soft); }
.filters__more summary .ico:last-child { transition: transform .2s; }
.filters__more[open] summary .ico:last-child { transform: rotate(180deg); }
.filters__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 14px; padding-top: 12px; }
.pill { background: var(--green); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 8px; }
.filters__clear { justify-self: start; display: inline-flex; align-items: center; gap: 6px; color: var(--red); font-weight: 700; font-size: .88rem; text-decoration: none; }
.filters__clear:hover { text-decoration: underline; }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 56px 20px; background: #fff; border: 1px dashed #cdd1e0; border-radius: var(--radius-lg); }
.empty__icon { width: 64px; height: 64px; border-radius: 20px; display: inline-grid; place-items: center; background: var(--navy-100); color: var(--navy); margin-bottom: 12px; }
.empty--warn .empty__icon { background: var(--amber-100); color: var(--amber); }
.empty h2 { font-size: 1.2rem; margin: 0 0 6px; color: var(--navy); }
.empty p { margin: 0; color: var(--muted); }

/* ---------- data table ---------- */
.table-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.table-bar p { margin: 0; color: var(--muted); font-size: .92rem; }
.table-bar b { color: var(--navy); font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline: 3px solid var(--ring); }
.dtable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.dtable th {
  position: sticky; top: 0; z-index: 1; background: var(--soft); color: var(--muted); font-weight: 700; font-size: .8rem;
  text-align: start; padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.dtable td { padding: 10px 10px; border-bottom: 1px solid #eceef4; vertical-align: middle; white-space: nowrap; text-align: start; }
.dtable__row > tr:first-child { cursor: pointer; transition: background .12s; }
.dtable__row:hover > tr:first-child, .dtable__row.is-open > tr:first-child { background: #f8f9fd; }
.dtable__row.is-open > tr:first-child td { border-bottom-color: transparent; }
.dtable__toggle { width: 44px; padding-inline-end: 0 !important; }
.dtable__toggle .ico { transition: transform .2s; }
.dtable__row.is-open .dtable__toggle .ico { transform: rotate(180deg); }
.dtable__hash { display: none; }
.dtable__serial { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }
.dtable__clip { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.dtable__phone, .dtable__date { font-variant-numeric: tabular-nums; color: #3a3d52; }
html[dir="rtl"] .dtable__phone, html[dir="rtl"] .dtable__date, html[dir="rtl"] .dtable__serial { text-align: right; }
.dtable__actions { text-align: end !important; }
.actions { display: inline-flex; gap: 6px; align-items: center; }
.actions form { margin: 0; display: contents; }
.person { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.person > div { display: grid; min-width: 0; }
.person__name { color: var(--navy); font-weight: 800; text-decoration: none; white-space: normal; line-height: 1.35; }
.person__name:hover { color: var(--green-700); text-decoration: underline; }
.person__id { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: end; }
html[dir="rtl"] .person__id { text-align: right; }
.dtable__detail td { background: #f8f9fd; padding: 4px 18px 18px; white-space: normal; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 0; }
.facts > div { background: #fff; border: 1px solid #e6e8f0; border-radius: 12px; padding: 10px 12px; }
.facts__wide { grid-column: span 2; }
.facts__full { grid-column: 1 / -1; }
.facts dt { font-size: .76rem; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.facts dd { margin: 0; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.facts dd a { color: var(--green-700); }

.rank { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: .78rem; background: #eef0f5; color: #4b5068; white-space: nowrap; }
.rank::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.rank--n1 { background: var(--amber-100); color: var(--amber); }
.rank--1, .rank--2 { background: var(--red-100); color: #9b1c1c; }
.rank--3 { background: var(--blue-100); color: var(--blue); }
.rank--4, .rank--5 { background: var(--green-100); color: var(--green-700); }
.rank--6 { background: #e0f5f3; color: #0f766e; }
.rank--7 { background: #e5e7eb; color: #374151; }
.rank--8 { background: #ede9fe; color: #5b21b6; }

/* ---------- pager ---------- */
.pager-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.pager a, .pager__gap {
  min-width: 36px; height: 36px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 10px;
  color: var(--navy); text-decoration: none; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pager a { border: 1px solid transparent; }
.pager a:hover { background: var(--navy-100); }
.pager a.is-active { background: var(--navy); color: #fff; }
.pager a.is-disabled { opacity: .35; pointer-events: none; }
.pager__edge { border-color: var(--line) !important; }
.pager__gap { color: var(--muted); min-width: 20px; }
.page-size, .page-jump { margin: 0; }
.page-size label, .page-jump label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; font-weight: 700; }
.page-size select, .page-jump input {
  border: 1.5px solid var(--line); border-radius: 10px; padding: .4em .6em; font: 700 .9rem var(--font-body); color: var(--navy); background-color: #fff;
}
.page-jump input { width: 72px; text-align: center; }

/* ---------- forms ---------- */
.admin-body .field { display: grid; gap: 6px; font-weight: 700; color: var(--navy); font-size: .9rem; align-content: start; }
.admin-body .field input, .admin-body .field select, .admin-body .field textarea {
  width: 100%; padding: .7em .9em; border: 1.5px solid var(--line); border-radius: 12px; background-color: var(--soft);
  font: 500 .95rem var(--font-body); color: var(--ink); transition: border-color .15s, box-shadow .15s, background .15s;
}
.admin-body .field textarea { resize: vertical; min-height: 96px; }
.admin-body .field select { padding-inline-end: 2.4em; min-height: 46px; }
.admin-body .field input { min-height: 46px; }
.admin-body .field input:focus, .admin-body .field select:focus, .admin-body .field textarea:focus {
  outline: none; border-color: var(--navy); background-color: #fff; box-shadow: 0 0 0 4px var(--ring);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid > *, .filters__grid > *, .admin-body .field { min-width: 0; }
.form-grid--one { grid-template-columns: 1fr; }
.form-grid__wide { grid-column: 1 / -1; }

/* ---------- styled dropdowns (see admin.js) ---------- */
.dd { position: relative; min-width: 0; }
.dd__native { position: absolute !important; inset: auto 0 0 0; width: 100% !important; height: 1px !important; min-height: 0 !important; opacity: 0; pointer-events: none; padding: 0 !important; border: 0 !important; }
.dd__btn {
  width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: .6em .9em; border: 1.5px solid var(--line); border-radius: 12px; background: var(--soft); cursor: pointer;
  font: 600 .95rem var(--font-body); color: var(--ink); text-align: start; transition: border-color .15s, box-shadow .15s, background .15s;
}
.dd__btn:hover { border-color: #c3c7da; background: #fff; }
.dd__btn:focus-visible, .dd.is-open .dd__btn { outline: none; border-color: var(--navy); background: #fff; box-shadow: 0 0 0 4px var(--ring); }
.dd__value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd.is-empty .dd__value { color: var(--muted); font-weight: 500; }
.dd__chev { color: var(--navy); flex-shrink: 0; transition: transform .2s; }
.dd.is-open .dd__chev { transform: rotate(180deg); }
.dd.is-invalid .dd__btn, .field.is-invalid .dd__btn { border-color: #d64545; background: #fff7f7; }
.dd__pop {
  position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px; background: #fff;
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 40px -16px rgba(22,26,82,.35); padding: 6px;
  animation: ddIn .14s ease;
}
.dd.is-up .dd__pop { top: auto; bottom: calc(100% + 6px); }
@keyframes ddIn { from { opacity: 0; transform: translateY(-4px); } }
.dd__search {
  width: 100%; margin-bottom: 6px; padding: .55em .8em; border: 1.5px solid var(--line); border-radius: 10px;
  font: 500 .9rem var(--font-body); background: var(--soft); outline: none;
}
.dd__search:focus { border-color: var(--navy); background: #fff; }
.dd__list { list-style: none; margin: 0; padding: 0; max-height: 264px; overflow-y: auto; outline: none; overscroll-behavior: contain; }
.dd__list li {
  position: relative; padding: .55em .8em; padding-inline-start: 2.1em; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: .93rem; color: var(--ink); line-height: 1.45;
}
.dd__list li.is-placeholder { color: var(--muted); }
.dd__list li.is-active { background: var(--navy-100); color: var(--navy); }
.dd__list li[aria-selected="true"] { color: var(--navy); font-weight: 800; }
.dd__list li[aria-selected="true"]::before {
  content: ""; position: absolute; inset-inline-start: .8em; top: 50%; width: 10px; height: 6px; margin-top: -5px;
  border: solid var(--green); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg);
}

/* ---------- edit ---------- */
.edit { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.edit__main { display: grid; gap: 18px; min-width: 0; }
.edit__side { grid-column: 2; grid-row: 1; display: grid; gap: 18px; position: sticky; top: 20px; }
.summary { text-align: center; display: grid; justify-items: center; gap: 8px; }
.summary h2 { margin: 4px 0 0; font-size: 1.1rem; color: var(--navy); line-height: 1.4; }
.summary__facts { width: 100%; margin: 8px 0 0; display: grid; gap: 0; text-align: start; }
.summary__facts div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid #eceef4; }
.summary__facts dt { color: var(--muted); font-size: .86rem; }
.summary__facts dd { margin: 0; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.attach { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1.5px dashed #cdd1e0; border-radius: 14px; background: var(--soft); flex-wrap: wrap; }
.attach__icon { width: 46px; height: 46px; border-radius: 12px; background: var(--navy); color: #fff; display: grid; place-items: center; }
.attach__info { display: grid; gap: 2px; flex: 1; min-width: 160px; }
.attach__info b { color: var(--navy); }
.attach__info a { color: var(--green-700); font-weight: 700; }
.attach__pick { cursor: pointer; position: relative; }
.attach__chosen { margin-top: 10px; font-weight: 700; color: var(--green-700); }
.savebar {
  grid-column: 1 / -1; position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 18px; margin: 0 calc(-1 * clamp(16px, 3vw, 36px)) -56px; background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}

/* ---------- add applicant (public form inside the portal) ---------- */
.portal-form .reg-form { max-width: none; gap: 18px; }
.portal-form .reg-card { border-radius: var(--radius-lg); padding: 22px 24px 24px; box-shadow: var(--shadow-1); }
.portal-form .reg-card legend { font-size: 1.08rem; margin-bottom: 16px; }
.portal-form .field input, .portal-form .field select { background-color: var(--soft); }
/* keep the public form's "label *" on one line, field underneath */
.portal-form .field { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 4px; }
.portal-form .field > input, .portal-form .field > .dd, .portal-form .field > .seg { flex: 1 1 100%; }
.portal-form .reg-actions {
  position: sticky; bottom: 0; z-index: 5; padding: 14px 18px; margin: 0 calc(-1 * clamp(16px, 3vw, 36px)) -56px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.portal-form .reg-submit { padding: .75em 1.8em; font-size: 1rem; border-radius: 12px; }
.portal-form .reg-done { margin: 20px auto; box-shadow: var(--shadow-1); }

/* ---------- confirm dialog ---------- */
.confirm { border: 0; padding: 0; border-radius: 20px; width: min(92vw, 440px); box-shadow: 0 30px 80px -20px rgba(22,26,82,.45); color: var(--ink); }
.confirm::backdrop { background: rgba(22,26,82,.45); backdrop-filter: blur(3px); }
.confirm[open] { animation: dlgIn .2s ease; }
.confirm__box { padding: 26px 24px 20px; text-align: center; margin: 0; }
.confirm__icon { width: 56px; height: 56px; border-radius: 18px; display: inline-grid; place-items: center; background: var(--green-100); color: var(--green-700); margin-bottom: 12px; }
.confirm--danger .confirm__icon { background: var(--red-100); color: var(--red); }
.confirm h2 { font-size: 1.2rem; margin: 0 0 8px; color: var(--navy); }
.confirm p { margin: 0 0 22px; color: var(--muted); line-height: 1.7; }
.confirm__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confirm__actions .btn { width: 100%; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- attachment viewer ---------- */
.viewer {
  border: 0; padding: 0; width: min(96vw, 1100px); height: min(92vh, 900px); border-radius: 18px; overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(22,26,82,.5); color: var(--ink);
}
.viewer[open] { display: flex; flex-direction: column; animation: dlgIn .2s ease; }
.viewer::backdrop { background: rgba(22,26,82,.55); backdrop-filter: blur(3px); }
.viewer__bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fff; flex-wrap: wrap; }
.viewer__icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--navy-100); color: var(--navy); }
.viewer__title { flex: 1; min-width: 140px; display: grid; }
.viewer__title b { color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__title span { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__body { flex: 1; min-height: 0; background: #e9ebf2; display: grid; place-items: center; overflow: auto; }
.viewer__body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
/* a column, not a grid: grid rows let the page placeholders (overflow: hidden) shrink to nothing */
.viewer__pages { align-self: stretch; justify-self: stretch; overflow: auto; -webkit-overflow-scrolling: touch; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.viewer__slot { flex: none; background: #fff; box-shadow: 0 2px 10px rgba(22,26,82,.15); border-radius: 4px; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.viewer__page { direction: ltr; display: block; background: #fff; box-shadow: 0 2px 10px rgba(22,26,82,.15); border-radius: 4px; height: auto; }
.viewer__body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer__body video { max-width: 100%; max-height: 100%; background: #000; }
.viewer__msg { text-align: center; color: var(--muted); display: grid; gap: 14px; justify-items: center; padding: 30px; margin: 0; }
.viewer__msg p { margin: 0; font-weight: 700; }
@media (max-width: 640px) {
  .viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; }
  .viewer__bar .btn span { display: none; }
  /* one compact row: title shrinks, the three buttons stay next to it */
  .viewer__bar { flex-wrap: nowrap; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .viewer__title { min-width: 0; }
  .viewer__icon { display: none; }
  .viewer__bar .btn, .viewer__bar .icon-btn { flex: none; width: 44px; height: 44px; padding: 0; justify-content: center; }
}

/* ---------- quick review ---------- */
.icon-btn--amber { color: var(--amber); }
.icon-btn--amber:hover { border-color: var(--amber); background: var(--amber-100); }
.review { width: min(94vw, 520px); }
.review__box { text-align: start; display: grid; gap: 16px; }
.review__head { display: flex; align-items: center; gap: 14px; }
.review__head .confirm__icon { margin: 0; background: var(--amber-100); color: var(--amber); flex-shrink: 0; }
.review__head h2 { margin: 0; }
.review__who { margin: 2px 0 0 !important; color: var(--muted); }
.review__who b { color: var(--navy); }
.review__ranks { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.review__ranks legend { font-weight: 700; color: var(--navy); font-size: .9rem; margin-bottom: 8px; padding: 0; }
.rank-pick { cursor: pointer; }
.rank-pick input { position: absolute; opacity: 0; pointer-events: none; }
.rank-pick .rank { padding: 7px 12px; font-size: .85rem; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.rank-pick:hover .rank { transform: translateY(-1px); }
.rank-pick input:checked + .rank { border-color: currentColor; box-shadow: 0 4px 12px -6px currentColor; }
.rank-pick input:focus-visible + .rank { outline: 3px solid var(--ring); outline-offset: 2px; }
.review .confirm__actions { margin-top: 4px; }

/* ---------- login ---------- */
.admin-bare { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login {
  width: min(100%, 920px); display: grid; grid-template-columns: 1fr 1fr; background: #fff; border-radius: 26px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: 0 30px 70px -36px rgba(22,26,82,.45);
}
.login__art {
  position: relative; display: grid; align-content: center; justify-items: start; gap: 10px; padding: 48px 40px; color: #fff;
  background: radial-gradient(circle at 20% 110%, rgba(0,154,76,.55), transparent 55%), linear-gradient(160deg, var(--navy), var(--navy-900));
}
.login__art img { width: 96px; height: auto; background: #fff; border-radius: 22px; padding: 8px; margin-bottom: 10px; }
.login__art h2 { color: #fff; font-size: 1.5rem; margin: 0; line-height: 1.4; }
.login__art p { margin: 0; opacity: .8; }
.login__form { padding: 44px 40px; display: grid; align-content: center; gap: 4px; }
.login__logo { display: none; }
.login__form h1 { font-size: 1.6rem; margin: 0; color: var(--navy); }
.login__form .toast { margin: 14px 0 0; }
.login__fields { display: grid; gap: 14px; margin-top: 20px; }
.login__submit { width: 100%; margin-top: 4px; }
.login__back { margin-top: 18px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 700; text-decoration: none; font-size: .9rem; justify-self: start; }
.login__back:hover { color: var(--navy); }
html[dir="rtl"] .login__back .ico { transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .dash { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edit { grid-template-columns: 1fr; }
  .edit__side { grid-column: auto; grid-row: auto; position: static; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(84vw, 300px); transform: translateX(100%);
    transition: transform .25s ease, visibility 0s linear .25s; box-shadow: none; visibility: hidden;
  }
  .side-open .side { box-shadow: 0 0 40px rgba(0,0,0,.3); visibility: visible; transition: transform .25s ease; }
  html[dir="ltr"] .side { transform: translateX(-100%); }
  .side-open .side { transform: none; }
  .side__close { display: grid; }
  .side-scrim { display: block; position: fixed; inset: 0; background: rgba(22,26,82,.4); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .side-open .side-scrim { opacity: 1; pointer-events: auto; }
  .side-open { overflow: hidden; }
  .topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; padding: 10px 16px;
    background: rgba(255,255,255,.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  }
  .topbar__brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--navy); }
  .topbar__brand img { height: 34px; width: auto; }
  .topbar .avatar { margin-inline-start: auto; }
  .admin-main { padding-top: 20px; }
  .login { grid-template-columns: 1fr; }
  .login__art { display: none; }
  .login__logo { display: block; width: 84px; height: auto; margin-bottom: 8px; }
  .login__form { padding: 32px 24px; }
}
@media (max-width: 640px) {
  .columns { gap: 3px; height: 180px; }
  .columns__label { font-size: .62rem; }
  .columns__value { font-size: .68rem; }
  .legend { grid-template-columns: 1fr; }
  .kpis { gap: 10px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi__icon { width: 36px; height: 36px; }
  .kpi b { font-size: 1.2rem; }
  .form-grid { grid-template-columns: 1fr; }
  .facts__wide { grid-column: 1 / -1; }
  .page-head__actions, .page-head__actions .btn { width: 100%; }
  .pager-bar { justify-content: center; }
  .page-jump { display: none; }
  .savebar .btn { flex: 1; }
}

/* ---------------------------------------------------------- member badge */
.badge-page { background: var(--cream); min-height: 100vh; }
.badge-wrap { min-height: 100vh; width: 100%; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 16px; }
/* membership card in the society's printed design: an ID-card (85.6 × 54 mm) that scales with the screen.
   Sizes are in cqw (percent of the card's width), so the layout is identical on a phone, a laptop and paper. */
.pcard {
  --ink: #232a7c; --ink-2: #3a4196; --leaf: #009a4c; --muted: #6b7091; --tint: #eef1fa;
  container-type: inline-size; position: relative; overflow: hidden; box-sizing: border-box;
  width: min(100%, 700px); aspect-ratio: 85.6 / 54;
  display: grid; grid-template-columns: 1fr 34%; grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "head side" "info side" "foot foot";
  column-gap: 0;
  border: .45cqw solid var(--ink); border-radius: 3.4cqw;
  background: linear-gradient(160deg, #ffffff 0%, #fbfcff 55%, #f1f4fb 100%);
  color: var(--ink); font-family: "Tajawal", system-ui, sans-serif;
  box-shadow: 0 2px 0 rgba(255,255,255,.9) inset, 0 40px 70px -36px rgba(22,26,82,.55), 0 6px 18px -10px rgba(22,26,82,.25);
}
.pcard__marks { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
/* watermark: a faint diagonal pattern of "cccps" (rows staggered like a security print) over the white area,
   with the family icon as a seal behind the details; the left band paints over both */
.pcard__mark { position: absolute; width: 34cqw; right: calc(33cqw - 17cqw); top: 14cqw; opacity: .05; }
.pcard__words { position: absolute; inset: -22cqw -20cqw; display: flex; flex-direction: column; justify-content: space-between;
  transform: rotate(-16deg); }
.pcard__words span { white-space: nowrap; font: 800 3.4cqw/1 "Source Sans 3", sans-serif; letter-spacing: .14em; word-spacing: 5cqw;
  color: rgba(35,42,124,.045); }
.pcard__words span:nth-child(even) { padding-left: 8.5cqw; color: rgba(0,154,76,.05); }

/* head */
.pcard__head { grid-area: head; position: relative; padding: 3.6cqw 5cqw 0 3.4cqw; }
.pcard__org { margin: 0 0 .4cqw; font-size: 1.85cqw; font-weight: 700; color: var(--muted); letter-spacing: .01em; }
.pcard__title { margin: 0; font-size: 4.5cqw; line-height: 1.1; font-weight: 800; color: var(--ink); }
.pcard__title::after { content: ""; display: block; width: 9cqw; height: .6cqw; margin-top: 1.1cqw; border-radius: 1cqw;
  background: linear-gradient(90deg, var(--leaf), #63cc93); }

/* details */
.pcard__info { grid-area: info; position: relative; padding: 3.4cqw 5cqw 2.4cqw 3.4cqw; display: flex; flex-direction: column; justify-content: flex-start; min-width: 0; min-height: 0; }
.pcard__label { display: block; font-size: 1.85cqw; font-weight: 700; color: var(--muted); letter-spacing: .01em; margin-bottom: .35cqw; }
.pcard__namebox { padding-bottom: 1.8cqw; margin-bottom: 2cqw; border-bottom: .18cqw dashed #d6dbea; }
.pcard__name { display: block; font-size: 3.5cqw; font-weight: 800; line-height: 1.3; color: var(--ink); overflow-wrap: anywhere; }
.pcard__name--long { font-size: 2.7cqw; line-height: 1.3; }
.pcard__name--xlong { font-size: 2.1cqw; line-height: 1.25; }
.pcard__grid { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2cqw 3cqw; }
.pcard__grid div { min-width: 0; }
.pcard__grid dd { margin: 0; font-size: 2.5cqw; font-weight: 800; color: #1d2160; line-height: 1.3; overflow-wrap: anywhere; }
.pcard__grid dd[dir="ltr"] { text-align: right; unicode-bidi: isolate; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.pcard__wide { grid-column: 1 / -1; }
.pcard__serial { margin: 0; display: inline-flex; align-items: center; gap: 1.4cqw; }
.pcard__serial span { font-size: 2.1cqw; font-weight: 800; color: #fff; }
.pcard__serial b { min-width: 7cqw; text-align: center; font: 900 3.5cqw/1 "Source Sans 3", "Tajawal", sans-serif; color: var(--ink);
  background: #fff; border-radius: 1.4cqw; padding: .7cqw 1.8cqw; letter-spacing: .04em; font-variant-numeric: tabular-nums;
  box-shadow: 0 .5cqw 1.2cqw -.4cqw rgba(10,14,60,.45); }

/* left band: a full-height tinted column (the card's own corner shapes it) holding the logo and the QR */
.pcard__side { grid-area: side; position: relative; padding: 3.6cqw 3.4cqw 2.8cqw;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 2cqw;
  background:
    radial-gradient(90% 55% at 50% 0%, rgba(255,255,255,.95) 0%, rgba(255,255,255,0) 70%),
    radial-gradient(80% 45% at 50% 100%, rgba(0,154,76,.10) 0%, rgba(0,154,76,0) 70%),
    linear-gradient(180deg, #f2f4fb 0%, #e9edf8 100%);
  border-left: .15cqw solid rgba(35,42,124,.10); }
.pcard__logo { width: 80%; height: auto; filter: drop-shadow(0 .6cqw 1.2cqw rgba(22,26,82,.12)); }
.pcard__qrbox { margin: 0; display: grid; justify-items: center; gap: .5cqw; padding: 1.1cqw 1.1cqw .75cqw; background: #fff;
  border-radius: 1.9cqw; box-shadow: 0 1.2cqw 2.6cqw -1.4cqw rgba(22,26,82,.38), 0 0 0 .15cqw rgba(35,42,124,.06); }
.pcard__qr { width: 16.5cqw; height: auto; display: block; image-rendering: pixelated; }
.pcard__qrbox figcaption { font-size: 1.55cqw; font-weight: 700; color: var(--muted); }

/* footer strip: serial number + contact */
.pcard__foot { grid-area: foot; position: relative; display: flex; align-items: center; justify-content: space-between; gap: 2cqw;
  padding: 1.3cqw 5cqw 1.3cqw 4cqw; background: linear-gradient(90deg, var(--leaf) 0%, var(--ink-2) 45%, var(--ink) 100%); color: #fff; }
.pcard__contact { margin: 0; display: flex; gap: 2.4cqw; font: 700 1.7cqw/1 "Source Sans 3", "Tajawal", sans-serif; letter-spacing: .03em; }
.pcard__contact span + span::before { content: "•"; margin-right: 2.4cqw; opacity: .6; }

.badge-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; width: min(100%, 700px); }
@media print {
  @page { margin: 12mm; }
  .badge-page { background: #fff; }
  .badge-wrap { min-height: 0; justify-content: flex-start; padding: 0; }
  .badge-actions { display: none; }
  .pcard { width: 85.6mm; box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pcard * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ==========================================================
   Phones: no sideways scrolling anywhere; table rows become cards
   ========================================================== */
.shell__main { overflow-x: clip; }
@media (max-width: 760px) {
  .admin-body { font-size: 15px; }
  .admin-main { padding: 16px 12px 40px; }
  .page-head { margin-bottom: 14px; gap: 12px; }
  .page-head h1 { font-size: 1.35rem; }
  .page-head .muted { font-size: .9rem; }
  .page-head__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .page-head__actions .btn { width: 100%; justify-content: center; padding: .7em .6em; }
  .page-head__actions .btn:only-child { grid-column: 1 / -1; }

  /* 16px inputs: iOS won't zoom in on focus */
  .admin-body .field input, .admin-body .field select, .admin-body .field textarea,
  .search-field input, .dd__btn, .dd__search, .page-jump input { font-size: 16px; }
  .admin-body .btn, .dd__btn, .admin-body .field input { min-height: 44px; }
  .icon-btn { width: 40px; height: 40px; }

  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .kpi { padding: 12px; gap: 10px; border-radius: 14px; }
  .kpi__icon { width: 36px; height: 36px; border-radius: 10px; }
  .kpi b { font-size: 1.2rem; }
  .kpi span:not(.kpi__icon) { font-size: .78rem; }

  .filters { padding: 12px; gap: 10px; }
  .filters__main { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .filters__main .btn { width: 100%; justify-content: center; }
  .search-field { min-height: 46px; }
  .filters__grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  .panel { padding: 16px; border-radius: 16px; }
  .panel--flush { padding: 0; }
  .table-bar { padding: 12px 14px; }
  .table-bar p { font-size: .85rem; }

  /* ---- table → cards ---- */
  .table-wrap { overflow: visible; }
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; width: auto; }
  .dtable thead { display: none; }
  .dtable__row { border-bottom: 8px solid var(--bg); }
  .dtable__row:last-child { border-bottom: 0; }
  .dtable__row > tr:first-child {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 10px; padding: 14px; cursor: default;
    grid-template-areas:
      "person person person person serial toggle"
      "cond cond cond cond cond cond"
      "gov gov phone phone date date"
      "rank rank rank rank rank rank"
      "actions actions actions actions actions actions";
  }
  .dtable__row:hover > tr:first-child, .dtable__row.is-open > tr:first-child { background: #fff; }
  .dtable td { padding: 0; border: 0; white-space: normal; }
  .dtable__person { grid-area: person; min-width: 0; }
  .person { min-width: 0; align-items: flex-start; }
  .person__name { font-size: 1rem; }
  .dtable__serial { grid-area: serial; align-self: start; justify-self: end; font-size: .85rem; background: var(--soft); border-radius: 8px; padding: 4px 8px !important; }
  .dtable__hash { display: inline; opacity: .6; }
  .dtable__toggle { grid-area: toggle; width: auto; align-self: start; justify-self: end; }
  .dtable__toggle .icon-btn { width: 36px; height: 36px; }
  .dtable__cond { grid-area: cond; max-width: none; white-space: normal; font-weight: 700; color: var(--navy); font-size: .9rem; }
  .dtable__gov { grid-area: gov; }
  .dtable__phone { grid-area: phone; }
  .dtable__date { grid-area: date; }
  .dtable__gov, .dtable__phone, .dtable__date { font-size: .88rem; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
  .dtable__gov::before, .dtable__phone::before, .dtable__date::before {
    content: attr(data-label); display: block; font-size: .72rem; color: var(--muted); font-weight: 700; margin-bottom: 1px;
  }
  html[dir="rtl"] .dtable__phone, html[dir="rtl"] .dtable__date { text-align: right; }
  .dtable__phone::before, .dtable__date::before { direction: rtl; }
  .dtable__rank { grid-area: rank; }
  .dtable__actions { grid-area: actions; text-align: start !important; border-top: 1px dashed var(--line) !important; padding-top: 10px !important; }
  .actions { display: flex; width: 100%; gap: 8px; }
  .actions > .icon-btn, .actions > form .icon-btn, .actions > span.icon-btn { flex: 1; width: auto; height: 42px; }
  .actions form { display: contents; }

  .dtable__detail td { padding: 0 14px 14px; background: #fff; }
  .facts { grid-template-columns: 1fr 1fr; gap: 8px; }
  .facts__wide, .facts__full { grid-column: 1 / -1; }
  .facts > div { padding: 9px 10px; }

  .pager-bar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
  .pager { justify-content: center; }
  .pager a, .pager__gap { min-width: 38px; height: 40px; }
  .page-size { display: flex; justify-content: center; }
  .page-jump { display: none; }

  /* ---- dialogs: bottom sheets ---- */
  .confirm, .review { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; }
  .confirm[open] { animation: sheetIn .22s ease; }
  .confirm__box { padding: 22px 16px calc(16px + env(safe-area-inset-bottom)); }
  .review__box { overflow-y: auto; max-height: 92dvh; }
  .review__who b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .review__ranks { gap: 6px; }
  .rank-pick .rank { padding: 9px 12px; font-size: .88rem; }
  .confirm__actions .btn { min-height: 48px; }

  /* ---- edit ---- */
  .edit { gap: 12px; }
  .edit__side, .edit__main { gap: 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .summary { grid-template-columns: auto 1fr; justify-items: start; text-align: start; gap: 4px 12px; }
  .summary .avatar--lg { width: 56px; height: 56px; font-size: 1.4rem; grid-row: span 2; }
  .summary h2 { margin: 0; font-size: 1rem; }
  .summary__facts { grid-column: 1 / -1; }
  .attach { gap: 10px; }
  .attach__pick { width: 100%; justify-content: center; }
  .savebar { margin: 0 -12px -40px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 2fr; }
  .savebar .btn { width: 100%; justify-content: center; }
  .portal-form .reg-card { padding: 16px 14px 18px; }
  .portal-form .reg-actions { margin: 0 -12px -40px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .portal-form .reg-submit { width: 100%; justify-content: center; }

  /* ---- dashboard ---- */
  .dash { gap: 12px; }
  .columns { height: 170px; gap: 3px; }
  .columns__value { font-size: .66rem; }
  .columns__label { font-size: .6rem; writing-mode: vertical-rl; transform: rotate(180deg); height: 3.2em; }
  .hbars li { grid-template-columns: minmax(80px, 42%) 1fr 34px; gap: 8px; }
  .split { grid-template-columns: 1fr 1fr; }
  .split__item:last-child { grid-column: 1 / -1; }
  .legend { grid-template-columns: 1fr; }
  .mini-list { padding: 0 4px 6px; }
  .mini-list li { padding: 10px; }

  .toast { font-size: .9rem; }
}
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }

/* row that was just saved */
.dtable__row.is-updated > tr:first-child { animation: rowFlash 2.4s ease; box-shadow: inset 4px 0 0 var(--green); }
html[dir="rtl"] .dtable__row.is-updated > tr:first-child { box-shadow: inset -4px 0 0 var(--green); }
@keyframes rowFlash { 0%, 40% { background: var(--green-100); } }

/* dashboard: age panel (under 18 / 18+) */
.split--two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 0 14px; }
.split__item--minor { background: #fff4e0; } .split__item--minor b { color: #b45309; }
.split__item--adult { background: var(--navy-100); }
.stack--age .age--minor { color: #f59e0b; }
.stack--age .age--adult { color: var(--navy); }
.hbars--age .hbars__label { font-variant-numeric: tabular-nums; }
.age-unknown { margin: 12px 0 0; font-size: .82rem; }
/* the 3-item split lets its last item span the row on phones; the age pair stays side by side */
@media (max-width: 760px) { .split.split--two { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split--two .split__item:last-child { grid-column: auto; } }
