/* OpenTrends admin: light theme, responsive, no framework. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #52606d;
  --border: #d5dbe1;
  --accent: #1f6feb;
  --accent-dark: #1a5bd0;
  --ok: #1a7f37;
  --ok-bg: #e7f5ea;
  --warn: #8a5a00;
  --warn-bg: #fff6dc;
  --error: #b3261e;
  --error-bg: #fdecea;
  --info: #1f6feb;
  --info-bg: #e8f0fe;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3 { line-height: 1.3; margin: 0 0 12px; font-weight: 650; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 20px; }
p { margin: 0 0 10px; }
ul, ol { margin: 0 0 10px; padding-left: 1.4rem; }

.mono { font-family: var(--mono); font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.wrap { overflow-wrap: anywhere; word-break: break-word; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.ok-text { color: var(--ok); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.error-text { color: var(--error); }

/* ---- layout ---- */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a, .session a {
  display: inline-block; padding: 5px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 0.9375rem;
}
.nav a:hover, .session a:hover { background: #eef2f6; color: var(--text); }
.nav a.active, .session a.active { background: var(--info-bg); color: var(--accent); font-weight: 600; }
.session { margin-left: auto; display: flex; align-items: center; gap: 4px; }

.page { max-width: 1160px; margin: 0 auto; padding: 20px; }
.footer { max-width: 1160px; margin: 0 auto; padding: 12px 20px 28px; color: var(--muted); font-size: 0.8125rem; }
.crumbs { margin-bottom: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card.narrow { max-width: 720px; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.grid-2 > .card { margin-bottom: 18px; }

/* ---- status text: colour plus a label or sign, never colour alone ---- */

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
  border: 1px solid transparent; vertical-align: middle;
}
.badge-ok { color: var(--ok); background: var(--ok-bg); border-color: #b7dfc1; }
.badge-fail { color: var(--error); background: var(--error-bg); border-color: #f3b9b5; }
.badge-run { color: var(--info); background: var(--info-bg); border-color: #b9cff7; }
.badge-info { color: var(--info); background: var(--info-bg); border-color: #b9cff7; }
.badge-pause, .badge-warn { color: var(--warn); background: var(--warn-bg); border-color: #eed9a0; }
.badge-push { color: var(--accent); background: var(--info-bg); border-color: #b9cff7; }
.badge-muted { color: var(--muted); background: #eef1f4; border-color: var(--border); }

.level { font-weight: 600; }
.level-info { color: var(--muted); }
.level-warning { color: var(--warn); }
.level-error, .level-critical { color: var(--error); font-weight: 700; }

.flash, .alert, .result {
  padding: 10px 14px; border-radius: var(--radius); margin: 0 0 14px;
  border: 1px solid; overflow-wrap: anywhere;
}
.flash-ok, .result-ok { color: var(--ok); background: var(--ok-bg); border-color: #b7dfc1; }
.flash-error, .alert-error, .result-error { color: var(--error); background: var(--error-bg); border-color: #f3b9b5; }
.alert-warn { color: var(--warn); background: var(--warn-bg); border-color: #eed9a0; }
.alert-title { font-weight: 700; margin-bottom: 6px; }
.alert ul { margin: 0; }
.alert ul li + li { margin-top: 4px; }
/* A notice to act on, not only a status: a heavier edge and a titled list */
.alert-notice { border-left-width: 4px; }
.result-title { font-weight: 700; margin-bottom: 6px; }
.result .muted { color: inherit; opacity: 0.85; }

/* ---- overview ---- */

.status-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 1.05rem; margin-bottom: 10px; }
.clock { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.kv {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 18px; margin: 0 0 12px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fafbfc;
}
.stat-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-label { color: var(--muted); font-size: 0.875rem; }

.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.check { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.check .mark {
  display: inline-block; width: 1.5em; text-align: center; font-weight: 700; border-radius: 50%;
}
.check-ok .mark { color: var(--ok); background: var(--ok-bg); }
.check-warn .mark { color: var(--warn); background: var(--warn-bg); }
.check-off .mark { color: var(--muted); background: #eef1f4; }

/* ---- buttons and forms ---- */

.btn {
  display: inline-block; padding: 6px 14px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.9375rem; line-height: 1.5; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f0f3f6; color: var(--text); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-small { padding: 2px 10px; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: 0.55; cursor: not-allowed; }
.btn.disabled:hover { background: var(--surface); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 6px; }
.inline-form { display: inline; }

.field { margin-bottom: 14px; min-width: 0; }
.field label, .filters label, .search label {
  display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.9375rem;
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 16px; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"],
input[type="file"], select, textarea {
  width: 100%; max-width: 34rem; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 0.9375rem; color: var(--text); background: var(--surface);
}
input[type="number"] { max-width: 12rem; }
select { max-width: 18rem; }
textarea { max-width: none; resize: vertical; }
textarea.mono { font-size: 0.875rem; line-height: 1.5; }
input[disabled], select[disabled] { background: #f0f3f6; }

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; max-width: none; margin: 0; }
.check label { display: inline; margin: 0; font-weight: 600; }
.check.small, .check.small label { font-size: 0.875rem; font-weight: 400; }
.check.small { margin-top: 6px; }

.search, .filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.filters select, .filters input[type="search"] { max-width: 16rem; width: auto; min-width: 11rem; }
.filters label { display: inline; margin: 0; }

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

.table-wrap { overflow-x: auto; }
.table-wrap.scroll-y { max-height: 60vh; overflow: auto; }
/* Four columns do not fit a phone: each keeps a readable width and the block
   scrolls sideways instead of squeezing the text to a character a line */
.compared th, .compared td { min-width: 9rem; }
.compared th:nth-child(3), .compared td:nth-child(3) { min-width: 6rem; }
.compared th:last-child, .compared td:last-child { min-width: 14rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.875rem; white-space: nowrap; background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f7f9fb; }
td.num, th.num { text-align: right; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; font-size: 0.9375rem; }

/* ---- run detail ---- */

.top-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.top-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.top-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 8px; }
.top-head .rank { font-weight: 700; color: var(--muted); }
.top-head .top-title { font-weight: 650; font-size: 1.05rem; flex: 1 1 14rem; min-width: 0; }
.top-item .kv { grid-template-columns: max-content minmax(0, 1fr); margin: 0; }

details.box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 18px; margin-bottom: 18px;
}
details.box > summary { cursor: pointer; padding: 10px 0; font-weight: 650; }
details.box[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
details.box h3:first-of-type { margin-top: 12px; }

pre.mono {
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  max-height: 26rem; overflow: auto; margin: 0 0 12px;
  padding: 10px 12px; background: #f7f8fa; border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.875rem; line-height: 1.5;
}
ul.plain { list-style: none; padding-left: 0; }
ul.plain > li { padding: 2px 0; }

/* what each monitoring setting does, under the form */
.param-notes { margin-top: 14px; color: var(--muted); }
.param-notes strong { color: var(--text); }
.card > details.box:last-child { margin-bottom: 0; }

.empty {
  padding: 26px 16px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
}

.error-card h2 { display: flex; align-items: baseline; gap: 12px; }
.error-code { color: var(--error); font-weight: 700; }

/* ---- login ---- */

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 22rem; padding: 28px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 4px 18px rgba(15, 30, 60, 0.08);
}
.login-card h1 { font-size: 1.3rem; }
.login-card .btn { margin-top: 4px; }

/* ---- narrow screens ---- */

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; gap: 4px 8px; }
  .brand { flex-basis: 100%; }
  .session { margin-left: auto; }
  .page { padding: 14px 12px; }
  .card { padding: 14px 14px; }
}
@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; gap: 0 12px; }
  .kv dt { margin-top: 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  input[type="text"], input[type="password"], input[type="search"] { max-width: none; }
  .btn { padding: 6px 12px; }
}
