:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfb;
  --ink: #152025;
  --muted: #65727a;
  --line: #d8e0e4;
  --primary: #176b63;
  --primary-dark: #0f514b;
  --amber: #a96810;
  --blue: #2463a6;
  --rose: #af3d4b;
  --safe: #24734c;
  --shadow: 0 14px 36px rgba(19, 34, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",
    Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
.link-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.primary {
  width: 100%;
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  background: #fff;
}

.ghost:hover {
  border-color: #a9b6bc;
  background: #f7fafb;
}

.danger {
  color: var(--rose);
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

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

h1 {
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  font-size: 15px;
  line-height: 1.3;
}

h3 {
  font-size: 17px;
  line-height: 1.35;
}

.meta-line {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.control-panel,
.workspace {
  min-width: 0;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-section h2 {
  margin-bottom: 2px;
}

label {
  display: grid;
  gap: 5px;
  color: #2c3c44;
  font-size: 13px;
  font-weight: 700;
}

.field-block {
  display: grid;
  gap: 7px;
}

.field-label {
  color: #2c3c44;
  font-size: 13px;
  font-weight: 700;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.choice-row label {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.choice-row label:has(input:checked) {
  border-color: #8abdb6;
  background: #edf7f5;
  color: var(--primary-dark);
}

.choice-row input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible,
.link-button:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 99, 0.18);
}

.autocomplete-field {
  position: relative;
}

.combo {
  position: relative;
}

.multi-combo {
  display: grid;
  gap: 6px;
}

.combo input {
  padding-right: 34px;
}

.combo-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.combo-tags:empty {
  display: none;
}

.filter-chip {
  display: inline-flex;
  max-width: 100%;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid #bed4d1;
  border-radius: 999px;
  background: #edf7f5;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.filter-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-chip button {
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--primary-dark);
  font-size: 16px;
  line-height: 1;
}

.filter-chip button:hover {
  background: #d8ebe7;
}

.combo-clear {
  position: absolute;
  top: 50%;
  right: 5px;
  display: none;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transform: translateY(-50%);
}

.multi-combo .combo-clear {
  top: auto;
  bottom: 4px;
  transform: none;
}

.combo.has-value .combo-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.combo-clear:hover {
  background: #eef3f4;
  color: var(--ink);
}

.combo-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 25;
  display: none;
  width: 100%;
  max-height: 240px;
  overflow: auto;
  border: 1px solid #b7c5cb;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(20, 32, 40, 0.16);
}

.combo-menu.open {
  display: block;
}

.combo-option,
.combo-empty {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.combo-option:hover,
.combo-option.active {
  background: #eef7f6;
  color: var(--primary-dark);
}

.combo-empty {
  color: var(--muted);
  cursor: default;
}

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

.compact-grid h2,
.compact-grid .wide {
  grid-column: 1 / -1;
}

.toggles {
  gap: 8px;
}

.switch-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  min-height: 28px;
  color: var(--ink);
  font-weight: 600;
}

.switch-row input {
  min-height: 18px;
  padding: 0;
}

.slider-row {
  display: grid;
  grid-template-columns: 56px minmax(90px, 1fr) 46px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.slider-row input {
  min-height: 24px;
  padding: 0;
}

.slider-row output {
  color: var(--ink);
  text-align: right;
}

.workspace {
  min-height: calc(100vh - 150px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 0;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.tab {
  min-width: 128px;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-weight: 700;
}

.tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: inset 0 -3px 0 var(--primary);
}

.tab span {
  display: inline-flex;
  min-width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e7eeee;
  color: #304148;
  font-size: 12px;
}

.view {
  display: none;
  padding: 14px;
}

.view.active {
  display: block;
}

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

.toolbar-actions,
.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-row {
  flex: 1;
}

.search-row .primary {
  width: 96px;
}

.summary-strip {
  display: flex;
  min-height: 36px;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid #d7e0e2;
  border-radius: 999px;
  background: #f8fbfb;
  color: #34454d;
  font-size: 12px;
  font-weight: 700;
}

.pill strong {
  color: var(--ink);
}

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

.card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.card:hover {
  border-color: #b8c6cb;
}

.card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.card-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.band {
  display: inline-flex;
  min-width: 32px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.band.stable {
  background: var(--safe);
}

.band.rush {
  background: var(--rose);
}

.band.safe {
  background: var(--blue);
}

.band.unknown {
  background: var(--amber);
}

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

.card-actions button {
  width: 72px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  gap: 8px;
}

.metric {
  min-height: 56px;
  padding: 8px;
  border-radius: 7px;
  background: var(--panel-soft);
}

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

.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tag-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tag-line span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef3f4;
}

.empty {
  padding: 36px 14px;
  color: var(--muted);
  text-align: center;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.35;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f6;
  color: #33454c;
  font-weight: 800;
}

td {
  color: #26363e;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(760px, 92vw);
  height: 100vh;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateX(105%);
  transition: transform 180ms ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  overflow: auto;
  padding: 16px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  background: rgba(20, 31, 38, 0.28);
}

.drawer-backdrop.open {
  display: block;
}

.reward-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(20, 31, 38, 0.35);
}

.reward-backdrop.open {
  display: block;
}

.reward-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 45;
  display: none;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.reward-modal.open {
  display: block;
}

.reward-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.reward-body {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px;
}

.reward-body img {
  display: block;
  width: min(100%, 330px);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.detail-table {
  margin-top: 10px;
}

.detail-table table {
  min-width: 980px;
}

footer {
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

footer a {
  color: var(--primary);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .metrics {
    grid-template-columns: repeat(3, minmax(110px, 1fr));
  }
}

@media (max-width: 760px) {
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions > * {
    flex: 1;
  }

  .app-shell {
    padding: 12px;
  }

  .control-panel,
  .compact-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    min-width: 120px;
  }

  .toolbar,
  .toolbar-actions,
  .search-row {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions,
  .search-row {
    width: 100%;
  }

  .search-row .primary {
    width: 100%;
  }

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

  .card-actions button {
    flex: 1;
    width: auto;
  }

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

  .slider-row {
    grid-template-columns: 58px minmax(80px, 1fr) 44px;
  }

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

@media (max-width: 460px) {
  h1 {
    font-size: 19px;
  }

  .metrics,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .view {
    padding: 10px;
  }

  .card {
    padding: 11px;
  }
}
