:root {
  --bg:      #0f1220;
  --panel:   #1a1f35;
  --panel2:  #222a47;
  --border:  #2e3759;
  --text:    #e8ebff;
  --muted:   #9aa3c7;
  --accent:  #5b8cff;
  --accent2: #22d3ee;
  --ok:      #22c55e;
  --bad:     #ef4444;
  --warn:    #f59e0b;
  
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  --font-sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --sidebar-w: 320px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; outline: none; }
ul { list-style: none; }

/* ── App Layout ── */
#app { display: flex; flex-direction: column; width: 100vw; height: 100vh; }

/* ── Cabecera Superior (Header) ── */
#header {
  height: 70px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.header-left h1 { font-size: 18px; color: var(--text); line-height: 1.2; }
.logo-sub { color: var(--accent2); font-size: 11px; font-weight: 600; }

.header-mid .day-sel {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
}
.header-mid select {
  background: transparent; border: none; color: var(--accent2); font-weight: 700; cursor: pointer;
}
.header-mid select option {
  background: var(--panel2);
  color: var(--accent2);
  font-weight: 600;
}

.tab-nav { display: flex; gap: 8px; }
.tab-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px; font-weight: 700;
  color: var(--muted);
  transition: .15s;
  display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { background: var(--panel2); color: var(--text); }
.tab-btn.active { background: var(--accent); color: #fff; }

/* ── Content Area ── */
#content { flex: 1; display: flex; overflow: hidden; }
.pane { display: none; flex: 1; overflow: hidden; flex-direction: row; }
.pane.active { display: flex; }

/* Inner Sidebar */
.inner-sidebar {
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 18px 14px;
}
.sidebar-hdr { font-size: 14px; font-weight: 700; color: var(--accent2); margin-bottom: 16px; }

/* Topic Progress */
.topic-group { margin-top: 10px; }
.topic-part { font-size: 11px; letter-spacing: 1.5px; color: var(--accent2); margin: 18px 0 6px; font-weight: 700; text-transform: uppercase; }
.ex-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 9px;
  font-size: 13px; color: var(--muted);
  transition: .12s; text-align: left; width: 100%;
}
.ex-btn:hover { color: var(--text); }
.ex-btn.active { background: var(--accent); color: #fff; }
.ex-btn .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.ex-btn .ico-done { font-size: 11px; margin-left: auto; width: 14px; height: 14px; border: 1px solid var(--muted); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.ex-btn.completed .ico-done { background: var(--ok); border-color: var(--ok); color: #fff; content: "✓"; }

/* Main internal padding */
.pane-inner { flex: 1; padding: 30px; overflow-y: auto; }

/* ── Ejercicios Top Header ── */
.ex-hdr-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.qtag {
  background: var(--panel2); color: var(--accent2); font-size: 11px; font-weight: 800;
  border-radius: 6px; padding: 4px 8px; letter-spacing: .5px; text-transform: uppercase;
}
.btn-help-yellow {
  background: var(--warn); color: #000; border-radius: 6px; padding: 8px 14px;
  font-weight: 700; font-size: 13px; transition: .15s;
}
.btn-help-yellow:hover { opacity: .9; }

.ex-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.ex-instruction { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 24px; }

/* Formula Bar */
.formula-bar-container { display: flex; gap: 10px; margin-bottom: 20px; }
.formula-bar {
  flex: 1; display: flex; align-items: center; background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px;
}
.qtag-ref { color: var(--accent2); font-weight: 700; margin-right: 12px; font-size: 14px; }
.formula-bar input {
  flex: 1; background: transparent; border: none; color: var(--text); font-size: 14px; font-family: var(--font-mono);
}
.btn-eval {
  background: var(--accent); color: #fff; padding: 0 20px; border-radius: 6px; font-weight: 700; transition: .15s;
}
.btn-eval:hover { background: #6f9cff; }

/* Grid / Tables */
.grid-area { margin-top: 10px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.excel-table { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 13px; background: var(--panel); }
.excel-table th {
  background: var(--panel2); color: var(--muted); font-size: 12px; padding: 10px; border: 1px solid var(--border); font-weight: 600;
}
.excel-table td { border: 1px solid var(--border); padding: 12px; color: var(--text); text-align: center; }
.excel-table td.target-cell { background: rgba(34,211,238,.1); box-shadow: inset 0 0 0 2px var(--accent2); color: var(--accent2); font-weight: 700; }

/* Quiz Styles */
#quiz-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px; align-items: start; }
.quiz-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; margin-bottom: 0; display: flex; flex-direction: column; }
.quiz-topic { background: var(--panel2); color: var(--accent2); font-size: 11px; font-weight: 800; border-radius: 6px; padding: 4px 8px; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 12px; display: inline-block; align-self: flex-start; }
.quiz-q { font-size: 15px; line-height: 1.55; margin-bottom: 12px; }
.quiz-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.quiz-opt {
  text-align: left; padding: 11px 13px; border-radius: 9px; background: var(--panel2);
  border: 1px solid var(--border); color: var(--text); font-size: 13.5px; transition: .12s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opt.selected { border-color: var(--accent); background: rgba(91,140,255,.15); }
.quiz-opt.correct { border-color: var(--ok); background: rgba(34,197,94,.13); }
.quiz-opt.wrong { border-color: var(--bad); background: rgba(239,68,68,.13); }

/* Feedback */
.feedback { margin-top: 15px; font-size: 14px; line-height: 1.55; }
.fb-ok { color: var(--ok); font-weight: 700; }
.fb-bad { color: var(--bad); font-weight: 700; }
.quiz-explain { background: var(--panel2); border-left: 3px solid var(--accent); padding: 9px 12px; border-radius: 0 7px 7px 0; margin-top: 7px; color: var(--text); }

/* ── Projects Area ── */
.proj-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.proj-btn {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 12px; text-align: left; color: var(--text);
}
.proj-btn:hover { border-color: var(--accent); }
.proj-btn.active { border-color: var(--accent); background: rgba(91,140,255,.15); }
.diff-badge { background: var(--panel); color: var(--accent2); padding: 3px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; display: inline-block; margin-bottom: 6px; text-transform: uppercase; border: 1px solid var(--border); }
.proj-btn .ptitle { font-weight: 700; font-size: 14px; }
.proj-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px; margin-bottom: 16px; }
.proj-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.proj-scenario { color: var(--muted); line-height: 1.6; margin-bottom: 16px; font-size: 14px; }
.req-box { background: var(--panel2); padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; border: 1px solid var(--border); }
.req-box h4 { font-size: 11px; color: var(--accent2); text-transform: uppercase; margin-bottom: 8px; }
.req-item { font-size: 13px; margin-bottom: 4px; display: flex; gap: 6px; align-items: flex-start; }
.btn-solution { background: var(--panel2); color: var(--text); border: 1px solid var(--border); padding: 10px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 700; transition: .15s; display: inline-flex; align-items: center; gap: 8px; }
.btn-solution:hover { border-color: var(--accent); }
.sol-card { background: var(--bg); border: 1px solid var(--ok); border-radius: 14px; padding: 22px; margin-top: 16px; }
.sol-title { color: var(--ok); font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.sol-section-hdr { font-size: 11px; color: var(--muted); text-transform: uppercase; margin: 16px 0 8px; letter-spacing: 0.5px; font-weight: 700; }
.sol-table { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 13px; margin-bottom: 20px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.sol-table tr:first-child td { background: var(--panel); color: var(--accent2); font-weight: 700; border-bottom: 1px solid var(--border); padding: 10px 12px; }
.sol-table td { padding: 10px 12px; color: var(--text); text-align: center; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.sol-table td:last-child { border-right: none; }
.sol-table tr:last-child td { border-bottom: none; }
.step-card { background: var(--panel); border-radius: 9px; padding: 12px 16px; margin-bottom: 12px; border: 1px solid var(--border); }
.step-name { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; color: var(--text); }
.step-formula { display: block; font-family: var(--font-mono); background: var(--panel2); padding: 8px 12px; border-radius: 6px; color: #ffe08a; font-size: 13px; margin-bottom: 8px; border: 1px solid var(--border); }
.step-note { color: var(--muted); font-size: 13px; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 99; align-items: center; justify-content: center; padding: 18px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--accent); border-radius: 16px; max-width: 760px; width: 100%; max-height: 86vh; overflow-y: auto; padding: 22px 26px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.modal-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-hdr h3 { color: var(--accent2); font-size: 18px; }
.modal-close { font-size: 28px; color: var(--accent2); transition: .12s; line-height: 1; }
.modal-close:hover { color: #fff; }
.cheat { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; margin: 7px 0; font-size: 13.5px; line-height: 1.65; }
.cheat b { color: var(--accent2); }
.modal code { background: var(--panel2); padding: 1px 6px; border-radius: 5px; color: #ffe08a; font-family: var(--font-mono); border: 1px solid var(--border); }
.btn-ok { background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 9px; font-weight: 700; font-size: 13.5px; width: 100%; margin-top: 15px; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
