:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --line-strong: #d2d2d7;
  --divider: #9aa4b2;
  --green: #163d22;
  --green-bg: #b9ec75;
  --green-soft: #f3fbf6;
  --amber: #4f3700;
  --amber-bg: #ffd764;
  --red: #5f171d;
  --red-bg: #ff7a7a;
  --alert-text: #d43f4a;
  --gray-bg: #f0f0f2;
  --blue: #1f5fbf;
  --blue-bg: #eef5ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 16px 36px rgba(0, 0, 0, 0.05);
  --matrix-row-height: 36px;
  --matrix-cell-font-size: 15px;
  --matrix-node-font-size: 15px;
  --matrix-head-font-size: 16px;
  --matrix-font-weight: 720;
  --matrix-ok-font-weight: 500;
  --matrix-node-font-weight: 500;
  --matrix-head-font-weight: 830;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 20% -10%, rgba(255, 255, 255, 0.96), transparent 360px),
    linear-gradient(180deg, #fbfbfd 0%, var(--bg) 42%, #f2f2f4 100%);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 18px 22px;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(190px, 0.72fr) minmax(220px, 0.82fr) minmax(380px, 430px);
  gap: 12px;
  margin-bottom: 12px;
}

.metric,
.panel {
  border: 1px solid rgba(210, 210, 215, 0.76);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  min-height: 68px;
  align-content: center;
  gap: 4px;
  padding: 12px 28px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metric strong {
  font-size: 28px;
  font-weight: 760;
  line-height: 1;
}

.count-current,
.count-divider,
.count-total {
  display: inline-block;
}

.count-current.danger {
  color: var(--alert-text);
}

.metric.alert {
  border-color: rgba(210, 210, 215, 0.82);
  background: rgba(255, 255, 255, 0.92);
}

.metric.alert .metric-label {
  color: var(--muted);
}

.metric.good {
  justify-content: center;
  justify-items: start;
  background: rgba(255, 255, 255, 0.92);
}

.metric.media {
  justify-content: center;
  justify-items: start;
  background: rgba(255, 255, 255, 0.92);
}

.metric.good.alert,
.metric.media.alert {
  background: rgba(255, 255, 255, 0.92);
}

.time-metric {
  grid-template-columns: auto auto auto;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding-inline: 24px;
  background: rgba(255, 255, 255, 0.9);
}

.time-pair span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.time-pair strong {
  font-size: 15px;
  font-weight: 760;
  white-space: nowrap;
}

.test-button,
.row-check-button {
  border: 1px solid rgba(210, 210, 215, 0.9);
  background: rgba(255, 255, 255, 0.94);
  color: var(--blue);
  cursor: pointer;
  font-family: inherit;
  font-weight: 760;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.test-button {
  min-width: 58px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(31, 95, 191, 0.08);
}

.test-button:hover,
.row-check-button:hover {
  border-color: rgba(31, 95, 191, 0.3);
  background: rgba(238, 245, 255, 0.96);
}

.test-button:disabled,
.row-check-button:disabled {
  border-color: rgba(210, 210, 215, 0.9);
  background: var(--gray-bg);
  box-shadow: none;
  color: var(--muted);
  cursor: not-allowed;
}

.panel {
  padding: 10px;
}

.matrix-panel {
  min-width: 0;
}

.matrix-wrap {
  max-height: calc(100vh - 126px);
  min-height: 430px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-solid);
}

.matrix-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.matrix-wrap::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(110, 110, 115, 0.35);
  background-clip: padding-box;
}

.unlock-matrix {
  width: 100%;
  min-width: 1288px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel-solid);
  table-layout: fixed;
}

.unlock-matrix th,
.unlock-matrix td {
  height: var(--matrix-row-height);
  padding: 6px 5px;
  border-right: 1px solid rgba(229, 229, 234, 0.82);
  border-bottom: 1px solid rgba(229, 229, 234, 0.82);
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unlock-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  color: #2f3137;
  font-size: 13px;
  font-weight: 760;
}

.service-head.ai {
  background: #f8fbf8;
}

.service-head.media {
  background: #f8fbff;
}

.group-start {
  border-left: 4px solid var(--divider) !important;
}

.index-head,
.index-cell {
  left: 0;
  width: 48px;
  min-width: 48px;
}

.node-head,
.node-cell {
  left: 48px;
  width: 148px;
  min-width: 148px;
}

.unlock-matrix .index-head,
.unlock-matrix .node-head,
.unlock-matrix .index-cell,
.unlock-matrix .node-cell {
  position: sticky;
  z-index: 2;
  border-right: 1px solid var(--line-strong);
}

.unlock-matrix .index-head,
.unlock-matrix .node-head {
  z-index: 5;
  background: #fbfbfd;
}

.index-cell,
.node-cell {
  background: rgba(255, 255, 255, 0.96);
}

.index-cell {
  position: sticky;
}

.index-number {
  display: inline-block;
  transition: opacity 0.16s ease;
}

.row-check-button {
  position: absolute;
  inset: 5px 7px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  font-size: 16px;
  line-height: 1;
}

.index-cell:hover .index-number {
  opacity: 0;
}

.index-cell:hover .row-check-button,
.row-check-button:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

body.is-checking .index-cell:hover .row-check-button,
body.is-checking .row-check-button:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.checking-row .index-cell,
.checking-row .node-cell {
  background: #f1f2f4 !important;
  color: #6f737a;
}

.checking-row .result-cell {
  background: #dfe2e7 !important;
  color: #646970 !important;
}

.checking-row .node-flag,
.checking-row .node-name,
.checking-row .result-cell {
  opacity: 0.72;
}

.node-cell {
  text-align: center;
}

.node-line {
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.node-flag {
  flex: 0 0 auto;
  font-size: 13px;
  line-height: 1;
}

.node-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  font-size: var(--matrix-node-font-size);
  font-weight: var(--matrix-node-font-weight);
  text-overflow: ellipsis;
}

.unlock-matrix thead .service-head {
  width: 84px;
  min-width: 84px;
  font-size: var(--matrix-head-font-size);
  font-weight: var(--matrix-head-font-weight);
  line-height: 1.15;
}

.result-cell {
  color: var(--text);
  font-size: var(--matrix-cell-font-size);
  font-weight: var(--matrix-font-weight);
}

.result-cell.ok {
  background: var(--green-bg);
  color: var(--green);
  font-weight: var(--matrix-ok-font-weight);
}

.result-cell.warn {
  background: var(--amber-bg);
  color: var(--amber);
}

.result-cell.blocked {
  background: var(--red-bg);
  color: var(--red);
}

.result-cell.error {
  background: var(--red-bg);
  color: var(--red);
}

@media (max-width: 820px) {
  .shell {
    padding: 10px;
  }

  .summary-grid {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 0.95fr) minmax(0, 1.1fr);
    gap: 6px;
  }

  .metric {
    min-height: 56px;
    padding: 8px 10px;
    border-radius: 10px;
  }

  .metric-label,
  .time-pair span {
    font-size: 11px;
  }

  .metric strong {
    font-size: 22px;
  }

  .time-metric {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 4px;
    align-items: center;
    justify-content: stretch;
    padding-inline: 8px 6px;
  }

  .time-pair span {
    margin-bottom: 1px;
  }

  .time-pair strong {
    font-size: 13px;
  }

  .test-button {
    position: static;
    width: 30px;
    min-width: 30px;
    height: 28px;
    padding: 0;
    font-size: 10px;
  }

  .panel {
    padding: 8px;
    border-radius: 10px;
  }

  .matrix-wrap {
    height: calc(100dvh - 100px);
    min-height: 0;
    max-height: none;
    border-radius: 8px;
    touch-action: auto;
  }

  .row-check-button {
    display: none;
  }

  .index-cell {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(31, 95, 191, 0.16);
  }

  .index-cell:active {
    background: #eef5ff;
  }

  .unlock-matrix thead {
    position: sticky;
    top: 0;
    z-index: 12;
    background: #fbfbfd;
    box-shadow: 0 1px 0 rgba(210, 210, 215, 0.95);
  }

  .unlock-matrix thead th {
    position: static;
    top: auto;
    z-index: auto;
    background-clip: padding-box;
  }

  .index-head,
  .index-cell,
  .node-head,
  .node-cell {
    left: auto;
  }

  .unlock-matrix .index-cell,
  .unlock-matrix .node-cell {
    position: static;
  }

  .unlock-matrix .index-head,
  .unlock-matrix .node-head {
    position: static;
    left: auto;
    z-index: auto;
  }
}
