/*
 * The console (WP07): the accepted A1' Control Room and Settings. Plain CSS on the tokens in tokens.css.
 * Sizes, spacing and class names follow the prototype (judgement-console-concepts.html, round 2, A1')
 * so the two can be compared side by side. Everything is scoped under body.console.
 */
body.console {
  margin: 0; min-height: 100vh; display: grid; grid-template-rows: auto auto 1fr auto;
  background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
.console *, .console *::before, .console *::after { box-sizing: border-box; }
.console h1, .console h2, .console h3, .console h4 { font-family: var(--f-display); line-height: 1.15; margin: 0; text-wrap: balance; }
.console p { margin: 0; }
.console a { color: var(--accent); }
.console :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.console button, .console input, .console summary { font: inherit; color: inherit; }
.console code, .console .mono { font-family: var(--f-mono); font-size: .85em; }
.console .muted { color: var(--muted); }
.console .small { font-size: .78rem; }
.console .num { font-variant-numeric: tabular-nums; }
.console .eyebrow { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.console .good { color: var(--good); }
.console .warn { color: var(--warn); }
.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; }
.console .skip { position: absolute; left: -999px; top: .5rem; background: var(--surface); padding: .3rem .6rem; border-radius: 6px; z-index: 20; }
.console .skip:focus { left: .5rem; }

/* App bar */
.app-bar { display: flex; align-items: center; gap: .8rem; padding: .55rem 16px; border-bottom: 1px solid var(--rule); background: var(--raised); font-size: .85rem; min-width: 0; }
.app-bar .brand { font-size: 1.05rem; }
.app-bar .sp { flex: 1; }
.app-bar .ws-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.app-nav { display: flex; gap: .2rem; }
.app-nav a { color: var(--ink); text-decoration: none; padding: .25rem .55rem; border-radius: 7px; white-space: nowrap; }
.app-nav a:hover { background: var(--tint); }
.app-nav a[aria-current="page"] { background: var(--surface); box-shadow: 0 0 0 1px var(--rule); font-weight: 600; }
.console .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--tint); display: grid; place-items: center; font-size: .72rem; font-weight: 600; color: var(--accent); flex: none; }
.sign-out { margin: 0; }

/* Flash */
.flash { padding: .5rem 16px 0; display: grid; gap: .3rem; }
.flash p { border-radius: 8px; padding: .45rem .7rem; font-size: .88rem; background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--good); }
.flash .flash-alert { border-left-color: var(--bad); }

.console-page { min-width: 0; }
.console-foot { padding: 1rem 16px 1.4rem; font-size: .82rem; color: var(--muted); text-align: center; }
.console-foot a { color: inherit; }

/* Buttons and pills */
.console .btn { display: inline-flex; align-items: center; gap: .3rem; background: var(--accent); color: var(--on-accent); border: 0; border-radius: 7px; padding: .38rem .8rem; font-weight: 600; font-size: .84rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.console .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.console .btn.ghost:hover { background: var(--tint); }
.console .btn.small { padding: .2rem .6rem; font-size: .8rem; }
.console .btn.danger { color: var(--bad); }
.console .btn:disabled { opacity: .5; cursor: default; }
.console form.button_to { display: inline; margin: 0; }
.console .pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; padding: .08rem .5rem; border-radius: 99px; white-space: nowrap; border: 1px solid currentColor; }
.console .pill::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.s-ACTIVE { color: var(--human); } .s-COMPLETED { color: var(--muted); } .s-AWAITING { color: var(--accent); }
.s-PAUSED { color: var(--warn); } .s-UNPUBLISHED, .s-SCHEDULED, .s-PUBLISHING { color: var(--muted); }

/* Control Room: rail, main column, and the side column the prototype gives the assistant (v1.1). */
.cr { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr) 19rem; min-height: 40rem; background: var(--surface); border-bottom: 1px solid var(--rule); }
.cr-rail { border-right: 1px solid var(--rule); padding: .8rem; display: grid; gap: .25rem; align-content: start; background: var(--raised); }
.cr-rail .ds { font-size: .78rem; color: var(--muted); padding: .6rem .4rem .2rem; display: flex; justify-content: space-between; gap: .5rem; }
.cr-rail .ds span:first-child { overflow-wrap: anywhere; }
.rail-item { border-radius: 8px; padding: .45rem .55rem; display: grid; gap: .3rem; color: var(--ink); text-decoration: none; }
.console .rail-item { color: var(--ink); }
.rail-item:hover { background: var(--tint); }
.rail-item[aria-current="page"] { background: var(--surface); box-shadow: 0 0 0 1px var(--rule); }
.rail-item .bn { font-size: .86rem; font-weight: 500; display: flex; justify-content: space-between; gap: .4rem; align-items: center; }
.hdot { width: .5rem; height: .5rem; border-radius: 50%; flex: none; background: var(--rule); }
.h-good { background: var(--good); } .h-warn { background: var(--warn); } .h-bad { background: var(--bad); } .h-none { background: var(--rule); }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--code); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--human); border-radius: 3px; transition: width .4s; }

.cr-main { position: relative; padding: 1.1rem 1.2rem; display: grid; gap: 1rem; align-content: start; min-width: 0; }
.cr-head { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; }
.cr-title { display: grid; gap: .2rem; min-width: 0; }
.cr-title .small { font-size: .8rem; overflow-wrap: anywhere; }
.cr-head h1 { font-size: 1.3rem; font-weight: 750; }
.cr-head .sp { flex: 1; }
.cr-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: "▾"; font-size: .7rem; margin-left: .1rem; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 4; min-width: 14rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 12px 30px -14px var(--shadow); padding: .3rem; display: grid; }
.menu-list a { padding: .4rem .6rem; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: .86rem; }
.menu-list a:hover { background: var(--tint); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; }
.kpi { border: 1px solid var(--rule); border-radius: 10px; padding: .7rem .8rem; display: grid; gap: .2rem; align-content: start; }
.kpi .v { font-family: var(--f-display); font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.kpi .k, .kpi .d { font-size: .76rem; }
.kpi .k { color: var(--muted); }

.console .panel { border: 1px solid var(--rule); border-radius: 10px; padding: .8rem .9rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; min-width: 0; background: var(--surface); }
.panel-h { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.panel-h h2 { font-size: .92rem; font-weight: 700; }
.panel .empty { font-size: .88rem; padding: 1.2rem 0; text-align: center; }
.two { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: .8rem; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .76rem; color: var(--muted); align-items: center; }
.legend span { display: inline-flex; gap: .35rem; align-items: center; }
.legend i { width: .7rem; height: .7rem; border-radius: 50%; display: inline-block; }
.legend .lg-actual { background: var(--human); }
.legend .lg-forecast { background: var(--forecast); }

/* Charts (ChartsHelper) */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--f-body); }
.ch-grid { stroke: var(--rule); stroke-width: 1; }
.ch-tick { font-size: 10.5px; fill: var(--muted); }
.chart-agreement .ch-tick { font-size: 10px; }
.ch-now { stroke: var(--ink); stroke-opacity: .25; }
.ch-line { fill: none; stroke: var(--human); stroke-width: 2.4; stroke-linejoin: round; }
.ch-line-thin { stroke-width: 2; }
.ch-dot { fill: var(--human); stroke: var(--surface); stroke-width: 2; }
.ch-area { fill: var(--human); fill-opacity: .12; }
.ch-target { stroke: var(--warn); stroke-dasharray: 4 4; stroke-width: 1.2; }
.ch-band { fill: var(--forecast); fill-opacity: .14; }
.ch-forecast { stroke: var(--forecast); stroke-width: 2; stroke-dasharray: 5 4; }
.ch-forecast-dot { fill: var(--forecast); }
.ch-forecast-label { font-size: 11.5px; font-weight: 600; fill: var(--forecast); }
.ch-paused { font-size: 11px; font-weight: 600; fill: var(--warn); }

/* Event pins: colour by who or what made the event. Automatic events share the forecast grey, not the tinted muted. */
.pin { cursor: pointer; --pin: var(--forecast); outline: none; }
.pin.ev-detection, .ap-num.ev-detection, .pin-dot.ev-detection { --pin: var(--warn); }
.pin.ev-customer, .ap-num.ev-customer, .pin-dot.ev-customer { --pin: var(--accent); }
.pin.ev-automatic, .ap-num.ev-automatic, .pin-dot.ev-automatic { --pin: var(--forecast); }
.pin-hit { fill: transparent; }
.pin-stem { stroke: var(--pin); stroke-dasharray: 2 3; stroke-opacity: .5; pointer-events: none; }
.pin-head { fill: var(--pin); stroke: var(--surface); stroke-width: 2; transition: r .1s; }
.pin-num { font-size: 10px; font-weight: 700; fill: var(--surface); pointer-events: none; }
.pin:hover .pin-stem, .pin:focus .pin-stem, .pin.on .pin-stem { stroke-opacity: 1; }
.pin:hover .pin-head, .pin.on .pin-head { r: 10; }
.pin:focus-visible .pin-head { stroke: var(--accent); stroke-width: 3; r: 10; }

/* Hover card */
.ckcard { position: absolute; z-index: 3; width: min(19rem, calc(100% - 16px)); background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 12px 30px -14px var(--shadow); padding: .7rem .8rem; display: grid; gap: .35rem; font-size: .84rem; pointer-events: none; }
.ckcard[hidden] { display: none; }
.ckc-h { display: flex; gap: .45rem; align-items: center; font-family: var(--f-mono); font-size: .72rem; color: var(--muted); }
.pin-dot, .ap-num { display: inline-grid; place-items: center; border-radius: 50%; background: var(--pin, var(--forecast)); color: var(--surface); font-weight: 700; font-size: .68rem; font-family: var(--f-body); }
.pin-dot { width: 1.3rem; height: 1.3rem; }
.ckc-snap { display: flex; flex-wrap: wrap; gap: .3rem .8rem; border-top: 1px solid var(--rule); padding-top: .4rem; font-size: .78rem; color: var(--muted); }
.ckc-snap b { color: var(--ink); font-weight: 600; }
.ckc-after { display: grid; gap: .15rem; background: var(--assist-tint); border-radius: 7px; padding: .4rem .5rem; }

/* Quotas */
.quota { display: grid; grid-template-columns: 4rem minmax(0, 1fr) 4.4rem; gap: .5rem; align-items: center; font-size: .8rem; }
.quota > span:first-child { overflow-wrap: anywhere; }
.quota .track { height: 8px; background: var(--code); border-radius: 4px; position: relative; display: block; }
.quota .track i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; transition: width .4s; }
.quota .track b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.quota .num { text-align: right; }

/* What changed */
.tl { display: grid; gap: .5rem; }
.sev { border-left: 3px solid var(--rule); padding: .5rem .7rem; background: var(--raised); border-radius: 0 8px 8px 0; display: grid; gap: .2rem; font-size: .85rem; }
.sev.warn { border-left-color: var(--warn); } .sev.bad { border-left-color: var(--bad); } .sev.good { border-left-color: var(--good); }
.sev b { font-weight: 600; }
.ap-ev { cursor: pointer; }
.ap-ev:hover { background: var(--tint); }
.ap-ev.on { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ap-num { width: 1.25rem; height: 1.25rem; margin-right: .25rem; vertical-align: 1px; }
.now-mark { font-family: var(--f-mono); font-size: .74rem; letter-spacing: .05em; color: var(--muted); padding-top: .3rem; }

/* Side column */
.cr-side { border-left: 1px solid var(--rule); padding: 1rem; display: grid; gap: .8rem; align-content: start; background: var(--raised); }
.cr-side h2 { font-size: 1.05rem; font-weight: 700; }
.cr-side h3 { font-size: .92rem; font-weight: 700; }
.facts { margin: 0; display: grid; gap: .45rem; font-size: .85rem; }
.facts div { display: grid; gap: .05rem; }
.facts dt { font-size: .74rem; color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.cr-side code { overflow-wrap: anywhere; }

/* Plumbline Assist (v1.1): briefing and priced fixes at the top of the side column, in the assistant's teal. */
.cr-side { background: linear-gradient(180deg, var(--assist-tint), var(--raised) 22rem); }
.assist-panel { display: grid; gap: .7rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
.assist-mark { display: inline-flex; align-items: center; gap: .35rem; font-family: var(--f-mono); font-size: .68rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--assist); }
.console h2.assist-mark { font-family: var(--f-mono); font-size: .68rem; font-weight: 500; }
.assist-mark svg { width: 14px; height: 14px; flex: none; }
.brief { display: grid; gap: .45rem; font-size: .9rem; line-height: 1.55; }
.brief em { font-style: normal; font-weight: 600; }
.assist-panel h3 { font-size: .86rem; font-weight: 700; }
.sugg { border: 1px solid var(--rule); border-radius: 10px; padding: .65rem .75rem; background: var(--surface); display: grid; gap: .35rem; font-size: .85rem; }
.sugg > b { font-weight: 600; line-height: 1.35; }
.sugg .cost { font-size: .8rem; }
.sugg .row-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding-top: .15rem; }
.console .btn.assist { background: var(--assist); color: var(--on-assist); }

.empty-room { max-width: 40rem; }
.empty-room h1 { font-size: 1.3rem; }

/* Settings */
.settings, .narrow { max-width: 52rem; margin: 0 auto; padding: 1.4rem 16px 2rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.panel-h > span { min-width: 0; overflow-wrap: anywhere; }
.narrow { max-width: 32rem; margin-top: 2rem; }
.settings h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; }
.settings .panel p { font-size: .9rem; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; padding: .6rem 0; border-top: 1px solid var(--rule); }
.row:first-child { border-top: 0; }
.row-main { display: grid; gap: .05rem; flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.row.revoked .row-main { opacity: .6; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; }
.inline-form input[type=text] { flex: 1 1 14rem; min-width: 0; font-size: .9rem; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: .4rem .6rem; }
.reveal { display: grid; gap: .4rem; border: 1px solid var(--good); background: var(--raised); border-radius: 10px; padding: .7rem .8rem; font-size: .88rem; }
.reveal .token { display: block; padding: .45rem .6rem; background: var(--code); border-radius: 6px; overflow-wrap: anywhere; user-select: all; font-size: .85rem; }
.consent { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
/* API keys (WP19): the access presets and expiry under the key form */
.key-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; margin-bottom: .6rem; }
.key-form > * { min-width: 0; }
.key-access { border: 1px solid var(--rule); border-radius: 8px; padding: .5rem .7rem; display: flex; flex-wrap: wrap; gap: .3rem .9rem; min-width: 0; }
.key-access legend { padding: 0 .3rem; color: var(--muted); }
.key-access label, .key-expiry label { display: inline-flex; align-items: center; gap: .35rem; }
.key-scopes { flex-basis: 100%; display: grid; gap: .2rem; padding-top: .3rem; border-top: 1px solid var(--rule); }
.key-scopes[hidden] { display: none; }
.key-scopes label { display: flex; flex-wrap: wrap; align-items: baseline; }
.key-expiry { display: flex; flex-wrap: wrap; gap: .4rem .7rem; align-items: center; }
.key-expiry input[type=date] { font-size: .88rem; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: .3rem .5rem; max-width: 100%; }

/* Narrower screens, as in the prototype: the side column drops below, then everything stacks. */
@media (max-width: 1100px) {
  .cr { grid-template-columns: 13rem minmax(0, 1fr); }
  .cr-side { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--rule); }
}
@media (max-width: 760px) {
  .cr { grid-template-columns: minmax(0, 1fr); }
  .cr-rail { border-right: 0; border-bottom: 1px solid var(--rule); max-height: 16rem; overflow-y: auto; }
  .cr-main { padding: 1rem 16px; }
  .cr-side { padding: 1rem 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: minmax(0, 1fr); }
  .app-bar { flex-wrap: wrap; gap: .5rem .8rem; }
  .app-bar .ws-name { display: none; }
}
/* On phones the 640-wide chart is drawn at about half size: enlarge its text and pins to stay legible. */
@media (max-width: 560px) {
  .chart-items .ch-tick { font-size: 19px; }
  .chart-items .ch-forecast-label { font-size: 19px; }
  .chart-items .ch-paused { font-size: 19px; }
  .chart-agreement .ch-tick { font-size: 15px; }
  .chart-items .pin-head { r: 12; }
  .chart-items .pin:hover .pin-head, .chart-items .pin.on .pin-head { r: 13; }
  .chart-items .pin-num { font-size: 14px; }
}
@media (max-width: 420px) {
  .app-bar .avatar { display: none; }
  .kpi .v { font-size: 1.35rem; }
}

/* Getting started (developer sign-up, 2026-10-19) */
.start-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.start h1 { margin: 0; }
.first-call { margin: 0; padding: .6rem .7rem; background: var(--code); border-radius: 8px; font: .8rem/1.6 var(--f-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.reveal .btn { justify-self: start; }
.s-SANDBOX { color: var(--warn); } .s-LIVE { color: var(--good); }
/* The Test/Live switch in the app bar */
.mode-switch { display: inline-flex; border: 1px solid var(--rule); border-radius: 99px; padding: 2px; gap: 2px; }
.mode-form { margin: 0; }
.mode-btn { font: inherit; font-size: .76rem; font-weight: 600; border: 0; border-radius: 99px; padding: .15rem .65rem; background: transparent; color: var(--muted); cursor: pointer; }
.mode-btn:hover { color: var(--ink); }
.mode-btn.mode-test[aria-pressed=true] { background: var(--warn); color: var(--surface); }
.mode-btn.mode-live[aria-pressed=true] { background: var(--good); color: var(--surface); }
.start .panel > .btn, .start .panel > form { justify-self: start; }
