:root {
  --ink: #17211e;
  --muted: #64716c;
  --line: #d8dfd8;
  --paper: #f3f1e8;
  --panel: #fffdf8;
  --steel: #235765;
  --steel-dark: #183f49;
  --signal: #d18728;
  --ok: #1f7a52;
  --warn: #ad472f;
  --shadow: 0 20px 48px rgba(35, 47, 42, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 18px 18px, rgba(35, 87, 101, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 87, 101, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(35, 87, 101, 0.055) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
  display: grid;
  gap: 18px;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  background: #17211e;
  color: #fffdf8;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scan-panel,
.history-panel {
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.scan-panel {
  display: grid;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--signal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 20px;
}

.operator-badge {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 253, 248, 0.25);
  border-radius: 6px;
  padding: 0 12px;
  color: #fff3dc;
  background: rgba(255, 253, 248, 0.08);
  font-weight: 800;
  white-space: nowrap;
}

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

.metric-card {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(35, 87, 101, 0.08), transparent 58%),
    #fff;
}

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

.metric-card strong {
  font-size: 22px;
  line-height: 1.1;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.disabled-link {
  pointer-events: none;
  opacity: 0.48;
}

.state-ok {
  color: var(--ok) !important;
}

.state-warn {
  color: var(--warn) !important;
}

.status-strip {
  min-height: 50px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--steel);
  background: #fbfaf5;
  border-radius: 6px;
  color: var(--muted);
  line-height: 1.4;
  font-weight: 800;
}

.status-strip.ok {
  border-left-color: var(--ok);
  color: var(--ok);
}

.status-strip.warn {
  border-left-color: var(--warn);
  color: var(--warn);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button,
.export-link {
  min-height: 46px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary-button {
  min-width: 190px;
  min-height: 58px;
  color: white;
  background: var(--steel);
  font-size: 18px;
  box-shadow: 0 12px 22px rgba(35, 87, 101, 0.24);
}

.primary-button:hover:not(:disabled) {
  background: var(--steel-dark);
}

.secondary-button,
.ghost-button,
.export-link {
  color: var(--steel-dark);
  background: #eef3f1;
  border-color: #cbd8d3;
}

.button-icon {
  font-size: 19px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.result-head,
.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.result-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f1eadf;
  color: var(--signal);
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid #e6ebe7;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf1ee;
  color: #2c484d;
  font-weight: 900;
}

td {
  background: rgba(255, 255, 255, 0.72);
}

tbody tr:hover td {
  background: #fff8ea;
}

.history-panel {
  display: grid;
  gap: 14px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

input:focus {
  border-color: var(--steel);
  outline: 3px solid rgba(35, 87, 101, 0.14);
}

.history-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.field-grid span {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--steel-dark);
  font-weight: 800;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 16px, 720px);
    padding-top: 8px;
  }

  .scan-panel,
  .history-panel {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 25px;
  }

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

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

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

  .filters button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 460px) {
  .result-head,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

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

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}
