/* ══════════════════════════════════════════════════════════════════════
   DataPoint EXPAND LAYER — shared styles for the one reusable
   expand / drill-through component (expand-layer.js).
   Cloud UI: pill buttons, 16px rounded modal, soft diffuse shadows.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Expand affordance (injected by expand-layer.js) ───────────────────── */
.xl-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text-tertiary, #64748b);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s, opacity 0.15s;
}
.xl-expand-btn:hover {
  color: var(--accent-600, #2563eb);
  border-color: var(--accent-200, #bfdbfe);
  background: var(--accent-50, #eff6ff);
}
.xl-expand-btn svg { display: block; }

/* On KPI cards the button floats top-right and appears on hover
   (Power BI style); .xl-host supplies the positioning context. */
.xl-host { position: relative; }
.xl-host > .xl-expand-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  opacity: 0;
  z-index: 2;
}
.xl-host:hover > .xl-expand-btn,
.xl-host:focus-within > .xl-expand-btn { opacity: 1; }

/* ── Modal overlay ─────────────────────────────────────────────────────── */
.xl-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;                      /* above sticky sidebar + fixed ta-multi menus */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
}
.xl-backdrop.is-open { display: flex; }

.xl-modal {
  width: min(1180px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}

.xl-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle, #e2e8f0);
  flex-shrink: 0;
}
.xl-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  letter-spacing: -0.01em;
  margin: 0;
}
.xl-modal-sub {
  font-size: 12px;
  color: var(--text-tertiary, #64748b);
  margin: 1px 0 0;
}
.xl-modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.xl-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 999px;
  background: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #475569);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.xl-modal-btn:hover {
  color: var(--accent-600, #2563eb);
  border-color: var(--accent-200, #bfdbfe);
  background: var(--accent-50, #eff6ff);
}

.xl-modal-body {
  padding: 20px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

/* The moved-in host fills the modal cleanly: its own card chrome (shadow,
   margins) is redundant inside the modal card. */
.xl-modal-body > .xl-expanded {
  box-shadow: none !important;
  margin: 0 !important;
  width: 100%;
}
/* Hide the (now-pointless) expand affordance while expanded. */
.xl-expanded .xl-expand-btn { display: none; }

/* Focus-mode sizing: known chart containers grow to study size while
   expanded. Heights are viewport-relative so the canvas redraw (via each
   chart's own ResizeObserver) fills the modal. */
.xl-modal-body .ratios-chart-canvas { height: 56vh; }
.xl-modal-body .ratios-chart-canvas-sm { height: 50vh; }
.xl-modal-body .composition-donut { max-width: 380px; }
.xl-modal-body .chart-canvas-wrap,
.xl-modal-body .chart-container,
.xl-modal-body .chart-container-tall,
.xl-modal-body .ta-chart-container,
.xl-modal-body .chart-wrap,
.xl-modal-body .fa-chart-canvas,
.xl-modal-body [class$="-chart-body"] { height: 56vh; }
.xl-modal-body .fa-donut-wrap { max-width: 380px; }

/* ── KPI drill-through detail (mock; appended inside the modal) ────────── */
.xl-detail {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle, #e2e8f0);
}
.xl-detail-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary, #64748b);
  margin: 0 0 10px;
}
.xl-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.xl-detail-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #64748b);
  background: var(--slate-50, #f8fafc);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle, #e2e8f0);
}
.xl-detail-table th:not(:first-child),
.xl-detail-table td:not(:first-child) { text-align: right; }
.xl-detail-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--slate-100, #f1f5f9);
  color: var(--text-primary, #0f172a);
}
.xl-detail-table tr:last-child td { border-bottom: none; }
.xl-detail-up   { color: var(--danger-600,  #dc2626); font-weight: 700; }   /* cost lens: rising = red */
.xl-detail-down { color: var(--success-600, #16a34a); font-weight: 700; }
.xl-detail-note {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
}

/* ── Inline row drill-down (e.g. Staffing Breakdown unit → departments) ── */
.xl-drill-row { cursor: pointer; }
.xl-drill-row.is-drilled { background: var(--slate-50, #f8fafc); }
.xl-row-detail {
  background: var(--slate-50, #f8fafc);
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 2px 0 10px;
}
.xl-row-detail-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary, #64748b);
  margin: 0 0 10px;
}
.xl-row-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.xl-row-detail-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--slate-100, #f1f5f9);
  border-radius: 8px;
}
.xl-row-detail-dept {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #64748b);
}
.xl-row-detail-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  flex-shrink: 0;
}
.xl-row-detail-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  font-variant-numeric: tabular-nums;
}
.xl-row-detail-sub {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  font-variant-numeric: tabular-nums;
}
