:root {
  color-scheme: light;
  --bg: #f2f5fa;
  --bg-grain: #e8edf5;
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --surface-strong: #eef2f8;
  --text: #0e1a33;
  --text-soft: #243250;
  --muted: #5b6786;
  --faint: #8d97b3;
  --line: #dde3ee;
  --line-strong: #c4cce0;
  --accent: #1e3a8a;
  --accent-strong: #14266b;
  --accent-soft: #e8eefb;
  --accent-glow: rgba(30, 58, 138, 0.20);
  --inflow: #c7352e;
  --inflow-soft: #fbeae8;
  --outflow: #16825f;
  --outflow-soft: #e6f1eb;
  --warn: #9a6a16;
  --warn-soft: #fbf2dd;
  --zebra: #f8fafd;
  --shadow-sm: 0 1px 2px rgba(14, 26, 51, 0.05), 0 1px 1px rgba(14, 26, 51, 0.03);
  --shadow: 0 12px 38px rgba(14, 26, 51, 0.08), 0 2px 6px rgba(14, 26, 51, 0.04);
  --shadow-lg: 0 24px 60px rgba(14, 26, 51, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@supports (font-variation-settings: normal) {
  :root {
    --font-sans:
      InterVariable, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
      "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  }
}

:root {
  --font-sans:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 480px at 14% -120px, rgba(30, 58, 138, 0.06), transparent 60%),
    radial-gradient(900px 380px at 90% -80px, rgba(15, 30, 80, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
  animation: enter 480ms var(--ease) both;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Hero ---------- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.hero-copy {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  box-shadow: 0 8px 22px rgba(30, 58, 138, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.012em;
}

h2 {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.hero-copy > div p {
  margin-top: 4px;
}

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

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 144px;
  height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 12px 28px rgba(30, 58, 138, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), filter 180ms var(--ease);
}

.primary-button-glyph {
  font-size: 17px;
  transition: transform 200ms var(--ease);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(30, 58, 138, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.primary-button:hover .primary-button-glyph {
  transform: translateX(2px);
}

.primary-button:active {
  transform: translateY(0);
  filter: brightness(0.96);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

/* ---------- Overview metrics ---------- */
.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  position: relative;
  min-height: 92px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  box-shadow: var(--shadow-sm);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
}

.metric::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, transparent, var(--accent-soft), transparent);
  opacity: 0;
  transition: opacity 180ms var(--ease);
}

.metric:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.metric:hover::before {
  opacity: 1;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.012em;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ---------- Notice ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #eadfbe;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffdf6 0%, #fff8e6 100%);
  color: #4c4131;
  font-size: 13px;
  line-height: 1.55;
}

.notice strong {
  color: var(--warn);
  font-weight: 700;
}

.notice-dot {
  flex-shrink: 0;
  margin-top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 4px var(--warn-soft);
}

/* ---------- Workspace ---------- */
.workspace {
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

legend::before {
  content: "";
  display: inline-block;
  margin-right: 8px;
  width: 4px;
  height: 14px;
  vertical-align: -2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-soft);
  font-family: inherit;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), background 160ms var(--ease);
}

input::placeholder {
  color: var(--faint);
}

input:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding-top: 18px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
}

.checkline input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--accent);
  background: var(--surface);
}

/* ---------- Status bar ---------- */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.statusbar-text {
  flex: 1 1 auto;
  min-width: 0;
}

#statusText {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

#metaText {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 56%;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge.good {
  border-color: #c2cef0;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge.warn {
  border-color: #eadfbe;
  background: var(--warn-soft);
  color: var(--warn);
}

/* ---------- Results table ---------- */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-toolbar {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.table-toolbar p {
  margin-top: 2px;
  font-size: 12px;
}

#resultHint {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

table {
  width: 100%;
  min-width: 1360px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 12px;
  text-align: right;
  vertical-align: top;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-strong);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
  transition: color 140ms var(--ease), background 140ms var(--ease);
}

th[data-sort]:hover {
  color: var(--accent-strong);
  background: #e5ebe4;
}

th[data-sort].asc::after,
th[data-sort].desc::after {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent);
  font-size: 9px;
}

th[data-sort].asc::after {
  content: "▲";
}

th[data-sort].desc::after {
  content: "▼";
}

tbody tr {
  transition: background 120ms var(--ease);
}

tbody tr:nth-child(even) td {
  background: var(--zebra);
}

tbody tr:hover td {
  background: var(--accent-soft);
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
}

th:first-child {
  z-index: 3;
  background: var(--surface-strong);
}

td.name,
td.reason,
th:nth-child(2),
th:nth-child(14) {
  text-align: left;
}

td.name {
  color: var(--text);
  font-weight: 600;
}

td.reason {
  min-width: 340px;
  color: var(--text-soft);
  font-size: 12.5px;
  white-space: normal;
  line-height: 1.55;
}

.source {
  display: inline-block;
  margin-top: 4px;
  color: var(--faint);
  font-size: 11px;
}

.code {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.inflow {
  color: var(--inflow);
  font-weight: 700;
}

.outflow {
  color: var(--outflow);
  font-weight: 700;
}

tbody tr td:last-child {
  border-bottom: 1px solid var(--line);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty {
  height: 180px;
  color: var(--faint);
  text-align: center;
  vertical-align: middle;
  font-size: 13px;
  font-weight: 500;
}

.is-hidden {
  display: none !important;
}

/* ---------- Footer ---------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.footer-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--line-strong);
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}

.footer a:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
}

.footer-sep {
  color: var(--faint);
}

.version-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

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

  .badges {
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 20px, 900px);
    padding-top: 20px;
  }

  .hero,
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .hero-actions,
  .primary-button {
    width: 100%;
    justify-content: center;
  }

  h1 {
    font-size: 26px;
  }

  .overview,
  fieldset {
    grid-template-columns: 1fr;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}
