:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --panel: #ffffff;
  --panel-soft: #fafaf7;
  --ink: #171916;
  --muted: #68706a;
  --line: #dadfd7;
  --line-strong: #c2cabe;
  --green: #1e7a55;
  --green-soft: #e4f3ea;
  --amber: #b46b13;
  --amber-soft: #fff2d8;
  --red: #b73737;
  --red-soft: #ffe7e3;
  --blue: #286aa6;
  --blue-soft: #e8f1f8;
  --shadow: 0 16px 40px rgba(25, 30, 24, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

.app {
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(30, 122, 85, 0.08), transparent 35%),
    linear-gradient(180deg, #fbfbf8, #edf1ea);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), transparent 42%),
    #123825;
  color: #f7fbf4;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 8px 18px rgba(18, 56, 37, 0.18);
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: auto 7px 7px auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #69d390;
}

.brand-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.brand-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form {
  margin-top: 28px;
  display: grid;
  gap: 14px;
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  padding: 10px 11px;
  outline: none;
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 122, 85, 0.13);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 246, 243, 0.9);
  backdrop-filter: blur(14px);
}

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

.topbar .brand-title {
  font-size: 18px;
}

.topbar .brand-mark {
  width: 32px;
  height: 32px;
}

.main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: 7px;
  background: #e8ece5;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn:hover {
  border-color: var(--line-strong);
}

.btn.primary {
  background: #173c2c;
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}

.btn.danger {
  color: var(--red);
  background: var(--red-soft);
}

.btn.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
}

.status-pills,
.chain-pills,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef1eb;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
}

.pill.ok {
  color: var(--green);
  background: var(--green-soft);
  border-color: #b9dac5;
}

.pill.warn {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #efd39b;
}

.pill.bad {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f0b8b2;
}

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

.page-title {
  margin: 0;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.05;
}

.page-kicker {
  margin: 8px 0 0;
  color: var(--muted);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(29, 34, 27, 0.04);
}

.card {
  padding: 16px;
}

.project-card {
  min-height: 210px;
  display: grid;
  gap: 14px;
  align-content: space-between;
  cursor: pointer;
}

.project-card:hover {
  border-color: var(--green);
}

.project-name {
  margin: 0;
  font-size: 19px;
}

.muted {
  color: var(--muted);
}

.scan-meta {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.4;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.56);
  text-align: center;
  color: var(--muted);
  padding: 30px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(210px, 240px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.detail-layout > * {
  min-width: 0;
}

.side {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 16px;
}

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

.chain-item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 11px;
  border-radius: 7px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  cursor: pointer;
}

.chain-item > span {
  min-width: 0;
}

.chain-item.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.chain-address {
  display: block;
  max-width: 100%;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

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

.kpi {
  min-height: 96px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}

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

.kpi .value {
  margin-top: 10px;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 750;
}

.risk-bar {
  height: 9px;
  border-radius: 999px;
  background: #e7ebe3;
  overflow: hidden;
  margin-top: 10px;
}

.risk-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-weight: 650;
  background: #fbfcf8;
}

tr.holder-flash > td {
  animation: holder-row-flash 3.4s ease-in-out;
}

@keyframes holder-row-flash {
  0% {
    background: #dff3e5;
    box-shadow: inset 4px 0 0 var(--green);
  }
  35% {
    background: #e9f7ee;
    box-shadow: inset 4px 0 0 var(--green);
  }
  100% {
    background: transparent;
    box-shadow: inset 0 0 0 transparent;
  }
}

.addr {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}

.address-label {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.address-nickname {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
}

.address-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #bfd6c8;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
}

.tag-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.tag-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  font-size: 13px;
}

.annotation-address,
.history-address-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bar-cell {
  min-width: 130px;
}

.mini-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #e8ece5;
  overflow: hidden;
}

.mini-bar span {
  display: block;
  height: 100%;
  background: var(--green);
}

.alert-list,
.cluster-list,
.safe-list,
.history-list {
  display: grid;
  gap: 10px;
}

.alert,
.cluster,
.safe-row,
.history-row,
.insight {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 12px;
}

.cluster-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.alert-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.alert-button:hover,
.cluster-button:hover {
  border-color: var(--green);
  background: #f6fbf7;
}

.alert.high {
  border-color: #efb0aa;
  background: var(--red-soft);
}

.alert.medium {
  border-color: #ead19a;
  background: var(--amber-soft);
}

.alert-title,
.cluster-title,
.safe-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.safe-title .pill {
  flex: 0 0 auto;
}

.safe-link {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.safe-link:hover {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.alert p,
.cluster p,
.safe-row p,
.history-row p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.alert .detail-hint {
  color: var(--green);
  font-weight: 700;
}

.insight {
  white-space: pre-wrap;
  line-height: 1.6;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  background: rgba(18, 24, 20, 0.42);
  padding: 18px;
}

.modal-backdrop.open {
  display: grid;
}

.modal {
  width: min(560px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal.wide {
  width: min(960px, 100%);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-body {
  display: grid;
  gap: 13px;
  padding: 16px;
}

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

.modal-kpis div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: var(--panel-soft);
  min-width: 0;
}

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

.modal-kpis strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.modal-table table {
  min-width: 640px;
}

.holder-address-cell {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.address-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.mini-action {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.mini-action:hover {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-soft);
}

.mini-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-chart {
  width: 100%;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcf8;
}

.history-chart line {
  stroke: #cbd4ca;
  stroke-width: 1;
}

.history-chart polyline {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.5;
}

.history-chart circle {
  fill: var(--green);
}

.history-chart text {
  fill: var(--muted);
  font-size: 11px;
}

.switch-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
}

.switch-line input {
  width: 19px;
  height: 19px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 36px));
  display: none;
  padding: 12px 14px;
  border-radius: 7px;
  background: #17241c;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.toast.show {
  display: block;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1020px) {
  .detail-layout,
  .split {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
  }

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

@media (max-width: 720px) {
  .topbar {
    height: auto;
    min-height: 64px;
    align-items: flex-start;
    padding: 12px;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .main {
    padding: 14px;
  }

  .page-head {
    display: grid;
  }

  .toolbar,
  .row-actions {
    flex-wrap: wrap;
  }

  .project-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .modal-kpis,
  .holder-address-cell {
    grid-template-columns: 1fr;
  }

  .address-actions {
    justify-content: flex-start;
  }

  .panel,
  .card {
    padding: 13px;
  }

  table {
    min-width: 640px;
  }
}
