/* =====================================================================
   Launch Curves — app-specific layout.
   Brand tokens, resets, typography primitives, buttons, inputs, chips,
   the segmented control and scrollbars all come from the shared design
   system at /assets/shared/psi-design.css. Keep only layout here.
   ===================================================================== */

input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.loading,
.empty {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--psi-muted);
  font-weight: 600;
}

/* ---------- Shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 300px;
  max-width: 300px;
  min-width: 0;
  height: 100vh;
  padding: var(--s-6) var(--s-5);
  background: var(--psi-surface);
  border-right: 1px solid var(--psi-border);
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
}

.brand {
  display: grid;
  align-items: start;
  gap: var(--s-3);
  margin-bottom: var(--s-7);
}

.brand-logo {
  width: min(186px, 100%);
  height: auto;
}

.brand h1 {
  margin: 0;
  color: var(--psi-navy);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 0;
  color: var(--psi-muted);
  font-size: 13px;
  line-height: 1.45;
}

/* ---------- Filters ---------- */
.filter-group {
  display: grid;
  gap: var(--s-5);
  min-width: 0;
}

.field {
  display: grid;
  gap: var(--s-2);
  min-width: 0;
}

.field span,
.meta-block span,
.kpi span {
  color: var(--psi-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field select {
  width: 100%;
  min-height: 40px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--psi-border-strong);
  border-radius: var(--r-sm);
  background: var(--psi-surface);
  color: var(--psi-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.field select:focus,
.range-row input:focus {
  outline: none;
  border-color: var(--psi-blue);
  box-shadow: var(--ring);
}

.multi-field {
  gap: var(--s-2);
}

.multi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.multi-head button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--psi-border-strong);
  border-radius: var(--r-xs);
  background: var(--psi-surface);
  color: var(--psi-text-soft);
  font-size: 12px;
  font-weight: 600;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}

.multi-head button:hover:not(:disabled) {
  border-color: var(--psi-steel);
  background: var(--psi-surface-2);
  color: var(--psi-navy);
}

.multi-head button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.multi-box {
  display: grid;
  width: 100%;
  min-width: 0;
  max-height: calc(var(--visible-rows, 6) * 34px);
  overflow-y: auto;
  border: 1px solid var(--psi-border);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  background: var(--psi-surface-2);
}

.combo-shell {
  display: grid;
  min-width: 0;
}

.combo-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--psi-border-strong);
  border-bottom: 0;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--psi-surface);
}

.combo-input-row input {
  width: 100%;
  min-width: 0;
  height: 39px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm) 0 0 0;
  background: transparent;
  color: var(--psi-text);
}

.combo-input-row input:focus {
  outline: none;
}

.combo-shell:focus-within .combo-input-row {
  border-color: var(--psi-blue);
  box-shadow: var(--ring);
}

.combo-input-row strong {
  display: grid;
  min-width: 28px;
  max-width: 38px;
  height: 24px;
  place-items: center;
  justify-self: center;
  border-radius: var(--r-pill);
  background: var(--psi-mist);
  color: var(--psi-navy);
  font-size: 12px;
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding: var(--s-2);
  border-right: 1px solid var(--psi-border-strong);
  border-left: 1px solid var(--psi-border-strong);
  background: var(--psi-surface);
}

.selected-chips button,
.selected-chips span {
  min-width: 0;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid var(--psi-border-strong);
  border-radius: var(--r-pill);
  background: var(--psi-mist);
  color: var(--psi-navy);
  font-size: 12px;
  font-weight: 600;
}

.selected-chips button {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.selected-chips button:hover {
  border-color: var(--psi-steel);
  background: #dce8f2;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center;
  gap: var(--s-3);
}

.range-row strong {
  color: var(--psi-navy);
  font-size: 18px;
  line-height: 1;
  text-align: right;
}

.range-row input {
  accent-color: var(--psi-blue);
}

.range-field {
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-md);
  background: var(--psi-surface-2);
}

.meta-block {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-5);
  padding: var(--s-4);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-md);
  background: var(--psi-surface-2);
}

.meta-block strong {
  color: var(--psi-text);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Sidebar utility / drawer buttons ---------- */
.drawer-head button,
.utility-button {
  min-height: 32px;
  border: 1px solid var(--psi-border-strong);
  border-radius: var(--r-sm);
  background: var(--psi-surface);
  color: var(--psi-text-soft);
  font-weight: 600;
  transition:
    transform var(--t-fast),
    box-shadow var(--t-fast),
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast);
}

.drawer-head button:hover {
  border-color: var(--psi-steel);
  background: var(--psi-surface-2);
  color: var(--psi-navy);
}

.utility-button {
  padding: 0 16px;
  background: linear-gradient(180deg, var(--psi-blue) 0%, var(--psi-navy) 100%);
  border-color: var(--psi-navy-dark);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.utility-button:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.utility-button:active {
  transform: translateY(1px);
}

.check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  min-height: 34px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--psi-border);
  color: var(--psi-text-soft);
  font-size: 13px;
  transition: background var(--t-fast);
}

.check-row:hover {
  background: var(--psi-surface);
}

.check-row:last-child {
  border-bottom: 0;
}

.check-row input {
  accent-color: var(--psi-blue);
}

.check-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-options {
  min-height: 42px;
  padding: var(--s-3);
  color: var(--psi-muted);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Content ---------- */
.content {
  min-width: 0;
  padding: var(--s-7) var(--s-7) var(--s-8);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}

.eyebrow {
  margin: 0 0 var(--s-2);
  color: var(--psi-blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.page-header h1 {
  margin: 0;
  color: var(--psi-navy);
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.06;
}

.status-pill {
  min-width: 74px;
  padding: 8px 14px;
  border: 1px solid var(--psi-border-strong);
  border-radius: var(--r-pill);
  background: var(--psi-mist);
  color: var(--psi-navy);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* ---------- KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}

.kpi {
  display: grid;
  gap: var(--s-2);
  min-height: 92px;
  padding: var(--s-4);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-lg);
  background: var(--psi-surface);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi strong {
  align-self: end;
  color: var(--psi-navy);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* ---------- Toolbar ---------- */
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}

.toolbar-row > span {
  color: var(--psi-muted);
  font-size: 13px;
  font-weight: 600;
}

.segment-control {
  display: inline-grid;
  grid-template-columns: repeat(var(--segment-count, 2), minmax(96px, 1fr));
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--psi-border);
  border-radius: var(--r-md);
  background: var(--psi-surface-3);
}

.segment-control button {
  min-height: 32px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--psi-muted);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}

.segment-control button:hover {
  color: var(--psi-navy);
}

.segment-control button.active {
  background: var(--psi-surface);
  color: var(--psi-navy);
  box-shadow: var(--shadow-xs);
}

/* ---------- Panels ---------- */
.chart-panel,
.table-panel {
  margin-bottom: var(--s-5);
  padding: var(--s-5) var(--s-5) var(--s-3);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-lg);
  background: var(--psi-surface);
  box-shadow: var(--shadow-sm);
}

.chart-panel h2,
.table-panel h2 {
  margin: 0;
  color: var(--psi-navy);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Methods ---------- */
.methods-panel {
  display: grid;
  gap: var(--s-4);
}

.methods-hero,
.method-card {
  padding: var(--s-5);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-lg);
  background: var(--psi-surface);
  box-shadow: var(--shadow-sm);
}

.methods-hero h2,
.method-card h3 {
  margin: 0;
  color: var(--psi-navy);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.methods-hero h2 {
  font-size: 26px;
}

.methods-hero p {
  max-width: 900px;
  margin: var(--s-3) 0 0;
  color: var(--psi-text-soft);
  line-height: 1.6;
}

.methods-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: var(--s-4);
}

.methods-grid.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.method-card {
  display: grid;
  align-content: start;
  gap: var(--s-4);
}

.source-list,
.method-stats,
.method-list,
.count-strip {
  margin: 0;
}

.source-list {
  display: grid;
  gap: var(--s-3);
}

.source-row {
  display: grid;
  gap: 5px;
  padding: var(--s-3);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-md);
  background: var(--psi-surface-2);
}

.source-row strong,
.method-stats dd,
.count-strip strong {
  color: var(--psi-navy);
}

.source-row span,
.source-row small,
.method-stats dt,
.count-strip span {
  color: var(--psi-muted);
}

.source-row code {
  width: max-content;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: var(--r-xs);
  background: var(--psi-mist);
  color: var(--psi-text-soft);
  overflow-wrap: anywhere;
}

.method-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

.method-stats div,
.count-strip div {
  padding: var(--s-3);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-md);
  background: var(--psi-surface-2);
}

.method-stats dt,
.count-strip span {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.method-stats dd {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 700;
}

.method-list {
  display: grid;
  gap: var(--s-3);
  padding-left: 22px;
  color: var(--psi-text-soft);
  line-height: 1.55;
}

.count-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--s-3);
}

.count-strip div {
  display: grid;
  gap: var(--s-2);
}

.count-strip strong {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

/* ---------- Plots ---------- */
.plot {
  width: 100%;
  height: 430px;
}

.heatmap-panel .plot {
  height: 620px;
}

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1380px;
  border-collapse: collapse;
  margin-top: var(--s-3);
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--psi-border);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--psi-surface);
  color: var(--psi-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  color: var(--psi-text-soft);
  font-size: 14px;
}

.clickable-row {
  cursor: pointer;
  transition: background var(--t-fast);
}

.clickable-row:hover td {
  background: var(--psi-surface-2);
}

/* ---------- Detail drawer ---------- */
.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  display: grid;
  align-content: start;
  gap: var(--s-5);
  width: min(440px, 100vw);
  height: 100vh;
  padding: var(--s-6);
  border-left: 1px solid var(--psi-border);
  background: var(--psi-surface);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  animation: psi-fade-in var(--t-med);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
}

.drawer-head span,
.submed-block span {
  color: var(--psi-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.drawer-head h2 {
  margin: 4px 0 0;
  color: var(--psi-navy);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.drawer-head button {
  padding: 0 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  margin: 0;
}

.detail-grid div {
  min-height: 78px;
  padding: var(--s-3);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-md);
  background: var(--psi-surface-2);
}

.detail-grid dt {
  color: var(--psi-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 7px 0 0;
  color: var(--psi-navy);
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.submed-block {
  display: grid;
  gap: var(--s-3);
}

.submed-block div {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.submed-block strong {
  padding: 7px 10px;
  border-radius: var(--r-pill);
  background: var(--psi-mist);
  color: var(--psi-navy);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: auto;
    max-width: none;
    height: auto;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .methods-grid,
  .methods-grid.two-column,
  .count-strip {
    grid-template-columns: 1fr;
  }

  .detail-drawer {
    width: min(380px, 100vw);
  }
}

@media (max-width: 620px) {
  .content {
    padding: var(--s-4);
  }

  .page-header {
    display: grid;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .plot {
    height: 340px;
  }

  .toolbar-row {
    align-items: stretch;
    flex-direction: column;
  }

  .segment-control {
    width: 100%;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
