:root {
  --bg: hsl(220 17% 97%);
  --fg: hsl(222 47% 11%);
  --card: #fff;
  --muted: hsl(220 9% 46%);
  --border: hsl(220 13% 91%);
  --primary: hsl(217 91% 60%);
  --primary-dim: hsl(217 91% 60% / 0.12);
  --accent: hsl(142 76% 36%);
  --danger: hsl(0 84% 60%);
  --sidebar-w: 300px;
  --header-h: 72px;
  --radius: 12px;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.08), 0 8px 24px rgb(0 0 0 / 0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 28px); }

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  font-size: 15px;
}

/* Header */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  gap: 1rem;
  background: hsl(0 0% 100% / 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s ease;
}

.brand:hover { opacity: 0.9; }

.brand-logo {
  height: 40px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  display: block;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.legal-nav a {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
}

.legal-nav a:hover { color: var(--fg); background: var(--primary-dim); }
.legal-nav a.active { color: var(--primary); background: var(--primary-dim); }

.header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, filter 0.2s;
}

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); background: var(--primary-dim); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
}

/* Layout */
.page-wrap {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding-top: var(--header-h);
}

.page-wrap--form .main-content { max-width: 720px; margin: 0 auto; }
.page-wrap--no-sidebar .main-content { max-width: 900px; margin: 0 auto; }

.toc-sidebar {
  position: sticky;
  top: var(--header-h);
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 1.5rem 1rem 2rem 1.5rem;
  border-right: 1px solid var(--border);
  background: hsl(0 0% 100% / 0.7);
}

.toc-title {
  font-family: Outfit, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}

.toc-search {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8125rem;
  margin-bottom: 1rem;
  background: var(--card);
  font-family: inherit;
}
.toc-search:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.toc-nav { list-style: none; }
.toc-nav > li { margin-bottom: 2px; }
.toc-nav a {
  display: block;
  padding: 0.38rem 0.5rem 0.38rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.toc-nav a:hover { color: var(--fg); background: var(--primary-dim); }
.toc-nav a.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-dim);
  border-left-color: var(--primary);
}
.toc-nav .toc-sub a { padding-left: 1.25rem; font-size: 0.72rem; }

.main-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 4rem;
  max-width: 880px;
}

/* Hero */
.doc-hero {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.logo-strip {
  margin-bottom: 1.25rem;
}

.logo-strip-inner {
  display: inline-flex;
  align-items: center;
}

.logo-strip-inner img {
  height: 52px;
  width: auto;
  max-width: min(280px, 100%);
  object-fit: contain;
  display: block;
}

.doc-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  background: var(--primary-dim);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.doc-hero h1 {
  font-family: Outfit, sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.doc-meta strong { color: var(--fg); }

/* Sections */
.legal-section {
  margin-bottom: 2.5rem;
  scroll-margin-top: calc(var(--header-h) + 28px);
}

.legal-section > h2 {
  font-family: Outfit, sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65rem;
  height: 1.65rem;
  font-size: 0.75rem;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  flex-shrink: 0;
}

.legal-section h3 {
  font-size: 1.02rem;
  font-weight: 600;
  margin: 1.35rem 0 0.6rem;
}

.legal-section h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  color: hsl(222 47% 25%);
}

.legal-section p { margin-bottom: 0.85rem; }
.legal-section ul, .legal-section ol { margin: 0.5rem 0 1rem 1.35rem; }
.legal-section li { margin-bottom: 0.4rem; }

.legal-articles { list-style: none; margin: 0; padding: 0; }
.legal-articles > li {
  margin-bottom: 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.legal-articles > li > strong {
  display: block;
  font-family: Outfit, sans-serif;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

a { color: var(--primary); }
a:hover { text-decoration: underline; }

.table-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  background: var(--card);
}

th, td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: hsl(220 17% 95%);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

tr:last-child td { border-bottom: none; }

.callout {
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  font-size: 0.875rem;
  border-left: 4px solid;
}
.callout-info { background: var(--primary-dim); border-color: var(--primary); }
.callout-warn { background: hsl(38 92% 50% / 0.1); border-color: hsl(38 92% 50%); }
.callout-legal { background: hsl(222 47% 11% / 0.04); border-color: hsl(222 47% 11%); }

.glossary dt {
  font-weight: 600;
  margin-top: 0.75rem;
  color: var(--primary);
}
.glossary dd {
  margin: 0.25rem 0 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.rights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.65rem;
  margin: 1rem 0;
}

.right-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  box-shadow: var(--shadow);
}
.right-card strong { display: block; font-size: 0.875rem; color: var(--primary); margin-bottom: 0.2rem; }
.right-card span { font-size: 0.78rem; color: var(--muted); }

.data-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin: 0.85rem 0;
  box-shadow: var(--shadow);
}
.data-card h3 { margin: 0 0 0.5rem !important; font-size: 0.95rem !important; }

.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.65rem; }
.tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: hsl(220 17% 95%);
  color: var(--muted);
}
.tag-legal { background: var(--primary-dim); color: var(--primary); }
.tag-required { background: hsl(0 84% 60% / 0.1); color: var(--danger); }

.contact-block {
  background: linear-gradient(135deg, var(--primary-dim), hsl(142 76% 36% / 0.06));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.legal-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

.site-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--card);
}

.site-footer .footer-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.site-footer .footer-logo {
  height: 36px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
}

.legal-entity-block {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--muted);
  box-shadow: var(--shadow);
}

.legal-entity-block strong {
  display: block;
  font-family: Outfit, sans-serif;
  font-size: 0.9rem;
  color: var(--fg);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.legal-entity-block a { word-break: break-all; }

.site-footer .legal-entity {
  max-width: 520px;
  margin: 0 auto 0.75rem;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted);
}

.site-footer .legal-entity strong {
  display: block;
  color: var(--fg);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

/* Forms */
.form-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin: 1.5rem 0;
}

.form-panel h2 {
  font-family: Outfit, sans-serif;
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
  border: none;
  padding: 0;
}

.form-panel > p.sub { font-size: 0.875rem; color: var(--muted); margin-bottom: 1.25rem; }

.legal-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 600px) {
  .legal-form .form-row { grid-template-columns: 1fr; }
}

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.form-group label .req { color: var(--danger); }
.form-group .hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: transparent;
}
.form-group input.error,
.form-group select.error,
.form-group textarea.error {
  border-color: var(--danger);
}

.form-check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}
.form-check input { margin-top: 0.2rem; width: auto; flex-shrink: 0; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.form-alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}
.form-alert.show { display: block; }
.form-alert.success { background: hsl(142 76% 36% / 0.12); color: hsl(142 50% 25%); border: 1px solid hsl(142 76% 36% / 0.3); }
.form-alert.error { background: hsl(0 84% 60% / 0.1); color: hsl(0 50% 35%); border: 1px solid hsl(0 84% 60% / 0.3); }

.api-endpoint {
  background: hsl(222 47% 11%);
  color: #e2e8f0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  margin: 0.5rem 0;
  overflow-x: auto;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.link-card {
  display: block;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, transform 0.2s;
}
.link-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  text-decoration: none;
}
.link-card strong { display: block; color: var(--primary); margin-bottom: 0.35rem; }
.link-card span { font-size: 0.8125rem; color: var(--muted); }

.back-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 50;
  font-size: 1.1rem;
}
.back-top.visible { opacity: 1; visibility: visible; }

.toc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  z-index: 90;
}
.toc-overlay.open { display: block; }

@media print {
  .site-header, .toc-sidebar, .back-top, .menu-toggle, .legal-nav { display: none !important; }
  .page-wrap { display: block; padding-top: 0; }
  .main-content { max-width: 100%; }
}

@media (max-width: 1024px) {
  .legal-nav { display: none; }
  .menu-toggle { display: block; }
  .toc-sidebar {
    position: fixed;
    left: 0; top: var(--header-h);
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.25s;
    background: #fff;
    box-shadow: var(--shadow);
  }
  .toc-sidebar.open { transform: translateX(0); }
  .main-content { padding: 1.5rem 1.25rem 3rem; }
}

@media (max-width: 640px) {
  .brand-logo { height: 32px; max-width: 130px; }
}
