/* The panel's hub (panel.explore.com.sa, hub.js): every site at a glance and the
   server's status. Built on the editor's tokens and pieces (../admin.css): the
   same light and dark colours, buttons, menus, sign-in card and toasts. */
body.hub { overflow: auto; height: auto; min-height: 100%; font-size: 13.5px; }
html[lang="ar"] body.hub { font-size: 14px; }
body.hub.booting #hub { visibility: hidden; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.hub-top { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; height: 56px; padding: 0 16px; background: var(--glass); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.hub-top .brand { gap: 10px; }
.hub-top .brand-name { font-size: 14px; }
.hub-mark { background: linear-gradient(135deg, #2a2925, #5a554b); }
:root[data-theme="dark"] .hub-mark { background: linear-gradient(135deg, #46433c, #76705f); }
.hub-tabs { display: flex; gap: 2px; padding: 3px; background: var(--field-2); border-radius: 10px; }
.hub-tabs button { display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 14px; border-radius: 8px; border: 0; background: none; font-weight: 500; font-size: 13px; color: var(--muted); transition: background .12s, color .12s; }
.hub-tabs button:hover { color: var(--ink); }
.hub-tabs button.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px rgba(0, 0, 0, .04); }
.hub-tabs button.on svg { color: var(--accent); }
.hub-tabs .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.hub-end { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

.hub-main { max-width: 1240px; margin: 0 auto; padding: 30px 24px 72px; }
.hub-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.hub-head h1 { font: 600 30px/1.2 var(--serif); margin: 0; letter-spacing: -.01em; }
html[lang="ar"] .hub-head h1 { font-family: var(--font); font-size: 26px; letter-spacing: 0; }
.hub-head p { margin: 6px 0 0; color: var(--muted); }
.hub-head .side { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }

/* ---------- status chips: always an icon and a word with the colour ---------- */
.flag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border-radius: 999px; font: 600 11.5px/1 var(--font); white-space: nowrap; background: var(--field-2); color: var(--ink-2); }
.flag.ok { background: var(--tint-ok); color: var(--ok); }
.flag.warn { background: var(--pend-soft); color: var(--pend-ink); }
.flag.crit { background: var(--tint-danger); color: var(--danger); }
.flag.off { color: var(--muted); }
.flag .ic { flex: none; }
.flag.lg { height: 26px; padding: 0 10px 0 8px; font-size: 12.5px; gap: 6px; }

/* ---------- the sites ---------- */
.srv-strip { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; width: 100%; margin: 0 0 18px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; text-align: start; color: inherit; box-shadow: var(--shadow); }
.srv-strip:hover { border-color: var(--line-strong); }
.srv-strip .facts { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.srv-strip .facts b { color: var(--ink); font-weight: 600; }
.srv-strip .go { margin-inline-start: auto; color: var(--muted); display: flex; align-items: center; gap: 4px; font-size: 12.5px; }
html[dir="rtl"] .srv-strip .go .ic, html[dir="rtl"] .site-open .ic { transform: scaleX(-1); }

.site-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.site-card { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.site-card-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.site-card-head .brandmark { width: 44px; height: 44px; border-radius: 13px; font-size: 21px; }
.site-card-head h2 { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.3; }
.site-card-head a { color: var(--muted); text-decoration: none; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.site-card-head a:hover { color: var(--sel); }
.site-facts { list-style: none; margin: 0; padding: 4px 18px 14px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.site-facts li { display: flex; align-items: center; gap: 9px; min-height: 22px; color: var(--ink-2); }
.site-facts li > .ic { color: var(--faint); }
.site-facts li .muted { margin-inline-start: auto; font-size: 12px; text-align: end; }
.site-facts .skel { height: 12px; border-radius: 6px; background: var(--field-2); flex: 1; max-width: 70%; }
.site-card-foot { display: flex; gap: 8px; padding: 14px 18px 18px; border-top: 1px solid var(--line-2); }
.site-open { flex: 1; }
.site-card-foot .btn { height: 36px; text-decoration: none; }
.site-card-foot .btn:not(.primary) { color: var(--ink); }

/* ---------- the server ---------- */
.srv-note { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--field-2); color: var(--ink-2); font-size: 12.5px; margin-bottom: 18px; }
.srv-note .ic { color: var(--muted); }
.srv-note b { font-weight: 600; }
.srv-note .grow { min-width: 8px; }
.empty-card { max-width: 620px; margin: 40px auto; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 34px 30px; box-shadow: var(--shadow); }
.empty-card .ic { margin: 0 auto 12px; color: var(--muted); }
.empty-card h2 { font: 600 22px/1.3 var(--serif); margin: 0 0 8px; }
html[lang="ar"] .empty-card h2 { font-family: var(--font); font-size: 19px; }
.empty-card p { color: var(--muted); margin: 0 auto; max-width: 460px; line-height: 1.6; }
.empty-card code { font: 12px var(--mono); background: var(--field-2); padding: 1px 5px; border-radius: 5px; }

.alerts { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 18px; overflow: hidden; box-shadow: var(--shadow); }
.alerts-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: 600; }
.alerts-head .muted { font-weight: 400; font-size: 12.5px; }
.alerts ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-2); }
.alerts li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line-2); }
.alerts li:last-child { border-bottom: 0; }
.alerts li .what { flex: 1; min-width: 0; }
.alerts li .what small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.alerts li .flag { margin-top: 1px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 12px; box-shadow: var(--shadow); min-width: 0; }
.kpi-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi-label .flag { margin-inline-start: auto; }
.kpi-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 8px; }
.kpi-value b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1; white-space: nowrap; }
.kpi-value span { color: var(--muted); font-size: 12px; }
.kpi-foot { color: var(--faint); font-size: 11.5px; margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; }
.meter { height: 6px; border-radius: 3px; background: var(--field-2); overflow: hidden; margin-top: 12px; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--muted); }
.meter.warn > i { background: var(--pend); }
.meter.crit > i { background: var(--danger); }

/* 24-hour sparkline: the line recedes, the latest point is in the accent */
.spark { position: relative; margin-top: 10px; height: 38px; touch-action: none; }
.spark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.spark .line { fill: none; stroke: var(--faint); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-dot { position: absolute; width: 8px; height: 8px; border-radius: 50%; transform: translate(-50%, -50%); background: var(--accent); box-shadow: 0 0 0 2px var(--panel); pointer-events: none; }
.spark-dot.hov { background: var(--ink); z-index: 1; }
.spark-cross { position: absolute; top: -2px; bottom: -2px; width: 1px; transform: translateX(-50%); background: var(--line-strong); pointer-events: none; }
.spark-tip { position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); background: var(--inv); color: var(--inv-ink); font-size: 11.5px; padding: 4px 8px; border-radius: 7px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); z-index: 2; }
.spark-tip b { font-weight: 600; }
.spark-none { display: grid; place-items: center; height: 38px; margin-top: 10px; border-radius: 8px; background: var(--field); color: var(--faint); font-size: 11.5px; }

.srv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.srv-grid > .wide { grid-column: 1 / -1; }
.hbox { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 0; }
.hbox-head { display: flex; align-items: center; gap: 9px; padding: 13px 16px; border-bottom: 1px solid var(--line-2); }
.hbox-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.hbox-head > .ic { color: var(--muted); }
.hbox-head .muted { margin-inline-start: auto; font-size: 12px; }
.hbox-body { padding: 12px 16px 14px; }
.hbox-empty { padding: 16px; color: var(--muted); font-size: 12.5px; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: start; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 8px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl td.end, .tbl th.end { text-align: end; white-space: nowrap; }
.tbl td .muted { font-size: 11.5px; }
.tbl .name { font-weight: 500; color: var(--ink); }
.tbl .who { display: flex; align-items: center; gap: 9px; }
.tbl .sub { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; margin-top: 1px; }
.tbl .mono { font: 12px var(--mono); }
.tbl tr.group td { background: var(--field); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 6px 12px; }
.tbl a { color: inherit; text-decoration: none; }
.tbl a:hover { color: var(--sel); text-decoration: underline; }

.facts-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 12.5px; }
.facts-list dt { color: var(--muted); }
.facts-list dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }

.runs { list-style: none; margin: 0; padding: 0; }
.runs li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.runs li:last-child { border-bottom: 0; }
.runs .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runs .mono { font: 12px var(--mono); color: var(--muted); }
.runs time { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 84px; text-align: end; }
.deploy + .deploy { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.deploy-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 600; }
.deploy-head .muted { font-weight: 400; font-size: 12px; }

.disk-row + .disk-row { margin-top: 12px; }
.disk-row .top { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.disk-row .top b { font-weight: 600; }
.disk-row .top .muted { margin-inline-start: auto; font-size: 12px; }
.disk-row .meter { margin-top: 6px; }

.errors-box { margin-top: 18px; }
.errors-box summary { cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 6px 0; }
.errors-box ul { margin: 6px 0 0; padding-inline-start: 18px; color: var(--muted); font: 12px/1.6 var(--mono); }

@media (max-width: 860px) {
  .srv-grid { grid-template-columns: minmax(0, 1fr); }
  .hub-top { grid-template-columns: auto 1fr auto; padding: 0 10px; }
  .hub-top .brand-name { display: none; }
  .hub-tabs { justify-self: center; }
  .hub-main { padding: 22px 16px 60px; }
}
@media (max-width: 520px) {
  .hub-tabs button { padding: 0 10px; }
  .hub-tabs button span.lbl { display: none; }
  .hub-head h1 { font-size: 24px; }
  .site-cards { grid-template-columns: minmax(0, 1fr); }
  #hub-updated { display: none; }
}
