:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --page: #eef3f7;
  --deep: #0d1b24;
  --blue: #2264d1;
  --teal: #0b7f79;
  --green: #287a46;
  --amber: #a05c00;
  --red: #b42318;
  --purple: #6941c6;
  --shadow: 0 14px 40px rgba(16, 24, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(34, 100, 209, 0.12), transparent 32%),
    linear-gradient(225deg, rgba(11, 127, 121, 0.14), transparent 34%),
    var(--page);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: rgba(13, 27, 36, 0.96);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.brand p {
  margin: 5px 0 0;
  color: #adc0cf;
  font-size: 13px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.brand-mark span {
  display: block;
  background: #68d391;
}

.brand-mark span:nth-child(2) {
  background: #63b3ed;
}

.brand-mark span:nth-child(3) {
  background: #f6ad55;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-switch,
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.segmented,
.tab {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: #c5d3df;
  border-radius: 6px;
}

.segmented.active,
.tab.active {
  background: #fff;
  color: var(--deep);
}

.owner-button {
  min-height: 46px;
  padding: 0 15px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #eaf2f8;
  font-weight: 800;
}

.owner-button.active,
.owner-button:hover {
  background: #68d391;
  color: #09231a;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(460px, 1.18fr);
  gap: 18px;
  padding: 18px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(102, 112, 133, 0.22);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.input-panel,
.result-panel {
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading.inline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading p {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-heading h2 {
  margin: 0;
  font-size: 22px;
}

label {
  display: block;
  margin-bottom: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 800;
  color: #344054;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfdff;
  color: var(--ink);
  border-radius: 7px;
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(34, 100, 209, 0.12);
}

textarea {
  min-height: 132px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.file-drop {
  margin: 0;
  min-height: 78px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 16px;
  border: 1px dashed #8ea6c8;
  background: #f4f8fd;
  color: #344054;
  border-radius: 8px;
}

.file-drop strong {
  font-size: 14px;
}

.file-drop span {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

#certUpload {
  min-height: 42px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 18px;
}

.primary,
.secondary,
.ghost {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 800;
}

.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

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

.secondary {
  color: #073b3a;
  background: #d8f3ee;
  border-color: #9eddd5;
}

.ghost {
  background: #fff;
  border-color: var(--line);
  color: #344054;
}

.quick-help {
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 14px;
  border-radius: 8px;
}

.quick-help h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.quick-help pre {
  margin: 0;
  color: #344054;
  font-size: 12px;
  line-height: 1.5;
}

.status-pill {
  min-width: 92px;
  text-align: center;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  border-radius: 999px;
}

.status-pill.neutral {
  color: #344054;
  background: #eef2f6;
}

.status-pill.ok {
  color: #14532d;
  background: #dcfce7;
}

.status-pill.warn {
  color: #7c2d12;
  background: #ffedd5;
}

.status-pill.bad {
  color: #7f1d1d;
  background: #fee2e2;
}

.story {
  min-height: 96px;
  padding: 16px;
  border-radius: 8px;
  background: #f6f8fb;
  border: 1px solid var(--line);
  line-height: 1.55;
}

.story strong {
  color: var(--deep);
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.metrics-row div {
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metrics-row span {
  display: block;
  font-size: 24px;
  font-weight: 900;
}

.metrics-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  width: 100%;
  margin-bottom: 14px;
  background: #edf2f7;
  border-color: #d7dee8;
  overflow-x: auto;
}

.tab {
  color: #475467;
  white-space: nowrap;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.simulator-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(320px, 1.22fr);
  gap: 14px;
}

.simulator-controls,
.simulator-output {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.check-row span {
  margin: 0;
  color: #344054;
  font-weight: 700;
  line-height: 1.35;
}

.sim-verdict {
  width: max-content;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.sim-verdict.neutral {
  color: #344054;
  background: #eef2f6;
}

.sim-verdict.ok {
  color: #14532d;
  background: #dcfce7;
}

.sim-verdict.warn {
  color: #7c2d12;
  background: #ffedd5;
}

.sim-verdict.bad {
  color: #7f1d1d;
  background: #fee2e2;
}

.sim-paths {
  display: grid;
  gap: 10px;
}

.sim-path {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.sim-path.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(34, 100, 209, 0.1);
}

.sim-path.valid {
  border-left: 6px solid var(--green);
}

.sim-path.invalid {
  border-left: 6px solid var(--red);
}

.sim-path div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.sim-path strong,
.sim-path span,
.sim-path small {
  display: block;
}

.sim-path span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #eaf2ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 900;
}

.sim-path p {
  margin: 9px 0 5px;
  color: var(--deep);
  font-weight: 800;
  line-height: 1.45;
}

.sim-path small {
  color: var(--muted);
  line-height: 1.45;
}

.sim-explanation {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #f6f8fb;
  border: 1px solid var(--line);
}

.sim-explanation h3,
.sim-explanation h4 {
  margin: 0 0 8px;
}

.sim-explanation h4 {
  margin-top: 12px;
  color: var(--blue);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sim-explanation p {
  margin: 0;
  color: #344054;
  line-height: 1.55;
}

.rootstore-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.86fr) minmax(340px, 1.14fr);
  gap: 14px;
}

.rootstore-controls,
.rootstore-output {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rootstore-summary {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8fb;
  margin-bottom: 12px;
}

.rootstore-summary p {
  margin: 0;
  line-height: 1.55;
  color: #344054;
}

.rootstore-matrix {
  display: grid;
  gap: 10px;
}

.rootstore-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.rootstore-card.ok {
  border-left: 6px solid var(--green);
}

.rootstore-card.warn {
  border-left: 6px solid var(--amber);
}

.rootstore-card.bad {
  border-left: 6px solid var(--red);
}

.rootstore-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rootstore-card strong,
.rootstore-card span {
  display: block;
}

.rootstore-card span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.rootstore-card p {
  margin: 9px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.rootstore-playbook {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.rootstore-playbook h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.rootstore-playbook ol {
  margin: 0;
  padding-left: 20px;
  color: #344054;
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

.owner-panel {
  grid-column: 1 / -1;
  padding: 22px;
}

.owner-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 14px;
}

.admin-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.admin-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

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

.admin-metrics span {
  display: block;
  font-size: 20px;
  font-weight: 900;
}

.admin-metrics p,
.admin-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.cost-guard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 14px;
}

.cost-guard label {
  margin: 0;
}

.switch-list {
  display: grid;
  gap: 9px;
}

.switch-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.switch-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.switch-row span,
.switch-row small {
  display: block;
  margin: 0;
}

.switch-row strong {
  font-size: 13px;
}

.switch-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.switch-row.required {
  background: #eff8ff;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px auto;
  gap: 8px;
  margin-bottom: 12px;
}

.user-table {
  display: grid;
  gap: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.launch-list {
  margin: 0;
  padding-left: 19px;
  color: #344054;
  line-height: 1.55;
}

.launch-list li + li {
  margin-top: 7px;
}

.trust-graph {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(#f8fafc 1px, transparent 1px),
    linear-gradient(90deg, #f8fafc 1px, transparent 1px),
    #fff;
  background-size: 26px 26px;
  padding: 18px;
  overflow: auto;
}

.trust-graph.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.chain-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 52px minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.cert-node {
  min-height: 112px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #b9c4d0;
  background: #fff;
}

.cert-node.leaf {
  border-left: 6px solid var(--blue);
}

.cert-node.intermediate {
  border-left: 6px solid var(--purple);
}

.cert-node.root {
  border-left: 6px solid var(--green);
}

.cert-node.unlinked {
  border-left: 6px solid var(--amber);
}

.cert-node h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.cert-node p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 12px;
}

.cert-badge {
  display: inline-flex;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 900;
}

.connector {
  min-height: 2px;
  border-top: 2px solid #8ea6c8;
  position: relative;
}

.connector::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -5px;
  width: 8px;
  height: 8px;
  border-top: 2px solid #8ea6c8;
  border-right: 2px solid #8ea6c8;
  transform: rotate(45deg);
}

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

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

.issue.error {
  border-left: 6px solid var(--red);
}

.issue.warning {
  border-left: 6px solid var(--amber);
}

.issue.info {
  border-left: 6px solid var(--blue);
}

.issue h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.issue p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.client-matrix {
  display: grid;
  gap: 10px;
}

.client-card {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.client-card strong {
  display: block;
  font-size: 14px;
}

.client-card span {
  display: inline-flex;
  width: max-content;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.client-card span.ok {
  color: #14532d;
  background: #dcfce7;
}

.client-card span.warn {
  color: #7c2d12;
  background: #ffedd5;
}

.client-card span.bad {
  color: #7f1d1d;
  background: #fee2e2;
}

.client-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.raw-evidence {
  min-height: 320px;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  color: #d7e3ee;
  background: #0a1118;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .topbar {
    height: auto;
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .owner-grid,
  .simulator-layout,
  .rootstore-layout,
  .admin-metrics,
  .cost-guard,
  .user-form,
  .user-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 10px;
  }

  .input-panel,
  .result-panel {
    padding: 16px;
  }

  .field-grid,
  .metrics-row,
  .chain-row,
  .client-card {
    grid-template-columns: 1fr;
  }

  .connector {
    min-height: 30px;
    width: 2px;
    border-top: 0;
    border-left: 2px solid #8ea6c8;
    margin-left: 18px;
  }

  .connector::after {
    right: auto;
    top: auto;
    bottom: -1px;
    left: -5px;
    transform: rotate(135deg);
  }
}
