:root {
  /* shadcn/ui-inspired tokens */
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;

  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;

  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;

  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;

  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;

  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;

  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;

  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;

  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 221.2 83.2% 53.3%;

  --radius: 0.5rem;
}

/* CSS variables as colors: use via hsl(var(--token)) */
html {
  color-scheme: light;
}

/* Basic element smoothing */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Generic helpers similar to shadcn base */
.container {
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
  max-width: 72ch;
}

.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

.muted { color: hsl(var(--muted-foreground)); }
.border { border: 1px solid hsl(var(--border)); }
.accent { color: hsl(var(--primary)); }







:root{
  --primary:#371B76;
  --secondary:#20ABAD;
  --highlight:#F7E64B;
  --paper:#ffffff;
  --font-body:"Questrial", system-ui, sans-serif;
  --font-display:"Quattrocento", serif;
  --font-condensed:"Roboto Condensed", sans-serif;
}

/* Reset */
body,html{margin:0;padding:0;}
section{display:flex;align-items:flex-start;justify-content:center;min-height:100vh;padding:4rem 2rem;}

/* FRONT COVER */
.cover.front{
  position:relative;
  background: linear-gradient(140deg, var(--primary) 0%, var(--primary) 70%, var(--highlight) 100%);
  color:#fff;
  overflow:hidden;
}
.cover.front::before{
  content:"";
  position:absolute;inset:0;
  /* adds depth and smooths the light end */
  background: 
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.08), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0,0,0,0.10), transparent 50%);
  mix-blend-mode: overlay;
  z-index:0;
}
.cover.front .title,
.cover.front .subtitle,
.cover.front .meta {
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.cover-content{
  z-index:1;
  text-align:left;
  max-width:700px;
  padding:2rem 3rem;
}
.title{
  font-family:var(--font-display);
  font-size:clamp(2.4rem,4vw,4rem);
  line-height:1.1;
  margin:0 0 .75rem 0;
}
.title .kicker{
  display:block;
  font-family:var(--font-condensed);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.5px;
  color:var(--highlight);
  font-size:clamp(.95rem,1vw,1.1rem);
}
.subtitle{
  font-size:1.15rem;
  color:rgba(255,255,255,0.85);
  max-width:40ch;
  margin:0 0 1.5rem 0;
}
.meta p{
  margin:.25rem 0;
  font-size:.95rem;
  opacity:0.9;
}
.logo-slot{
  position:absolute;
  right:3rem; bottom:3rem;
  width:100px;
  height:auto;
  z-index:2;
}
.logo-slot img{width:100%;height:auto;filter:brightness(1.2);}

/* BACK COVER */
.cover.back{
  position:relative;
  background:linear-gradient(160deg, var(--paper) 0%, #f5f6f9 100%);
  color:var(--primary);
  padding:2rem 2rem;
  align-items:flex-start;
  justify-content:space-between;
  min-height:100vh;
  display:flex;
  flex-direction:column;
}
.back-content{
  max-width:700px;
  font-family:var(--font-body);
  margin:0 auto;
  flex:1;
  display:flex;
  flex-direction:column;
}
.back-content h3{
  font-family:var(--font-display);
  font-size:1.8rem;
  color:var(--primary);
  margin-bottom:1rem;
}
.back-content p{font-size:1.05rem;line-height:1.6;color:#2b2550;margin-bottom:1rem;}
.back-content ul{
  margin:1.5rem 0 2rem 0;
  padding-left:0;
  list-style:none;
}
.back-content li{
  margin:1rem 0;
  padding-left:1.5rem;
  position:relative;
  line-height:1.7;
  font-size:1.05rem;
  color:#2b2550;
}
.back-content li::before{
  content:"•";
  position:absolute;
  left:0;
  color:var(--primary);
  font-weight:600;
  font-size:1.2rem;
}
.back-content .footer-tagline{
  margin-top:1.5rem;
  margin-bottom:0;
}
.back-content hr{
  width:60%;
  border:none;
  border-top:1px solid #ddd;
  margin:2rem auto;
}
.cover-links{
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
}
.back-content a{
  display: inline-block;
  margin:0 auto 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--secondary);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-family: var(--font-condensed);
  font-weight: 600;
  transition: background .2s ease, transform .1s ease;
  text-align: center;
}
.back-content a:hover{
  background: color-mix(in oklab, var(--secondary), black 10%);
  transform: translateY(-1px);
}
.back-content a:active{
  transform: translateY(0);
}
.back-content a.pdf-download{
  display: inline-block;
  margin: 0.5rem auto 2rem;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  white-space: nowrap;
}
.back-content a.pdf-download:hover{
  background: var(--primary);
  color: white;
}
.cover.back .copyright{
  font-family:var(--font-body);
  font-size:.9rem;
  color:#6E6B86;
  margin-top:auto;
  padding-bottom:2rem;
  width:100%;
  max-width:700px;
  margin-left:auto;
  margin-right:auto;
  text-align:center;
}
.cover.back .copyright p{
  margin:0;
  line-height:1.6;
  font-family:var(--font-body);
}
.cover.back .copyright em{
  font-style:italic;
  font-family:var(--font-body);
}
.cover.back .copyright a{
  color:#6E6B86;
  text-decoration:none;
  font-family:var(--font-body);
}
.cover.back .copyright a:hover{
  text-decoration:underline;
}
.logo-slot-back{
  position:absolute;
  top:3rem;
  right:calc(50% - 350px - 30px);
  width:150px;
  height:auto;
}
.logo-slot-back img{
  width:100%;
  height:auto;
}
/* Hide logo if it would overlap with content (viewport narrower than 600px) */
@media (max-width: 600px) {
  .logo-slot-back{
    display:none;
  }
}
.footer-tagline{
  font-family:var(--font-condensed);
  font-size:.95rem;
  text-transform:uppercase;
  color:var(--secondary);
  letter-spacing:.5px;
}

/* TITLE PAGE */
.title-page{
  background:var(--paper);
  color:var(--primary);
  flex-direction:column;
  text-align:center;
  padding:2rem;
  font-family:var(--font-body);
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:100vh;
  position:relative;
  overflow:visible;
}
/* HTML version - combine title and content on one page */
.title-page.html-cover{
  justify-content:flex-start;
  padding-top:3rem;
  min-height:auto;
}
.title-page.html-cover .back-content{
  max-width:700px;
  margin:3rem auto 0;
  width:100%;
  text-align:left;
}
.title-page.html-cover .copyright{
  margin-top:3rem;
  padding-top:2rem;
  max-width:700px;
  margin-left:auto;
  margin-right:auto;
  width:100%;
}
.logo-slot-title{
  width:200px;
  height:auto;
  margin:0 auto 1.5rem;
  position:relative;
  z-index:1;
  flex-shrink:0;
}
.logo-slot-title img{
  width:100%;
  height:auto;
}
.title-page-content{
  max-width:600px;
  margin:0 auto;
  width:100%;
  flex-shrink:0;
}
.title-page-content h1{
  font-family:var(--font-display);
  font-size:2.4rem;
  margin:0 0 1.5rem 0;
  color:var(--primary);
  font-weight:700;
  line-height:1.2;
}
.title-page-content h1 br{
  display:block;
}
.title-page-content p{
  font-size:1.15rem;
  margin:0;
  color:#3b3850;
  font-style:italic;
  line-height:1.7;
}
.scroll-indicator{
  position:absolute;
  bottom:2rem;
  left:50%;
  transform:translateX(-50%);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:0.5rem;
  color:var(--primary);
  opacity:0.7;
  animation:scrollBounce 2s ease-in-out infinite;
  z-index:10;
}
.scroll-indicator svg{
  width:24px;
  height:24px;
}
.scroll-indicator span{
  font-size:0.85rem;
  font-family:var(--font-condensed);
  font-weight:500;
  letter-spacing:0.5px;
  text-transform:uppercase;
}
@keyframes scrollBounce{
  0%,100%{
    transform:translateX(-50%) translateY(0);
  }
  50%{
    transform:translateX(-50%) translateY(10px);
  }
}
.title-page hr{
  width:60%;
  border:none;
  border-top:1px solid #ddd;
  margin:2rem auto;
}
.title-page > a{
  display: inline-block;
  margin:2rem auto;
  padding: 0.75rem 1.5rem;
  background: var(--secondary);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-family: var(--font-condensed);
  font-weight: 600;
  transition: background .2s ease, transform .1s ease;
}
.title-page > a:hover{
  background: color-mix(in oklab, var(--secondary), black 10%);
  transform: translateY(-1px);
}
.title-page > a:active{
  transform: translateY(0);
}
.title-page .copyright{
  font-size:.9rem;
  color:#6E6B86;
  margin-top:auto;
  padding-bottom:2rem;
  width:100%;
  text-align:center;
}
.title-page .copyright p{
  margin:0;
  line-height:1.6;
}
.title-page .copyright a{
  color:#6E6B86;
  text-decoration:none;
}
.title-page .copyright a:hover{
  text-decoration:underline;
}

.logo-slot-title{
  margin-bottom: 3rem;
  width: 200px;
  height: auto;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  z-index: 1;
}
.logo-slot-title img{
  width: 100%;
  height: auto;
}

.title-page a{
  display: inline-block;
  margin-top: 2rem;
  padding: 0.75rem 1.5rem;
  background: var(--secondary);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-family: var(--font-condensed);
  font-weight: 600;
  transition: background .2s ease, transform .1s ease;
}

.title-page a:hover{
  background: color-mix(in oklab, var(--secondary), black 10%);
  transform: translateY(-1px);
}

.title-page a:active{
  transform: translateY(0);
}

/* COVER PAGE: Title + About This Guide */
.cover.title-about {
  background: var(--paper);
  color: var(--primary);
  flex-direction: column;
  padding: 4rem 3rem;
  max-width: 800px;
  margin: 0 auto;
}

.cover-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid #e5e7eb;
}

.logo-slot-header {
  margin: 0 auto 2rem;
  width: 200px;
  height: auto;
}

.logo-slot-header img {
  width: 100%;
  height: auto;
}

.cover-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  margin: 0 0 0.75rem 0;
  color: var(--primary);
  line-height: 1.2;
}

.cover-byline {
  font-size: 1.25rem;
  margin: 0.5rem 0;
  color: #3b3850;
}

.cover-pub-info {
  font-size: 1rem;
  color: #6b7280;
  margin: 0.5rem 0 0 0;
}

.cover-about {
  max-width: 100%;
  font-family: var(--font-body);
  line-height: 1.7;
}

.cover-about h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--primary);
  margin: 0 0 1.5rem 0;
  font-weight: 700;
}

.cover-about p {
  font-size: 1.05rem;
  color: #2b2550;
  margin: 0 0 1.25rem 0;
  text-align: justify;
}

/* Print */
@page { margin: 0; }
@media print {
  section{min-height:100vh;}
  .title-page a{display:none;}
  .cover.title-about {
    page-break-after: always;
  }
}



/* ============================================
   PAYROLL ACCOUNTING GUIDE - SCREEN STYLES
   ============================================ */

/* ===== 1. DESIGN TOKENS / CSS VARIABLES ===== */
:root {
  /* Base colors */
  --text: #161616;
  --bg: #ffffff;
  --muted: #6b7280;
  --accent: #0f62fe;
  --maxw: 81ch; /* Increased by 12.5% from 72ch */

  /* Brand tokens - Dapt colors */
  --color-primary: #371B76;   /* Dapt Primary */
  --color-secondary: #20ABAD; /* Dapt Secondary */
  --color-highlight: #F7E64B; /* Dapt Highlight */

  /* Light neutrals tuned for calm look */
  --ink-900: #1E1B2A;          /* body text */
  --ink-700: #3B3850;          /* muted text */
  --ink-500: #6E6B86;          /* captions/help */
  --line-300: #E9E7F2;         /* subtle borders (tinted by primary) */
  --line-200: #F3F2F8;         /* header/zebra bg */
  --bg-100: #FFFFFF;           /* card/table surface */
  --bg-050: #FBFAFF;           /* very subtle tint */

  /* Spacing & Effects */
  --radius: 14px;
  --shadow: 0 2px 10px rgba(23,16,58,.06);
  --pad-y: .65rem;
  --pad-x: .9rem;

  /* Typography */
  --font-body: "Questrial", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: "Quattrocento", Georgia, Cambria, "Times New Roman", Times, serif;
  --font-condensed: "Roboto Condensed", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-ui: var(--font-body);
  --tabular: tabular-nums lining-nums;
}

/* ===== 2. BASE STYLES ===== */
html, body {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.6;
}

/* Global link styling */
a {
  color: #2b59c3;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover,
a:focus {
  color: #1d3f8a;
  text-decoration: none;
}

/* ===== 3. LAYOUT ===== */
header, footer, nav, main {
  padding: 1.25rem;
}

/* Allow sticky elements to work in header */
header {
  overflow: visible;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
}

/* ===== 4. HEADER ===== */
header {
  position: relative;
  overflow: visible;
}

header h1 {
  margin: 0.5rem 0 0;
  font-family: var(--font-heading);
  /* Visually hidden for SEO but kept in HTML */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Header action buttons (for individual policy pages) */
.header-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.header-actions a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

    .header-actions .back-link {
      background: transparent;
      color: #2b59c3;
      border: none;
      padding: 0.625rem 0;
    }

    .header-actions .back-link:hover {
      background: transparent;
      color: #1d3f8a;
      border: none;
    }

.header-actions .pdf-link {
  background: #371B76;
  color: white;
  border: 1px solid #371B76;
}

.header-actions .pdf-link:hover {
  background: #2a1459;
  color: white;
  border-color: #2a1459;
}

.header-actions svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

/* Cover navigation */
nav[aria-label="Cover"] {
  text-align: center;
  margin: 1rem 0;
  padding: 0.5rem;
}

nav[aria-label="Cover"] a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

nav[aria-label="Cover"] a:hover {
  color: var(--color-secondary);
  text-decoration: underline;
}

/* ===== 5. TABLE OF CONTENTS ===== */
/* TOC: visual upgrade (no HTML changes required) */
nav#toc {
  max-width: var(--maxw);
  margin: 0 auto 2rem;
  counter-reset: toc-section-counter;
}

/* Card container */
nav#toc.toc {
  background: var(--bg-100);
  border: 1px solid var(--line-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1rem 1.1rem;
}

/* Base list + spacing */
nav#toc ul,
nav#toc ol {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

nav#toc .toc-l1 > li {
  margin: .65rem 0 .65rem;
  padding: .15rem 0 .45rem;
  border-top: 1px solid var(--line-300);
}

nav#toc .toc-l1 > li:first-child {
  border-top: 0;
}

/* TOC Counter - Reset subsection counter at each main section (excluding front-matter) */
nav#toc ul.toc-l1 > li:not(.toc-front-matter) {
  counter-reset: toc-subsection-counter;
}

/* TOC Counter - Reset subsection counter for numbered sections with subsections */
nav#toc ul.toc-l1 > li:not(.toc-front-matter) > ul {
  counter-reset: toc-subsection-counter;
}

/* Links: calmer color, better hit-area */
nav#toc a {
  display: inline-block;
  text-decoration: none;
  color: var(--ink-900);
  line-height: 1.5;
  padding: .35rem .5rem;
  border-radius: 8px;
  transition: background .15s ease, color .15s ease;
}

nav#toc a:hover {
  background: #F4FBFB;
  text-decoration: none;
}

/* Front-matter tone */
nav#toc li.toc-front-matter > a {
  font-weight: 600;
  color: var(--ink-700);
}

/* TOC Counter - Number main sections (excluding front-matter) with badge styling */
nav#toc ul.toc-l1 > li:not(.toc-front-matter) > a::before {
  counter-increment: toc-section-counter;
  content: counter(toc-section-counter);
  display: inline-block;
  background: var(--line-200);
  color: var(--color-primary);
  border: 1px solid var(--line-300);
  border-radius: 999px;
  padding: .1rem .5rem;
  margin-right: .55rem;
  min-width: 2.2ch;
  text-align: center;
  font-family: var(--font-condensed);
  font-weight: 600;
}

/* Disable TOC numbering badges for security/privacy/terms (content already numbered) */
nav#toc.security-policies ul.toc-l1 > li > a::before,
nav#toc.security-policies ul.toc-l1 > li ul.toc-l2 > li > a::before,
nav#toc.policy-doc ul.toc-l1 > li > a::before,
nav#toc.policy-doc ul.toc-l1 > li ul.toc-l2 > li > a::before {
  content: none;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
}

/* TOC Counter - Number subsections (H3 items under numbered sections only) */
nav#toc ul.toc-l1 > li:not(.toc-front-matter) ul.toc-l2 > li > a::before {
  counter-increment: toc-subsection-counter;
  content: counter(toc-section-counter) "." counter(toc-subsection-counter) " ";
  font-weight: 600;
}

/* TOC Counter - Subsections under front-matter sections (no numbering) */
nav#toc ul.toc-l1 > li.toc-front-matter ul.toc-l2 > li > a::before {
  content: none;
}

/* TOC Counter - Front-matter sections (no numbering) */
nav#toc li.toc-front-matter > a::before {
  content: none;
}

/* Subsection list: accent rail + tighter spacing */
nav#toc .toc-l2 {
  margin-top: .4rem;
  padding-left: .85rem;
  border-left: 3px solid color-mix(in oklab, var(--color-secondary), white 20%);
}

nav#toc .toc-l2 > li {
  margin: .28rem 0;
}

nav#toc .toc-l2 a {
  color: var(--ink-700);
  font-size: .96rem;
  padding: .25rem .35rem;
}

/* Active state (add .is-active via your scroll spy if you use one) */
nav#toc a.is-active {
  background: #F4FBFB;
  border-left: 4px solid var(--color-secondary);
  padding-left: .6rem;
}

/* Optional: subtle caret for parents with children */
nav#toc .toc-l1 > li > ul.toc-l2 {
  position: relative;
}

nav#toc .toc-l1 > li > a + ul.toc-l2::before {
  content: "›";
  position: absolute;
  left: -1.05rem;
  top: .15rem;
  color: var(--ink-500);
  font-family: var(--font-condensed);
}


/* Slightly larger hit-area on touch devices */
@media (hover: none) {
  nav#toc a {
    padding: .5rem .6rem;
  }
  nav#toc .toc-l2 a {
    padding: .4rem .45rem;
  }
}

/* ===== 5b. TITLE HERO (inline title block above TOC) ===== */
.title-hero {
  text-align: center;
  padding: 3rem 1.5rem 2.5rem;
  margin: 0 calc(-1 * var(--pad-x, 1.25rem)) 0;
  background: linear-gradient(170deg, var(--bg-050) 0%, color-mix(in oklab, var(--color-primary), white 94%) 100%);
  border-bottom: 3px solid color-mix(in oklab, var(--color-primary), white 60%);
}

.title-hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

.title-hero h1 a.heading-link {
  color: inherit;
}

.title-hero > p {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--ink-700);
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.3px;
}

/* ===== 6. TYPOGRAPHY ===== */
/* Headings use Quattrocento, except H3 uses Questrial and H4 uses Roboto Condensed for section headers */
article#book h1,
article#book h2,
article#book h5,
article#book h6 {
  font-family: var(--font-heading);
}

/* H3 styling - uses Questrial, clearly sub-level to H2 */
article#book h3 {
  font-family: var(--font-body);
  font-size: 1.2rem;
  color: var(--ink-700);
  margin: 1.25rem 0 0.5rem;
  margin-left: 1rem;
  font-weight: 600;
  line-height: 1.4;
  border-left: 3px solid color-mix(in oklab, var(--color-secondary), white 30%);
  padding-left: 0.75rem;
}

/* H4 headings use Roboto Condensed for compact section headers - less prominent than H3 */
article#book h4 {
  font-family: var(--font-condensed);
  font-size: 1.1rem;
  color: var(--color-primary);
  margin: 1.25rem 0 0.25rem;
  letter-spacing: 0.2px;
  font-weight: 600;
  line-height: 1.4;
}

/* Liability group descriptions (paragraph after H4) */
article#book h4 + p {
  color: var(--ink-700);
  margin: 0.25rem 0 0.6rem;
}

/* Heading links (automatic anchors) */
.heading-link {
  text-decoration: none;
  color: inherit;
}

/* Bold text styling */
strong,
b {
  font-weight: 600;
}

/* ===== 7. CSS COUNTERS FOR AUTOMATIC SECTION NUMBERING ===== */
article#book {
  counter-reset: section-counter subsection-counter;
}

/* Reset subsection counter at each main section (except front-matter) */
article#book h2:not(.front-matter) {
  counter-reset: subsection-counter;
}

/* Number main sections (H2) - exclude front-matter, start from Introduction */
/* Disabled for security/privacy/terms as they already have numbering in content */
article#book:not(.security-policies):not(.policy-doc) h2:not(.front-matter) {
  counter-increment: section-counter;
}

article#book:not(.security-policies):not(.policy-doc) h2:not(.front-matter)::before {
  content: counter(section-counter) ". ";
  font-weight: 600;
}

/* Number subsections (H3) - only those following numbered H2 sections */
article#book:not(.security-policies):not(.policy-doc) h2:not(.front-matter) ~ h3 {
  counter-increment: subsection-counter;
}

article#book:not(.security-policies):not(.policy-doc) h2:not(.front-matter) ~ h3::before {
  content: counter(section-counter) "." counter(subsection-counter) " ";
  font-weight: 600;
}

/* Front-matter sections (About This Guide, Executive Summary) - no numbering */
article#book h2.front-matter::before {
  content: none;
}

/* Subsections under front-matter sections - no numbering or increment */
article#book h2.front-matter ~ h3::before {
  content: none;
}

/* ===== 8. TABLES (Dapt Table Styles) ===== */
/* Table wrapper */
.table-wrap {
  margin: 1.25rem 0 1.75rem;
  background: var(--bg-100);
  border: 1px solid var(--line-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden; /* clips sticky header glow */
}

.table-wrap[data-scroll="auto"] {
  overflow-x: auto;
}

/* Fallback: plain tables get styled automatically (no wrapper needed) */
table {
  margin: 1.25rem 0 1.75rem;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto; /* Let content determine column widths */
}

/* Table core */
.table,
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-family: var(--font-condensed);
  color: var(--ink-900);
  background: var(--bg-100);
  table-layout: auto; /* Let content determine column widths for better balance */
}

/* Table captions */
.table caption,
table caption {
  text-align: left;
  padding: 0.85rem var(--pad-x);
  font-weight: 600;
  color: var(--ink-700);
}

/* Table headers */
.table thead th,
table thead th {
  position: sticky;
  top: 0;
  background: var(--line-200);
  color: var(--ink-900);
  font-weight: 600;
  letter-spacing: .01em;
  text-align: left;
  border-bottom: 1px solid var(--line-300);
  padding: .7rem var(--pad-x);
  white-space: normal; /* Allow wrapping for long headers */
}

/* Brand accent rail on header-left */
.table thead th:first-child,
table thead th:first-child {
  border-left: 4px solid var(--color-primary);
}

/* Table body cells */
.table tbody td,
table tbody td {
  padding: var(--pad-y) var(--pad-x);
  border-bottom: 1px solid var(--line-300);
  vertical-align: top;
  font-variant-numeric: var(--tabular);
}

/* Zebra striping for readability */
.table tbody tr:nth-child(odd),
table tbody tr:nth-child(odd) {
  background: var(--bg-050);
}

/* Totals / emphasis rows */
.table tfoot td,
.table .is-total td,
table tfoot td,
table .is-total td {
  font-weight: 600;
  color: var(--ink-900);
  background: #FFFCE6; /* softened highlight */
  border-top: 2px solid #F0EAA5;
}

/* Alignment helpers */
.table .num,
table .num {
  text-align: right;
}

.table .center,
table .center {
  text-align: center;
}

/* Cell notes - small annotations inside cells */
.cell-note {
  display: block;
  margin-top: .25rem;
  font-size: .85em;
  color: var(--ink-500);
}

/* Table modifiers */
.table--compact {
  font-family: var(--font-condensed);
}

/* Target tables that follow H4 headings (liability sections) */
h4 + p + table,
h4 + p + div.table-wrap > table {
  font-family: var(--font-condensed);
}

h4 + p + table th,
h4 + p + table td,
h4 + p + div.table-wrap > table th,
h4 + p + div.table-wrap > table td {
  font-family: var(--font-condensed);
}

h4 + p + table thead th {
  font-weight: 600;
}

.table--compact td,
.table--compact th {
  padding: .5rem .65rem;
  font-family: var(--font-condensed);
}

.table--compact thead th {
  font-weight: 600;
  font-family: var(--font-condensed);
}

.table--compact tbody td {
  font-family: var(--font-condensed);
}

/* Compact table styling - smaller font, condensed sans-serif */
.table-compact {
  font-size: 0.875rem;
  font-family: var(--font-condensed);
  font-stretch: condensed;
}

.table-compact th,
.table-compact td {
  padding: 0.5rem 0.65rem;
  line-height: 1.4;
}

.table-compact thead th {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.6rem 0.65rem;
}

/* Column width control - only apply to tables with fixed layout */
/* Most tables use auto layout to balance based on content */

/* For tables that need specific column widths, use table-layout: fixed and set widths */
table th,
table td {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Column width control for 3-column liability tables - use fixed layout for these specific tables */
h4 + p + table,
h4 + p + div.table-wrap > table {
  table-layout: fixed;
}

h4 + p + table thead th:nth-child(1),
h4 + p + table tbody td:nth-child(1),
h4 + p + div.table-wrap > table thead th:nth-child(1),
h4 + p + div.table-wrap > table tbody td:nth-child(1) {
  width: 35%; /* Accrual Event - more room */
}

h4 + p + table thead th:nth-child(2),
h4 + p + table tbody td:nth-child(2),
h4 + p + div.table-wrap > table thead th:nth-child(2),
h4 + p + div.table-wrap > table tbody td:nth-child(2) {
  width: 35%; /* Clearing Event - more room */
  white-space: normal;
  word-wrap: break-word;
}

h4 + p + table thead th:nth-child(3),
h4 + p + table tbody td:nth-child(3),
h4 + p + div.table-wrap > table thead th:nth-child(3),
h4 + p + div.table-wrap > table tbody td:nth-child(3) {
  width: 30%; /* Typical Timing - less room */
}

/* Table keyboard focus */
.table-wrap:focus-within {
  outline: 3px solid color-mix(in oklab, var(--color-secondary), white 70%);
  outline-offset: 2px;
}

/* ===== 9. FIGURES AND ASIDES ===== */
figure {
  margin: 1.25rem 0;
}

figcaption {
  color: #667085;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

aside {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  background: #f7fbff;
  border: 1px solid #dde9ff;
  border-radius: 8px;
}

/* Blockquote styling for notes */
blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: #F8F9FA;
  border-left: 4px solid var(--color-secondary);
  border-radius: 4px;
  color: var(--ink-700);
  font-style: normal;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

blockquote p {
  margin: 0.5rem 0;
}

blockquote p:first-child {
  margin-top: 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote ul,
blockquote ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

/* Notes / callouts below tables */
.note {
  margin: .75rem 0 0;
  padding: .65rem .8rem;
  border-left: 3px solid var(--color-secondary);
  background: #F4FBFB;
  color: var(--ink-700);
  border-radius: 8px;
}

/* ===== 10. CODE ===== */
pre, code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

/* ===== 11. DOCUMENT FOOTER ===== */
article#book .document-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line-300);
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-700);
  line-height: 1.6;
}

article#book .document-footer p {
  margin: 0.5rem 0;
}

article#book .document-footer em {
  font-style: normal;
  color: var(--ink-900);
}

article#book .document-footer a {
  color: var(--color-primary);
  text-decoration: none;
}

article#book .document-footer a:hover {
  text-decoration: underline;
}

/* ===== 12. RESPONSIVE IMAGES WITH ZOOM ===== */
article#book img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  cursor: zoom-in;
  transition: transform 0.2s ease;
  box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.08), 4px 4px 8px rgba(0, 0, 0, 0.1);
}

article#book img:hover {
  transform: scale(1.02);
  box-shadow: -3px -3px 6px rgba(0, 0, 0, 0.1), 6px 6px 12px rgba(0, 0, 0, 0.15);
}


/* Image container for zoom functionality - constrained to content margins */
.image-zoom-container,
figure {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 2rem auto 0.5rem auto;
  text-align: center;
  box-sizing: border-box;
  overflow: hidden; /* keep large images from overflowing content */
}

.image-zoom-container img,
figure img {
  margin: 0 auto;
  width: auto;
  max-width: 100%;
  height: auto;
  display: block;
  box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.08), 4px 4px 8px rgba(0, 0, 0, 0.1);
  cursor: zoom-in;
}

/* Hint that image is clickable for full size */
.image-zoom-container::after,
figure.image-zoom-container::after {
  content: "Click to view full size";
  display: block;
  font-size: 0.75rem;
  color: var(--ink-500);
  margin-top: 0.25rem;
  font-style: normal;
}

/* Caption styling - figcaption elements in image containers */
.image-zoom-container figcaption,
.image-zoom-container + figcaption,
figure figcaption {
  margin-top: 0.1rem;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-700);
  font-style: italic;
  text-align: left;
}

.image-zoom-container figcaption em,
.image-zoom-container figcaption i,
.image-zoom-container + figcaption em,
.image-zoom-container + figcaption i,
figure figcaption em,
figure figcaption i {
  font-style: italic;
  color: var(--ink-700);
}

/* Zoom modal overlay */
.image-zoom-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-zoom-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.image-zoom-modal-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-zoom-modal-content img {
  max-width: 100%;
  max-height: 95vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  cursor: zoom-out;
  margin: 0;
  transform: none;
}

.image-zoom-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 10001;
  font-family: var(--font-body);
  font-weight: 600;
}

.image-zoom-close:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

.image-zoom-close:active {
  transform: scale(0.95);
}

/* Zoom controls */
.image-zoom-controls {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  z-index: 10001;
}

.image-zoom-btn {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.image-zoom-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-2px);
}

.image-zoom-btn:active {
  transform: translateY(0);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  article#book img {
    margin: 1.5rem auto;
  }
  
  .image-zoom-modal-content {
    padding: 1rem;
  }
  
  .image-zoom-close {
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  
  .image-zoom-controls {
    bottom: 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .image-zoom-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
}

/* ===== 13. PRINT STYLES (for tables) ===== */
@media print {
  .table-wrap {
    box-shadow: none;
    border-color: #BBB;
  }

  table {
    box-shadow: none;
    border-color: #BBB;
  }

  .table thead th,
  table thead th {
    background: #EFEFF6 !important;
    -webkit-print-color-adjust: exact;
  }

  .table tfoot td,
  .table .is-total td,
  table tfoot td,
  table .is-total td {
    background: #FFF8B8 !important;
    -webkit-print-color-adjust: exact;
  }
  
  /* Hide zoom modal in print */
  .image-zoom-modal {
    display: none !important;
  }
  
  article#book img {
    cursor: default;
    max-width: 100%;
    page-break-inside: avoid;
  }
}