:root {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #637083;
  --line: #d8e0ea;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 16px 42px rgba(28, 39, 60, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "Segoe UI",
    Arial,
    sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

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

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

h1 {
  margin: 0;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: 0;
}

.service-state,
.fault-badge {
  min-width: 98px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.service-state.ok {
  border-color: rgba(22, 163, 74, 0.35);
  color: var(--green);
}

.service-state.bad {
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 18px;
}

.section-title {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.sample-btn {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.sample-btn.active {
  border-color: var(--blue);
  background: #dbeafe;
  color: var(--blue-dark);
}

.primary-btn,
.secondary-btn {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: white;
  font-weight: 800;
}

.primary-btn {
  background: var(--blue);
}

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

.secondary-btn {
  background: #334155;
}

.secondary-btn:hover {
  background: #1f2937;
}

.divider {
  height: 1px;
  margin: 18px 0;
  background: var(--line);
}

.file-drop {
  display: block;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
}

.file-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}

.file-name {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#fileInput {
  display: none;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.input-row label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.input-row input {
  width: 100%;
  height: 38px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
}

.result-panel {
  padding: 18px;
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.main-label {
  min-height: 58px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.fault-badge {
  color: white;
}

.fault-badge.idle {
  background: #64748b;
}

.fault-badge.normal {
  background: var(--green);
}

.fault-badge.fault {
  background: var(--red);
}

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

.metrics div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

.metrics strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 22px;
}

.chart-wrap {
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.vote-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.vote-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.vote-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.vote-item strong {
  float: right;
}

.log-panel {
  margin-top: 18px;
  padding: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

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

@media (max-width: 860px) {
  .topbar,
  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace,
  .metrics,
  .vote-strip {
    grid-template-columns: 1fr;
  }
}
