:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --brand: #0f5e9c; --brand-ink: #fff; --ok: #1f8a4c; --warn: #b7791f; --bad: #c0392b; --idle: #8a93a5;
  --radius: 8px; --font: "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--brand); cursor: pointer; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 20px 0 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.right { text-align: end; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #12263a; color: #d6dfea; padding: 14px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { font-weight: 700; font-size: 16px; padding: 4px 18px 14px; color: #fff; letter-spacing: .3px; }
.side .logo small { display: block; font-weight: 400; font-size: 11px; color: #8fa6bf; }
.side .group { font-size: 11px; text-transform: uppercase; color: #7f95ad; padding: 12px 18px 4px; letter-spacing: .6px; }
.side a { display: block; color: #d6dfea; padding: 7px 18px; border-inline-start: 3px solid transparent; }
.side a:hover { background: #1b3550; text-decoration: none; }
.side a.on { background: #1b3550; border-inline-start-color: #5fb0f0; color: #fff; }
.main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.top .who { color: var(--muted); }
.top .who a { margin-inline-start: 12px; }
.top .who a.lang { margin-inline-start: 0; font-weight: 600; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.bar .grow { flex: 1; }
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 6px 12px;
  border-radius: 6px; cursor: pointer; }
button:hover { border-color: #b9c1cf; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.danger { color: var(--bad); }
button.small { padding: 2px 8px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff;
  color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc8ee; border-color: var(--brand); }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
label.f input, label.f select, label.f textarea { color: var(--ink); font-size: 14px; }
label.chk { display: flex; gap: 6px; align-items: center; font-size: 13px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 600; margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--muted); }

table.t { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; }
table.t th, table.t td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
table.t th { background: #f8f9fb; font-weight: 600; font-size: 12.5px; color: #475066; white-space: nowrap; position: sticky; top: 0; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click:hover td { background: #f2f7fc; cursor: pointer; }
table.t td.num, table.t th.num { text-align: end; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; max-height: 70vh; overflow-y: auto; border-radius: var(--radius); }
.empty { padding: 18px; color: var(--muted); text-align: center; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #eef0f4; color: #4a5266; }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.warn { background: #fbf0dc; color: var(--warn); }
.badge.bad { background: #fbe5e2; color: var(--bad); }
.badge.idle { background: #eef0f4; color: var(--idle); }
.badge.info { background: #e3eefa; color: var(--brand); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); text-decoration: none; }

.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: min(720px, 100%); padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; }
.span2 { grid-column: span 2; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.err { color: var(--bad); margin-top: 10px; min-height: 1em; }
.secret { background: #fff8e5; border: 1px solid #f0d58a; padding: 10px; border-radius: 6px; word-break: break-all; }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart .barv { width: 100%; background: #5b9bd5; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .lbl { font-size: 10.5px; color: var(--muted); margin-top: 4px; }

.login { max-width: 360px; margin: 12vh auto; }
.login .panel { padding: 26px; }
.login h1 { text-align: center; }
.login form { display: flex; flex-direction: column; gap: 12px; }

.toast { position: fixed; bottom: 20px; inset-inline-end: 20px; background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 99;
  max-width: 420px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.cond { display: grid; grid-template-columns: 1.1fr 1fr .7fr 1fr 1fr 1.1fr 1fr .9fr auto; gap: 6px; align-items: end; margin-bottom: 6px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .grid2, .grid3, .cond { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
.cond > * { min-width: 0; }
.cond input, .cond select, .grid2 input, .grid2 select, .grid3 input, .grid3 select { width: 100%; }

[dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] textarea, [dir="rtl"] button {
  font-family: "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, sans-serif; }
[dir="rtl"] .side .group { letter-spacing: 0; }
[dir="rtl"] .mono, [dir="rtl"] input[type=date], [dir="rtl"] input[type=datetime-local] { direction: ltr; unicode-bidi: plaintext; }

/* site configuration (HO -> station) */
.modal:has(.cfgwrap) { width: min(1100px, 100%); }
.cfgwrap { max-height: 70vh; overflow: auto; }
.cfgsec { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.cfgsec label.chk { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.cfgsec textarea { width: 100%; margin-top: 6px; direction: ltr; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
pre.cfgview { max-height: 65vh; overflow: auto; background: #f6f8fa; padding: 10px; border-radius: 6px; direction: ltr; }
