.treatment-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.treatment-timeline {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: linear-gradient(180deg, #f8fafc 0%, #fff 120px);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

/* Header */

.treatment-sidebar__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 1rem 1rem 0.875rem;
  border-bottom: 1px solid #e8edf3;
  background: #fff;
}

.treatment-sidebar__header-main {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  min-width: 0;
}

.treatment-sidebar__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.treatment-timeline__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.treatment-timeline__subtitle {
  margin: 0.125rem 0 0;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #94a3b8;
  letter-spacing: 0.01em;
}

.treatment-sidebar__toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.treatment-sidebar__toggle:hover {
  background: #e2e8f0;
  color: #334155;
}

.treatment-sidebar__toggle-icon {
  display: block;
  transition: transform 0.2s ease;
}

/* Panel */

.treatment-sidebar__panel {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  flex: 1;
  min-height: 0;
  padding: 0.875rem 1rem 1.125rem;
  overflow: hidden;
}

.treatment-sidebar__steps-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-right: -0.375rem;
  padding-right: 0.375rem;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.treatment-sidebar__steps-scroll::-webkit-scrollbar {
  width: 6px;
}

.treatment-sidebar__steps-scroll::-webkit-scrollbar-track {
  background: transparent;
  margin: 0.25rem 0;
}

.treatment-sidebar__steps-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.treatment-sidebar__steps-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.treatment-sidebar--collapsed .treatment-timeline {
  display: none;
}

.treatment-sidebar__status-row {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.treatment-timeline__status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: #ecfdf5;
  color: #047857;
}

.treatment-timeline__status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.treatment-timeline__status--viewing {
  background: #eff6ff;
  color: #1d4ed8;
}

.treatment-timeline__status--viewing::before {
  background: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.treatment-timeline__new-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  flex-shrink: 0;
  padding: 0.5625rem 1rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.28);
  transition: transform 0.12s, box-shadow 0.15s;
}

.treatment-timeline__new-step:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.treatment-timeline__new-step:active {
  transform: translateY(0);
}

/* Steps list — vertical timeline */

.treatment-timeline__steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 0.25rem;
}

.treatment-timeline__step {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.treatment-timeline__step + .treatment-timeline__step {
  margin-top: 0.5rem;
}

.treatment-timeline__rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
  padding-top: 0.875rem;
  position: relative;
}

.treatment-timeline__rail::after {
  content: "";
  position: absolute;
  top: 1.75rem;
  bottom: -0.5rem;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: #e2e8f0;
}

.treatment-timeline__step:last-child .treatment-timeline__rail::after {
  display: none;
}

.treatment-timeline__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #e2e8f0;
  flex-shrink: 0;
  z-index: 1;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.treatment-timeline__step--active .treatment-timeline__dot {
  background: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  transform: scale(1.15);
}

.treatment-timeline__step--current .treatment-timeline__dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.treatment-timeline__step--current.treatment-timeline__step--active .treatment-timeline__dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
  transform: scale(1.15);
}

.treatment-timeline__card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid #e8edf3;
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.treatment-timeline__step:hover .treatment-timeline__card {
  border-color: #bfdbfe;
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.08);
}

.treatment-timeline__step--active .treatment-timeline__card {
  border-color: #93c5fd;
  background: linear-gradient(135deg, #f8fbff 0%, #eff6ff 100%);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.12);
}

.treatment-timeline__step--current.treatment-timeline__step--active .treatment-timeline__card {
  border-color: #6ee7b7;
  background: linear-gradient(135deg, #f0fdf8 0%, #ecfdf5 100%);
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.12);
}

.treatment-timeline__step-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.treatment-timeline__step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.375rem;
  height: 1.375rem;
  padding: 0 0.3125rem;
  border-radius: 6px;
  background: #f1f5f9;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #475569;
}

.treatment-timeline__step--active .treatment-timeline__step-badge {
  background: #3b82f6;
  color: #fff;
}

.treatment-timeline__step-badge--live {
  background: #d1fae5;
  color: #047857;
  font-size: 0.5625rem;
  letter-spacing: 0.04em;
}

.treatment-timeline__step--current.treatment-timeline__step--active .treatment-timeline__step-badge--live {
  background: #10b981;
  color: #fff;
}

.treatment-timeline__step-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.treatment-timeline__step-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.treatment-timeline__tag {
  display: inline-block;
  padding: 0.125rem 0.4375rem;
  border-radius: 4px;
  background: #f1f5f9;
  font-size: 0.625rem;
  font-weight: 500;
  color: #64748b;
  line-height: 1.4;
}

.treatment-timeline__tag--empty {
  background: transparent;
  color: #94a3b8;
  font-style: italic;
  padding: 0;
}

.treatment-timeline__step-date {
  font-size: 0.625rem;
  font-weight: 500;
  color: #94a3b8;
  letter-spacing: 0.01em;
}

/* Collapsed sidebar — expand arrow centered on bar */

.treatment-sidebar__collapsed-rail {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
}

.treatment-sidebar__collapsed-rail:not([hidden]) {
  display: flex;
}

.treatment-sidebar__expand-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.treatment-sidebar__expand-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.15);
}

.treatment-sidebar__expand-count {
  position: absolute;
  top: -6px;
  right: -6px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #3b82f6;
  border: 2px solid #fff;
  font-size: 0.625rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.treatment-sidebar__expand-count[hidden] {
  display: none;
}

.treatment-sidebar--collapsed .treatment-sidebar__toggle-icon {
  transform: rotate(180deg);
}

/* Chart banner */

.treatment-timeline__banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5625rem 1rem;
  background: linear-gradient(90deg, #fffbeb 0%, #fef9c3 100%);
  border-bottom: 1px solid #fde68a;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #92400e;
  flex-wrap: wrap;
}

.treatment-timeline__banner[hidden] {
  display: none;
}

.treatment-timeline__banner-return {
  padding: 0.3125rem 0.75rem;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  background: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  color: #b45309;
  cursor: pointer;
  transition: background 0.15s;
}

.treatment-timeline__banner-return:hover {
  background: #fef3c7;
}

/* Read-only chart */

.dental-chart-wrapper.dental-chart--readonly .dental-chart {
  opacity: 0.92;
}

.dental-chart-wrapper.dental-chart--readonly .tooth,
.dental-chart-wrapper.dental-chart--readonly .tooth-gap,
.dental-chart-wrapper.dental-chart--readonly .arch-midline-gap {
  cursor: default !important;
}

@media (max-width: 1024px) {
  .treatment-sidebar {
    min-height: auto;
  }

  .treatment-sidebar__collapsed-rail {
    min-height: auto;
    padding: 0.75rem 0;
  }
}
