/* Custom report studio — list + large modal + accordion */
.crs-home,
.crs-modal {
  --crs-ink: #1c1917;
  --crs-muted: #78716c;
  --crs-line: #e7e5e4;
  --crs-surface: #fff;
  --crs-tint: #fafaf9;
  --crs-accent: #0f766e;
  --crs-accent-soft: #ccfbf1;
  --crs-warn: #b45309;
  --crs-shadow: 0 24px 64px rgba(28, 25, 23, .18);
  direction: rtl;
  font-family: inherit;
}

.crs-home {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: .15rem 0 .5rem;
}

.crs-home__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: .85rem 1.25rem;
}

.crs-home__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 750;
  color: var(--crs-ink);
  letter-spacing: -.01em;
}

.crs-home__desc {
  margin: .4rem 0 0;
  color: var(--crs-muted);
  font-size: .9rem;
  line-height: 1.55;
  max-width: 36rem;
}

.crs-intent-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .55rem;
}

.crs-intent-badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  background: #eef2f7;
  color: #334155;
  border: 1px solid #dbe3ee;
}

.crs-intent-badge--surface {
  background: #ecfeff;
  border-color: #a5f3fc;
  color: #0e7490;
}

.crs-intent-badge--list {
  background: #f1f5f9;
  color: #475569;
}

.crs-intent-badge--agg {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.crs-intent-warn {
  margin: .45rem 0 0;
  font-size: .8rem;
  color: #b45309;
  line-height: 1.45;
}

.crs-home__list {
  border: 1px solid var(--crs-line);
  border-radius: 16px;
  background: var(--crs-surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.crs-home__tabs {
  display: flex;
  gap: .3rem;
  padding: .55rem .65rem;
  border-bottom: 1px solid var(--crs-line);
  background: #f8fafc;
}

.crs-home__tab {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border: 0;
  border-radius: 10px;
  padding: .5rem .95rem;
  font: inherit;
  font-weight: 650;
  color: #64748b;
  background: transparent;
  cursor: pointer;
}

.crs-home__tab.is-active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
  border: 1px solid rgba(148, 163, 184, .28);
}

.crs-home__tab-count {
  display: inline-flex;
  min-width: 1.4rem;
  justify-content: center;
  padding: .05rem .4rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: rgba(15, 23, 42, .08);
  color: inherit;
}

.crs-home__tab.is-active .crs-home__tab-count {
  background: rgba(13, 148, 136, .14);
  color: #0f766e;
}

.crs-home__empty {
  display: grid;
  place-items: center;
  gap: .35rem;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--crs-muted);
}

.crs-home__empty--filtered {
  gap: .55rem;
}

.crs-home__empty strong {
  color: var(--crs-ink);
  font-size: 1rem;
}

.crs-table-wrap--home {
  max-height: none;
  border: 0;
  border-radius: 0;
}

.crs-table--filterable thead th {
  vertical-align: bottom;
}

.crs-table__filters th {
  background: #f8fafc;
  padding: .45rem .55rem;
  font-weight: 500;
}

.crs-table__filter {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: .8rem;
  padding: .4rem .55rem;
}

.crs-table__filter:focus {
  outline: none;
  border-color: rgba(13, 148, 136, .55);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .12);
}

.crs-table__filters-actions {
  white-space: nowrap;
}

.crs-btn--sm {
  padding: .35rem .55rem !important;
  font-size: .8rem !important;
}

.crs-chip {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--crs-tint);
  border: 1px solid var(--crs-line);
  font-size: .78rem;
  font-weight: 650;
  color: var(--crs-ink);
}

/* Modal */
.crs-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: .75rem;
}

.crs-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, .45);
  backdrop-filter: blur(2px);
}

.crs-modal__panel {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  height: min(96vh, 980px);
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  background: var(--crs-surface);
  border-radius: 20px;
  border: 1px solid var(--crs-line);
  box-shadow: var(--crs-shadow);
  overflow: hidden;
  animation: crs-pop .22s ease-out;
}

@keyframes crs-pop {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.crs-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem .85rem;
  background:
    linear-gradient(135deg, #f0fdfa 0%, #fff 42%, #fafaf9 100%);
  border-bottom: 1px solid var(--crs-line);
}

.crs-modal__header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--crs-ink);
}

.crs-modal__header p {
  margin: .35rem 0 0;
  color: var(--crs-muted);
  font-size: .86rem;
}

.crs-modal__close {
  border: 0;
  background: #fff;
  border: 1px solid var(--crs-line);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 10px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: var(--crs-muted);
}

.crs-modal__close:hover {
  color: var(--crs-ink);
  background: var(--crs-tint);
}

.crs-modal__meta {
  display: grid;
  grid-template-columns: 1.4fr .9fr;
  gap: .75rem 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--crs-line);
  background: #fff;
}

@media (max-width: 720px) {
  .crs-modal__meta { grid-template-columns: 1fr; }
}

.crs-modal__alert {
  margin: .75rem 1.25rem 0;
}

.crs-modal__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1.1rem 1.35rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(180deg, #fafaf9 0%, #fff 28%);
}

.crs-tabs {
  display: flex;
  gap: .35rem;
  padding: .2rem;
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  background: #f5f5f4;
  flex: 0 0 auto;
}

.crs-tab {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: .65rem 1rem;
  font: inherit;
  font-weight: 600;
  color: #57534e;
  background: transparent;
  cursor: pointer;
}

.crs-tab.is-active {
  background: #fff;
  color: #1c1917;
  box-shadow: 0 1px 2px rgba(28, 25, 23, .08);
}

.crs-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.crs-chart-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem 1rem;
}

@media (max-width: 900px) {
  .crs-chart-form {
    grid-template-columns: 1fr;
  }
}

.crs-chart-preview {
  border: 1px solid var(--crs-line);
  border-radius: 14px;
  background: #fff;
  padding: 1rem 1.1rem;
}

.crs-chart-preview__title {
  margin: 0 0 .75rem;
  font-size: 1rem;
}

.crs-kpi-card {
  border: 1px solid var(--crs-line, #e7e5e4);
  border-radius: 14px;
  background: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.crs-visual-subtabs {
  display: flex;
  gap: .35rem;
  margin: 0 0 1rem;
  padding: .25rem;
  border-radius: 12px;
  background: #f1f5f9;
  border: 1px solid var(--crs-line, #e7e5e4);
}

.crs-visual-subtab {
  flex: 1;
  border: 0;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-weight: 600;
  padding: .55rem .75rem;
  border-radius: 10px;
  cursor: pointer;
}

.crs-visual-subtab.is-active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.crs-kpi-card--live {
  position: relative;
  overflow: hidden;
  min-height: 140px;
  border-color: color-mix(in srgb, var(--crs-kpi-accent, #2dd4bf) 35%, #e7e5e4);
}

.crs-kpi-grid {
  display: grid;
  grid-template-columns: repeat(var(--crs-kpi-cols, auto-fit), minmax(160px, 1fr));
  gap: .75rem;
}

.crs-kpi-grid:not([style*="--crs-kpi-cols"]) {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.crs-chart-preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  margin-bottom: .55rem;
}

.crs-chart-preview__title { margin: 0; }

.crs-preview-settings-btn {
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  color: #475569;
  border-radius: 10px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
}

.crs-preview-settings-btn:hover {
  border-color: #93c5fd;
  color: #0f172a;
}

.crs-table-wrap[style*="--crs-table-cols"] .crs-table {
  min-width: calc(var(--crs-table-cols, 1) * 7rem);
}

.crs-field--actions .crs-inline-actions {
  margin-top: 0;
}

.crs-table-col-row__title {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

.crs-badge {
  display: inline-flex;
  align-items: center;
  font-size: .7rem;
  font-weight: 700;
  padding: .12rem .4rem;
  border-radius: 999px;
  letter-spacing: 0;
}

.crs-badge--group {
  color: #1d4ed8;
  background: #dbeafe;
}

.crs-badge--agg {
  color: #b45309;
  background: #ffedd5;
}

.crs-badge--formula {
  color: #6d28d9;
  background: #ede9fe;
}

.crs-badge--hidden {
  color: #78716c;
  background: #f5f5f4;
}

.crs-field-hint {
  margin: .2rem 0 .45rem;
  font-size: .78rem;
}

.crs-field-hint--err {
  color: #b91c1c;
}

.crs-btn--accent {
  background: #0f766e;
  color: #fff;
  border-color: #0f766e;
}

.crs-btn--accent:disabled {
  opacity: .45;
}

.crs-col-bucket {
  border-radius: 14px;
  padding: .65rem .7rem .75rem;
  margin: 0 0 .75rem;
  border: 1px solid transparent;
}

.crs-col-bucket__head {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0 0 .55rem;
  font-size: .86rem;
}

.crs-col-bucket__dot {
  width: .55rem;
  height: .55rem;
  border-radius: 999px;
  flex: 0 0 auto;
}

.crs-col-bucket__count {
  margin-inline-start: auto;
  font-size: .72rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, .06);
  color: #475569;
}

.crs-col-bucket--group {
  background: linear-gradient(165deg, #eff6ff 0%, #f8fbff 100%);
  border-color: #bfdbfe;
}

.crs-col-bucket--group .crs-col-bucket__dot { background: #3b82f6; }

.crs-col-bucket--measure {
  background: linear-gradient(165deg, #fff7ed 0%, #fffdf9 100%);
  border-color: #fed7aa;
}

.crs-col-bucket--measure .crs-col-bucket__dot { background: #f59e0b; }

.crs-col-bucket--plain {
  background: linear-gradient(165deg, #f8fafc 0%, #ffffff 100%);
  border-color: #e2e8f0;
}

.crs-col-bucket--plain .crs-col-bucket__dot { background: #94a3b8; }

.crs-col-bucket--computed {
  background: linear-gradient(165deg, #f5f3ff 0%, #faf9ff 100%);
  border-color: #ddd6fe;
}

.crs-col-bucket--computed .crs-col-bucket__dot { background: #8b5cf6; }

.crs-col-bucket .crs-table-col-row {
  background: rgba(255, 255, 255, .82);
  margin-bottom: .4rem;
}

.crs-col-bucket .crs-table-col-row:last-child {
  margin-bottom: 0;
}

.crs-formula-studio {
  display: grid;
  grid-template-columns: minmax(11rem, 1fr) minmax(14rem, 1.25fr);
  gap: .9rem;
  margin: .35rem 0 .75rem;
}

@media (max-width: 900px) {
  .crs-formula-studio { grid-template-columns: 1fr; }
}

.crs-formula-studio__tokens,
.crs-formula-studio__canvas {
  border: 1px solid #d6e4ef;
  border-radius: 16px;
  padding: .85rem .9rem 1rem;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(45, 212, 191, .1), transparent 55%),
    linear-gradient(165deg, #ffffff 0%, #f7fbfd 100%);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.crs-formula-studio__canvas {
  border-color: #ddd6fe;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(139, 92, 246, .1), transparent 55%),
    linear-gradient(165deg, #ffffff 0%, #faf8ff 100%);
}

.crs-formula-studio__head {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .45rem;
}

.crs-formula-studio__title {
  font-size: .9rem;
  font-weight: 750;
  color: #0f172a;
}

.crs-formula-studio__chip {
  margin-inline-start: auto;
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: #ecfeff;
  color: #0f766e;
  border: 1px solid #a5f3fc;
}

.crs-formula-token-section {
  border-radius: 12px;
  padding: .5rem .55rem .55rem;
  margin: 0 0 .55rem;
}

.crs-formula-token-section--group {
  background: rgba(59, 130, 246, .08);
  border: 1px solid rgba(59, 130, 246, .18);
}

.crs-formula-token-section--measure {
  background: rgba(245, 158, 11, .08);
  border: 1px solid rgba(245, 158, 11, .18);
}

.crs-formula-token-section__label {
  display: block;
  font-size: .72rem;
  font-weight: 750;
  color: #64748b;
  margin-bottom: .35rem;
}

.crs-formula-token-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .15rem 0 .35rem;
  min-height: 2.2rem;
}

.crs-formula-token {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .05rem;
  border: 1px solid #99f6e4;
  background: #f0fdfa;
  color: #0f766e;
  border-radius: 12px;
  padding: .35rem .7rem;
  font: inherit;
  font-size: .82rem;
  font-weight: 650;
  cursor: grab;
  transition: transform .12s ease, box-shadow .12s ease;
}

.crs-formula-token:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
}

.crs-formula-token--group {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.crs-formula-token--num {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #b45309;
}

.crs-formula-token__label {
  line-height: 1.2;
}

.crs-formula-token__meta {
  font-size: .65rem;
  font-weight: 600;
  opacity: .7;
}

.crs-formula-ops {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .55rem;
}

.crs-formula-op {
  min-width: 2.2rem;
  height: 2.2rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.crs-formula-op:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.crs-formula-input {
  min-height: 8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9rem;
  direction: ltr;
  text-align: left;
  border-radius: 12px !important;
  border-color: #c4b5fd !important;
  background: rgba(255, 255, 255, .9) !important;
}

.crs-formula-layout {
  display: grid;
  grid-template-columns: minmax(10rem, 0.9fr) minmax(14rem, 1.3fr);
  gap: .85rem;
  margin: .35rem 0 .75rem;
}

@media (max-width: 900px) {
  .crs-formula-layout { grid-template-columns: 1fr; }
}

.crs-formula-tokens,
.crs-formula-canvas {
  border: 1px solid var(--crs-line, #e7e5e4);
  border-radius: 12px;
  padding: .75rem;
  background: #fff;
}

.crs-kpi-card__accent {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--crs-kpi-accent, #2dd4bf);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--crs-kpi-accent, #2dd4bf) 25%, transparent);
}

.crs-table-col-editor {
  margin: .85rem 0 1rem;
  padding: .9rem 1rem;
  border: 1px dashed var(--crs-line, #e7e5e4);
  border-radius: 12px;
  background: #fafafa;
}

.crs-inline-actions {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
}

.crs-table-col-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .75rem;
}

.crs-table-col-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .75rem;
  border: 1px solid var(--crs-line, #e7e5e4);
  border-radius: 10px;
  background: #fff;
}

.crs-table-col-row.is-dragging {
  opacity: .55;
}

.crs-table-col-row__handle {
  cursor: grab;
  color: #94a3b8;
  user-select: none;
  letter-spacing: -.15em;
}

.crs-table-col-row__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.crs-table-col-row__actions {
  display: flex;
  gap: .25rem;
}

.crs-kpi-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.crs-kpi-card__title {
  font-size: .9rem;
  font-weight: 600;
  color: #475569;
}

.crs-kpi-card__value {
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.crs-kpi-card__delta {
  font-size: .85rem;
  font-weight: 600;
  width: fit-content;
  padding: .15rem .45rem;
  border-radius: 999px;
}

.crs-kpi-card__delta.is-up {
  color: #047857;
  background: #d1fae5;
}

.crs-kpi-card__delta.is-down {
  color: #b91c1c;
  background: #fee2e2;
}

.crs-chart-canvas-wrap--kpi {
  height: 120px;
  min-height: 120px;
  margin-top: .5rem;
}

.crs-field--check {
  display: flex;
  align-items: flex-end;
}

.crs-check {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .88rem;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.crs-check input {
  width: 1rem;
  height: 1rem;
}

.crs-empty--warn {
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.crs-chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  min-height: 280px;
}

.crs-chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.crs-chart-kpi {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-bottom: .75rem;
}

.crs-chart-kpi__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1c1917;
}

.crs-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: .55rem;
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--crs-line);
  background: #fff;
}

/* Accordion */
.crs-accordion {
  border: 1px solid var(--crs-line);
  border-radius: 14px;
  background: #fff;
  overflow: visible;
  flex: 0 0 auto;
}

.crs-accordion__head {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: .55rem .75rem;
  padding: .95rem 1.1rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: right;
  font: inherit;
  color: var(--crs-ink);
}

.crs-accordion__head:hover {
  background: var(--crs-tint);
}

.crs-accordion__title {
  font-weight: 700;
  font-size: .95rem;
}

.crs-accordion__hint {
  color: var(--crs-muted);
  font-size: .78rem;
  justify-self: start;
}

.crs-accordion__chev {
  width: .65rem;
  height: .65rem;
  border-inline-end: 2px solid var(--crs-muted);
  border-bottom: 2px solid var(--crs-muted);
  transform: rotate(45deg);
  transition: transform .18s ease;
  margin-inline-start: .25rem;
}

.crs-accordion__head.is-open .crs-accordion__chev {
  transform: rotate(-135deg);
  margin-top: .35rem;
}

.crs-accordion__body {
  padding: 1rem 1.15rem 1.25rem;
  border-top: 1px solid var(--crs-line);
  background: #fff;
  overflow: visible;
}

.crs-badge {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--crs-accent-soft);
  color: var(--crs-accent);
  font-size: .72rem;
  font-weight: 800;
}

.crs-subhead {
  margin: .85rem 0 .45rem;
  font-size: .86rem;
  font-weight: 700;
  color: var(--crs-ink);
}

.crs-divider {
  height: 1px;
  background: var(--crs-line);
  margin: 1rem 0 .35rem;
}

.crs-field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .65rem;
}

.crs-field--inline {
  margin: 0;
  min-width: 7.5rem;
}

.crs-field__label {
  font-size: .82rem;
  font-weight: 650;
  color: var(--crs-ink);
}

.crs-input,
.crs-select {
  width: 100%;
  border: 1px solid var(--crs-line);
  border-radius: 10px;
  padding: .55rem .7rem;
  background: #fff;
  color: #1c1917;
  font: inherit;
  color-scheme: light;
}

.crs-input:focus,
.crs-select:focus {
  outline: 2px solid rgba(15, 118, 110, .22);
  border-color: var(--crs-accent);
  background: #fff;
}

.crs-select option,
.crs-select optgroup {
  color: #1c1917;
  background: #fff;
}

/* Custom dropdown — avoids native Windows white-on-white option popups */
.crs-select-dd {
  position: relative;
  width: 100%;
}

.crs-select-dd__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  border: 1px solid var(--crs-line);
  border-radius: 10px;
  padding: .55rem .7rem;
  background: #fff;
  color: #1c1917;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.crs-select-dd.is-disabled .crs-select-dd__trigger {
  opacity: .55;
  cursor: not-allowed;
}

.crs-select-dd__value.is-placeholder {
  color: #78716c;
}

.crs-select-dd__chev {
  width: .5rem;
  height: .5rem;
  border-inline-end: 2px solid #78716c;
  border-bottom: 2px solid #78716c;
  transform: rotate(45deg);
  flex: 0 0 auto;
  margin-top: -.2rem;
}

.crs-select-dd.is-open .crs-select-dd__chev {
  transform: rotate(-135deg);
  margin-top: .2rem;
}

.crs-select-dd__panel {
  position: absolute;
  z-index: 40;
  inset-inline: 0;
  top: calc(100% + .25rem);
  max-height: min(42vh, 16rem);
  overflow: auto;
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(28, 25, 23, .14);
  padding: .3rem;
}

.crs-select-dd__opt {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: .55rem .65rem;
  background: transparent;
  color: #1c1917;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.crs-select-dd__opt:hover {
  background: #f0fdfa;
}

.crs-select-dd__opt.is-on {
  background: #ccfbf1;
  color: #0f766e;
  font-weight: 650;
}

.crs-select-dd__empty {
  padding: .65rem;
  color: #78716c;
  font-size: .86rem;
}

.crs-y-series {
  display: grid;
  gap: .55rem;
}

.crs-y-series__row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto auto;
  gap: .45rem;
  align-items: end;
  padding: .55rem;
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  background: #fafaf9;
}

.crs-y-series__color {
  width: 2.6rem;
  min-height: 2.4rem;
  padding: .2rem;
}

.crs-x-series {
  display: grid;
  gap: .55rem;
}

.crs-x-series__row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: .45rem;
  align-items: end;
  padding: .55rem;
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  background: #fafaf9;
}

@media (max-width: 720px) {
  .crs-y-series__row,
  .crs-x-series__row {
    grid-template-columns: 1fr;
  }
}

.crs-checklist {
  min-height: 8.5rem;
  max-height: min(42vh, 22rem);
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  background: #fff;
  color: #1c1917;
  padding: .5rem .45rem .65rem;
  -webkit-overflow-scrolling: touch;
}

.crs-checklist--scroll {
  min-height: 6rem;
  max-height: 12rem;
}

.crs-runtime__editor {
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  padding: .85rem .9rem 1rem;
  margin-bottom: 1rem;
  background: #fff;
}

.crs-check {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .55rem .65rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: .88rem;
  line-height: 1.45;
  min-height: 2.75rem;
  color: #1c1917;
}

.crs-check:hover { background: #f0fdfa; }
.crs-check input { margin-top: .2rem; accent-color: var(--crs-accent); flex-shrink: 0; }
.crs-check > span {
  display: block;
  min-width: 0;
  word-break: break-word;
  color: #1c1917;
}
.crs-check__meta {
  display: block;
  color: var(--crs-muted);
  font-size: .75rem;
  margin-top: .2rem;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.crs-switch {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
}

.crs-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.crs-switch__track {
  position: relative;
  flex: 0 0 auto;
  width: 2.6rem;
  height: 1.45rem;
  margin-top: .15rem;
  border-radius: 999px;
  background: #d6d3d1;
  transition: background .15s ease;
}

.crs-switch__track::after {
  content: "";
  position: absolute;
  top: .15rem;
  right: .15rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .15s ease;
}

.crs-switch input:checked + .crs-switch__track {
  background: #0f766e;
}

.crs-switch input:checked + .crs-switch__track::after {
  transform: translateX(-1.15rem);
}

.crs-chart-form.is-dimmed {
  opacity: .55;
  pointer-events: none;
  filter: grayscale(.15);
}

.crs-switch .crs-muted {
  font-size: .82rem;
  color: #78716c;
}

.crs-check--dyn {
  margin: .35rem 0 .55rem;
  padding: .55rem .7rem;
  border: 1px dashed color-mix(in srgb, var(--crs-accent) 45%, var(--crs-line));
  background: color-mix(in srgb, var(--crs-accent) 6%, #fff);
}

.crs-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}

@media (max-width: 700px) {
  .crs-dual { grid-template-columns: 1fr; }
}

.crs-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.crs-btn {
  border: 1px solid var(--crs-line);
  background: #fff;
  color: var(--crs-ink);
  border-radius: 10px;
  padding: .48rem .9rem;
  font: inherit;
  font-weight: 650;
  font-size: .86rem;
  cursor: pointer;
}

.crs-btn:hover { background: var(--crs-tint); }
.crs-btn--primary {
  background: var(--crs-accent);
  border-color: var(--crs-accent);
  color: #fff;
}
.crs-btn--primary:hover {
  filter: brightness(1.06);
  background: var(--crs-accent);
}
.crs-btn--ghost {
  background: transparent;
  padding-inline: .55rem;
}
.crs-btn:disabled { opacity: .45; cursor: not-allowed; }

.crs-preview-card {
  border: 1px solid var(--crs-line);
  border-radius: 14px;
  background: #fff;
  padding: 1rem 1.1rem 1.15rem;
  flex: 1 1 auto;
  min-height: 16rem;
  display: flex;
  flex-direction: column;
}

.crs-preview-frame {
  flex: 1 1 auto;
  min-height: 14rem;
  max-height: none;
  overflow: auto;
  border: 1px dashed #d6d3d1;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #fafaf9);
}

.crs-preview-frame .crs-table-wrap {
  max-height: none;
  border: 0;
  border-radius: 12px;
}

.crs-table-wrap {
  overflow: auto;
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  max-height: min(36vh, 18rem);
}

.crs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.crs-table th,
.crs-table td {
  padding: .55rem .65rem;
  border-bottom: 1px solid var(--crs-line);
  text-align: right;
  white-space: nowrap;
}

.crs-table th {
  background: var(--crs-tint);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.crs-table tr:last-child td { border-bottom: 0; }

.crs-preview-card__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: .75rem;
}

.crs-preview-card__title {
  margin: 0;
  font-size: .95rem;
  font-weight: 750;
}

.crs-preview-toolbar__left {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  align-items: flex-end;
}

.crs-empty {
  padding: 2.25rem 1.25rem;
  text-align: center;
  color: var(--crs-muted);
  font-size: .9rem;
  line-height: 1.6;
}

.crs-hint {
  margin: .55rem 0 0;
  font-size: .8rem;
  color: var(--crs-warn);
}

.crs-muted {
  color: var(--crs-muted);
  font-size: .82rem;
}

.crs-alert {
  margin: 0;
  padding: .65rem .8rem;
  border-radius: 10px;
  font-size: .86rem;
}

.crs-alert--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.crs-alert--ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Phase 2 — TSQL scripting accordion */
.crs-script-list {
  display: grid;
  gap: .55rem;
  margin: 0 0 .85rem;
  padding: .75rem .85rem;
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  background: #f8fafc;
}

.crs-script-list__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.crs-script-list__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .45rem;
}

.crs-script-list__item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .4rem;
  align-items: center;
  padding: .35rem .4rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #fff;
}

.crs-script-list__item.is-active {
  border-color: #94a3b8;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, .35);
}

.crs-script-list__select {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: .25rem .4rem;
  border-radius: 8px;
  font-size: .78rem;
  color: #475569;
}

.crs-script-list__item.is-active .crs-script-list__select {
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 600;
}

.crs-script-list__title-input {
  min-width: 0;
}

.crs-script-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(12rem, .9fr);
  gap: .85rem;
  align-items: start;
}

@media (max-width: 900px) {
  .crs-script-layout { grid-template-columns: 1fr; }
}

.crs-monaco-host {
  min-height: 14rem;
  height: min(36vh, 18rem);
  border: 1px solid var(--crs-line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  direction: ltr;
  text-align: left;
}

.crs-script-aliases .crs-table--compact th,
.crs-script-aliases .crs-table--compact td {
  padding: .4rem .45rem;
  font-size: .82rem;
}

.crs-script-aliases .crs-input {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .82rem;
  direction: ltr;
  text-align: left;
}

.crs-script-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
  justify-content: space-between;
  margin: .85rem 0 .65rem;
}

.crs-script-errors {
  flex: 1 1 12rem;
  font-size: .84rem;
  color: var(--crs-ink);
}

.crs-script-errors__text {
  color: #991b1b;
  margin-inline-start: .35rem;
}

.crs-script-result {
  border: 1px solid var(--crs-line);
  border-radius: 12px;
  background: #fafaf9;
  min-height: 6rem;
  overflow: auto;
  max-height: min(32vh, 16rem);
}
