/* لوحة إدارة حِسبة — حسب تصميم Figma «لوحة إدارة حِسبة · Hisba Admin» (الصفحة العربية) */
@font-face { font-family: "Saudi Riyal"; src: url(/fonts/SaudiRiyal-Regular.woff2) format("woff2"); font-weight: 400; unicode-range: U+20C0-20C1, U+E001-E002, U+E900; }
@font-face { font-family: "Saudi Riyal"; src: url(/fonts/SaudiRiyal-Bold.woff2) format("woff2"); font-weight: 700; unicode-range: U+20C0-20C1, U+E001-E002, U+E900; }
:root {
  color-scheme: light dark;
  --bg: #F4F0FB; --side: #EEE4FC; --raised: #FFFFFF; --field: #F4F0FB; --head: #F8F4FE;
  --line: #E2D9F2; --ink: #1C1B22; --muted: #5A5468; --on-brand: #1C1B22;
  --brand: #B289F0; --brand-deep: #7741C8; --tint: #F0E7FD; --signal: #F0A531;
  --ok: #1B7A4E; --ok-tint: #E6F4EC; --bad: #C6303F; --bad-tint: #FBE2E4; --warn: #935A00; --warn-tint: #FDE6BB;
  --pill: #F1EEF7; --scrim: rgba(60, 45, 90, .5); --shadow: 0 18px 50px rgba(40, 20, 80, .22);
  --r: 12px; --r-card: 18px;
  --font: "Saudi Riyal", "Graphik Arabic", "Vazirmatn", "IBM Plex Sans Arabic", -apple-system, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #100E16; --side: #18151F; --raised: #1D1A26; --field: #24202F; --head: #221E2C;
    --line: #322C40; --ink: #F2F0F7; --muted: #A9A3B8; --on-brand: #15121C;
    --brand-deep: #CBB0F8; --tint: #2E2346;
    --ok: #4CC28D; --ok-tint: #15301F; --bad: #F27B88; --bad-tint: #3B1A20; --warn: #F3C77A; --warn-tint: #3A2C12;
    --pill: #2A2535; --scrim: rgba(0, 0, 0, .6); --shadow: 0 18px 50px rgba(0, 0, 0, .5);
  }
}
:root[data-theme=dark] {
  --bg: #100E16; --side: #18151F; --raised: #1D1A26; --field: #24202F; --head: #221E2C;
  --line: #322C40; --ink: #F2F0F7; --muted: #A9A3B8; --on-brand: #15121C;
  --brand-deep: #CBB0F8; --tint: #2E2346;
  --ok: #4CC28D; --ok-tint: #15301F; --bad: #F27B88; --bad-tint: #3B1A20; --warn: #F3C77A; --warn-tint: #3A2C12;
  --pill: #2A2535; --scrim: rgba(0, 0, 0, .6); --shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
:root[lang=en] { --font: "Saudi Riyal", "IBM Plex Sans", "Vazirmatn", -apple-system, system-ui, sans-serif; }
:root[data-size=sm] body { zoom: .92; }
:root[data-size=lg] body { zoom: 1.1; }

* { box-sizing: border-box; }
html, body { margin: 0; }
html, body { touch-action: manipulation; }
body { font-family: var(--font); font-size: 14px; line-height: 1.6; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }
h1 { font-size: 28px; line-height: 35px; margin: 0; font-weight: 700; }
h2 { font-size: 15px; line-height: 24px; margin: 0; font-weight: 700; color: var(--brand-deep); }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.caption { font-size: 12px; color: var(--muted); }
.err { color: var(--bad); min-height: 20px; margin: 8px 0 0; font-size: 13px; }
dialog .err:empty { min-height: 0; margin: 0; }
.sar { font-family: "Saudi Riyal", var(--font); }
.strong { font-weight: 700; }
.t-warn { color: var(--warn); font-weight: 700; }
.t-bad { color: var(--bad); font-weight: 700; }
.t-brand { color: var(--brand-deep); font-weight: 600; }

/* الأيقونات: ملفات SVG كقناع، تاخذ لون النص */
.ic { display: inline-block; width: 20px; height: 20px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ic.s16 { width: 16px; height: 16px; } .ic.s18 { width: 18px; height: 18px; }
.i-download { --i: url(icons/download.svg); } .i-chevron { --i: url(icons/chevron.svg); } .i-chevron-up { --i: url(icons/chevron-up.svg); }
.i-back { --i: url(icons/back.svg); } .i-alert { --i: url(icons/alert.svg); } .i-snow { --i: url(icons/snow.svg); }
.i-search { --i: url(icons/search.svg); } .i-users { --i: url(icons/users.svg); } .i-renew { --i: url(icons/renew.svg); }
.i-invoice { --i: url(icons/invoice.svg); } .i-shield { --i: url(icons/shield.svg); } .i-shield-plus { --i: url(icons/shield-plus.svg); }
.i-log { --i: url(icons/log.svg); } .i-settings { --i: url(icons/settings.svg); } .i-plus { --i: url(icons/plus.svg); }
.i-close { --i: url(icons/close.svg); } .i-user { --i: url(icons/user.svg); } .i-lock { --i: url(icons/lock.svg); }
.i-eye { --i: url(icons/eye.svg); } .i-eye-off { --i: url(icons/eye-off.svg); } .i-warn { --i: url(icons/warn.svg); }
.i-key { --i: url(icons/key.svg); } .i-pause { --i: url(icons/pause.svg); } .i-phone { --i: url(icons/phone.svg); }
.i-check { --i: url(icons/check.svg); } .i-bell { --i: url(icons/bell.svg); } .i-logout { --i: url(icons/logout.svg); } .i-code { --i: url(icons/code.svg); }

/* الشعار */
.mark { display: block; width: 34px; height: 34px; border-radius: 10px; flex: none; }
.art-mark { display: block; width: 88px; height: 88px; margin-bottom: 8px; border-radius: 22px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-size: 20px; font-weight: 700; line-height: 32px; }
.tag { height: 24px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: 999px; background: #1C1B22; color: #F0E7FD; font-size: 12px; font-weight: 600; }

/* الأزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--raised); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: transparent; color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.signal { background: var(--signal); border-color: transparent; color: #1C1B22; }
.btn.danger { background: var(--bad); border-color: transparent; color: #fff; }
.btn.danger-soft { background: var(--bad-tint); border-color: transparent; color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.xs { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 4px 0; color: var(--brand-deep); font-weight: 600; cursor: pointer; text-decoration: none; font-size: 14px; }
.icon-btn { width: 42px; padding: 0; }
:focus-visible { outline: 3px solid var(--brand-deep); outline-offset: 2px; }

/* الحقول */
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--field); color: var(--ink); }
textarea { padding: 10px 14px; min-height: 76px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
select { appearance: none; background-image: none; }
label.field { display: block; margin-bottom: 16px; }
.field > .lbl { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field > .lbl small { font-weight: 400; color: var(--muted); font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.otp { letter-spacing: 10px; text-align: center; font-size: 20px; font-weight: 700; direction: ltr; }
.with-icon { position: relative; }
.with-icon > .ic { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.with-icon > input { padding-inline-start: 42px !important; }
.with-icon > .eye { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.with-icon.has-eye > input { padding-inline-end: 44px !important; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 15px; direction: ltr; text-align: end; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand-deep); margin: 0; flex: none; }
input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand-deep); margin: 0; flex: none; }

/* الإطار: شريط جانبي (لابتوب) / شريط أيقونات (آيباد) / شريط علوي وتبويبات تحت (جوال) */
.shell { display: flex; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; width: 232px; flex: none; background: var(--side); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.side .brand { padding: 0 8px 20px; }
.side .brand .tag { margin-inline-start: auto; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 10px; text-decoration: none; font-size: 15px; font-weight: 500; color: var(--ink); }
.nav-link:hover { background: color-mix(in srgb, var(--brand) 18%, transparent); }
.nav-link.on { background: var(--brand); color: #1C1B22; font-weight: 600; }
.nav-label { flex: 1; }
.nav-short { display: none; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }
.nav-settings { margin-top: auto; }
.me { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 16px 8px 0; margin-top: 8px; }
.me-text { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.me-text b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { font-size: 13px; color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 999px; background: var(--brand); color: #1C1B22; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex: none; }
.avatar.soft { background: var(--tint); color: var(--brand-deep); width: 32px; height: 32px; font-size: 14px; }
.avatar-btn { border: 0; cursor: pointer; width: 40px; height: 40px; }
.topbar, .tabs { display: none; }
.view { flex: 1; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
/* المحتوى بعرض 1216 كحد أقصى وفي النص على الشاشات العريضة */
.view > * { width: 100%; max-width: 1216px; }

/* رأس الصفحة */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sub { margin-top: 4px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--brand-deep); font-weight: 600; text-decoration: none; font-size: 14px; margin-bottom: 12px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* الأرقام */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); background: var(--tint); border-radius: var(--r-card); overflow: hidden; }
.stat { padding: 16px 18px; border-inline-start: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-inline-start: 0; }
.stat span { display: block; font-size: 13px; color: var(--muted); line-height: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b { display: block; font-size: 26px; line-height: 29px; margin-top: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.err-stat { border: 1px solid var(--bad); }
.seats { display: flex; gap: 6px; margin-top: 6px; align-items: center; height: 29px; }
.tally { position: relative; width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 2.5px; flex: none; }
.tally i { width: 3px; height: 14px; border-radius: 9px; background: color-mix(in srgb, var(--brand-deep) 30%, transparent); }
.tally i.on { background: var(--brand-deep); }
.tally.full { background: var(--brand); }
.tally.full i { background: #1C1B22; }
.tally b { position: absolute; width: 20px; height: 3px; border-radius: 9px; background: var(--signal); transform: rotate(-28deg); }

.cards4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px 18px; }
.kpi b { display: block; font-size: 26px; line-height: 32px; font-weight: 700; }
.kpi span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.kpi span::before { content: ""; width: 7px; height: 7px; border-radius: 9px; background: var(--muted); }
.kpi.k-compliance span::before { background: var(--brand-deep); }
.kpi.k-production span::before { background: var(--ok); }
.kpi.k-error { border-color: var(--bad); }
.kpi.k-error b { color: var(--bad); }
.kpi.k-error span::before { background: var(--bad); }
.kpi.k-error.zero { border-color: var(--line); }
.kpi.k-error.zero b { color: var(--ink); }

/* البطاقات */
.card { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-card); }
.card > :last-child { border-end-start-radius: var(--r-card); border-end-end-radius: var(--r-card); }
.card > .table-wrap:last-child { overflow-y: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; min-height: 58px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 18px; }
.count { min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--pill); color: var(--muted); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.count.warn { background: var(--warn-tint); color: var(--warn); }
.count.bad { background: var(--bad-tint); color: var(--bad); }
.tile { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tile.bad { background: var(--bad-tint); color: var(--bad); }
.tile.warn { background: var(--warn-tint); color: var(--warn); }
.tile.brand { background: var(--tint); color: var(--brand-deep); }
.tile.lg { width: 40px; height: 40px; border-radius: 12px; }
.alert-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); }
.alert-row .what { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.alert-row .what b { font-weight: 700; }
.alert-row .what span { color: var(--muted); }
.card-foot { padding: 14px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* الحالات */
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--pill); color: var(--muted); }
.pill.active, .pill.ok, .pill.production { background: var(--ok-tint); color: var(--ok); }
.pill.trial, .pill.brand, .pill.compliance { background: var(--tint); color: var(--brand-deep); }
.pill.frozen, .pill.warn { background: var(--warn-tint); color: var(--warn); }
.pill.expired, .pill.bad, .pill.error { background: var(--bad-tint); color: var(--bad); }
.pill.cancelled { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.pill.none, .pill.muted { background: var(--pill); color: var(--muted); border: 1px solid var(--line); }

/* الفلاتر والقوائم المنسدلة */
.toolbar { display: flex; gap: 8px; align-items: center; padding: 14px 16px; flex-wrap: wrap; }
.search { flex: 1 1 260px; position: relative; }
.search input { padding-inline-start: 42px !important; min-height: 42px; }
.search .ic { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.dd { position: relative; }
.dd-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding-inline: 12px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); cursor: pointer; white-space: nowrap; font-size: 14px; }
.dd-btn .k { color: var(--muted); }
.dd-btn .v { font-weight: 700; }
.dd-btn .ic { color: var(--muted); }
.dd-btn[aria-expanded=true] { border-color: var(--brand-deep); }
.dd-btn.set { background: var(--warn-tint); border-color: var(--signal); }
.dd-btn.set .k, .dd-btn.set .v, .dd-btn.set .ic { color: var(--warn); }
.dd-btn.compact { min-height: 36px; font-size: 13px; }
.menu { position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 30; min-width: 220px; max-height: 360px; overflow: auto; background: var(--raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.menu.end { inset-inline-start: auto; inset-inline-end: 0; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 9px; background: none; cursor: pointer; text-align: start; }
.menu button:hover, .menu button:focus-visible { background: var(--field); outline: none; }
.menu button.on { background: var(--tint); }
.menu .m-main { flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.menu .m-main b { font-weight: 600; }
.menu .m-main small { color: var(--muted); font-size: 12px; }
.menu .m-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.menu .tick { width: 16px; color: var(--brand-deep); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu-search { position: sticky; top: -6px; background: var(--raised); padding: 2px 2px 6px; display: flex; align-items: center; gap: 6px; }
.menu-search .ic { position: absolute; inset-inline-start: 12px; color: var(--muted); }
.menu .menu-search input { min-height: 38px; padding-inline-start: 34px; font-size: 14px; }
.clear { display: inline-flex; align-items: center; gap: 4px; }

/* الجداول */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: start; border-top: 1px solid var(--line); white-space: nowrap; }
th { background: var(--head); font-size: 12px; color: var(--muted); font-weight: 600; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th.sorted { color: var(--ink); }
th small { display: block; font-weight: 400; font-size: 11px; }
td.name, td b { font-weight: 700; }
td.wrap { white-space: normal; min-width: 150px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--head); }
td.empty { text-align: center; color: var(--muted); padding: 32px; white-space: normal; }
td.actions { text-align: end; }
td .row-actions { display: inline-flex; gap: 6px; }
td.center, th.center { text-align: center; }
.yes { color: var(--brand-deep); font-weight: 700; }
.tick-ok { color: var(--ok); font-weight: 700; }
.who-cell { display: inline-flex; align-items: center; gap: 10px; }

/* بطاقات المشتركين (آيباد وجوال) */
/* بطاقات الجوال والتابلت (الجداول للكمبيوتر بس) */
.mcards { display: none; }
.tcard.click { cursor: pointer; }
.tcard-top .spacer { flex: 1; }
.tcard-top .avatar { margin-inline-end: 4px; }
.tcard-foot { flex-wrap: wrap; justify-content: flex-start; column-gap: 16px; row-gap: 6px; }
.tcard-foot .grow { flex: 1; }
.kv { display: inline-flex; align-items: center; gap: 8px; }
.tcard-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tcard-actions > .btn { flex: 1 1 0; }
.tcard-actions > .btn.danger-soft { flex: 0 0 auto; }
.tcard-actions > .btn:only-child { flex: 0 0 auto; margin-inline-start: auto; }
.tcard-actions > :not(.btn) { flex-basis: 100%; margin: 0; font-size: 13px; }
.who-stack { display: flex; flex-direction: column; line-height: 1.35; }
.who-stack b { font-size: 16px; }
.who-stack small { font-size: 13px; font-weight: 400; }
.tcards { display: none; }
.tcard { display: block; background: var(--raised); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; text-decoration: none; }
.tcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tcard-top b { font-size: 16px; }
.tcard p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.tcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 13px; }

/* ملف المشترك */
.banner { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: 14px; background: var(--warn-tint); color: var(--warn); }
.banner.bad { background: var(--bad-tint); color: var(--bad); }
.banner b { font-weight: 700; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.actions-row .push { margin-inline-start: auto; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.facts { margin: 0; padding: 0 18px 8px; }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); flex: none; }
.facts dd { margin: 0; font-weight: 600; text-align: end; overflow-wrap: anywhere; min-width: 0; }
.timeline { list-style: none; margin: 0; padding: 4px 18px 18px; }
.timeline li { position: relative; padding: 0 0 18px; padding-inline-start: 22px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 0; top: 7px; width: 9px; height: 9px; border-radius: 9px; background: var(--brand); }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 4px; top: 20px; bottom: 2px; width: 1px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline li.k-freeze::before, .timeline li.k-unfreeze::before { background: var(--signal); }
.timeline li.k-new::before, .timeline li.k-activate::before, .timeline li.k-renew::before, .timeline li.k-restore::before { background: var(--ok); }
.timeline li.k-cancel::before { background: var(--bad); }
.timeline b { display: block; font-weight: 700; }
.timeline .line { display: block; }
.timeline .meta { display: block; color: var(--muted); font-size: 13px; }
.note-form { padding: 0 18px 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; border-bottom: 1px solid var(--line); }
.notes { list-style: none; margin: 0; padding: 4px 18px 8px; }
.notes li { padding: 12px 0; border-top: 1px solid var(--line); }
.notes li:first-child { border-top: 0; }
.notes .body { white-space: pre-wrap; display: block; }
.notes .meta { color: var(--muted); font-size: 13px; }
.empty-note { color: var(--muted); padding: 4px 18px 18px; margin: 0; }

/* النوافذ */
dialog { border: 0; border-radius: 20px; padding: 24px; width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); background: var(--raised); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: var(--scrim); }
.dlg-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.dlg-head h2 { font-size: 20px; line-height: 28px; color: var(--ink); }
.dlg-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.dlg-head > div { flex: 1; }
.dlg-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.info { background: var(--field); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.info.brand { background: var(--tint); color: var(--brand-deep); font-weight: 700; }
.info.warn { background: var(--warn-tint); color: var(--warn); }
.info.bad { background: var(--bad-tint); color: var(--ink); }
.info ul { margin: 0; padding-inline-start: 18px; line-height: 1.9; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; color: var(--ink); font-weight: 400; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; text-align: end; }
.kv .v.n { font-weight: 400; }
.seg { display: flex; padding: 4px; gap: 4px; background: var(--field); border-radius: 12px; margin-bottom: 16px; }
.seg button { flex: 1; min-height: 36px; border: 0; border-radius: 9px; background: none; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { min-width: 40px; height: 32px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); cursor: pointer; font-weight: 600; font-size: 13px; padding: 0 12px; }
.chip.on { border-color: var(--brand-deep); background: var(--tint); color: var(--brand-deep); }
.days-row { display: flex; gap: 10px; align-items: center; }
.field .days-row input[name=days] { width: 110px; flex: none; font-weight: 700; font-size: 16px; }
.opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--brand-deep); background: var(--tint); }
.opt:has(input:disabled) { opacity: .5; cursor: default; }
.opt .o-main { flex: 1; display: flex; flex-direction: column; line-height: 1.4; }
.opt .o-main b { font-weight: 700; }
.opt .o-main small { color: var(--muted); font-size: 12px; }
.opt .o-side { font-weight: 700; white-space: nowrap; }
.opt .o-side small { font-weight: 400; color: var(--muted); }
.checks { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check .o-main { display: flex; flex-direction: column; line-height: 1.4; }
.check b { font-weight: 700; }
.check small { color: var(--muted); font-size: 12px; }
.rules { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.rules li { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.rules li .ic { width: 14px; height: 14px; }
.rules li.ok { color: var(--ok); }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--brand-deep); }
.qr-box { display: flex; gap: 14px; align-items: center; background: var(--field); border-radius: 14px; padding: 12px; margin-bottom: 16px; }
.qr-box img { width: 120px; height: 120px; border-radius: 10px; background: #fff; padding: 6px; flex: none; }
.qr-box .secret { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: 1px; direction: ltr; text-align: end; margin: 6px 0 10px; word-break: break-all; }
.preview-msg { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); }
.preview-msg .mark { width: 30px; height: 30px; border-radius: 8px; }
.check .o-main > small { display: block; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 50; font-weight: 600; box-shadow: var(--shadow); }

/* الدخول */
.lang-switch { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 5; }
:root[dir=ltr] .i-back, :root[dir=ltr] .with-icon .i-back { transform: scaleX(-1); }
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; background: var(--raised); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 24px; }
.auth-form > div { width: 100%; max-width: 420px; }
.auth-form h1 { font-size: 26px; line-height: 34px; }
.auth-form .sub { margin: 6px 0 22px; }
.auth-form .btn.primary { width: 100%; min-height: 50px; font-size: 15px; }
.auth-form .center { text-align: center; margin-top: 14px; }
.auth-art { position: relative; background: var(--brand) url(tally.svg) 14px 10px / 62px 52px repeat; color: #1C1B22; padding: 28px 34px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.auth-art .tag { position: absolute; top: 28px; inset-inline-start: 34px; }
.auth-art .big { font-size: 96px; line-height: 1.1; font-weight: 800; margin: 0; }
.auth-art p { font-size: 20px; font-weight: 600; margin: 8px 0 0; max-width: 260px; }
.auth-art .foot { position: absolute; bottom: 24px; inset-inline-start: 34px; font-size: 13px; }
.howto { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px; }
.howto-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.howto ol { margin: 10px 0 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.howto li { counter-increment: s; display: flex; gap: 8px; }
.howto li::before { content: counter(s); flex: none; width: 20px; height: 20px; border-radius: 999px; background: var(--tint); color: var(--brand-deep); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.howto li b { color: var(--ink); }
.code-tile { width: 44px; height: 44px; border-radius: 12px; background: var(--tint); color: var(--brand-deep); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }

/* الإعدادات */
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.rows > div { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); min-height: 58px; }
.rows > div:first-child { border-top: 0; }
.rows .r-main { flex: 1; display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.rows .r-main b { font-weight: 700; }
.rows .r-main small { color: var(--muted); font-size: 12px; }
.rows .r-val { color: var(--muted); }
.rows .seg button { flex: none; padding: 0 14px; }
/* عدّاد − / + */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--raised); flex: none; }
.stp-btn { width: 38px; height: 38px; border: 0; background: none; color: var(--brand-deep); font-size: 18px; font-weight: 700; cursor: pointer; }
.stp-btn:disabled { color: var(--muted); opacity: .4; cursor: default; }
.stp-val { min-width: 84px; text-align: center; font-weight: 700; border-inline: 1px solid var(--line); line-height: 38px; padding: 0 8px; white-space: nowrap; }
/* مفتاح تشغيل */
.switch { position: relative; width: 46px; height: 28px; border-radius: 999px; border: 0; background: var(--line); cursor: pointer; flex: none; transition: background .15s; }
.switch i { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: inset-inline-start .15s; }
.switch[aria-checked=true] { background: var(--brand); }
.switch[aria-checked=true] i { inset-inline-start: 21px; }
/* الملخص الأسبوعي: الأيام والوقت */
.weekly { padding: 14px 18px 2px; border-top: 1px solid var(--line); }
.weekly .field { display: block; margin-bottom: 16px; }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.day-chips .chip { min-width: 56px; height: 40px; border-radius: 12px; }
.time-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tp-col { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 2px 10px; background: var(--raised); }
.tp-col b { font-size: 22px; line-height: 28px; min-width: 32px; text-align: center; }
.tp-arr { border: 0; background: none; color: var(--brand-deep); cursor: pointer; padding: 2px; display: grid; place-items: center; }
.tp-colon { font-size: 22px; font-weight: 700; }
.tp-ampm { display: flex; flex-direction: column; gap: 4px; padding: 4px; background: var(--field); border-radius: 12px; }
.tp-ampm button { border: 0; background: none; border-radius: 8px; padding: 4px 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tp-ampm button.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

/* لابتوب صغير: الجدول يضيق بدل ما يتمرر */
@media (max-width: 1365px) {
  th, td { padding: 11px 10px; }
  .c-partner { display: none; }
  .stat { padding: 14px; }
}
/* كمبيوتر بنافذة ضيقة (أو مكبّرة): نفس شكل اللابتوب بس أضيق، مو شكل الآيباد */
@media (max-width: 1199px) and (pointer: fine) {
  .side { width: 200px; padding-inline: 10px; }
  .view { padding-inline: 24px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat:nth-child(4) { border-inline-start: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
  .cols3 { grid-template-columns: 1fr 1fr; }
  .cols3 > .col:last-child { grid-column: 1 / -1; }
  .cols2 { grid-template-columns: 1fr; }
}
/* الآيباد (بالطول والعرض)، أو أي شاشة أضيق من 900: شريط أيقونات بدل الشريط الجانبي، والمشتركين بطاقات، والملف عمود واحد */
@media (max-width: 1199px) and (pointer: coarse), (max-width: 899px) {
  .side { width: 84px; padding: 16px 8px; align-items: stretch; }
  .side .brand { flex-direction: column; gap: 6px; padding: 0 0 14px; }
  .side .brand .tag { margin: 0; }
  .side .brand-name { font-size: 15px; line-height: 20px; }
  .nav-link { flex-direction: column; justify-content: center; gap: 2px; padding: 8px 4px; font-size: 12px; font-weight: 600; position: relative; text-align: center; }
  .nav-link .nav-label { flex: none; }
  .nav-link:has(.nav-short) .nav-label { display: none; }
  .nav-short { display: inline; }
  .nav-link .badge { position: absolute; top: 2px; inset-inline-start: calc(50% + 4px); min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }
  .me { flex-direction: column; padding: 12px 0 0; }
  .me-text { display: none; }
  .me .btn { padding: 0 8px; }
  .view { padding: 24px; }
  .stats { grid-template-columns: repeat(6, 1fr); background: none; gap: 10px; border-radius: 0; }
  .search { flex-basis: 100%; }
  .stat { background: var(--tint); border-radius: 14px; border: 0; }
  .cards4 { grid-template-columns: repeat(2, 1fr); }
  .cols3 { grid-template-columns: 1fr; }
  .actions-row { display: grid; grid-template-columns: 1fr 1fr; }
  .actions-row .btn { min-height: 46px; font-size: 15px; }
  .actions-row .btn.wide { grid-column: 1 / -1; }
  /* زر وحيد في آخر سطر ياخذ العرض كله */
  .actions-row .btn.wide ~ .btn:last-child:nth-child(even), .actions-row .btn:not(.wide):first-child ~ .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .actions-row .push { margin: 0; }
  .page-head .actions-row { display: flex; }
  .subs-table { display: none; }
  .tcards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 12px; }
  .cols2 { grid-template-columns: 1fr; }
  .auth-art .big { font-size: 72px; }
}
/* التابلت والجوال: كل قسم عنوان فوق، وتحته بطاقة لكل سطر مثل التصميم */
@media (max-width: 1199px) and (pointer: coarse), (max-width: 899px) {
  .mcards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .mcards > .empty-note { grid-column: 1 / -1; }
  .card.split { background: none; border: 0; border-radius: 0; }
  .card.split > .card-head { padding: 0 2px 10px; min-height: 0; }
  .card.split .table-wrap, .card.split .d-only, .card.split .card-foot { display: none; }
}
/* الآيباد بالطول */
@media (max-width: 999px) and (pointer: coarse), (max-width: 899px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .tcards { grid-template-columns: 1fr 1fr; }
}
/* الجوال: شريط علوي، تبويبات تحت، والإعدادات من الصورة */
@media (max-width: 720px) {
  .side { display: none; }
  .shell { flex-direction: column; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--side); }
  .topbar .brand-name { font-size: 18px; }
  .tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--raised); border-top: 1px solid var(--line); padding: 6px 4px max(6px, env(safe-area-inset-bottom)); }
  .tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; font-size: 11px; font-weight: 600; padding: 6px 0; position: relative; color: var(--ink); }
  .tabs a.on { color: var(--brand-deep); }
  .tabs a.on::before { content: ""; position: absolute; top: -7px; width: 36px; height: 3px; border-radius: 3px; background: var(--brand-deep); }
  .tabs .badge { position: absolute; top: 0; inset-inline-end: calc(50% - 22px); min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; }
  .view { padding: 16px 16px 96px; gap: 16px; }
  h1 { font-size: 24px; line-height: 32px; }
  /* الأرقام: شريط يتمرر مثل التصميم، والعنوان كامل بدون قص */
  .stats { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px) !important; max-width: none !important; }
  .stats::-webkit-scrollbar { display: none; }
  .stat { flex: 0 0 auto; min-width: 128px; padding: 12px 14px; }
  .stat span { overflow: visible; text-overflow: clip; font-size: 13px; }
  .stat b { font-size: 24px; line-height: 28px; margin-top: 4px; }
  .cards4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .toolbar { padding: 12px; }
  .toolbar .dd { flex: 1 1 auto; }
  .toolbar .dd-btn { width: 100%; justify-content: space-between; }
  .tcards { grid-template-columns: 1fr; padding: 10px; }
  .mcards { grid-template-columns: 1fr; gap: 10px; }
  /* المشتركين: الأرقام، ثم البحث والفلاتر، ثم التنبيهات، ثم القائمة (مثل التصميم) */
  .view[data-page=tenants] .subs-list { display: contents; }
  .view[data-page=tenants] .subs-list > * { width: 100%; }
  .view[data-page=tenants] .stats { order: 1; }
  .view[data-page=tenants] .subs-list > .toolbar { order: 2; padding: 0; }
  .view[data-page=tenants] > .split { order: 3; }
  .view[data-page=tenants] .subs-list > .tcards { order: 4; padding: 0; }
  .view[data-page=tenants] .subs-list > .card-foot { order: 5; border: 0; padding: 0 2px; }
  .toolbar .search { flex-basis: 100%; }
  .toolbar .dd { flex: 1 1 0; min-width: 0; }
  .toolbar .dd-btn { padding-inline: 10px 8px; font-size: 13px; gap: 4px; }
  .alert-row { flex-wrap: wrap; }
  .cols3 { grid-template-columns: 1fr; }
  .actions-row .btn { flex: 1 1 calc(50% - 4px); min-height: 48px; font-size: 15px; }
  .actions-row .btn.wide { flex-basis: 100%; }
  .actions-row .push { margin: 0; }
  .page-head .btn .btn-label { display: none; }
  .page-head .btn.icon-mobile { width: 44px; height: 44px; padding: 0; }
  .menu { max-width: calc(100vw - 32px); }
  dialog { padding: 20px; }
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-art { order: -1; min-height: 170px; padding: 22px; justify-content: flex-end; }
  .auth-art .tag { top: 18px; inset-inline-start: 22px; }
  .auth-art .big { font-size: 48px; }
  .auth-art p { font-size: 15px; margin-top: 2px; }
  .auth-art .foot { display: none; }
  .auth-form { align-items: flex-start; }
  /* الإعدادات: القيمة تحت العنوان، والأزرار على الطرف، والاختيارات بعرض البطاقة (مثل التصميم) */
  .rows > div { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; row-gap: 6px; align-items: center; padding: 12px 16px; }
  .rows > div > .r-main { grid-column: 1; grid-row: 1; }
  .rows > div > .r-val, .rows > div > .pill { grid-column: 1; grid-row: 2; justify-self: start; font-size: 13px; }
  .rows > div > :not(.r-main):not(.r-val):not(.pill):not(.seg) { grid-column: 2; grid-row: 1 / span 2; }
  .rows > div > .seg { grid-column: 1 / -1; grid-row: 2; }
  .rows .seg button { flex: 1; }
  .view[data-page=settings] .card { position: relative; margin-top: 30px; }
  .view[data-page=settings] .card > .card-head { position: absolute; bottom: 100%; inset-inline: 0; padding: 0 2px 8px; min-height: 0; }
}
/* آيفون يكبّر الصفحة إذا الخط في الحقل أصغر من 16 */
@media (pointer: coarse) { input:not(.otp), select, textarea { font-size: 16px !important; } }
