:root {
  --bg: #f4f6f9; --card: #ffffff; --ink: #121a26; --muted: #5d6b7e; --line: #dde3eb;
  --brand: #1d5bd8; --brand-ink: #ffffff; --ok: #0f7b4d; --okbg: #e3f5ec; --err: #c42b1c; --errbg: #fdeceb;
  --warn: #9a6200; --warnbg: #fff4dc; --chip: #eef1f6;
  --trial: #6b3fd1; --trialbg: #efe8ff; --readonly: #9a6200; --readonlybg: #fff4dc;
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131b; --card: #161d28; --ink: #e8edf4; --muted: #95a3b6; --line: #273142;
    --brand: #5b8cff; --brand-ink: #0b1220; --ok: #4fd39a; --okbg: #12301f; --err: #ff7a6e; --errbg: #3a1714;
    --warn: #f3c15b; --warnbg: #352a10; --chip: #222b39; --trial: #b49cff; --trialbg: #2a2148; --readonly: #f3c15b; --readonlybg: #352a10;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.6; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
.code { background: var(--chip); padding: 1px 6px; border-radius: 6px; letter-spacing: .5px; }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
h2 { font-size: 1.1rem; margin: 0 0 .7rem; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.bad { color: var(--err); font-weight: 600; }
.nowrap { white-space: nowrap; }
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.nav a.on, .nav a:hover { background: var(--chip); color: var(--ink); text-decoration: none; }
.logout { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: .9em; }
.page { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 520px; margin: 40px auto; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary h2 { display: inline; }
details.card > summary::before { content: "◂ "; color: var(--muted); }
details[open].card > summary::before { content: "▾ "; }
.row-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.grid2-inner .wide, .grid2-inner button { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 820px) { .grid2, .grid2-inner { grid-template-columns: 1fr; } }
.form label { display: block; margin-bottom: 10px; font-weight: 600; font-size: .92em; }
.form label.inline, label.inline { display: flex; align-items: center; gap: 8px; font-weight: 600; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); font: inherit; font-weight: 400; }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.quick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.quick input { width: 110px; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: .85em; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.actions form { margin: 0; }
td.actions { margin: 0; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0; }
.inline-form label { margin: 0; font-weight: 600; font-size: .92em; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: var(--okbg); color: var(--ok); }
.flash.err { background: var(--errbg); color: var(--err); }
.flash.warn { background: var(--warnbg); color: var(--warn); }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85em; font-weight: 700; background: var(--chip); }
.chip.warn { background: var(--warnbg); color: var(--warn); }
.st-active { background: var(--okbg); color: var(--ok); }
.st-trial { background: var(--trialbg); color: var(--trial); }
.st-readonly { background: var(--readonlybg); color: var(--readonly); }
.st-expired, .st-suspended { background: var(--errbg); color: var(--err); }
.status-big .chip { font-size: 1rem; padding: 5px 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; color: var(--ink); display: flex; flex-direction: column; }
.stat b { font-size: 1.7rem; }
.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat.st-active, .stat.st-trial, .stat.st-readonly, .stat.st-expired, .stat.st-suspended { background: var(--card); }
.stat.st-active b { color: var(--ok); } .stat.st-trial b { color: var(--trial); } .stat.st-readonly b { color: var(--readonly); }
.stat.st-expired b, .stat.st-suspended b { color: var(--err); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .88em; }
tr.revoked td { opacity: .55; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input { max-width: 320px; margin: 0; }
.filters select { max-width: 200px; margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 10px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.app-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.app-row select { width: auto; min-width: 190px; margin: 0; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.when { color: var(--muted); font-size: .85em; margin-inline-end: 6px; }
.detail { color: var(--muted); font-size: .8em; word-break: break-all; }
.keybox { display: flex; align-items: center; gap: 10px; background: var(--chip); padding: 14px; border-radius: 12px; font-size: 1.15rem; margin: 12px 0; flex-wrap: wrap; }
.qr { background: #fff; display: inline-block; padding: 10px; border-radius: 12px; }
.qr svg { width: 220px; height: 220px; display: block; }
pre { background: var(--chip); padding: 10px; border-radius: 10px; overflow-x: auto; }
.danger-zone { border-color: var(--err); }

/* طلباتُ الموقع ونسخُ الخادم */
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--err); color: #fff; font-size: .75em; font-weight: 700; text-align: center; line-height: 20px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 5px 12px; border-radius: 999px; background: var(--chip); color: var(--ink); font-weight: 600; font-size: .9em; }
.tabs a.on { background: var(--brand); color: var(--brand-ink); }
.tabs a:hover { text-decoration: none; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.st-new { background: var(--errbg); color: var(--err); }
.st-contacted { background: var(--warnbg); color: var(--warn); }
.st-closed { background: var(--chip); color: var(--muted); }
.st-creating { background: var(--warnbg); color: var(--warn); }
.st-running { background: var(--okbg); color: var(--ok); }
.st-failed, .st-stopped { background: var(--errbg); color: var(--err); }
.host-input { display: flex; align-items: center; gap: 6px; direction: ltr; }
.host-input input { margin: 0; max-width: 220px; text-align: left; }
.host-input span { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.creds { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; gap: 6px 12px; align-items: center; background: var(--chip); padding: 12px 14px; border-radius: 12px; margin: 10px 0; }
.creds dt { color: var(--muted); }
.creds dd { margin: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; direction: ltr; text-align: left; min-width: 0; overflow-wrap: anywhere; }
.order-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.order-facts dt { color: var(--muted); }
.order-facts dd { margin: 0; }
.err-text { color: var(--err); font-size: .9em; word-break: break-word; }

/* النسخ الاحتياطيّ (الرئيسيّة) */
.problems { list-style: none; margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--warnbg); color: var(--warn); font-weight: 600; }
.problems li + li { margin-top: 4px; }
.lag-alert { margin: 0 0 12px; padding: 12px 16px; border-radius: 10px; background: var(--errbg); color: var(--err); font-weight: 700; border: 2px solid var(--err); }
.lag-alert.global { margin: 12px 16px 0; }
.lag-alert a { color: inherit; }
#backups .order-facts dd { overflow-wrap: anywhere; }
#backups bdi, #instance bdi { white-space: nowrap; }

/* ── طلباتُ الخدمة وحساباتُ الموقع (2026-11-08) ── */
.st-in_progress { background: var(--warnbg); color: var(--warn); }
.st-done { background: var(--okbg); color: var(--ok); }
.st-rejected { background: var(--errbg); color: var(--err); }
.st-cancelled { background: var(--chip); color: var(--muted); }
.mail-pending { background: var(--warnbg); color: var(--warn); }
.mail-sent { background: var(--okbg); color: var(--ok); }
.mail-failed { background: var(--errbg); color: var(--err); }
.mail-expired { background: var(--chip); color: var(--muted); }
.request-head { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; align-items: flex-start; }
.request-who { text-align: start; }
.request-details { white-space: pre-line; background: var(--chip); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.request-form textarea { width: 100%; }
.search-form { margin-bottom: 12px; }
a.chip { text-decoration: none; }

/* ── موارد الخوادم (/resources) ───────────────────────────────────────── */
.res-live { display: inline-flex; align-items: center; gap: 8px; }
.res-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; }
.res-dot.bad { background: var(--err); }
.res-switch { display: grid; gap: 10px; }
.res-switch-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.res-switch-label { color: var(--muted); font-size: .88em; font-weight: 600; min-width: 52px; }
.res-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.res-pill { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .92em; cursor: pointer; }
.res-pill:hover { border-color: var(--brand); text-decoration: none; }
.res-pill.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.res-pill.on .muted { color: inherit; opacity: .8; }
.res-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.res-tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.res-tile-label { color: var(--muted); font-size: .88em; font-weight: 600; }
.res-tile-value { font-size: 1.55rem; line-height: 1.2; }
.res-tile-sub { color: var(--muted); font-size: .85em; }
.res-tile .chip { align-self: flex-start; }
.res-meter { display: block; height: 6px; border-radius: 4px; background: var(--chip); overflow: hidden; min-width: 60px; }
.res-meter-fill { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.res-meter-fill.warn { background: var(--warn); }
.res-meter-fill.bad { background: var(--err); }
.res-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.res-chart-head h2 { margin: 0 0 8px; }
.res-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.res-chart { margin: 0; }
.res-chart figcaption { color: var(--muted); font-size: .88em; font-weight: 600; margin-bottom: 4px; }
.res-plot { position: relative; }
.res-svg { width: 100%; height: auto; display: block; direction: ltr; touch-action: pan-y; }
.res-grid { stroke: var(--line); stroke-width: 1; }
.res-axis { fill: var(--muted); font-size: 11px; }
.res-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; }
.res-area { fill: var(--brand); opacity: .12; }
.res-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.res-dot-mark { fill: var(--brand); stroke: var(--card); stroke-width: 2; }
.res-tip { position: absolute; top: 0; width: 120px; text-align: center; background: var(--ink); color: var(--card); border-radius: 8px; padding: 3px 6px; font-size: .8em; pointer-events: none; }
.res-table td.num, .res-table th.num { text-align: end; width: 150px; }
.res-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.res-cell .res-meter { width: 110px; }
.res-click { cursor: pointer; }
.res-click:hover td, .res-click:focus td { background: var(--chip); }
.res-links { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 18px; }
.res-foot { margin-top: 8px; }
@media (max-width: 720px) {
  .res-charts { grid-template-columns: 1fr; }
  .res-table td.num, .res-table th.num { width: auto; }
  .res-cell .res-meter { width: 70px; }
}

/* ── قائمة الخوادم في الشريط + صفحة «الخوادم» (/hub) ───────────────────── */
.srv-menu { position: relative; }
.srv-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 8px; }
.srv-menu > summary::-webkit-details-marker { display: none; }
.srv-menu > summary:hover, .srv-menu[open] > summary { background: var(--chip); }
.srv-caret { font-size: .75em; color: var(--muted); }
.srv-list { position: absolute; inset-inline-start: 0; top: calc(100% + 6px); min-width: 230px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); z-index: 20; }
.srv-list a { padding: 8px 12px; border-radius: 8px; color: var(--ink); }
.srv-list a:hover { background: var(--chip); text-decoration: none; }
.srv-list a.on { background: var(--brand); color: var(--brand-ink); }
.hub-pills { align-items: center; margin-bottom: 10px; }
.hub-reload { margin-inline-start: auto; }
.hub-frames { position: relative; height: calc(100vh - 150px); min-height: 480px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.hub-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.hub-frame[hidden] { display: none; }
.hub-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; }
.hub-wait[hidden] { display: none; }
.page:has(#hub) { max-width: none; padding: 12px 12px 12px; }
