:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --ink: #0f172a;
  --muted: #475569;
  --subtle: #64748b;
  --line: #dbe3ec;
  --line-strong: #b8c5d6;
  --steel: #1e3a5f;
  --steel-deep: #0f2540;
  --steel-soft: #e8eff7;
  --amber: #d97706;
  --amber-deep: #b45309;
  --amber-soft: #fef3c7;
  --ok: #047857;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(244, 246, 248, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand-domain {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--subtle);
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
.nav a:hover { color: var(--ink); }

/* Hero */
.hero {
  padding: 36px 0 24px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel);
  background: var(--steel-soft);
  padding: 5px 12px;
  border-radius: 999px;
}
.hero h1 {
  margin: 14px 0 8px;
  font-size: clamp(26px, 3.6vw, 38px);
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.hero-sub {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 15px;
}

/* Main Calculator Grid */
.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 28px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 12px 28px -24px rgba(15, 23, 42, 0.25);
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

/* Unit Switch */
.segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* Shape Tabs */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}
.shape-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.shape-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.shape-btn.active {
  border-color: var(--steel);
  background: var(--steel-soft);
  color: var(--steel-deep);
}
.shape-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Diagram + Fields */
.diagram-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px dashed var(--line-strong);
  margin-bottom: 16px;
}
.diagram-svg {
  width: 78px;
  height: 58px;
  flex-shrink: 0;
}
.diagram-info {
  font-size: 12.5px;
  color: var(--muted);
}
.diagram-formula {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--steel-deep);
  font-weight: 600;
  margin-top: 2px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field.full {
  grid-column: 1 / -1;
}
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.field-hint {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--subtle);
}
.field input, .field select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.chip:hover {
  border-color: var(--steel);
  color: var(--steel-deep);
}
.error-msg {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12.5px;
  display: none;
}

/* Result Card */
.result-panel {
  background: var(--ink);
  color: #f8fafc;
  border-color: #1e293b;
}
.result-panel .panel-title { color: #f8fafc; }
.result-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(217, 119, 6, 0.22);
  color: #fbbf24;
  font-weight: 600;
}
.kpi-main {
  padding: 16px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.kpi-label {
  font-size: 12px;
  color: #94a3b8;
}
.kpi-value {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}
.kpi-sub {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: #cbd5e1;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.kpi-box {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 12px;
}
.kpi-box .num {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}
.kpi-box .sub {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #94a3b8;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.btn-primary {
  flex: 1;
  min-width: 150px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: var(--amber);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--amber-deep); }
.btn-ghost {
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: transparent;
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover { border-color: #ffffff; color: #ffffff; }
.btn-outline {
  height: 36px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-outline:hover { border-color: var(--steel); color: var(--steel-deep); }

/* BOM Table */
.section { margin-bottom: 28px; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
td.num, th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td { border-bottom: 0; }
.bom-empty {
  padding: 24px;
  text-align: center;
  color: var(--subtle);
  font-size: 13.5px;
}
.del-btn {
  border: 0;
  background: transparent;
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.bom-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--steel-soft);
  color: var(--steel-deep);
  font-size: 13.5px;
  font-weight: 600;
}

/* Reference Grids */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.faq-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.faq-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.faq-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}
.faq-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

/* B2B Probe Band */
.b2b-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 16px;
  padding: 22px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.b2b-band h2 {
  margin: 0 0 6px;
  font-size: 18px;
}
.b2b-band p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  max-width: 640px;
}
.b2b-cta {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  background: var(--ink);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
}
.b2b-cta:hover { background: var(--steel-deep); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.3);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
  margin-top: 24px;
  font-size: 13px;
  color: var(--subtle);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 900px) {
  .calc-layout, .ref-grid, .faq-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .shape-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .nav { display: none; }
}
