:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --ink: #101828;
    --muted: #667085;
    --line: #e4e7ec;
    --accent: #1d4ed8;
    --ok: #067647;
    --ok-bg: #ecfdf3;
    --warn: #b54708;
    --warn-bg: #fffaeb;
    --err: #b42318;
    --err-bg: #fef3f2;
    --side: #0f172a;
    --side-ink: #cbd5e1;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
}

.shell { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.side {
    width: 232px;
    flex: 0 0 232px;
    background: var(--side);
    color: var(--side-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { background: var(--accent); color: #fff; font-weight: 700; border-radius: 7px; padding: 4px 8px; font-size: 13px; letter-spacing: .5px; }
.brand-text { color: #fff; font-weight: 600; font-size: 13px; line-height: 1.25; }
.side nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side nav a {
    color: var(--side-ink); text-decoration: none; padding: 8px 11px; border-radius: 7px;
    display: flex; align-items: center; justify-content: space-between; font-size: 13.5px;
}
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.on { background: var(--accent); color: #fff; font-weight: 500; }
.pill { background: var(--err); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.side-foot { padding: 12px 16px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 500; }
.side-foot .role { color: #94a3b8; margin: 2px 0 8px; text-transform: capitalize; }
.signout { color: #94a3b8; text-decoration: none; font-size: 12px; }
.signout:hover { color: #fff; text-decoration: underline; }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--panel); border-bottom: 1px solid var(--line);
    padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar .back { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px 5px 6px; border: 1px solid var(--line); border-radius: 8px;
                background: var(--panel); color: var(--muted, #64748b); font-size: 13px; text-decoration: none; white-space: nowrap; }
.topbar .back:hover, .topbar .back:focus-visible { color: var(--accent, #2457d8); border-color: var(--accent, #2457d8); outline: none; }
.topbar .back svg { flex: none; }
.gw { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 500; }
.gw.up { background: var(--ok-bg); color: var(--ok); }
.gw.down { background: var(--err-bg); color: var(--err); }
.content { padding: 22px 24px 60px; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 22px; align-items: stretch; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius, 12px); padding: 15px 17px; box-shadow: var(--shadow, none); display: flex; flex-direction: column; }
/* detail-page tiles: equal height with the value vertically centred, so a long
   value (a client name) doesn't make one box hang below the rest. */
.tiles.detail { align-items: stretch; }
.tiles.detail .tile { display: flex; flex-direction: column; }
.tiles.detail .v { flex: 1; display: flex; align-items: center; font-size: 18px; line-height: 1.3; word-break: break-word; margin-top: 8px; }
.tile .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tile .v { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 3px; min-height: 1.4em; }   /* always rendered, so every tile in a row is the same height */
.tile.ok  .v { color: var(--ok); }
.tile.warn .v { color: var(--warn); }
.tile.err .v { color: var(--err); }

/* ---------- panels & tables ---------- */
/* .panel is the legacy container; it is kept visually identical to .card so
   every page shares one elevated-card look without per-page markup changes. */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius, 12px); box-shadow: var(--shadow, none); margin-bottom: 22px; overflow: hidden; }
.panel > h2 {
    margin: 0; padding: 16px 20px; font-size: 15px; font-weight: 650; letter-spacing: -.01em;
    border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-body { padding: 18px 20px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 18px; text-align: left; border-bottom: 1px solid var(--line-soft, var(--line)); vertical-align: middle; }
th { background: var(--panel-2, #fafbfc); font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; border-bottom-color: var(--line); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2, #fafbfc); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- badges (crisp bordered pills, shared by every status column) ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 550; white-space: nowrap; border: 1px solid transparent; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line, transparent); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line, transparent); }
.badge.err { background: var(--err-bg); color: var(--err); border-color: var(--err-line, transparent); }
.badge.mute { background: var(--line-soft, #f2f4f7); color: var(--muted); border-color: var(--line); }
.badge.mode { background: var(--accent-soft, #eef4ff); color: var(--accent); border-color: var(--accent-soft, transparent); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
/* Settings — grouped sections with "?" tooltips */
.settings-form { overflow: visible; }              /* let tooltips escape the card */
.sgroup { padding: 22px 0; border-top: 1px solid var(--line); }
.sgroup:first-of-type { padding-top: 4px; border-top: 0; }
.sgroup-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.sgroup-ic { flex: none; width: 34px; height: 34px; border-radius: 9px; display: inline-flex;
    align-items: center; justify-content: center; color: var(--accent);
    background: var(--accent-soft, #eef4ff); border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); }
.sgroup-tx { min-width: 0; }
.sgroup-tx h3 { margin: 1px 0 0; font-size: 14px; font-weight: 650; letter-spacing: -.01em; color: var(--ink); }
.sgroup-tx p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; max-width: 70ch; }
.field label { display: flex; align-items: center; gap: 6px; }
.field-key { font-size: 10.5px; color: var(--faint, var(--muted)); opacity: .8;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 1px; }

/* the "?" tip badge + its tooltip bubble */
.tip { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
    border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2, #fafbfc);
    color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1; cursor: help;
    position: relative; transition: all .12s; user-select: none; }
.tip:hover, .tip:focus { border-color: var(--accent); color: var(--accent);
    background: var(--accent-soft, #eef4ff); outline: none; }
.tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 9px);
    transform: translateX(-50%) translateY(4px); width: max-content; max-width: 250px;
    background: #101828; color: #fff; text-align: left; text-transform: none; letter-spacing: normal;
    font-size: 11.5px; font-weight: 400; line-height: 1.5; padding: 9px 11px; border-radius: 9px;
    box-shadow: 0 10px 28px rgba(16,24,40,.22); white-space: normal; z-index: 60;
    opacity: 0; visibility: hidden; transition: opacity .14s ease, transform .14s ease; pointer-events: none; }
.tip::before { content: ""; position: absolute; left: 50%; bottom: calc(100% + 4px);
    transform: translateX(-50%); border: 5px solid transparent; border-top-color: #101828;
    z-index: 61; opacity: 0; visibility: hidden; transition: opacity .14s ease; }
.tip:hover::after, .tip:focus::after { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.tip:hover::before, .tip:focus::before { opacity: 1; visibility: visible; }
.tip-inline { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
    border-radius: 50%; border: 1px solid currentColor; font-size: 9.5px; font-weight: 700;
    vertical-align: middle; opacity: .75; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
label { font-size: 12px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=search], input[type=url], input[type=datetime-local], select, textarea {
    font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
    background: #fff; color: var(--ink); width: 100%;
}
textarea { min-height: 76px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.hint { font-size: 11.5px; color: var(--muted); }

.btn {
    font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line);
    background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--err); border-color: #fecdca; }
.btn.danger:hover { background: var(--err-bg); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 130px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.screen {
    white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; font-size: 13px; line-height: 1.5;
}
.screen:dir(rtl) { text-align: right; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; }

/* =====================================================================
   Shared UI components (introduced with the Approvals redesign; these are
   the vocabulary the other screens converge onto). Additive — existing
   .panel / .badge / table styles are left intact for not-yet-migrated pages.
   ===================================================================== */
:root {
    --panel-2: #fafbfc;
    --ink-soft: #344054;
    --faint: #98a2b3;
    --line-soft: #f0f1f4;
    --accent-soft: #eef2ff;
    --ok-line: #a6f4c5; --warn-line: #fedf89; --err-line: #fecdca;
    --info: #175cd3; --info-bg: #eff8ff; --info-line: #b2ddff;
    --violet: #6941c6; --violet-bg: #f4f3ff; --violet-line: #d9d6fe;
    --teal: #107569; --teal-bg: #f0fdf9; --teal-line: #99f6e4;
    --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    --radius: 12px;
}

/* card — the elevated container replacing .panel on migrated pages */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card-head .htext h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.card-head .htext p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; max-width: 64ch; }
.count-chip { background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; min-width: 26px; text-align: center; }

/* initials avatar */
.avatar { width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 11.5px; flex: 0 0 auto; letter-spacing: .3px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.sq { border-radius: 7px; }

/* category glyph + label (humanised change types) */
.cat { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.cat .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--cat-bg); color: var(--cat-fg); flex: 0 0 auto; }
.cat .ic svg { width: 15px; height: 15px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); background: var(--line-soft); padding: 2px 7px; border-radius: 5px; }

/* old → new diff */
.diff { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 12.5px; }
.diff .lbl { color: var(--faint); font-size: 12px; }
.diff .val { padding: 3px 9px; border-radius: 7px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.diff .old { background: var(--err-bg); color: var(--err); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--err) 45%, transparent); }
.diff .new { background: var(--ok-bg); color: var(--ok); font-weight: 500; }
.diff .arrow { color: var(--faint); }
.diff .plain { color: var(--ink-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }

/* approval rows */
.rows { display: flex; flex-direction: column; }
.arow { display: grid; grid-template-columns: 1fr auto; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); align-items: center; position: relative; transition: background .12s; }
.arow::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cat-line, transparent); }
.arow:last-child { border-bottom: 0; }
.arow:hover { background: var(--panel-2); }
.arow .lead { min-width: 0; }
.cat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; flex-wrap: wrap; }
.cat-row .client { color: var(--muted); font-size: 13px; }
.cat-row .client b { color: var(--ink-soft); font-weight: 600; }
.arow .meta { display: flex; align-items: center; gap: 18px; }
.who-mini { display: flex; align-items: center; gap: 9px; }
.who-mini .nm { font-size: 12.5px; font-weight: 550; color: var(--ink-soft); }
.who-mini .rl { font-size: 11px; color: var(--muted); }
.arow .stack { text-align: right; }
.expiry { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; justify-content: flex-end; }
.expiry .lbl { color: var(--faint); }
.expiry.soon { color: var(--warn); font-weight: 600; }
.arow .actions { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; justify-content: flex-end; }
.arow .actions.mut { color: var(--muted); }
.rej-form { display: none; margin-top: 10px; gap: 8px; align-items: center; justify-content: flex-end; }
.rej-form.open { display: flex; }
.rej-form input[type=text] { width: 200px; }
.btn svg { width: 15px; height: 15px; margin-right: -2px; }
.btn.icon { display: inline-flex; align-items: center; gap: 6px; }

/* decided table (reuses the base table look, lighter chrome) */
.cell-change { display: flex; align-items: center; gap: 9px; }
.cell-change .mini-ic { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--cat-bg); color: var(--cat-fg); flex: 0 0 auto; }
.cell-change .mini-ic svg { width: 14px; height: 14px; }
.cell-change .lbl { font-weight: 600; font-size: 13px; }
.cell-change .sub { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--faint); }
a.doc-link { cursor: pointer; }
a.doc-link:hover .lbl { color: var(--accent); text-decoration: underline; }
.outcome { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.outcome .d { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.outcome.applied { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.outcome.rejected { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.outcome.failed  { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.outcome.expired { background: #f2f4f7; color: var(--muted); border-color: var(--line); }
.who-cell { display: flex; align-items: center; gap: 8px; }
.who-cell .nm { font-size: 12.5px; font-weight: 550; color: var(--ink-soft); }
.note-cell { color: var(--muted); font-size: 12.5px; max-width: 42ch; }

/* status dot inside a badge — makes every status column a dot-pill */
.badge .d { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex: 0 0 auto; }

/* money — tabular figures with a muted currency suffix */
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.amount.lg { font-size: 15px; }
.cur { color: var(--muted); font-weight: 500; font-size: .85em; margin-left: 3px; }
.pos { color: var(--ok); } .neg { color: var(--err); }

/* client selector — segmented pill tabs (Wallets / Revenue) */
.chiptabs { display: flex; gap: 8px; flex-wrap: wrap; }
.chiptab { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft); text-decoration: none; font-size: 13px; font-weight: 550; transition: all .12s; }
.chiptab:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); background: var(--panel-2); }
.chiptab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chiptab .code { background: rgba(0,0,0,.06); color: inherit; }
.chiptab.on .code { background: rgba(255,255,255,.2); }

/* inline toolbar form (generate / actions) */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card-pad { padding: 18px 20px; }
.hero-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.mini-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.reveal { display: none; }
.reveal.open { display: inline-flex; gap: 6px; align-items: center; }

/* live pulse dot (active sessions) */
.live-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--ok); display: inline-block; vertical-align: middle; margin-right: 6px; animation: livepulse 1.8s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* latency figure — coloured by speed band */
.lat { font-variant-numeric: tabular-nums; font-weight: 600; }
.lat.f { color: var(--ok); } .lat.m { color: var(--ink-soft); } .lat.s { color: var(--warn); } .lat.x { color: var(--err); }

/* mini proportion bar (dashboard outcomes) */
.bar { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar.ok > span { background: var(--ok); } .bar.warn > span { background: var(--warn); } .bar.err > span { background: var(--err); }

/* dashboard traffic chart bars */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 132px; padding-top: 6px; border-bottom: 1px solid var(--line); }
.chart .b { flex: 1; min-width: 5px; border-radius: 3px 3px 0 0; background: var(--accent); transition: opacity .12s; }
.chart .b:hover { opacity: .75; }
.chart .b.e { background: var(--warn); }



@media (max-width: 860px) {
    .arow { grid-template-columns: 1fr; }
    .arow .meta { justify-content: space-between; }
    .arow .stack { text-align: left; }
}

/* ---------- login ---------- */
.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: var(--side); }
body:has(> .login-wrap) { background: var(--side); margin: 0; }
.login-card { background: var(--panel); border-radius: 12px; padding: 30px; width: 340px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-brand { text-align: center; margin: 4px 0 22px; }
.login-logo { display: block; height: 64px; width: auto; margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; font-weight: 700; margin: 0 0 6px; letter-spacing: -.01em; line-height: 1.3; }
.login-card p.sub { color: var(--ink-soft, #344054); font-size: 15px; margin: 0; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; text-align: center; }
.login-card.gate { width: 700px; max-width: calc(100vw - 32px); }
.login-card.gate a.btn { display: inline-block; width: auto; }
.gate-grid { display: grid; grid-template-columns: 210px 1fr; gap: 28px; align-items: start; margin-top: 18px; }
.gate-qr { text-align: center; }
.gate-qr #qr { display: inline-block; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.gate-qr #qr img, .gate-qr #qr canvas { display: block; }
.gate-qr .cap { font-size: 12px; color: var(--muted); margin-top: 8px; }
.gate-key { margin-top: 14px; text-align: left; }
.gate-key .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.gate-key .mono { font-size: 13px; letter-spacing: .06em; word-break: break-all; line-height: 1.5; margin-top: 4px; }
.gate-steps { margin: 0 0 18px 18px; padding: 0; line-height: 1.6; font-size: 13.5px; }
.gate-steps li + li { margin-top: 6px; }
.gate-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.gate-form .field { flex: 0 0 160px; margin: 0; }
.gate-form .field input { font-size: 18px; letter-spacing: .25em; text-align: center; }
.gate-form .btn { width: auto; }
.gate-foot { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
@media (max-width: 640px) { .gate-grid { grid-template-columns: 1fr; } .gate-qr { text-align: left; } }

/* ---------- tree builder ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-left: 22px; border-left: 1px dashed var(--line); }
.tree li { padding: 3px 0; }
.node-row { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 7px; }
.node-row:hover { background: #f8fafc; }
.node-key { background: #0f172a; color: #fff; border-radius: 5px; padding: 1px 7px; font-size: 11.5px; font-family: ui-monospace, monospace; }
.node-code { font-weight: 500; }
.node-type { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.node-text { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.node-actions { margin-left: auto; display: flex; gap: 6px; opacity: 0; }
.node-row:hover .node-actions { opacity: 1; }

.sim-phone { background: #0f172a; border-radius: 14px; padding: 14px; }
.sim-screen { background: #0b1220; color: #d1fae5; border-radius: 8px; padding: 14px; min-height: 130px; white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 13px; line-height: 1.55; }
.sim-input { display: flex; gap: 8px; margin-top: 10px; }
.sim-input input { flex: 1; }
.sim-input input:disabled { opacity: .55; cursor: not-allowed; }
/* the service closed the dialogue — shown on the handset screen itself */
.sim-ended { color: #f2a2ae; font-size: 12px; margin-top: 10px; letter-spacing: .02em; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }



/* Reports hub — clickable report cards + planned roadmap */
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.rep-card { display: flex; align-items: flex-start; gap: 14px; padding: 18px; text-decoration: none;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius, 12px);
    box-shadow: var(--shadow, none); color: inherit; transition: border-color .12s, box-shadow .12s, transform .12s; }
.rep-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16,24,40,.08); }
.rep-ic { flex: none; width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center;
    justify-content: center; color: var(--accent); background: var(--accent-soft, #eef4ff);
    border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); }
.rep-tx { min-width: 0; flex: 1; }
.rep-tx h3 { margin: 2px 0 0; font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; color: var(--ink); }
.rep-tx p { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.rep-go { flex: none; color: var(--muted); font-size: 18px; align-self: center; transition: color .12s, transform .12s; }
.rep-card:hover .rep-go { color: var(--accent); transform: translateX(2px); }
.rep-card.is-planned { cursor: default; opacity: .72; }
.rep-card.is-planned:hover { transform: none; box-shadow: var(--shadow, none); border-color: var(--line); }
.rep-card.is-planned .rep-ic { color: var(--muted); background: var(--panel-2, #fafbfc);
    border-color: var(--line); }
.rep-soon { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
    color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 4px;
    vertical-align: middle; }
.rep-planned-head { margin: 26px 0 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
    font-weight: 700; color: var(--muted); }

/* Report totals row */
tr.rep-total td { border-top: 2px solid var(--line); background: var(--panel-2, #fafbfc); }

/* Menu drop-off funnel — journey-depth bars */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 168px 1fr 132px; align-items: center; gap: 14px; }
.funnel-row .fl { font-size: 12.5px; font-weight: 600; color: var(--ink-soft, var(--ink)); }
.funnel-row .fl small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 1px; }
.funnel-track { position: relative; height: 34px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--panel-2, #f2f4f7); overflow: hidden; }
.funnel-fill { position: absolute; top: 0; left: 0; bottom: 0; border-radius: 7px 0 0 7px; min-width: 3px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 78%, #fff), var(--accent)); }
.funnel-fill.warn { background: linear-gradient(90deg, color-mix(in srgb, var(--warn) 70%, #fff), var(--warn)); }
.funnel-fill.err  { background: linear-gradient(90deg, color-mix(in srgb, var(--err) 70%, #fff), var(--err)); }
.funnel-meta { text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.funnel-meta .pct { font-weight: 650; }
.funnel-drop { color: var(--err); font-size: 11px; margin-top: 1px; }

.dot-ok { color: var(--ok); font-size: 9px; vertical-align: middle; }

/* subscriber content hidden from platform roles (Common/Content.php) */
.masked { cursor: help; }
.content-notice a { color:inherit; font-weight:600; }

/* password fields with a reveal toggle (assets/pw-eye.js) */
.pw-wrap { position: relative; display: flex; width: 100%; }
.pw-wrap input { flex: 1 1 auto; width: 100%; padding-right: 40px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; align-items: center;
  background: none; border: 0; padding: 4px; cursor: pointer; color: var(--muted); border-radius: 6px; }
.pw-eye:hover { color: var(--ink); background: rgba(127,127,127,.12); }
.pw-eye:focus-visible { outline: 2px solid #bfdbfe; }

/* ---------- client edit form (sectioned) ---------- */
.client-form { overflow: visible; }                 /* tooltips may escape the card */
.client-form .card-body { padding: 4px 20px 8px; }
.client-form .form-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); max-width: 1080px; gap: 14px 18px; }
.client-form .field.span-2 { grid-column: span 2; }
.client-form .field.span-3 { grid-column: span 3; }
@media (max-width: 760px) { .client-form .field.span-2, .client-form .field.span-3 { grid-column: 1 / -1; } }
.client-form .sgroup { padding: 20px 0; }
.client-form .sgroup[hidden] { display: none; }
.client-form .np-fields { grid-column: 1 / -1; padding: 14px 16px; background: var(--panel-2, #f8faf9); border: 1px dashed var(--line); border-radius: 10px; }
.client-form .np-fields[hidden], .client-form .np-fields .field[hidden] { display: none; }
.client-form .unit { font-size: 11px; color: var(--muted); }
.client-form input.mono, .client-form .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.client-form textarea { min-height: 58px; resize: vertical; }
.client-form .card-head .head-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.client-form .card-head .htext h2 .badge { font-size: 11px; font-weight: 500; }
.client-form .card-head .htext p { max-width: none; }
.check-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: 9px; background: var(--panel-2, #fafbfc); cursor: pointer; max-width: 760px; font-size: 13px; color: var(--ink); }
.check-card input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.check-card .check-tx { display: flex; flex-direction: column; gap: 3px; }
.check-card small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.check-card:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft, #eef4ff); }
.form-footer { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    padding: 12px 20px; border-top: 1px solid var(--line); background: var(--panel);
    border-radius: 0 0 var(--radius, 12px) var(--radius, 12px); z-index: 3; }
.form-footer .hint { margin-left: auto; }

/* Toasts: short confirmations for actions done in place (activation panel). */
#toastHost { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 11px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.18); border: 1px solid var(--line);
         background: var(--panel); color: var(--ink, inherit); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: none; }
.toast.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: transparent; }
.toast.err  { background: var(--err-bg);  color: var(--err);  border-color: transparent; }
.toast.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; transform: none; } }

/* A disabled action button reads as disabled (activation request before both checkpoints, or while awaiting approval). */
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

/* flatpickr, themed to the portal */
.flatpickr-calendar { font-family: inherit; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(16,24,40,.14); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.startRange, .flatpickr-day.endRange { background: var(--accent); border-color: var(--accent); color: #fff; }
.flatpickr-day.today { border-color: var(--accent); }
.flatpickr-day.today:hover { background: var(--accent-soft, #e6ecfb); color: var(--ink); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month, .flatpickr-weekdays, span.flatpickr-weekday { color: var(--ink); fill: var(--ink); }
.flatpickr-time input, .flatpickr-time .flatpickr-time-separator { color: var(--ink); font-size: 14px; }
.fp-bar { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.fp-bar button { font: inherit; font-size: 12.5px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); cursor: pointer; }
.fp-bar button:hover { border-color: var(--accent); color: var(--accent); }
input.fp-done + input.form-control, input.flatpickr-input[readonly] { cursor: pointer; }

/* Audit log: field-level changes (inside the entry dialog) */
.chg-head { color: var(--ink-soft, #344054); font-weight: 600; margin-bottom: 4px; }
ul.chg { list-style: none; margin: 0; padding: 0; }
ul.chg li { line-height: 1.6; }
ul.chg .f { color: var(--muted); }
ul.chg .f::after { content: ":"; }
ul.chg s { color: var(--err, #b42318); text-decoration: line-through; opacity: .8; margin: 0 2px; }
ul.chg b { color: var(--ok, #067647); font-weight: 600; }

/* Dialog (audit entry) */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.55); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); color: var(--ink); border-radius: 14px; width: min(680px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-x { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 14px; }
.modal-x:hover { color: var(--ink); border-color: var(--accent); }
.modal-dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; margin: 0; padding: 16px 18px 20px; font-size: 13.5px; }
.modal-dl dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.modal-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.modal-dl dd.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.modal-dl dd.detail { white-space: pre-wrap; }
body.modal-open { overflow: hidden; }
@media (max-width: 600px) { .modal-dl { grid-template-columns: 1fr; gap: 2px 0; } .modal-dl dt { margin-top: 8px; } }

/* In-page help: "?" on card headers (dialog) and hover tips on column headers */
.help-btn { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-inline-start: 8px; vertical-align: middle;
            border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2, #fafbfc); color: var(--muted); font: 700 11px/1 inherit; font-family: inherit; cursor: pointer; }
.help-btn:hover, .help-btn:focus-visible { border-color: var(--accent); color: var(--accent); background: var(--accent-soft, #eef4ff); outline: none; }
.th-help { border-bottom: 1px dotted var(--muted); cursor: help; position: relative; }
.th-help::after { content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 8px); width: max-content; max-width: 260px;
    background: #101828; color: #fff; text-align: left; text-transform: none; letter-spacing: normal; font-size: 11.5px; font-weight: 400; line-height: 1.5;
    padding: 9px 11px; border-radius: 9px; box-shadow: 0 10px 28px rgba(16,24,40,.22); white-space: normal; z-index: 60;
    opacity: 0; visibility: hidden; transition: opacity .14s ease; pointer-events: none; }
.th-help:hover::after, .th-help:focus::after { opacity: 1; visibility: visible; }
th:last-child .th-help::after, th.num .th-help::after { left: auto; right: 0; }
.help-card { width: min(720px, 100%); }
.help-body { padding: 6px 20px 20px; font-size: 14px; line-height: 1.6; }
.help-body p { margin: 10px 0; }
.help-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.help-cols { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0; }
.help-cols dt { font-weight: 600; color: var(--ink-soft, #344054); }
.help-cols dd { margin: 0; color: var(--ink); }
@media (max-width: 600px) { .help-cols { grid-template-columns: 1fr; } .help-cols dd { margin-bottom: 6px; } }
.tiles-head { display: flex; align-items: center; margin: 0 0 8px; font-size: 13px; }

/* Labelled inline forms (Billing): fields line up on their baseline; a unit sits after its input */
.toolbar .field { gap: 4px; }
.toolbar .field > label { font-size: 11.5px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.toolbar:has(.field) { align-items: flex-end; }
.with-unit { display: inline-flex; align-items: center; gap: 6px; }
.with-unit .unit { font-size: 12.5px; color: var(--muted); }

/* =====================================================================
   Zain theme (P39). Primary green #1a473a, taken from Zain Sudan's own
   portal login (the reference the client supplied); sidebar a deeper shade,
   tints derived from it. Status colours (ok / warn / err) stay semantic.
   ===================================================================== */
:root {
    --accent: #1a473a;
    --accent-soft: #e8f1ed;
    --accent-ring: #a9cfc0;
    --side: #133a2f;
    --side-ink: #cfe3db;
    --side-on: #2b6b57;
}

input:focus, select:focus, textarea:focus { outline-color: var(--accent-ring); }
.side nav a.on { background: var(--side-on); }
.brand { padding: 16px 18px 14px; }
.brand-logo { display: block; height: 26px; width: auto; }
.brand-text { font-size: 12px; opacity: .85; }
.brand.has-logo { flex-direction: column; align-items: flex-start; gap: 8px; }
.login-card .btn.primary { background: var(--accent); border-color: var(--accent); }

/* Login card wide enough for "Welcome to <name> Platform" on one line; wraps again on phones. */
.login-card { width: 480px; max-width: calc(100vw - 32px); padding: 34px 40px; box-sizing: border-box; }
.login-card h1 { white-space: normal; overflow-wrap: anywhere; text-align: center; }
@media (max-width: 520px) { .login-card { padding: 28px 22px; } .login-card h1 { white-space: normal; } }

/* Two-step verification page (mfa.php) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.otp-card { width: 440px; }
.otp-card .login-logo { height: 44px; margin-bottom: 18px; }
.otp-card h1 { white-space: normal; }
.otp-card p.sub { color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 330px; margin: 0 auto; }
.otp-icon { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
            color: var(--accent); background: var(--accent-soft); }
.login-card .otp-input, .otp-input { width: 100%; box-sizing: border-box; text-align: center; font: 600 30px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
             letter-spacing: .55em; padding: 16px 0 16px .55em; border: 1.5px solid var(--line); border-radius: 12px; background: var(--panel-2, #fafbfc); }
.otp-input::placeholder { color: var(--faint, #98a2b3); letter-spacing: .55em; }
.login-card .otp-input:focus, .otp-input:focus { border-color: var(--accent); background: var(--panel); outline: 3px solid var(--accent-ring); outline-offset: 0; }
.otp-timer { height: 4px; border-radius: 999px; background: var(--line); margin: 14px 0 6px; overflow: hidden; }
.otp-timer span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 1s linear; }
.otp-timer span.low { background: var(--warn); }
.otp-hint { font-size: 12.5px; color: var(--muted); text-align: center; margin: 0 0 18px; min-height: 1.5em; }
.otp-card .btn.primary { width: 100%; padding: 12px; font-size: 15px; border-radius: 10px; }
.otp-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.otp-lost { margin: 0; }
.otp-link { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--accent); text-decoration: none; cursor: pointer; }
.otp-link:hover { text-decoration: underline; }

/* My notifications */
.notify-grid { display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:14px; margin:14px 0; }
@media (max-width:800px) { .notify-grid { grid-template-columns:1fr; } }
.seg { display:inline-flex; border:1px solid var(--line); border-radius:9px; overflow:hidden; flex-wrap:wrap; }
.seg-opt { position:relative; cursor:pointer; }
.seg-opt input { position:absolute; opacity:0; pointer-events:none; }
.seg-opt span { display:block; padding:8px 14px; font-size:13px; border-right:1px solid var(--line); }
.seg-opt:last-child span { border-right:0; }
.seg-opt input:checked + span { background:var(--accent); color:#fff; }
.seg-opt input:focus-visible + span { outline:2px solid var(--accent-ring); outline-offset:-2px; }

/* Access control */
table.access-t td { vertical-align: middle; }
.acc-sel { font-size: 12.5px; padding: 5px 8px; border-radius: 7px; }
.acc-sel.acc-grant { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.acc-sel.acc-deny { border-color: var(--err); color: var(--err); background: var(--err-bg); }
.acc-sel.acc-off { color: var(--muted); }
.acc-na { font-size: 12px; color: var(--faint, #98a2b3); }
.acc-lock { font-size: 12px; color: var(--err); }
.acc-chk { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; cursor: pointer; }
.acc-chk input:not(:checked) + span { color: var(--err); }

/* Help dialog, structured (summary · good to know · columns) */
.help-body { padding: 18px 22px 22px; }
.hp-lead { display: flex; gap: 12px; align-items: flex-start; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
           border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.55; color: var(--ink); }
.hp-ic { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 12px/22px Georgia, serif; text-align: center; font-style: italic; margin-top: 1px; }
.hp-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; font-weight: 700; }
.hp-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hp-points li { position: relative; padding-left: 22px; font-size: 13.5px; line-height: 1.55; color: var(--ink-soft, var(--ink)); }
.hp-points li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: .75; }
.hp-cols { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.hp-row { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13.5px; line-height: 1.5; }
.hp-row:first-child { border-top: 0; }
.hp-row:nth-child(even) { background: var(--panel-2, #fafbfc); }
.hp-name { font-weight: 600; color: var(--ink); }
.hp-desc { color: var(--ink-soft, var(--ink)); }
.hp-sub { margin-bottom: 6px; }
.hp-vals { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.hp-vals li { display: flex; gap: 8px; align-items: baseline; }
.hp-chip { flex: none; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
@media (max-width: 600px) { .hp-row { grid-template-columns: 1fr; gap: 4px; } }

/* Hidden tooltips take no layout space (a right-edge tile or column used to push a horizontal scrollbar) */
.tip:not(:hover):not(:focus)::after, .tip:not(:hover):not(:focus)::before,
.th-help:not(:hover):not(:focus)::after { display: none; }
.tile .tip::after { left: auto; right: -10px; transform: none; }
.tile .tip::before { left: 50%; }

/* Right-hand drawer (Users: add / edit) */
.drawer-back { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 65; display: flex; justify-content: flex-end; }
.drawer { width: min(760px, 100%); height: 100%; background: var(--bg); box-shadow: -18px 0 48px rgba(0,0,0,.22); display: flex; flex-direction: column;
          animation: drawer-in .18s ease-out; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; background: var(--panel); border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.drawer-head .modal-x { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 28px; display: block; }
.drawer-body > .panel, .drawer-body > .flash { margin: 0 0 16px; }
@media (max-width: 600px) { .drawer-body { padding: 12px; } }

/* Sidebar footer (compact): tenant switcher · account · actions. Everything stays inside the sidebar. */
.side-foot { padding: 10px 12px 12px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12.5px; display: grid; gap: 8px; min-width: 0; box-sizing: border-box; }
.side-foot > * { min-width: 0; }
.side-foot .tenant-switch { margin: 0; }
.ts-label { display: block; color: var(--side-ink); opacity: .75; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; margin-bottom: 4px; }
.ts-select { width: 100%; max-width: 100%; box-sizing: border-box; font-size: 12px; padding: 5px 6px; border-radius: 7px; min-height: 0; height: 32px; }
.me-card { display: flex; gap: 9px; align-items: center; min-width: 0; padding: 2px 2px; }
.me-card .avatar { flex: none; }
.me-txt { min-width: 0; flex: 1; line-height: 1.3; }
.me-name { color: #fff; font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { color: var(--side-ink); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
.me-2fa { color: #9fe0c4; font-weight: 600; }
.me-actions { display: flex; gap: 6px; min-width: 0; }
.me-icon { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--side-ink); border: 1px solid rgba(255,255,255,.14); }
.me-icon:hover, .me-icon.on { color: #fff; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.3); }
.me-signout { flex: 1; min-width: 0; height: 32px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 8px; text-decoration: none;
              color: #fff; font-weight: 600; font-size: 12.5px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.28); white-space: nowrap; }
.me-signout:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.5); }

/* live counter: a short pulse when it goes up */
.pill[hidden] { display: none; }
.pill-bump { animation: pill-bump .5s ease-out; }
@keyframes pill-bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .pill-bump { animation: none; } }

.field > .seg { align-self: flex-start; }

/* ---- language switch (EN / العربية) ---- */
.topbar-right { display: flex; align-items: center; gap: 10px; }
.lang-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
    color: var(--ink-soft); background: var(--panel); text-decoration: none; font-size: 13px; font-weight: 500; line-height: 1.2; white-space: nowrap; }
.lang-toggle:hover { border-color: var(--accent, #1a473a); color: var(--accent, #1a473a); }
.lang-toggle span[lang="ar"], .lang-toggle:lang(ar) span { font-family: "IBM Plex Sans Arabic", Tahoma, sans-serif; }
.login-wrap { position: relative; }
.lang-toggle.on-login { position: absolute; top: 18px; right: 18px; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.25); color: #fff; }
.lang-toggle.on-login:hover { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.5); }
/* text that must stay left-to-right inside Arabic pages: codes, numbers, phone numbers */
/*rtl:ignore*/
[dir="rtl"] .amount, [dir="rtl"] td.num, [dir="rtl"] .tile .v, [dir="rtl"] .mono { direction: ltr; unicode-bidi: isolate; }
/*rtl:ignore*/
[dir="rtl"] code, [dir="rtl"] .mono, [dir="rtl"] .code, [dir="rtl"] input[type="tel"], [dir="rtl"] input[type="email"], [dir="rtl"] input[type="url"] { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] textarea { direction: auto; }

/* ---- audit entry dialog ---- */
.ad-card { width: min(720px, 100%); }
.ad-head { align-items: flex-start; padding: 16px 18px; }
.ad-headline { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.ad-ic { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.ad-ic svg { width: 19px; height: 19px; }
.ad-head h2 { font-size: 17px; line-height: 1.3; }
.ad-sub { margin-top: 3px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ad-sub .ad-id { color: var(--faint); }
.ad-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.ad-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ad-fact { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2, #fafbfc); min-width: 0; }
.ad-fact .k { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.ad-fact .v { font-size: 14px; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.ad-fact .x { font-size: 12px; color: var(--faint); margin-top: 2px; }
.ad-who { display: inline-flex; align-items: center; gap: 8px; }
.ad-sec h3 { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ad-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.ad-box ul.chg { white-space: normal; }
.ad-tech { border-top: 1px dashed var(--line); padding-top: 14px; }
.ad-tech-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-bottom: 8px; }
.ad-tech-row .k { font-size: 12px; color: var(--muted); }
.ad-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--ink-soft); background: var(--line-soft); border-radius: 7px; padding: 6px 9px; overflow-wrap: anywhere; text-align: left; }
.ad-copy { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.ad-copy:hover { color: var(--accent); border-color: var(--accent); }
.ad-copy.ok { color: var(--ok); border-color: var(--ok); }
.ad-note { margin: 6px 0 0; font-size: 12px; color: var(--faint); line-height: 1.5; }
@media (max-width: 600px) { .ad-facts { grid-template-columns: 1fr; } .ad-tech-row { grid-template-columns: 1fr auto; } .ad-tech-row .k { grid-column: 1 / -1; } }
.ad-box .chg-head { font-weight: 600; margin-bottom: 6px; }
.ad-box ul.chg { list-style: none; margin: 0; padding: 0; }
.ad-box ul.chg li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.ad-box ul.chg li:first-child { border-top: 0; padding-top: 2px; }
.ad-box ul.chg .f { flex: 0 0 100%; font-size: 12px; color: var(--muted); font-weight: 600; }
.ad-box ul.chg s { text-decoration: line-through; color: var(--err); background: var(--err-bg); border-radius: 6px; padding: 1px 7px; overflow-wrap: anywhere; }
.ad-box ul.chg b { color: var(--ok); background: var(--ok-bg); border-radius: 6px; padding: 1px 7px; font-weight: 600; overflow-wrap: anywhere; }
.ad-box ul.chg .arr { color: var(--faint); display: inline-block; }
/*rtl:ignore*/
[dir="rtl"] .ad-box ul.chg .arr { transform: scaleX(-1); }

/* ---------- API console ---------- */
.con-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.con-tabs a { padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--ink-soft, #344054); text-decoration: none; font-size: 13.5px; }
.con-tabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.con-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.con-pair h3, .con-result h3 { font-size: 13px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.con-json { margin: 0; max-height: 420px; overflow: auto; direction: ltr /*rtl:ignore*/; text-align: left /*rtl:ignore*/; }
.con-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.con-meta span { unicode-bidi: isolate; }
.con-meta code { direction: ltr /*rtl:ignore*/; unicode-bidi: isolate; }
.con-checks { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.con-checks li { padding: 8px 12px; border-radius: 8px; font-size: 13.5px; }
.con-checks li.ok { background: var(--ok-bg, #ecfdf3); }
.con-checks li.err { background: var(--err-bg); }
.con-checks .mk { font-weight: 700; margin-inline-end: 6px; }
.con-prov textarea { width: 100%; max-width: 900px; font-size: 12.5px; direction: ltr /*rtl:ignore*/; text-align: left /*rtl:ignore*/; }
.con-secret { margin-top: 8px; display: grid; gap: 4px; }
.con-secret code { user-select: all; font-size: 13px; }
