:root {
  --bg: #0b1220;
  --card: #0f1628;
  --accent: #38bdf8;
  --accent-2: #10b981;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2937;
  --danger: #f87171;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --warning-bg: rgba(248,113,113,0.08);
  --warning-border: #f87171;
  --compliance-border: #38bdf8;
  --info-border: #10b981;
  --contact-border: #38bdf8;
  --important-border: #f59e0b;
  --acceptance-border: #10b981;
  --sidebar-width: 280px;
  --header-height: 56px;
}

body.light-mode {
  --bg: #f8fafc;
  --card: #ffffff;
  --accent: #0284c7;
  --accent-2: #059669;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --shadow: 0 24px 80px rgba(0,0,0,0.08);
  --warning-bg: rgba(220,38,38,0.05);
  --warning-border: #dc2626;
  --compliance-border: #0284c7;
  --info-border: #059669;
  --contact-border: #0284c7;
  --important-border: #d97706;
  --acceptance-border: #059669;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

body:not(.light-mode) {
  background-image:
    radial-gradient(circle at 10% 20%, rgba(56,189,248,0.12), transparent 25%),
    radial-gradient(circle at 80% 10%, rgba(16,185,129,0.12), transparent 25%);
}

a { color: inherit; text-decoration: none; }

/* ==================== HEADER ==================== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(11,18,32,0.85);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.3s;
}

body.light-mode header {
  background: rgba(248,250,252,0.9);
}

.navbar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(56,189,248,0.6);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}

.nav-links a:hover { color: var(--text); }

/* ==================== PROGRESS BAR ==================== */
.tyc-progress-bar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 99;
  transition: width 0.2s ease-out;
}

/* ==================== THEME TOGGLE ==================== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: border-color 0.2s, background-color 0.2s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: rgba(56,189,248,0.1);
}

/* ==================== LAYOUT ==================== */
.tyc-layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - var(--header-height));
}

/* ==================== SIDEBAR ==================== */
.tyc-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 3px);
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: calc(100vh - var(--header-height) - 3px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--card);
  z-index: 50;
  transition: background-color 0.3s, transform 0.3s;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-weight: 700;
  font-size: 15px;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.sidebar-close:hover {
  color: var(--text);
  background: rgba(148,163,184,0.1);
}

/* ==================== SEARCH ==================== */
.tyc-search {
  position: relative;
}

.tyc-search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tyc-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}

.tyc-search input::placeholder {
  color: var(--muted);
}

.search-results {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 4px 0;
  min-height: 20px;
}

.search-results:empty {
  display: none;
}

/* ==================== TOC ==================== */
.tyc-toc {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 120px;
  max-height: calc(100vh - 380px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.toc-item {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  transition: color 0.15s, background-color 0.15s, padding-left 0.15s;
  line-height: 1.5;
  cursor: pointer;
  text-decoration: none;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
  min-height: 2.75em;
}

.toc-item:hover {
  color: var(--text);
  background: rgba(148,163,184,0.08);
  padding-left: 14px;
}

.toc-item.active {
  color: var(--accent);
  background: rgba(56,189,248,0.1);
  font-weight: 600;
  padding-left: 14px;
}

.toc-item--danger {
  color: var(--danger) !important;
}

.toc-item--danger.active {
  color: var(--danger) !important;
  background: var(--warning-bg) !important;
}

/* ==================== SIDEBAR PROGRESS ==================== */
.sidebar-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.progress-circle {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.progress-circle svg {
  width: 40px;
  height: 40px;
  transform: rotate(-90deg);
}

.progress-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}

.progress-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.3s ease-out;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
}

.progress-label {
  font-size: 12px;
  color: var(--muted);
}

/* ==================== SIDEBAR ACTIONS ==================== */
.sidebar-actions {
  padding-top: 4px;
}

.btn-expand-all {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.btn-expand-all:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(56,189,248,0.06);
}

/* ==================== MAIN CONTENT ==================== */
.tyc-content {
  flex: 1;
  padding: 28px 28px 64px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==================== HERO ==================== */
.hero {
  background: linear-gradient(145deg, rgba(15,22,40,0.9), rgba(15,22,40,0.7));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s;
}

body.light-mode .hero {
  background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(248,250,252,0.9));
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 32px;
  letter-spacing: -0.5px;
}

.hero p { color: var(--muted); margin: 0; max-width: 720px; }

.eyebrow {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(56,189,248,0.12);
  color: var(--text);
  font-size: 12px;
  margin-bottom: 14px;
  font-weight: 500;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
  overflow: hidden;
}

body.light-mode .card {
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.card h3 { margin: 0 0 8px; }
.card p { margin: 0 0 10px; color: var(--muted); }
.card p:last-child { margin-bottom: 0; }

.card--standard { border-left: 3px solid var(--border); }
.card--danger { border-left: 4px solid var(--danger); }
.card--compliance { border-left: 3px solid var(--compliance-border); }
.card--info { border-left: 3px solid var(--info-border); }
.card--contact { border-left: 3px solid var(--contact-border); }
.card--important { border-left: 3px solid var(--important-border); }
.card--acceptance { border-left: 4px solid var(--acceptance-border); background: rgba(16,185,129,0.04); }

.card--danger .section-body {
  background: var(--warning-bg);
}

/* ==================== SECTION HEADER ==================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  cursor: default;
  gap: 12px;
}

.tyc-section[data-collapsible="true"] .section-header {
  cursor: pointer;
}

.tyc-section[data-collapsible="true"] .section-header:hover {
  background: rgba(148,163,184,0.04);
}

.section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.section-icon {
  flex-shrink: 0;
  font-size: 20px;
}

.section-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ==================== ANCHOR LINK ==================== */
.anchor-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
  opacity: 0.4;
  transition: opacity 0.2s, background-color 0.2s;
}

.anchor-link:hover {
  opacity: 1;
  background: rgba(148,163,184,0.1);
}

/* ==================== COLLAPSE TOGGLE ==================== */
.collapse-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  color: var(--muted);
  transition: color 0.2s, transform 0.3s, border-color 0.2s;
}

.collapse-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tyc-section.expanded .collapse-toggle {
  transform: rotate(180deg);
}

/* ==================== SECTION BODY ==================== */
.section-body {
  padding: 0 20px 20px;
}

.tyc-section[data-collapsible="true"]:not(.expanded) .section-body {
  max-height: 0;
  padding: 0 20px;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease-out, opacity 0.2s ease-out, padding 0.3s ease-out;
}

.tyc-section[data-collapsible="true"].expanded .section-body {
  max-height: 5000px;
  opacity: 1;
  transition: max-height 0.5s ease-in, opacity 0.3s ease-in;
}

.section-body p {
  line-height: 1.7;
  font-size: 14px;
}

.section-body h3 {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* ==================== DANGER BADGE ==================== */
.danger-badge {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(248,113,113,0.15);
  border: 1px solid var(--danger);
  color: var(--danger) !important;
  font-weight: 800;
  font-size: 13px !important;
  letter-spacing: 0.5px;
  margin-bottom: 16px !important;
}

/* ==================== LISTS ==================== */
.list-clean {
  margin: 0 0 10px;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.list-clean li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.list-clean li strong {
  color: var(--text);
}

/* ==================== TABLES ==================== */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  margin: 10px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
  color: var(--text);
}

th, td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(148,163,184,0.05);
}

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

/* ==================== BADGES & UTILITIES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(56,189,248,0.1);
  color: var(--text);
  font-size: 12px;
}

.text-muted { color: var(--muted); }
.highlight { color: var(--accent); }

/* ==================== SEARCH HIGHLIGHT ==================== */
mark.search-highlight {
  background: rgba(56,189,248,0.25);
  color: inherit;
  padding: 1px 2px;
  border-radius: 3px;
}

mark.search-highlight.search-current {
  background: rgba(56,189,248,0.5);
  outline: 2px solid var(--accent);
}

/* ==================== FAB BUTTONS ==================== */
.fab {
  position: fixed;
  z-index: 80;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transition: opacity 0.2s, transform 0.2s, background-color 0.3s;
}

body.light-mode .fab {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.fab:hover {
  background: var(--accent);
  color: #0b1220;
  border-color: var(--accent);
}

.fab-top {
  bottom: 24px;
  right: 24px;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.fab-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.fab-toc {
  bottom: 24px;
  left: 24px;
  display: none;
}

/* ==================== TOAST ==================== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #0b1220;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== SIDEBAR OVERLAY ==================== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ==================== FOOTER ==================== */
footer {
  border-top: 1px solid var(--border);
  background: rgba(11,18,32,0.9);
  color: var(--muted);
  padding: 24px 20px;
  text-align: center;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background-color 0.3s;
}

body.light-mode footer {
  background: rgba(248,250,252,0.95);
}

/* ==================== BUTTONS (general) ==================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1220;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(56,189,248,0.25);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 700;
}

.btn-secondary:hover {
  border-color: #334155;
}

/* ==================== RESPONSIVE ==================== */

/* Tablet: 768-1023px */
@media (max-width: 1023px) {
  .tyc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    z-index: 200;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 30px rgba(0,0,0,0.3);
  }

  .tyc-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-inner {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .tyc-toc {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  .toc-item {
    min-height: 3em;
    line-height: 1.55;
    padding: 11px 12px;
  }

  .sidebar-close {
    display: block;
  }

  .fab-toc {
    display: flex;
  }

  .tyc-content {
    padding: 24px 20px 64px;
  }
}

/* Mobile: <768px */
@media (max-width: 767px) {
  .navbar {
    flex-direction: row;
    padding: 12px 16px;
  }

  .nav-links {
    gap: 10px;
  }

  .hero {
    padding: 24px 18px;
    border-radius: 14px;
  }

  .hero h1 {
    font-size: 24px;
  }

  .tyc-content {
    padding: 16px 14px 80px;
    gap: 14px;
  }

  .section-header {
    padding: 14px 16px;
  }

  .section-body {
    padding: 0 16px 16px;
  }

  .section-title {
    font-size: 16px;
  }

  .fab-top {
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
  }

  .fab-toc {
    bottom: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
  }

  .tyc-sidebar {
    width: 85vw;
    min-width: 85vw;
  }

  table {
    min-width: 400px;
    font-size: 12px;
  }

  th, td {
    padding: 8px 10px;
  }
}

/* Small mobile: <480px */
@media (max-width: 479px) {
  .hero h1 {
    font-size: 20px;
  }

  .hero {
    padding: 18px 14px;
  }

  .section-title {
    font-size: 14px;
  }

  .toc-item {
    font-size: 13px;
    padding: 10px 10px;
    min-height: 3em;
    line-height: 1.55;
  }

  .navbar {
    padding: 10px 12px;
  }

  .brand span:last-child {
    font-size: 14px;
  }
}

/* ==================== OLD CLASSES (backward compat) ==================== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.hero-cta {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cards {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.step-card {
  position: relative;
  padding-top: 42px;
}

.step-number {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #0b1220;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.steps-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.cta-block {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  background: linear-gradient(145deg, rgba(15,22,40,0.92), rgba(15,22,40,0.72));
}

/* ==================== SCROLLBAR (webkit) ==================== */
.tyc-sidebar::-webkit-scrollbar,
.tyc-toc::-webkit-scrollbar {
  width: 4px;
}

.tyc-sidebar::-webkit-scrollbar-track,
.tyc-toc::-webkit-scrollbar-track {
  background: transparent;
}

.tyc-sidebar::-webkit-scrollbar-thumb,
.tyc-toc::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ==================== SECTION FLASH (scroll-to) ==================== */
@keyframes sectionFlash {
  0% { box-shadow: 0 0 0 0 rgba(56,189,248,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(56,189,248,0.15); }
  100% { box-shadow: 0 0 0 0 rgba(56,189,248,0); }
}

.tyc-section.flash {
  animation: sectionFlash 0.8s ease-out;
}
