:root {
  color-scheme: dark;
  --bg: #090a0b;
  --panel: #101214;
  --panel-2: #15181b;
  --line: #262a2e;
  --text: #f0f3f4;
  --muted: #8e989f;
  --soft: #c7d0d5;
  --accent: #4fd1a5;
  --accent-2: #f4c95d;
  --danger: #ff6b6b;
  --info: #63b3ed;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  --radius: 8px;
}

body.light {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-2: #eef1ee;
  --line: #d9ded9;
  --text: #151817;
  --muted: #606b66;
  --soft: #323b38;
  --shadow: 0 18px 44px rgba(31, 41, 35, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 70% 12%, rgba(79, 209, 165, 0.1), transparent 28rem),
    linear-gradient(180deg, rgba(244, 201, 93, 0.04), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

.mobile-topbar,
.drawer-backdrop {
  display: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: rgba(12, 14, 15, 0.84);
  padding: 22px 16px;
  backdrop-filter: blur(24px);
}

body.light .sidebar {
  background: rgba(255, 255, 255, 0.82);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(79, 209, 165, 0.45);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(79, 209, 165, 0.18), rgba(244, 201, 93, 0.12));
  color: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--soft);
  padding: 11px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  border-color: rgba(79, 209, 165, 0.28);
  background: rgba(79, 209, 165, 0.08);
  color: var(--text);
}

.nav-icon {
  width: 20px;
  color: var(--accent);
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.run-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  font-size: 13px;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 7px rgba(79, 209, 165, 0.12);
}

.main {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 26px 32px 56px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

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

.daily-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.daily-actions input {
  width: 150px;
}

.icon-button,
.ghost-button,
.text-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  font-size: 18px;
}

.ghost-button {
  min-height: 38px;
  padding: 0 14px;
}

.mobile-menu-button {
  display: grid;
  gap: 4px;
  place-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.mobile-menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 18, 20, 0.82);
  padding: 16px;
}

body.light .metric {
  background: rgba(255, 255, 255, 0.9);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 30px;
  line-height: 1;
}

.filter-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 160px 120px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 18, 20, 0.9);
  padding: 10px;
  backdrop-filter: blur(18px);
}

body.light .filter-bar {
  background: rgba(255, 255, 255, 0.9);
}

.filter-bar label {
  display: grid;
  gap: 6px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  min-height: 38px;
  padding: 0 11px;
}

textarea {
  min-height: 96px;
  padding: 10px 11px;
  resize: vertical;
}

.view {
  display: none;
  margin-top: 22px;
}

.view.is-active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.section-head h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.section-head.compact {
  margin-bottom: 10px;
}

.timestamp {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.feed {
  display: grid;
  gap: 10px;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pagination-actions {
  display: flex;
  gap: 8px;
}

.signal {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 168px;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
  box-shadow: var(--shadow);
}

.dense .signal {
  grid-template-columns: 60px minmax(0, 1fr) 150px;
  padding: 13px;
  box-shadow: none;
}

.score {
  display: grid;
  place-items: center;
  align-self: start;
  min-height: 62px;
  border-radius: var(--radius);
  border: 1px solid rgba(79, 209, 165, 0.25);
  background: rgba(79, 209, 165, 0.08);
  color: var(--accent);
  font-size: 24px;
  font-weight: 800;
}

.score.hot {
  border-color: rgba(255, 107, 107, 0.36);
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
}

.signal h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.45;
}

.signal h3 button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.signal h3 button:hover {
  color: var(--accent);
}

.summary {
  margin-bottom: 12px;
  color: var(--soft);
  line-height: 1.65;
}

.meta-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.meta-row {
  color: var(--muted);
  font-size: 13px;
}

.tag,
.source-tier,
.risk {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
}

.tag {
  border: 1px solid var(--line);
  color: var(--soft);
}

.source-tier {
  background: rgba(99, 179, 237, 0.12);
  color: var(--info);
}

.risk {
  background: rgba(244, 201, 93, 0.14);
  color: var(--accent-2);
}

.risk.high {
  background: rgba(255, 107, 107, 0.14);
  color: var(--danger);
}

.signal-side {
  display: grid;
  gap: 10px;
  align-content: start;
  color: var(--muted);
  font-size: 13px;
}

.reason {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  color: var(--soft);
  line-height: 1.55;
}

.viewpoint {
  margin-top: 8px;
  color: var(--accent);
  line-height: 1.55;
  font-weight: 650;
}

.open-link {
  color: var(--accent);
  text-decoration: none;
}

.daily-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

.daily-brief,
.watchlist,
.topic-card,
.source-card,
.endpoint,
.table-panel,
.ops-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
}

.daily-brief h3,
.watchlist h3 {
  margin-bottom: 12px;
}

.daily-brief ol,
.daily-brief ul {
  padding-left: 20px;
  line-height: 1.75;
}

.watch-item {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.watch-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.watch-item strong {
  display: block;
  margin-bottom: 5px;
}

.watch-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.topic-grid,
.source-grid,
.api-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.topic-card h3,
.source-card h3,
.endpoint h3 {
  margin-bottom: 8px;
}

.topic-card p,
.source-card p,
.endpoint p {
  color: var(--muted);
  line-height: 1.6;
}

.topic-progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.topic-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.source-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.source-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr 150px 120px 1fr 120px;
  gap: 8px;
  margin-bottom: 12px;
}

.source-config-list {
  display: grid;
  gap: 8px;
}

.source-config-row {
  display: grid;
  grid-template-columns: 1fr 90px 120px 120px 200px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px;
  color: var(--soft);
  font-size: 13px;
}

.source-config-row strong {
  display: block;
  margin-bottom: 4px;
}

.source-config-row small {
  color: var(--muted);
}

.source-test-state {
  grid-column: 1 / -1;
  line-height: 1.5;
}

.source-test-state.success {
  color: var(--accent);
}

.source-test-state.failed {
  color: var(--danger);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.mini-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

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

.ops-card span,
.feedback-state {
  color: var(--muted);
  font-size: 13px;
}

.ops-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.alert-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.alert-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 180px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px 12px;
  color: var(--soft);
  font-size: 13px;
}

.alert-level {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(99, 179, 237, 0.12);
  color: var(--info);
}

.alert-level.warning {
  background: rgba(244, 201, 93, 0.14);
  color: var(--accent-2);
}

.alert-level.error {
  background: rgba(255, 107, 107, 0.14);
  color: var(--danger);
}

.alert-item strong {
  display: block;
  margin-bottom: 3px;
}

.alert-item small {
  color: var(--muted);
}

.risk-control-list {
  display: grid;
  gap: 8px;
}

.risk-control {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 12px;
}

.risk-control h3 {
  margin-bottom: 6px;
  font-size: 15px;
}

.risk-control p,
.risk-control small {
  display: block;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.table-panel {
  margin-top: 12px;
}

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

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

.changelog-list {
  display: grid;
  gap: 12px;
}

.changelog-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
}

.changelog-card h3 {
  margin-bottom: 8px;
}

.changelog-card ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--soft);
  line-height: 1.7;
}

.event-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 150px;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 12px;
}

.event-card h3 {
  margin-bottom: 7px;
  font-size: 16px;
}

.event-card p {
  margin-bottom: 9px;
  color: var(--muted);
  line-height: 1.55;
}

.event-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.run-row {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 0.8fr 0.7fr 1.4fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px;
  color: var(--soft);
  font-size: 13px;
}

.run-row.header {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(79, 209, 165, 0.12);
  color: var(--accent);
}

.status-pill.failed {
  background: rgba(255, 107, 107, 0.13);
  color: var(--danger);
}

.endpoint span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.feedback-panel {
  display: grid;
  gap: 10px;
}

.feedback-panel label {
  display: grid;
  gap: 6px;
}

.feedback-panel .inline-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
}

.feedback-panel .inline-toggle input {
  width: 16px;
  height: 16px;
}

code {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--soft);
  padding: 11px;
  white-space: nowrap;
}

img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

.detail-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 24px;
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.close-dialog {
  position: absolute;
  top: 12px;
  right: 12px;
}

.detail-content {
  display: grid;
  gap: 16px;
}

.detail-content h2 {
  max-width: calc(100% - 48px);
  margin-bottom: 0;
}

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

.detail-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 12px;
}

.detail-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-box strong {
  display: block;
  margin-top: 5px;
}

@media (max-width: 980px) {
  body {
    padding-top: 64px;
  }

  body.nav-open {
    overflow: hidden;
  }

  .mobile-topbar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: 64px;
    border-bottom: 1px solid var(--line);
    background: rgba(12, 14, 15, 0.92);
    padding: 10px 14px;
    backdrop-filter: blur(22px);
  }

  body.light .mobile-topbar {
    background: rgba(255, 255, 255, 0.92);
  }

  .mobile-brand {
    min-width: 0;
    flex: 1;
  }

  .mobile-brand .brand-mark {
    width: 36px;
    height: 36px;
  }

  .mobile-brand strong,
  .mobile-brand small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  body.nav-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(84vw, 320px);
    height: 100dvh;
    overflow-y: auto;
    padding: 18px 16px;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .nav-item {
    min-height: 46px;
  }

  .main {
    width: 100%;
    padding: 18px 14px 42px;
  }

  .topbar {
    margin-bottom: 16px;
  }

  .topbar .icon-button {
    display: none;
  }

  .stats-grid,
  .topic-grid,
  .source-grid,
  .api-grid,
  .release-grid,
  .ops-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .source-form,
  .source-config-row {
    grid-template-columns: 1fr 1fr;
  }

  .signal,
  .dense .signal {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .signal-side {
    grid-column: 2;
  }

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

  .table-panel {
    overflow-x: hidden;
  }
}

@media (max-width: 620px) {
  body {
    padding-top: 58px;
  }

  .mobile-topbar {
    height: 58px;
    padding: 8px 10px;
  }

  .mobile-menu-button,
  .mobile-topbar .icon-button {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }

  .brand {
    gap: 9px;
  }

  .brand small {
    font-size: 11px;
  }

  .sidebar {
    width: min(88vw, 300px);
  }

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .topbar-actions .ghost-button,
  .section-head .ghost-button,
  .section-head .text-button {
    min-height: 44px;
  }

  .daily-actions {
    justify-content: stretch;
  }

  .daily-actions input,
  .daily-actions button {
    width: 100%;
  }

  .nav-list,
  .stats-grid,
  .filter-bar,
  .topic-grid,
  .source-grid,
  .api-grid,
  .release-grid,
  .ops-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .run-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .event-card {
    grid-template-columns: 1fr;
  }

  .alert-item {
    grid-template-columns: 1fr;
  }

  .risk-control {
    grid-template-columns: 1fr;
  }

  .source-form,
  .source-config-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions .mini-button {
    flex: 1;
  }

  .mini-button {
    min-height: 38px;
  }

  .nav-item {
    justify-content: flex-start;
  }

  .signal,
  .dense .signal {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 13px;
  }

  .score {
    width: 72px;
    min-height: 54px;
  }

  .signal-side {
    grid-column: auto;
  }

  .signal h3 {
    font-size: 16px;
  }

  .signal h3 button {
    min-height: 44px;
  }

  .filter-bar {
    gap: 8px;
    padding: 8px;
  }

  input,
  select,
  textarea,
  .ghost-button,
  .icon-button {
    min-height: 44px;
  }

  .pagination-bar,
  .pagination-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-dialog {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
  }

  .detail-dialog form {
    max-height: calc(100dvh - 18px);
  }

  .detail-content h2 {
    max-width: none;
    padding-right: 42px;
    font-size: 20px;
  }

  .daily-brief,
  .watchlist,
  .topic-card,
  .source-card,
  .endpoint,
  .changelog-card {
    padding: 14px;
  }

  code {
    white-space: pre;
  }
}
