:root {
  --bg: #f4f5f7; --card: #ffffff; --ink: #1d2433; --muted: #6b7385; --line: #e3e6ec; --accent: #2457c5;
  --pass: #1f9d55; --warn: #c98a04; --fail: #d1343e; --error: #7b3fc4; --none: #9aa1ae;
  --pass-soft: #e6f5ec; --warn-soft: #fbf2dc; --fail-soft: #fbe6e7; --error-soft: #efe6f9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --card: #1b2029; --ink: #e6e9ef; --muted: #98a0b0; --line: #2b3240; --accent: #7aa2ff;
    --pass-soft: #163324; --warn-soft: #3a2f12; --fail-soft: #3d1b1f; --error-soft: #2c1d40;
  }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font-family: Vazirmatn, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif; line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
pre { background: var(--bg); padding: .8rem; border-radius: 8px; overflow: auto; text-align: left; }
h1 { font-size: 1.35rem; margin: 0 0 .3rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem; background: var(--card);
          border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); }
.topbar nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.topbar nav a { padding: .3rem .7rem; border-radius: 6px; color: var(--muted); }
.topbar nav a.on { background: var(--bg); color: var(--ink); font-weight: 600; }
.who { margin-inline-start: auto; display: flex; gap: .6rem; align-items: center; color: var(--muted); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 6px; padding: .45rem 1rem; background: var(--accent); color: #fff; }
button.link { background: none; color: var(--accent); padding: 0; }

main { max-width: 1400px; margin: 0 auto; padding: 1.2rem 1.5rem; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.clip { max-width: 38rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { white-space: pre-wrap; word-break: break-word; }
.message { max-width: 50rem; font-size: .88rem; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.summary .card { margin: 0; }
.summary .monitor { grid-column: span 2; }
.label { color: var(--muted); font-size: .82rem; }
.big { font-size: 1.6rem; font-weight: 700; }
.m-running { border-inline-start: 4px solid var(--pass); }
.m-stopped { border-inline-start: 4px solid var(--warn); }
.m-silent { border-inline-start: 4px solid var(--fail); }
.s-PASS-soft { background: var(--pass-soft); } .s-WARN-soft { background: var(--warn-soft); }
.s-FAIL-soft { background: var(--fail-soft); } .s-ERROR-soft { background: var(--error-soft); }
.alert { border-color: var(--fail); background: var(--fail-soft); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: start; padding: .45rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; white-space: nowrap; }
tr.disabled td { opacity: .55; }
tr.row-bad td { background: var(--fail-soft); }
tr.row-warn td { background: var(--warn-soft); }

.badge { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; color: #fff; white-space: nowrap; }
.s-PASS { background: var(--pass); } .s-WARN { background: var(--warn); } .s-FAIL { background: var(--fail); }
.s-ERROR { background: var(--error); } .s-NONE { background: var(--none); } .s-overdue { background: var(--ink); }
.n-sent { background: var(--pass); } .n-failed { background: var(--fail); } .n-queued { background: var(--warn); } .n-log_only { background: var(--none); }

.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.ranges { display: flex; gap: .25rem; flex-wrap: wrap; }
.ranges a { padding: .25rem .65rem; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: .85rem; }
.ranges a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.stats { display: flex; gap: 2rem; flex-wrap: wrap; margin: .8rem 0; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 1.25rem; }
.strip { display: flex; flex-wrap: wrap; gap: 2px; direction: ltr; margin: .6rem 0; }
.strip a { width: 9px; height: 22px; border-radius: 2px; }
.chart { position: relative; height: 240px; }
.chart.small { height: 150px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1rem; }
.metric .label { margin-bottom: .2rem; }
.shot { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.filter { display: flex; gap: .4rem; }
select, input { font: inherit; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); }

/* Tooltip box placed by tooltips.js for any element with data-tip (hover, or tap/focus on phones). */
.tipbox { position: fixed; z-index: 50; max-width: min(300px, 86vw); white-space: normal; text-align: start;
          background: var(--ink); color: var(--card); padding: .45rem .65rem; border-radius: 6px;
          font-size: .8rem; font-weight: 400; line-height: 1.6; box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
          pointer-events: none; }
.tipbox[hidden] { display: none; }
.tip { display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; border-radius: 50%;
       background: var(--line); color: var(--muted); font-size: .72rem; font-weight: 700; cursor: help;
       margin-inline-start: .25rem; vertical-align: middle; outline: none; }
.badge[data-tip], .cam, span[data-tip] { cursor: help; outline: none; }
.check-title { font-weight: 600; }
.tech { color: var(--muted); font-size: .72rem; direction: ltr; text-align: end; font-family: ui-monospace, Consolas, monospace; opacity: .8; }
.tech-inline { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: isolate; }
.thumb { display: block; flex: none; }
.thumb img { width: 240px; max-width: 100%; height: 150px; object-fit: cover; object-position: top;
             border: 1px solid var(--line); border-radius: 8px; display: block; }
td .thumb img { width: 120px; height: 75px; }
.incident-list { display: grid; gap: .8rem; }
.incident, .failure { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.incident { padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
.incident:last-child { border-bottom: 0; padding-bottom: 0; }
.failure ul.plain li { border: 0; padding: .2rem 0; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { width: min(360px, 92vw); display: flex; flex-direction: column; gap: .8rem; }
.login label { display: flex; flex-direction: column; gap: .3rem; color: var(--muted); font-size: .9rem; }
.login h1 { text-align: center; }
.error { color: var(--fail); margin: 0; }

@media (max-width: 800px) {
  .table-wrap { overflow-x: auto; }  /* tables scroll sideways on phones */
  .incident, .failure { flex-direction: column; }
  .grid2 { grid-template-columns: 1fr; }
  .summary .monitor { grid-column: auto; }
  main, .topbar { padding-inline: 1rem; }
}
