/*
 * One stylesheet, no framework, no external font.
 *
 * The Content-Security-Policy forbids any external origin, which is only possible because nothing
 * here loads one. That is not asceticism: an admin panel that pulls a CDN stylesheet has handed a
 * third party the ability to inject script into the page where somebody blocks a release.
 *
 * The palette is dark by default because this is a tool used at night during incidents, with exactly
 * three semantic colours — ok, warn, bad — so that "is this bad" is answerable from across a desk.
 */

:root {
  --bg:        #0e1117;
  --bg-soft:   #161b23;
  --bg-lift:   #1c2330;
  --line:      #2a3240;
  --line-soft: #212836;
  --text:      #d7dee9;
  --text-dim:  #8b97a8;
  --text-mute: #5f6b7c;

  --ok:   #3fb950;
  --warn: #d29922;
  --bad:  #f85149;
  --accent: #4f8cff;

  --ok-bg:   rgba(63, 185, 80, .12);
  --warn-bg: rgba(210, 153, 34, .12);
  --bad-bg:  rgba(248, 81, 73, .12);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Vazirmatn", sans-serif;
  --r: 8px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa; --bg-soft: #ffffff; --bg-lift: #f0f3f6;
    --line: #d5dbe2; --line-soft: #e4e9ee;
    --text: #1f2530; --text-dim: #5b6673; --text-mute: #8a94a1;
    --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e; --accent: #0969da;
    --ok-bg: rgba(26,127,55,.10); --warn-bg: rgba(154,103,0,.10); --bad-bg: rgba(207,34,46,.10);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--sans); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 6px; font-weight: 600; color: var(--text-dim); }
p  { margin: 0 0 10px; }
.lede { color: var(--text-dim); margin: 0 0 18px; max-width: 68ch; }
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---- shell ------------------------------------------------------------ */

.shell { display: flex; min-height: 100vh; }
.shell.rtl { direction: rtl; }

.side {
  width: 210px; flex: 0 0 210px; background: var(--bg-soft);
  border-inline-end: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 16px 16px 12px; font-weight: 650; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }

.navlist { list-style: none; margin: 0; padding: 4px 8px; flex: 1; }
.navlist a {
  display: block; padding: 6px 10px; border-radius: 6px; color: var(--text-dim);
  font-size: 13px;
}
.navlist a:hover { background: var(--bg-lift); color: var(--text); text-decoration: none; }
.navlist a.on { background: var(--bg-lift); color: var(--text); font-weight: 600; }

.sidefoot { border-top: 1px solid var(--line); padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { display: flex; flex-direction: column; gap: 2px; color: var(--text); font-size: 12px; }
.who:hover { text-decoration: none; }
.role { font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-mute); }
.role-owner { color: var(--warn); }
.linkbtn { background: none; border: 0; color: var(--text-mute); cursor: pointer; font: inherit; font-size: 12px; padding: 0; }
.linkbtn:hover { color: var(--bad); }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; max-width: 1400px; }

/* ---- mode + flash ----------------------------------------------------- */

.modebar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px 12px; margin-bottom: 16px; font-size: 12.5px; color: var(--text-dim);
}
.chip {
  font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 2px 7px;
  border-radius: 999px; background: var(--bg-lift); color: var(--text-dim); border: 1px solid var(--line);
}
.chip.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: transparent; }

.flash { border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--bg-soft); }
.flash-ok    { border-color: var(--ok);   background: var(--ok-bg); }
.flash-error { border-color: var(--bad);  background: var(--bad-bg); }
.flash-info  { border-color: var(--accent); }
.flash pre { font-family: var(--mono); font-size: 12.5px; }

/* ---- cards + grid ----------------------------------------------------- */

.grid { display: grid; gap: 14px; margin-bottom: 20px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

.card {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 16px;
}
.card.tight { padding: 10px 12px; }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.stat .k { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }
.stat .sub { font-size: 11.5px; color: var(--text-dim); }
.v.ok { color: var(--ok); } .v.warn { color: var(--warn); } .v.bad { color: var(--bad); }

/* ---- banner ----------------------------------------------------------- */

.banner { border-radius: var(--r); padding: 14px 16px; margin-bottom: 18px; border: 1px solid; }
.banner.ok   { border-color: var(--ok);   background: var(--ok-bg); }
.banner.bad  { border-color: var(--bad);  background: var(--bad-bg); }
.banner.warn { border-color: var(--warn); background: var(--warn-bg); }
.banner h2 { margin: 0 0 2px; font-size: 16px; }

.issue { border-top: 1px solid var(--line-soft); padding: 10px 0; }
.issue:first-of-type { border-top: 0; }
.issue .code { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.issue .why { color: var(--text-dim); margin: 3px 0 0; }
.issue .fix { font-family: var(--mono); font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.issue .fix::before { content: "→ "; color: var(--text-mute); }

/* ---- tables ----------------------------------------------------------- */

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-soft); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 12px; text-align: start; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); font-weight: 600; background: var(--bg-lift); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-lift); }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-bad { color: var(--bad); } .t-muted { color: var(--text-mute); }

/* ---- forms ------------------------------------------------------------ */

label { display: block; font-size: 12px; color: var(--text-dim); margin: 0 0 4px; }
label.inline { display: flex; align-items: center; gap: 7px; margin: 8px 0; color: var(--text); font-size: 13px; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=url],
input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 10px; font: inherit; font-size: 13px;
}
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.field { margin-bottom: 12px; }
.hint { font-size: 11.5px; color: var(--text-mute); margin-top: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .fit { flex: 0 0 auto; }

button, .btn {
  background: var(--bg-lift); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 13px; font: inherit; font-size: 13px; cursor: pointer;
  display: inline-block; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--text-mute); text-decoration: none; }
button.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
button.danger  { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); font-weight: 600; }
button.ghost   { background: none; }
button:disabled { opacity: .45; cursor: not-allowed; }

fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin: 0 0 14px; }
legend { font-size: 12px; color: var(--text-dim); padding: 0 6px; }

/* ---- composed command ------------------------------------------------- */

.cmd {
  background: var(--bg); border: 1px solid var(--line); border-inline-start: 3px solid var(--accent);
  border-radius: 6px; padding: 9px 12px; font-family: var(--mono); font-size: 12.5px;
  display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
}
.cmd pre { flex: 1; min-width: 0; }
.cmd button { flex: none; font-size: 11px; padding: 3px 8px; }

/* ---- misc ------------------------------------------------------------- */

.spark { display: block; width: 100%; height: 26px; }
.bar { height: 6px; border-radius: 999px; background: var(--bg-lift); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.ok > span { background: var(--ok); } .bar.warn > span { background: var(--warn); } .bar.bad > span { background: var(--bad); }

.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--text-mute); }
.kv dd { margin: 0; word-break: break-word; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 7px 12px; color: var(--text-dim); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }

.logbox {
  background: #07090d; color: #c7d0da; border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.5;
  max-height: 68vh; overflow: auto; white-space: pre;
}

.authpage { max-width: 380px; margin: 8vh auto; }
.authpage .card { padding: 22px 24px; }
.secretbox {
  font-family: var(--mono); font-size: 16px; letter-spacing: .08em; text-align: center;
  background: var(--bg); border: 1px dashed var(--line); border-radius: 6px; padding: 12px; margin: 10px 0;
  user-select: all;
}

.warnbox { border: 1px solid var(--warn); background: var(--warn-bg); border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; }
.badbox  { border: 1px solid var(--bad);  background: var(--bad-bg);  border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; }
.okbox   { border: 1px solid var(--ok);   background: var(--ok-bg);   border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; }
.notebox { border: 1px solid var(--line); background: var(--bg-soft); border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; color: var(--text-dim); }

.check { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 13px; }
.check .mark { flex: none; width: 14px; font-weight: 700; }
.check .mark.y { color: var(--ok); } .check .mark.n { color: var(--bad); } .check .mark.o { color: var(--text-mute); }
.check .detail { color: var(--text-mute); font-family: var(--mono); font-size: 11.5px; word-break: break-all; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .side { width: 100%; flex: none; height: auto; position: static; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .navlist { display: flex; flex-wrap: wrap; gap: 2px; }
  .main { padding: 16px 14px 50px; }
}
