/*
 * Mabry
 * Copyright (c) 2018 by Benjamin Critton & Colophon Foundry. All rights reserved.
 * Mabry is a trademark of Colophon Foundry. http://www.colophon-foundry.org
 * Web font licence: licensed to Mercive ApS.
 * For an up-to-date licence agreement please visit: http://www.colophon-foundry.org
 */
@font-face { font-family: "Mabry"; font-weight: 300; font-style: normal; font-display: swap; src: url("/static/fonts/mabry-light.woff2") format("woff2"); }
@font-face { font-family: "Mabry"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/fonts/mabry-regular.woff2") format("woff2"); }
@font-face { font-family: "Mabry"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/fonts/mabry-medium.woff2") format("woff2"); }

/* =====================================================================
   Mercive design tokens (Mercive design rules v9).
   Light mode only. Adjust here; everything below reads from these.
   ===================================================================== */
:root {
  color-scheme: light;

  /* Colour */
  --ink: #1d1d1d;            /* text, primary buttons, header */
  --muted: #616161;          /* secondary text, labels */
  --bg: #ffffff;             /* page and cards */
  --soft: #f6f6f6;           /* secondary buttons, table heads, error-page backdrop */
  --soft-hover: #ececec;
  --line: #e1e1e1;           /* borders and dividers */
  --line-strong: #d1d1d1;    /* inputs */
  --placeholder: #767676;
  --lime: #cdea19;           /* the single accent: live, ready, selected */
  --lime-edge: #a9c20f;
  --danger: #c0261c;         /* destructive, errors */
  --danger-bg: #fdf4f3;
  --danger-line: #f0c7c3;
  --warn-text: #7a5200;      /* caution badges (mock / estimated data) */
  --warn-bg: #fff3d6;
  --header-muted: #b5b5b5;   /* secondary text on the ink header */
  --header-line: #4a4a4a;

  /* Type */
  --font: "Mabry", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-body: 15px;
  --fs-small: 13px;
  --fs-button: 14px;
  --fs-badge: 12px;
  --fs-card-title: 20px;
  --fs-page-title: 32px;
  --fs-tile: 26px;
  --track-section: 0.02em;
  --track-header: 0.04em;

  /* Layout */
  --header-h: 52px;
  --content: 960px;
  --content-wide: 1320px;
  --pad: 20px;
  --section-gap: 56px;
  --field-gap: 18px;
  --list-gap: 12px;

  /* Shape and motion */
  --radius: 4px;
  --radius-button: 2px;
  --fade: 150ms ease;
}

/* =====================================================================
   Base
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
h1 { font-size: var(--fs-page-title); font-weight: 500; letter-spacing: -0.015em; line-height: 1.15; }
h2 { font-size: var(--fs-card-title); font-weight: 500; letter-spacing: -0.01em; line-height: 1.25; }
h3 { font-size: 16px; font-weight: 500; line-height: 1.35; }
strong, b { font-weight: 500; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, pre { font-family: var(--font-mono); font-size: 13px; }
code { background: var(--soft); padding: 1px 5px; border-radius: 3px; overflow-wrap: anywhere; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--pad); top: -100px; z-index: 20;
  background: var(--bg); color: var(--ink); padding: 8px 12px; border-radius: var(--radius);
}
.skip-link:focus { top: 8px; }

.num, .tabular { font-variant-numeric: tabular-nums; }
.break-anywhere { overflow-wrap: anywhere; }

/* =====================================================================
   Header: 52px, sticky, dark (internal tool)
   ===================================================================== */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--ink); color: #fff;
}
.top-inner {
  display: flex; align-items: center; gap: 20px;
  height: var(--header-h);
  padding: 0 var(--pad);
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; flex-shrink: 0; }
.brand img { width: 105px; height: 23px; }
.header-label {
  font-size: var(--fs-small); font-weight: 500; text-transform: uppercase; letter-spacing: var(--track-header);
  color: var(--header-muted); padding-left: 12px; border-left: 1px solid var(--header-line); line-height: 1;
  white-space: nowrap;
}
.top-nav { display: flex; gap: 18px; font-size: var(--fs-small); }
.top-nav a { color: var(--header-muted); text-decoration: none; white-space: nowrap; transition: color var(--fade); }
.top-nav a:hover { color: #fff; }
.top-nav a.active { color: #fff; text-decoration: underline; text-underline-offset: 6px; }
.top-user { margin-left: auto; display: flex; gap: 14px; font-size: var(--fs-small); color: var(--header-muted); min-width: 0; }
.top-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-user a { color: #fff; text-decoration: none; white-space: nowrap; }
.top-user a:hover { text-decoration: underline; }
.top-user form { margin: 0; display: flex; }
.top-user button {
  padding: 0; border: 0; background: none; color: #fff; min-height: 0;
  font: 400 var(--fs-small)/1.5 var(--font); white-space: nowrap;
}
.top-user button:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
.top :focus-visible { outline-color: #fff; }

.notice {
  background: var(--soft); border-bottom: 1px solid var(--line);
  font-size: var(--fs-small); font-weight: 300; color: var(--ink);
}
.notice .wrap { padding-top: 8px; padding-bottom: 8px; }

/* =====================================================================
   Page layout
   ===================================================================== */
.wrap { width: 100%; max-width: calc(var(--content) + 2 * var(--pad)); margin: 0 auto; padding-left: var(--pad); padding-right: var(--pad); }
.wrap.wide { max-width: calc(var(--content-wide) + 2 * var(--pad)); }
.page { flex: 1 0 auto; padding-top: 40px; padding-bottom: 96px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-meta { font-size: var(--fs-small); font-weight: 300; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }
.page-meta a { color: var(--ink); }

section, .section { margin-top: var(--section-gap); }
.section-label {
  display: block;
  font-size: var(--fs-small); font-weight: 500; text-transform: uppercase; letter-spacing: var(--track-section);
  color: var(--ink); margin: 0 0 16px; line-height: 1.4;
}
.section-label::before { content: ">"; margin-right: 8px; }
.section-label .aside { text-transform: none; letter-spacing: 0; font-weight: 300; color: var(--muted); margin-left: 6px; }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--bg); }
.card + .card { margin-top: var(--list-gap); }
.card h2 { margin-bottom: 8px; }

.hint { font-size: var(--fs-small); font-weight: 300; color: var(--muted); margin-top: 6px; }
.meta { font-size: var(--fs-small); font-weight: 300; color: var(--muted); font-variant-numeric: tabular-nums; }
.meta a { color: var(--muted); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 12px; }
.sep { color: var(--line-strong); }

.site-footer { border-top: 1px solid var(--line); flex-shrink: 0; }
.site-footer .wrap { padding-top: 16px; padding-bottom: 16px; }
.footer-label { font-size: var(--fs-small); font-weight: 500; text-transform: uppercase; letter-spacing: var(--track-header); color: var(--muted); }

/* =====================================================================
   Buttons: 2px radius, 14px medium. One primary per view.
   ===================================================================== */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 var(--fs-button)/1.2 var(--font);
  padding: 8px 14px;
  border-radius: var(--radius-button);
  border: 1px solid var(--ink);
  background: var(--ink); color: #fff;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--fade), color var(--fade), border-color var(--fade);
}
.btn:hover, button:hover { background: #000; text-decoration: none; }
.btn.secondary { background: var(--soft); border-color: var(--soft); color: var(--ink); }
.btn.secondary:hover { background: var(--soft-hover); border-color: var(--soft-hover); }
.btn.danger { background: var(--soft); border-color: var(--soft); color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: var(--fs-small); font-weight: 400; }
.btn[disabled], button[disabled], .btn.disabled { opacity: 0.4; pointer-events: none; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions:empty { display: none; }

/* =====================================================================
   Badges and dots
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center;
  font-size: var(--fs-badge); font-weight: 400; line-height: 1.5;
  padding: 2px 7px; border-radius: var(--radius);
  background: var(--soft); color: var(--muted);
  white-space: nowrap; text-decoration: none; vertical-align: middle;
}
a.badge:hover { background: var(--soft-hover); }
.badge.live { background: var(--lime); color: var(--ink); font-weight: 500; }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.error { background: var(--danger-bg); color: var(--danger); }
.badge.ink { background: var(--ink); color: #fff; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: var(--line-strong); flex-shrink: 0; }
.dot.live { background: var(--lime); box-shadow: 0 0 0 1px var(--lime-edge); }
.dot.ink { background: var(--ink); }
.dot.dot-error { background: var(--danger); }
.status { display: inline-flex; align-items: center; font-size: var(--fs-small); }

/* =====================================================================
   Forms: single column, label above, one-line hint below
   ===================================================================== */
form.form { max-width: 560px; }
.field { margin-top: var(--field-gap); }
.field:first-child, .section-label + .field { margin-top: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset + fieldset { margin-top: 40px; }
legend { padding: 0; }
label, .label { display: block; font-size: var(--fs-small); font-weight: 500; margin-bottom: 6px; }
label .optional { font-weight: 300; color: var(--muted); margin-left: 6px; }

input[type=text], input[type=number], input[type=url], input[type=email], input[type=date], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff; color: var(--ink);
  font: 400 var(--fs-body)/1.4 var(--font);
  min-height: 42px;
  transition: border-color var(--fade);
}
input[type=date] { -webkit-appearance: none; appearance: none; }
input::placeholder { color: var(--placeholder); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
input:user-invalid { border-color: var(--danger); }
select {
  -webkit-appearance: none; appearance: none; padding-right: 30px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%231d1d1d' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 11px center;
}
.input-uppercase { text-transform: uppercase; }
.form-actions { margin-top: 28px; }

/* Radio choices as bordered cards */
.choices { display: grid; gap: 8px; }
.choice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px; margin: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; font-size: var(--fs-body); font-weight: 400;
  transition: border-color var(--fade);
}
.choice:hover { border-color: var(--line-strong); }
.choice:has(input:checked) { border-color: var(--ink); }
.choice:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.choice input { margin: 4px 0 0; accent-color: var(--ink); }
.choice strong { display: block; font-size: var(--fs-button); font-weight: 500; }
.choice small { display: block; font-size: var(--fs-small); font-weight: 300; color: var(--muted); }

/* =====================================================================
   Feedback
   ===================================================================== */
.error {
  border: 1px solid var(--danger-line); background: var(--danger-bg); color: var(--danger);
  border-radius: var(--radius); padding: 10px 12px; font-size: var(--fs-button);
}
.error-detail {
  margin-top: 8px; padding: 12px 14px;
  background: var(--soft); border-radius: var(--radius); color: var(--ink);
  max-height: 320px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; user-select: text;
}
.success {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 16px; background: var(--lime); color: var(--ink); border-radius: var(--radius);
}
.success-label { font-size: var(--fs-badge); font-weight: 500; text-transform: uppercase; letter-spacing: var(--track-header); }
.success .btn.secondary { background: #fff; border-color: #fff; }

.progress { height: 4px; background: var(--soft); border-radius: 2px; overflow: hidden; margin-top: 12px; }
.progress .fill { height: 100%; background: var(--ink); transition: width 150ms ease; }

/* =====================================================================
   List rows (engagements, run history): bordered cards
   ===================================================================== */
.rows { list-style: none; padding: 0; display: grid; gap: var(--list-gap); }
.row-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 14px; }
.row-title { font-size: var(--fs-card-title); font-weight: 500; letter-spacing: -0.01em; line-height: 1.25; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-title a { text-decoration: none; }
.row-title a:hover { text-decoration: underline; }
.row-link { display: inline-block; margin-top: 2px; color: var(--muted); font-size: var(--fs-small); overflow-wrap: anywhere; }
.row-facts { font-size: var(--fs-small); font-weight: 300; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.row-card .actions .btn { padding: 6px 10px; font-size: var(--fs-small); font-weight: 400; }
.row-card.compact { padding: 14px 16px; gap: 8px; grid-template-columns: 1fr auto; align-items: center; }
.row-card.compact .row-title { font-size: var(--fs-button); letter-spacing: 0; }

/* =====================================================================
   Stat tiles
   ===================================================================== */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.tile-label { font-size: var(--fs-small); font-weight: 300; color: var(--muted); }
.tile-value { font-size: var(--fs-tile); font-weight: 500; letter-spacing: -0.01em; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.2; }

/* =====================================================================
   Tables: soft head, 13px, tabular numbers, hairlines, own scroll box
   ===================================================================== */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap + .hint { margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); white-space: nowrap; }
th { text-align: left; font-weight: 500; color: var(--muted); background: var(--soft); padding: 9px 14px; border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; }
td.text { white-space: normal; min-width: 220px; }

/* Definition list (roster) */
.fields { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; font-size: var(--fs-small); }
.fields dt, .fields dd { padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.fields dt { color: var(--muted); font-weight: 300; padding-right: 16px; }
.fields dd { font-variant-numeric: tabular-nums; }
.fields dt:last-of-type, .fields dd:last-of-type { border-bottom: 0; }
.fields dd:empty::after { content: "-"; color: var(--muted); }

/* Findings */
.findings { display: grid; gap: var(--list-gap); }
.finding { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; font-size: var(--fs-body); }
.finding h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.finding .meta { margin-bottom: 10px; }
.finding p + p { margin-top: 4px; }
.finding .forecast { margin-top: 12px; padding: 10px 12px; background: var(--soft); border-radius: var(--radius); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.finding .basis { margin-top: 8px; }
.sublist { list-style: none; padding: 0; margin-top: 10px; font-size: var(--fs-small); }
.sublist li { padding: 6px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }

.link-list { list-style: none; padding: 0; display: grid; gap: 10px; font-size: var(--fs-body); }
.link-list a { overflow-wrap: anywhere; }

/* =====================================================================
   Standalone error page: one 400px card on soft background
   ===================================================================== */
body.gate { background: var(--soft); align-items: center; justify-content: center; padding: 32px var(--pad); }
.gate-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 36px 32px; }
.gate-card img { width: 105px; height: auto; }
.gate-card h1 { font-size: 26px; line-height: 1.2; margin-top: 28px; }
.gate-card .intro { color: var(--muted); font-weight: 300; margin: 10px 0 24px; }
.gate-card .btn { width: 100%; padding: 12px 14px; font-size: var(--fs-body); }
.gate-card details { margin-top: 16px; font-size: var(--fs-small); color: var(--muted); }
.gate-card summary { cursor: pointer; }
/* Sign-in card (templates/login.html) */
.gate-card .error { margin: -8px 0 20px; }
.gate-form .btn { margin-top: 20px; }
.gate-form .hint { margin-top: 8px; }
.code-input { font-size: 24px !important; font-weight: 500; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.gate-alt { margin-top: 16px; text-align: center; font-size: var(--fs-small); color: var(--muted); }
.gate-alt a { color: var(--muted); }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 720px) {
  .top-inner { height: auto; min-height: var(--header-h); flex-wrap: wrap; row-gap: 0; padding-top: 14px; padding-bottom: 0; }
  .header-label { display: none; }
  .top-nav { order: 3; width: 100%; height: 40px; align-items: center; border-top: 1px solid var(--header-line); margin-top: 14px; }
  h1 { font-size: 28px; }
}
@media (max-width: 520px) {
  .top-user span { display: none; }
  .fields { grid-template-columns: 1fr; }
  .fields dt { border-bottom: 0; padding-bottom: 0; }
  .row-card.compact { grid-template-columns: 1fr; }
  .gate-card { padding: 28px 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
