:root {
  --ink: #0F1B2D; --ink-2: #44546A; --ink-3: #5F6B7D; --line: #E3E8EF; --line-2: #EEF2F6;
  --bg: #F4F6F9; --panel: #FFFFFF; --pri: #0F4C45; --pri-2: #136B61; --pri-tint: #E5F2EF; --gold: #F4B740;
  --red: #C81E1E; --red-t: #FDECEC; --orange: #B23A08; --orange-t: #FFF1E7; --amber: #8A5A0B; --amber-t: #FFF7E0;
  --green: #136F35; --green-t: #E8F6EC; --violet: #6D28D9; --violet-t: #F1EBFE; --slate: #536173; --slate-t: #EEF1F5;
  --blue: #1D4ED8; --blue-t: #E8EEFD;
  --soft: #FAFBFC; --line-strong: #C9D2DE; --pri-text: #0F4C45; --link: #136B61;
  --red-b: #F7D3D3; --violet-b: #E2D6FB; --green-b: #CDEBD6; --amber-b: #F6E4B3; --accent-b: #C6E3DC;
  --red-s: #C81E1E; --orange-s: #C2410C; --amber-s: #A16207; --green-s: #15803D;
  color-scheme: light;
  --r: 12px; --r-sm: 8px; --shadow: 0 1px 2px rgba(15,27,45,.05), 0 4px 16px rgba(15,27,45,.05);
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E6EBF2; --ink-2: #B9C3D0; --ink-3: #95A1B2; --line: #2A3442; --line-2: #212A36;
    --bg: #0E131A; --panel: #161D26; --soft: #1B232E; --line-strong: #3A4656;
    --pri: #1E7A6D; --pri-2: #25907F; --pri-tint: #12302C; --pri-text: #7DD8CA; --link: #7DD8CA; --gold: #F4B740;
    --red: #F49A9A; --red-t: #3A1D20; --orange: #F5AE7E; --orange-t: #3A2518; --amber: #EBC877; --amber-t: #322914;
    --green: #79D59A; --green-t: #14301F; --violet: #C3B1F7; --violet-t: #261F3F; --slate: #A9B5C4; --slate-t: #232C38;
    --blue: #9DBBF7; --blue-t: #1A2440;
    --red-b: #5A2A2E; --violet-b: #3B3060; --green-b: #23502F; --amber-b: #4D4020; --accent-b: #1E4A43;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #E6EBF2; --ink-2: #B9C3D0; --ink-3: #95A1B2; --line: #2A3442; --line-2: #212A36;
  --bg: #0E131A; --panel: #161D26; --soft: #1B232E; --line-strong: #3A4656;
  --pri: #1E7A6D; --pri-2: #25907F; --pri-tint: #12302C; --pri-text: #7DD8CA; --link: #7DD8CA; --gold: #F4B740;
  --red: #F49A9A; --red-t: #3A1D20; --orange: #F5AE7E; --orange-t: #3A2518; --amber: #EBC877; --amber-t: #322914;
  --green: #79D59A; --green-t: #14301F; --violet: #C3B1F7; --violet-t: #261F3F; --slate: #A9B5C4; --slate-t: #232C38;
  --blue: #9DBBF7; --blue-t: #1A2440;
  --red-b: #5A2A2E; --violet-b: #3B3060; --green-b: #23502F; --amber-b: #4D4020; --accent-b: #1E4A43;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.muted { color: var(--ink-3); } .small { font-size: 12px; } .num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--pri); display: grid; place-items: center; flex: none; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.brand-name span { color: var(--gold); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--line-2); text-decoration: none; }
.nav a.on { background: var(--pri-tint); color: var(--pri-text); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-inline-start: auto; background: var(--red-s); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 7px; line-height: 18px; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .search { flex: 1; max-width: 380px; }
.top .grow { flex: 1; }
.top .menu-btn { display: none; }
.content { padding: 22px 24px 48px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); font-size: 13px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--line-strong); }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri-2); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 36px; padding: 0; position: relative; }
.icon-btn .dot { position: absolute; top: 6px; inset-inline-end: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--red-s); }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--pri-2); outline-offset: 1px; }
label.f { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--pri); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 2px 11px; font-size: 12.5px; cursor: pointer; }
.chip:hover, .chip.on { border-color: var(--pri-2); color: var(--pri-text); background: var(--pri-tint); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.card-h .right { margin-inline-start: auto; display: flex; gap: 6px; align-items: center; }
.card-b { padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { border-radius: var(--r); padding: 14px 16px; border: 1px solid var(--line); background: var(--panel); display: block; color: inherit; min-height: 112px; }
a.stat:hover { text-decoration: none; border-color: var(--line-strong); }
.stat .k { font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.stat .v { font-size: 30px; font-weight: 600; margin-top: 6px; line-height: 1.1; }
.stat .d { font-size: 12px; margin-top: 4px; opacity: .8; }
.stat.red { background: var(--red-t); border-color: var(--red-b); } .stat.red .k, .stat.red .v { color: var(--red); }
.stat.violet { background: var(--violet-t); border-color: var(--violet-b); } .stat.violet .k, .stat.violet .v { color: var(--violet); }
.stat.green { background: var(--green-t); border-color: var(--green-b); } .stat.green .k, .stat.green .v { color: var(--green); }
.stat.amber { background: var(--amber-t); border-color: var(--amber-b); } .stat.amber .k, .stat.amber .v { color: var(--amber); }
.stat.solid-orange { background: #E0700F; border-color: #E0700F; color: #fff; }
.stat.solid-pine { background: var(--pri); border-color: var(--pri); color: #fff; }
.stat.solid-blue { background: #3346C8; border-color: #3346C8; color: #fff; }
.bar { height: 6px; background: rgba(21,128,61,.18); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.strip a { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-inline-start-width: 4px; border-radius: var(--r-sm); padding: 12px 14px; color: var(--ink); font-weight: 500; }
.strip a:hover { text-decoration: none; background: var(--soft); }
.strip a b { margin-inline-start: auto; font-size: 20px; font-weight: 600; }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: start; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: var(--soft); }
.t .title-cell { font-weight: 500; }
.t .sub { color: var(--ink-3); font-size: 12px; }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-3); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-expired { background: var(--red-t); color: var(--red); } .b-week { background: var(--orange-t); color: var(--orange); }
.b-month { background: var(--amber-t); color: var(--amber); } .b-ok { background: var(--green-t); color: var(--green); }
.b-in_process { background: var(--violet-t); color: var(--violet); } .b-inactive, .b-na { background: var(--slate-t); color: var(--slate); }
.b-plain { background: var(--slate-t); color: var(--ink-2); } .b-plain::before { display: none; }
.days { font-weight: 600; font-variant-numeric: tabular-nums; }
.days.expired { color: var(--red); } .days.week { color: var(--orange); } .days.month { color: var(--amber); } .days.ok { color: var(--green); }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-inline-end: 6px; vertical-align: 1px; }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.filters .input { width: auto; min-width: 140px; height: 34px; }
.filters .input.q { flex: 1; min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 2px; background: var(--panel); }
.seg button { border: 0; background: transparent; border-radius: 99px; padding: 2px 10px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--pri-tint); color: var(--pri-text); font-weight: 600; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 8px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }  /* minmax: a long chip must not widen its column */
.cal .wd { font-size: 11px; color: var(--ink-3); text-align: center; padding: 4px 0; font-weight: 600; }
.cal .d { min-height: 46px; border-radius: var(--r-sm); background: var(--soft); border: 1px solid var(--line-2); padding: 4px 6px; font-size: 12px; position: relative; }
.cal .d.out { background: transparent; border-color: transparent; color: var(--line-strong); }
.cal .d.today { border-color: var(--pri-2); }
.cal .d .n { font-weight: 500; }
.cal .d .pill { position: absolute; bottom: 4px; inset-inline-end: 4px; min-width: 20px; text-align: center; border-radius: 99px; font-size: 11px; font-weight: 600; padding: 0 6px; color: #fff; background: var(--pri-2); cursor: pointer; border: 0; }
.cal .d .pill.expired { background: var(--red-s); } .cal .d .pill.week { background: var(--orange-s); } .cal .d .pill.month { background: var(--amber-s); }
.cal.big .d { min-height: 104px; }
.cal.big .ev { display: block; font-size: 11.5px; border-radius: 5px; padding: 1px 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal.big .ev:hover { text-decoration: none; filter: brightness(.96); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.hbar { display: grid; grid-template-columns: 140px 1fr 44px; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13px; }
.hbar .track { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 99px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-stats div { background: var(--soft); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 8px 10px; }
.mini-stats b { display: block; font-size: 20px; font-weight: 600; }

/* detail */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; }
.kv dt { color: var(--ink-3); font-size: 13px; } .kv dd { margin: 0; }
.hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.hero .big-days { font-size: 34px; font-weight: 600; line-height: 1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; font-size: 13px; }
.timeline .when { color: var(--ink-3); min-width: 128px; font-variant-numeric: tabular-nums; }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.step-row .input { width: auto; }
.step-row input.input { width: 80px; }
.pick { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.pick label { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.pick label:last-child { border-bottom: 0; }
.pick label:hover { background: var(--soft); }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin: 4px 0 12px; }

/* dropdown */
.dd { position: relative; }
.dd-menu { position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(15,27,45,.14); min-width: 260px; padding: 6px; }
.dd-menu a { display: flex; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); }
.dd-menu a:hover { background: var(--line-2); text-decoration: none; }
.dd-menu small { display: block; color: var(--ink-3); font-size: 12px; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,27,45,.38); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 24px 64px rgba(15,27,45,.24); }
.modal.wide { max-width: 760px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal-b { padding: 18px 20px; }
.modal-f { padding: 12px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; }
#toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 80; }
[dir="rtl"] #toast { transform: translateX(50%); }
#toast div { background: #0F1B2D; color: #fff; padding: 10px 16px; border-radius: 10px; margin-top: 8px; box-shadow: var(--shadow); }
#toast div.err { background: var(--red-s); }
.notice { background: var(--amber-t); border: 1px solid var(--amber-b); color: var(--amber); border-radius: var(--r-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }

/* auth / public */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--pri-tint), var(--bg) 55%); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .card .card { padding: 0; max-width: none; }
.auth .brand { justify-content: center; padding-bottom: 6px; }
.auth .tag { text-align: center; color: var(--ink-3); margin-bottom: 22px; }
.auth .btn.pri { width: 100%; height: 40px; }
.auth .lang { position: fixed; top: 16px; inset-inline-end: 16px; }
.err-text { color: var(--red); font-size: 13px; margin-bottom: 10px; min-height: 1px; }

@media (max-width: 1080px) {
  .cols, .cols-3-2 { grid-template-columns: minmax(0, 1fr); }  /* minmax: a wide table scrolls in its card, not the page */
  .strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 248px; z-index: 50; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  [dir="rtl"] .side { transform: translateX(105%); }
  .side.open { transform: none !important; }
  .top .menu-btn { display: inline-flex; }
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .top .search { order: 9; max-width: none; flex-basis: 100%; }
  .content { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .strip { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .hbar { grid-template-columns: 100px 1fr 36px; }
  .hide-sm { display: none; }
}

/* dashboard v2 */
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat.neutral .k { color: var(--ink-2); }
.stat.accent { background: var(--pri-tint); border-color: var(--accent-b); } .stat.accent .k, .stat.accent .v { color: var(--pri-text); }
.strip.compact { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.strip.compact a { padding: 9px 12px; font-size: 13px; }
.strip.compact a b { font-size: 16px; }
.needs { list-style: none; margin: 0; padding: 0; }
.needs li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.needs li:last-child { border-bottom: 0; }
.needs .rail { width: 4px; align-self: stretch; border-radius: 2px; background: var(--slate); flex: none; }
.needs .rail.expired { background: var(--red); } .needs .rail.week { background: var(--orange); } .needs .rail.month { background: #D99A1E; } .needs .rail.reply { background: var(--violet); }
.needs .grow { flex: 1; min-width: 0; }
.needs .t1 { font-weight: 500; color: var(--ink); }
.needs .t2 { font-size: 12px; color: var(--ink-3); }
.hijri { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.date-hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; min-height: 18px; }
.t .title-cell a { color: var(--ink); }
.t .row-act { width: 1%; white-space: nowrap; }
/* reminders: state chips, phone cards, floating add */
.state-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 16px 0; }
.state-chips a { border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px; font-size: 12.5px; color: var(--ink-2); background: var(--panel); }
.state-chips a:hover { text-decoration: none; border-color: var(--line-strong); }
.state-chips a.on { background: var(--pri-tint); border-color: var(--pri-2); color: var(--pri-text); font-weight: 600; }
.rcards { display: none; padding: 12px; gap: 10px; flex-direction: column; }
.rcard { display: block; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--panel); color: var(--ink); }
.rcard:hover { text-decoration: none; border-color: var(--line-strong); }
.rcard .row1 { display: flex; gap: 8px; align-items: flex-start; }
.rcard .row1 b { font-weight: 600; flex: 1; min-width: 0; }
.rcard .meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.rcard .row3 { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.rcard .row3 .btn { margin-inline-start: auto; }
.fab { display: none; position: fixed; bottom: 20px; inset-inline-end: 20px; width: 54px; height: 54px; border-radius: 50%; background: var(--pri); color: #fff; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(15,27,45,.25); z-index: 30; }
.fab svg { width: 24px; height: 24px; }
.fab:hover { text-decoration: none; background: var(--pri-2); }
@media (max-width: 1080px) { .strip.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .stats.four { grid-template-columns: 1fr 1fr; }
  .strip.compact { grid-template-columns: 1fr 1fr; }
  .needs li { padding: 10px 12px; gap: 10px; flex-wrap: wrap; }
  .needs .act { margin-inline-start: 16px; }
  .rcards { display: flex; }
  .table-wrap.has-cards { display: none; }
  .fab { display: inline-flex; }
  .filters .input, .filters .input.q { min-width: 0; flex: 1 1 calc(50% - 4px); }
  .filters .input.q { flex-basis: 100%; }
  .stat { min-height: 0; }
  .stat .v { font-size: 26px; }
}

/* theme toggle + live search + checklist + tabs + bulk */
.search-wrap { position: relative; flex: 1; max-width: 380px; }
.search-wrap .search { max-width: none; width: 100%; }
.search-pop { position: absolute; top: calc(100% + 6px); inset-inline: 0; z-index: 45; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(15,27,45,.18); padding: 6px; max-height: 420px; overflow-y: auto; }
.search-pop a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); }
.search-pop a:hover, .search-pop a.on { background: var(--line-2); text-decoration: none; }
.search-pop .grow { flex: 1; min-width: 0; }
.search-pop .all { justify-content: center; color: var(--link); font-size: 13px; border-top: 1px solid var(--line-2); border-radius: 0; margin-top: 4px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; background: var(--soft); }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; display: grid; place-items: center; }
.checklist li.done .tick { background: var(--green-s); border-color: var(--green-s); color: #fff; }
.checklist li.done .lbl { text-decoration: line-through; color: var(--ink-3); }
.checklist .tick svg { width: 14px; height: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--pri-text); border-bottom-color: var(--pri-2); }
.tabs .cnt { font-size: 11px; background: var(--line-2); border-radius: 99px; padding: 0 7px; margin-inline-start: 6px; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; background: var(--pri-tint); border-bottom: 1px solid var(--accent-b); }
.bulkbar b { color: var(--pri-text); margin-inline-end: 6px; }
.t th.sel, .t td.sel { width: 1%; padding-inline-end: 0; }
.t td.sel input, .t th.sel input { width: 16px; height: 16px; accent-color: var(--pri); }
.t th button.sort { border: 0; background: transparent; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; padding: 0; display: inline-flex; gap: 4px; align-items: center; }
.t th button.sort:hover { color: var(--ink); }
.t th button.sort.on { color: var(--pri-text); }
.hijri-entry { display: flex; gap: 6px; margin-top: 6px; }
.hijri-entry .input { height: 32px; }
.linkish { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; font-size: 12px; }
@media (max-width: 760px) { .search-wrap { order: 9; max-width: none; flex-basis: 100%; } .bulkbar { position: sticky; top: 0; z-index: 5; } }

/* calendar: click a day to add a reminder */
.cal .d[data-add] { cursor: pointer; }
.cal .d[data-add]:hover, .cal .d[data-add]:focus-visible { border-color: var(--pri-2); background: var(--pri-tint); outline: none; }
.cal .d .add { position: absolute; top: 2px; inset-inline-end: 7px; font-weight: 600; font-size: 15px; color: var(--pri-text); opacity: 0; pointer-events: none; }
.cal .d[data-add]:hover .add, .cal .d[data-add]:focus-visible .add { opacity: 1; }
@media (hover: none) { .cal .d[data-add] .add { opacity: .55; } }
.cal .d { min-width: 0; overflow: hidden; }

/* companies */
.co-logo { border-radius: 10px; object-fit: contain; background: var(--panel); border: 1px solid var(--line); flex: none; display: inline-flex; }
.co-logo.initials { align-items: center; justify-content: center; background: var(--pri-tint); color: var(--pri-text); font-weight: 600; border-color: var(--accent-b); }
.co-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.co-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.co-card { display: block; padding: 14px; color: var(--ink); }
.co-card:hover { text-decoration: none; border-color: var(--line-strong); }
.co-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.co-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.co-chip { background: var(--soft); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 7px 9px; font-size: 13px; min-width: 0; }
.co-chip.bad { background: var(--red-t); border-color: var(--red-b); }
.co-foot { margin-top: 10px; }
.co-reg { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 0 12px; align-items: start; position: relative; }
.co-track { margin-top: 30px; white-space: nowrap; }
.co-remlink { position: absolute; inset-inline-end: 0; top: 2px; }
.co-inline { display: inline-flex; align-items: center; gap: 5px; color: inherit; vertical-align: middle; }
.co-inline .co-logo { border-radius: 4px; }
@media (max-width: 760px) { .co-reg { grid-template-columns: 1fr; } .co-track { margin: -4px 0 14px; } .co-remlink { position: static; display: block; margin: -8px 0 12px; } }

/* insights */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stat .d.up { color: var(--green); } .stat .d.down { color: var(--red); }
.ins-chart { width: 100%; height: auto; display: block; overflow: visible; }
.ins-chart .ins-bar { cursor: pointer; outline: none; }
.ins-chart .ins-bar path { fill: var(--pri-2); }
.ins-chart .ins-bar:hover path, .ins-chart .ins-bar:focus path { fill: var(--pri); }
.ins-chart .ins-bar:focus rect { stroke: var(--pri-2); stroke-width: 1.5; rx: 6; }
.ins-chart .ins-base { stroke: var(--line); stroke-width: 1; }
.ins-chart .ins-axis { font-size: 9px; fill: var(--ink-3); }
.ins-chart .ins-val-lbl { font-size: 10px; fill: var(--ink); font-weight: 600; }
.ins-tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--ink); color: var(--panel); font-size: 12px; padding: 4px 9px; border-radius: 6px; pointer-events: none; white-space: nowrap; }
[dir="rtl"] .ins-tip { transform: translateX(50%); }
.ins-row { display: grid; grid-template-columns: minmax(0, 120px) 1fr 52px; gap: 10px; align-items: center; padding: 6px 0; color: var(--ink); font-size: 13px; }
a.ins-row:hover { text-decoration: none; background: var(--soft); }
.ins-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-track { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; display: block; }
.ins-track i { display: block; height: 100%; border-radius: 99px; }
.ins-val { text-align: end; }
.ins-sub { margin: -4px 0 6px; padding-inline-start: 130px; }
/* reports */
.rep-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.rep-list { padding: 6px; }
.rep-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: var(--r-sm); color: var(--ink); }
.rep-item:hover { background: var(--line-2); text-decoration: none; }
.rep-item.on { background: var(--pri-tint); }
.rep-item.on svg { color: var(--pri-text); }
.rep-title { font-weight: 600; font-size: 13.5px; }
.rep-filters, [data-repf] { align-items: flex-end; }
[data-repf] label { display: flex; flex-direction: column; gap: 3px; }
.rep-count { padding: 10px 16px; }
.print-head { display: none; }
@media (max-width: 1080px) { .rep-layout { grid-template-columns: minmax(0, 1fr); } .rep-list { display: flex; overflow-x: auto; min-width: 0; } .rep-item { min-width: 200px; } }  /* minmax: a wide table must scroll inside its card, not widen the page */
@media (max-width: 760px) { .ins-sub { padding-inline-start: 0; } }
@media print {
  .side, .top, .no-print, .fab, #toast, #modal-root { display: none !important; }
  .shell { display: block; } .content { padding: 0; max-width: none; }
  .rep-layout { display: block; } .card { box-shadow: none; border: 0; }
  .print-head { display: block; padding: 0 0 12px; border-bottom: 1px solid #ccc; margin-bottom: 8px; }
  body { background: #fff; color: #000; }
  .t th { background: none; } .t tr.click { cursor: auto; }
}

/* WO-LAYOUT-01 — narrow-width layout (ISSUE-LAYOUT-01 L1–L3) */
/* L2 (R2): a card header and a segmented control wrap onto another line when they do not fit */
.card-h { flex-wrap: wrap; }
.card-h .right { flex-wrap: wrap; max-width: 100%; }
.seg { flex-wrap: wrap; max-width: 100%; }
.seg button { overflow-wrap: anywhere; }
/* L3 (R3): a long unbroken name breaks inside its list row instead of widening the page */
.list .grow { overflow-wrap: anywhere; }
/* L1 (R1 D): the Renew buttons stay at the table's end edge (right in English, left in Arabic) while the
   other columns scroll beneath them. Only the body cells are pinned: the column's header is empty, so the
   header's sort buttons are never under the pin. Opaque in both themes; row hover still tints the cell
   (.t tr.click:hover td is more specific). Focus scrolling keeps a control clear of the pinned column. */
.t td.row-act { position: sticky; inset-inline-end: 0; z-index: 1; background: var(--panel); }
.table-wrap:has(td.row-act) { scroll-padding-inline-end: 8rem; }

/* WO-LAYOUT-02 — narrow-width layout (ISSUE-LAYOUT-01 L4, L6–L8) */
/* L4 (D1, content-aware): above the phone layout the top bar wraps instead of running off the screen, and only
   when the search box would otherwise be narrower than 160 px. The search keeps the first row and takes the free
   space there first (up to its usual maximum); the controls after it move to the next row. Phones keep the
   search on its own row (the 760 px rules). */
@media (min-width: 761px) { .top { flex-wrap: wrap; row-gap: 8px; } .top .search-wrap { flex: 99 1 160px; min-width: 160px; } }
/* L7 (D2 a): on phones the tabs sit closer, and wrap onto a second row only where one row cannot fit */
@media (max-width: 760px) { .tabs { flex-wrap: wrap; } .tabs button { padding-inline: 9px; } }
/* L8: a control focused while it is only partly visible at the table's start edge is scrolled fully into view
   (the end edge keeps WO-LAYOUT-01's padding for the pinned column) */
.table-wrap { scroll-padding-inline-start: 2.5rem; }
