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

:root {
  --accent:    #ec3045;
  --accent-h:  #c9263b;
  --green:     #1a7f3c;
  --dark:      #1A202C;
  --text:      #2D3748;
  --muted:     #718096;
  --border:    #E2E8F0;
  --bg:        #F7FAFC;
  --white:     #ffffff;
  --max-w:     1290px;
  --narrow:    820px;
  --radius:    6px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --transition: .18s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-h); text-decoration: underline; }

h1,h2,h3,h4,h5,h6 {
  font-family: system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-weight: 700;
  line-height: 1.35;
  color: var(--dark);
  margin-top: 2rem;
  margin-bottom: .6rem;
}
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); margin-top: 0; }
h2 { font-size: clamp(1.25rem, 3vw, 1.55rem); padding-bottom: .4rem; border-bottom: 2px solid var(--border); }
h3 { font-size: 1.15rem; color: var(--text); }
p  { margin-bottom: 1rem; }
ul, ol { margin: .5rem 0 1rem 1.4rem; }
li  { margin-bottom: .3rem; }

/* ===== LAYOUT ===== */
.site-wrap { display: flex; flex-direction: column; min-height: 100vh; }
.container  { max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }

/* ===== HEADER ===== */
#masthead {
  background: var(--accent);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem;
}
.site-branding a {
  display: flex; align-items: center; gap: .5rem;
  color: white; font-weight: 700; font-size: 1.15rem;
  font-family: system-ui, sans-serif; text-decoration: none;
}
.site-branding a:hover { text-decoration: none; opacity: .9; }
.logo-icon {
  width: 32px; height: 32px; background: rgba(255,255,255,.2);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: white; font-weight: 900;
}

/* NAV */
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
.main-nav a {
  color: rgba(255,255,255,.9); padding: .5rem .75rem;
  border-radius: var(--radius); font-size: .95rem;
  font-family: system-ui, sans-serif; transition: background var(--transition);
}
.main-nav a:hover, .main-nav a.active { background: rgba(255,255,255,.15); color: white; text-decoration: none; }

/* Mobile toggle */
#nav-toggle {
  display: none; background: none; border: none; cursor: pointer; padding: .4rem;
  color: white;
}
#nav-toggle svg { display: block; }

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, var(--dark) 0%, #2D3748 100%);
  color: white; padding: 3.5rem 0 2.5rem;
}
.hero .container { max-width: var(--narrow); }
.hero-tag {
  display: inline-block; background: var(--accent); color: white;
  font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: .25rem .7rem; border-radius: 3px; margin-bottom: 1rem;
  font-family: system-ui, sans-serif;
}
.hero h1 { color: white; font-size: clamp(1.7rem, 4.5vw, 2.4rem); margin-top: .5rem; line-height: 1.25; }
.hero-lead { font-size: 1.05rem; color: rgba(255,255,255,.8); margin-top: .75rem; margin-bottom: 0; }
.hero-meta {
  display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 1.25rem;
  font-size: .85rem; color: rgba(255,255,255,.6); font-family: system-ui, sans-serif;
}
.hero-meta span::before { content: '📅 '; }
.hero-meta span:last-child::before { content: '⏱ '; }

/* ===== STATS BAR ===== */
.stats-bar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}
.stats-inner {
  display: flex; gap: 0; flex-wrap: wrap;
  max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem;
  divide-x: 1px solid var(--border);
}
.stat-item {
  flex: 1; min-width: 160px; text-align: center; padding: .5rem 1rem;
  border-right: 1px solid var(--border); font-family: system-ui, sans-serif;
}
.stat-item:last-child { border-right: none; }
.stat-num { font-size: 1.4rem; font-weight: 700; color: var(--accent); display: block; }
.stat-label { font-size: .8rem; color: var(--muted); }

/* ===== CONTENT LAYOUT ===== */
.content-area { padding: 3rem 0 4rem; }
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 2.5rem;
  max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem;
  align-items: start;
}

/* ===== ARTICLE ===== */
.article-body { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem; }
.article-body h2 { scroll-margin-top: 80px; }
.article-body h3 { scroll-margin-top: 80px; }

/* Steps */
.art-steps { list-style: none; margin: 1rem 0 1.5rem; padding: 0; counter-reset: steps; }
.art-steps li {
  counter-increment: steps;
  display: flex; gap: 1rem; align-items: flex-start;
  padding: .85rem 1rem; margin-bottom: .5rem;
  background: var(--bg); border-radius: var(--radius); border-left: 3px solid var(--green);
}
.art-steps li::before {
  content: counter(steps);
  min-width: 28px; height: 28px; border-radius: 50%;
  background: var(--green); color: white; font-size: .85rem;
  font-family: system-ui, sans-serif; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* Checklist */
.art-checklist { list-style: none; margin: 1rem 0 1.5rem; padding: 0; }
.art-checklist li {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.art-checklist li:last-child { border-bottom: none; }
.art-checklist li::before {
  content: '✓'; color: var(--green); font-weight: 700;
  font-size: 1.1rem; flex-shrink: 0; margin-top: .05rem;
}

/* Info boxes */
.art-info {
  background: #EBF8FF; border-left: 4px solid #3182CE;
  padding: 1rem 1.25rem; border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.25rem 0;
}
.art-info.warn { background: #FFFBEB; border-left-color: #D69E2E; }
.art-info p:last-child { margin-bottom: 0; }

/* Table */
.tbl-wrap { overflow-x: auto; margin: 1.25rem 0 1.5rem; border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; font-family: system-ui, sans-serif; }
.data-table th {
  background: var(--dark); color: white; padding: .75rem 1rem;
  text-align: left; font-weight: 600; white-space: nowrap;
}
.data-table td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:nth-child(even) td { background: var(--bg); }
.data-table tr:hover td { background: #EDF2F7; }

/* ===== SIDEBAR TOC ===== */
.sidebar { position: sticky; top: 80px; }
.toc-box {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.5rem; border-top: 3px solid var(--accent);
}
.toc-box h3 { margin-top: 0; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: none; }
.toc-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.toc-list li { border-bottom: 1px solid var(--border); }
.toc-list li:last-child { border-bottom: none; }
.toc-list a {
  display: block; padding: .5rem .25rem; font-size: .88rem;
  color: var(--text); font-family: system-ui, sans-serif; line-height: 1.4;
  transition: color var(--transition), padding-left var(--transition);
}
.toc-list a:hover, .toc-list a.toc-active {
  color: var(--accent); padding-left: .5rem; text-decoration: none;
}
.toc-list .toc-h3 a { padding-left: .75rem; font-size: .83rem; color: var(--muted); }
.toc-list .toc-h3 a:hover { color: var(--accent); padding-left: 1rem; }

/* ===== FAQ ===== */
.faq-list { margin: 1rem 0; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:first-child { border-top: 1px solid var(--border); }
.faq-btn {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 1.1rem .25rem; font-size: 1rem; font-weight: 600;
  font-family: system-ui, sans-serif; color: var(--dark);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  transition: color var(--transition);
}
.faq-btn:hover { color: var(--accent); }
.faq-icon { font-size: 1.2rem; line-height: 1; flex-shrink: 0; transition: transform var(--transition); }
.faq-item.open .faq-icon { transform: rotate(45deg); }
.faq-answer { display: none; padding: 0 .25rem 1rem; color: var(--text); }
.faq-answer p { margin-bottom: .5rem; }
.faq-item.open .faq-answer { display: block; }

/* ===== BACK TO TOP ===== */
#back-top {
  position: fixed; bottom: 2rem; right: 1.5rem; z-index: 90;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: white; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(236,48,69,.4);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}
#back-top.visible { opacity: 1; transform: none; pointer-events: auto; }
#back-top:hover { background: var(--accent-h); }
#back-top svg { display: block; }

/* ===== FOOTER ===== */
#colophon {
  background: var(--dark); color: rgba(255,255,255,.7); margin-top: auto;
}
.footer-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 2rem 1.5rem;
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
}
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.footer-nav a {
  color: rgba(255,255,255,.65); font-size: .88rem;
  font-family: system-ui, sans-serif; padding: .3rem .6rem;
  border-radius: 3px; transition: color var(--transition);
}
.footer-nav a:hover { color: white; text-decoration: none; }
.footer-copy { font-size: .85rem; font-family: system-ui, sans-serif; }

/* ===== PAGE CONTENT (sub-pages) ===== */
.page-content { max-width: var(--narrow); margin: 0 auto; padding: 3rem 1.5rem; }
.page-content .article-body { padding: 2rem; }

/* ===== 404 ===== */
.not-found { text-align: center; padding: 5rem 1.5rem; }
.not-found h1 { font-size: 4rem; color: var(--accent); }

/* ===== MEDIA QUERIES ===== */
@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .toc-box { display: none; }
}

@media (max-width: 768px) {
  .hero { padding: 2.5rem 0 2rem; }
  .main-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--dark); padding: 1rem; }
  .main-nav.open { display: block; }
  .main-nav ul { flex-direction: column; gap: .25rem; }
  .main-nav a { display: block; }
  #nav-toggle { display: flex; align-items: center; }
  .stats-inner { gap: 0; }
  .stat-item { min-width: 50%; border-top: 1px solid var(--border); }
  .stat-item:nth-child(odd) { border-right: 1px solid var(--border); }
  .article-body { padding: 1.5rem; }
  .data-table { font-size: .82rem; }
  .data-table th, .data-table td { padding: .5rem .65rem; }
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .hero h1 { font-size: 1.5rem; }
  .art-steps li { flex-direction: column; }
  .stat-item { min-width: 100%; border-right: none; }
  .footer-inner { flex-direction: column; text-align: center; }
}
