/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: Arial, "Helvetica Neue", Helvetica, Ubuntu, sans-serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e0e3e8;
  --text: #1a1c1f;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-dim: rgba(37, 99, 235, 0.07);
  --accent-border: rgba(37, 99, 235, 0.2);
  --nav-h: 44px;
  --header-h: 60px;
  --radius: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --danger-bg: rgba(220, 38, 38, 0.06);
  --danger-border: rgba(220, 38, 38, 0.25);
  --danger-text: #dc2626;
  --safe-bg: rgba(22, 163, 74, 0.06);
  --safe-border: rgba(22, 163, 74, 0.25);
  --safe-text: #16a34a;
}

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--nav-h);
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Main layout container ──────────────────────────────────────────────── */
.bd-layout {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* ── Tab bar ────────────────────────────────────────────────────────────── */
.bd-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  gap: 0;
}

.bd-tab {
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
  white-space: nowrap;
}

.bd-tab:hover { color: var(--text); }

.bd-tab.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* ── Tab panels ─────────────────────────────────────────────────────────── */
.bd-panel { display: none; }
.bd-panel.active { display: block; }

/* ── Two-column grid for DC and RF panels ───────────────────────────────── */
.bd-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* ── Input card ─────────────────────────────────────────────────────────── */
.bd-input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.input-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Form fields ────────────────────────────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.form-field:last-of-type { margin-bottom: 0; }

.form-field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.field-unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  font-family: var(--mono);
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: -2px;
  margin-bottom: 2px;
}

.form-field select,
.form-field input[type="number"] {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
.form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.form-field select:focus,
.form-field input[type="number"]:focus {
  border-color: var(--accent);
  background-color: var(--surface);
}
.form-field input[type="number"]::placeholder { color: #aaa; }

/* ── Info boxes ─────────────────────────────────────────────────────────── */
.info-box {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}
.info-box strong { color: var(--text); }
.info-box em { font-style: italic; }
.info-box .eq {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(37, 99, 235, 0.06);
  padding: 3px 6px;
  border-radius: 3px;
  display: inline-block;
  margin: 2px 0;
}

.source-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}
.source-box strong { color: var(--text); }
.source-box a { color: var(--accent); text-decoration: none; }
.source-box a:hover { text-decoration: underline; }

.warn-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(217, 119, 6, 0.07);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius);
  font-size: 11px;
  color: #92400e;
  line-height: 1.6;
}
.warn-box strong { color: #78350f; }
.warn-box a { color: var(--accent); text-decoration: none; }
.warn-box a:hover { text-decoration: underline; }

/* ── Gas constants panel ────────────────────────────────────────────────── */
.gas-constants {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.8;
  font-family: var(--mono);
}
.gas-constants strong { color: var(--text); font-family: var(--font); font-size: 11px; }
.gas-constants .source-sub {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  font-family: var(--font);
  line-height: 1.5;
}
.gas-constants a { color: var(--accent); text-decoration: none; }
.gas-constants a:hover { text-decoration: underline; }

/* ── Results column ─────────────────────────────────────────────────────── */
.bd-results-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bd-results-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* ── Result cards ───────────────────────────────────────────────────────── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 11px 14px;
}

.result-card.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}
.result-card.safe {
  background: var(--safe-bg);
  border-color: var(--safe-border);
}

.result-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.result-card-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  font-family: var(--mono);
  letter-spacing: -0.5px;
  line-height: 1.15;
}
.result-card.danger .result-card-value { color: var(--danger-text); }
.result-card.safe .result-card-value   { color: var(--safe-text); }

.result-card-unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  font-family: var(--font);
  margin-left: 2px;
}

.result-card-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.3;
}
.result-card.danger .result-card-detail { color: var(--danger-text); }
.result-card.safe .result-card-detail   { color: var(--safe-text); }

/* ── Paschen Curves tab ─────────────────────────────────────────────────── */
.gas-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.gas-toggle-btn {
  padding: 4px 11px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
/* Active state is set inline via JS (color + border vary per gas) */

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow-x: auto;
}

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

#paschen-chart-svg {
  width: 100%;
  max-width: 680px;
  display: block;
  margin: 0 auto;
}

.paschen-minimums {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.8;
}
.paschen-minimums strong { color: var(--text); }

/* ── Data table ─────────────────────────────────────────────────────────── */
.data-table-section {
  margin-top: 20px;
}

.data-table-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table thead th {
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  font-family: var(--font);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }

.data-table td {
  padding: 6px 10px;
  color: var(--text);
  vertical-align: middle;
}

.data-table td.gas-name {
  font-family: var(--font);
  font-weight: 600;
}

.data-table td.source-col {
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .bd-panel-grid {
    grid-template-columns: 1fr;
  }
  .bd-layout {
    padding: 16px;
  }
  h1 { font-size: 16px; white-space: normal; }
  .bd-tab { padding: 8px 12px; font-size: 12px; }
}
