/* ============================================================
   ONE EQUATION TO RULE THEM ALL — Effective Porosity Calculator
   Design: Deep water / geology — navy, teal, slate
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);

  /* Spacing */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem; --sp-10: 2.5rem;
  --sp-12: 3rem; --sp-16: 4rem; --sp-20: 5rem;

  /* Radius */
  --r-sm: 0.375rem; --r-md: 0.5rem; --r-lg: 0.75rem; --r-xl: 1rem;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* LIGHT MODE — deep water palette */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --border: #d0d8e4;
  --text: #0f1f2e;
  --text-muted: #4a5f78;
  --text-faint: #8a9ab0;
  --primary: #0a5c7a;
  --primary-hover: #084a63;
  --primary-light: #e0f0f7;
  --accent: #00a896;
  --accent-light: #d6f4f0;
  --navy: #0d2137;
  --result-bg: #e8f4f8;
  --shadow-sm: 0 1px 3px rgba(10,50,80,0.08);
  --shadow-md: 0 4px 16px rgba(10,50,80,0.10);
  --shadow-lg: 0 12px 40px rgba(10,50,80,0.14);

  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;
}

[data-theme="dark"] {
  --bg: #0a1520;
  --surface: #111f2e;
  --surface-2: #162536;
  --border: #1e3448;
  --text: #dde8f0;
  --text-muted: #7a9ab8;
  --text-faint: #3a5470;
  --primary: #38b2d4;
  --primary-hover: #58c8e8;
  --primary-light: #0d2a38;
  --accent: #00c9b4;
  --accent-light: #062820;
  --navy: #dde8f0;
  --result-bg: #0d2538;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  line-height: 1.6;
}

/* ---- HEADER ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .site-header {
  background: #08111a;
  border-bottom-color: var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.logo-block {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: #fff;
}

.logo-icon { color: #38b2d4; flex-shrink: 0; }

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}

.logo-sub {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.55);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-left: auto;
  margin-right: var(--sp-4);
}

.nav-link {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  transition: all var(--transition);
}
.theme-toggle:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Lang selector */
.lang-selector-wrap { position: relative; }

.lang-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.85);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.lang-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

.lang-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  list-style: none;
  overflow: hidden;
  z-index: 200;
}

.lang-dropdown.open { display: block; }

.lang-dropdown li {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}
.lang-dropdown li:hover { background: var(--surface-2); }
.lang-dropdown li.active { color: var(--primary); font-weight: 600; background: var(--primary-light); }

/* ---- HERO ---- */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, #0a3d5a 60%, #0a5c7a 100%);
  color: #fff;
  padding: clamp(var(--sp-12), 8vw, var(--sp-20)) var(--sp-6);
}

[data-theme="dark"] .hero {
  background: linear-gradient(135deg, #060e18 0%, #0a1e30 60%, #0d2e42 100%);
}

.hero-inner {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.hero-eyebrow {
  font-size: var(--text-xs);
  letter-spacing: 0.25em;
  word-spacing: 0.6em;
  text-transform: uppercase;
  color: #38b2d4;
  font-weight: 600;
  margin-bottom: var(--sp-3);
}

.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 400;
  line-height: 1.15;
  color: #fff;
  margin-bottom: var(--sp-5);
  letter-spacing: -0.02em;
}

.hero-desc {
  font-size: var(--text-base);
  color: rgba(255,255,255,0.7);
  max-width: 60ch;
  margin: 0 auto var(--sp-8);
  line-height: 1.7;
}

.equation-display {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-xl);
  padding: var(--sp-6) var(--sp-8);
  backdrop-filter: blur(8px);
  display: inline-block;
  text-align: center;
}

.eq-label {
  display: block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.5);
  margin-bottom: var(--sp-2);
}

.eq-math {
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 3vw, 2rem);
  color: #7edce8;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: var(--sp-2);
}

.eq-r2 {
  display: block;
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.5);
}

/* ---- CALCULATOR SECTION ---- */
.calculator-section {
  padding: clamp(var(--sp-10), 6vw, var(--sp-16)) var(--sp-6);
}

.calc-container {
  max-width: 1100px;
  margin: 0 auto;
}

/* Unit System Bar */
.unit-system-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

.unit-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.unit-tabs {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.unit-tab {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-full, 9999px);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  color: var(--text-muted);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.unit-tab:hover { border-color: var(--primary); color: var(--primary); }
.unit-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Calc Grid */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
  align-items: start;
}

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

.calc-inputs, .calc-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  box-shadow: var(--shadow-sm);
}

.calc-section-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--border);
}

/* Input Groups */
.input-group { margin-bottom: var(--sp-5); }

.input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-2);
}

.unit-tag {
  font-size: var(--text-xs);
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-weight: 500;
}

.calc-input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  -moz-appearance: textfield;
}
.calc-input::-webkit-outer-spin-button,
.calc-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.calc-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10,92,122,0.12);
}
.calc-input::placeholder { color: var(--text-faint); }

.input-hint {
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-top: var(--sp-1);
}

/* Calc Button */
.calc-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  margin-top: var(--sp-4);
  box-shadow: 0 2px 8px rgba(10,92,122,0.25);
}
.calc-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px rgba(10,92,122,0.35);
  transform: translateY(-1px);
}
.calc-btn:active { transform: translateY(0); }

/* Results */
.result-card {
  background: var(--result-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-placeholder {
  text-align: center;
  color: var(--text-faint);
}
.result-placeholder svg { margin: 0 auto var(--sp-3); opacity: 0.4; }
.result-placeholder p { font-size: var(--text-sm); }

.result-content { width: 100%; }

.result-main {
  text-align: center;
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.result-label {
  display: block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.result-value {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 600;
  color: var(--primary);
  line-height: 1;
  margin-bottom: var(--sp-1);
}

.result-unit {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.result-secondary { display: flex; flex-direction: column; gap: var(--sp-3); }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.result-row strong { color: var(--text); font-family: var(--font-mono); }

/* Interpretation Guide */
.interpretation-guide {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}

.guide-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-4);
}

.guide-grid { display: flex; flex-direction: column; gap: var(--sp-2); }

.guide-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-xs);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  transition: background 0.2s, box-shadow 0.2s;
}

.guide-item.active {
  background: var(--primary-light);
  box-shadow: inset 3px 0 0 var(--primary);
}
[data-theme="dark"] .guide-item.active {
  background: rgba(20,160,180,0.12);
}

.guide-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.swatch-warn { background: #ef4444; }
.swatch-low  { background: #f97316; }
.swatch-med  { background: #f59e0b; }
.swatch-good { background: #10b981; }
.swatch-high   { background: #3b82f6; }
.swatch-karst  { background: #8b5cf6; }
.swatch-basalt { background: #ec4899; }

.guide-range {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
  min-width: 90px;
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  text-align: center;
}

.guide-desc { color: var(--text-muted); flex: 1; }

/* Error */
.error-msg {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: #fff0f3;
  border: 1px solid #ffc0cc;
  border-radius: var(--r-md);
  color: #c0003a;
  font-size: var(--text-sm);
  margin-top: var(--sp-4);
}
[data-theme="dark"] .error-msg {
  background: #2a0e16;
  border-color: #6b1a2a;
  color: #ff8fa3;
}

/* ---- ABOUT SECTION ---- */
.about-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: clamp(var(--sp-10), 6vw, var(--sp-16)) var(--sp-6);
}

.about-inner { max-width: 1100px; margin: 0 auto; }

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-10);
}

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

.about-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-4);
}

.about-block p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: var(--sp-4);
  max-width: 65ch;
}

.citation-box {
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: var(--sp-4) var(--sp-5);
}

.citation-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.8;
  font-family: var(--font-body);
}
.citation-text.mt { margin-top: var(--sp-3); }
.citation-text a { color: var(--primary); }
.citation-text a:hover { color: var(--primary-hover); }
.citation-text em { font-style: italic; }

/* ---- FOOTER ---- */
.site-footer {
  background: var(--navy);
  color: rgba(255,255,255,0.6);
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
}
[data-theme="dark"] .site-footer { background: #04090f; }

.footer-inner { max-width: 1100px; margin: 0 auto; }

.footer-author {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.8);
  margin-bottom: var(--sp-2);
}

.footer-note {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.4);
}

/* RTL support for Arabic */
[dir="rtl"] .header-inner { flex-direction: row-reverse; }
[dir="rtl"] .logo-block { flex-direction: row-reverse; }
[dir="rtl"] .input-label { flex-direction: row-reverse; }
[dir="rtl"] .result-row { flex-direction: row-reverse; }
[dir="rtl"] .citation-box { border-left: none; border-right: 3px solid var(--primary); border-radius: var(--r-md) 0 0 var(--r-md); }
[dir="rtl"] .guide-item { flex-direction: row-reverse; }
[dir="rtl"] .unit-system-bar { flex-direction: row-reverse; }

/* Highlight active result */
.result-card.has-result {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* ---- INTERPRETATION BADGE ---- */
.interp-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-body);
}
.interp-low     { background: rgba(239,68,68,0.12); color: #b91c1c; }
[data-theme="dark"] .interp-low { background: rgba(239,68,68,0.2); color: #fca5a5; }
.interp-med     { background: rgba(245,158,11,0.12); color: #b45309; }
[data-theme="dark"] .interp-med { background: rgba(245,158,11,0.2); color: #fcd34d; }
.interp-good    { background: rgba(16,185,129,0.12); color: #065f46; }
[data-theme="dark"] .interp-good { background: rgba(16,185,129,0.2); color: #6ee7b7; }
.interp-high    { background: rgba(59,130,246,0.12); color: #1d4ed8; }
[data-theme="dark"] .interp-high { background: rgba(59,130,246,0.2); color: #93c5fd; }
.interp-karst   { background: rgba(139,92,246,0.12); color: #6d28d9; }
[data-theme="dark"] .interp-karst { background: rgba(139,92,246,0.2); color: #c4b5fd; }
.interp-basalt  { background: rgba(236,72,153,0.12); color: #be185d; }
[data-theme="dark"] .interp-basalt { background: rgba(236,72,153,0.2); color: #f9a8d4; }
.interp-warn    { background: rgba(239,68,68,0.12); color: #b91c1c; }
[data-theme="dark"] .interp-warn { background: rgba(239,68,68,0.2); color: #fca5a5; }

/* ---- RESULT FLASH ANIMATION ---- */
@keyframes resultFlash {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(20,160,180,0.4); }
  50%  { transform: scale(1.008); box-shadow: 0 0 0 8px rgba(20,160,180,0); }
  100% { transform: scale(1); box-shadow: none; }
}
.result-flash {
  animation: resultFlash 0.4s ease-out;
}

/* ---- HOW TO USE ---- */
.howto-section {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-8) var(--sp-6);
}

.howto-inner {
  max-width: 900px;
  margin: 0 auto;
}

.howto-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-6);
}

.howto-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-5);
}

.howto-step {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-body strong {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  display: block;
}

.step-body span {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.6;
}

[dir="rtl"] .howto-step { flex-direction: row-reverse; }

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

/* ---- BUTTON ROW ---- */
.btn-row {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
}

.btn-row .calc-btn {
  flex: 1;
}

.reset-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--sp-4);
  height: 44px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  white-space: nowrap;
}

.reset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ── German long-word handling ──────────────────────────────── */
[lang="de"] .section-body,
[lang="de"] .deeper-dive-body,
[lang="de"] .card-desc,
[lang="de"] h1, [lang="de"] h2, [lang="de"] h3,
[lang="de"] p, [lang="de"] li {
  hyphens: auto;
  -webkit-hyphens: auto;
  word-break: break-word;
  overflow-wrap: break-word;
}


/* ── Interpretation Guide overlap note ─────────────────────────────── */
.guide-overlap-note {
  margin: 12px 4px 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-muted, #6b7280);
  font-style: italic;
  border-top: 1px solid var(--border, #e5e7eb);
  padding-top: 10px;
}

/* ── Batch Processing Section ───────────────────────────────────────── */
.batch-section {
  background: var(--surface-alt, #f9fafb);
  border-top: 1px solid var(--border, #e5e7eb);
  padding: 3rem 1.5rem;
}
.batch-inner {
  max-width: 900px;
  margin: 0 auto;
}
.batch-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary, #111827);
  margin: 0 0 0.5rem;
}
.batch-desc {
  font-size: 0.92rem;
  color: var(--text-secondary, #374151);
  margin: 0 0 1.25rem;
  line-height: 1.6;
}
.batch-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.batch-file-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #d1d5db);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary, #111827);
  transition: border-color 0.15s, background 0.15s;
}
.batch-file-label:hover {
  border-color: var(--accent, #0ea5e9);
  background: var(--surface-hover, #f0f9ff);
}
.batch-file-input {
  display: none;
}
.batch-filename {
  font-size: 0.85rem;
  color: var(--text-muted, #6b7280);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.batch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  background: var(--accent, #0ea5e9);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.batch-btn:hover:not(:disabled) { background: var(--accent-dark, #0284c7); }
.batch-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.batch-format-hint {
  font-size: 0.78rem;
  color: var(--text-muted, #6b7280);
  margin: 0 0 1.5rem;
  font-family: monospace;
}
.batch-results {
  margin-top: 1.5rem;
}
.batch-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.batch-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary, #111827);
}
.batch-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: var(--surface, #fff);
  border: 1.5px solid var(--accent, #0ea5e9);
  border-radius: 8px;
  color: var(--accent, #0ea5e9);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.batch-download-btn:hover {
  background: var(--surface-hover, #f0f9ff);
}
.batch-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border, #e5e7eb);
}
.batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.batch-table thead th {
  background: var(--surface-header, #f3f4f6);
  padding: 0.6rem 0.9rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary, #111827);
  border-bottom: 2px solid var(--border, #e5e7eb);
  white-space: nowrap;
}
.batch-table tbody tr:nth-child(even) { background: var(--surface-alt, #f9fafb); }
.batch-table tbody tr:hover { background: var(--surface-hover, #f0f9ff); }
.batch-table tbody td {
  padding: 0.5rem 0.9rem;
  color: var(--text-secondary, #374151);
  border-bottom: 1px solid var(--border, #f0f0f0);
  white-space: nowrap;
}
.batch-table .ne-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* Ne band colours matching the guide swatches */
.band-warn  { color: #b45309; }
.band-low   { color: #0369a1; }
.band-med   { color: #0891b2; }
.band-good  { color: #16a34a; }
.band-high  { color: #15803d; }
.band-karst { color: #7c3aed; }
.batch-error {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 0.88rem;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .batch-section { background: var(--surface-alt, #1f2937); }
  .batch-file-label { background: var(--surface, #1f2937); border-color: var(--border, #374151); color: var(--text-primary, #f9fafb); }
  .batch-file-label:hover { background: var(--surface-hover, #374151); }
  .batch-table thead th { background: var(--surface-header, #374151); color: var(--text-primary, #f9fafb); }
  .batch-table tbody tr:nth-child(even) { background: var(--surface-alt, #1f2937); }
  .batch-table tbody tr:hover { background: var(--surface-hover, #374151); }
  .batch-download-btn { background: var(--surface, #1f2937); }
  .batch-download-btn:hover { background: var(--surface-hover, #374151); }
  .batch-error { background: #450a0a; border-color: #991b1b; color: #fca5a5; }
}

/* RTL batch layout */
[dir="rtl"] .batch-controls { flex-direction: row-reverse; }
[dir="rtl"] .batch-table thead th,
[dir="rtl"] .batch-table tbody td { text-align: right; }
[dir="rtl"] .batch-results-header { flex-direction: row-reverse; }

/* ── Batch CSV Preview Table ────────────────────────────────────────── */
.batch-preview-wrap {
  margin: 1.25rem 0 1.5rem;
}
.batch-preview-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary, #374151);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem;
}
.batch-preview-table-wrap {
  display: inline-block;
  border: 1.5px solid var(--accent, #0ea5e9);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(14,165,233,0.08);
}
.batch-preview-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  font-family: 'Courier New', Courier, monospace;
  min-width: 280px;
}
.batch-preview-table thead th {
  background: var(--accent, #0ea5e9);
  color: #fff;
  padding: 0.55rem 1.2rem;
  text-align: left;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.batch-preview-table tbody td {
  padding: 0.45rem 1.2rem;
  color: var(--text-primary, #111827);
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.batch-preview-table tbody tr:last-child td { border-bottom: none; }
.batch-preview-table tbody tr:nth-child(even):not(.preview-note-row) {
  background: var(--surface-alt, #f0f9ff);
}
.preview-note-row td {
  font-family: inherit;
  font-size: 0.76rem;
  color: var(--text-muted, #6b7280);
  font-style: italic;
  background: var(--surface-alt, #f9fafb) !important;
  padding: 0.35rem 1rem;
  border-bottom: 1.5px dashed var(--accent, #0ea5e9) !important;
}
.batch-preview-actions {
  margin-top: 0.75rem;
}
.batch-template-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: var(--surface, #fff);
  border: 1.5px solid var(--accent, #0ea5e9);
  border-radius: 8px;
  color: var(--accent, #0ea5e9);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.batch-template-btn:hover {
  background: var(--surface-hover, #f0f9ff);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .batch-preview-table tbody td { color: var(--text-primary, #f9fafb); }
  .batch-preview-table tbody tr:nth-child(even):not(.preview-note-row) { background: rgba(14,165,233,0.08); }
  .preview-note-row td { background: rgba(255,255,255,0.04) !important; }
  .batch-template-btn { background: var(--surface, #1f2937); }
  .batch-template-btn:hover { background: var(--surface-hover, #374151); }
}

/* RTL */
[dir="rtl"] .batch-preview-table thead th,
[dir="rtl"] .batch-preview-table tbody td { text-align: right; }
[dir="rtl"] .batch-preview-actions { text-align: right; }

/* ── How-to batch note ──────────────────────────────────────────────── */
.howto-batch-note {
  margin: 1.25rem 0 0;
  padding: 0.65rem 1rem;
  background: var(--surface-alt, #f0f9ff);
  border-left: 3px solid var(--accent, #0ea5e9);
  border-radius: 0 6px 6px 0;
  font-size: 0.875rem;
  color: var(--text-secondary, #374151);
  line-height: 1.5;
}
.howto-batch-note strong { color: var(--accent, #0ea5e9); font-weight: 600; }

@media (prefers-color-scheme: dark) {
  .howto-batch-note {
    background: rgba(14,165,233,0.08);
    color: var(--text-secondary, #9ca3af);
  }
}

[dir="rtl"] .howto-batch-note {
  border-left: none;
  border-right: 3px solid var(--accent, #0ea5e9);
  border-radius: 6px 0 0 6px;
}

/* ── Footer credit ──────────────────────────────────────────────────── */
.footer-credit {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-faint, #9ca3af);
}
.footer-credit a {
  color: var(--accent, #0ea5e9);
  text-decoration: none;
}
.footer-credit a:hover {
  text-decoration: underline;
}
