:root {
  --teal: #1F5E5B;
  --teal-dark: #174845;
  --charcoal: #2B2E30;
  --muted: #5d6366;
  --cream: #F7F3EC;
  --mist: #D6E6E2;
  --mist-soft: #EAF2EF;
  --line: #E4DED3;
  --white: #FFFFFF;
  --warn: #F9EEDA;
  --sidebar: 250px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 20px); }

body {
  margin: 0;
  background: var(--cream);
  color: var(--charcoal);
  font: 16px/1.65 "DM Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

a { color: var(--teal); text-underline-offset: 2px; }
a:hover { color: var(--teal-dark); }

.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--teal); color: var(--white); padding: 8px 12px; border-radius: 6px; z-index: 50;
}
.skip:focus { left: 16px; }

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(247, 243, 236, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-row {
  max-width: 1240px; margin: 0 auto; min-height: 64px;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--charcoal); flex-shrink: 0; }
.brand img { height: 30px; width: auto; display: block; }
.brand span { font-weight: 500; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line); }

.header-links { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.header-links a, .header-links button, .button {
  font: inherit; font-size: 14px; font-weight: 500; white-space: nowrap;
  color: var(--teal); background: none; border: 1px solid transparent;
  padding: 8px 14px; border-radius: 8px; text-decoration: none; cursor: pointer;
}
.header-links a:hover, .header-links button:hover { background: var(--mist-soft); }
.header-links .primary, .button { background: var(--teal); color: var(--white); }
.header-links .primary:hover, .button:hover { background: var(--teal-dark); color: var(--white); }
.menu-toggle { display: none; }

/* ---------- Search ---------- */

.search { position: relative; flex: 1 1 auto; max-width: 460px; }
.search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.search input {
  width: 100%; font: inherit; font-size: 15px; color: var(--charcoal);
  background: var(--white); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 40px 9px 38px; outline: none; -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: #8a8f91; }
.search input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(31, 94, 91, 0.15); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-key {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 12px/1 ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; background: var(--cream);
}
.search input:focus ~ .search-key { display: none; }

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(43, 46, 48, 0.14);
  max-height: min(70vh, 520px); overflow-y: auto; padding: 6px;
}
.search-results[hidden] { display: none; }
.result { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--charcoal); }
.result + .result { margin-top: 2px; }
.result.active, .result:hover { background: var(--mist-soft); color: var(--charcoal); }
.r-where { display: block; font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.r-title { display: block; font-weight: 700; color: var(--teal-dark); line-height: 1.35; margin: 1px 0 2px; }
.r-snip { display: block; font-size: 14px; color: var(--muted); line-height: 1.5; }
.result mark { background: #F3E2B8; color: inherit; border-radius: 3px; padding: 0 1px; }
.search-empty { margin: 0; padding: 14px; font-size: 14px; color: var(--muted); }

/* ---------- Home ---------- */

.home main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px 64px; flex: 1; }
.hub-hero { text-align: center; padding: 64px 0 44px; }
.hub-hero h1 { font-size: 44px; line-height: 1.1; margin: 0 0 10px; letter-spacing: -0.015em; }
.hub-hero .lead { font-size: 19px; color: var(--muted); margin: 0 auto 28px; }
.search-hero { margin: 0 auto; max-width: 640px; text-align: left; }
.search-hero input { font-size: 17px; padding: 15px 18px 15px 48px; border-radius: 14px; box-shadow: 0 6px 24px rgba(43, 46, 48, 0.07); }
.search-hero svg { left: 17px; width: 21px; height: 21px; }

.hub-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.hub-card {
  display: block; background: var(--white); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; text-decoration: none; color: var(--charcoal);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.hub-card:hover { border-color: var(--teal); box-shadow: 0 10px 28px rgba(31, 94, 91, 0.12); transform: translateY(-2px); color: var(--charcoal); }
.hub-card svg {
  width: 40px; height: 40px; padding: 8px; border-radius: 10px; background: var(--mist-soft);
  fill: none; stroke: var(--teal); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.hub-card h2 { font-size: 20px; margin: 14px 0 6px; }
.hub-card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }

.popular { margin-top: 44px; }
.popular h2, .contact-strip h2 { font-size: 20px; margin: 0 0 12px; }
.popular ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 24px; max-width: none; }
.popular li { margin: 0; }
.popular a { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 500; }
.popular a::after { content: " \2192"; color: var(--muted); }

.contact-strip {
  margin-top: 44px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: var(--teal); color: var(--cream); border-radius: 16px; padding: 24px 28px;
}
.contact-strip h2 { color: var(--white); margin-bottom: 4px; }
.contact-strip p { margin: 0; color: var(--mist); }
.contact-strip .button { background: var(--cream); color: var(--teal-dark); font-size: 15px; padding: 10px 18px; }
.contact-strip .button:hover { background: var(--white); color: var(--teal-dark); }

/* ---------- Topic pages ---------- */

.layout {
  width: 100%; max-width: 1240px; margin: 0 auto; flex: 1;
  display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); gap: 56px;
  padding: 32px 24px 72px;
}

.toc {
  position: sticky; top: calc(var(--header-h) + 24px); align-self: start;
  max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto;
  font-size: 15px;
}
.toc-label { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc > ol > li { margin: 2px 0; }
.toc > ol > li > a {
  display: block; padding: 7px 12px; border-radius: 8px;
  color: var(--charcoal); text-decoration: none; font-weight: 500;
}
.toc > ol > li > a:hover { background: var(--mist-soft); }
.toc .current > a { background: var(--teal); color: var(--white); }
.toc .current > a:hover { background: var(--teal-dark); }
.toc .sub { margin: 6px 0 10px 12px; border-left: 2px solid var(--line); }
.toc .sub a {
  display: block; padding: 5px 0 5px 14px; margin-left: -2px; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.toc .sub a:hover { color: var(--charcoal); }
.toc .sub a.active { color: var(--teal); border-left-color: var(--teal); font-weight: 600; }
.toc-contact { display: inline-block; margin: 16px 12px 0; font-size: 14px; font-weight: 500; }

main { min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { text-decoration: none; }
.print-link {
  margin-left: auto; font: inherit; font-size: 13px; color: var(--muted); background: none;
  border: 1px solid var(--line); border-radius: 7px; padding: 4px 10px; cursor: pointer;
}
.print-link:hover { color: var(--teal); border-color: var(--teal); }

.layout main h1 { font-size: 38px; line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.01em; }
.layout main .lead { font-size: 18px; color: var(--muted); margin: 0 0 8px; padding-bottom: 24px; border-bottom: 1px solid var(--line); max-width: 720px; }
.layout main h2 { font-size: 26px; line-height: 1.25; margin: 40px 0 12px; letter-spacing: -0.005em; }
.layout main h3 { font-size: 19px; margin: 28px 0 8px; }
p { margin: 0 0 14px; max-width: 72ch; }
ul, ol { margin: 0 0 16px; padding-left: 24px; max-width: 72ch; }
li { margin: 6px 0; }
li > ol, li > ul { margin: 6px 0 4px; }
kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85em;
  background: var(--white); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px;
}

.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 40px; margin: 14px 0; }
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 1px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--teal); color: var(--white);
  font-size: 14px; font-weight: 700; line-height: 26px; text-align: center;
}
.steps ol { list-style: lower-alpha; }

.callout {
  border-left: 4px solid var(--teal); background: var(--mist-soft);
  padding: 14px 18px; border-radius: 0 10px 10px 0; margin: 16px 0 20px; max-width: 72ch;
}
.callout.warn { border-left-color: #C9932E; background: var(--warn); }
.callout > :last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 16px 0 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 12px 16px; border-bottom: 1px solid var(--line); }
th { background: var(--mist-soft); font-size: 13px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--teal-dark); }
tr:last-child td { border-bottom: none; }

.command-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 20px 0 8px; }
.command, .problem { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.layout main .command h3, .layout main .problem h3 { margin: 0 0 6px; font-size: 18px; }
.command p:last-child, .problem p:last-child { margin-bottom: 0; }
.command .example { font-style: italic; color: var(--muted); font-size: 15px; border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 10px; }
.problem { margin: 12px 0; max-width: 820px; }
.problem h3 { color: var(--teal-dark); }

.flow { list-style: none; padding: 0; margin: 18px 0 8px; display: flex; flex-wrap: wrap; gap: 10px; max-width: none; counter-reset: flow; }
.flow li {
  counter-increment: flow; position: relative; margin: 0;
  flex: 1 1 150px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 12px 44px;
}
.flow li::before {
  content: counter(flow); position: absolute; left: 12px; top: 13px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--mist); color: var(--teal-dark);
  font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
}
.flow strong { display: block; line-height: 1.3; }
.flow span { display: block; font-size: 13px; color: var(--muted); line-height: 1.4; margin-top: 2px; }

.faq details { background: var(--white); border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; max-width: 820px; }
.faq summary {
  cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none;
  display: flex; justify-content: space-between; gap: 16px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--teal); font-weight: 700; font-size: 20px; line-height: 1; }
.faq details[open] summary::after { content: "\2013"; }
.faq details p { padding: 0 18px 4px; }

.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px rgba(31, 94, 91, 0.35); } 100% { box-shadow: 0 0 0 3px rgba(31, 94, 91, 0); } }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a {
  display: block; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--white);
  text-decoration: none; font-weight: 700; color: var(--teal-dark);
}
.pager a:hover { border-color: var(--teal); }
.pager span { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.pager .next { text-align: right; grid-column: 2; }

.site-footer { border-top: 1px solid var(--line); padding: 24px 16px; text-align: center; font-size: 14px; color: var(--muted); }
.site-footer p { margin: 4px auto; max-width: none; }
.site-footer .footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }

/* ---------- Phone and tablet ---------- */

@media (max-width: 900px) {
  .header-row { flex-wrap: wrap; gap: 8px 10px; padding: 10px 16px; min-height: 0; }
  .brand img { height: 26px; }
  .brand span { display: none; }
  .header-links { gap: 4px; }
  .header-links a, .header-links button { padding: 7px 10px; }
  .menu-toggle { display: inline-block; }
  .search-header { order: 3; flex-basis: 100%; max-width: none; }
  .search-key { display: none; }

  .layout { grid-template-columns: 1fr; gap: 0; padding: 20px 16px 56px; }
  .toc {
    display: none; position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 25;
    height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h));
    max-height: none; background: var(--cream); padding: 20px 16px 32px;
  }
  body.menu-open { overflow: hidden; }
  .toc.open { display: block; }

  .home main { padding: 0 16px 48px; }
  .hub-hero { padding: 40px 0 28px; }
  .hub-hero h1 { font-size: 34px; }
  .hub-hero .lead { font-size: 17px; }
  .hub-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .popular ul { grid-template-columns: 1fr; }
  .contact-strip { flex-direction: column; align-items: flex-start; }

  .layout main h1 { font-size: 30px; }
  .layout main h2 { font-size: 23px; }
  .command-grid { grid-template-columns: 1fr; }
  .print-link { display: none; }
}

@media (max-width: 560px) {
  .hub-grid { grid-template-columns: 1fr; }
  .hub-card { padding: 18px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}

/* ---------- Print / Save as PDF ---------- */

@media print {
  @page { margin: 18mm 16mm; }
  body { background: var(--white); font-size: 11pt; display: block; }
  .site-header, .toc, .skip, .pager, .site-footer, .print-link, .search { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .crumbs { display: none; }
  .layout main h2 { break-after: avoid; margin-top: 24px; }
  .command, .problem, .callout, tr, .faq details, .flow li { break-inside: avoid; }
  .faq summary::after { content: ""; }
  a { color: var(--charcoal); text-decoration: none; }
  .table-wrap { overflow: visible; }
}
