/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Global safety: all images must never overflow their container */
img { max-width: 100%; height: auto; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f8f9fa;
  color: #212529;
  line-height: 1.7;
}
a { color: #0D6EFD; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 280px;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;
}

.logo-img {
  max-width: 160px;
  height: auto;
  display: block;
  margin-bottom: 8px;
}

.logo-url {
  font-size: 12px;
  color: #0D6EFD;
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: #f1f1f1; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 80px;
  padding: 0 20px;
  color: #212529;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.nav-item:hover {
  background: #f0f4ff;
  text-decoration: none;
}

.nav-item.active {
  background: #f0f4ff;
  border-left-color: #0D6EFD;
  color: #0D6EFD;
}

.nav-icon {
  width: 24px;
  height: 24px;
  color: #0D6EFD;
  flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: 280px;
  min-height: 100vh;
  background: #fff;
  padding: 0 48px;
}

.content-wrapper {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 0;
}

/* ===== HERO SECTION ===== */
.hero-section {
  background: linear-gradient(135deg, #1565C0 0%, #1E88E5 40%, #42A5F5 75%, #64B5F6 100%);
  border-radius: 16px;
  padding: 60px 50px;
  margin-bottom: 48px;
  color: #fff;
  max-width: 1000px;
  min-height: 320px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.45);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 20px;
  width: fit-content;
}

.hero-title {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 18px;
  color: #fff;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 16px;
  color: rgba(255,255,255,0.92);
  line-height: 1.6;
  margin-bottom: 36px;
  max-width: 680px;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-hero-primary {
  background: #fff;
  color: #0D6EFD;
  border: none;
  padding: 12px 28px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, transform 0.1s;
}

.btn-hero-primary:hover {
  background: #f0f4ff;
  text-decoration: none;
  color: #0D6EFD;
  transform: translateY(-1px);
}

.btn-hero-secondary {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.85);
  padding: 12px 28px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, transform 0.1s;
}

.btn-hero-secondary:hover {
  background: rgba(255,255,255,0.15);
  text-decoration: none;
  color: #fff;
  transform: translateY(-1px);
}

/* ===== CONTENT SECTIONS ===== */
.content-section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: #0D6EFD;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #0D6EFD;
}

.subsection-title {
  font-size: 18px;
  font-weight: 600;
  color: #0D6EFD;
  margin: 28px 0 14px;
}

.content-section p {
  font-size: 15px;
  color: #343a40;
  line-height: 1.8;
  margin-bottom: 16px;
}

/* ===== FIGURES ===== */
.figure-container {
  margin: 28px 0;
  text-align: center;
}

.figure-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  display: block;
  margin: 0 auto;
  object-fit: cover;
}

/* Universal image constraint — all content images must stay within content width */
.img-container {
  margin: 28px 0;
  text-align: center;
  width: 100%;
  overflow: hidden;
}

.content-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  display: block;
  margin: 0 auto;
  object-fit: cover;
}

.img-caption {
  font-size: 13px;
  color: #6c757d;
  margin-top: 10px;
  font-style: italic;
  text-align: center;
}

.figure-caption {
  font-size: 13px;
  color: #6c757d;
  margin-top: 10px;
  font-style: italic;
  text-align: center;
}

/* ===== TABLES ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 20px 0;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
  border-radius: 8px;
  overflow: hidden;
}

.data-table thead tr {
  background: #0D6EFD;
  color: #fff;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid #e9ecef;
  color: #343a40;
  vertical-align: top;
  line-height: 1.6;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: #f8f9ff; }
.data-table tbody tr:hover { background: #eef2ff; }

/* ===== CHAPTER GRID ===== */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.chapter-card {
  background: #0D6EFD;
  border-radius: 10px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  min-height: 130px;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}

.chapter-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13,110,253,0.35);
  text-decoration: none;
  color: #fff;
}

.card-icon {
  width: 28px;
  height: 28px;
  color: rgba(255,255,255,0.9);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
}

.card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #198754;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== INFO BOXES ===== */
.info-box {
  background: #f0f4ff;
  border-left: 4px solid #0D6EFD;
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: #343a40;
}

.warning-box {
  background: #fff8e1;
  border-left: 4px solid #ffc107;
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: #343a40;
}

.success-box {
  background: #f0fff4;
  border-left: 4px solid #198754;
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: #343a40;
}

/* ===== LISTS ===== */
.bullet-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.bullet-list li {
  padding: 4px 0 4px 20px;
  position: relative;
  font-size: 14px;
  color: #343a40;
  line-height: 1.6;
}

.bullet-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #0D6EFD;
  font-weight: bold;
}

.numbered-list {
  padding-left: 20px;
  margin: 12px 0;
}

.numbered-list li {
  padding: 4px 0;
  font-size: 14px;
  color: #343a40;
  line-height: 1.6;
}

/* ===== PAGE HEADER (chapter pages) ===== */
.page-header {
  background: linear-gradient(135deg, #1565C0 0%, #1E88E5 40%, #42A5F5 75%, #64B5F6 100%);
  border-radius: 16px;
  padding: 40px 50px;
  margin-bottom: 40px;
  color: #fff;
}

.page-header .chapter-num {
  display: inline-block;
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.45);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
  text-transform: uppercase;
}

.page-header h1 {
  font-size: 36px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 14px;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.page-header p {
  font-size: 15px;
  color: rgba(255,255,255,0.9);
  line-height: 1.6;
  margin: 0;
  max-width: 700px;
}

/* ===== FOOTER ===== */
.page-footer {
  margin-top: 60px;
  padding: 24px 0;
  border-top: 1px solid #e9ecef;
  text-align: center;
  font-size: 13px;
  color: #6c757d;
}

/* ===== SCENARIO CARDS ===== */
.scenario-card {
  border: 1px solid #e9ecef;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 40px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.scenario-header {
  background: linear-gradient(135deg, #0D6EFD, #2979d8);
  padding: 20px 24px;
  color: #fff;
}

.scenario-header h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.scenario-header .scenario-tag {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

.scenario-body {
  padding: 24px;
}

.scenario-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 16px;
  object-fit: cover;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.metric-item {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.metric-value {
  font-size: 16px;
  font-weight: 700;
  color: #0D6EFD;
  display: block;
}

.metric-label {
  font-size: 11px;
  color: #6c757d;
  margin-top: 2px;
}

/* ===== CALCULATOR ===== */
.calc-container {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 32px;
  border: 1px solid #e9ecef;
}

.calc-title {
  font-size: 17px;
  font-weight: 700;
  color: #0D6EFD;
  margin-bottom: 6px;
}

.calc-desc {
  font-size: 13px;
  color: #6c757d;
  margin-bottom: 20px;
}

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

.calc-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #343a40;
  margin-bottom: 6px;
}

.calc-field input, .calc-field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 14px;
  color: #343a40;
  background: #fff;
  transition: border-color 0.15s;
}

.calc-field input:focus, .calc-field select:focus {
  outline: none;
  border-color: #0D6EFD;
  box-shadow: 0 0 0 3px rgba(13,110,253,0.1);
}

.calc-result {
  background: linear-gradient(135deg, #0D6EFD, #2979d8);
  border-radius: 10px;
  padding: 20px 24px;
  color: #fff;
  margin-top: 16px;
}

.calc-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.result-item {
  text-align: center;
}

.result-value {
  font-size: 24px;
  font-weight: 700;
  color: #4fc3f7;
  display: block;
}

.result-label {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
}

.calc-btn {
  background: #0D6EFD;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.calc-btn:hover { background: #0b5ed7; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { width: 240px; }
  .main-content { margin-left: 240px; padding: 0 24px; }
  .chapter-grid { grid-template-columns: repeat(2, 1fr); }
  .calc-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 0 16px; }
  .chapter-grid { grid-template-columns: 1fr; }
}
