:root {
  --bg: #f4f6f8; --card: #fff; --text: #17202a; --muted: #5f6b76; --line: #e2e6ea;
  --primary: #0f766e; --primary-2: #115e59; --danger: #b42318; --warn: #b54708; --ok: #067647;
  --ok-bg: #ecfdf3; --warn-bg: #fffaeb; --danger-bg: #fef3f2; --muted-bg: #f2f4f7;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419; --card: #182028; --text: #e6edf3; --muted: #9aa7b3; --line: #2a3540;
    --primary: #2dd4bf; --primary-2: #14b8a6; --danger: #f97066; --warn: #fdb022; --ok: #47cd89;
    --ok-bg: #0b2e1f; --warn-bg: #33250b; --danger-bg: #3a1513; --muted-bg: #222c36;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif; }
.hidden { display: none !important; }
a { color: var(--primary); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); min-height: 44px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0; }
label input, label select, label textarea { margin-top: 4px; color: var(--text); }
.btn { border: 1px solid var(--line); background: var(--card); padding: 9px 14px; border-radius: 10px; cursor: pointer;
  min-height: 44px; white-space: nowrap; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #062a26; } }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.sm { min-height: 36px; padding: 5px 10px; font-size: 14px; }
.icon-btn { background: none; border: 0; font-size: 22px; cursor: pointer; min-width: 44px; min-height: 44px; color: inherit; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card label { text-align: right; }
.login-card .btn { width: 100%; margin-top: 8px; }
.err { color: var(--danger); min-height: 1.5em; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.pill { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--muted-bg); }
.banner { background: var(--danger-bg); color: var(--danger); padding: 10px 16px; border-bottom: 1px solid var(--danger);
  font-weight: 600; }
.nav { position: fixed; top: 57px; bottom: 0; right: 0; width: 220px; background: var(--card); border-left: 1px solid var(--line);
  padding: 8px; overflow: auto; z-index: 4; }
.nav a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
.nav a.active { background: var(--muted-bg); font-weight: 600; }
.view { margin-right: 220px; padding: 16px; max-width: 1200px; }
@media (max-width: 860px) {
  .nav { transform: translateX(100%); transition: transform .2s; width: 260px; }
  .nav.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .view { margin-right: 0; }
}
@media (min-width: 861px) { #menuBtn { display: none; } }
h2 { margin: 4px 0 14px; font-size: 20px; }
h3 { margin: 18px 0 8px; font-size: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { padding: 14px; }
.stat .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat a { text-decoration: none; color: inherit; display: block; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.row .grow { flex: 1 1 180px; }
.toolbar { margin-bottom: 12px; }
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: var(--muted-bg); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--muted-bg); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.b-active { background: var(--ok-bg); color: var(--ok); }
.b-expired { background: var(--danger-bg); color: var(--danger); }
.b-disabled { background: var(--muted-bg); color: var(--muted); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-inline-end: 6px; }
.dot.off { background: var(--line); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.muted { color: var(--muted); }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg { padding: 18px; max-height: 85vh; overflow: auto; }
.dlg h3 { margin-top: 0; }
.dlg .actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 14px; position: sticky; bottom: -18px;
  background: var(--card); padding: 10px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } .kv { grid-template-columns: 110px 1fr; } }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 12px; z-index: 50; max-width: calc(100vw - 32px); }
.pager { margin-top: 10px; }
.alert-row { padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); margin-bottom: 8px; }
.cards-list { display: none; }
@media (max-width: 640px) {
  .tbl-wrap.resp { display: none; }
  .cards-list { display: grid; gap: 8px; }
  .cards-list .card { padding: 12px; }
}

/* ---- status colours, legend, tones ---- */
:root { --c-blue: #2563eb; --c-green: #16a34a; --c-red: #dc2626; --c-cyan: #0891b2; --c-orange: #d97706; --c-gray: #6b7280; --c-purple: #7c3aed; }
@media (prefers-color-scheme: dark) { :root { --c-blue: #60a5fa; --c-green: #4ade80; --c-red: #f87171; --c-cyan: #22d3ee; --c-orange: #fbbf24; --c-gray: #9ca3af; --c-purple: #a78bfa; } }
a.stat { display: block; text-decoration: none; color: inherit; position: relative; overflow: hidden; border-top: 4px solid var(--tone); transition: transform .12s; }
a.stat:hover { transform: translateY(-2px); }
.stat .n { color: var(--tone); }
.stat-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stat-ico { font-size: 22px; opacity: .9; }
.tone-blue { --tone: var(--c-blue); } .tone-green { --tone: var(--c-green); } .tone-red { --tone: var(--c-red); }
.tone-cyan { --tone: var(--c-cyan); } .tone-orange { --tone: var(--c-orange); } .tone-gray { --tone: var(--c-gray); } .tone-purple { --tone: var(--c-purple); }
.st-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 700; color: #fff; vertical-align: middle; }
.si-active { background: var(--c-green); } .si-expiring { background: var(--c-orange); } .si-expired { background: var(--c-red); } .si-disabled { background: var(--c-gray); }
tr.st-active td:first-child { box-shadow: inset -4px 0 0 var(--c-green); }
tr.st-expiring td:first-child { box-shadow: inset -4px 0 0 var(--c-orange); }
tr.st-expired td:first-child { box-shadow: inset -4px 0 0 var(--c-red); }
tr.st-disabled td:first-child { box-shadow: inset -4px 0 0 var(--c-gray); }
.cards-list .card.st-active { border-right: 4px solid var(--c-green); } .cards-list .card.st-expiring { border-right: 4px solid var(--c-orange); }
.cards-list .card.st-expired { border-right: 4px solid var(--c-red); } .cards-list .card.st-disabled { border-right: 4px solid var(--c-gray); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 8px 12px; margin-bottom: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-size: 13px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.dot { background: var(--c-cyan); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th.sortable.on { color: var(--primary); }
.bar { display: flex; height: 10px; width: 160px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; gap: 2px; }
.bar-a { background: var(--c-green); } .bar-e { background: var(--c-red); opacity: .7; }
@media (max-width: 640px) { .hide-sm { display: none; } }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.stat .n { text-align: right; }
.cards-list .num { white-space: nowrap; }
/* ---- usage chart ---- */
:root { --s-dl: #2563eb; --s-ul: #d97706; }
@media (prefers-color-scheme: dark) { :root { --s-dl: #3b82f6; --s-ul: #c97a08; } }
.u-wrap { position: relative; }
.u-svg { width: 100%; height: auto; display: block; overflow: visible; }
.u-dl { fill: var(--s-dl); background: var(--s-dl); } .u-ul { fill: var(--s-ul); background: var(--s-ul); }
.u-grid { stroke: var(--line); stroke-width: 1; } .u-base { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.u-ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; direction: ltr; }
.u-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.u-leg { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.u-leg b { color: var(--text); font-weight: 600; }
.u-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.u-tip { position: absolute; top: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12); pointer-events: none; white-space: nowrap; }
.u-tip b { display: block; margin-bottom: 4px; }
/* SaaS pages */
.banner.info { background: var(--card, #fff); color: inherit; border-bottom-color: var(--primary); }
.banner a { font-weight: 600; }
.steps { list-style: none; padding: 0; margin: 0 0 16px; }
.steps .step { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line, #e3e6ea); border-radius: 10px; margin-bottom: 8px; background: var(--card, #fff); }
.steps .step.ok { border-color: var(--ok); }
.steps .st-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px solid var(--muted, #888); font-size: 14px; }
.steps .step.ok .st-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
pre.code { background: #0b1220; color: #d1fae5; padding: 12px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; font-size: 13px; user-select: all; }
