:root {
  --ink: #14211f;
  --ink-soft: #4a5c58;
  --muted: #7b8c88;
  --line: #dfe6e3;
  --bg: #f6f8f7;
  --card: #ffffff;
  --accent: #04635a;
  --accent-soft: #e6f2f0;
  --warn: #8a5a00;
  --warn-bg: #fdf5e3;
  --err: #9b1c1c;
  --err-bg: #fdeceb;
  --ok: #0f5132;
  --ok-bg: #e8f5ee;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  letter-spacing: .08em;
  padding: 5px 7px;
  border-radius: 5px;
}
.brand-text { font-size: 16px; letter-spacing: .01em; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: var(--ink-soft);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 14px;
}
.nav a:hover { background: var(--accent-soft); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
form.inline { display: inline; }
button.link {
  background: none; border: 0; color: var(--ink-soft); cursor: pointer;
  font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 6px;
}
button.link:hover { background: var(--accent-soft); }

main.wrap { padding-top: 26px; padding-bottom: 60px; min-height: 60vh; }

/* ---------- headings ---------- */
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; margin-bottom: 22px; flex-wrap: wrap;
}
.muted { color: var(--muted); }
.mini { font-size: 12.5px; }
.warn { color: var(--warn); }
.err { color: var(--err); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.grid-4 {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 20px;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin: 60px auto; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.editor-main { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.editor-side .card { margin-bottom: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- readable article preview (display only, no effect on the stored article) ---------- */
.read-view { border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 22px; }
.read-view .mini { margin: 0 0 12px; }
.read-title { font-size: 26px; line-height: 1.25; margin: 0 0 10px; }
.read-standfirst { font-size: 16px; line-height: 1.5; color: var(--ink-soft); margin: 0 0 16px; }
.read-image { width: 100%; height: auto; border-radius: var(--radius); margin: 0 0 18px; }
.read-body { font-size: 15.5px; line-height: 1.65; color: var(--ink); }
.read-body p { margin: 0 0 14px; }
.read-body h2 { font-size: 18px; line-height: 1.35; margin: 24px 0 10px; }
.read-body h2:first-child { margin-top: 0; }
.raw-html { margin-bottom: 16px; }
.raw-html summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 6px 0; }
.raw-html textarea { margin-top: 8px; }

/* Read / Edit tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 16px; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab-on { color: var(--ink); border-bottom-color: var(--ink); }
.edit-pane { border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 22px; }
.rich-edit {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px 16px;
  background: #fff; min-height: 220px;
}
.rich-edit:focus { outline: 2px solid var(--bde-brand-primary-color, #2563eb); outline-offset: 1px; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 14px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
textarea { resize: vertical; line-height: 1.55; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.checkline { display: flex; align-items: center; gap: 9px; font-weight: 500; margin-bottom: 10px; }
.checkline input { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

button.primary, .btn {
  display: inline-block; padding: 9px 15px; font: inherit; font-size: 14px; font-weight: 600;
  border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  cursor: pointer;
}
button.primary:hover, .btn:hover { background: #03524a; text-decoration: none; }
.btn.small { padding: 5px 10px; font-size: 13px; }
button.ghost, .btn.ghost { background: #fff; color: var(--ink-soft); border-color: var(--line); }
button.ghost:hover, .btn.ghost:hover { background: var(--bg); color: var(--ink); }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 10px; border-bottom: 1px solid #eef2f0; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafcfb; }

.score {
  display: inline-block; min-width: 34px; text-align: center; padding: 3px 6px;
  border-radius: 5px; background: var(--accent-soft); color: var(--accent);
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px;
}
.score-low { background: #f2f4f3; color: var(--muted); }

/* ---------- pills & chips ---------- */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
  background: #eef2f0; color: var(--ink-soft);
}
.pill-draft { background: var(--warn-bg); color: var(--warn); }
.pill-approved { background: var(--accent-soft); color: var(--accent); }
.pill-published { background: var(--ok-bg); color: var(--ok); }
.pill-rejected, .pill-failed { background: var(--err-bg); color: var(--err); }
.pill-new { background: #eef2f0; color: var(--ink-soft); }
.pill-written { background: var(--ok-bg); color: var(--ok); }
.pill-skipped { background: #f2f4f3; color: var(--muted); }

.switches, .filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  display: inline-block; padding: 5px 11px; border-radius: 20px; font-size: 12.5px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-soft);
}
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-link { border-style: dashed; }
.chip-off { color: var(--muted); }

/* ---------- flashes ---------- */
.flashes { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 11px 14px; border-radius: 7px; font-size: 14px; border: 1px solid var(--line);
  background: var(--card);
}
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash-success { background: var(--ok-bg); border-color: #c9e6d5; color: var(--ok); }
.flash-error { background: var(--err-bg); border-color: #f3cdc9; color: var(--err); }
.flash-warning { background: var(--warn-bg); border-color: #f0e0bd; color: var(--warn); }

/* ---------- article editor bits ---------- */
.preview {
  width: 100%; border-radius: 6px; display: block; background: #f0f3f2;
}
.preview.empty {
  aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; border: 1px dashed var(--line);
}
.facts { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-soft); }
.facts li { margin-bottom: 4px; }
.level { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.level-info { color: var(--accent); }
.level-warning { color: var(--warn); }
.level-error { color: var(--err); }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 18px 0; background: var(--card); }
.footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12.5px; }

@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .nav { gap: 0; }
}
@media (max-width: 560px) {
  .two-col { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
}
