/* -------------------- Design Tokens -------------------- */
:root {
  /* Surfaces */
  --surface-glass: rgba(16, 38, 79, 0.78);
  --surface-glass-weak: rgba(255, 255, 255, 0.03);

  /* Borders / dividers */
  --border-glass: rgba(255, 255, 255, 0.10);
  --divider-glass: rgba(255, 255, 255, 0.06);

  /* Text */
  --text-strong: rgba(255, 255, 255, 0.96);
  --text-muted:  rgba(255, 255, 255, 0.72);

  /* Radii & elevation */
  --radius-lg: 18px;
  --radius-md: 12px;
  --elev-3: 0 16px 40px rgba(0, 0, 0, 0.35);

  /* Brand accent (falls back to existing --secondary-color) */
  --brand-accent: var(--secondary-color, #2FA0FF);

  /* Focus ring */
  --focus-ring: 0 0 0 2px rgba(72, 168, 255, 0.60);

  /* Sticky footer height (used to reserve space in the scroller) */
  --settings-footer-h: 76px;

  /* Toast width */
  --toast-width: min(92vw, 420px);
}

/* If backdrop-filter isn’t supported, slightly darken as a fallback */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --surface-glass: #0f274b; }
}

/* -------------------- Backdrop -------------------- */
.offcanvas-backdrop.show {
  background-color: rgba(4, 10, 24, 0.40);
}

/* ======================================================================
   Settings / Custom Drawer — Modern Dark
   ====================================================================== */

/* Drawer Surface -------------------------------------------------------- */
.offcanvas.settings-drawer,
.offcanvas.custom-offcanvas {
  --bs-offcanvas-width: min(92vw, 420px);

  /* Slightly more opaque than modals, but not black */
  background: rgba(16, 38, 79, 0.90);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
  backdrop-filter: blur(18px) saturate(115%);

  color: var(--text-strong);
  border-left: 1px solid var(--border-glass);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  box-shadow: var(--elev-3);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s;

  /* Lock to viewport height to prevent “overshoot” on open */
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden; /* the inner list owns scrolling */
}

@media (max-width: 576px) {
  .offcanvas.settings-drawer,
  .offcanvas.custom-offcanvas {
    border-radius: 0;
  }
}

/* Header --------------------------------------------------------------- */
.settings-drawer .offcanvas-header,
.custom-offcanvas .offcanvas-header {
  border-bottom: 1px solid var(--divider-glass);
}

.settings-drawer .btn-close,
.custom-offcanvas .btn-close {
  filter: invert(1) opacity(0.75);
}
.settings-drawer .btn-close:hover,
.custom-offcanvas .btn-close:hover {
  opacity: 1;
}

/* Title --------------------------------------------------------------- */
.settings-drawer .offcanvas-title,
.custom-offcanvas .offcanvas-title,
.drawer-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: 0.2px;
}

/* -------------------- Icon Token (match home tiles) ------------------- */
.icon-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
}
.icon-token > i {
  font-size: 1rem;
  line-height: 1;
}

/* -------------------- Layout: single scroll area ---------------------- */
.settings-drawer .offcanvas-body,
.custom-offcanvas .offcanvas-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  overflow: hidden !important; /* body doesn't scroll; the list will */
}

/* Accordion as flex column so its content can shrink/grow */
.settings-drawer .accordion,
.custom-offcanvas .accordion {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* Each item is a column; header is fixed, collapse region is flexible */
.settings-drawer .accordion-item,
.custom-offcanvas .accordion-item {
  background: transparent;
  border-color: var(--divider-glass);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.settings-drawer .accordion-header,
.custom-offcanvas .accordion-header {
  flex: 0 0 auto;
}

/* Respect Bootstrap’s display:none on hidden collapse.
   When shown, switch to flex so children can layout. */
.settings-drawer .accordion-collapse.collapse.show,
.custom-offcanvas .accordion-collapse.collapse.show {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Overshoot guard: disable the height animation that causes the “jump” */
.custom-offcanvas .accordion .collapsing {
  height: auto !important;
  transition: none !important;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.settings-drawer .accordion-body,
.custom-offcanvas .accordion-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

/* Sections & Panels ----------------------------------------------------- */
.drawer-section {
  padding: 8px 12px 0;
}

.glass-panel {
  background: var(--surface-glass-weak);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
}

/* -------------------- Accordion look ---------------------------------- */
.settings-drawer .accordion-button,
.custom-offcanvas .accordion-button {
  background: transparent;
  color: var(--text-strong);
  box-shadow: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
}
.settings-drawer .accordion-button:not(.collapsed),
.custom-offcanvas .accordion-button:not(.collapsed) {
  color: var(--text-strong);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--border-glass);
}
.settings-drawer .accordion-button::after,
.custom-offcanvas .accordion-button::after {
  filter: invert(1) opacity(0.85);
}

/* -------------------- Inputs on glass --------------------------------- */
.settings-drawer .form-control,
.custom-offcanvas .form-control,
.form-control-glass {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}

.settings-drawer .form-control::placeholder,
.custom-offcanvas .form-control::placeholder,
.form-control-glass::placeholder {
  color: var(--text-muted);
}

.settings-drawer .form-control:focus,
.custom-offcanvas .form-control:focus,
.form-control-glass:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: rgba(72, 168, 255, 0.65);
}

/* Search + actions row (consistent 40px controls) ----------------------- */
.settings-drawer .action-row,
.custom-offcanvas .action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.settings-drawer .action-row .spacer,
.custom-offcanvas .action-row .spacer {
  flex: 1;
}

.settings-drawer .atc-search,
.custom-offcanvas .atc-search {
  height: 40px;
  padding-left: 2.25rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.settings-drawer .atc-search::placeholder,
.custom-offcanvas .atc-search::placeholder {
  color: var(--text-muted);
}

/* Plain white magnifying glass (no disc, no animation) */
.settings-drawer .input-icon,
.custom-offcanvas .input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  line-height: 1;
  color: #ffffff;
  opacity: 0.95;
  background: none !important;
  box-shadow: none !important;
  width: auto;
  height: auto;
  pointer-events: none;
  transition: none;
}
.settings-drawer .input-icon svg,
.settings-drawer .input-icon svg * {
  fill: #ffffff !important;
  stroke: #ffffff !important;
}

/* Ensure buttons in the action row never wrap and match input height */
.settings-drawer .action-row .btn,
.custom-offcanvas .action-row .btn {
  white-space: nowrap;
  height: 40px;
  line-height: 24px;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  flex: 0 0 auto;
  min-width: max-content;
}

.settings-drawer .action-row .form-control,
.custom-offcanvas .action-row .form-control {
  flex: 1 1 auto;
  min-width: 0;
}

/* -------------------- Checklist --------------------------------------- */
.atc-checklist .form-check {
  margin-bottom: 0.35rem;
}
.atc-checklist .form-check-label {
  color: var(--text-strong);
}
.atc-checklist .form-check-input {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  box-shadow: none;
}
.atc-checklist .form-check-input:focus {
  box-shadow: var(--focus-ring);
  border-color: rgba(72, 168, 255, 0.65);
}
.atc-checklist .form-check-input:checked {
  background-color: var(--brand-accent);
  border-color: var(--brand-accent);
}

/* List container – the ONLY scroller ----------------------------------- */
.settings-drawer .atc-list,
.custom-offcanvas .atc-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto !important;
  overscroll-behavior: contain;  /* keep scroll from bubbling to body */
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 4px;
  /* Reserve space so the sticky footer never covers the last items */
  padding-bottom: calc(var(--settings-footer-h) + 12px) !important;
  scrollbar-gutter: stable; /* avoid width shift when scrollbar appears */
}

/* Subtle dividers within lists ----------------------------------------- */
.settings-drawer .list-group-item {
  background: transparent;
  color: var(--text-strong);
  border-color: var(--divider-glass);
}

/* -------------------- Sticky Footer (actions) ------------------------- */
.settings-drawer .drawer-footer,
.custom-offcanvas .offcanvas-footer {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  min-height: var(--settings-footer-h);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;

  padding: 12px var(--bs-offcanvas-padding-x, 16px);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));

  margin-left: calc(-1 * var(--bs-offcanvas-padding-x, 16px));
  margin-right: calc(-1 * var(--bs-offcanvas-padding-x, 16px));

  /* Same “weight” as body – no dark chin */
  background: rgba(16, 38, 79, 0.94);
  border-top: 1px solid var(--divider-glass);
  z-index: 3;
}

/* -------------------- Buttons (match modals) -------------------------- */
.settings-drawer .btn-primary,
.custom-offcanvas .btn-primary {
  background-color: var(--brand-accent);
  border-color: var(--brand-accent);
  font-weight: 600;
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}
.settings-drawer .btn-primary:hover,
.custom-offcanvas .btn-primary:hover {
  filter: brightness(1.03);
}
.settings-drawer .btn-primary:active,
.custom-offcanvas .btn-primary:active {
  filter: brightness(0.97);
}
.settings-drawer .btn-primary:disabled,
.custom-offcanvas .btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.settings-drawer .btn-ghost,
.custom-offcanvas .btn-ghost,
.settings-drawer .btn-cancel,
.custom-offcanvas .btn-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-strong);
}
.settings-drawer .btn-ghost:hover,
.custom-offcanvas .btn-ghost:hover,
.settings-drawer .btn-cancel:hover,
.custom-offcanvas .btn-cancel:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Make Select all / Clear feel like link-ish buttons */
.settings-drawer .btn-ghost,
.custom-offcanvas .btn-ghost {
  font-weight: 500;
  padding-inline: 0.8rem;
  font-size: 0.875rem;
}

.settings-drawer .btn:focus-visible,
.custom-offcanvas .btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* If you still render "Close" as a link button somewhere */
.settings-drawer .btn-link,
.custom-offcanvas .btn-link {
  color: var(--text-muted);
  text-decoration: none;
}
.settings-drawer .btn-link:hover,
.custom-offcanvas .btn-link:hover {
  color: var(--text-strong);
  text-decoration: underline;
}

/* -------------------- Badges (live selection count) ------------------- */
.setting-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  color: var(--text-strong);
}

/* -------------------- Scrollbar (list) -------------------------------- */
.settings-drawer .atc-list,
.custom-offcanvas .atc-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.20) transparent;
}
.settings-drawer .atc-list::-webkit-scrollbar,
.custom-offcanvas .atc-list::-webkit-scrollbar {
  width: 10px;
}
.settings-drawer .atc-list::-webkit-scrollbar-thumb,
.custom-offcanvas .atc-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.settings-drawer .atc-list::-webkit-scrollbar-thumb:hover,
.custom-offcanvas .atc-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* Back-compat: if markup still uses #atc-options-container, style its scrollbar too */
#atc-options-container::-webkit-scrollbar {
  width: 10px;
}
#atc-options-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}
#atc-options-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
#atc-options-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* -------------------- ATC Quickbar (if/when you enable it) ------------ */
.atc-quickbar {
  background: rgba(255, 255, 255, 0.15);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  border-bottom: 1px solid var(--border-glass);
}
.atc-quickbar .chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-strong);
  border: 1px solid var(--border-glass);
  font-size: 0.85rem;
}
.atc-quickbar .chip .remove {
  opacity: 0.7;
  cursor: pointer;
}
.atc-quickbar .chip .remove:hover {
  opacity: 1;
}

/* -------------------- A11y / Reduced Motion --------------------------- */
@media (prefers-reduced-motion: reduce) {
  .offcanvas.settings-drawer,
  .offcanvas.custom-offcanvas,
  .offcanvas.settings-drawer *,
  .offcanvas.custom-offcanvas * {
    transition: none !important;
  }
}

/* -------------------- Utilities --------------------------------------- */
.text-muted-glass {
  color: var(--text-muted) !important;
}
.card-glass {
  background: var(--surface-glass-weak);
  border: 1px solid var(--border-glass);
  color: var(--text-strong);
  border-radius: var(--radius-md);
}

/* Small tweak carried over from PI settings */
.pi-view-settings-card .pi-period-overview-section .timeline-bar {
  margin-top: 0rem;
}

/* =======================================================================
   Excel Filters — Offcanvas (Modern Dark), styled like .custom-offcanvas
   ======================================================================= */

/* Fallback if backdrop-filter unsupported — match your settings.css behavior */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .offcanvas.excel-offcanvas {
    background: #0f274b !important;
  }
}

/* Drawer Surface -------------------------------------------------------- */
.offcanvas.excel-offcanvas {
  --bs-offcanvas-width: min(92vw, 420px);
  width: var(--bs-offcanvas-width) !important;     /* override inline width:auto */

  background: rgba(16, 38, 79, 0.90) !important;
  -webkit-backdrop-filter: blur(18px) saturate(115%);
  backdrop-filter: blur(18px) saturate(115%);

  color: var(--text-strong);
  border-left: 1px solid var(--border-glass);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg) !important;
  box-shadow: var(--elev-3) !important;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s;

  /* Lock to viewport height; inner list scrolls */
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

@media (max-width: 576px) {
  .offcanvas.excel-offcanvas {
    border-radius: 0 !important;
  }
}

/* Header --------------------------------------------------------------- */
.excel-offcanvas .offcanvas-header {
  border-bottom: 1px solid var(--divider-glass);
}
.excel-offcanvas .btn-close {
  filter: invert(1) opacity(0.75);
}
.excel-offcanvas .btn-close:hover {
  opacity: 1;
}

/* Title (matches .custom-offcanvas .offcanvas-title) ------------------- */
.excel-offcanvas .offcanvas-title,
.excel-offcanvas .drawer-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: 0.2px;
}

/* Body layout ---------------------------------------------------------- */
.excel-offcanvas .offcanvas-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  overflow: hidden !important; /* body doesn't scroll; the list will */
}

.excel-offcanvas .drawer-section {
  padding: 8px 12px 0;
}
.excel-offcanvas .glass-panel {
  background: var(--surface-glass-weak);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
}

/* Inputs on glass ------------------------------------------------------ */
.excel-offcanvas .form-control,
.form-control-glass {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}
.excel-offcanvas .form-control::placeholder,
.form-control-glass::placeholder {
  color: var(--text-muted);
}
.excel-offcanvas .form-control:focus,
.form-control-glass:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: rgba(72, 168, 255, 0.65);
}

/* Search + actions row ------------------------------------------------- */
.excel-offcanvas .action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.excel-offcanvas .action-row .spacer {
  flex: 1;
}

/* Search input + leading icon (plain white magnifier) */
.excel-offcanvas .atc-search {
  height: 40px;
  padding-left: 2.25rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}
.excel-offcanvas .atc-search::placeholder {
  color: var(--text-muted);
}
.excel-offcanvas .input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  line-height: 1;
  color: #ffffff;
  opacity: 0.95;
  background: none !important;
  box-shadow: none !important;
  width: auto;
  height: auto;
  pointer-events: none;
  transition: none;
}
.excel-offcanvas .input-icon svg,
.excel-offcanvas .input-icon svg * {
  fill: #ffffff !important;
  stroke: #ffffff !important;
}

/* Ensure buttons in the action row never wrap and match input height ---- */
.excel-offcanvas .action-row .btn {
  white-space: nowrap;
  height: 40px;
  line-height: 24px;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  flex: 0 0 auto;
  min-width: max-content;
}
.excel-offcanvas .action-row .form-control {
  flex: 1 1 auto;
  min-width: 0;
}

/* Checklist ------------------------------------------------------------ */
.excel-offcanvas .atc-checklist .form-check {
  margin-bottom: 0.35rem;
}
.excel-offcanvas .atc-checklist .form-check-label {
  color: var(--text-strong);
}
.excel-offcanvas .atc-checklist .form-check-input {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  box-shadow: none;
}
.excel-offcanvas .atc-checklist .form-check-input:focus {
  box-shadow: var(--focus-ring);
  border-color: rgba(72, 168, 255, 0.65);
}
.excel-offcanvas .atc-checklist .form-check-input:checked {
  background-color: var(--brand-accent);
  border-color: var(--brand-accent);
}

/* The ONLY scroller ---------------------------------------------------- */
.excel-offcanvas .atc-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto !important;
  overscroll-behavior: contain;  /* keep scroll from bubbling to body */
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 4px;
  padding-bottom: calc(var(--settings-footer-h) + 12px) !important;
  scrollbar-gutter: stable;
}

/* Subtle dividers within lists ----------------------------------------- */
.excel-offcanvas .list-group-item {
  background: transparent;
  color: var(--text-strong);
  border-color: var(--divider-glass);
}

/* Sticky Footer (actions) ---------------------------------------------- */
.excel-offcanvas .offcanvas-footer {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  min-height: var(--settings-footer-h);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;

  padding: 12px var(--bs-offcanvas-padding-x, 16px);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));

  margin-left: calc(-1 * var(--bs-offcanvas-padding-x, 16px));
  margin-right: calc(-1 * var(--bs-offcanvas-padding-x, 16px));

  background: rgba(16, 38, 79, 0.94);
  border-top: 1px solid var(--divider-glass);
  z-index: 3;
}

/* Buttons (on-brand, match drawers/modals) ----------------------------- */
.excel-offcanvas .btn-primary {
  background-color: var(--brand-accent);
  border-color: var(--brand-accent);
  font-weight: 600;
}
.excel-offcanvas .btn-primary:hover {
  filter: brightness(1.03);
}
.excel-offcanvas .btn-primary:active {
  filter: brightness(0.97);
}
.excel-offcanvas .btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.excel-offcanvas .btn-ghost,
.excel-offcanvas .btn-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-strong);
}
.excel-offcanvas .btn-ghost:hover,
.excel-offcanvas .btn-cancel:hover {
  background: rgba(255, 255, 255, 0.04);
}

.excel-offcanvas .btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Scrollbar (list) ----------------------------------------------------- */
.excel-offcanvas .atc-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.20) transparent;
}
.excel-offcanvas .atc-list::-webkit-scrollbar {
  width: 10px;
}
.excel-offcanvas .atc-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.excel-offcanvas .atc-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* Back-compat: if markup still uses #atc-options-container, style its scrollbar too */
#atc-options-container::-webkit-scrollbar {
  width: 10px;
}
#atc-options-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}
#atc-options-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
#atc-options-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}
/* -------------------- Toast (compact glass, matches drawers) -------------------- */
/* dbc.Toast puts class on the .toast element itself */
.global-toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2200;

  width: var(--toast-width);
  max-width: var(--toast-width);

  /* Same family as the drawers */
  background: rgba(16, 38, 79, 0.96) !important;
  border: 1px solid var(--border-glass) !important;
  color: var(--text-strong) !important;

  -webkit-backdrop-filter: blur(12px) saturate(120%);
  backdrop-filter: blur(12px) saturate(120%);
  box-shadow: var(--elev-3);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 0 !important;

  /* Scoped tokens */
  --success-500: #1FD1A3;
  --success-500-rgb: 31, 209, 163;
  --toast-title: var(--text-strong);
  --toast-body:  var(--text-muted);

  /* CTA sizing (match drawer CTAs) */
  --cta-h: 40px;
  --cta-line: 24px;
  --cta-radius: 10px;
  --cta-py: .45rem;
  --cta-px: .9rem;

  /* Status dot size */
  --toast-status-size: 12px;/* =====================================================================
   Life Science Pro – Excel-style Filter Offcanvas
   Scope: .pi-filter-offcanvas (ATC class, Distributor, etc.)
   Matches Settings drawer style
   ===================================================================== */

/* Shell --------------------------------------------------------------- */

.pi-filter-offcanvas.offcanvas {
  --bs-offcanvas-width: min(92vw, 460px);

  width: var(--bs-offcanvas-width) !important;
  max-width: var(--bs-offcanvas-width) !important;

  background:
    radial-gradient(140% 180% at 20% 0%, rgba(70, 124, 230, 0.40) 0, transparent 55%),
    radial-gradient(180% 160% at 85% 100%, rgba(33, 210, 204, 0.25) 0, transparent 55%),
    var(--surface-glass);
  color: var(--text-strong);

  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass);
  box-shadow: var(--elev-3);

  -webkit-backdrop-filter: blur(18px) saturate(115%);
  backdrop-filter: blur(18px) saturate(115%);

  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0;
}

@media (max-width: 576px) {
  .pi-filter-offcanvas.offcanvas {
    border-radius: 0;
  }
}

/* Header -------------------------------------------------------------- */

.pi-filter-offcanvas .offcanvas-header {
  padding: 0.85rem 1.4rem;
  border-bottom: 1px solid var(--divider-glass);
}

.pi-filter-offcanvas .offcanvas-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.2px;
  color: var(--text-strong);
}

.pi-filter-offcanvas .btn-close {
  filter: invert(1) opacity(0.8);
}
.pi-filter-offcanvas .btn-close:hover {
  opacity: 1;
}

/* Body layout --------------------------------------------------------- */

.pi-filter-offcanvas .offcanvas-body {
  padding: 0.9rem 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ---------------------------------------------------------------------
   TOP CONTROLS: Search | Select all | Clear
   ------------------------------------------------------------------ */

/* Kill the white “card” wrapper and turn it into a row */
.pi-filter-offcanvas .offcanvas-body > .border-bottom.flex-shrink-0 {
  padding: 0 !important;
  margin: 0 0 0.75rem 0;
  border: 0 !important;
  background: transparent !important;

  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
}

/* Search input group occupies the left side */
.pi-filter-offcanvas
  .offcanvas-body
  > .border-bottom.flex-shrink-0
  > .input-group,
.pi-filter-offcanvas
  .offcanvas-body
  > .border-bottom.flex-shrink-0
  > .dash-input-group {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0 !important;
}

/* Squarish search input (same height family as Settings search) */
.pi-filter-offcanvas input[id$="-search-input"] {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(3, 17, 47, 0.95);
  color: var(--text-strong);
  padding: 0 0.8rem;
  font-size: 0.9rem;
}

.pi-filter-offcanvas input[id$="-search-input"]::placeholder {
  color: var(--text-muted);
  opacity: 0.9;
}

/* Buttons container (Select all / Clear) on the right */
.pi-filter-offcanvas
  .offcanvas-body
  > .border-bottom.flex-shrink-0
  > .mb-3 {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0 !important;
}

/* Base chip/button shape – squarish & fixed height */
.pi-filter-offcanvas
  .offcanvas-body
  > .border-bottom.flex-shrink-0
  .btn {
  width: auto !important;     /* override inline width:100% */
  height: 36px;
  padding: 0 1rem;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 0.9rem;
  box-shadow: none;
}

/* Select all (primary) – like “Save changes” */
.pi-filter-offcanvas .select-all-button {
  background-image: none;
  background-color: var(--brand-accent);
  border: 1px solid rgba(0, 0, 0, 0.45);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

/* Clear filters (secondary) – softer red, matches dark shell */
.pi-filter-offcanvas .btn-outline-danger {
  border-color: rgba(255, 201, 201, 0.8);
  color: rgba(255, 224, 224, 0.96);
  background-color: rgba(16, 38, 79, 0.55);
  font-weight: 500;
}
.pi-filter-offcanvas .btn-outline-danger:hover {
  background-color: rgba(255, 201, 201, 0.22);
  color: #ffe9e9;
}

/* ---------------------------------------------------------------------
   OPTIONS LIST: checklist + “Show all”
   ------------------------------------------------------------------ */

.pi-filter-offcanvas [id$="-options-container"] {
  flex: 1 1 auto;
  margin: 0;
  padding: 0.25rem 0 0.75rem;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Checklist items */
.pi-filter-offcanvas .form-check {
  margin-bottom: 0.45rem;
}
.pi-filter-offcanvas .form-check-label {
  color: var(--text-strong);
  font-weight: 500;
}

/* Bullet / checkbox style (slightly rounded squares → “squarish dot”) */
.pi-filter-offcanvas .form-check-input {
  width: 14px;
  height: 14px;
  margin-top: 0.15rem;
  border-radius: 6px;   /* <-- less round than Settings dot */
  background: var(--surface-glass-weak);
  border: 1px solid var(--border-glass);
  box-shadow: none;
}

.pi-filter-offcanvas .form-check-input:focus {
  box-shadow: var(--focus-ring);
  border-color: rgba(72, 168, 255, 0.75);
}

.pi-filter-offcanvas .form-check-input:checked {
  background-color: var(--brand-accent);
  border-color: var(--brand-accent);
}

/* “Show all” button under the list */
.pi-filter-offcanvas .show-all-button {
  width: 100% !important;
  margin-top: 0.75rem;
  height: 32px;
  border-radius: 10px;
  background-color: rgba(6, 22, 55, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------
   FOOTER / APPLY BUTTON
   ------------------------------------------------------------------ */

.pi-filter-offcanvas .offcanvas-body > .p-3:last-child {
  margin-top: auto;
  padding: 0.75rem 0 0.25rem;
  border-top: 1px solid var(--divider-glass);
  background:
    linear-gradient(180deg, rgba(5, 18, 46, 0.96), rgba(2, 8, 26, 1));
}

/* Apply button – full width, same weight as Settings CTA */
.pi-filter-offcanvas .offcanvas-body .btn[id$="-apply"] {
  display: block;
  width: 100%;
  height: 40px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  background-color: var(--brand-accent);
  border-color: rgba(0, 0, 0, 0.55);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6);
  color: #ffffff;
}

/* Remove the extra margin added in the Python layout */
.pi-filter-offcanvas .offcanvas-body .btn[id$="-apply"].mt-2 {
  margin-top: 0;
}

  --toast-status-radius: 6px;
}

/* Header – same weight as drawer headers */
.global-toast .toast-header {
  background: rgba(16, 38, 79, 0.98) !important;
  color: var(--toast-title) !important;
  border-bottom: 1px solid var(--divider-glass) !important;
  font-weight: 600;
  letter-spacing: .18px;
  padding: .55rem .9rem;
  align-items: center;
}

/* Body */
.global-toast .toast-body {
  background: rgba(16, 38, 79, 0.96) !important;
  color: var(--toast-body) !important;
  padding: .7rem .9rem .85rem;
  font-size: .95rem;
  line-height: 1.4;
}

/* Actions row */
.global-toast .toast-actions {
  display: flex;
  gap: 8px;
  margin-top: .55rem;
}

/* Buttons inside toast — normalize .btn & .btn-sm to drawer CTA size */
.global-toast .btn,
.global-toast .btn-sm {
  height: var(--cta-h) !important;
  line-height: var(--cta-line) !important;
  padding: var(--cta-py) var(--cta-px) !important;
  border-radius: var(--cta-radius) !important;
  font-weight: 600 !important;
  font-size: .95rem !important;
  white-space: nowrap;
  box-shadow: none !important;
}

/* Primary (“Undo”) — same recipe as app primary CTA */
.global-toast .btn-primary {
  background-color: var(--brand-accent) !important;
  border-color: var(--brand-accent) !important;
  color: #fff !important;
}
.global-toast .btn-primary:hover {
  filter: brightness(1.03);
}
.global-toast .btn-primary:active {
  filter: brightness(0.97);
}
.global-toast .btn-primary:focus-visible {
  outline: none !important;
  box-shadow: var(--focus-ring) !important;
}

/* Secondary (“Manage codes”) — ghost style like drawer buttons */
.global-toast .btn-outline-primary {
  color: var(--text-strong) !important;
  background: transparent !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
}
.global-toast .btn-outline-primary:hover {
  background: rgba(255, 255, 255, 0.04) !important;
}
.global-toast .btn-outline-primary:focus-visible {
  outline: none !important;
  box-shadow: var(--focus-ring) !important;
}

/* Success status: teal dot, minimal but on the same navy shell */
.global-toast,
.global-toast .toast-header {
  --bs-success: var(--success-500);
  --bs-success-rgb: var(--success-500-rgb);
}

/* Generic badge (covers bg-success/text-bg-success/rounded variants) */
.global-toast .toast-header .bg-success,
.global-toast .toast-header .text-bg-success,
.global-toast .toast-header .rounded,
.global-toast .toast-header [class*="bg-success"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin-right: .5rem !important;
  border-radius: 50%;
  background-color: var(--success-500) !important;
  border: 0 !important;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23ffffff' d='M6.03 10.97 3.53 8.47a.75.75 0 1 1 1.06-1.06l1.44 1.44 4.88-4.88a.75.75 0 1 1 1.06 1.06L7.56 10.97a.75.75 0 0 1-1.06 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 11px 11px;
}

/* Close affordance (soft blue → white on hover) */
.global-toast .btn-close {
  opacity: 1 !important;
  filter: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%239EC5FF' viewBox='0 0 16 16'%3E%3Cpath d='M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 1 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E") !important;
  background-size: 1em 1em;
  background-position: center;
  background-repeat: no-repeat;
}
.global-toast .btn-close:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23F4F7FF' viewBox='0 0 16 16'%3E%3Cpath d='M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 1 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E") !important;
}
/* Make the module title feel like a label */
.pi-view-settings-card .pi-module-title {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.85rem;
  font-weight: 600;
}

.pi-page-root #pi-timeline-header-status {
  font-size: 0.95rem;   /* slightly smaller than .small */
  line-height: 1.2;
    font-weight: 400;
      color: var(--gray-700) !important;  /* slightly darker than Bootstrap's muted */
}
.pi-page-root .pi-since-period-label {
  font-size: 0.95rem;
  line-height: 1.2;
    font-weight: 400;
  color: var(--gray-700) !important;
}
/* Space between name and badge */
.ag-cell .pack-name {
  margin-right: 0.25rem;
}

/* Generic pill style */
.ag-cell .status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0 0.4rem;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.4;
  margin-left: 0.25rem;
  white-space: nowrap;
}

/* Variants (tweak colors to match COL_* constants) */
.ag-cell .status-pill--new {
  background-color: #e6f6ec;
  color: #0f5132;
}

.ag-cell .status-pill--back {
  background-color: #e7f1ff;
  color: #0b3c74;
}

.ag-cell .status-pill--disc {
  background-color: #fde2e2;
  color: #842029;
}

.ag-cell .status-pill--inc {
  background-color: #fff3cd;
  color: #854d0e;
}

.ag-cell .status-pill--dec {
  background-color: #e0f2ff;
  color: #1d4ed8;
}
#pi-tabs .nav-link.active {
    background-color: #fafafa !important;        /* soft white, not yellow */

    border: 1px solid #e2e8f0 !important;        /* cool, subtle outline */
    border-bottom-color: #fafafa !important;     /* blend into body */
}
/* INACTIVE TABS — match the active tab’s aesthetic */
#pi-tabs .nav-link:not(.active) {
    background-color: #f5f7fa !important;    /* soft cool-grey that pairs with #fafafa */
    color: #6b7280 !important;               /* muted text */
    border: 1px solid transparent !important;
    border-radius: 0.6rem 0.6rem 0 0;
}

/* Hover state — subtle, still minimal */
#pi-tabs .nav-link:not(.active):hover {
    background-color: #f0f3f7 !important;    /* tiny lift on hover */
    color: #374151 !important;
}
/* Make the tab card float more than the header card */
.pi-tab-card.shadow-sm {
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08) !important;
}

/* Outer shells: header card + tab card -> same rounding */
.pi-view-settings-card,
.pi-view-settings-card .card-header,
.pi-tab-card,
.pi-tab-card-header {
  border-radius: 10px !important;
}

/* Inner tinted panels: header body + tab tray -> same rounding */
.pi-view-settings-card .card-body,
.pi-tab-bodies {
  border-radius: 8px !important;
}
/* Make custom card headers follow the card's rounding */
.card > .custom-card-header {
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

/* Ensure the body below the header doesn't add extra rounding */
.card > .custom-card-header + .card-body {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
/* TAB STRIP – pull it up so the active tab lines up with the card radius */
#pi-tabs {
    background: transparent;
    border-bottom: 1px solid #e5e7eb;
    padding: 0;
    margin-top: -0.25rem;              /* tweak this value (-0.2 to -0.4rem) if needed */
}

/* BASE TAB ------------------------------------------------------------ */
#pi-tabs .nav-link {
    position: relative;
    padding: 0.3rem 0.9rem !important;
    margin-right: 0.25rem;

    background: transparent !important;
    border: none !important;

    border-radius: 0.5rem 0.5rem 0 0 !important;   /* rounded top, square bottom */

    font-size: 0.9rem;
    font-weight: 500;
    color: #6b7280 !important;

    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        box-shadow 0.15s ease;
}

/* ACTIVE TAB ---------------------------------------------------------- */
#pi-tabs .nav-link.active {
    background: #f4f6fa !important;               /* soft grey, not pure white */
    color: #2563eb !important;
    font-weight: 600;

    border-radius: 0.5rem 0.5rem 0 0 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* HOVER (inactive) ---------------------------------------------------- */
#pi-tabs .nav-link:not(.active):hover {
    background: rgba(148,163,184,0.12) !important;
    color: #374151 !important;
}

/* FOCUS --------------------------------------------------------------- */
#pi-tabs .nav-link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
/* TAB STRIP – applies to all tab bars */
.nav-tabs {
    background: transparent;
    border-bottom: 1px solid #e5e7eb;
    padding: 0;
    margin-top: -0.25rem;                      /* tweak per layout if needed */
}

/* BASE TAB ------------------------------------------------------------ */
.nav-tabs .nav-link {
    position: relative;
    padding: 0.3rem 0.9rem !important;
    margin-right: 0.25rem;

    background: transparent !important;
    border: 1px solid transparent !important;  /* <- keeps outline logic working */
    border-radius: 0.5rem 0.5rem 0 0 !important;   /* rounded top, square bottom */

    font-size: 0.9rem;
    font-weight: 500;
    color: #6b7280 !important;

    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        box-shadow 0.15s ease,
        border-color 0.15s ease;
}

/* ACTIVE TAB ---------------------------------------------------------- */
.nav-tabs .nav-link.active {
    background: #f4f6fa !important;
    color: #2563eb !important;
    font-weight: 600;

    border-color: #d1d5db !important;          /* <- subtle grey outline */
    border-bottom-color: #f4f6fa !important;   /* blend into content/header */
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* HOVER (inactive) ---------------------------------------------------- */
.nav-tabs .nav-link:not(.active):hover {
    background: rgba(148,163,184,0.12) !important;
    color: #374151 !important;
    border-color: #e5e7eb !important;          /* light outline on hover */
}

/* FOCUS --------------------------------------------------------------- */
.nav-tabs .nav-link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
/* Add to your z_price_intelligence.css or similar */

/* Locked filter badges - subtle, non-interactive appearance */
.pi-view-section--filters .btn[disabled],
.pi-view-section--filters .btn.locked-filter {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    cursor: default;
    opacity: 1;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    box-shadow: none;
}

.pi-view-section--filters .btn[disabled]:hover,
.pi-view-section--filters .btn.locked-filter:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    transform: none;
}


.pi-breadcrumb .breadcrumb { font-size: 0.8rem; margin-bottom: 0; }
.pi-breadcrumb .breadcrumb-item a { color: #6c757d; text-decoration: none; }
.pi-breadcrumb .breadcrumb-item a:hover { text-decoration: underline; }
.pi-breadcrumb .breadcrumb-item.active { color: #495057; }
/* Only top navbar, if you add .app-navbar to it */
.app-navbar .navbar-nav .nav-link {
  color: rgba(255,255,255,.75);
}

.app-navbar .navbar-nav .nav-link.active {
  color: #fff;
  font-weight: 600;
  border-bottom: 2px solid rgba(255,255,255,.9);
}


.headerToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 12px;               /* creates breathing room above divider */
  border-bottom: 1px solid var(--border-subtle);
}

.legendRow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 6px;                /* a little tighter than toolbar */
  /* optional: give it a “strip” feel */
  background: var(--surface-subtle);  /* very light */
  border-radius: 8px;
  padding-left: 8px;
  padding-right: 8px;
  margin-top: 10px;                   /* separates it from divider */
}
.shhist-toolbar-sep{
  height: 0; /* divider only */
  border-top: 1px solid rgba(0,0,0,.06);
  margin: .5rem 0 .25rem 0;  /* space above/below divider */
}

.legendLabel {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 6px;
}
