/* Aferente web demo. Visual language borrowed from the gateway site console
   (gateway/src/aferente_gateway/static/console.css): same tokens, cards, tiles, pills, tables. */
:root {
  --bg: #f4f3ef; --panel: #ffffff; --ink: #1b2422; --muted: #5a6662; --line: #dcd8cf; --soft: #ecebe5;
  --brand: #0f5c52; --brand-ink: #ffffff; --accent: #0f5c52; --brand-soft: #e3efec;
  --ok: #1d7445; --ok-bg: #e5f2ea; --warn: #8a5a00; --warn-bg: #fbf1dc; --bad: #a3302a; --bad-bg: #fbe7e5;
  --live: #0f5c52; --silent: #5b4a8a; --silent-bg: #eeeaf7; --focus: #2563eb;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --viewer: #0b0f0f; --viewer-panel: #151b1b; --viewer-ink: #d7dedc; --viewer-line: #2a3333;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615; --panel: #182020; --ink: #e6ebe9; --muted: #9aa7a2; --line: #2b3533; --soft: #1f2927;
    --brand: #49b3a1; --brand-ink: #0b1312; --accent: #6cc7b6; --brand-soft: #173431;
    --ok: #6fcf97; --ok-bg: #16301f; --warn: #e8b45a; --warn-bg: #33270f; --bad: #f08a80; --bad-bg: #3a1a17;
    --live: #6cc7b6; --silent: #b4a4e6; --silent-bg: #262040; --focus: #7aa2ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 10; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sub { display: block; color: var(--muted); font-size: 12.5px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.break { word-break: break-all; }

/* header */
.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: .01em; }
.brand .mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--brand) 0 55%, transparent 55%), var(--soft); border: 2px solid var(--brand); }
.brand .site { font-weight: 500; color: var(--muted); font-size: 14px; padding-left: 10px; border-left: 1px solid var(--line); }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.langs button { border: 0; border-radius: 0; min-height: 32px; padding: 4px 10px; font-size: 13px; background: var(--panel); color: var(--muted); }
.langs button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.research { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--line); text-align: center; padding: 6px 16px; font-size: 13px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; }
footer.foot { max-width: 1180px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
footer.foot p { margin: 0; }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 21px; line-height: 1.25; margin: 0 0 6px; letter-spacing: -.01em; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; font-weight: 650; }
.lead { font-size: 16.5px; color: var(--muted); max-width: 820px; margin: 0; }
.hero { margin-bottom: 16px; }

/* pills, buttons */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn, .pill.synthetic { background: var(--warn-bg); color: var(--warn); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.silent { background: var(--silent-bg); color: var(--silent); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
button, .button { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { border-color: var(--muted); }
button.primary, .button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* stepper */
.stepper { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.stepper button { width: 100%; min-height: 58px; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; padding: 8px 10px; white-space: normal; text-align: left;
  font-weight: 550; font-size: 13px; line-height: 1.25; border-radius: var(--radius); }
.stepper .num { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.stepper button[aria-current="step"] { border-color: var(--brand); box-shadow: inset 0 -3px 0 var(--brand); }
.stepper button.done .num::after { content: " ✓"; color: var(--ok); }

/* flow map */
.map { display: grid; grid-template-columns: 2fr auto 1fr auto 1fr; gap: 0; margin: 0 0 18px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.zone { padding: 8px 10px 12px; position: relative; }
.zone.hospital { background: var(--soft); border-right: 3px dashed var(--muted); }
.zone.cloud { background: var(--brand-soft); }
.zone.vendors { background: var(--panel); }
.zone .zl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 6px; display: flex; justify-content: space-between; gap: 6px; }
.zone .fw { font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500; }
.zone .row { display: flex; align-items: center; gap: 6px; }
.node { flex: 1; text-align: center; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 4px; font-weight: 600; font-size: 13.5px; transition: border-color .3s, box-shadow .3s, opacity .3s; opacity: .55; }
.node.on { opacity: 1; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.link { width: 26px; height: 2px; background: var(--line); position: relative; flex: none; }
.link.on { background: var(--brand); }
.link.on::after { content: ""; position: absolute; top: -4px; width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.link.on.f::after { right: -2px; border-left: 7px solid var(--brand); }
.link.on.b::after { left: -2px; border-right: 7px solid var(--brand); }
.map > .link { align-self: end; margin: 0 4px 30px; }
.map .packet { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); top: -4px; animation: travel 1.6s ease-in-out infinite; }
.link.b .packet { animation-direction: reverse; }
@keyframes travel { from { left: 0; } to { left: calc(100% - 10px); } }

/* stage */
.stage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stage-head .count { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin: 0 0 4px; }
.stage-head h2:focus { outline: none; }
.screens { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.screens.wide { grid-template-columns: 1fr; }
.win { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.win-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px; background: var(--soft); border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 650; color: var(--muted); }
.win-h .dots { display: inline-flex; gap: 5px; margin-right: 8px; vertical-align: middle; }
.win-h .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; }
.win-b { padding: 12px; min-width: 0; flex: 1; }
.win-b > :first-child { margin-top: 0; }
.win-b > :last-child { margin-bottom: 0; }
.win.dark { background: var(--viewer); border-color: #222; color: var(--viewer-ink); }
.win.dark .win-h { background: var(--viewer-panel); color: #9fb0ab; border-color: var(--viewer-line); }

/* tables */
.wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13.5px; }
thead th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total th, tr.total td { border-top: 2px solid var(--ink); }
tr.ours td { background: var(--brand-soft); }
tr.flash td { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--warn-bg); } }

/* tiles, cards */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile .n { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 12.5px; }
.tile.big .n { color: var(--brand); }
.tile.zero .n { color: var(--ok); font-size: 34px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 12px; }
.card.attn { border-left: 6px solid var(--warn); }
.card header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.card h4 { margin: 0; font-size: 16px; }
.card dl { margin: 10px 0; display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; font-size: 13.5px; }
.card dt { color: var(--muted); } .card dd { margin: 0; }
.notice { background: var(--warn-bg); color: var(--warn); border: 1px solid currentColor; border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; }
.flashmsg { background: var(--ok-bg); color: var(--ok); border: 1px solid currentColor; border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; font-weight: 550; }
.errmsg { background: var(--bad-bg); color: var(--bad); border: 1px solid currentColor; border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; font-weight: 550; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.who { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-height: 36px; max-width: 100%; }
label { font-weight: 550; font-size: 13.5px; }
.radios { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.radios label { font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
.radios input { margin-top: 4px; accent-color: var(--brand); }

/* checks and sequences */
ul.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
ul.checks li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
ul.checks .ic { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: var(--soft); color: var(--muted); }
ul.checks li.pass .ic { background: var(--ok-bg); color: var(--ok); }
ul.checks li.fail { border-color: var(--bad); }
ul.checks li.fail .ic { background: var(--bad-bg); color: var(--bad); }
ul.checks li.na { opacity: .55; }
[data-seq] { transition: opacity .35s ease, transform .35s ease; }
.seq-hidden { opacity: 0; transform: translateY(4px); }
.progress { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .4s ease; }
.result { font-weight: 650; padding: 10px 12px; border-radius: 8px; margin-top: 10px; }
.result.ok { background: var(--ok-bg); } .result.bad { background: var(--bad-bg); }
.toggle { display: flex; gap: 8px; align-items: center; margin: 12px 0 0; font-size: 13.5px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--bad); }

/* de-identification table */
.deid td.v { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.deid td.v.gone { color: var(--muted); text-decoration: line-through; }
.deid tr.removed td.out { color: var(--bad); }
.deid tr.replaced td.out { color: var(--silent); }
.deid tr.kept td.out { color: var(--ok); }
.deid td.out .pill { margin-bottom: 2px; }
.deid th .tag { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-weight: 400; }

/* firewall & compare */
.fw-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fw-rules li { display: flex; gap: 8px; align-items: flex-start; font-family: var(--mono); font-size: 12.5px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.fw-rules li.allow { border-color: var(--ok); }
.fw-rules li.deny { border-color: var(--bad); }
.compare { display: grid; grid-template-columns: max-content 1fr 1fr; gap: 6px 14px; align-items: center; font-size: 13.5px; margin-top: 10px; }
.compare .h { font-weight: 650; font-size: 12.5px; color: var(--muted); }
.compare .n { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.compare .n.bad { color: var(--bad); } .compare .n.ok { color: var(--ok); }
input[type=range] { width: 100%; accent-color: var(--brand); }

/* viewer */
.viewer { display: grid; grid-template-columns: 150px 1fr; gap: 10px; }
.thumbs { display: flex; flex-direction: column; gap: 8px; }
.thumb { background: var(--viewer-panel); border: 1px solid var(--viewer-line); color: var(--viewer-ink); border-radius: 6px; padding: 6px; text-align: left; font-size: 12px; font-weight: 500; white-space: normal; flex-direction: column; align-items: stretch; min-height: 0; }
.thumb:hover { border-color: #5b6b67; }
.thumb[aria-pressed="true"] { border-color: #6cc7b6; box-shadow: 0 0 0 1px #6cc7b6; }
.thumb svg { width: 100%; height: auto; display: block; border-radius: 3px; margin-bottom: 4px; }
.thumb .ai { color: #6cc7b6; font-weight: 650; }
.thumb .newtag { display: inline-block; background: #6cc7b6; color: #0b1312; border-radius: 4px; padding: 0 5px; font-size: 11px; font-weight: 700; margin-left: 4px; }
.vp { position: relative; background: #000; border-radius: 6px; overflow: hidden; min-height: 240px; }
.vp svg { width: 100%; height: auto; display: block; }
.vp .ovl { position: absolute; left: 8px; top: 6px; font: 11.5px/1.4 var(--mono); color: #c9d4d1; text-shadow: 0 1px 2px #000; }
.vp .ovr { position: absolute; right: 8px; bottom: 6px; font: 11px/1.4 var(--mono); color: #8fa19c; text-align: right; }
.sr-box { margin-top: 10px; background: var(--viewer-panel); border: 1px solid var(--viewer-line); border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.sr-box h4 { margin: 0 0 6px; color: #6cc7b6; font-size: 13px; }
.sr-box p { margin: 2px 0; }
.win.dark .hint { color: #8fa19c; }

/* timeline */
ol.timeline { list-style: none; margin: 0; padding: 0; counter-reset: tl; display: flex; flex-direction: column; gap: 8px; }
ol.timeline li { counter-increment: tl; display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); opacity: .45; transition: opacity .3s, border-color .3s; }
ol.timeline li::before { content: counter(tl); flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
ol.timeline li.on { opacity: 1; border-color: var(--brand); }
ol.timeline li.on::before { background: var(--brand); color: var(--brand-ink); }

/* parties */
.parties { margin-top: 18px; }
.party-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.party { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; border-top: 4px solid var(--line); }
.party.id { border-top-color: var(--warn); }
.party.deid { border-top-color: var(--silent); }
.party.meta { border-top-color: var(--brand); }
.party.none { border-top-color: var(--line); }
.party .pn { font-weight: 650; font-size: 14px; }
.party p { margin: 0; font-size: 13.5px; }
.party .pill { align-self: flex-start; white-space: normal; border-radius: 6px; padding: 3px 8px; line-height: 1.3; }
.pill.lvl-id { background: var(--warn-bg); color: var(--warn); }
.pill.lvl-deid { background: var(--silent-bg); color: var(--silent); }
.pill.lvl-meta { background: var(--brand-soft); color: var(--brand); }

/* pager & cta */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.pager .hint { margin: 0; }
.cta { margin-top: 18px; border: 1px solid var(--brand); border-left: 6px solid var(--brand); border-radius: var(--radius); background: var(--panel); padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.cta h3 { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 17px; margin: 0 0 2px; }
.cta p { margin: 0; color: var(--muted); }

@media (max-width: 1000px) {
  .stepper { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 128px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; }
  .stepper li { scroll-snap-align: start; }
  .party-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  h1 { font-size: 22px; }
  h2 { font-size: 18.5px; }
  .lead { font-size: 15px; }
  .brand .site { display: none; }
  .stage { padding: 14px 12px; }
  .screens { grid-template-columns: minmax(0, 1fr); }
  .map { grid-template-columns: 2fr auto 1fr auto 1fr; }
  .pager .hint { display: none; }
  table.worklist .opt { display: none; }
  table.worklist td, table.worklist th { padding: 7px 6px; font-size: 12.5px; }
  .zone { padding: 6px 5px 10px; }
  .zone .zl { font-size: 10px; letter-spacing: .03em; }
  .zone .fw { display: none; }
  .node { font-size: 11.5px; padding: 6px 2px; }
  .link { width: 10px; }
  .map > .link { margin: 0 2px 24px; }
  .party-grid { grid-template-columns: minmax(0, 1fr); }
  .viewer { grid-template-columns: 1fr; }
  .thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .thumb { font-size: 11px; }
  .card dl { grid-template-columns: 1fr; gap: 2px; }
  .card dt { margin-top: 6px; }
  .compare { grid-template-columns: 1fr 70px 70px; gap: 4px 8px; }
  .compare .n { font-size: 18px; }
  .tile.zero .n { font-size: 28px; }
  /* tables become stacked rows on phones */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td, table.stack th { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td, table.stack th { border: 0; padding: 2px 10px; text-align: left; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); font-family: system-ui, sans-serif; text-decoration: none; }
  table.stack td.num { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .map .packet { display: none; }
}
