/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0D6EFD;
  --secondary: #198754;
  --bg-white: #FFFFFF;
  --text-dark: #212529;
  --text-gray: #6C757D;
  --bg-light: #F8F9FA;
  --border: #DEE2E6;
  --sidebar-width: 280px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-dark);
  background: var(--bg-white);
}

/* ===== LEFT SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.sidebar-logo {
  padding: 12px 16px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  text-align: center;
}

.sidebar-logo img {
  max-width: 180px;
  height: auto;
}

.sidebar-logo a.site-url {
  display: block;
  font-size: 0.75rem;
  color: var(--primary);
  text-decoration: none;
  margin-top: 4px;
}

.sidebar-logo a.site-url:hover { text-decoration: underline; }

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  height: 80px; /* 5rem */
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-dark);
  font-size: 0.875rem;
  border-left: 4px solid transparent;
  transition: background 0.15s;
  position: relative;
  gap: 16px;
}

.sidebar-nav a:hover {
  background: var(--bg-light);
  cursor: pointer;
}

.sidebar-nav a.active {
  border-left-color: var(--primary);
  background: var(--bg-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-nav a svg {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  stroke: var(--primary);
}

.sidebar-nav a span.nav-text {
  flex: 1;
  line-height: 1.3;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-white);
}

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

/* ===== HERO SECTION ===== */
.hero {
  background: linear-gradient(135deg, #0D6EFD 0%, #5DADE2 100%);
  border-radius: 16px;
  padding: 60px 50px;
  margin-bottom: 40px;
  max-width: 1000px;
}

.hero .version-tag {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.875rem;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.hero h1 {
  color: #fff !important;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero .subtitle {
  color: rgba(255,255,255,0.9);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 32px;
  max-width: 700px;
}

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

.btn-primary-hero {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 28px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary-hero:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-secondary-hero {
  background: transparent;
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 28px;
  border-radius: 6px;
  text-decoration: none;
  border: 2px solid rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary-hero:hover { background: rgba(255,255,255,0.15); }

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

.chapter-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 15px;
  height: 130px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: var(--text-dark);
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.075);
  transition: box-shadow 0.2s, transform 0.2s;
  overflow: hidden;
}

.chapter-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.chapter-card .card-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter-card .card-icon svg {
  width: 40px;
  height: 40px;
  stroke: var(--primary);
}

.chapter-card .card-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chapter-card .card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 2.5rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
h2 { font-size: 2rem; font-weight: 700; color: var(--primary); margin: 40px 0 16px; }
h3 { font-size: 1.5rem; font-weight: 600; color: var(--primary); margin: 32px 0 12px; }
h4 { font-size: 1.25rem; font-weight: 600; color: var(--primary); margin: 24px 0 10px; }

p { margin-bottom: 1.5rem; line-height: 1.6; }

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-gray);
  margin-bottom: 16px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0 32px;
}

/* ===== IMAGES ===== */
.figure-block {
  margin: 24px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #E7F1FF;
  padding: 16px;
}

.figure-block img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.figure-caption {
  font-size: 0.875rem;
  color: var(--text-gray);
  text-align: center;
  margin-top: 10px;
  font-style: italic;
}

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
  font-size: 0.875rem;
}

thead th {
  background: var(--bg-light);
  color: var(--text-dark);
  font-weight: 700;
  font-size: 0.875rem;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--bg-light); }

/* ===== LISTS ===== */
ul.bullet-list, ol.numbered-list {
  margin: 0 0 1.5rem 0;
  padding-left: 1.5rem;
  line-height: 1.6;
}

ul.bullet-list li, ol.numbered-list li {
  margin-bottom: 8px;
  text-align: left;
}

/* ===== INFO BOXES ===== */
.info-box {
  background: #E7F1FF;
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
}

.warning-box {
  background: #FFF3CD;
  border-left: 4px solid #FFC107;
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
}

.success-box {
  background: #D1E7DD;
  border-left: 4px solid var(--secondary);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
}

/* ===== SCENARIO CARDS ===== */
.scenario-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 24px 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.scenario-card .scenario-header {
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  font-size: 1.1rem;
  font-weight: 600;
}

.scenario-card .scenario-body {
  padding: 20px;
}

.scenario-card .scenario-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric-item {
  background: var(--bg-light);
  border-radius: 6px;
  padding: 10px 14px;
  text-align: center;
}

.metric-item .metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.metric-item .metric-label {
  font-size: 0.75rem;
  color: var(--text-gray);
  margin-top: 2px;
}

/* ===== CALCULATOR ===== */
.calc-container {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin: 24px 0;
}

.calc-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
}

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

.calc-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.calc-field input[type="number"],
.calc-field input[type="range"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
  transition: border-color 0.15s;
}

.calc-field input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

.calc-field .field-unit {
  font-size: 0.75rem;
  color: var(--text-gray);
  margin-top: 4px;
}

.calc-btn {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 28px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.calc-btn:hover {
  background: #0b5ed7;
  transform: translateY(-1px);
}

.calc-results {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.result-item {
  background: #E7F1FF;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.result-item .result-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.result-item .result-label {
  font-size: 0.8rem;
  color: var(--text-gray);
  margin-top: 4px;
}

.pass-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
}

.pass-badge.pass { background: #D1E7DD; color: #0f5132; }
.pass-badge.fail { background: #F8D7DA; color: #842029; }

/* ===== FOOTER ===== */
.page-footer {
  margin-top: 60px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-gray);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .content-wrapper { padding: 20px; }
  .chapter-grid { grid-template-columns: 1fr 1fr; }
  .calc-grid { grid-template-columns: 1fr; }
}
