/* ─────────────────────────────────────────────
   Biogas-to-Methanol Simple Calculator
   Style: clean, white cards, blue accent
   ───────────────────────────────────────────── */

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

body {
  font-family: system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
  padding: 0 0 48px;
}

/* ── Header ── */
.app-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 16px 12px;
  margin-bottom: 16px;
}
.app-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header h1 .icon { font-size: 1.2rem; }
.app-header p {
  color: #64748b;
  font-size: 0.82rem;
  margin-top: 4px;
}
@media (min-width: 640px) {
  .app-header { padding: 20px 32px 16px; margin-bottom: 24px; }
  .app-header h1 { font-size: 1.45rem; }
  .app-header h1 .icon { font-size: 1.4rem; }
  .app-header p { font-size: 0.88rem; }
}

/* ── Main layout ── */
.app-body {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 12px;
}
@media (min-width: 640px) { .app-body { padding: 0 24px; } }

/* ── Tab bar ── */
.tab-bar {
  display: flex;
  gap: 2px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
}
.tab-btn {
  flex: 1;
  padding: 12px 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn:hover { background: #f8fafc; color: #334155; }
.tab-btn.active {
  background: #2563eb;
  color: #fff;
}
.tab-btn .tab-icon { font-size: 1.2rem; line-height: 1; }
@media (min-width: 480px) {
  .tab-btn {
    flex-direction: row;
    padding: 13px 8px;
    font-size: 0.85rem;
    gap: 6px;
    min-height: auto;
  }
  .tab-btn .tab-icon { font-size: 1rem; }
}
@media (min-width: 640px) { .tab-btn { font-size: 0.9rem; gap: 7px; } }

/* ── Tab content panels ── */
.tab-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 16px;
}
@media (min-width: 640px) { .tab-panel { padding: 28px 32px; } }
.hidden { display: none !important; }

/* ── Section headings ── */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  margin: 24px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}
.section-title:first-child { margin-top: 0; }

/* ── Form grid ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 32px;
}
@media (max-width: 680px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
}
.field input[type=number],
.field input[type=range],
.field select {
  width: 100%;
}

input[type=number] {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 1rem;
  color: #1e293b;
  background: #fff;
  transition: border-color 0.15s;
  min-height: 44px;
  -webkit-appearance: none;
}
input[type=number]:focus { outline: none; border-color: #2563eb; }

input[type=range] {
  accent-color: #2563eb;
  height: 4px;
  min-height: 44px;
  cursor: pointer;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.range-val {
  font-weight: 700;
  color: #2563eb;
  min-width: 52px;
  font-size: 0.95rem;
}

select {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  min-height: 44px;
}

/* ── Calculated flows box ── */
.flows-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 20px;
}
.flows-box .flows-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: #475569;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.flows-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 400px) { .flows-grid { grid-template-columns: 1fr 1fr; } }
.flow-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 12px;
}
.flow-item .flabel { font-size: 0.78rem; color: #94a3b8; margin-bottom: 2px; }
.flow-item .fval   { font-weight: 700; font-size: 0.95rem; color: #1e293b; }
.flow-item.accent  { border-color: #bfdbfe; background: #eff6ff; }
.flow-item.accent .fval { color: #2563eb; }

/* ── KPI cards row ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0;
}
@media (min-width: 640px) {
  .kpi-row { grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 24px 0; }
}

.kpi-card {
  border-radius: 10px;
  padding: 14px 14px;
  color: #fff;
  min-width: 0;
}
@media (min-width: 640px) { .kpi-card { padding: 18px 20px; } }
.kpi-card.blue   { background: #2563eb; }
.kpi-card.green  { background: #16a34a; }
.kpi-card.purple { background: #7c3aed; }
.kpi-card.amber  { background: #d97706; }

.kpi-card .kpi-label { font-size: 0.75rem; opacity: 0.85; margin-bottom: 4px; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; line-height: 1; overflow-wrap: break-word; word-break: break-all; }
.kpi-card .kpi-unit  { font-size: 0.75rem; opacity: 0.8; margin-top: 4px; }
.kpi-card .kpi-sub   { font-size: 0.72rem; margin-top: 6px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
@media (min-width: 640px) {
  .kpi-card .kpi-label { font-size: 0.82rem; margin-bottom: 6px; }
  .kpi-card .kpi-value { font-size: 2rem; letter-spacing: -1px; }
  .kpi-card .kpi-unit  { font-size: 0.8rem; }
  .kpi-card .kpi-sub   { font-size: 0.8rem; }
}

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-ok   { background: rgba(255,255,255,0.2); }
.badge-warn { background: rgba(255,200,0,0.3); }
.badge-bad  { background: rgba(255,80,80,0.3); }

/* ── Economics table ── */
.econ-section { margin-top: 8px; }
.econ-section h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 14px;
}
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.econ-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 420px;
}
.econ-table th {
  background: #f1f5f9;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
}
.econ-table th.num,
.econ-table td.num { text-align: right; }

.econ-table tbody tr { border-bottom: 1px solid #f1f5f9; }
.econ-table tbody tr:hover { background: #f8fafc; }
.econ-table tbody td { padding: 10px 14px; color: #334155; }
.econ-table td.highlight { color: #dc2626; font-weight: 600; }

.econ-table tfoot tr.total-row td {
  padding: 12px 14px;
  font-weight: 700;
  font-size: 0.95rem;
  background: #1e293b;
  color: #fff;
  border-top: 2px solid #334155;
}

/* ── Equipment summary ── */
.eq-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
@media (min-width: 700px) {
  .eq-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 20px; }
}
@media (max-width: 399px) { .eq-grid { grid-template-columns: 1fr; } }

.eq-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
}
.eq-card .eq-title { font-size: 0.8rem; font-weight: 600; color: #64748b; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.eq-card .eq-row { display: flex; justify-content: space-between; font-size: 0.88rem; margin-bottom: 4px; }
.eq-card .eq-row span:last-child { font-weight: 600; color: #1e293b; }

/* ── Disclaimer ── */
.disclaimer {
  margin-top: 28px;
  background: #fef9c3;
  border: 1px solid #fef08a;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.83rem;
  color: #713f12;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.disclaimer .disc-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* ── Muted helper text ── */
.muted { color: #94a3b8; font-size: 0.82rem; margin-top: 2px; }
