:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #10263a;
  --muted: #5b6b78;
  --line: #d9e1e8;
  --soft: #f5f8fa;
  --primary: #0d6e5f;
  --primary-dark: #0a5549;
  --primary-soft: #e4f2ef;
  --accent: #d29a2d;
  --accent-soft: #fbf2dc;
  --blue: #2c5f7c;
  --good: #2f7d4f;
  --bad: #c2413c;
  --shadow: 0 1px 2px rgba(16, 38, 58, 0.06), 0 8px 24px rgba(16, 38, 58, 0.05);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0 28px;
  background: #102a43;
  color: #fff;
  border-bottom: 3px solid var(--accent);
}

.brand {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.subtitle {
  margin-top: 4px;
  color: #a9bdc9;
  font-size: 14px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd8e0;
  font-size: 13px;
}

.status-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7f8d98;
}

.status-chip.online {
  background: rgba(47, 125, 79, 0.22);
  border-color: rgba(47, 125, 79, 0.45);
  color: #dff4e6;
}

.status-chip.online::before {
  background: #59b57d;
}

.layout {
  display: grid;
  grid-template-columns: 348px minmax(0, 1fr);
  gap: 22px;
  padding: 24px;
  max-width: 1560px;
  margin: 0 auto;
  align-items: start;
}

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

.control-panel {
  position: sticky;
  top: 24px;
  padding: 22px;
}

.control-panel h2 {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}

.control-panel h2::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 8px;
  border-radius: 2px;
  background: var(--accent);
}

.mode-switch,
.capacity-tabs {
  display: flex;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.mode-switch .segment,
.capacity-tabs .segment {
  flex: 1;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.segment {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.segment + .segment {
  border-left: 0;
}

.segment.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(16, 38, 58, 0.12);
}

.field-label {
  display: block;
  margin: 0 0 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.drop-zone {
  border: 1.5px dashed #b8c5cf;
  border-radius: 10px;
  background: linear-gradient(180deg, #fbfdfe 0%, #f5f8fa 100%);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone.dragover {
  transform: translateY(-1px);
}

.drop-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

.drop-hint {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.file-name {
  margin-top: 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.or-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 13px;
}

.or-line::before,
.or-line::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

select,
button,
input[type="file"] {
  font: inherit;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  box-shadow: 0 1px 2px rgba(16, 38, 58, 0.04);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 95, 0.12);
}

#capacityPanel input[type="file"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.sample-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.sample-links a {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.sample-links a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.primary,
.secondary {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  font-size: 15px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.primary {
  width: 100%;
  padding: 13px 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 5px rgba(13, 110, 95, 0.2);
}

.primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.primary:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.secondary {
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.status {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: var(--bad);
  font-weight: 700;
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 14px 13px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 38, 58, 0.04);
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
}

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

.kpi .value {
  margin-top: 5px;
  font-size: 25px;
  font-weight: 900;
  color: var(--ink);
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.checks,
.cell-summary {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
  font-size: 14px;
}

.checks h3,
.cell-summary h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

.check-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
  color: var(--muted);
}

.check-row .pass {
  color: var(--good);
  font-weight: 900;
}

.check-row .fail {
  color: var(--bad);
  font-weight: 900;
}

.cell-summary p {
  margin: 5px 0;
  line-height: 1.5;
}

.report-options {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.report-options .field-label {
  margin: 0;
  font-size: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 14px;
}

.capacity-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
  background: #fff;
}

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

.capacity-subtitle {
  margin: 20px 0 10px;
  padding: 0 12px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

.capacity-table th,
.capacity-table td {
  border: 1px solid var(--line);
  padding: 9px 11px;
  text-align: left;
  white-space: nowrap;
}

.capacity-table th {
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
}

.capacity-table tbody tr:hover {
  background: #f8fbfc;
}

.capacity-table .status-badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.capacity-table .status-badge.over {
  background: #fdecea;
  color: var(--bad);
}

.capacity-table .status-badge.risk {
  background: var(--accent-soft);
  color: #94630c;
}

.capacity-table .status-badge.ok {
  background: #e7f3ec;
  color: var(--good);
}

.report-frame {
  height: 76vh;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.report-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

#capacityPanel h3 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .control-panel {
    position: static;
  }

  .topbar {
    padding: 0 16px;
  }

  .report-frame {
    height: 70vh;
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .field-row {
    grid-template-columns: 1fr;
  }

  .brand {
    font-size: 19px;
  }

  .result-panel,
  .control-panel {
    padding: 16px;
  }
}
