/* ══════════════════════════════════════════════════════════════════════
   Meridian — admin interface
   ══════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f1f4f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --border: #dfe5ee;
  --border-soft: #eaeff6;
  --text: #0f1b2d;
  --text-2: #33415a;
  --muted: #6b7a90;
  --faint: #97a3b6;

  --brand: #1d4ed8;
  --brand-2: #2563eb;
  --brand-soft: #e8eefc;
  --brand-ink: #16307d;

  --ok: #157f4a;      --ok-soft: #e2f5ea;
  --warn: #b45309;    --warn-soft: #fdf0dc;
  --danger: #c0272d;  --danger-soft: #fdeaea;
  --info: #0e7490;    --info-soft: #e0f4f8;
  --purple: #7c3aed;  --purple-soft: #f0e9fe;

  --sidebar: #0d1b30;
  --shadow-1: 0 1px 2px rgba(16,32,58,.06), 0 1px 3px rgba(16,32,58,.05);
  --shadow-2: 0 2px 6px rgba(16,32,58,.07), 0 8px 24px rgba(16,32,58,.07);

  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080e1a; --surface: #101a2c; --surface-2: #16233a; --surface-3: #1c2b45;
    --border: #24344f; --border-soft: #1c2a41;
    --text: #e8eefa; --text-2: #c2cee1; --muted: #8b9bb4; --faint: #6b7c96;
    --brand: #5b8def; --brand-2: #7aa5f5; --brand-soft: #172544; --brand-ink: #a9c4fb;
    --ok: #4ade80; --ok-soft: #12301f;
    --warn: #fbbf24; --warn-soft: #35270c;
    --danger: #f87171; --danger-soft: #391616;
    --info: #38bdf8; --info-soft: #0b2b38;
    --purple: #c4b5fd; --purple-soft: #241a44;
    --sidebar: #070d18;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 2px 8px rgba(0,0,0,.45), 0 12px 32px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
body.centred { display: grid; place-items: center; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 660; letter-spacing: -.02em; margin: 0 0 3px; }
h2 { font-size: 14.5px; font-weight: 640; margin: 0; }
code { font-family: var(--mono); font-size: .92em; }
.mono { font-family: var(--mono); font-size: .92em; }
.faint { color: var(--faint); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.centre { text-align: center; }
.ar { font-family: "Segoe UI", Tahoma, sans-serif; color: var(--muted); font-weight: 500; }

/* ────────────────────────────── top bar ────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 22px;
  background: var(--sidebar); color: #cddaee;
  padding: 0 22px; height: 58px; flex: 0 0 58px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  background: linear-gradient(140deg, #3b82f6, #1e3a8a 70%);
  display: grid; place-items: center;
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-mark.lg { width: 44px; height: 44px; border-radius: 12px; }
.brand-mark.lg svg { width: 24px; height: 24px; }
.brand-name { color: #fff; font-weight: 650; font-size: 15px; display: block; line-height: 1.15; }
.brand-sub { color: #7f93b3; font-size: 10.5px; display: block; }

.nav { display: flex; gap: 2px; flex: 1; }
.nav a {
  color: #b9c6da; padding: 7px 12px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.on { background: #142440; color: #fff; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { text-align: end; line-height: 1.2; }
.who-name { color: #dde6f4; font-size: 12.5px; font-weight: 600; display: block; }
.who-role { color: #6f83a3; font-size: 10.5px; display: block; }
.inline { display: inline; }

.foot {
  padding: 14px 24px; color: var(--faint); font-size: 11.5px;
  display: flex; gap: 8px; border-top: 1px solid var(--border);
}
.dot-sep { opacity: .5; }

/* ─────────────────────────────── layout ────────────────────────────── */

.wrap { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 22px 24px 40px; }

.page-head {
  display: flex; align-items: flex-end; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.page-head-main { display: flex; align-items: center; gap: 14px; }
.page-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.sub { color: var(--muted); font-size: 13.5px; margin: 0; }

.split { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 14px; }

@media (max-width: 1000px) {
  .split, .grid2 { grid-template-columns: minmax(0,1fr); }
  .nav a { padding: 7px 9px; }
}
@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .brand-text, .who { display: none; }
  .wrap { padding: 16px 12px 32px; }
}

/* ──────────────────────────────── cards ────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  margin-bottom: 16px; overflow: hidden;
}
.stack .card, .split .card { margin-bottom: 0; }
.card-head {
  padding: 13px 18px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2 { flex: 1; min-width: 0; }
.card-head .link, .card-head .faint { font-size: 12px; }
.card-body { padding: 16px 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border-soft); background: var(--surface-2); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ───────────────────────────────── KPIs ────────────────────────────── */

.kpi-row {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 16px; margin-bottom: 16px;
}
@media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 15px 16px; box-shadow: var(--shadow-1);
}
.kpi-label {
  font-size: 11px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 7px;
}
.kpi-value { font-size: 25px; font-weight: 660; letter-spacing: -.025em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-value.sm { font-size: 17px; text-transform: capitalize; }
.kpi-foot { margin-top: 7px; font-size: 11.5px; color: var(--muted); }

/* ──────────────────────────────── chips ────────────────────────────── */

.chip {
  display: inline-flex; align-items: center; height: 21px; padding: 0 8px;
  border-radius: 20px; font-size: 11px; font-weight: 620; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); text-transform: lowercase;
}
.chip.high, .chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.medium, .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.low, .chip.muted { background: var(--surface-3); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.method-rss { background: var(--info-soft); color: var(--info); }
.chip.method-api { background: var(--ok-soft); color: var(--ok); }
.chip.method-html { background: var(--surface-3); color: var(--muted); }
.chip.method-headless { background: var(--warn-soft); color: var(--warn); }

.code {
  display: inline-grid; place-items: center; min-width: 30px; height: 22px;
  padding: 0 7px; border-radius: 6px; background: var(--brand-soft);
  color: var(--brand-ink); font-family: var(--mono); font-size: 11.5px; font-weight: 700;
}
.code.lg { min-width: 44px; height: 32px; font-size: 15px; border-radius: 8px; }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--border-soft);
  font-size: 11px; color: var(--text-2);
}
.tags { display: flex; flex-wrap: wrap; gap: 5px; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.idle { background: var(--faint); }

/* ──────────────────────────────── tables ───────────────────────────── */

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: start; font-size: 10.5px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; padding: 9px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tr.click { cursor: pointer; }
table.tbl tr.click:hover { background: var(--surface-2); }

/* ─────────────────────────────── sources ───────────────────────────── */

.src-list { display: flex; flex-direction: column; }
.src {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 18px; border-bottom: 1px solid var(--border-soft);
}
.src:last-child { border-bottom: 0; }
.src .dot { margin-top: 6px; }
.src-main { flex: 1; min-width: 0; }
.src-name { font-size: 13px; font-weight: 570; }
.src-url { font-size: 11.5px; color: var(--muted); word-break: break-all; direction: ltr; }
.src-meta { font-size: 11px; color: var(--faint); margin-top: 3px; }
.src-note { font-size: 11.5px; color: var(--warn); margin-top: 4px; }
.src-right { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.jur-title { flex: 1; min-width: 0; }

/* ───────────────────────────── bars & rows ─────────────────────────── */

.bar-row { margin-bottom: 13px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.bar-count { margin-inline-start: auto; font-weight: 650; font-variant-numeric: tabular-nums; }
.bar-note { font-size: 11px; color: var(--faint); margin-top: 4px; }
.meter { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.fill-rss { background: var(--info); }
.fill-api { background: var(--ok); }
.fill-html { background: var(--muted); }
.fill-headless { background: var(--warn); }

.row-line {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px;
}
.row-line:last-child { border-bottom: 0; }
.row-num { margin-inline-start: auto; font-weight: 650; font-variant-numeric: tabular-nums; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px;
}
.feed li:last-child { border-bottom: 0; }
.feed-text { flex: 1; min-width: 0; }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; font-size: 12.5px; }
.dl dt { color: var(--muted); font-weight: 550; }
.dl dd { margin: 0; }
.note { font-size: 12.5px; color: var(--text-2); line-height: 1.55; margin: 12px 0 0; }

pre.code {
  background: var(--sidebar); color: #d6e2f5; border-radius: var(--r);
  padding: 14px 16px; margin: 0; font-family: var(--mono); font-size: 11.5px;
  line-height: 1.6; overflow-x: auto; direction: ltr;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ──────────────────────────────── forms ────────────────────────────── */

.field { display: block; margin-bottom: 14px; }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.req { color: var(--danger); font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.hint { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; padding: 8px 11px; outline: none;
  transition: border-color .13s, box-shadow .13s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.input.mono { font-family: var(--mono); font-size: 12px; }
.ar-input { direction: rtl; text-align: right; }
.textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.textarea.sm { min-height: 60px; }
.select { appearance: none; padding-inline-end: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8l3-3.5' fill='none' stroke='%236b7a90' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px; }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.switch.block { display: flex; padding: 6px 0; font-size: 13px; }
.switch input { accent-color: var(--brand); width: 15px; height: 15px; }

.row-form { display: flex; gap: 8px; align-items: center; }
.row-form .input { flex: 1; }

.src-editor {
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 15px 4px; margin-bottom: 12px; background: var(--surface-2);
}
.src-editor legend {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 0 0 10px; font-size: 12px;
}
.src-index { font-weight: 660; color: var(--text-2); }
.src-editor legend .switch { margin-inline-start: auto; }

.sticky-save { position: sticky; top: 16px; }

.timer {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: var(--ok-soft); color: var(--ok); padding: 5px 11px; border-radius: 20px;
}
.timer.over { background: var(--warn-soft); color: var(--warn); }

/* ─────────────────────────────── buttons ───────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background .13s, border-color .13s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); }
.btn-ghost { border-color: transparent; background: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { height: 29px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.link { color: var(--brand); font-size: 12.5px; }

/* ─────────────────────────────── alerts ────────────────────────────── */

.alert {
  padding: 12px 15px; border-radius: var(--r); margin-bottom: 18px;
  font-size: 13px; line-height: 1.55; border: 1px solid transparent;
}
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert ul { margin: 8px 0 0; padding-inline-start: 20px; }
.alert li { margin-bottom: 3px; }

.empty { padding: 32px 18px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-page { text-align: center; padding: 80px 20px; }
.empty-code { font-size: 56px; font-weight: 700; color: var(--faint); letter-spacing: -.03em; }
.empty-page h1 { margin: 8px 0 6px; }
.empty-page p { color: var(--muted); margin: 0 0 20px; }

/* ──────────────────────────────── login ───────────────────────────── */

.login-wrap { display: grid; place-items: center; padding: 24px; width: 100%; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 30px 28px; box-shadow: var(--shadow-2);
}
.login-head { text-align: center; margin-bottom: 22px; }
.login-head .brand-mark { margin: 0 auto 14px; }
.login-head h1 { font-size: 21px; margin-bottom: 2px; }
.login-head p { color: var(--muted); font-size: 13px; margin: 0; }
.login-foot { text-align: center; color: var(--faint); font-size: 11px; margin: 20px 0 0; line-height: 1.5; }
