/* Operations console that reads like a reference page: dense, institutional,
   one accent. Semantic colour is reserved for contract state and never used
   decoratively, so a red row always means the same thing. */
:root {
  --ground: #F2F5F8;
  --surface: #FFFFFF;
  --surface-2: #E9EFF4;
  --ink: #0D141A;
  --ink-2: #41505C;
  --ink-3: #6E808E;
  --rule: #D0DBE3;
  --rule-2: #B2C3CF;
  --accent: #1B5A8C;
  --accent-soft: #DEEAF3;
  --urgent: #8E3221;
  --urgent-soft: #F6E3DF;
  --soon: #875412;
  --soon-soft: #F6EBD8;
  --later: #2B6350;
  --later-soft: #DEEAE4;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0C1116; --surface: #141C23; --surface-2: #1B242C;
    --ink: #E3EBF1; --ink-2: #A5B6C2; --ink-3: #788996;
    --rule: #25313B; --rule-2: #35454F;
    --accent: #6FACDB; --accent-soft: #152837;
    --urgent: #E0897A; --urgent-soft: #2B1512;
    --soon: #D6A75B; --soon-soft: #2A2012;
    --later: #74BB9E; --later-soft: #12251E;
  }
}
:root[data-theme="dark"] {
  --ground: #0C1116; --surface: #141C23; --surface-2: #1B242C;
  --ink: #E3EBF1; --ink-2: #A5B6C2; --ink-3: #788996;
  --rule: #25313B; --rule-2: #35454F;
  --accent: #6FACDB; --accent-soft: #152837;
  --urgent: #E0897A; --urgent-soft: #2B1512;
  --soon: #D6A75B; --soon-soft: #2A2012;
  --later: #74BB9E; --later-soft: #12251E;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1480px; margin: 0 auto; padding: 20px 22px 64px; }

header.top {
  display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: baseline;
  border-bottom: 2px solid var(--rule-2); padding-bottom: 14px; margin-bottom: 20px;
}
h1 {
  font-family: var(--serif); font-size: 25px; font-weight: 600;
  letter-spacing: -0.01em; margin: 0;
}
.freshness {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  display: flex; gap: 16px; flex-wrap: wrap; margin-left: auto;
}
.freshness b { color: var(--ink-2); font-weight: 600; }
.freshness .warn { color: var(--soon); }
.freshness .bad { color: var(--urgent); }

nav.tabs { display: flex; gap: 2px; margin-bottom: 18px; }
nav.tabs button {
  font-family: var(--sans); font-size: 13.5px; padding: 8px 16px;
  background: transparent; color: var(--ink-2); border: 1px solid transparent;
  border-bottom: 2px solid transparent; cursor: pointer;
}
nav.tabs button[aria-selected="true"] {
  color: var(--ink); border-bottom-color: var(--accent); font-weight: 600;
}
nav.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 3px;
  padding: 11px 14px; margin-bottom: 16px;
}
.controls label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3); display: flex; gap: 7px;
  align-items: center;
}
.controls select, .controls input[type=search] {
  font-family: var(--sans); font-size: 13px; padding: 5px 8px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: 2px;
}
.controls input[type=search] { min-width: 210px; }
.count { font-family: var(--mono); font-size: 12px; color: var(--ink-2); margin-left: auto; }

/* Quarter strip: the shape of the window at a glance, counts not currency. */
.quarters { display: flex; gap: 4px; align-items: flex-end; margin-bottom: 18px; min-height: 92px; }
.q { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; }
.q .bar { background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.q .n { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.q .lbl {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  text-align: center; border-top: 1px solid var(--rule); padding-top: 4px;
}

.tbl-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; }
table { border-collapse: collapse; width: 100%; min-width: 900px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 1;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 500; white-space: nowrap;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
td.date { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
td.ref { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
td.title { max-width: 420px; }

.pill {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 2px; white-space: nowrap;
}
.p-urgent { background: var(--urgent-soft); color: var(--urgent); }
.p-soon { background: var(--soon-soft); color: var(--soon); }
.p-later { background: var(--later-soft); color: var(--later); }
.p-flat { background: var(--surface-2); color: var(--ink-2); }

.caveats {
  background: var(--surface-2); border: 1px solid var(--rule);
  border-left: 3px solid var(--accent); border-radius: 0 3px 3px 0;
  padding: 12px 16px; margin-top: 16px;
}
.caveats h3 {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 7px; font-weight: 500;
}
.caveats ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.caveats li { font-size: 13px; color: var(--ink-2); }

.msg { padding: 18px; font-size: 14px; color: var(--ink-2); }
.msg.err { color: var(--urgent); }
.hidden { display: none; }
a { color: var(--accent); }
button.theme {
  font-family: var(--mono); font-size: 11px; background: transparent;
  color: var(--ink-3); border: 1px solid var(--rule-2); border-radius: 2px;
  padding: 4px 8px; cursor: pointer;
}

/* Profile panels. A grid of small tables rather than cards with big numbers:
   the useful content here is distributions and name variants, and a hero
   figure would have to be a total, which this data cannot support. */
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.panel h3 {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 500;
  margin: 0; padding: 9px 13px; background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
}
.panel table { min-width: 0; }
.panel td, .panel th { padding: 6px 13px; font-size: 13px; }
.panel .wide { grid-column: 1 / -1; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-row .mini { height: 8px; background: var(--accent); border-radius: 1px; min-width: 2px; }
.variants { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.linkish { color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Notice drawer. One component, opened from every table that lists a notice,
   so the drill-down is the same wherever you are. */
.scrim {
  position: fixed; inset: 0; background: rgba(8, 14, 19, 0.5);
  display: flex; justify-content: flex-end; z-index: 50;
}
.scrim[hidden] { display: none; }
.drawer {
  width: min(680px, 100%); background: var(--ground); height: 100%;
  overflow-y: auto; border-left: 1px solid var(--rule-2);
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.22);
}
.drawer-head {
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  border-bottom: 1px solid var(--rule); padding: 14px 18px;
  display: flex; gap: 14px; align-items: flex-start;
}
.drawer-head h2 {
  font-family: var(--serif); font-size: 18px; font-weight: 600;
  margin: 0; line-height: 1.3; text-wrap: balance;
}
.drawer-head .meta { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 5px; }
.drawer-body { padding: 16px 18px 48px; display: flex; flex-direction: column; gap: 14px; }
.facts { display: grid; grid-template-columns: 128px 1fr; gap: 5px 14px; font-size: 13px; }
.facts dt {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-3); padding-top: 2px;
}
.facts dd { margin: 0; color: var(--ink); }
.doclist { display: flex; flex-direction: column; gap: 1px; }
.doc {
  display: flex; gap: 10px; align-items: baseline; padding: 8px 13px;
  background: var(--surface); border: 1px solid var(--rule);
}
.doc + .doc { border-top: 0; }
.doc .fmt { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-left: auto; white-space: nowrap; }
.doc a { word-break: break-all; font-size: 13px; }
.unavail { font-size: 12.5px; color: var(--ink-3); font-style: italic; }
.closebtn {
  margin-left: auto; font-family: var(--mono); font-size: 16px; line-height: 1;
  background: transparent; border: 1px solid var(--rule-2); border-radius: 2px;
  color: var(--ink-2); padding: 4px 9px; cursor: pointer;
}

/* --- Clickable Freshness Bar --- */
.freshness { cursor: pointer; transition: opacity 0.15s ease; }
.freshness:hover { opacity: 0.85; text-decoration: underline dotted; }

/* --- System Health & Diagnostics Drawer --- */
.health-drawer { width: min(760px, 100%); }
.diag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.diag-card { background: var(--surface); border: 1px solid var(--rule); padding: 12px 14px; border-radius: 4px; }
.diag-card h4 { margin: 0 0 8px; font-size: 13px; font-family: var(--mono); text-transform: uppercase; color: var(--ink-2); letter-spacing: 0.05em; }
.diag-card .val { font-size: 20px; font-weight: 600; font-family: var(--mono); color: var(--ink); }
.diag-card .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.diag-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.diag-table th { text-align: left; padding: 6px 8px; font-family: var(--mono); color: var(--ink-3); border-bottom: 1px solid var(--rule); font-weight: normal; }
.diag-table td { padding: 6px 8px; border-bottom: 1px solid var(--rule); font-family: var(--mono); }
.diag-status-ok { color: #16a34a; font-weight: 600; }
.diag-status-warn { color: #d97706; font-weight: 600; }

/* --- Embedded MCP Copilot Chat Widget --- */
.chat-widget { position: fixed; bottom: 20px; right: 24px; z-index: 100; font-family: system-ui, -apple-system, sans-serif; }
.chat-toggle {
  display: flex; align-items: center; gap: 8px; background: #0f172a; color: #fff;
  border: 1px solid #334155; border-radius: 30px; padding: 10px 18px; font-size: 14px;
  font-weight: 500; cursor: pointer; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, background 0.15s ease;
}
.chat-toggle:hover { transform: translateY(-2px); background: #1e293b; }
.chat-toggle .chat-icon { font-size: 16px; }

.chat-panel {
  position: absolute; bottom: 54px; right: 0; width: min(440px, calc(100vw - 32px));
  height: 560px; max-height: calc(100vh - 100px); background: var(--ground);
  border: 1px solid var(--rule-2); border-radius: 8px; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-panel[hidden] { display: none; }

.chat-head {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.chat-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.chat-head .chat-sub { font-size: 11px; font-family: var(--mono); color: var(--ink-3); }
.chat-head .chat-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-2); line-height: 1; padding: 0 4px; }

.chat-prompts { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--rule); }
.chat-prompts::-webkit-scrollbar { height: 4px; }
.prompt-chip {
  white-space: nowrap; font-size: 11px; font-family: var(--mono); padding: 4px 9px;
  background: transparent; border: 1px solid var(--rule-2); border-radius: 12px;
  color: var(--ink-2); cursor: pointer;
}
.prompt-chip:hover { border-color: var(--ink); color: var(--ink); }

.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; font-size: 13.5px; line-height: 1.45; }
.chat-msg { max-width: 88%; padding: 10px 13px; border-radius: 8px; word-break: break-word; }
.chat-msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--rule); color: var(--ink); }
.chat-msg.user { align-self: flex-end; background: #0284c7; color: #fff; }
.chat-msg.system { align-self: center; font-size: 11.5px; font-style: italic; color: var(--ink-3); background: transparent; }

.chat-msg p { margin: 0 0 6px; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg ul, .chat-msg ol { margin: 4px 0 6px 18px; padding: 0; }
.chat-msg li { margin-bottom: 3px; }
.chat-msg table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 6px 0; }
.chat-msg th, .chat-msg td { padding: 4px 6px; border: 1px solid var(--rule); text-align: left; }
.chat-msg code { font-family: var(--mono); font-size: 12px; background: rgba(125, 125, 125, 0.15); padding: 1px 4px; border-radius: 3px; }

.chat-form { display: flex; gap: 8px; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--rule); }
.chat-form input { flex: 1; padding: 8px 12px; border: 1px solid var(--rule-2); border-radius: 4px; background: var(--ground); color: var(--ink); font-size: 13px; }
.chat-form input:focus { outline: none; border-color: #0284c7; }
.chat-form button { padding: 8px 14px; background: #0284c7; color: #fff; border: none; border-radius: 4px; font-size: 13px; font-weight: 500; cursor: pointer; }
.chat-form button:disabled { opacity: 0.5; cursor: not-allowed; }

