:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1d2520;
  --muted: #627066;
  --line: #dce2dc;
  --accent: #0d7963;
  --accent-dark: #075a49;
  --danger: #9d2e36;
  --shadow: 0 18px 45px rgba(29, 37, 32, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button {
  font: inherit;
}

.app-shell {
  width: calc(100vw - 32px);
  max-width: none;
  margin: 0 auto;
  padding: 24px 0 36px;
}

.toolbar {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding-bottom: 16px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 850;
  line-height: 1.08;
  letter-spacing: 0;
}

.coverage-stat {
  margin: -2px 0 2px;
  color: var(--accent-dark);
  font-size: 0.96rem;
  font-weight: 850;
}

.matrix-switch {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.segment-button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.segment-button:last-child {
  border-right: 0;
}

.segment-button:hover,
.segment-button.active {
  background: #e9f8ef;
  color: var(--accent-dark);
}

.segment-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.message {
  max-width: 960px;
  margin: 0 auto 14px;
  border: 1px solid #e4a5a9;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff1f2;
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

.table-region {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dashboard-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.dashboard-panel.tree-panel {
  display: block;
}

.person-card {
  display: grid;
  gap: 14px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.person-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.person-card h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.person-total,
.register-count {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  background: #e9f8ef;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.register-groups {
  display: grid;
  gap: 14px;
}

.register-group {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.register-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.register-name {
  color: #334039;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.register-count {
  min-width: 28px;
  padding: 0 8px;
}

.entry-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry-item {
  display: grid;
  gap: 2px;
  padding-left: 10px;
  border-left: 3px solid rgba(13, 121, 99, 0.28);
  text-align: left;
}

.entry-name {
  font-size: 0.93rem;
  font-weight: 850;
  line-height: 1.25;
}

.entry-secondary {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.35;
}

.dashboard-empty,
.dashboard-loading {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.dashboard-loading {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  text-align: center;
}

.tp-map {
  --map-width: 960px;
  --map-height: 420px;
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tp-map::before {
  content: "";
  position: relative;
  display: block;
  width: var(--map-width);
  height: var(--map-height);
}

.tp-map-svg,
.tp-map-nodes {
  position: absolute;
  inset: 0 auto auto 0;
  width: var(--map-width);
  height: var(--map-height);
}

.tp-map-svg {
  pointer-events: none;
  overflow: visible;
}

.tp-map-svg marker path {
  fill: rgba(13, 121, 99, 0.72);
}

.tp-map-svg #tp-arrowhead-incoming path {
  fill: #1f66d1;
}

.tp-map-svg #tp-arrowhead-outgoing path {
  fill: var(--accent-dark);
}

.tp-map-edge {
  fill: none;
  stroke: rgba(13, 121, 99, 0.46);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  marker-end: url(#tp-arrowhead);
  transition: opacity 140ms ease, stroke 140ms ease, stroke-width 140ms ease;
}

.tp-map.has-highlight .tp-map-edge.dimmed {
  opacity: 0.12;
}

.tp-map-edge.incoming {
  opacity: 1;
  stroke: #1f66d1;
  stroke-width: 3.4;
  marker-end: url(#tp-arrowhead-incoming);
}

.tp-map-edge.outgoing {
  opacity: 1;
  stroke: var(--accent-dark);
  stroke-width: 3.4;
  marker-end: url(#tp-arrowhead-outgoing);
}

.tp-map-node {
  position: absolute;
  z-index: 1;
  display: grid;
  width: 226px;
  height: 112px;
  overflow: hidden;
  border: 1px solid #d5e3dc;
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(29, 37, 32, 0.1);
}

.tp-map-node:hover {
  z-index: 2;
  height: auto;
  min-height: 112px;
  overflow: visible;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(29, 37, 32, 0.16);
}

.tp-map-node.multi-parent {
  border-color: #e7c66f;
  background: #fffdf7;
}

.tp-map-node:hover .tp-meta {
  max-height: none;
}

.tp-map-node:hover .tp-description {
  -webkit-line-clamp: 6;
}

.tp-node-body {
  display: grid;
  gap: 8px;
  text-align: left;
}

.tp-node-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
}

.tp-node-name {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 900;
  line-height: 1.22;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.tp-child-count {
  display: inline-grid;
  min-width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #eef4f0;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 950;
}

.tp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 26px;
  overflow: hidden;
}

.tp-meta-chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid #d5e3dc;
  border-radius: 999px;
  padding: 0 8px;
  background: #ffffff;
  color: #334039;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
}

.tp-meta-chip.attention {
  border-color: #edd39b;
  background: #fff8e7;
  color: #725017;
}

.tp-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: center;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4f0;
  color: #334039;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.row-axis-header,
.row-axis-name,
.requirement-header,
.requirement-name {
  position: sticky;
  left: 0;
}

.row-axis-header,
.requirement-header {
  z-index: 3;
}

.row-axis-name,
.requirement-name {
  z-index: 2;
  width: 220px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: none;
}

.verification-header {
  height: 80px;
  vertical-align: middle;
}

.verification-header span {
  display: block;
  line-height: 1.2;
  white-space: normal;
}

tbody tr:hover {
  background: #f7fbf9;
}

tbody tr:hover .requirement-name {
  background: #f7fbf9;
}

tbody tr:hover .row-axis-name {
  background: #f7fbf9;
}

tbody tr:last-child td,
tbody tr:last-child th {
  border-bottom: 0;
}

.matrix-cell {
  height: 52px;
  padding: 0;
}

.matrix-cell.linked,
.matrix-cell.verified {
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 950;
}

.matrix-cell.linked span,
.matrix-cell.verified span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid rgba(13, 121, 99, 0.28);
  border-radius: 999px;
  background: #e9f8ef;
}

.matrix-cell.empty {
  background: #fbfcfb;
}

.loading td {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100vw - 20px);
    padding-top: 18px;
  }

  .matrix-switch {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .segment-button {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 10px;
  }

  .segment-button:last-child {
    border-bottom: 0;
  }

  .dashboard-panel {
    grid-template-columns: 1fr;
  }

  .row-axis-header,
  .row-axis-name,
  .requirement-header,
  .requirement-name {
    width: 150px;
  }
}
