/* =========================================================================
   Temas: día y noche
   ========================================================================= */
[data-theme="dark"] {
  --bg: #0d1117;
  --bg-panel: #161b22;
  --bg-input: #0d1117;
  --bg-card: #0d1117;
  --border: #30363d;
  --border-light: #21262d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --green: #2d9d2d;
  --red: #d92d2d;
  --blue: #2d6dd9;
  --orange: #d97a2d;
  --cyan: #2dd9d9;
  --gold: #ffd700;

  /* SVG-specific */
  --svg-bg: #0d1117;
  --svg-grid: #30363d;
  --svg-grid-minor: #21262d;
  --svg-axis: #30363d;
  --svg-label: #8b949e;
  --svg-hco3: #3d6b3d;
  --svg-hco3-minor: #2a3f2a;
  --svg-met-acid-acute: #8b5cf6;
  --svg-met-acid-acute-band: rgba(139, 92, 246, 0.08);
  --svg-met-acid-chronic: #58a6ff;
  --svg-met-acid-chronic-band: rgba(88, 166, 255, 0.08);
  --svg-resp-acid-acute: #d97a2d;
  --svg-resp-acid-acute-band: rgba(217, 122, 45, 0.08);
  --svg-resp-acid-chronic: #d92d2d;
  --svg-resp-acid-chronic-band: rgba(217, 45, 45, 0.08);
  --svg-resp-alk-acute: #2dd9d9;
  --svg-resp-alk-acute-band: rgba(45, 217, 217, 0.08);
  --svg-resp-alk-chronic: #2d6dd9;
  --svg-resp-alk-chronic-band: rgba(45, 109, 217, 0.08);
  --svg-met-alk-acute: #e879f9;
  --svg-met-alk-acute-band: rgba(232, 121, 249, 0.08);
  --svg-met-alk-chronic: #a06bff;
  --svg-met-alk-chronic-band: rgba(160, 107, 255, 0.08);

  --toggle-bg: #21262d;
  --toggle-icon: #ffd700;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-panel: #ffffff;
  --bg-input: #f6f8fa;
  --bg-card: #f6f8fa;
  --border: #d0d7de;
  --border-light: #eaeef2;
  --text: #1f2328;
  --text-dim: #656d76;
  --accent: #0969da;
  --green: #1a7f37;
  --red: #cf222e;
  --blue: #0550ae;
  --orange: #bc4c00;
  --cyan: #0979b3;
  --gold: #9a6700;

  --svg-bg: #ffffff;
  --svg-grid: #d0d7de;
  --svg-grid-minor: #eaeef2;
  --svg-axis: #afb8c1;
  --svg-label: #656d76;
  --svg-hco3: #1a7f37;
  --svg-hco3-minor: #9ec5a5;
  --svg-met-acid-acute: #7c3aed;
  --svg-met-acid-acute-band: rgba(124, 58, 237, 0.08);
  --svg-met-acid-chronic: #0969da;
  --svg-met-acid-chronic-band: rgba(9, 105, 218, 0.08);
  --svg-resp-acid-acute: #bc4c00;
  --svg-resp-acid-acute-band: rgba(188, 76, 0, 0.08);
  --svg-resp-acid-chronic: #cf222e;
  --svg-resp-acid-chronic-band: rgba(207, 34, 46, 0.08);
  --svg-resp-alk-acute: #0979b3;
  --svg-resp-alk-acute-band: rgba(9, 121, 179, 0.08);
  --svg-resp-alk-chronic: #0550ae;
  --svg-resp-alk-chronic-band: rgba(5, 80, 174, 0.08);
  --svg-met-alk-acute: #c026d3;
  --svg-met-alk-acute-band: rgba(192, 38, 211, 0.08);
  --svg-met-alk-chronic: #8250df;
  --svg-met-alk-chronic-band: rgba(130, 80, 223, 0.08);

  --toggle-bg: #fff8c5;
  --toggle-icon: #9a6700;
}

/* =========================================================================
   Estilos generales
   ========================================================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  padding: 20px;
  transition: background 0.3s ease, color 0.3s ease;
}

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

header {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
}

header h1 {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 5px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
}

/* Theme toggle button */
.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--toggle-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 18px;
  color: var(--toggle-icon);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-toggle:hover {
  opacity: 0.85;
  border-color: var(--accent);
}

.theme-toggle .icon {
  font-size: 16px;
}

.theme-toggle .label {
  font-size: 12px;
  color: var(--text-dim);
}

.main-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.panel h2 {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

/* Form */
.form-row {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
}

.form-row label {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 3px;
}

.required {
  color: var(--red);
  font-size: 10px;
}

.optional {
  color: var(--text-dim);
  font-size: 10px;
}

.form-row input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.2s, background 0.3s;
}

.form-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row input::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.hint {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
}

.separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.section-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-style: italic;
}

button {
  padding: 8px 14px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
  margin-right: 6px;
  transition: opacity 0.2s;
}

button:hover {
  opacity: 0.85;
}

.btn-calculate {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-clear {
  background: var(--border);
  color: var(--text);
}

/* Nomograma */
.nomogram-wrapper {
  display: flex;
  justify-content: center;
}

#nomogram {
  width: 100%;
  max-width: 560px;
  height: auto;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 15px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* SVG elements — usar variables CSS */
#nomogram {
  --c-bg: var(--svg-bg);
  --c-grid: var(--svg-grid);
  --c-grid-minor: var(--svg-grid-minor);
  --c-axis: var(--svg-axis);
  --c-label: var(--svg-label);
}

/* Resultados */
.results-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  transition: background 0.3s, border-color 0.3s;
}

.results-panel h2 {
  font-size: 16px;
  color: var(--accent);
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 15px;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 15px;
  transition: background 0.3s, border-color 0.3s;
}

.result-card h3 {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.big-text {
  font-size: 18px;
  color: var(--gold);
  font-weight: 600;
}

.sub-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 5px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
}

.result-table td {
  padding: 5px 8px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

.result-table td:first-child {
  color: var(--text-dim);
}

.result-table td:last-child {
  text-align: right;
  color: var(--text);
  font-weight: 500;
}

.flags-list {
  list-style: none;
}

.flags-list li {
  font-size: 13px;
  padding: 4px 0;
  color: var(--orange);
}

.explanation-list {
  list-style: disc;
  padding-left: 18px;
}

.explanation-list li {
  font-size: 13px;
  padding: 4px 0;
  color: var(--text);
}

.diff-list {
  list-style: square;
  padding-left: 18px;
  margin-top: 5px;
}

.diff-list li {
  font-size: 12px;
  padding: 2px 0;
  color: var(--text-dim);
}

.sub-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
  margin-bottom: 4px;
  font-style: italic;
}

footer {
  text-align: center;
  margin-top: 30px;
  padding: 15px;
  color: var(--text-dim);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  margin: 0;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: var(--text);
  opacity: 1;
}

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

/* Info panel */
.info-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-section h3 {
  font-size: 15px;
  color: var(--accent);
  margin-bottom: 10px;
}

.info-section p {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.6;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.info-table th {
  background: var(--bg-card);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  border: 1px solid var(--border);
}

.info-table td {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border-light);
  color: var(--text);
}

.info-table td:first-child {
  font-weight: 500;
}

.info-list {
  list-style: disc;
  padding-left: 20px;
  margin: 8px 0;
}

.info-list li {
  font-size: 13px;
  padding: 4px 0;
  color: var(--text);
  line-height: 1.5;
}

.info-note {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .theme-toggle {
    position: static;
    margin-bottom: 15px;
  }
}