:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde6;
  --text: #18202b;
  --muted: #667085;
  --accent: #315f9f;
  --accent-2: #234a7f;
  --strong: #7f1d1d;
  --ok: #047857;
  --warn: #a16207;
  --danger: #b42318;
  --none: #eef1f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.app-header {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(88px, 1fr));
  gap: 10px;
  min-width: 520px;
}

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

.metric[data-signal] {
  cursor: pointer;
}

.metric[data-signal]:hover {
  border-color: var(--accent);
  background: #eef6ff;
}

.metric strong {
  display: block;
  font-size: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(560px, 1fr) 340px;
  gap: 0;
  min-height: calc(100vh - 97px);
}

.controls,
.detail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
}

.detail {
  border-right: 0;
  border-left: 1px solid var(--line);
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #344054;
  font-size: 12px;
  font-weight: 600;
}

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

.note {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.content {
  min-width: 0;
  padding: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.view-tabs {
  display: flex;
  gap: 6px;
}

button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.reset-button {
  width: 100%;
  margin-top: 2px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  max-height: calc(100vh - 170px);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafb;
  color: #475467;
  font-size: 12px;
}

.sort-header {
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0 14px 0 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  position: relative;
}

.sort-header:hover {
  color: var(--text);
}

.sort-header.active {
  background: transparent;
  color: var(--accent-2);
}

.sort-header.active::after {
  content: "↓";
  position: absolute;
  right: 0;
}

.sort-header.active[data-direction="asc"]::after {
  content: "↑";
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f1f5f9;
}

.org-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.level-none {
  background: var(--none);
  color: #667085;
}

.level-low {
  background: #dcfce7;
  color: var(--ok);
}

.level-medium {
  background: #fef3c7;
  color: var(--warn);
}

.level-high {
  background: #fee2e2;
  color: var(--danger);
}

.empty-state {
  color: var(--muted);
  line-height: 1.5;
}

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

.detail .asn {
  color: var(--muted);
  margin-top: 4px;
}

.detail-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.signal-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.label-chip {
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  padding: 4px 8px;
  font-size: 12px;
}

.api-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 240px 1fr;
  }

  .detail {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 780px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-strip {
    min-width: 0;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .controls,
  .detail {
    border-left: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
