/* ResearchDart operations console. Shares tokens and outcome colours with the public site. */

@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("../fonts/schibsted-grotesk-variable.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2"); }

:root {
  --paper: #f2f4f1;
  --paper-raised: #e8ece7;
  --surface: #ffffff;
  --ink: #17262b;
  --ink-soft: #4a5a5f;
  --ink-faint: #71807f;
  --rule: #d6ddd9;
  --route: #0e6b66;
  --route-deep: #0a4f4b;
  --route-wash: #dcebe8;
  --complete: #1e7a4c;
  --terminate: #93600a;
  --overquota: #3558a8;
  --quality: #b23a3a;
  --font-sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--route-deep); }
:focus-visible { outline: 3px solid var(--route); outline-offset: 2px; }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }

.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--ink); color: #cfdad7; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 800; padding: 0 8px 20px; }
.sidebar .brand svg { width: 24px; height: 24px; }
.sidebar .brand svg path { stroke: #ffffff; }
.sidebar .brand svg circle { stroke: #7fd1c7; }
.sidebar .brand svg circle:last-child { fill: #7fd1c7; }
.sidebar nav a { display: block; color: #cfdad7; text-decoration: none; padding: 8px 10px; border-radius: 6px; margin-bottom: 2px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a[aria-current="page"] { background: var(--route); color: #fff; }
.sidebar .group { font-size: 0.8rem; color: #8ea3a0; padding: 16px 10px 6px; }
.sidebar form button { background: none; border: 0; color: #cfdad7; font: inherit; padding: 8px 10px; cursor: pointer; }
.badge-count { background: var(--quality); color: #fff; border-radius: 999px; font-size: 0.75rem; padding: 1px 7px; margin-left: 6px; }

.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head p { color: var(--ink-soft); margin: 4px 0 0; }
.page-head select { width: auto; min-width: 160px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar .group { display: none; }
}

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; margin: 0 0 20px; overflow: hidden; }
.metric { padding: 14px 16px; background: var(--surface); }
.metric dt { color: var(--ink-soft); font-size: 0.85rem; }
.metric dd { margin: 2px 0 0; font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 0.82rem; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

.status-complete { --status: var(--complete); }
.status-terminate { --status: var(--terminate); }
.status-overquota { --status: var(--overquota); }
.status-quality { --status: var(--quality); }
.status-in_progress, .status-draft, .status-paused, .status-closed { --status: var(--ink-faint); }
.status-live, .status-active, .status-published, .status-sent { --status: var(--complete); }
.status-failed { --status: var(--quality); }
.status-pending { --status: var(--terminate); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--status, var(--ink-soft)); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--status, var(--ink-faint)); }

.button { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 0.9rem; padding: 9px 14px; border-radius: 6px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; line-height: 1.2; }
.button:hover { border-color: var(--ink); }
.button-primary { background: var(--route); border-color: var(--route); color: #fff; }
.button-primary:hover { background: var(--route-deep); border-color: var(--route-deep); }
.button-danger { color: var(--quality); }
.button-small { padding: 5px 10px; font-size: 0.82rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="url"], input[type="number"], input[type="password"], input[type="date"], input[type="datetime-local"], select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 6px; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14'%3E%3Cpath d='M2 5.2 5 2.2l3 3M2 8.8l3 3 3-3' fill='none' stroke='%2371807f' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-size: 10px 14px; background-position: right 12px center; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--route); box-shadow: 0 0 0 3px var(--route-wash); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.code-chip { display: inline-block; min-width: 22px; text-align: center; font-family: var(--font-mono); font-size: 0.76rem; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 4px; }
.gdq-line { white-space: nowrap; padding: 2px 0; font-size: 0.85rem; }
.status-flagged, .status-unavailable { --status: var(--terminate); }
.status-blocked { --status: var(--quality); }
.status-passed { --status: var(--complete); }
.status-reversed { --status: var(--quality); }
.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.segmented label { border: 1px solid var(--rule); border-radius: 8px; padding: 12px; font-weight: 400; cursor: pointer; margin: 0; background: #fff; }
.segmented label:has(input:checked) { border-color: var(--route); box-shadow: 0 0 0 1px var(--route); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented strong { display: block; font-size: 0.92rem; }
.segmented span { display: block; color: var(--ink-faint); font-size: 0.8rem; margin-top: 2px; }
@media (max-width: 760px) { .segmented { grid-template-columns: 1fr; } }
textarea.editor { min-height: 460px; font-family: var(--font-mono); font-size: 0.88rem; line-height: 1.6; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }
.check strong { display: block; }
.hint { color: var(--ink-faint); font-size: 0.84rem; margin-top: 4px; }
.error { color: var(--quality); font-size: 0.84rem; margin-top: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters > div { min-width: 140px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; background: var(--route-wash); border: 1px solid #b7d4cf; }
.flash-error { background: #f8e3e3; border-color: #e7b9b9; }
.secret-reveal { background: #fff4d6; border: 1px solid #e9cf86; padding: 14px 16px; border-radius: 8px; margin-bottom: 18px; }

.link-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.link-row:last-child { border-bottom: 0; }
.link-row code { background: var(--paper); padding: 7px 9px; border-radius: 6px; overflow-x: auto; white-space: nowrap; display: block; }
@media (max-width: 760px) { .link-row { grid-template-columns: 1fr; } }

.progress { height: 6px; background: var(--paper-raised); border-radius: 3px; overflow: hidden; min-width: 80px; }
.progress span { display: block; height: 100%; background: var(--route); }

dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
dl.facts dt { color: var(--ink-soft); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

.empty { color: var(--ink-soft); padding: 24px 0; text-align: center; }
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .panel { width: 100%; max-width: 380px; }
