/* BidPilot — warm graphite. Existing classes and semantic states are the component API.
   Presentation only: no external fonts, runtime dependency or replacement event handlers.
   Verified / uncertain / conflict / human / AI always keep distinct semantic colours. */
:root {
  color-scheme: dark;
  --bg: #191918; --panel: #232321; --sunken: #1d1d1b; --raised: #2c2b28;
  --ink: #f1eee7; --ink2: #d8d3ca; --muted: #b0aaa0; --faint: #a19b91;
  --line: #3b3934; --line2: #302f2b; --line-strong: #81796d;
  --brand: #f0b99c; --brand2: #e8ab89; --brand-bg: #372c25;
  --accent: #e8ab89; --accent-bg: #372c25; --on-brand: #261b15;
  --ok: #9bd2b0; --ok-bg: #203329; --warn: #edc57e; --warn-bg: #382f20;
  --bad: #f1a7a0; --bad-bg: #3d2727; --info: #aac6ec; --info-bg: #263140;
  --human: #cdb8ec; --human-bg: #322b40; --ai: #94d2d2; --ai-bg: #213536;
  --unk: #c3bdb2; --unk-bg: #32312c;
  --radius: 14px; --radius-sm: 8px;
  --shadow: 0 2px 3px rgb(0 0 0 / 10%), inset 0 1px 0 rgb(255 255 255 / 2%);
  --shadow-pop: 0 12px 28px rgb(0 0 0 / 22%), inset 0 1px 0 rgb(255 255 255 / 4%);
  --ring: 0 0 0 3px rgb(232 171 137 / 24%);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --space-page: clamp(20px, 3vw, 48px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01"; }
a { color: var(--brand2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
/* In running text, links must not be distinguishable by colour alone. */
.crumbs a, .content p a:not(.btn), .content li a:not(.btn),
.content .small > a:not(.btn):not(.cite):not(.rv-btn), .flash a:not(.btn) {
  text-decoration: underline; text-underline-offset: 3px;
}
h1, h2, h3, h4 { margin: 0 0 .45em; line-height: 1.25; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: clamp(25px, 2.3vw, 34px); font-weight: 600; letter-spacing: -.035em; } h2 { font-size: 18px; font-weight: 600; } h3 { font-size: 15px; font-weight: 600; }
h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
::selection { background: var(--brand-bg); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; box-shadow: var(--ring); }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--sunken); border-right: 1px solid var(--line); color: var(--ink2); padding: 26px 16px 16px;
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 15px;
  margin: 2px 8px 28px; letter-spacing: -.01em; }
.logo .mark { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(145deg, var(--brand), #ce8968); color: var(--on-brand); display: grid;
  place-items: center; font-size: 22px; font-family: Georgia, serif; font-weight: 700; flex: none; box-shadow: var(--shadow-pop); }
.logo small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.side a { color: var(--ink2); padding: 10px 12px; border-radius: 9px; display: flex; gap: 9px; align-items: center;
  font-size: 13.5px; font-weight: 500; }
.side a .ni, .nav-off .ni { width: 16px; text-align: center; color: var(--faint); font-size: 13px; flex: none; }
.side a:hover { background: var(--raised); color: var(--ink); text-decoration: none; }
.side a.on { background: var(--brand-bg); color: var(--brand2); font-weight: 600; box-shadow: inset 2px 0 0 var(--brand2); }
.side a.on .ni { color: var(--brand2); }
.side .sep { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600;
  margin: 18px 10px 5px; }
.side .soon { margin-left: auto; }
.side .foot { margin-top: auto; font-size: 11.5px; line-height: 1.55; color: var(--muted); padding: 12px 10px 4px;
  border-top: 1px solid var(--line); }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px var(--space-page); min-height: 70px; background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .crumbs { color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.top .grow { flex: 1; }
.top form { display: flex; gap: 6px; align-items: center; margin: 0; }
.top select, .top input[type=text] { font: inherit; font-size: 13px; height: 30px; padding: 0 8px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: var(--panel); }
.content { padding: 32px var(--space-page) 72px; max-width: 1600px; margin-inline: auto; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- containers */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; margin-bottom: 20px; min-width: 0; }
.panel.flat { box-shadow: none; background: var(--sunken); }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.journey-grid { grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 8px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; }
.sec-title { display: flex; align-items: center; gap: 14px; margin: 32px 0 16px; flex-wrap: wrap; }
.sec-title h2 { margin: 0; font-size: 17px; }
.sec-title .line { flex: 1; height: 1px; background: var(--line); }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 13px; font-weight: 550;
  min-height: 38px; padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel);
  color: var(--ink); cursor: pointer; white-space: normal; text-align: center; line-height: 1.4; max-width: 100%; box-shadow: var(--shadow);
  transition: background-color .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease); }
.btn:hover { background: var(--raised); border-color: var(--muted); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--brand2); border-color: var(--brand2); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand); border-color: var(--brand); }
.btn.accent { background: var(--ink); border-color: var(--ink); color: var(--on-brand); }
.btn.accent:hover { background: var(--ink2); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--raised); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=number], input[type=date], input[type=email], textarea, select.in, .content select {
  font: inherit; font-size: 13.5px; width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--sunken); color: var(--ink); transition: border-color .16s, box-shadow .16s; }
.content select { width: auto; max-width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--brand2); box-shadow: var(--ring); }
textarea { min-height: 64px; resize: vertical; line-height: 1.5; }
label { color: var(--ink2); }

/* ---------------------------------------------------------------- badges and states */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; line-height: 18px;
  padding: 2px 8px; border-radius: 6px; background: var(--unk-bg); color: var(--unk); white-space: normal; overflow-wrap: anywhere;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 24%, transparent); }
.badge.ok, .g-verificato .grade { background: var(--ok-bg); color: var(--ok); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 24%, transparent); }
.badge.warn, .g-da_rivedere .grade, .g-ambiguo .grade { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 24%, transparent); }
.badge.bad, .g-conflitto .grade { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 24%, transparent); }
.badge.info { background: var(--info-bg); color: var(--info); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 24%, transparent); }
.badge.human { background: var(--human-bg); color: var(--human); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 24%, transparent); }
.badge.ai { background: var(--ai-bg); color: var(--ai); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 24%, transparent); }
.badge.unk, .g-non_trovato .grade { background: var(--unk-bg); color: var(--unk); }
.badge.alta { background: var(--bad-bg); color: var(--bad); } .badge.media { background: var(--warn-bg); color: var(--warn); }
.badge.bassa { background: var(--unk-bg); color: var(--unk); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: currentColor; }

/* ---------------------------------------------------------------- tender header and tabs */
.th { background: linear-gradient(125deg, var(--panel), var(--bg)); border-bottom: 1px solid var(--line); padding: 28px var(--space-page) 0; }
.th .kicker { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.th h1 { margin: 12px 0 8px; font-size: clamp(23px, 2vw, 30px); max-width: 1100px; line-height: 1.3; }
.th .facts { display: flex; gap: 28px; flex-wrap: wrap; margin: 12px 0 14px; }
.th .facts div { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.th .facts b { display: block; font-size: 14px; color: var(--ink); font-weight: 600; text-transform: none; letter-spacing: 0;
  font-variant-numeric: tabular-nums; margin-top: 1px; }
.th .facts div .btn, .th .facts div .badge { text-transform: none; letter-spacing: 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 -4px; padding-top: 4px; scroll-padding-inline: 4px; }
.tabs a { padding: 12px 14px 14px; font-size: 13px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 550;
  white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); background: var(--raised); border-radius: 8px 8px 0 0; }
.tabs a.on { border-color: var(--brand2); color: var(--brand); }
.tabs .cnt { font-size: 11px; font-weight: 600; background: var(--warn-bg); color: var(--warn); padding: 0 6px;
  border-radius: 9px; margin-left: 5px; }
.tabs .later { color: var(--faint); font-weight: 500; }

/* ---------------------------------------------------------------- facts: every card shows its epistemic state */
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 14px; }
.fact { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--panel); position: relative; }
.fact-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.fact-value { font-weight: 600; font-size: 14px; word-break: break-word; font-variant-numeric: tabular-nums; }
.fact.g-da_rivedere, .fact.g-ambiguo { border-left: 3px solid #e0a84a; }
.fact.g-conflitto { border-left: 3px solid var(--bad); background: var(--bad-bg); }
.fact.g-non_trovato { border-style: dashed; background: var(--sunken); }
.g-non_trovato .fact-value { color: var(--muted); font-weight: 500; font-style: italic; }
.fact-meta { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.fact .note { font-size: 12px; color: var(--ink2); margin-top: 5px; }
.fact .ai-was { font-size: 11.5px; color: var(--muted); text-decoration: line-through; margin-top: 3px; }
.fact details.fa { margin-top: 6px; } .fact details.fa summary { font-size: 11.5px; color: var(--muted); cursor: pointer; list-style: none; }
.fact details.fa summary:hover { color: var(--ink); }
.fact details.fa[open] { background: var(--sunken); border: 1px solid var(--line2); padding: 8px; border-radius: 6px; }
.fact details.fa form { display: grid; gap: 6px; margin-top: 6px; }
.fact.wide { grid-column: 1 / -1; }
.fact.g-human { border-left: 3px solid var(--human); }
.cite { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 0 6px; line-height: 18px;
  border-radius: 5px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink2); cursor: pointer; }
.cite:hover { border-color: var(--brand2); color: var(--brand2); text-decoration: none; }
.cite.v-exact, .cite.v-fuzzy, .cite.v-other_page { border-color: #4d7b5d; color: var(--ok); background: var(--ok-bg); }
.cite.v-not_found, .cite.v-bad_doc, .cite.v-too_short { border-color: #947645; color: var(--warn); background: var(--warn-bg); }

/* ---------------------------------------------------------------- tables */
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--sunken); white-space: nowrap; }
table.t th:first-child { border-top-left-radius: 6px; } table.t th:last-child { border-top-right-radius: 6px; }
table.t td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tbody tr:hover td, table.t tr:hover > td { background: var(--raised); }
table.t tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num .badge { white-space: nowrap; }

/* ---------------------------------------------------------------- checks */
.check { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line2); }
.check:last-child { border-bottom: 0; }
.check .ic { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; font-size: 11.5px; flex: none;
  margin-top: 1px; font-weight: 700; }
.check.ok .ic { background: var(--ok-bg); color: var(--ok); } .check.warn .ic { background: var(--warn-bg); color: var(--warn); }
.check.error .ic { background: var(--bad-bg); color: var(--bad); } .check.info .ic { background: var(--info-bg); color: var(--info); }
.check .d { font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- stat cards */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .v { font-size: 30px; font-weight: 600; margin-top: 6px; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); }
.stat.hl { border-color: #71503d; background: var(--brand-bg); }

/* ---------------------------------------------------------------- offer architecture */
.chapter { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.chapter > .ch-head { display: flex; gap: 14px; align-items: center; padding: 12px 16px; background: var(--sunken); border-bottom: 1px solid var(--line); }
.ch-head .n { width: 28px; height: 28px; border-radius: 6px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center;
  font-weight: 650; flex: none; font-size: 13px; }
.ch-head .ttl { flex: 1; font-weight: 650; font-size: 14.5px; }
.ch-head .pts { text-align: right; min-width: 120px; }
.ch-head .pts b { font-size: 17px; font-variant-numeric: tabular-nums; }
.bar { height: 5px; background: var(--line2); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--brand2); border-radius: 3px; }
.para { padding: 12px 16px 12px 58px; border-bottom: 1px solid var(--line2); }
.para:last-child { border-bottom: 0; }
.para .ph { display: flex; gap: 10px; align-items: baseline; }
.para .ph .pn { font-weight: 650; color: var(--brand2); min-width: 34px; font-variant-numeric: tabular-nums; }
.para .ph .pt { font-weight: 600; flex: 1; }
.para .look { background: var(--ai-bg); border-radius: 6px; padding: 8px 10px; margin: 8px 0; font-size: 13px; color: var(--ai); }
.need { display: inline-flex; gap: 6px; align-items: center; border: 1px dashed var(--line-strong); border-radius: 6px; padding: 2px 8px;
  margin: 3px 4px 0 0; font-size: 12px; background: var(--panel); }
.need .o { font-weight: 650; color: var(--human); }
.need.done { opacity: .8; }
.need .ans-inline { display: block; font-size: 12px; color: var(--ok); margin-top: 2px; }
.risk { font-size: 12.5px; color: var(--bad); margin-top: 4px; }

/* ---------------------------------------------------------------- work queue */
.q { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.q.done { background: var(--sunken); box-shadow: none; }
.q .qh { display: flex; gap: 8px; align-items: flex-start; }
.q .qt { font-weight: 600; flex: 1; }
.q .why { font-size: 12.5px; color: var(--muted); margin: 4px 0; }
.q .ans { background: var(--human-bg); border-radius: 6px; padding: 8px 10px; margin-top: 6px; font-size: 13px; }
.q form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; align-items: start; }
.q form .acts { display: flex; flex-direction: column; gap: 6px; }
.owner-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.owner-chips a { border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px 10px; background: var(--panel); font-size: 12.5px;
  color: var(--ink2); font-weight: 500; }
.owner-chips a:hover { text-decoration: none; background: var(--sunken); }
.owner-chips a.on { background: var(--ink); color: var(--on-brand); border-color: var(--ink); }

/* ---------------------------------------------------------------- source drawer */
.drawer { position: fixed; top: 0; right: 0; width: min(720px, 94vw); height: 100vh; height: 100dvh; background: var(--panel); border-left: 1px solid var(--line);
  visibility: hidden; box-shadow: -12px 0 48px rgb(0 0 0 / 32%); transform: translateX(105%); transition: transform .22s var(--ease), visibility .22s; z-index: 50;
  display: flex; flex-direction: column; }
.drawer.open { transform: none; visibility: visible; }
.drawer .dh { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.drawer .db { padding: 14px 18px; overflow: auto; flex: 1; }
.drawer pre { white-space: pre-wrap; font-family: "Cascadia Mono", "SF Mono", Consolas, monospace; font-size: 12px; line-height: 1.6;
  background: var(--sunken); border: 1px solid var(--line2); border-radius: 6px; padding: 12px; }
.drawer mark { background: var(--warn); color: #261f12; padding: 1px 0; border-radius: 2px; box-shadow: 0 0 0 2px var(--warn); }
.src-quote { border-left: 3px solid var(--brand2); padding: 6px 10px; background: var(--brand-bg); border-radius: 0 6px 6px 0;
  margin-bottom: 10px; font-size: 13px; }
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 58%); z-index: 40; display: none; }
.scrim.open { display: block; }

/* ---------------------------------------------------------------- page header, cards, messages */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--sunken); font-size: 13.5px; }
.hero { background: radial-gradient(ellipse at 100% 0, rgb(232 171 137 / 9%), transparent 65%), var(--panel);
  border: 1px solid var(--line); border-radius: 20px; padding: clamp(24px, 3vw, 44px); margin-bottom: 24px;
  box-shadow: var(--shadow); }
.hero h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(26px, 2.6vw, 40px); font-weight: 400; line-height: 1.18;
  letter-spacing: -.035em; margin-bottom: 16px; max-width: 900px; text-wrap: balance; }
.hero p { color: var(--muted); margin: 4px 0 0; max-width: 860px; font-size: 14px; line-height: 1.75; }
.card-t { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; color: var(--ink);
  box-shadow: var(--shadow); transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease); }
.card-t:hover { border-color: #947661; box-shadow: var(--shadow-pop); text-decoration: none; }
.card-t .ttl { font-weight: 600; margin: 16px 0 8px; font-size: 17px; line-height: 1.45; letter-spacing: -.015em; }
.card-t .meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }
.run-note { font-size: 12px; color: var(--ai); background: var(--ai-bg); border-radius: 6px; padding: 5px 10px; display: inline-flex; gap: 6px; align-items: center; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
ul.clean { margin: 0; padding-left: 18px; } ul.clean li { margin: 3px 0; }
.pill-line { display: flex; gap: 6px; flex-wrap: wrap; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; border: 1px solid transparent;
  border-left-width: 3px; background: var(--panel); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: #79623e; border-left-color: var(--warn); }
.flash.info { background: var(--info-bg); color: var(--info); border-color: #526780; border-left-color: var(--info); }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: #85504c; border-left-color: var(--bad); margin: 12px 32px 0; }
.main > .flash.warn { margin: 12px 32px 0 !important; }
code { font-family: "Cascadia Mono", "SF Mono", Consolas, monospace; font-size: 12px; background: var(--line2); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .foot { display: none; }
  .cols, .g3, .g4 { grid-template-columns: 1fr; }
  .content, .th { padding-left: 16px; padding-right: 16px; } .top { padding: 0 16px; }
}

/* ---------------------------------------------------------------- brain and studio */
.asset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 20px; box-shadow: var(--shadow); }
.asset:target { outline: 2px solid var(--brand2); outline-offset: 1px; }
.asset .at { font-weight: 650; margin: 4px 0; }
.asset .rt { font-size: 12.5px; background: var(--sunken); border-left: 3px solid var(--line-strong); padding: 6px 10px; margin-top: 6px;
  color: var(--ink2); white-space: pre-wrap; max-height: 150px; overflow: auto; border-radius: 0 6px 6px 0; }
.asset .fx { font-size: 12px; color: var(--ink2); margin-top: 4px; }
.asset.excluded { border-style: dashed; background: var(--sunken); }
.type-chip { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand2); }
.cov { font-weight: 600; font-size: 11.5px; padding: 0 7px; line-height: 18px; border-radius: 5px; }
.cov-forte { background: var(--ok-bg); color: var(--ok); } .cov-parziale { background: var(--warn-bg); color: var(--warn); }
.cov-debole, .cov-assente { background: var(--bad-bg); color: var(--bad); }
.draft { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 32px; font-size: 15px; line-height: 1.8;
  box-shadow: var(--shadow); max-width: 900px; }
.draft h3, .draft h4, .draft h5 { margin: 16px 0 6px; } .draft p { margin: 6px 0; } .draft ul, .draft ol { margin: 6px 0 6px 20px; padding: 0; }
.draft .aref { font-size: 11.5px; font-weight: 600; background: var(--brand-bg); color: var(--brand2); padding: 0 6px; border-radius: 5px; white-space: nowrap; }
.draft .aref.bad { background: var(--bad-bg); color: var(--bad); }
.tbc { background: var(--warn-bg); color: var(--warn); font-weight: 600; font-size: 12.5px; padding: 1px 6px; border-radius: 4px; border: 1px dashed var(--warn); }
.status-strip { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-radius: var(--radius); margin-bottom: 12px;
  font-weight: 600; font-size: 13.5px; border: 1px solid transparent; }
.status-strip.bozza_ai { background: var(--ai-bg); color: var(--ai); border-color: #527c7c; }
.status-strip.approvata { background: var(--ok-bg); color: var(--ok); border-color: #4d7b5d; }
.status-strip.rifiutata { background: var(--bad-bg); color: var(--bad); border-color: #85504c; }
.status-strip.modificata { background: var(--human-bg); color: var(--human); border-color: #78618c; }
.ver { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ver a { font-size: 12px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 8px; background: var(--panel); }
.ver a.on { background: var(--brand-bg); color: var(--brand); border-color: var(--brand); }
.band { font-size: 18px; font-weight: 750; text-transform: uppercase; letter-spacing: .02em; }

/* ---------------------------------------------------------------- iteration 1: human layer, decision, economics */
.badge.soon { background: var(--line2); color: var(--muted); font-weight: 600; font-size: 10px; padding: 0 6px; margin-left: 4px; box-shadow: none; }
.nav-off { display: flex; gap: 9px; align-items: center; padding: 6px 10px; color: var(--faint); cursor: default; font-size: 13.5px; }
.decision-badge { display: inline-block; font-weight: 750; font-size: 18px; padding: 5px 12px; border-radius: 6px; margin-bottom: 6px; letter-spacing: .01em; }
.d-GO { background: var(--ok-bg); color: var(--ok); } .d-NO_GO { background: var(--bad-bg); color: var(--bad); }
.d-GO_CON_RISERVA { background: var(--warn-bg); color: var(--warn); }
.badge.d-GO, .badge.d-NO_GO, .badge.d-GO_CON_RISERVA { font-size: 10px; padding: 0 6px; }
.badge.nat-fatto { background: var(--ok-bg); color: var(--ok); } .badge.nat-ipotesi { background: var(--human-bg); color: var(--human); }
.badge.nat-derivato { background: var(--unk-bg); color: var(--ink2); } .badge.nat-decisione { background: var(--warn-bg); color: var(--warn); }
.badge.nat-mancante { background: var(--bad-bg); color: var(--bad); }
.answer { border-top: 1px solid var(--line); padding: 10px 0; }
.answer .q { font-weight: 650; margin-bottom: 4px; border: 0; padding: 0; box-shadow: none; background: none; }

/* ---------------------------------------------------------------- iteration 2: studio */
.need-card { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin: 10px 0; background: var(--panel); }
.need-card.s-risolto { border-left: 3px solid var(--ok); } .need-card.s-proposto { border-left: 3px solid var(--ai); }
.need-card.s-aperto { border-left: 3px solid var(--warn); }
.badge.fam-riusabile { background: var(--ok-bg); color: var(--ok); } .badge.fam-specifico_gara { background: var(--brand-bg); color: var(--brand2); }
.badge.fam-decisione { background: var(--warn-bg); color: var(--warn); } .badge.fam-evidenza { background: var(--human-bg); color: var(--human); }
.badge.fam-costo { background: var(--bad-bg); color: var(--bad); }
.badge.imp-decisivo { background: var(--brand); color: var(--on-brand); box-shadow: none; } .badge.imp-alto { background: var(--brand2); color: var(--on-brand); box-shadow: none; }
.badge.imp-medio { background: var(--brand-bg); color: var(--brand2); } .badge.imp-basso { background: var(--line2); color: var(--muted); }
.draft table.mdt { margin: 8px 0; font-size: 13px; }
.look { background: var(--ai-bg); padding: 8px; border-radius: 6px; }
.diff del { background: var(--bad-bg); color: var(--bad); } .diff ins { background: var(--ok-bg); color: var(--ok); text-decoration: none; }

/* Shared finishing: native controls stay native, tables retain their semantics. */
html { scrollbar-color: var(--line-strong) var(--sunken); scroll-padding-top: 90px; }
:where(.grid, .cols, .row, .facts-grid) > * { min-width: 0; }
:where(.panel, .fact, .q, .asset, .card-t, .draft, .flash, .kv, .th, .drawer) { overflow-wrap: anywhere; }
.panel:has(> table), .panel > div:has(> table), .draft:has(> table) { overflow-x: auto; }
.panel > table { min-width: 100%; }
table:focus-visible, .drawer .db:focus-visible { outline-offset: -2px; }
.panel:has(> table:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.card-t .meta { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 18px; }
.card-t .meta > span { flex: 1 1 42%; }
.side a, .tabs a, .owner-chips a, .ver a, summary { transition: background-color .16s, color .16s, border-color .16s; }
summary { cursor: pointer; color: var(--ink2); padding-block: 4px; }
summary:hover, details[open] > summary { color: var(--brand); }
details[open] > summary { margin-bottom: 8px; }
summary::marker { color: var(--muted); }
input, select, textarea { max-width: 100%; accent-color: var(--brand2); }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; vertical-align: middle; }
input[type=file] { font: inherit; width: 100%; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--sunken); color: var(--ink2); }
input[type=file]::file-selector-button { font: inherit; background: var(--raised); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 12px; margin-right: 12px; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--line); }
form[data-busy] button[type=submit]:disabled { opacity: 1; background: var(--brand-bg); color: var(--brand); border-color: var(--brand); cursor: progress; }
form[data-busy] button[type=submit]:disabled::before { content: ""; width: 12px; height: 12px; flex: none; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: bp-spin .8s linear infinite; }
.run-note, .status-strip, .need { flex-wrap: wrap; }
.empty { padding: 40px 24px; }
.top form { flex-wrap: wrap; }
.top input[type=text], .top select { min-height: 32px; color: var(--ink); }
.cite { max-width: 100%; }
.drawer .dh { background: var(--sunken); min-height: 68px; }
.drawer .db { overscroll-behavior: contain; }
@keyframes bp-spin { to { transform: rotate(360deg); } }
@keyframes bp-enter { from { opacity: .7; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .content { animation: bp-enter .2s var(--ease) both; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card-t:hover { transform: translateY(-2px); }
}
@media (max-width: 1280px) {
  .top { flex-wrap: wrap; }
  .cols { grid-template-columns: 1fr; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .side { padding: 18px var(--space-page); gap: 6px; height: auto; }
  .side .logo { flex-basis: 100%; margin: 0 0 12px; }
  .side .sep { flex-basis: 100%; margin: 12px 10px 2px; }
  .side .sep:has(+ .foot) { display: none; }
  .side a { padding: 9px 12px; }
  .top { position: static; padding: 14px var(--space-page); }
  .content, .th { padding-left: var(--space-page); padding-right: var(--space-page); }
  .content { padding-top: 24px; }
}
@media (max-width: 640px) {
  :root { --space-page: 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  /* Wrap existing actions rather than hiding them behind a new menu button. */
  .side { padding: 12px 16px; min-width: 0; flex-wrap: wrap; align-items: center; }
  .side .logo { flex: none; margin: 0 12px 0 0; }
  .side .logo small, .side .sep { display: none; }
  .side .logo + .sep { display: block; flex-basis: 100%; margin: 4px 0; }
  .side a, .nav-off { font-size: 13px; flex: none; white-space: nowrap; }
  .top .crumbs { flex-basis: 100%; white-space: normal; overflow-wrap: anywhere; }
  .top .grow { display: none; }
  .top form { max-width: 100%; gap: 8px; }
  .panel, .card-t, .q, .asset, .draft { padding: 18px; }
  .hero { padding: 24px 20px; }
  .th .facts { gap: 16px 24px; }
  .th .facts > div { flex: 1 1 40%; }
  .btn { min-height: 42px; }
  .btn.sm { min-height: 36px; }
  .top select, .top input[type=text], input[type=text], input[type=number], input[type=date], input[type=email], textarea, select.in, .content select { font-size: 16px; min-height: 40px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .kv dd { margin-bottom: 10px; }
  .q form { grid-template-columns: minmax(0, 1fr); }
  .q form .acts { flex-direction: row; flex-wrap: wrap; }
  .para { padding: 16px; }
  .para .ph, .ch-head { flex-wrap: wrap; }
  .ch-head .pts { min-width: 0; }
  .status-strip { gap: 8px; }
  .main > .flash.warn { margin: 12px 16px 0 !important; }
  .flash-error { margin: 12px 16px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .btn, .badge, .cite, .panel, .card-t { border: 1px solid CanvasText; }
  .side a.on, .tabs a.on { outline: 2px solid Highlight; outline-offset: -2px; }
}
