:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f1f4f7;
  --line: #dde3ea;
  --line-strong: #c8d1dc;
  --text: #26313f;
  --muted: #647184;
  --faint: #8a96a8;
  --brand: #1e3a5f;
  --brand-ink: #0f2744;
  --good: #16794d;
  --good-bg: #e8f6ef;
  --warn: #8a5a0a;
  --warn-bg: #fff4d7;
  --bad: #9b2c2c;
  --bad-bg: #fbe9e9;
  --unknown: #596579;
  --unknown-bg: #edf1f5;
  --shadow: 0 1px 2px rgba(24, 39, 75, 0.06);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    system-ui,
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.brand-name {
  font-weight: 700;
  color: var(--brand-ink);
}

.brand-subtitle {
  color: var(--faint);
  font-size: 12px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  position: relative;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 4px;
  color: var(--muted);
  padding: 0 10px 0 12px;
  text-decoration: none;
}

.nav-item small {
  margin-left: auto;
  color: var(--faint);
  font-size: 11px;
}

.nav-item:hover,
.nav-item.active {
  color: var(--brand);
  background: #eef3f8;
}

.nav-item.active {
  font-weight: 700;
}

.nav-indicator {
  position: absolute;
  left: 0;
  width: 3px;
  height: 18px;
  border-radius: 3px;
  background: transparent;
}

.nav-item.active .nav-indicator {
  background: var(--brand);
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  color: var(--muted);
  background: var(--surface);
}

.sidebar-note p {
  margin: 4px 0 0;
  font-size: 12px;
}

.note-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.main {
  padding: 22px 24px 32px;
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 20px;
  align-items: start;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  color: var(--brand-ink);
}

.notice {
  border: 1px solid #ecd894;
  border-radius: 6px;
  background: var(--warn-bg);
  padding: 10px 12px;
}

.notice-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--warn);
}

.notice-head a {
  color: var(--warn);
  text-decoration: none;
}

.notice ul {
  margin: 6px 0 0;
  padding-left: 16px;
  color: #6d4a0d;
  font-size: 12px;
}

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

.metric {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.metric strong {
  color: var(--brand-ink);
  font-size: 24px;
  line-height: 1;
}

.toolbar {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.search {
  height: 38px;
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.search span {
  color: var(--faint);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
}

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

.filter {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  cursor: pointer;
}

.filter:hover,
.filter.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.status-line {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.site-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
}

.site-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.site-main {
  min-width: 0;
}

.site-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.site-name {
  margin: 0;
  color: var(--brand-ink);
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.platform-tag,
.badge {
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.platform-tag {
  color: var(--unknown);
  background: var(--unknown-bg);
}

.site-url {
  display: inline-block;
  margin-top: 3px;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.site-url:hover,
.open-link:hover {
  text-decoration: underline;
}

.open-link {
  display: inline-flex;
  align-items: center;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--brand);
  background: #f8fafc;
  padding: 0 9px;
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
}

.state-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.site-description {
  margin: 10px 0 0;
  border-left: 5px solid #1f6f9d;
  border-radius: 6px;
  background: #eaf2f8;
  color: #203449;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.state-cell {
  min-width: 0;
  padding: 7px 9px;
  background: #fbfcfd;
  border-right: 1px solid var(--line);
}

.state-cell:last-child {
  border-right: 0;
}

.state-cell span {
  display: block;
  color: var(--faint);
  font-size: 11px;
}

.state-cell strong {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.state-enabled {
  color: var(--good);
}

.state-disabled {
  color: var(--bad);
}

.state-unknown,
.state-mentioned {
  color: var(--unknown);
}

.detail-button {
  width: 100%;
  height: 32px;
  margin-top: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #f8fafc;
  color: var(--brand);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.detail-button:hover {
  background: #eef3f8;
  border-color: #9eb4ca;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 31, 48, 0.42);
  backdrop-filter: blur(3px);
}

.modal-panel {
  position: relative;
  width: min(880px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 31, 48, 0.22);
}

.modal-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title-row h2 {
  margin: 0;
  color: var(--brand-ink);
  font-size: 18px;
  line-height: 1.25;
}

.modal-url {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.modal-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fbfcfd;
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.modal-description {
  margin: 14px 18px 0;
  border-left: 5px solid #1f6f9d;
  border-radius: 6px;
  background: #eaf2f8;
  color: #203449;
  padding: 11px 13px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.modal-state-grid {
  margin: 12px 18px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.modal-toolbar {
  margin: 14px 18px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-search {
  height: 36px;
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
}

.modal-search span {
  color: var(--faint);
}

.modal-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
}

.model-counter {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.modal-model-list {
  margin: 12px 18px 18px;
  padding: 12px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  display: flex;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}

.model-chip {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
  color: #465466;
  padding: 2px 6px;
  font-size: 11px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.modal-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  margin-top: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  padding: 28px;
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  font-size: 16px;
}

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

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 212px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 12px;
  }

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

  .modal {
    align-items: stretch;
    padding: 14px;
  }

  .modal-panel {
    max-height: calc(100vh - 28px);
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    white-space: nowrap;
  }

  .sidebar-note {
    display: none;
  }

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

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 18px 14px 24px;
  }

  .metrics,
  .state-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-cell:nth-child(2) {
    border-right: 0;
  }

  .state-cell:nth-child(1),
  .state-cell:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }

  .site-row {
    flex-direction: column;
  }

  .modal-state-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-state-grid .state-cell:nth-child(2) {
    border-right: 0;
  }

  .modal-state-grid .state-cell:nth-child(1),
  .modal-state-grid .state-cell:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }

  .modal-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .model-counter {
    align-self: flex-start;
  }
}
