/* Every token a rule reads is defined here in BOTH blocks. A rule that writes var(--x, #fff) and never
   defines --x keeps the light value inside the dark scheme, which is how the inbox panel came to be white
   text on white in dark mode. `grep 'var(--[a-z0-9-]*,'` before adding a rule: a fallback is a bug marker. */
:root {
  --bg: #f6f7f5; --card: #fff; --ink: #1d2320; --muted: #5f6b64; --line: #dfe4e0;
  --surface: #fff; --surface-2: rgba(0,0,0,.045); --surface-3: rgba(0,0,0,.08); --line-soft: #eceef1;
  --brand: #205527; --brand-ink: #fff; --accent: #205527;
  --clear: #1f7a3a; --conditional: #7a5d00; --unknown: #5a5f73; --hold: #9a4506; --prohibited: #b91c1c;
  --clear-bg: #e7f4ea; --conditional-bg: #fbf3d6; --unknown-bg: #eceef4; --hold-bg: #fdecd9; --prohibited-bg: #fde2e2;
  --info: #1b4aa0; --info-bg: #e1ecff; --warn: #8a5a00; --ok: #1e6b34;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141816; --card: #1c211e; --ink: #e5ebe7; --muted: #9aa69f; --line: #2d3530;
    --surface: #1f2522; --surface-2: rgba(255,255,255,.07); --surface-3: rgba(255,255,255,.13); --line-soft: #2a322d;
    --clear-bg: #16301f; --conditional-bg: #3a3212; --unknown-bg: #262a36; --hold-bg: #3b2610; --prohibited-bg: #401818;
    --info-bg: #1b2b48;
    /* the verdict and error colours are re-chosen for the dark surfaces: the light-mode ones were 2 to 3:1 here */
    --clear: #7fd69a; --conditional: #e8c84a; --unknown: #b4bad6; --hold: #f4a964; --prohibited: #ff9a9a; --accent: #8fd69b;
    --info: #8fb6f0; --warn: #e8c84a; --ok: #7fd69a; }
}
* { box-sizing: border-box; }
/* `hidden` must win over any display rule (nav is display:flex): signed-out users see no portal tabs */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif; }
.top { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.2rem; background: var(--brand); color: var(--brand-ink); flex-wrap: wrap; }
.brand .mark { font-weight: 800; letter-spacing: .08em; }
.brand .sub { opacity: .85; font-size: .9rem; }
nav { display: flex; gap: .3rem; flex-wrap: wrap; }
nav button { background: transparent; color: var(--brand-ink); border: 1px solid transparent; border-radius: 6px; padding: .35rem .8rem; font: inherit; cursor: pointer; opacity: .85; }
nav button.on { border-color: rgba(255,255,255,.6); opacity: 1; font-weight: 600; }
.who { margin-left: auto; font-size: .9rem; }
.link { background: none; border: none; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
main { max-width: 1360px; margin: 1.2rem auto; padding: 0 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.3rem; margin-bottom: 1rem; }
.narrow { max-width: 26rem; margin: 3rem auto; }
h1, h2, h3 { margin: 0 0 .5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
label { display: block; margin: .6rem 0; }
input, select, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); width: 100%; }
select { width: auto; }
button.primary { background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: .5rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: .35rem .7rem; font: inherit; cursor: pointer; color: var(--ink); }
.error { color: var(--prohibited); }
.grid2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 1rem; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
.fixtures { display: grid; gap: .5rem; margin: .8rem 0; }
.fixture { text-align: left; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; background: var(--card); color: var(--ink); cursor: pointer; font: inherit; }
.fixture:hover { border-color: var(--brand); }
.fixture .t { font-weight: 600; } .fixture .s { color: var(--muted); font-size: .88rem; }
.upload textarea { margin: .5rem 0; }
.verdict { display: inline-block; font-weight: 800; letter-spacing: .04em; padding: .2rem .7rem; border-radius: 6px; }
.v-CLEAR { color: var(--clear); background: var(--clear-bg); }
.v-CONDITIONAL { color: var(--conditional); background: var(--conditional-bg); }
.v-UNKNOWN { color: var(--unknown); background: var(--unknown-bg); }
.v-HOLD { color: var(--hold); background: var(--hold-bg); }
.v-PROHIBITED { color: var(--prohibited); background: var(--prohibited-bg); }
.big { font-size: 1.6rem; }
.stats { display: flex; gap: 1.2rem; flex-wrap: wrap; margin: .7rem 0; }
.stat b { display: block; font-size: 1.3rem; }
.stat span { color: var(--muted); font-size: .85rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
/* the extraction review: Value and the quote share the width; a value wraps and grows in its textarea */
table.review { table-layout: fixed; }
table.review col.c-use { width: 3rem; } table.review col.c-what { width: 18%; }
table.review td { overflow-wrap: anywhere; }
textarea.rv-val { resize: none; overflow: hidden; min-height: 2.2rem; line-height: 1.35; }
@media (max-width: 600px) {
  table.review { font-size: .85rem; }
  table.review th, table.review td { padding: .4rem .25rem; }
  table.review col.c-use { width: 2rem; } table.review col.c-what { width: 22%; }
  table.review th { letter-spacing: 0; text-transform: none; }
}
tr.click { cursor: pointer; } tr.click:hover { background: var(--bg); }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.tag.req { border-color: var(--accent); color: var(--accent); }
.tag.bar { border-color: var(--prohibited); color: var(--prohibited); }
.tag.failure { border-color: var(--hold); color: var(--hold); }
/* the chips carry their own background, so each one reads its pair from the tokens rather than a
   light-mode hex. The light hexes were 5.6:1 on their own surface but glare on a dark card. */
.tag.done { background: var(--clear-bg); color: var(--clear); border-color: transparent; }
.tag.todo { background: var(--conditional-bg); color: var(--conditional); border-color: transparent; }
/* severity, so a critical item does not read like an ordinary one */
.tag.sev-critical { background: var(--prohibited-bg); color: var(--prohibited); border-color: transparent; }
.tag.sev-high { background: var(--hold-bg); color: var(--hold); border-color: transparent; }
.pill { background: #fff; color: var(--brand); border-radius: 99px; padding: 0 .45rem; font-size: .8rem; font-weight: 700; }
.stage { border: 1px solid var(--line); border-radius: 8px; margin: .4rem 0; }
.stage > summary { display: flex; gap: .7rem; align-items: center; padding: .5rem .7rem; cursor: pointer; list-style: none; }
.stage > summary::-webkit-details-marker { display: none; }
.stage .name { font-weight: 600; flex: 1; }
.stage .body { padding: 0 .9rem .7rem; }
.stage.na { opacity: .6; }
.finding { border-left: 3px solid var(--line); padding: .3rem .7rem; margin: .5rem 0; }
.finding.f-PROHIBITED { border-color: var(--prohibited); } .finding.f-HOLD { border-color: var(--hold); }
.finding.f-UNKNOWN { border-color: var(--unknown); } .finding.f-CONDITIONAL { border-color: var(--conditional); }
.finding .ft { font-weight: 600; } .finding .fr { font-size: .9rem; }
.finding .cite, .finding .flag { font-size: .82rem; color: var(--muted); }
.decide { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .4rem; }
.decide input { width: 18rem; }
pre { background: var(--bg); padding: .6rem; border-radius: 6px; overflow: auto; font-size: .82rem; max-height: 22rem; }
.filters { display: flex; gap: 1rem; flex-wrap: wrap; }
.filters label { display: flex; gap: .4rem; align-items: center; }
.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 2rem 1rem; }
.subnav { display: flex; gap: .3rem; margin-bottom: .8rem; }
.subnav button { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .3rem .8rem; font: inherit; cursor: pointer; }
.subnav button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.noperm { font-size: .85rem; color: var(--muted); margin-top: .4rem; }
.decisions { margin-top: .8rem; }
.who-org { opacity: .8; }
label.inline { display: flex; gap: .5rem; align-items: center; } label.inline input { width: auto; }
.cand { display: flex; gap: .5rem; align-items: baseline; margin: .25rem 0; }
.cand input { width: auto; }
.conflict { margin: .5rem 0; padding: .3rem 0; border-top: 1px solid var(--line); }
.conflict-note { font-size: .82rem; color: var(--hold); margin-top: .2rem; }
.doc-wait, .doc-failure { font-size: .82rem; margin-top: .2rem; }
.doc-actions { white-space: nowrap; text-align: right; }
.doc-actions button { font-size: .82rem; padding: .2rem .55rem; vertical-align: middle; }
.doc-actions button:disabled { opacity: .4; cursor: default; }
/* One rule for every button the page turns off. Before this only the document row's actions had a
   disabled style, so Extract (which the server refuses to queue anything for) and every tool's Run
   looked exactly as clickable as an enabled one, and the only signal was a label that changed text. */
button:disabled, .ghost:disabled, .primary:disabled, .link:disabled {
  opacity: .45;
  cursor: not-allowed;
  filter: grayscale(1);
}
.doc-delete svg { display: block; }
.doc-alert { margin: .4rem 0; }
.cand-src { display: block; font-size: .85rem; }
details.card > summary { cursor: pointer; }
details.area > summary { display: flex; align-items: baseline; gap: .8rem; list-style: none; }
details.area > summary::-webkit-details-marker { display: none; }
details.area > summary::before { content: "\25B8"; color: var(--muted, #888); }
details.area[open] > summary::before { content: "\25BE"; }
details.area > summary h2 { margin: 0; }
details.area[open] > summary { margin-bottom: .6rem; }
.tag.stage-reading{background:var(--conditional-bg);color:var(--conditional)}
.tag.stage-needs_confirmation{background:var(--info-bg);color:var(--info)}
.tag.stage-active{background:var(--clear-bg);color:var(--clear)}

.tag.run-tool{border-color:var(--accent);color:var(--accent)}
.tag.run-assessment{background:var(--unknown-bg);color:var(--unknown)}
/* a row that opens something is reachable and visible from the keyboard */
tr.click:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* long names and file names wrap inside their cell, and a wide table scrolls inside its card */
td, th { overflow-wrap: anywhere; }
.card { overflow-x: auto; }
/* `anywhere` also lets a column shrink below the width of its longest WORD, which is how the documents
   table's Kind column came to hold 60px and break "Ingredient list" in the middle of a word: the state
   cell beside it carries sentences, so the auto layout took the width from the short column. Keep the
   short labels whole and let the sentences take the space. Tags are short by construction, so they are
   the same rule. */
/* `.nw` is a cell whose content is a short word or two and must not be broken or squeezed: a Kind
   label, a date, a tag. Position-based rules broke as soon as a table gained a column, so the cell
   says it itself. */
.nw, .tag { white-space: nowrap; }

/* The product's reading state, at the top where it cannot be missed. */
.reading-banner {
  margin: .5rem 0 0;
  padding: .5rem .75rem;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 3px;
}
.reading-banner.stalled { border-left-color: var(--warn); }
.reading-banner.done { border-left-color: var(--ok); }

/* ---- inbox bell ---------------------------------------------------------- */
.bell-wrap { position: relative; display: inline-block; }
.bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; border: 1px solid rgba(255,255,255,.55);
  border-radius: 50%; background: transparent; color: inherit; cursor: pointer;
}
.bell:hover, .bell[aria-expanded="true"] { background: rgba(255,255,255,.18); }
/* The bell sits on the brand bar, which is the same green in both schemes, so the badge is the same
   pair as the other count pill: a paper chip with brand ink. White on --accent was 1.7:1 in dark. */
.bell .pill {
  position: absolute; top: -.35rem; right: -.35rem; min-width: 1.1rem; padding: 0 .25rem;
  font-size: .7rem; line-height: 1.1rem; text-align: center; border-radius: .55rem;
  background: var(--brand-ink); color: var(--brand);
}
.inbox-panel {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 40; width: min(26rem, 92vw);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.22); padding: .5rem .6rem;
}
.inbox-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.inbox-list { list-style: none; margin: .4rem 0 0; padding: 0; max-height: 28rem; overflow: auto; }
.inbox-list li { padding: .45rem 0; border-top: 1px solid var(--line-soft); }
.inbox-list li:first-child { border-top: 0; }
.inbox-title { display: block; }
.inbox-what { display: block; font-size: .88rem; color: var(--muted); }
.inbox-meta { display: flex; align-items: center; gap: .45rem; margin-top: .2rem; }
.inbox-actions { margin-left: auto; display: flex; gap: .35rem; }
.inbox-foot { margin: .4rem 0 0; font-size: .78rem; }
.inbox-stale { margin: .4rem 0 0; font-size: .82rem; color: var(--hold); }

/* ---- tool tips -----------------------------------------------------------
   One element, positioned next to whatever asked for it. A tooltip inside a table is clipped by the
   card's overflow-x:auto (which makes overflow-y auto too), so it cannot be a CSS child of the row. */
#tool-tip {
  position: fixed; z-index: 60; width: min(30rem, 88vw); padding: .55rem .7rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.24); font-size: .88rem; line-height: 1.45;
}
#tool-tip[hidden] { display: none !important; }
.tool-cell { position: relative; }
.tool-name { cursor: help; border-bottom: 1px dotted var(--muted); }
.tool-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the tool's own output sits under the list, at the page's full width, because findings are wide */
.tool-out { margin-top: .9rem; }
.tool-out h3 { margin-top: 0; }
#sku-tool-table td { vertical-align: middle; }
#sku-tool-table .tool-last { width: 7.5rem; white-space: nowrap; }

/* ---- the confirmed set --------------------------------------------------- */
.set-done td { vertical-align: top; }
.set-done .set-val { font-weight: 600; }
.set-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.set-head h3 { margin: 0; }
.set-head .decide { margin: 0 0 0 auto; }
.set-note { margin: .4rem 0 .6rem; }

/* Links. The browser default is #0000EE, which is unreadable on the dark card and on the brand bar,
   and one link on the activity page used it because nothing set a colour for an anchor. */
a { color: var(--accent); text-underline-offset: 2px; }
a:visited { color: var(--accent); }
a:hover { color: var(--ink); }
.top a { color: var(--brand-ink); }

/* A heading with an action on the same line, used where a log or a list exports itself. */
.list-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .5rem; }
.list-head h2 { margin: 0; }
.list-head > .ghost { margin-left: auto; }

/* The demo surfaces under Products: a closed card, so they are reachable and never in the way. */
#demo-card > summary { cursor: pointer; font-weight: 600; }
/* Whose result this is: the one sentence that travels with every result (app.js RESULT_NOTICE). It sits
   directly under a headline result and once above a table or list of results, so it is quiet but it is
   body text, not a footnote: the same size as a finding's reasoning, and never below the muted contrast. */
.result-notice { margin: .35rem 0 .6rem; font-size: .88rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: .6rem; }
.result-headline { margin: .4rem 0; }
.result-headline .release-line { margin-left: .4rem; }
/* Market access: a product's shipment cases, the form that creates one, and the stored decision. */
#ma-case, #ma-form-box { margin-top: .8rem; }
.ma-case, .ma-form { border-top: 1px solid var(--line); padding-top: .8rem; }
.ma-case h4, .ma-form h4 { margin: .9rem 0 .3rem; font-size: .92rem; }
.ma-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 1rem; align-items: end; }
.ma-fields select { width: 100%; }
/* a pack's title is a sentence, so the pack takes the whole row instead of being cut off in a column */
.ma-fields label.wide { grid-column: 1 / -1; }
.ma-q { margin: .5rem 0; }
.ma-q label { display: block; }
.ma-q select { display: block; margin-top: .2rem; width: 100%; max-width: 32rem; }
.ma-legal { display: block; font-size: .85rem; }
.ma-pack-group h3 { margin: .9rem 0 .2rem; font-size: 1rem; }
.ma-attach, .ma-unissued { border-top: 1px solid var(--line); padding: .5rem 0; }
.ma-attach-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .3rem 1rem; align-items: end; }
.ma-attach-fields .ma-declared { grid-column: 1 / -1; margin: 0; }
.ma-attach select, .ma-attach input { width: 100%; }
.ma-count { margin: .5rem 0; }
.ma-attached, .ma-unmapped { margin: .6rem 0; }
.ma-unmapped > summary { cursor: pointer; font-weight: 600; }
table.ma-gates { width: auto; min-width: 22rem; }
.ma-req .ma-what { color: var(--muted); }
.ma-req .ma-found, .ma-req .ma-evidence { margin-top: .2rem; }
.ma-advisory, .ma-purpose { font-size: .88rem; }
.ma-facts, .ma-rest, .ma-other { margin: .6rem 0; }
.ma-facts > summary, .ma-rest > summary, .ma-other > summary { cursor: pointer; font-weight: 600; }
code.ma-basis { font-weight: 700; }
/* declared evidence is marked, in the conditional pair: it is not a fault, and it is not a check */
.tag.self-declared { background: var(--conditional-bg); color: var(--conditional); border-color: transparent; }
.result-copy { margin: .35rem 0 .2rem; font-weight: 600; }
.declared-notice { margin: .35rem 0 .6rem; font-size: .9rem; border-left: 3px solid var(--line); padding-left: .6rem; }
.ma-rests-on { margin: .8rem 0; }
.ma-rests-on h5 { margin: .6rem 0 .2rem; font-size: .88rem; }
.ma-declared-row { font-size: .85rem; }
.ma-todo, .ma-unassessed { margin: .5rem 0; }
.ma-declare { margin: .8rem 0 .4rem; }
.ma-declare-label { display: flex; gap: .5rem; align-items: flex-start; }
