/* ── Theme ── */
:root {
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --brand-muted: #6366f1;
  --surface: #ffffff;
  --page-bg: #f4f6fa;
  --text: #334155;
  --heading: #0f172a;
  --border: #e2e8f0;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
  --header-h: 3.75rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html,
body,
.font-display,
.prose,
.prose :where(h1, h2, h3, h4, h5, h6) {
  font-family: var(--font);
}

body {
  background: var(--page-bg);
  color: var(--text);
}

/* Subtle dot pattern on doc pages */
.doc-layout {
  background-color: var(--page-bg);
  background-image: radial-gradient(circle at 1px 1px, rgb(148 163 184 / 0.12) 1px, transparent 0);
  background-size: 24px 24px;
}

/* ── Header ── */
.site-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.logo-mark {
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.nav-pill {
  border-radius: 0.5rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-pill--active {
  background: var(--brand-soft);
  color: #4338ca;
}

.nav-pill--ghost:hover {
  background: #f1f5f9;
  color: #4338ca;
}

.search-input {
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.search-input:focus {
  border-color: #a5b4fc;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  outline: none;
}

/* ── Sidebar ── */
#doc-sidebar {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.03);
}

#doc-sidebar::-webkit-scrollbar {
  width: 5px;
}

#doc-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.sidebar-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 0 0.75rem;
  margin-bottom: 0.35rem;
}

.nav-part {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.1rem 0.5rem;
  border-radius: 0.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #475569;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-part:hover {
  background: #fff;
  border-color: var(--border);
  color: var(--brand);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.nav-part.is-current {
  background: var(--brand-soft);
  border-color: #c7d2fe;
  color: #3730a3;
  font-weight: 600;
}

.nav-part-num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  background: #f1f5f9;
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
}

.nav-part.is-current .nav-part-num {
  background: #4f46e5;
  color: #fff;
}

.toc-link {
  display: block;
  border-radius: 0.375rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: #64748b;
  transition: color 0.15s, background 0.15s;
}

.toc-link:hover {
  color: var(--brand);
  background: rgba(255, 255, 255, 0.8);
}

.toc-link.is-active {
  color: #4338ca;
  background: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #4f46e5;
  border-radius: 0 0.375rem 0.375rem 0;
}

.toc-link.toc-h3 {
  padding-left: 1.1rem;
  font-size: 0.75rem;
}

#doc-sidebar {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-h));
  min-height: 0;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.doc-toc-block {
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  padding: 0.75rem 0.75rem 1.25rem;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.9) 0%, transparent 100%);
}

@media (min-width: 1024px) {
  #doc-sidebar {
    position: sticky;
    top: var(--header-h);
    align-self: flex-start;
    max-height: calc(100vh - var(--header-h));
  }
}

@media (max-width: 1023px) {
  #doc-sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
  }

  #sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
}

#sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* ── Article card ── */
.doc-article-wrap {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1rem 2.5rem;
}

@media (min-width: 640px) {
  .doc-article-wrap {
    padding: 2rem 1.5rem 3rem;
  }
}

.doc-article-card {
  max-width: 52rem;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 1rem;
  box-shadow: var(--shadow-card);
  padding: 1.75rem 1.5rem;
}

@media (min-width: 640px) {
  .doc-article-card {
    padding: 2.25rem 2.5rem 2.75rem;
    border-radius: 1.25rem;
  }
}

.page-eyebrow {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-muted);
  background: var(--brand-soft);
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  margin-bottom: 1rem;
}

/* ── Prose ── */
#doc-content.prose {
  --tw-prose-body: var(--text);
  --tw-prose-headings: var(--heading);
  --tw-prose-links: var(--brand);
  --tw-prose-bold: var(--heading);
  --tw-prose-code: #4338ca;
  --tw-prose-pre-bg: #1e293b;
  max-width: none;
  font-size: 1.0625rem;
  line-height: 1.75;
}

#doc-content.prose :where(h1):not(:where([class~="not-prose"] *)) {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

#doc-content.prose :where(h2):not(:where([class~="not-prose"] *)) {
  scroll-margin-top: calc(var(--header-h) + 1rem);
  font-size: 1.375rem;
  font-weight: 650;
  margin-top: 2.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #f1f5f9;
}

#doc-content.prose :where(h3):not(:where([class~="not-prose"] *)) {
  scroll-margin-top: calc(var(--header-h) + 1rem);
  font-size: 1.125rem;
  color: #1e293b;
  margin-top: 1.75rem;
}

#doc-content.prose :where(a):not(:where([class~="not-prose"] *)) {
  font-weight: 500;
  text-decoration-color: #c7d2fe;
  text-underline-offset: 3px;
}

#doc-content.prose :where(a:hover):not(:where([class~="not-prose"] *)) {
  text-decoration-color: var(--brand);
}

#doc-content.prose :where(code):not(:where([class~="not-prose"] *)):not(pre code) {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 0.35rem;
  padding: 0.15rem 0.4rem;
  font-size: 0.875em;
}

#doc-content.prose :where(blockquote):not(:where([class~="not-prose"] *)) {
  border-left: 4px solid var(--brand-muted);
  background: linear-gradient(90deg, #f8fafc 0%, #fff 100%);
  border-radius: 0 0.75rem 0.75rem 0;
  padding: 1rem 1.25rem;
  font-style: normal;
  color: #475569;
}

#doc-content.prose :where(hr):not(:where([class~="not-prose"] *)) {
  border-color: #e2e8f0;
  margin: 2.5rem 0;
}

/* Tables in content */
.doc-table-wrap {
  margin: 1.5rem 0;
  overflow-x: auto;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.doc-table-wrap table {
  width: 100%;
  font-size: 0.875rem;
  border-collapse: collapse;
}

.doc-table-wrap thead {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.doc-table-wrap th {
  text-align: left;
  font-weight: 600;
  color: #334155;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}

.doc-table-wrap td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #475569;
}

.doc-table-wrap tbody tr:hover {
  background: #fafbff;
}

.doc-table-wrap tbody tr:last-child td {
  border-bottom: none;
}

/* Legacy not-prose table wrapper from build */
.not-prose.overflow-x-auto table {
  width: 100%;
}

/* Prev / next */
.pager-link {
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  padding: 1rem 1.25rem;
  background: #fafbfc;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.pager-link:hover {
  border-color: #c7d2fe;
  background: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.08);
}

.mermaid {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
  padding: 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: #fafbfc;
}

mark.search-hit,
#doc-content mark.search-hit {
  background: #fde68a;
  border-radius: 2px;
  padding: 0 2px;
}

/* ── Home page ── */
.home-hero {
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  border-bottom: 1px solid var(--border);
}

.home-hero-glow {
  background: radial-gradient(ellipse 90% 70% at 50% -30%, rgba(99, 102, 241, 0.12), transparent 55%);
}

.guide-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 2rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.guide-card:hover {
  transform: translateY(-2px);
  border-color: #c7d2fe;
  box-shadow: 0 12px 40px rgba(79, 70, 229, 0.1);
}

.guide-card--payroll:hover {
  border-color: #a7f3d0;
  box-shadow: 0 12px 40px rgba(16, 185, 129, 0.1);
}

.part-grid-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.625rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  color: #475569;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.part-grid-link:hover {
  background: #f8fafc;
  border-color: var(--border);
  color: #4338ca;
}

.part-grid-link .num {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  background: var(--brand-soft);
  color: #4338ca;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-demo {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-demo:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}