:root {
  --bg: #f5f7f7; --fg: #1b3035; --muted: #58696d; --card: #fff; --line: #dce4e5;
  --accent: #096b70; --link: #096b70; --ok: #24714d; --warn: #855600; --bad: #b02e36;
  --code: #eef3f3; --hl: #fff1bb; --soft: #e7f3f2; --amber: #fff3d7;
  --shadow: 0 8px 30px #153d4310; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111c20; --fg: #e0ecee; --muted: #a6b9be; --card: #19272c; --line: #33464b;
    --accent: #096b70; --link: #86d8d4; --ok: #8dd9b1; --warn: #f2cb79; --bad: #ffabb0;
    --code: #23343a; --hl: #4a431e; --soft: #203b3e; --amber: #42371d; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.65 "Segoe UI", Inter, system-ui, -apple-system, sans-serif; }
a { color: var(--link); }
header.top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .6rem 1.2rem;
  background: var(--card); border-bottom: 2px solid var(--accent); }
header.top .brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--fg);
  text-decoration: none; }
header.top .brand img { width: 28px; height: 28px; }
header.top nav { display: flex; gap: .9rem; flex: 1; flex-wrap: wrap; }
header.top nav a { color: var(--muted); text-decoration: none; padding: .1rem 0; }
header.top nav a.on { color: var(--fg); border-bottom: 2px solid var(--accent); }
header.top .who { color: var(--muted); font-size: .9em; }
main { max-width: 1240px; margin: 0 auto; padding: 2.5rem 2rem 5rem; min-height: 80vh; }
h1 { font-size: 1.5rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; }
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.card .n { font-size: 1.8rem; font-weight: 700; }
.card .l { color: var(--muted); font-size: .85em; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8em; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.s-running { color: var(--link); }
.s-done, .s-approved { color: var(--ok); }
.s-waiting_gate, .s-blocked, .s-queued { color: var(--warn); }
.s-failed, .s-cancelled, .s-rejected { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.notice { background: var(--card); border-left: 4px solid var(--ok); padding: .5rem .8rem; margin: .6rem 0; }
.errorbox { border-left-color: var(--bad); }
pre, code { background: var(--code); border-radius: 4px; }
code { padding: 0 .25em; }
pre { padding: .6rem .8rem; overflow-x: auto; }
pre.report { white-space: pre-wrap; }
.doc { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .4rem 1.2rem 1rem;
  overflow-x: auto; }
.doc table { margin: .6rem 0; }
.doc pre code { background: none; }
.doc pre.mermaid { background: #fff; text-align: center; overflow-x: auto; }
.doc pre.mermaid svg { max-width: 100%; height: auto; }
.doc .footnotes { font-size: .85em; border-top: 1px solid var(--code); margin-top: 2rem; padding-top: .5rem; }
a.cite { font-family: ui-monospace, Consolas, monospace; font-size: .9em; text-decoration: none;
  border-bottom: 1px dotted var(--link); }
table.src { border: 0; font: 13px/1.45 ui-monospace, Consolas, monospace; }
table.src td { border: 0; padding: 0 .6rem; white-space: pre; }
table.src td.ln { color: var(--muted); text-align: right; user-select: none; width: 1%; }
table.src tr.hl td, table.src tr:target td { background: var(--hl); }
button, textarea { font: inherit; padding: .35rem .7rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); }
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
textarea { width: 100%; }
.chat { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.msg { padding: .5rem .8rem; border-radius: 8px; max-width: 85%; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); }
.tools { color: var(--muted); font-size: .8em; margin-top: .3rem; }
.htmx-request button { opacity: .6; }
/* Knowledge library */
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
[hidden] { display: none !important; }
::selection { background: var(--soft); }
:focus-visible { outline: 3px solid var(--link); outline-offset: 4px; }
a { text-underline-offset: 3px; }
p { margin: .7rem 0 1rem; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.025em; }
h1 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 650; }
h2 { font-size: 1.55rem; margin: 1.8rem 0 1rem; font-weight: 650; }
h3 { font-size: 1.2rem; font-weight: 650; }
header.top { padding: 1.15rem 2rem; gap: 1.5rem; border-bottom: 1px solid var(--line); }
header.top .brand { gap: .8rem; white-space: nowrap; font-size: 1.12rem; }
header.top .brand img { width: 34px; height: 34px; }
.brand-description { font-size: .85rem; font-weight: 400; color: var(--muted); }
header.top nav { justify-content: flex-end; align-items: center; gap: 1.7rem; font-size: .9rem; }
header.top nav a { padding: .35rem 0; white-space: nowrap; }
header.top nav a.on { color: var(--link); border-bottom: 2px solid var(--link); }
header.top .who { font-size: .75rem; }
.operations-menu { position: relative; }
summary { cursor: pointer; }
.menu-panel { position: absolute; right: 0; top: 2.1rem; z-index: 20; padding: .7rem 1.2rem; min-width: 225px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.menu-panel a { display: block; }
.skip-link { position: absolute; top: -70px; left: 1rem; background: var(--card); padding: .8rem; z-index: 50; }
.skip-link:focus { top: 0; }
.site-footer { max-width: 1240px; margin: auto; border-top: 1px solid var(--line); padding: 1.7rem 2rem; display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .8rem; }
.hero { padding: 2.4rem 0 3.7rem; max-width: 850px; }
.eyebrow { color: var(--link); font-size: .7rem; text-transform: uppercase; letter-spacing: .14em; font-weight: 700; margin: 0 0 .8rem; }
.hero h1 { font-size: clamp(2.5rem, 5vw, 4.3rem); line-height: 1.1; letter-spacing: -.045em; margin: .9rem 0 1.4rem; }
.hero h1 span { color: var(--link); }
.lead { font-size: 1.15rem; line-height: 1.7; color: var(--muted); max-width: 700px; }
.lead.compact { max-width: 780px; }
.actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 1.8rem; }
.button, button { display: inline-flex; align-items: center; justify-content: center; gap: .8rem; min-height: 44px; padding: .65rem 1.15rem; border-radius: 7px; text-decoration: none; font-size: .9rem; font-weight: 600; border: 1px solid var(--line); }
.button.primary, button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.secondary { color: var(--link); background: var(--card); }
.button:hover, button:hover { filter: brightness(.94); }
.reading-guide { display: grid; grid-template-columns: .65fr 1fr 1.25fr 1.2fr; gap: 2rem; padding: 1.65rem 1.8rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.reading-guide h2 { font-size: 1rem; margin: 0; }
.reading-guide strong { font-size: .87rem; }
.reading-guide p { color: var(--muted); font-size: .83rem; line-height: 1.65; margin: .45rem 0 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2.9rem 0 1.3rem; }
.section-heading h2, .section-heading h1 { margin: .25rem 0 0; }
.section-heading .eyebrow { margin: 0; }
.service-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1.5rem; }
.service-card { background: var(--card); padding: 1.8rem; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.service-card-heading { display: flex; align-items: center; gap: 1rem; }
.service-monogram { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); color: var(--link); font-size: 1.1rem; letter-spacing: -.02em; flex-shrink: 0; }
.service-card h3 { font-size: 1.4rem; margin: 0; }
.service-card h3 a { text-decoration: none; color: var(--fg); }
.service-card .eyebrow { font-size: .62rem; margin-bottom: .35rem; }
.service-summary { color: var(--muted); font-size: .94rem; margin: 1.4rem 0; }
.service-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: .6rem; margin: auto 0 1.4rem; padding: 1.2rem 0; border-block: 1px solid var(--line); }
.service-stats div { display: flex; flex-direction: column-reverse; }
.service-stats dt { font-size: .72rem; color: var(--muted); }
.service-stats dd { margin: 0; font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.review-summary { background: var(--bg); padding: 1rem; border-radius: 7px; font-size: .83rem; }
.review-summary p { margin: 0 0 .5rem; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-right: .35rem; }
.card-bottom { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin: 1.3rem 0 .2rem; font-size: .85rem; }
.card-bottom .button { font-size: .82rem; padding-inline: .8rem; }
.updated { margin-bottom: 0; font-size: .72rem; }
.badge, .customer, .count-pill { display: inline-block; padding: .1em .55em; border-radius: 5px; font-size: .75rem; line-height: 1.6; font-weight: 600; vertical-align: baseline; letter-spacing: 0; white-space: nowrap; }
.unverified { color: var(--warn); background: var(--amber); }
.customer.noo { color: var(--link); background: var(--soft); }
.customer.egd { color: #34589b; background: #eaf0ff; }
.customer.both, .neutral, .count-pill { background: var(--code); color: var(--muted); }
.answered { background: var(--soft); color: var(--ok); }
.service-header .section-heading { margin: 1.4rem 0 .4rem; }
.breadcrumb { font-size: .85rem; }
.service-tabs { display: flex; gap: 2rem; border-bottom: 1px solid var(--line); margin: 1.8rem 0 2rem; overflow: auto; }
.service-tabs a { padding: .7rem 0; text-decoration: none; color: var(--muted); white-space: nowrap; font-size: .9rem; }
.service-tabs a.on { color: var(--link); border-bottom: 3px solid var(--link); font-weight: 600; }
.reader-layout { display: grid; grid-template-columns: 235px minmax(0,1fr); gap: 2.2rem; align-items: start; }
.toc { position: sticky; top: 1.5rem; max-height: calc(100vh - 3rem); overflow-y: auto; padding-right: .5rem; }
.toc nav a { display: block; border-left: 2px solid var(--line); padding: .45rem .75rem; font-size: .8rem; color: var(--muted); text-decoration: none; line-height: 1.5; }
.toc nav a:hover, .toc nav a.on { color: var(--link); background: var(--soft); border-color: var(--link); }
.toc-note { margin-top: 1.5rem; padding: 1rem .8rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: .76rem; color: var(--muted); }
.doc { padding: 2rem 2.4rem; border-radius: 10px; overflow: visible; min-width: 0; overflow-wrap: anywhere; }
.business-document { font-size: 16.5px; line-height: 1.8; }
.business-document > h1 { font-size: 1.8rem; }
.business-document > h1 + p { font-size: .8rem; color: var(--muted); }
.doc h2 { border-top: 1px solid var(--line); padding-top: 2rem; margin-top: 3rem; font-size: 1.65rem; }
.doc h3 { margin: 2rem 0 1rem; }
.doc h4 { font-size: 1.07rem; margin: 2rem 0 1rem; }
.doc p, .doc li { max-width: 76ch; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.doc blockquote { border-left: 3px solid var(--line); margin: 1rem 0; padding: .3rem 1.2rem; color: var(--muted); }
.doc pre { max-width: 100%; font-size: .8rem; }
.doc pre.mermaid { background: var(--card); display: flex; justify-content: center; padding: 1.5rem 0; border-block: 1px solid var(--line); }
.doc pre.mermaid svg { display: block; margin: auto; min-width: 450px; }
.doc pre.diagram-error { white-space: pre-wrap; display: block; }
.table-scroll { overflow: auto; max-height: 70vh; margin: 1.2rem 0; border: 1px solid var(--line); border-radius: 7px; }
table { border: 0; overflow: visible; border-collapse: separate; border-spacing: 0; }
th { font-size: .7rem; letter-spacing: .05em; background: var(--code); color: var(--muted); position: sticky; top: 0; z-index: 2; }
td, th { padding: .8rem .9rem; }
tbody tr:nth-child(even) { background: var(--bg); }
.doc table { font-size: .83rem; line-height: 1.6; margin: 0; }
.doc td { min-width: 100px; }
.doc td[id] { white-space: nowrap; }
[id]:target { scroll-margin-top: 2rem; }
.doc td:target, .doc h4:target { background: var(--hl); outline: 2px solid var(--warn); }
.rule-link { font-weight: 650; white-space: nowrap; }
.citation-button { display: inline; min-height: 0; padding: .05em .3em; border: 0; background: var(--soft); color: var(--link); font-size: .67rem; border-radius: 3px; line-height: 1.3; margin: 0 .08rem; }
.citation-popover { width: min(640px,calc(100vw - 2rem)); max-height: 55vh; overflow: auto; padding: 1.4rem; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 15px 70px #0003; font-size: .85rem; overflow-wrap: anywhere; }
.citation-popover::backdrop { background: #0000000a; }
.citation-popover p { max-width: none; }
input, select, textarea { background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; font: inherit; padding: .7rem .8rem; width: 100%; }
label { display: block; font-size: .85rem; font-weight: 600; }
label input, label select { display: block; margin-top: .4rem; }
.filter-bar { display: grid; grid-template-columns: 1.7fr 1fr 1fr 1.2fr auto; gap: .8rem; align-items: end; background: var(--card); padding: 1.3rem; border: 1px solid var(--line); border-radius: 10px; margin-top: 1.5rem; }
.filter-bar select, .filter-bar input { font-size: .8rem; }
.rules-table { font-size: .88rem; }
.rules-table td:first-child { width: 95px; }
.rules-table td:nth-child(2) { min-width: 300px; }
.rule-group { display: block; margin-bottom: .5rem; }
.empty-state { text-align: center; padding: 3rem; color: var(--muted); }
.question-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.question-card { padding: 1.5rem; border: 1px solid var(--line); background: var(--card); border-radius: 10px; }
.question-meta { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; }
.question-meta a { text-decoration: none; font-weight: 650; }
.question-card h3 { line-height: 1.5; font-size: 1rem; }
.question-body { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.question-group { margin-top: 2.5rem; }
.verification-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1.2rem; margin: 2rem 0; }
.verification-card { padding: 1.6rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: .87rem; }
.verification-card h3 { font-size: 1.2rem; }
.verdict { padding: 1rem 0; border-block: 1px solid var(--line); font-size: 1.16rem; font-weight: 600; }
.review-numbers { margin: 1rem 0 2rem; }
.review-numbers div { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; padding: .4rem 0; }
.review-numbers dt { color: var(--muted); }
.review-numbers dd { margin: 0; font-weight: 650; }
.review-notice { border-left-color: var(--warn); font-size: .88rem; padding: 1rem; }
.report-document { max-width: 960px; margin: 1.5rem auto; }
.page-intro { padding: 1rem 0 1.5rem; }
.advice-layout { display: grid; grid-template-columns: minmax(0,2fr) minmax(230px,1fr); gap: 3rem; align-items: start; }
.advice-form { padding: 2rem; }
.advice-form label { margin: 1.3rem 0 .45rem; }
.advice-form label:first-child { margin-top: 0; }
.advice-aside h2 { margin-top: 0; font-size: 1.15rem; }
.advice-aside ol { padding-left: 1.3rem; font-size: .88rem; color: var(--muted); }
.advice-aside li { margin: .7rem 0; }
.saved-advice { list-style: none; padding: 0; }
.saved-advice li { border-bottom: 1px solid var(--line); padding-bottom: .8rem; overflow-wrap: anywhere; }
.saved-advice span { display: block; }
.ticket-context { padding: 1rem 1.5rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.ticket-context pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.advice-answer { max-width: 930px; }
.answer-section { display: grid; grid-template-columns: 45px minmax(0,1fr); gap: 1rem; border-bottom: 1px solid var(--line); padding: 2rem 0; }
.answer-number { color: var(--link); font-size: .9rem; padding-top: .2rem; }
.answer-section h2 { margin: 0 0 1rem; font-size: 1.4rem; }
.answer-body { overflow-wrap: anywhere; }
@media (prefers-color-scheme: dark) { .customer.egd { background: #263858; color: #b5cafa; } }
@media (max-width: 1100px) {
  header.top { gap: .7rem; } header.top .who { display: none; }
  .brand-description { display: block; font-size: .7rem; }
  .reading-guide { grid-template-columns: repeat(3,1fr); gap: 1.3rem; }
  .reading-guide h2 { grid-column: 1 / -1; }
  .reader-layout { grid-template-columns: 205px minmax(0,1fr); gap: 1.3rem; }
  .doc { padding: 1.6rem; }
  .filter-bar { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filter-bar .search-field { grid-column: 1 / -1; }
}
@media (max-width: 780px) {
  main { padding: 1.5rem 1rem 3rem; } header.top { padding: 1rem; }
  header.top nav { justify-content: flex-start; width: 100%; gap: 1.3rem; flex-basis: 100%; }
  .brand-description { display: inline; }
  .hero { padding: 1.5rem 0 2.5rem; }
  .reading-guide, .service-grid, .question-grid, .verification-grid, .advice-layout { grid-template-columns: 1fr; }
  .reading-guide { gap: 1rem; padding: 1.4rem; }
  .service-card { padding: 1.4rem; }
  .reader-layout { display: block; } .toc { position: static; max-height: none; margin-bottom: 1.5rem; }
  .toc nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); } .toc-note { display: none; }
  .service-tabs { gap: 1.5rem; }
  .doc { padding: 1.2rem; }
  .section-heading { align-items: flex-start; } .service-header .section-heading .button { max-width: 150px; font-size: .8rem; }
  .advice-form { padding: 1.4rem; } .site-footer { flex-direction: column; }
  .menu-panel { right: -1rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media (max-width: 640px) {
  main { padding: .8rem; }
  th, td { padding: .3rem .4rem; }
  .msg { max-width: 100%; }
}
/* Entra sign-in uses the knowledge library's existing palette and components. */
.sign-in { max-width: 640px; margin: clamp(1rem, 6vh, 5rem) auto; padding: clamp(1.5rem, 5vw, 3.5rem);
  border-radius: 16px; box-shadow: var(--shadow); }
.sign-in-logo { display: block; margin-bottom: 2rem; }
.sign-in h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.sign-in .lead { margin-bottom: 1.8rem; }
header.top .who.authenticated { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; overflow-wrap: anywhere; }
.who.authenticated a { white-space: nowrap; }
