/* Ferrete Cloud: one stylesheet, no inline styles (blocked by our CSP). */
/* Self-hosted fonts (SIL Open Font License, see static/fonts/OFL-*.txt) */
@font-face { font-family: "Archivo"; src: url("fonts/archivo.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --bg: #111214; --surface: #1A1C1F; --sunken: #151618; --line: #2A2D31; --line-soft: #22252A; --line-strong: #3A3E44;
  --text: #ECEAE4; --text-2: #C9C8C1; --muted: #A3A39C; --accent: #FF7A3D; --accent-ink: #111214;
  --info-bg: #1E2A3D; --info: #8AB8FF; --info-text: #D7E6FF; --warn-bg: #3A2418; --warn: #FFB08A; --warn-text: #FFD9C7;
  --bad-bg: #3A1A1A; --bad: #FF9A9A; --radius: 10px;
  --font: "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --display: Archivo, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-kerning: normal; }
table, .stat strong, .mono, .hash, progress + span { font-variant-numeric: tabular-nums; }
a { color: var(--text); }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font: 800 30px/1.1 var(--display); font-stretch: 112%; }
h2 { font-size: 17px; font-weight: 600; }
p { margin: 0; }
code, pre, .mono, textarea.code { font-family: var(--mono); font-size: 13px; font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }
h1.mono { font: 500 28px/1.15 var(--mono); }
pre { margin: 0; padding: 14px 16px; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; line-height: 1.6; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .soft { color: var(--text-2); } .small { font-size: 13px; }
.ok-text { color: var(--info); } .warn-text { color: var(--warn); } .bad-text { color: var(--bad); }
.stack { display: flex; flex-direction: column; gap: 16px; } .stack-sm { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; } .between { justify-content: space-between; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-wide { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > .main { flex: 999 1 560px; min-width: 0; } .split > .side { flex: 1 1 300px; min-width: 0; }
.wrap { word-break: break-all; }

/* ---------- header ---------- */
.topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 6px; }
.brand span { font: 700 14px var(--display); font-stretch: 125%; letter-spacing: 0.18em; }
.wsname { padding: 9px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs a { padding: 10px 14px; border-radius: 8px; text-decoration: none; color: var(--muted); }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); }
.iconbtn { position: relative; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--text); background: none; border: none; cursor: pointer; text-decoration: none; }
.iconbtn[aria-current="page"] { background: var(--surface); }
.dot { position: absolute; top: 8px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; text-decoration: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.page { max-width: 1320px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 20px; }
.page.narrow { max-width: 960px; }
.page.narrow .grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.rowlink { text-decoration: none; padding: 6px 0; }
.rowlink:hover .mono { color: var(--accent); }
textarea.code.short { min-height: 0; }
input[type=file] { color: var(--text-2); font: inherit; }
input[type=file]::file-selector-button { margin-right: 12px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.pagehead { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.crumb { font-size: 13px; color: var(--muted); text-decoration: none; }

/* ---------- settings layout ---------- */
.settings { max-width: 1320px; margin: 0 auto; padding: 0 24px; display: flex; flex-wrap: wrap; gap: 32px; }
.settings nav { flex: 1 1 220px; max-width: 250px; padding: 24px 0; display: flex; flex-direction: column; gap: 2px; }
.settings nav .group { font-size: 12px; color: var(--muted); padding: 14px 10px 6px; }
.settings nav a { padding: 9px 10px; border-radius: 6px; text-decoration: none; color: var(--text-2); }
.settings nav a[aria-current="page"] { background: var(--surface); color: var(--text); }
.settings main { flex: 999 1 640px; min-width: 0; padding: 28px 0 64px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- surfaces ---------- */
.card { border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card.flush > .cardhead { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.cardhead { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; }
.danger-zone { border-color: #6B2B2B; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.stat strong { font: 800 30px/1.1 var(--display); }
.stat.info strong { color: var(--info); } .stat.warn strong { color: var(--warn); } .stat.bad strong { color: var(--bad); }
.callout { padding: 14px 16px; border-radius: var(--radius); background: var(--info-bg); color: var(--info-text); }
.callout.warn { background: var(--warn-bg); color: var(--warn-text); }
.callout.bad { background: var(--bad-bg); color: #FFD2D2; }
.flashes { display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 12px 16px; border-radius: var(--radius); background: var(--info-bg); color: var(--info-text); }
.flash.error { background: var(--bad-bg); color: #FFD2D2; } .flash.warn, .flash.secret { background: var(--warn-bg); color: var(--warn-text); }
.flash.secret { font-family: var(--mono); font-size: 13px; word-break: break-all; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 500; }
.field .hint { color: var(--muted); font-size: 13px; }
.field .error { color: var(--bad); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 11px 13px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); font: inherit; min-height: 44px; }
textarea { resize: vertical; line-height: 1.55; }
textarea.code { min-height: 260px; tab-size: 4; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
input[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--bad); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 2px; }
.toggle-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.digits { display: flex; gap: 8px; justify-content: space-between; }
.digits input { width: 48px; height: 56px; text-align: center; font: 22px var(--mono); padding: 0; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 500; margin-bottom: 8px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; border: 1px solid transparent; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { color: var(--accent-ink); filter: brightness(1.06); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--line-strong); font-weight: 500; }
.btn-danger { background: transparent; color: var(--bad); border-color: #6B2B2B; font-weight: 500; }
.btn-quiet { background: none; border: none; color: var(--muted); padding: 8px; font-weight: 500; text-decoration: underline; }
.btn[disabled], .btn[aria-disabled=true] { background: var(--line); color: #B4B4AD; border-color: var(--line); cursor: not-allowed; filter: none; }
.btn.block { width: 100%; }
form.inline { display: inline; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 16px; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.card:not(.flush) .tablewrap { margin: 0 -22px; }
td select { min-height: 38px; padding: 6px 10px; width: auto; }
.person { display: flex; gap: 10px; align-items: center; }
.person small { display: block; color: var(--muted); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- tags and status ---------- */
.tag { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--line-soft); color: var(--text-2); white-space: nowrap; }
.tag.info, .tag.Verified, .tag.verified, .tag.Approved { background: var(--info-bg); color: var(--info); }
.tag.warn, .tag.Needs-approval, .tag.Re-approve, .tag.Running, .tag.running { background: var(--warn-bg); color: var(--warn); }
.tag.bad, .tag.Failing, .tag.not_verified, .tag.error { background: var(--bad-bg); color: var(--bad); }

/* ---------- module + review ---------- */
.req { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.req b { font-family: var(--mono); color: var(--accent); min-width: 28px; font-weight: 500; }
.hash { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); word-break: break-all; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; align-items: baseline; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.timeline { display: flex; flex-direction: column; }
.tl { display: flex; gap: 14px; padding-bottom: 14px; }
.tl .n { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--bad); display: flex; align-items: center; justify-content: center; font: 12px var(--mono); flex: none; }
.tl .n.ok { border-color: var(--info); }
details summary { cursor: pointer; color: var(--text-2); }

/* ---------- meters ---------- */
progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 4px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 4px; }
progress::-webkit-progress-value { background: var(--info); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--info); border-radius: 4px; }
.meter { padding: 16px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 8px; }

/* ---------- inbox ---------- */
.note { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.note.unread { background: var(--surface); }
.note .pip { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--muted); flex: none; }
.note .pip.approval_requested, .note .pip.lock_invalidated { background: var(--warn); }
.note .pip.build_failed, .note .pip.rollback { background: var(--bad); }
.note .pip.member_joined { background: var(--info); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 48px 20px; gap: 28px; }
.auth .panel { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.auth .panel h1 { font-size: 28px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.authfoot { color: var(--muted); font-size: 13px; }
.authfoot a { color: var(--muted); }
.secretbox { padding: 12px 14px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; font: 14px var(--mono); word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; font-family: var(--mono); }

/* ---------- error ---------- */
.errorpage { max-width: 760px; margin: 0 auto; padding: 120px 24px; display: flex; flex-direction: column; gap: 20px; align-items: flex-start; }
.errorpage .code { font-family: var(--mono); color: var(--accent); }
.errorpage h1 { font-size: clamp(34px, 5vw, 56px); }

@media (max-width: 720px) {
  .page, .settings { padding-left: 16px; padding-right: 16px; }
  .settings nav { max-width: none; flex-direction: row; flex-wrap: wrap; padding-bottom: 0; }
  .settings nav .group { width: 100%; }
  .card { padding: 18px; } .card:not(.flush) .tablewrap { margin: 0 -18px; }
  h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Proposed-change diffs */
.diff { font: 13px/1.55 var(--mono); font-variant-ligatures: none; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 0; overflow-x: auto; max-height: 360px; overflow-y: auto; }
.diff > div { padding: 0 14px; white-space: pre; }
.diff-add { background: rgba(138, 184, 255, 0.12); color: #CFE0FF; }
.diff-del { background: rgba(255, 154, 154, 0.12); color: #FFC9C9; }
.diff-meta { color: var(--text-2); }
ul.plain { list-style: none; margin: 0; padding: 0; }

/* Charts (server-rendered SVG) */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis, .chart .label, .chart .value { fill: var(--text-2); font: 12px var(--font); font-variant-numeric: tabular-nums; }
.chart .label { fill: var(--text); }
.c-ok { fill: #8AB8FF; } .c-bad { fill: #FF9A9A; } .c-warn { fill: #FFB08A; } .c-accent { fill: var(--accent); } .c-muted { fill: #5B606A; }
.spark { width: 160px; height: 40px; display: block; }
.spark polyline { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.s-accent { stroke: var(--accent); } .s-ok { stroke: #8AB8FF; } .s-bad { stroke: #FF9A9A; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .l-ok { background: #8AB8FF; } .legend .l-bad { background: #FF9A9A; } .legend .l-warn { background: #FFB08A; } .legend .l-accent { background: var(--accent); }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi strong { font: 700 30px/1.1 var(--display, var(--font)); font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 13px; color: var(--text-2); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; }

/* Operator panel */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; align-items: start; }
.board .column { gap: 10px; }
.pcard { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: inherit; text-decoration: none; background: var(--bg); }
.pcard:hover, .pcard:focus-visible { border-color: var(--accent); }
.userrow { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; padding: 16px 20px; border-top: 1px solid var(--line); }

input[type=date] { color-scheme: dark; }
.admin nav .tag { align-self: flex-start; margin: 2px 0 8px; }
.board { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.inline-form .field { flex: 1 1 280px; margin: 0; }
