/* ==========================================================================
   Safety Plan (Document View) - Modern UI matching site theme
   ========================================================================== */

.safety-plan {
  padding-top: calc(var(--fixed-header-height, 120px) + 18px);
  padding-bottom: 60px;
}

.sp-hero {
  position: relative;
  overflow: hidden;
  padding: 46px 24px 28px;
}

.sp-hero__bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 500px at 20% 20%, rgba(56, 189, 248, 0.20), transparent 60%),
    radial-gradient(700px 500px at 80% 30%, rgba(0, 123, 255, 0.16), transparent 60%),
    radial-gradient(900px 700px at 50% 100%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 45%);
  pointer-events: none;
  filter: saturate(110%);
}

.sp-hero__inner {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  align-items: stretch;
}

.sp-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
  font-size: 0.86rem;
}

.sp-title {
  margin: 12px 0 8px;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.12;
}

.sp-subtitle {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 600;
}

.sp-hero__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sp-btn {
  padding: 0.78rem 1.2rem;
  border-radius: 999px;
}

.sp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 18px;
  box-shadow: var(--shadow-main);
  padding: 18px;
}

.sp-card--glass {
  background: rgba(22, 27, 34, 0.72);
  backdrop-filter: blur(16px);
}

.sp-card__title {
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.sp-company-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.sp-kv {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: baseline;
}

.sp-kv .k {
  color: rgba(255, 255, 255, 0.66);
  font-weight: 800;
  font-size: 0.86rem;
}

.sp-kv .v {
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
}

.sp-kv--wide {
  grid-column: 1 / -1;
}

.sp-body {
  padding: 0 24px;
}

.sp-layout {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
}

.sp-toc {
  position: sticky;
  top: calc(var(--fixed-header-height, 120px) + 18px);
  align-self: start;
  height: fit-content;
}

.sp-toc__inner {
  background: rgba(22, 27, 34, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(14px);
}

.sp-toc__title {
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.sp-toc__link {
  display: block;
  padding: 9px 10px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  font-weight: 800;
  border: 1px solid transparent;
  transition: all 160ms ease;
}

.sp-toc__link:hover {
  background: rgba(56, 189, 248, 0.10);
  border-color: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
}

.sp-toc__hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.62);
  font-weight: 700;
  font-size: 0.86rem;
}

.sp-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sp-section {
  scroll-margin-top: calc(var(--fixed-header-height, 120px) + 18px);
}

.sp-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.sp-section__desc {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 650;
  font-size: 0.92rem;
  max-width: 68ch;
}

.sp-h2 {
  margin: 0;
  font-weight: 950;
  letter-spacing: -0.03em;
  font-size: 1.35rem;
}

.sp-badges {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sp-badge {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 900;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.86rem;
}

.sp-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.sp-metric {
  background: rgba(22, 27, 34, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 16px;
}

.sp-metric__label {
  color: rgba(255, 255, 255, 0.68);
  font-weight: 900;
  font-size: 0.9rem;
}

.sp-metric__value {
  font-weight: 950;
  letter-spacing: -0.03em;
  font-size: 1.25rem;
  margin-top: 6px;
}

.sp-metric__hint {
  color: rgba(255, 255, 255, 0.62);
  font-weight: 750;
  font-size: 0.88rem;
  margin-top: 6px;
}

.sp-list {
  margin: 0;
  padding-left: 1.2rem;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 650;
}

.sp-list li {
  padding: 6px 0;
}

/* Org chart */
.sp-org {
  display: grid;
  gap: 16px;
}

.sp-org__top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sp-org__mid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sp-org__teams {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.sp-node {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
}

.sp-node .t {
  font-weight: 950;
  letter-spacing: -0.02em;
}

.sp-node .s {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
  margin-top: 4px;
}

.sp-node--primary {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.14), rgba(255, 255, 255, 0.03));
  border-color: rgba(56, 189, 248, 0.18);
}

.sp-node--muted {
  background: rgba(255, 255, 255, 0.02);
}

.sp-team {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  text-align: center;
}

.sp-team__name {
  font-weight: 950;
  letter-spacing: -0.02em;
}

.sp-team__slot {
  margin-top: 6px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.65);
  font-weight: 850;
  padding: 6px 0;
}

/* Timeline */
.sp-timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sp-timecard {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(22, 27, 34, 0.85);
  padding: 14px;
}

.sp-timecard__month {
  font-weight: 950;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.sp-bullets {
  margin: 0;
  padding-left: 1.05rem;
  color: rgba(255, 255, 255, 0.84);
  font-weight: 650;
}

.sp-bullets li {
  padding: 4px 0;
}

/* Table */
.sp-table {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.92);
}

.sp-table thead th {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  font-weight: 950;
}

.sp-table tbody td {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.015);
}

.sp-td-month {
  font-weight: 950;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
}

/* Details accordion */
.sp-accordion {
  display: grid;
  gap: 10px;
}

.sp-details {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(22, 27, 34, 0.85);
  overflow: hidden;
}

.sp-details>summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}

.sp-details>summary::-webkit-details-marker {
  display: none;
}

.sp-details__title {
  font-weight: 950;
  letter-spacing: -0.02em;
}

.sp-details__meta {
  color: rgba(255, 255, 255, 0.65);
  font-weight: 850;
  font-size: 0.9rem;
}

.sp-details__body {
  padding: 0 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sp-checklist {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.sp-checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: rgba(255, 255, 255, 0.86);
  font-weight: 650;
}

.sp-checklist .box {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.02);
  margin-top: 1px;
  flex: 0 0 auto;
}

.sp-checklist--2col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sp-footer-note {
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
}

.sp-footer-note__title {
  font-weight: 950;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.sp-footer-note__body {
  color: rgba(255, 255, 255, 0.76);
  font-weight: 650;
}

/* Tree CSS Framework (Global) */
.sp-tree ul {
  padding-top: 20px;
  position: relative;
  transition: all 0.5s;
  display: flex;
  justify-content: center;
  margin: 0;
  padding-left: 0;
}

.sp-tree li {
  float: left;
  text-align: center;
  list-style-type: none;
  position: relative;
  padding: 20px 5px 0 5px;
  transition: all 0.5s;
}

/* Connectors */
.sp-tree li::before,
.sp-tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 1px solid #ddd;
  width: 50%;
  height: 20px;
}

.sp-tree li::after {
  right: auto;
  left: 50%;
  border-left: 1px solid #ddd;
}

/* Remove connectors from root */
.sp-tree li:only-child::after,
.sp-tree li:only-child::before {
  display: none;
}

.sp-tree li:only-child {
  padding-top: 0;
}

.sp-tree li:first-child::before,
.sp-tree li:last-child::after {
  border: 0 none;
}

/* Vertical line for multi-child nodes */
.sp-tree li:last-child::before {
  border-right: 1px solid #ddd;
  border-radius: 0 5px 0 0;
}

.sp-tree li:first-child::after {
  border-radius: 5px 0 0 0;
}

/* Downward connector from parent */
.sp-tree ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 1px solid #ddd;
  width: 0;
  height: 20px;
}

/* Node Styles */
.sp-tree-node {
  display: inline-block;
  padding: 14px 18px;
  text-decoration: none;
  font-size: 11px;
  border-radius: 12px;
  transition: all 0.3s ease;
  min-width: 110px;
  background: #fff;
  position: relative;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.05);
  cursor: default;
}

.sp-tree-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Typography within nodes */
.sp-tree-node .t {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 13px;
  color: #1f2937;
}

.sp-tree-node .n {
  font-size: 12px;
  color: #4b5563;
  font-weight: 500;
}

/* Color Coding Accents */
/* Level 1 & 2: Yellow */
.sp-tree-node.level-1,
.sp-tree-node.level-2 {
  border-top: 4px solid #FFC000;
}

/* Level 3: Grey-Blue */
.sp-tree-node.level-3 {
  border-top: 4px solid #64748b;
}

/* Level 4: Beige/Brown */
.sp-tree-node.level-4 {
  border-top: 4px solid #a8a29e;
}

/* Responsive */
@media (max-width: 1100px) {
  .sp-hero__inner {
    grid-template-columns: 1fr;
  }

  .sp-layout {
    grid-template-columns: 1fr;
  }

  .sp-toc {
    position: relative;
    top: auto;
  }

  .sp-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sp-org__teams {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sp-timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .sp-hero {
    padding: 34px 16px 18px;
  }

  .sp-body {
    padding: 0 16px;
  }

  .sp-grid-4 {
    grid-template-columns: 1fr;
  }

  .sp-timeline {
    grid-template-columns: 1fr;
  }

  .sp-company-grid {
    grid-template-columns: 1fr;
  }

  .sp-kv {
    grid-template-columns: 92px 1fr;
  }

  .sp-checklist--2col {
    grid-template-columns: 1fr;
  }
}

/* Print / PDF */
@media print {
  body::before {
    display: none !important;
  }

  header.main-header,
  #scrollTopBtn {
    display: none !important;
  }

  .safety-plan {
    padding-top: 0 !important;
    color: #111 !important;
  }

  .sp-hero__bg {
    display: none !important;
  }

  .sp-hero,
  .sp-body {
    padding: 0 !important;
  }

  .sp-toc {
    display: none !important;
  }

  .sp-layout {
    grid-template-columns: 1fr !important;
  }

  .sp-card,
  .sp-metric,
  .sp-timecard,
  .sp-details,
  .sp-footer-note {
    box-shadow: none !important;
    background: #fff !important;
    border-color: #d0d7de !important;
    color: #111 !important;
  }

  .sp-table thead th,
  .sp-table tbody td {
    background: #fff !important;
    color: #111 !important;
    border-color: #d0d7de !important;
  }

  .sp-subtitle,
  .sp-section__desc,
  .sp-kv .k,
  .sp-metric__label,
  .sp-metric__hint,
  .sp-details__meta,
  .sp-checklist li,
  .sp-checklist .txt,
  .sp-bullets,
  .sp-bullets li,
  .sp-timecard__month,
  .sp-timecard,
  .sp-list,
  .sp-list li,
  .sp-kv .k,
  .sp-kv .v,
  .sp-tree-node,
  .sp-tree-node .t,
  .sp-tree-node .n {
    color: #000 !important;
  }

  .sp-tree-node {
    box-shadow: none !important;
    border: 1px solid #000 !important;
  }

  .btn {
    display: none !important;
  }

  /* Named page for landscape */
  @page orgchart-landscape {
    size: landscape;
    margin: 1cm;
  }

  /* Named page for portrait */
  @page portrait-page {
    size: portrait;
    margin: 1cm;
  }

  /* Separate Page for Org Chart - Tree Style */
  .sp-print-only-page {
    page: orgchart-landscape;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    break-before: page;
    min-height: 0;
    /* Removed 100vh to prevent overflow */
    padding: 20px;
    background: #fff;
    color: #111;
  }

  /* Modifier for Portrait Page */
  .sp-print-only-page--portrait {
    page: portrait-page;
  }


  /* Enlarge Tree for Print Page */
  .sp-print-only-page .sp-tree-node {
    font-size: 16px;
    min-width: 140px;
    padding: 18px 24px;
    border-width: 2px !important;
  }

  .sp-print-only-page .sp-tree-node .t {
    font-size: 18px;
    margin-bottom: 8px;
  }

  .sp-print-only-page .sp-tree-node .n {
    font-size: 15px;
  }

  .sp-print-only-page .sp-tree li {
    padding: 30px 10px 0 10px;
  }


  .sp-print-header {
    text-align: center;
    margin-bottom: 40px;
    width: 100%;
  }

  /* Tree Overrides for Print */
  .sp-tree ul ul::before,
  .sp-tree li::before,
  .sp-tree li::after,
  .sp-tree li:last-child::before {
    border-color: #000 !important;
  }
}

/* Default hidden on screen */
.sp-print-only-page {
  display: none;
}