/* ===== FONTS & RESET ===== */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

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

:root {
  --fire-red:    #c0392b;
  --fire-orange: #e67e22;
  --fire-amber:  #f39c12;
  --deep-navy:   #1a2744;
  --mid-navy:    #2c3e6e;
  --light-navy:  #3d5290;
  --bg:          #f5f6fa;
  --card-bg:     #ffffff;
  --border:      #d9dde8;
  --text-main:   #1e2235;
  --text-muted:  #6b7280;
  --blue:        #1a56db;
  --green:       #166534;
  --orange:      #9a3412;
  --chart-h:     210px;
  --radius:      8px;
  --shadow:      0 2px 12px rgba(0,0,0,0.08);
}

html { scroll-behavior: smooth; }
body { 
  font-family: 'IBM Plex Sans', sans-serif; 
  background: var(--bg); 
  color: var(--text-main); 
  font-size: 14px; 
  line-height: 1.5; 
}

/* ===== HEADER ===== */
header {
  background: linear-gradient(135deg, var(--deep-navy) 0%, #2e1503 100%);
  padding: 16px 24px;
  border-bottom: 3px solid var(--fire-orange);
}
.header-inner { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  max-width: 1600px; 
  margin: 0 auto; 
}
.header-title { display: flex; align-items: center; gap: 14px; }
.flame-icon { font-size: 2.4rem; }
header h1 { 
  color: #fff; 
  font-size: 1.5rem; 
  font-weight: 700; 
  letter-spacing: 0.02em; 
}
.header-sub { 
  color: #f5c97e; 
  font-size: 0.8rem; 
  margin-top: 2px; 
  opacity: 0.9; 
}

/* ===== TAB NAV ===== */
#tab-nav {
  background: var(--mid-navy);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 16px;
  border-bottom: 2px solid var(--fire-orange);
  position: sticky;
  top: 0;
  z-index: 100;
}
.tab-btn {
  background: transparent;
  color: #c4d0ef;
  border: none;
  padding: 8px 14px;
  border-radius: 5px 5px 0 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.tab-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.tab-btn.active { background: var(--fire-orange); color: #fff; }

/* ===== MAIN CONTENT - Centered with increased width ===== */
#main-content { 
  max-width: 1380px;           /* Increased overall width */
  margin: 0 auto; 
  padding: 20px 20px 40px; 
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== TWO-COL LAYOUT - Slightly wider right column ===== */
.two-col { 
  display: grid; 
  grid-template-columns: 410px 520px;   /* Increased right column width */
  gap: 26px; 
  align-items: start; 
  margin: 0 auto;
}

.col-left { 
  min-width: 0; 
}

.col-right { 
  min-width: 0; 
  max-width: 560px; 
}

/* ===== INPUT GROUPS ===== */
.input-group {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.input-group h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--deep-navy);
  border-bottom: 2px solid var(--fire-orange);
  padding-bottom: 6px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.field-row label {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  min-width: 190px;
  max-width: 220px;
}
.field-row input[type="number"],
.field-row input[type="text"],
.field-row select {
  width: 120px;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.88rem;
  background: #f9fafb;
  transition: border-color 0.2s;
}
.field-row select { 
  width: 200px; 
  font-family: 'IBM Plex Sans', sans-serif; 
}
.field-row input:focus, 
.field-row select:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
}
.field-row .unit { 
  color: var(--text-muted); 
  font-size: 0.8rem; 
  white-space: nowrap; 
}
.checkbox-row { flex-wrap: wrap; }
.checkbox-row label { 
  font-weight: 400; 
  max-width: none; 
  flex: unset; 
}
.hint { 
  font-size: 0.77rem; 
  color: var(--text-muted); 
  margin: -4px 0 8px 0; 
  padding-left: 4px; 
}
.optional { 
  font-size: 0.75rem; 
  color: var(--text-muted); 
  font-weight: 400; 
}
.readonly-row .readonly-val { 
  font-family: 'IBM Plex Mono', monospace; 
  color: var(--text-muted); 
  font-size: 0.88rem; 
}

/* ===== CALC BUTTON ===== */
.calc-btn {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--fire-red), var(--fire-orange));
  color: #fff;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: opacity 0.2s, transform 0.1s;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(192,57,43,0.35);
}
.calc-btn:hover { opacity: 0.92; }
.calc-btn:active { transform: scale(0.98); }

/* ===== RESULTS ===== */
.results-box {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.results-box h3 { 
  font-size: 0.88rem; 
  font-weight: 700; 
  color: var(--deep-navy); 
  margin-bottom: 10px; 
  text-transform: uppercase; 
  letter-spacing: 0.05em; 
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f5;
  font-size: 0.83rem;
}
.result-val { 
  font-family: 'IBM Plex Mono', monospace; 
  font-weight: 600; 
  color: var(--text-main); 
}
.result-val.blue { color: var(--blue); }
.result-val.green { color: #15803d; }
.result-val.orange { color: #c2410c; }
.result-highlight {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  margin: 8px 0;
  border-radius: 6px;
  background: #eef2ff;
  border-left: 4px solid var(--blue);
}
.result-big {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.18rem;
  font-weight: 700;
}

/* ===== CHARTS & DIAGRAMS - Fixed & Improved ===== */
.chart-title { 
  font-size: 1rem; 
  font-weight: 700; 
  color: var(--deep-navy); 
  margin-bottom: 10px; 
  text-align: center; 
}
.chart-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  height: var(--chart-h);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.diagram-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.diagram-box h3 { 
  font-size: 0.88rem; 
  font-weight: 700; 
  margin-bottom: 10px; 
  color: var(--deep-navy); 
}
.diagram-box svg { 
  width: 100%; 
  height: auto; 
  max-height: 280px;
  display: block;
  margin: 0 auto;
}
.diagram-box canvas { 
  width: 100%; 
  height: auto; 
  max-height: 280px;           /* Increased for burnout diagram */
  display: block;
  margin: 0 auto;
  image-rendering: crisp-edges;
}

/* ===== FORMULAS & REFERENCE ===== */
.formula-box, 
.reference-box, 
.method-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.formula-box h3, 
.reference-box h4, 
.method-box h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--deep-navy);
  margin-bottom: 8px;
}
.formula {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: #1e3a8a;
  margin-bottom: 5px;
  line-height: 1.6;
}
.formula-small {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.77rem;
  color: #374151;
  margin-bottom: 4px;
  line-height: 1.5;
}
.note {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 8px;
}

/* ===== SAFETY BANNER ===== */
.safety-banner {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.84rem;
  display: none;
}
.safety-banner.danger  { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; display:block; }
.safety-banner.warning { background: #fff7ed; color: #9a3412; border-left: 4px solid #f97316; display:block; }
.safety-banner.safe    { background: #f0fdf4; color: #166534; border-left: 4px solid #22c55e; display:block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 950px) {
  .two-col { 
    grid-template-columns: 1fr; 
  }
  .col-left { order: 1; }
  .col-right { order: 2; }
  #tab-nav { 
    overflow-x: auto; 
    flex-wrap: nowrap; 
    padding: 6px 8px; 
  }
}

@media (max-width: 600px) {
  .two-col { gap: 16px; }
  #main-content { padding: 12px 10px 30px; }
  .field-row input[type="number"] { width: 90px; }
  .col-right { max-width: 100%; }
}