:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --border: #e3e8f0;
  --text: #1b2430;
  --muted: #5b6878;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf0ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 35, 60, 0.04), 0 8px 24px rgba(20, 35, 60, 0.06);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: #eef2f8;
  border-radius: 4px;
  padding: 2px 6px;
}

.container {
  width: min(1080px, calc(100% - 48px));
  margin: 0 auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
}

.brand-text small {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.nav {
  display: flex;
  gap: 6px;
}

.nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.nav a:hover {
  background: #eef2f8;
  color: var(--text);
  text-decoration: none;
}

.nav a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* Hero */
.hero {
  padding: 88px 0 72px;
  background:
    radial-gradient(900px 380px at 15% -20%, #dbe7ff 0%, transparent 70%),
    radial-gradient(700px 320px at 90% 0%, #e4defd 0%, transparent 65%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #cfdcff;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 500;
}

.hero h1 {
  margin: 18px 0 16px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.hero-sub {
  max-width: 640px;
  margin: 0 0 30px;
  color: var(--muted);
  font-size: 16.5px;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 20px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: #c8d3e4;
  background: #f9fbff;
}

.btn-small {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 7px;
}

/* Sections */
.section {
  padding: 64px 0;
}

.section-alt {
  background: #fff;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-head {
  margin-bottom: 28px;
}

.section-head h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 18px;
}

.tools-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.tool-card {
  color: inherit;
  display: block;
}

.tool-card:hover {
  transform: translateY(-3px);
  border-color: #b9cdf7;
  text-decoration: none;
}

.tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 14px;
}

.tool-card h3 {
  margin: 0 0 6px;
  font-size: 16.5px;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.feature-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.feature h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.feature p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
}

/* Page head */
.page-head {
  padding: 48px 0 24px;
}

.page-head h1 {
  margin: 0 0 8px;
  font-size: 32px;
  letter-spacing: -0.01em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

/* Tool tabs */
.tool-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  flex: none;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.tab:hover {
  background: #eef2f8;
  color: var(--text);
}

.tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #cfdcff;
  font-weight: 600;
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 56px;
}

.panel.active {
  display: block;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 19px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.select,
.input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}

.select:focus,
.input:focus,
.editor:focus {
  border-color: #93b4f8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.editor {
  width: 100%;
  min-height: 260px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.field-label:first-child {
  margin-top: 0;
}

.input {
  width: 100%;
  height: 40px;
  font-size: 14px;
}

.result-box {
  min-height: 260px;
  max-height: 420px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  overflow: auto;
}

.result-tall {
  min-height: 320px;
}

.hint {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.hint.error {
  color: #c0392b;
}

.hint.success {
  color: #1e7e4f;
}

/* Docs */
.docs-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 40px;
  padding-bottom: 72px;
}

.docs-sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 48px;
}

.sidebar-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.docs-sidebar a {
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
}

.docs-sidebar a:hover {
  background: #eef2f8;
  color: var(--text);
  text-decoration: none;
}

.docs-content section {
  padding: 8px 0 26px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}

.docs-content section:last-child {
  border-bottom: 0;
}

.docs-content h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.docs-content h3 {
  margin: 20px 0 6px;
  font-size: 16.5px;
}

.docs-content p {
  color: #36414f;
}

.docs-content ul,
.docs-content ol {
  color: #36414f;
  padding-left: 22px;
}

.code-block {
  background: #0f172a;
  color: #dbe4f5;
  border-radius: 10px;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  overflow-x: auto;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 26px 0;
  margin-top: 40px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13.5px;
}

/* Status dashboard */
.dashboard {
  padding-bottom: 56px;
}

.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 44px 0 24px;
}

.dash-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dash-head h1 {
  margin: 10px 0 6px;
  font-size: clamp(26px, 3.2vw, 34px);
  letter-spacing: -0.02em;
}

.dash-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
  animation: pulse 2s infinite;
}

.live-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.updated {
  font-size: 12.5px;
  color: #93a1b3;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.gauge-card,
.stat-card {
  display: flex;
  flex-direction: column;
  padding: 22px 20px;
  min-height: 232px;
}

.gauge {
  position: relative;
  width: 128px;
  height: 128px;
  margin: 2px auto 12px;
}

.gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: #eef2f8;
  stroke-width: 10;
}

.gauge-fill {
  fill: none;
  stroke: var(--gauge-color, #2563eb);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s ease;
}

.gauge-fill.warn {
  stroke: #d97706;
}

.gauge-fill.danger {
  stroke: #dc2626;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding-bottom: 4px;
}

.gauge-center b {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gauge-center span {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.gauge-card[data-accent="mem"] {
  --gauge-color: #7c3aed;
}

.gauge-card[data-accent="disk"] {
  --gauge-color: #0d9488;
}

.gauge-meta {
  margin-top: auto;
  text-align: center;
}

.gauge-meta h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.gauge-meta p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-head h3 {
  margin: 0;
  font-size: 15px;
}

.chip {
  padding: 2px 9px;
  border-radius: 999px;
  background: #f2f5fa;
  color: var(--muted);
  font-size: 11.5px;
}

.stat-big {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-big-text {
  font-size: 22px;
}

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

.stat-card .muted {
  margin: 8px 0 0;
  font-size: 12.5px;
}

.stat-card .muted b {
  color: var(--text);
  font-weight: 600;
}

.net-kpis {
  display: flex;
  gap: 28px;
  margin-top: 4px;
}

.net-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.net-dir {
  font-size: 12.5px;
  color: var(--muted);
}

.net-kpi b {
  font-size: 20px;
  font-weight: 700;
}

.alert {
  padding: 12px 16px;
  margin-bottom: 18px;
  border: 1px solid #f5c2bd;
  background: #fff4f3;
  color: #b3261e;
  border-radius: 10px;
  font-size: 14px;
}

.stat-card .bar {
  margin-top: 14px;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: #edf1f7;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  transition: width 0.5s ease, background 0.3s ease;
}

.bar-fill.warn {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.bar-fill.danger {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.chart-card {
  padding: 22px 22px 16px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.chart-head h2 {
  margin: 0;
  font-size: 16px;
}

.chart-head .muted {
  margin: 3px 0 0;
  font-size: 12px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot-cpu { background: #2563eb; }
.dot-mem { background: #7c3aed; }
.dot-down { background: #0891b2; }
.dot-up { background: #f59e0b; }

.chart-card canvas {
  display: block;
  width: 100%;
  height: 240px;
}

.info-card {
  padding: 22px;
}

.info-card h2 {
  margin: 0 0 16px;
  font-size: 16px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px 28px;
  margin: 0;
}

.info-grid div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.info-grid dt {
  font-size: 12px;
  color: var(--muted);
}

.info-grid dd {
  margin: 0;
  font-size: 13.5px;
  font-family: var(--mono);
  word-break: break-all;
}

@media (max-width: 1000px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 620px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .gauge-card,
  .stat-card {
    min-height: auto;
  }

  .dash-head {
    padding-top: 32px;
  }

  .chart-card canvas {
    height: 200px;
  }
}

/* Admin page */
.admin-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: start;
  margin-bottom: 18px;
}

.admin-grid .card {
  padding: 22px;
}

.admin-grid .term-card {
  padding: 0;
}

.term-card {
  background: #0f172a;
  border-color: #1e293b;
  color: #e2e8f0;
  overflow: hidden;
}

.term-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.term-dots {
  display: flex;
  gap: 6px;
}

.term-dots i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
}

.term-dots i:nth-child(2) { background: #f59e0b; }
.term-dots i:nth-child(3) { background: #22c55e; }

.term-title {
  font-family: var(--mono);
  font-size: 12.5px;
  color: #94a3b8;
}

.term-body {
  padding: 22px 20px 24px;
}

.term-line {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 13.5px;
  color: #cbd5e1;
}

.prompt {
  color: #38bdf8;
  margin-right: 6px;
}

.term-hint {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.7;
  color: #94a3b8;
}

.card-title {
  margin: 0 0 16px;
  font-size: 16px;
}

.cmd-card {
  padding: 22px;
  margin-bottom: 56px;
}

.cmd-list {
  display: flex;
  flex-direction: column;
}

.cmd-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.cmd-row:last-child {
  border-bottom: 0;
}

.cmd-row span {
  color: var(--muted);
}

@media (max-width: 860px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

/* ESP32 tool layout */
.tools-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding-bottom: 64px;
}

.tools-nav {
  position: sticky;
  top: 88px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tool-search {
  width: 100%;
  height: 36px;
  margin-bottom: 12px;
}

.tool-group {
  margin-bottom: 14px;
}

.tool-group:last-child {
  margin-bottom: 0;
}

.tool-group h4 {
  margin: 0 0 6px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #93a1b3;
  text-transform: uppercase;
}

.tool-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tool-link {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.tool-link:hover {
  background: #eef2f8;
  color: var(--text);
}

.tool-link.active {
  background: var(--primary-soft);
  border-color: #cfdcff;
  color: var(--primary);
  font-weight: 600;
}

.tool-workspace {
  min-width: 0;
}

.tool-panel {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tool-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.tool-head h2 {
  margin: 0 0 4px;
  font-size: 21px;
  letter-spacing: -0.01em;
}

.tool-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.tool-tag {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}

.field .input,
.field .select {
  width: 100%;
  height: 38px;
  font-size: 13.5px;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 4px;
}

.tool-out {
  margin-top: 16px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.kv {
  padding: 12px 14px;
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.kv span {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--muted);
}

.kv b {
  font-size: 17px;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td code {
  background: transparent;
  padding: 0;
}

.tag {
  display: inline-block;
  padding: 1px 7px;
  margin: 1px 2px 1px 0;
  border-radius: 999px;
  background: #eef2f8;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.tag-info { background: var(--primary-soft); color: var(--primary); }
.tag-warn { background: #fff4e5; color: #b45309; }
.tag-danger { background: #fdeceb; color: #b3261e; }
.tag-ok { background: #e7f6ee; color: #1e7e4f; }

.drop-zone {
  padding: 26px 18px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: #93b4f8;
  background: var(--primary-soft);
}

.drop-zone b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 15px;
}

.hash-box {
  display: block;
  padding: 12px 14px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  word-break: break-all;
  white-space: pre-wrap;
}

.log-out {
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  margin-top: 14px;
  border-radius: 10px;
  background: #0f172a;
  color: #dbe4f5;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

#serial-out {
  min-height: 260px;
}

.serial-send {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.serial-send .input {
  flex: 1 1 220px;
  width: auto;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.check input {
  accent-color: var(--primary);
}

.progress {
  height: 8px;
  margin-top: 14px;
  border-radius: 999px;
  background: #eef2f8;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.15s linear;
}

.mqtt-line.ok { color: #7ee2a8; }
.mqtt-line.err { color: #ff9b93; }
.mqtt-line.out { color: #9ec5ff; }
.mqtt-line.msg { color: #e7d9a6; }


.note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-left: 3px solid #93b4f8;
  border-radius: 0 8px 8px 0;
  background: #f7f9fc;
  color: #36414f;
  font-size: 13px;
  line-height: 1.7;
}

.spec-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  font-size: 17px;
}

.spec-card .chip-name {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.spec-list {
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
  font-size: 13.5px;
}

.spec-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--muted);
}

.spec-list li:last-child {
  border-bottom: 0;
}

.spec-list b {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.flow {
  counter-reset: flow;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
}

.flow-item {
  position: relative;
  padding: 20px 20px 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.flow-item::before {
  counter-increment: flow;
  content: counter(flow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.flow-item h3 {
  margin: 0 0 6px;
  font-size: 15.5px;
}

.flow-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* Responsive */
@media (max-width: 900px) {
  .tools-layout {
    grid-template-columns: 1fr;
  }

  .tools-nav {
    position: static;
  }

  .tool-links {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .tool-link {
    width: auto;
    border-color: var(--border);
  }
}

@media (max-width: 860px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .docs-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .docs-sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 28px 0 0;
  }

  .sidebar-title {
    display: none;
  }

  .hero {
    padding: 60px 0 52px;
  }

  .section {
    padding: 48px 0;
  }

  .container {
    width: min(1080px, calc(100% - 32px));
  }
}

/* ================= 元件库存 ================= */

.inv-main {
  padding-bottom: 72px;
}

.inv-login {
  max-width: 440px;
  margin: 0 auto;
}

.inv-login .input {
  margin-top: 8px;
}

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

.inv-stat {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.inv-stat span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

.inv-stat b {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.inv-stat b.warn {
  color: #b45309;
}

.inv-panel {
  margin-bottom: 18px;
}

.inv-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.inv-toolbar .input {
  flex: 1 1 240px;
  max-width: 380px;
}

.inv-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inv-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.inv-panel-head .card-title {
  margin: 0;
}

.inv-stock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.inv-stock.low {
  color: #b45309;
}

.inv-op {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-mini {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 6px;
}

.inv-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.inv-badge.in {
  background: #e7f7ef;
  color: #1e7e4f;
}

.inv-badge.out {
  background: #fdecec;
  color: #c0392b;
}

.inv-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inv-form-grid .wide {
  grid-column: 1 / -1;
}

.inv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.inv-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
}

.inv-modal[hidden] {
  display: none;
}

.inv-modal-card {
  width: min(640px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 22px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

.inv-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.inv-modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.inv-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.inv-close:hover {
  color: var(--text);
}

.inv-errors {
  max-height: 260px;
  margin-top: 0;
}

@media (max-width: 640px) {
  .inv-form-grid {
    grid-template-columns: 1fr;
  }

  .inv-toolbar .input {
    max-width: none;
  }
}

.inv-code {
  display: inline-block;
  margin-top: 2px;
  padding: 0 6px;
  border-radius: 4px;
  background: #f2f5fa;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  word-break: break-all;
}

.scan-camera {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0f172a;
}

.scan-camera video {
  display: block;
  width: 100%;
  max-height: 320px;
  border-radius: 8px;
  background: #000;
  object-fit: cover;
}

.scan-camera .hint {
  color: #cbd5e1;
}

.label-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-height: 420px;
  margin-top: 14px;
  overflow: auto;
}

.label-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
}

.label-card canvas {
  width: 104px;
  height: 104px;
  image-rendering: pixelated;
}

.label-card b {
  font-size: 13px;
  word-break: break-all;
}

.label-card span {
  font-size: 12px;
  color: var(--muted);
}

.label-card code {
  font-size: 11px;
  word-break: break-all;
}
