:root {
  --ink: #18201f;
  --ink-deep: #111716;
  --ink-soft: #28332f;
  --muted: #68716e;
  --paper: #f3f5f1;
  --surface: #ffffff;
  --line: #d9ded8;
  --green: #087f5b;
  --green-bright: #42d69e;
  --green-soft: #dff4ea;
  --amber: #a85b00;
  --amber-soft: #fff0d5;
  --red: #b5352f;
  --red-soft: #fbe5e2;
  --blue: #1769aa;
  --mono: "IBM Plex Mono", "Cascadia Mono", "Consolas", monospace;
  --sans: "Manrope", "Segoe UI Variable", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); }
button, a { font: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: clamp(25px, 2.6vw, 38px); font-weight: 600; letter-spacing: -.025em; }
h2 { margin-bottom: 0; font-size: 19px; font-weight: 650; letter-spacing: -.015em; }

.topbar {
  min-height: 116px;
  padding: 22px clamp(20px, 3vw, 52px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  color: #fff;
  background: var(--ink-deep);
  border-bottom: 4px solid #34b78a;
}
.eyebrow { margin-bottom: 7px; color: #52ad8b; font: 600 10px var(--mono); letter-spacing: .055em; text-transform: uppercase; }
.topbar .eyebrow { color: #72d0ae; }
.title-line { display: flex; align-items: center; gap: 15px; }
.title-line p { margin: 5px 0 0; color: #9facaa; font: 10px var(--mono); }
.alpha-mark { display: grid; width: 43px; height: 43px; place-items: center; color: var(--ink-deep); background: #72d0ae; font: 700 17px var(--mono); }
.header-console { display: flex; align-items: stretch; justify-content: flex-end; min-width: 0; }
.connection-state, .identity-strip, .build-strip {
  min-width: 160px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 7px 16px;
  border-left: 1px solid #34403c;
}
.connection-state { position: relative; min-width: 150px; padding-left: 35px; }
.connection-state > span { position: absolute; left: 16px; top: 50%; width: 8px; height: 8px; margin-top: -4px; background: var(--green-bright); border-radius: 50%; box-shadow: 0 0 0 5px rgba(66, 214, 158, .13); }
.connection-state.error > span { background: var(--red); box-shadow: 0 0 0 5px rgba(181, 53, 47, .15); }
.header-console strong { font: 600 11px var(--mono); }
.header-console span, .header-console small { color: #96a49f; font: 9px/1.35 var(--mono); }
.identity-strip span { color: #a7efce; text-transform: uppercase; }
.identity-strip small { color: #d6a45c; }
.build-strip strong { color: #dbe4e0; }
.header-console button {
  margin-left: 14px;
  padding: 0 15px;
  color: #dbe4e0;
  background: transparent;
  border: 1px solid #60706a;
  cursor: pointer;
  font: 500 11px var(--mono);
}
.header-console button:hover { color: #fff; border-color: #72d0ae; }
.header-console button[hidden] { display: none; }

.section-nav {
  min-height: 39px;
  padding: 0 clamp(20px, 3vw, 52px);
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  white-space: nowrap;
  background: var(--ink-soft);
  border-bottom: 1px solid #46534e;
}
.section-nav a { display: flex; align-items: center; padding: 0 16px; color: #bac5c1; border-right: 1px solid #3c4844; text-decoration: none; font: 9px var(--mono); text-transform: uppercase; letter-spacing: .04em; }
.section-nav a:first-child { border-left: 1px solid #3c4844; }
.section-nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.section-nav a:last-child { margin-left: auto; }

main { width: min(1680px, 100%); margin: 0 auto; padding: 20px clamp(16px, 2.6vw, 42px) 38px; }
.sign-in-panel { width: min(620px, 100%); margin: 7vh auto; padding: clamp(26px, 5vw, 48px); background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--green); }
.sign-in-panel[hidden], #authenticated-workspace[hidden] { display: none; }
.sign-in-panel h2 { margin-bottom: 12px; font-size: clamp(24px, 4vw, 34px); }
.sign-in-panel > p:not(.eyebrow) { max-width: 540px; margin-bottom: 24px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.sign-in-panel a { display: inline-grid; min-height: 42px; padding: 0 17px; place-items: center; color: #fff; background: var(--green); border: 1px solid var(--green); text-decoration: none; font: 600 11px var(--mono); }
.sign-in-panel a[aria-disabled="true"] { color: #7f8985; background: #edf0ec; border-color: #cfd5ce; pointer-events: none; }
.runtime-banner { min-height: 42px; display: flex; align-items: center; gap: 11px; margin-bottom: 22px; padding: 9px 13px; color: #46504c; background: var(--surface); border: 1px solid var(--line); font: 10px var(--mono); }
.runtime-banner .status-orbit { width: 9px; height: 9px; flex: 0 0 auto; background: var(--amber); border-radius: 50%; box-shadow: 0 0 0 4px rgba(168, 91, 0, .12); }
.runtime-banner.ready .status-orbit { background: var(--green); box-shadow: 0 0 0 4px rgba(8, 127, 91, .12); }
.runtime-banner.error .status-orbit { background: var(--red); box-shadow: 0 0 0 4px rgba(181, 53, 47, .12); }
.runtime-banner time { margin-left: auto; color: var(--muted); }
.section-heading { min-height: 59px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading.compact { min-height: 51px; }
.section-summary { padding-top: 7px; color: var(--muted); font: 10px var(--mono); }
.section-note { margin: 8px 0 23px; color: var(--muted); font-size: 10px; }

.system-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.system-card { position: relative; min-width: 0; min-height: 142px; padding: 15px 17px 13px 20px; background: var(--surface); border-left: 3px solid var(--muted); }
.system-card.online { border-left-color: var(--green); }
.system-card.degraded, .system-card.not_connected, .system-card.configuration_required { border-left-color: var(--amber); }
.system-card.unavailable { border-left-color: var(--red); }
.system-card header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.system-card h3 { margin: 0; overflow: hidden; font: 600 11px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.system-kind { display: inline-block; margin-top: 14px; padding: 4px 6px; color: #59635f; background: var(--paper); font: 600 9px var(--mono); text-transform: uppercase; }
.system-card p { margin: 12px 0 7px; color: #58625e; font-size: 10px; line-height: 1.45; }
.system-card small { display: block; overflow: hidden; color: var(--muted); font: 9px/1.45 var(--mono); text-overflow: ellipsis; white-space: nowrap; }

.status-chip { display: inline-block; width: max-content; padding: 4px 7px; color: #59635f; background: #eef1ed; border: 1px solid #d5dad4; font: 600 8px var(--mono); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.status-online, .status-connected_read_only, .status-recorded, .status-available { color: var(--green); background: var(--green-soft); border-color: #9ed8c3; }
.status-unavailable, .status-degraded { color: var(--red); background: var(--red-soft); border-color: #e6b7b2; }
.status-not_connected, .status-not_authorized, .status-configuration_required, .status-not_verified, .status-warm_lead_awaiting_tender_details { color: var(--amber); background: var(--amber-soft); border-color: #e2be80; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(285px, .9fr); gap: 16px; margin-bottom: 24px; }
.operations-panel, .oversight-panel, .activity-panel, .application-panel, .evidence-panel { min-width: 0; padding: 17px 18px; background: var(--surface); border: 1px solid var(--line); }
.table-wrap { overflow: auto; border: 1px solid var(--line); }
table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 10px; }
thead { background: #edf1ed; }
th { color: #4e5955; font: 600 8px var(--mono); letter-spacing: .045em; text-transform: uppercase; }
th, td { padding: 10px 11px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faf7; }
.work-title { display: block; min-width: 180px; margin-bottom: 4px; color: var(--ink); font-weight: 650; }
.work-id { color: var(--muted); font: 8px var(--mono); }
.source-cell, .owner-cell, .updated-cell { color: var(--muted); font: 9px/1.45 var(--mono); }
.action-cell { min-width: 240px; color: #46504c; line-height: 1.45; }
.priority { color: var(--muted); font: 600 10px var(--mono); }

.oversight-stack { display: grid; align-content: start; gap: 16px; }
.oversight-panel { min-height: 186px; border-top: 3px solid var(--amber); }
.panel-kicker { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; color: var(--muted); font: 600 9px var(--mono); letter-spacing: .045em; }
.oversight-panel h2 { margin-bottom: 19px; }
.oversight-empty { padding: 17px 0 4px; border-top: 1px solid var(--line); }
.oversight-empty strong { display: block; margin-bottom: 8px; font: 600 11px var(--mono); text-transform: uppercase; }
.oversight-empty p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.gates-panel { border-top-color: var(--blue); }
.gates-panel ul { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.gates-panel li { position: relative; padding: 10px 8px 10px 20px; color: #4f5a56; border-bottom: 1px solid var(--line); font-size: 10px; line-height: 1.45; }
.gates-panel li::before { content: ""; position: absolute; left: 4px; top: 14px; width: 6px; height: 6px; background: var(--amber); }

.lower-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .75fr) minmax(260px, .8fr); gap: 16px; }
.activity-stream { border-top: 1px solid var(--line); }
.activity-row { display: grid; grid-template-columns: 86px minmax(130px, .8fr) minmax(160px, 1.2fr) minmax(140px, 1fr) auto; gap: 10px; align-items: center; padding: 9px 3px; border-bottom: 1px solid var(--line); }
.activity-row time, .activity-row span { color: var(--muted); font: 8px/1.4 var(--mono); }
.activity-row strong { font-size: 10px; }
.application-card { padding: 15px; background: #f8faf7; border: 1px solid var(--line); border-left: 3px solid var(--amber); }
.application-card .application-type { display: block; margin-bottom: 14px; color: var(--green); font: 600 9px var(--mono); text-transform: uppercase; }
.application-card h3 { margin: 0 0 7px; font-size: 14px; }
.application-card p { margin-bottom: 14px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.application-card a, .application-card button { width: 100%; min-height: 36px; color: var(--ink); background: transparent; border: 1px solid #65726d; font: 600 9px var(--mono); text-transform: uppercase; }
.application-card a { display: grid; place-items: center; text-decoration: none; }
.application-card button:disabled { color: #8a948f; background: #edf0ec; border-color: #cfd5ce; cursor: not-allowed; }
.evidence-panel dl { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; border-top: 1px solid var(--line); }
.evidence-panel dt, .evidence-panel dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); font: 9px/1.45 var(--mono); }
.evidence-panel dt { padding-right: 12px; color: var(--muted); text-transform: uppercase; }
.evidence-panel dd { overflow-wrap: anywhere; color: #46504c; }
.empty-row { padding: 24px !important; color: var(--muted); text-align: center; font: 10px var(--mono); }
.loading-bar { height: 46px; background: linear-gradient(90deg, #edf0ec, #f8faf7, #edf0ec); background-size: 200% 100%; animation: pulse 1.5s infinite; }
@keyframes pulse { to { background-position: -200% 0; } }

footer { min-height: 48px; display: flex; justify-content: space-between; gap: 20px; padding: 15px clamp(20px, 3vw, 52px); color: #aab6b1; background: var(--ink-deep); font: 8px var(--mono); }

@media (max-width: 1180px) {
  .topbar { align-items: flex-start; }
  .header-console { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .header-console button { min-height: 34px; margin: 7px 0 0; }
  .system-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-grid { grid-template-columns: 1fr; }
  .oversight-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lower-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .activity-panel { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .topbar { display: block; padding: 19px 16px; }
  .title-line { align-items: flex-start; }
  .title-line p { line-height: 1.5; }
  .header-console { grid-template-columns: 1fr; margin-top: 20px; border-top: 1px solid #34403c; }
  .connection-state, .identity-strip, .build-strip { min-height: 54px; border-left: 0; border-bottom: 1px solid #34403c; }
  .header-console button { min-height: 39px; margin-top: 10px; }
  .section-nav { padding: 0; }
  .section-nav a { min-height: 39px; }
  .section-nav a:last-child { margin-left: 0; }
  main { padding: 16px 12px 28px; }
  .runtime-banner { align-items: flex-start; flex-wrap: wrap; }
  .runtime-banner time { width: 100%; margin: 0 0 0 20px; }
  .section-heading { min-height: 67px; }
  .system-grid, .oversight-stack, .lower-grid { grid-template-columns: 1fr; }
  .activity-panel { grid-column: auto; }
  .activity-row { grid-template-columns: 78px minmax(0, 1fr) auto; }
  .activity-row > strong { grid-column: 2; grid-row: 1; min-width: 0; }
  .activity-row > span:nth-of-type(1) { grid-column: 2 / 4; grid-row: 2; overflow-wrap: anywhere; }
  .activity-row > span:nth-of-type(2) { grid-column: 2 / 4; grid-row: 3; overflow-wrap: anywhere; }
  .activity-row > .status-chip { grid-column: 3; grid-row: 1; }
  .system-card { min-height: 128px; }
  footer { flex-direction: column; }
}
