/* Night-shift palette: deep harbour blue, with colour reserved for meaning.
   Red = needs a person now. Amber = waiting on a person. Teal = handled by automation. */
:root {
    --ink: #0e1a25;
    --panel: #15242f;
    --panel-2: #1b2e3c;
    --line: #2a4152;
    --text: #e7eef2;
    --muted: #93a8b6;
    --red: #f2605f;
    --amber: #f1b445;
    --teal: #45c9b1;
    --sky: #86c1f5;
    --display: "Archivo", "Segoe UI", system-ui, sans-serif;
    --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
    --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
    margin: 0;
    background: var(--ink);
    color: var(--text);
    font: 400 15px/1.5 var(--body);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--sky); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #fff; }

:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3 { font-family: var(--display); margin: 0; }
h1 { font-size: 30px; font-weight: 700; font-stretch: 112%; letter-spacing: -0.01em; line-height: 1.15; }
h2 { font-size: 13px; font-weight: 700; font-stretch: 110%; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin-bottom: 12px; }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 0 4px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

.mono { font-family: var(--mono); font-size: 0.92em; }
.dim { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.skip { position: absolute; left: -999px; top: 8px; background: var(--sky); color: var(--ink); padding: 8px 12px; border-radius: var(--radius); z-index: 10; }
.skip:focus { left: 8px; }

/* ---- Shell ---------------------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }

.rail {
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; color: var(--text); text-decoration: none; }
.brand-mark { grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; background: conic-gradient(var(--teal) 0 62%, var(--amber) 62% 86%, var(--red) 86%); mask: radial-gradient(circle, transparent 7px, #000 8px); }
.brand-name { font: 700 16px/1.1 var(--display); font-stretch: 112%; }
.brand-sub { font-size: 12px; color: var(--muted); }

.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: var(--radius); font-weight: 500; border-left: 2px solid transparent; }
.rail nav a:hover { color: var(--text); background: var(--panel-2); }
.rail nav a[aria-current="page"] { color: var(--text); background: var(--panel-2); border-left-color: var(--teal); }
.nav-gap { height: 14px; }
.signout { margin-top: auto; display: grid; gap: 8px; font-size: 12px; color: var(--muted); }
.signout .btn { justify-self: start; padding: 7px 10px; font-size: 13px; }
.signout + .rail-note { margin-top: 0; }
.rail-note { margin-top: auto; font-size: 12px; line-height: 1.45; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }

main { padding: 28px 32px 56px; max-width: 1320px; width: 100%; }

.page-head { margin-bottom: 18px; }
.lede { color: var(--muted); max-width: 68ch; margin-top: 6px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* ---- Building blocks ------------------------------------------------------------------ */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }

.tag { display: inline-block; font-size: 12px; font-weight: 500; line-height: 1; padding: 4px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; margin-right: 6px; }
.tag-wait, .tag-miss { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.tag-auto, .tag-ok, .tag-done-auto { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 45%, transparent); }
.tag-person, .tag-done { color: var(--sky); border-color: color-mix(in srgb, var(--sky) 45%, transparent); }
.tag-bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.tag-pending { color: var(--text); }

.btn { font: 500 14px/1 var(--body); color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #06221d; font-weight: 600; }
.btn-primary:hover { background: #63d8c2; border-color: #63d8c2; }

.empty { color: var(--muted); padding: 14px 0; }
.footnote { font-size: 13px; color: var(--muted); margin-top: 12px; }
.notice { background: color-mix(in srgb, var(--teal) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--teal) 45%, transparent); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); }
.table th.num { text-align: right; }
.table td { padding: 9px 12px 9px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.split-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-wide { margin: 0 0 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 16px 0 0; }
.stats div { border-top: 1px solid var(--line); padding-top: 10px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font: 700 22px/1.2 var(--display); font-stretch: 108%; }

.reasons { margin: 0; padding-left: 18px; }
.reasons li { margin-bottom: 4px; }

/* ---- Control room --------------------------------------------------------------------- */

.pulse { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.lanes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.lane { padding: 20px 22px 22px; min-width: 0; }
.lane-person { border-right: 1px solid var(--line); border-top: 3px solid var(--amber); border-top-left-radius: var(--radius); }
.lane-auto { border-top: 3px solid var(--teal); border-top-right-radius: var(--radius); }

.lane-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.lane-head h2 { font-size: 26px; font-weight: 800; font-stretch: 122%; letter-spacing: 0; text-transform: none; color: var(--text); margin: 0; }
.lane-count { font: 800 34px/1 var(--display); font-stretch: 100%; }
.lane-person .lane-count { color: var(--amber); }
.lane-auto .lane-count { color: var(--teal); }
.lane-note { font-size: 13px; color: var(--muted); margin: 4px 0 14px; }

.cards, .rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.card { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 14px; padding: 12px; background: var(--panel-2); border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.card:hover, .row:hover { border-color: var(--muted); color: var(--text); }
.card.risk-critical { border-left-color: var(--red); }
.card.risk-high { border-left-color: var(--amber); }
.card.risk-medium { border-left-color: var(--sky); }
.card.risk-low { border-left-color: var(--line); }

.score { display: grid; justify-items: center; align-content: center; text-align: center; }
.score-num { font: 800 26px/1 var(--display); font-stretch: 100%; }
.score-level { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 3px; }
.risk-critical .score-num { color: var(--red); }
.risk-high .score-num { color: var(--amber); }
.risk-medium .score-num { color: var(--sky); }
.score-big .score-num { font-size: 44px; }

.card-body, .row-main { display: grid; gap: 2px; min-width: 0; }
.card-title { font-weight: 600; }
.card-site { color: var(--muted); font-size: 14px; }
.card-why { font-size: 13px; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.card-meta .tag { margin-right: 0; }

.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }

.tally { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.tally-num { display: block; font: 800 28px/1.1 var(--display); color: var(--teal); }
.tally div:last-child .tally-num { color: var(--sky); }
.tally-label { font-size: 12px; color: var(--muted); }

/* ---- Handling trace ------------------------------------------------------------------- */

.track { list-style: none; margin: 0; padding: 0; display: flex; align-items: flex-start; }
.node { position: relative; display: grid; justify-items: center; gap: 4px; width: 52px; font-size: 11px; color: var(--muted); }
.node::before { content: ""; position: absolute; top: 6px; right: 50%; width: 100%; height: 2px; background: var(--line); }
.node:first-child::before { display: none; }
.node-dot { position: relative; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line); }
.node-ok .node-dot { background: var(--teal); border-color: var(--teal); }
.node-ok::before, .node-miss::before, .node-bad::before, .node-pending::before { background: var(--muted); }
.node-miss .node-dot { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 30%, var(--panel)); }
.node-bad .node-dot { border-color: var(--red); background: color-mix(in srgb, var(--red) 30%, var(--panel)); }
.node-pending .node-dot { border-color: var(--text); animation: pulse 1.4s ease-in-out infinite; }
.node-ok .node-name, .node-pending .node-name { color: var(--text); }
.node-person .node-dot { border-radius: 3px; }
.node-handed .node-dot { background: var(--amber); border-color: var(--amber); }
.node-handed::before { background: var(--amber); }
.node-handed .node-name { color: var(--amber); }

.track-labelled { margin-bottom: 16px; }
.track-labelled .node { width: 20%; font-size: 13px; padding: 0 6px; text-align: center; }
.track-labelled .node::before { top: 8px; }
.track-labelled .node-dot { width: 18px; height: 18px; }
.node-detail { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* ---- Event and customer detail -------------------------------------------------------- */

.case-head { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 18px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.case-head.risk-critical { border-left-color: var(--red); }
.case-head.risk-high { border-left-color: var(--amber); }
.case-head.risk-medium { border-left-color: var(--sky); }
.case-head .lede { margin-bottom: 10px; }

.site-name { font: 700 18px/1.2 var(--display); margin-bottom: 4px; }

.contacts, .signals, .audit, .questions { list-style: none; margin: 0; padding: 0; }
.contacts li { display: grid; gap: 1px; padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); font-size: 14px; }
.contacts li:last-child, .signals li:last-child { border-bottom: 0; }
.contact-name { font-weight: 600; }
.contact-role { color: var(--muted); font-size: 13px; }

.signals li { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid color-mix(in srgb, var(--line) 45%, transparent); }
.signals .mono { color: var(--muted); }

.message { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); margin-bottom: 8px; }
.message summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 12px; cursor: pointer; font-size: 14px; }
.message summary .tag { margin-right: 0; min-width: 52px; text-align: center; }
.message-to { flex: 1 1 220px; }
.message-result { flex: 1 1 200px; color: var(--muted); }
.message > p { margin: 0 12px 10px; }
.message-subject { font-weight: 600; }
.message-body { white-space: pre-wrap; font-size: 14px; border-left: 2px solid var(--line); padding-left: 12px; max-width: 70ch; }

.actions form { margin-top: 12px; }
.stack { display: grid; gap: 6px; max-width: 520px; }
.stack button { justify-self: start; }

label { font-size: 13px; font-weight: 500; }
input[type="number"], input[type="search"], input[type="text"], input[type="password"], textarea {
    font: 400 15px/1.4 var(--body); color: var(--text); background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 10px; width: 100%;
}
textarea { resize: vertical; }
::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }

.audit li { display: grid; grid-template-columns: 178px 132px minmax(0, 1fr); gap: 12px; padding: 8px 0 8px 12px; border-left: 2px solid var(--line); font-size: 14px; }
.audit-auto { border-left-color: var(--teal) !important; }
.audit-person { border-left-color: var(--sky) !important; }
.audit-time { color: var(--muted); white-space: nowrap; }
.audit-actor { font-weight: 600; }
.audit-auto .audit-actor { color: var(--teal); }
.audit-person .audit-actor { color: var(--sky); }

/* ---- Customers, messages -------------------------------------------------------------- */

.search { display: flex; gap: 8px; max-width: 560px; margin-bottom: 16px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filters a { color: var(--muted); text-decoration: none; padding: 7px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 14px; }
.filters a[aria-current="page"] { color: var(--text); border-color: var(--teal); background: var(--panel); }

/* ---- Automation ----------------------------------------------------------------------- */

.workflow { border-left-width: 4px; }
.workflow-on { border-left-color: var(--teal); }
.workflow-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.workflow-head h2 { font-size: 20px; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 4px; }

.policy { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); counter-reset: step; }
.policy li { counter-increment: step; position: relative; padding: 26px 12px 0 0; display: grid; gap: 2px; align-content: start; }
.policy li::before { content: counter(step); position: absolute; top: 0; left: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); font: 500 11px/18px var(--mono); text-align: center; }
.policy li::after { content: ""; position: absolute; top: 10px; left: 26px; right: 6px; height: 1px; background: var(--line); }
.policy li:last-child::after { display: none; }
.workflow-on .policy li::before { border-color: var(--teal); color: var(--teal); }
.policy-step { font-weight: 600; font-size: 14px; }
.policy-wait { font-size: 12px; color: var(--muted); }

/* ---- Value ---------------------------------------------------------------------------- */

.verdict-line { font: 500 20px/1.3 var(--display); margin-bottom: 14px; }
.verdict-num { display: block; font: 800 56px/1 var(--display); font-stretch: 118%; color: var(--teal); margin-bottom: 6px; }

.bar { height: 22px; background: color-mix(in srgb, var(--amber) 55%, var(--panel)); border-radius: 3px; overflow: hidden; }
.bar-auto { display: block; height: 100%; background: var(--teal); border-right: 2px solid var(--panel); }
.bar-key { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; margin-top: 8px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.key-auto { background: var(--teal); }
.key-person { background: color-mix(in srgb, var(--amber) 55%, var(--panel)); }

.projection { margin: 0; }
.projection div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.projection dt { color: var(--muted); }
.projection dd { margin: 0; font: 700 18px/1.2 var(--display); }
.projection-total dt { color: var(--text); font-weight: 600; }
.projection-total dd { font: 800 30px/1 var(--display); color: var(--teal); }

.assumptions { display: grid; gap: 4px; max-width: 420px; }
.assumptions label { margin-top: 10px; }
.assumptions button { justify-self: start; margin-top: 14px; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; }

.compare { display: grid; gap: 8px; margin: 14px 0; max-width: 640px; }
.compare-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 60px; align-items: center; gap: 12px; }
.compare-row > .compare-bar { height: 20px; border-radius: 3px; justify-self: start; }
.compare-now { background: color-mix(in srgb, var(--amber) 55%, var(--panel)); }
.compare-bench { background: var(--teal); }
.compare-label { font-size: 13px; color: var(--muted); }
.compare-value { font: 700 16px/1 var(--display); }

/* ---- Patriot link, demo --------------------------------------------------------------- */

.questions { counter-reset: q; display: grid; gap: 12px; }
.questions li { counter-increment: q; position: relative; padding-left: 34px; max-width: 80ch; }
.questions li::before { content: counter(q); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--amber); color: var(--amber); font: 500 12px/20px var(--mono); text-align: center; }

.inject { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---- Sign in -------------------------------------------------------------------------- */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 380px; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--teal); border-radius: var(--radius); }
.login .brand { margin-bottom: 26px; }
.login h1 { font-size: 24px; margin-bottom: 14px; }
.login .stack label { margin-top: 8px; }
.login .stack button { margin-top: 12px; }
.login-error { color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 45%, transparent); border-radius: var(--radius); padding: 9px 12px; font-size: 14px; }

/* ---- Small screens -------------------------------------------------------------------- */

@media (max-width: 980px) {
    .shell { grid-template-columns: 1fr; }
    .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
    .rail nav { flex-direction: row; flex-wrap: wrap; }
    .rail nav a { border-left: 0; border-bottom: 2px solid transparent; }
    .rail nav a[aria-current="page"] { border-bottom-color: var(--teal); }
    .nav-gap { display: none; }
    .rail-note { margin: 0; border: 0; padding: 0; flex-basis: 100%; }
    main { padding: 20px 16px 40px; }
    .lanes, .split, .split-even { grid-template-columns: 1fr; }
    .lane-person { border-right: 0; border-bottom: 1px solid var(--line); border-top-right-radius: var(--radius); }
    .lane-auto { border-top-right-radius: 0; }
    .row { grid-template-columns: 1fr; }
    .policy { grid-template-columns: 1fr; gap: 12px; }
    .policy li::after { display: none; }
    .audit li { grid-template-columns: 1fr; gap: 2px; }
    .tally { grid-template-columns: 1fr; }
    .table { display: block; overflow-x: auto; }
    .table th, .table td { min-width: 120px; }
    .workflow-head { flex-direction: column; }
    .track-labelled .node-detail { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .pulse-dot, .node-pending .node-dot { animation: none; }
}
