:root {
  --bg: #f2f6f3;
  --card: #ffffff;
  --ink: #0f1d18;
  --ink-soft: #354a42;
  --muted: #6c8077;
  --line: rgba(15, 29, 24, 0.08);
  --line-strong: rgba(15, 29, 24, 0.16);
  --emerald: #10b981;
  --emerald-deep: #067857;
  --emerald-soft: #e6f7ef;
  --amber: #e6931b;
  --amber-soft: #fff5e3;
  --blue: #2f7ae5;
  --blue-soft: #eaf2fd;
  --red: #de4d44;
  --red-soft: #fdeceb;
  --radius: 20px;
  --shadow: 0 16px 36px -28px rgba(9, 40, 32, 0.5), 0 2px 6px -3px rgba(9, 40, 32, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(680px 380px at 8% -6%, rgba(16, 185, 129, 0.15), transparent 62%),
    radial-gradient(600px 360px at 100% 2%, rgba(47, 122, 229, 0.09), transparent 60%);
  background-repeat: no-repeat;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 21px; }
h2 { font-size: 16.5px; }
h3 { font-size: 16px; }
p { margin: 0; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; }
.muted { color: var(--muted); font-size: 12.5px; }

/* ---------------- 登录 / 绑定门禁 ---------------- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
}

.gate-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border-radius: 24px;
  padding: 22px 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

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

.gate-form {
  display: grid;
  gap: 12px;
}

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

.field > span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input,
.field textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #f9fbfa;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.field textarea {
  resize: vertical;
  min-height: 76px;
  word-break: break-all;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--emerald);
  background: #fff;
}

.form-err {
  font-size: 13px;
  color: var(--red);
  min-height: 18px;
}

.guide-box {
  background: #f5f9f7;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.guide-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--emerald-deep);
}

.guide-box ol {
  margin: 8px 0 2px;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.guide-box code {
  background: rgba(6, 120, 87, 0.09);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 11.5px;
}

.security-note {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.security-note .ic {
  color: var(--emerald-deep);
  width: 16px;
  height: 16px;
}

/* ---------------- 主界面 ---------------- */
.app {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 14px 42px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px 10px;
  background: var(--bg);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #10b981, #065f46);
  box-shadow: 0 8px 18px -10px rgba(6, 95, 70, 0.85);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15.5px; }
.brand-text span { font-size: 11.5px; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.icon-btn.icon-sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.spin .ic { animation: spin 0.85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert-banner {
  margin-bottom: 12px;
  padding: 10px 13px;
  border-radius: 14px;
  background: var(--amber-soft);
  border: 1px solid rgba(230, 147, 27, 0.32);
  color: #8f5606;
  font-size: 13px;
  font-weight: 500;
}

main { display: grid; gap: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 13px;
}

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

/* ---------------- Hero 卡片 ---------------- */
.hero {
  background: linear-gradient(160deg, #0c3b2e 0%, #07271f 100%);
  color: #f4fbf8;
  border: none;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-label { font-size: 12.5px; color: rgba(244, 251, 248, 0.72); }
.hero-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #d5f5e8;
}

.hero-balance {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 38px;
  font-weight: 720;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.hero-balance .currency { font-size: 21px; font-weight: 600; opacity: 0.85; }

.auto-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.auto-strip-info { display: grid; gap: 2px; }
.auto-strip-info strong { font-size: 13.5px; }
.auto-strip-info span { font-size: 12px; color: rgba(244, 251, 248, 0.72); }

.switch { position: relative; width: 46px; height: 26px; flex: 0 0 auto; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  transition: background 0.2s ease;
}
.switch i::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}
.switch input:checked + i { background: var(--emerald); }
.switch input:checked + i::after { transform: translateX(20px); }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.hero-stats div { display: grid; gap: 1px; }
.hero-stats b { font-size: 16px; font-weight: 650; }
.hero-stats span { font-size: 11.5px; color: rgba(244, 251, 248, 0.68); }

/* ---------------- 按钮与分段器 ---------------- */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: #eef3f0;
}
.seg-eq .seg-item { flex: 1; }
.seg-item {
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-soft);
  text-align: center;
  transition: background 0.16s ease, color 0.16s ease;
}
.seg-item.is-active {
  background: #fff;
  color: var(--emerald-deep);
  font-weight: 650;
  box-shadow: 0 2px 6px -2px rgba(9, 40, 32, 0.12);
}

.control-group { display: grid; gap: 5px; }
.control-label { font-size: 12px; color: var(--muted); font-weight: 550; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 620;
  transition: transform 0.14s ease, opacity 0.14s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { padding: 12.5px 16px; font-size: 15px; }

.btn-primary {
  background: linear-gradient(145deg, #10b981, #067857);
  color: #fff;
  box-shadow: 0 10px 20px -12px rgba(6, 120, 87, 0.8);
}
.btn-ghost {
  background: #f3f7f5;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(222, 77, 68, 0.2);
}

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-stack { display: grid; gap: 8px; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--emerald-soft);
  color: var(--emerald-deep);
  white-space: nowrap;
}
.tag.warn { background: var(--amber-soft); color: #9a5e08; }
.tag.err { background: var(--red-soft); color: var(--red); }

/* ---------------- 步骤与结果 ---------------- */
.stepper {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  font-size: 12.5px;
}
.step-row { display: flex; align-items: flex-start; gap: 8px; }
.step-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 6px;
  flex: 0 0 auto;
  background: var(--muted);
}
.step-row.ok .step-dot { background: var(--emerald); }
.step-row.warn .step-dot, .step-row.skip .step-dot { background: var(--amber); }
.step-row.fail .step-dot { background: var(--red); }
.step-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }

.verdict {
  padding: 11px 13px;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 560;
}
.verdict.ok { background: var(--emerald-soft); color: var(--emerald-deep); }
.verdict.warn { background: var(--amber-soft); color: #8f5606; }
.verdict.err { background: var(--red-soft); color: var(--red); }

/* ---------------- 12 端口网格 ---------------- */
.dev-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 9px 11px;
  background: #f6f9f7;
  border-radius: 12px;
}
.dev-meta div { display: grid; gap: 1px; }
.dev-meta span { font-size: 11px; color: var(--muted); }
.dev-meta b { font-size: 13px; }

.ports-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.port-cell {
  border-radius: 12px;
  padding: 9px 6px;
  text-align: center;
  border: 1px solid var(--line);
  display: grid;
  gap: 2px;
  position: relative;
}
.port-cell b { font-size: 14px; font-variant-numeric: tabular-nums; }
.port-cell span { font-size: 11.5px; }
.port-cell.free { background: var(--emerald-soft); border-color: rgba(16, 185, 129, 0.28); color: var(--emerald-deep); }
.port-cell.busy { background: var(--amber-soft); border-color: rgba(230, 147, 27, 0.3); color: #9a5e08; }
.port-cell.float { background: var(--blue-soft); border-color: rgba(47, 122, 229, 0.28); color: var(--blue); }
.port-cell.fault { background: var(--red-soft); border-color: rgba(222, 77, 68, 0.25); color: var(--red); }
.port-cell.is-mine {
  outline: 2.5px solid var(--emerald-deep);
  outline-offset: 1px;
}
.mine-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  background: var(--emerald-deep);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend-right { margin-left: auto; color: var(--emerald-deep); font-weight: 560; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.free { background: var(--emerald); }
.dot.busy { background: var(--amber); }
.dot.float { background: var(--blue); }
.dot.fault { background: var(--red); }

/* ---------------- 记录列表 ---------------- */
.list-box { display: grid; gap: 8px; }
.item-row {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fbf9;
  border: 1px solid var(--line);
  display: grid;
  gap: 3px;
}
.item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}
.item-sub {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.empty {
  grid-column: 1 / -1;
  padding: 20px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------- 弹窗 ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 22, 18, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
}
@media (min-width: 560px) {
  .modal-backdrop { align-items: center; }
}
.modal-sheet {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 22px;
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: 0 24px 48px -20px rgba(0, 0, 0, 0.35);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-desc { font-size: 14px; color: var(--ink-soft); line-height: 1.55; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.divider { height: 1px; background: var(--line); }

/* ---------------- 多校区高德地图 ---------------- */
.head-right { display: flex; align-items: center; gap: 6px; }
.chip-copy {
  padding: 5px 10px;
  border-radius: 999px;
  background: #edf4f0;
  color: var(--emerald-deep);
  font-size: 12px;
  font-weight: 600;
}
.btn-xs { padding: 6px 11px; font-size: 12px; border-radius: 10px; text-decoration: none; }

.campus-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.campus-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 580;
  background: #eef3f0;
  color: var(--ink-soft);
  border: 1px solid transparent;
}
.campus-pill em {
  font-style: normal;
  font-size: 11px;
  margin-left: 3px;
  opacity: 0.78;
}
.campus-pill.is-active {
  background: var(--emerald-deep);
  color: #fff;
}

.map-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.amap-box {
  width: 100%;
  height: 300px;
  background: #e9f1ec;
}
.map-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  background: #fff;
  border-top: 1px solid var(--line);
}
.map-selected strong { display: block; font-size: 13.5px; }

.amap-bubble {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.24);
  border: 2px solid #fff;
}
.amap-bubble.good { background: #10b981; }
.amap-bubble.tight { background: #e6931b; }
.amap-bubble.full { background: #de4d44; }
.amap-bubble.static { background: #7d8f87; min-width: 20px; height: 20px; font-size: 11px; }

.zju-list {
  display: grid;
  gap: 7px;
  max-height: 280px;
  overflow-y: auto;
}
.zju-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 12px;
  background: #f8fbf9;
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.zju-row:hover { border-color: var(--emerald); }
.zju-row strong { display: block; font-size: 13.5px; }
.zju-row span { font-size: 11.5px; color: var(--muted); }
