:root {
  --ink: #12202a;
  --muted: #657681;
  --line: #dbe5ea;
  --panel: #ffffff;
  --page: #f3f6f7;
  --blue: #1e5c7c;
  --teal: #1b7a74;
  --green: #1f7a4d;
  --amber: #9a6a10;
  --red: #b33a3a;
  --soft-blue: #e7f1f6;
  --soft-green: #e7f5ed;
  --soft-amber: #fff5d8;
  --soft-red: #fdeaea;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 16px;
  background: #0f2734;
  color: #fff;
}

.rail b {
  display: block;
  font-size: 22px;
}

.rail small {
  display: block;
  color: #a9c2cf;
}

.rail nav {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.rail a {
  padding: 10px 12px;
  border-left: 3px solid transparent;
  color: #d9e8ef;
  text-decoration: none;
}

.rail a:hover {
  border-color: #68b2c8;
  background: rgba(255, 255, 255, .06);
}

main {
  padding: 28px;
}

.topbar,
.panel-head,
.actions,
.row,
.metric-grid,
.grid,
.admin-grid,
.split-list,
.timeline,
.record-list {
  display: grid;
  gap: 14px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 18px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 { margin-bottom: 4px; font-size: 28px; }
h2 { margin-bottom: 0; font-size: 18px; }
h3 { font-size: 15px; }
p { color: var(--muted); line-height: 1.65; }

.panel {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 14px;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin-grid { grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); }
.split-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.metric,
.card,
.record,
.trace-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.metric b {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.tag {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.tag.ok { background: var(--soft-green); color: var(--green); }
.tag.warn { background: var(--soft-amber); color: var(--amber); }
.tag.danger { background: var(--soft-red); color: var(--red); }

.primary,
.ghost {
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 7px;
  border: 1px solid var(--line);
  font-weight: 800;
  cursor: pointer;
}

.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.ghost {
  background: #fff;
  color: var(--ink);
}

.primary:disabled,
.ghost:disabled,
button[disabled],
input[disabled],
select[disabled] {
  cursor: not-allowed;
  opacity: .55;
}

button[data-permission-denied] {
  border-color: #c8d3d9;
}

input[readonly] {
  border-color: #c8d3d9;
  background: #f7fafb;
  color: var(--muted);
}

.small {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.full-span {
  grid-column: 1 / -1;
}

.actions {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.compact-form {
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.topbar .actions {
  min-width: min(460px, 100%);
}

.detail-panel {
  border-left: 5px solid var(--teal);
}

.compact-panel {
  padding-top: 14px;
  padding-bottom: 14px;
}

.offline-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.offline-shell .panel {
  width: min(620px, 100%);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  text-decoration: none;
}

.readiness-summary {
  margin-bottom: 12px;
}

.readiness-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: #fbfcfd;
}

.readiness-band b {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  line-height: 1.55;
}

.readiness-band span {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.readiness-list {
  display: grid;
  gap: 10px;
}

.readiness-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.readiness-item .row {
  padding-top: 0;
}

.readiness-item p {
  margin-bottom: 7px;
  font-size: 13px;
}

.pilot-workbench-panel {
  border-top: 4px solid #1b7a74;
}

.pilot-workbench-panel .readiness-band:first-child {
  position: relative;
  overflow: hidden;
}

.pilot-workbench-panel .readiness-band:first-child::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, #1e5c7c, #1b7a74 45%, #9a6a10);
}

.pilot-actions {
  grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
  align-items: end;
  margin-bottom: 12px;
}

.pilot-actions label {
  min-width: min(240px, 100%);
}

.pilot-workbench-panel .readiness-item {
  padding: 10px 12px;
}

.pilot-workbench-panel .row {
  padding: 8px 0;
}

.pilot-workbench-panel .row b {
  line-height: 1.35;
}

.row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.row small,
.record small {
  color: var(--muted);
  line-height: 1.5;
}

.inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mini-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.visibility-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.visibility-grid .subsection {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.permission-gates {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.permission-gate {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.permission-gate.blocked {
  border-left-color: var(--red);
  background: #fffafa;
}

.permission-gate small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.45;
}

.scope-notice {
  border-left: 4px solid var(--amber);
  background: #fffaf0;
}

.workspace-scope {
  margin: -12px 0 18px;
}

.workspace-store-picker {
  min-width: 260px;
}

.workspace-store-picker select {
  margin-top: 4px;
  width: 100%;
}

.operational-risk-panel {
  border-left: 5px solid var(--amber);
}

.risk-overview-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.risk-decision {
  margin: 12px 0;
  border-left-color: var(--amber);
}

.risk-overview-list {
  display: grid;
  gap: 8px;
}

.risk-layer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.risk-layer {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.risk-layer .row {
  align-items: start;
}

.risk-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.risk-item:hover {
  border-color: #8fb4c4;
  background: var(--soft-blue);
}

.risk-main {
  color: var(--ink);
  text-decoration: none;
}

.risk-main:hover b {
  color: var(--blue);
}

.risk-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.boundary-note {
  margin: 12px 0 0;
  font-size: 12px;
}

.governance-summary {
  margin-bottom: 14px;
}

.matrix-table {
  display: grid;
  gap: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.matrix-head,
.matrix-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(5, minmax(110px, .7fr));
  min-width: 880px;
}

.matrix-head {
  background: var(--soft-blue);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.matrix-head span,
.matrix-row span {
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.matrix-head span:last-child,
.matrix-row span:last-child {
  border-right: 0;
}

.matrix-row:last-child span {
  border-bottom: 0;
}

.matrix-row small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.cert-level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.cert-level {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  border-radius: 8px;
  background: #fff;
}

.cert-level.passed {
  border-left-color: var(--green);
}

.cert-level header,
.check-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.check-row {
  grid-template-columns: auto minmax(0, 1fr);
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.cert-level small,
.check-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.risk-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.risk-summary {
  border-left-color: var(--amber);
}

.notification-summary {
  margin: 12px 0;
  border-left-color: var(--blue);
}

.sla-summary {
  margin: 12px 0;
  border-left-color: var(--red);
}

.dossier-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.dossier-summary {
  border-left-color: var(--green);
}

.dossier-metrics .metric b {
  font-size: 20px;
}

.dossier-timeline {
  display: grid;
  gap: 8px;
}

.timeline-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.timeline-item small {
  color: var(--muted);
  line-height: 1.45;
}

.risk-notes {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.risk-notes ul {
  margin: 6px 0 12px;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.workflow-steps {
  display: grid;
  gap: 8px;
}

.workflow-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  border-radius: 8px;
  background: #fff;
}

.workflow-step.done {
  border-left-color: var(--green);
}

.workflow-step small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.row:last-child {
  border-bottom: 0;
}

.record {
  display: grid;
  gap: 8px;
}

.record header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.trace-box {
  min-height: 140px;
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.6;
}

.compact-output {
  max-height: 320px;
  overflow: auto;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
  }
  .rail nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar,
  .panel-head,
  .metric-grid,
  .risk-overview-summary,
  .risk-layer-grid,
  .risk-item,
  .admin-grid,
  .split-list,
  .grid.two,
  .grid.three,
  .readiness-band,
  .cert-level-grid,
  .visibility-grid,
  .pilot-actions {
    grid-template-columns: 1fr;
  }
}
