* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f6f8f4;
  color: #15201b;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

code,
pre,
select,
input,
button {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 26px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: #64756b;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid #d5ddd3;
  border-radius: 999px;
  background: #fff;
  color: #415047;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9a453a;
}

.status-pill.is-connected span {
  background: #247c5b;
}

.source-alert {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
  padding: 14px 16px;
  border: 1px solid #d98d85;
  border-left: 5px solid #9a453a;
  border-radius: 8px;
  background: #fff4f2;
  color: #7d241b;
}

.source-alert strong {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.source-alert ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
}

.panel {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid #d9e1d6;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(18 28 21 / 4%);
}

.panel.stack {
  display: block;
}

.dashboard-section {
  margin-top: 34px;
}

.dashboard-section:first-of-type {
  margin-top: 0;
}

.dashboard-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding-top: 18px;
  border-top: 1px solid #dbe4d8;
}

.dashboard-section:first-of-type .dashboard-section-heading {
  padding-top: 0;
  border-top: 0;
}

.dashboard-section-heading h2 {
  margin: 0;
  color: #15201b;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}

.panel p {
  margin: 0;
  color: #546158;
  line-height: 1.55;
}

.panel-main {
  max-width: 660px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #c9d3c7;
  border-radius: 7px;
  background: #fff;
  color: #15201b;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  border-color: #29483c;
  background: #29483c;
  color: #fff;
}

.button.danger {
  color: #8f2d24;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0;
}

.facts div {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
}

.facts dt {
  color: #64756b;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.facts dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.facts.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.facts.compact div {
  grid-template-columns: 1fr auto;
}

.muted {
  color: #64756b;
}

.warning {
  margin-top: 14px !important;
  padding: 12px 14px;
  border: 1px solid #e4c777;
  border-radius: 8px;
  background: #fff9e8;
  color: #684b0f !important;
}

.config-label {
  margin: 16px 0 10px !important;
  font-weight: 700;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.data-panel {
  border-color: #cad7d0;
}

.operations-details {
  border-top: 1px solid #dbe4d8;
  padding-top: 18px;
}

.operations-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 16px 18px;
  border: 1px solid #d9e1d6;
  border-radius: 8px;
  background: #fff;
  color: #15201b;
  cursor: pointer;
  font-size: 22px;
  font-weight: 800;
  list-style: none;
  box-shadow: 0 1px 2px rgb(18 28 21 / 4%);
}

.operations-details summary::-webkit-details-marker {
  display: none;
}

.operations-details summary::after {
  content: "+";
  color: #64756b;
  font-size: 28px;
  line-height: 1;
}

.operations-details[open] summary::after {
  content: "-";
}

.operations-details summary span {
  display: grid;
  gap: 3px;
}

.operations-details summary small {
  color: #64756b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.operations-content {
  margin-top: 18px;
}

.analytics-grid {
  align-items: stretch;
}

.inline-filter {
  display: flex;
  align-items: end;
  gap: 10px;
}

.inline-filter label {
  display: grid;
  gap: 6px;
  color: #536158;
  font-size: 13px;
  font-weight: 700;
}

.inline-filter select {
  min-height: 38px;
  min-width: 112px;
  border: 1px solid #c9d3c7;
  border-radius: 7px;
  background: #fff;
  color: #15201b;
  padding: 0 10px;
}

.lens-panel {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid #26342d;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 5%), rgb(255 255 255 / 1%)),
    #121713;
  color: #edf4ee;
  box-shadow: 0 18px 42px rgb(20 30 24 / 14%);
}

.lens-panel .eyebrow,
.lens-panel .muted {
  color: #9ba8a0;
}

.lens-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.lens-header h2 {
  margin: 0 0 6px;
  color: #f4faf5;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

.lens-range-control {
  position: absolute;
  right: 6.8%;
  bottom: 44px;
  left: 6.4%;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  height: 12px;
}

.lens-range-control input {
  width: 100%;
  height: 12px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.lens-range-control input:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.lens-range-control input::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background: rgb(255 255 255 / 22%);
}

.lens-range-control input::-webkit-slider-thumb {
  width: 8px;
  height: 8px;
  margin-top: -3px;
  border: 1px solid rgb(240 255 247 / 72%);
  border-radius: 50%;
  appearance: none;
  background: #70c79c;
  box-shadow: 0 0 0 4px rgb(112 199 156 / 12%);
}

.lens-range-control input::-moz-range-track {
  height: 2px;
  border-radius: 999px;
  background: rgb(255 255 255 / 22%);
}

.lens-range-control input::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 1px solid rgb(240 255 247 / 72%);
  border-radius: 50%;
  background: #70c79c;
  box-shadow: 0 0 0 4px rgb(112 199 156 / 12%);
}

.lens-side-label {
  color: #aab6af;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.lens-range-control strong {
  color: #c4d3cb;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.lens-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 16px;
  align-items: stretch;
}

.lens-chart-card,
.lens-side {
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 8px;
  background: rgb(255 255 255 / 4%);
}

.lens-chart-card {
  min-width: 0;
  padding: 16px;
}

.lens-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.lens-toggle {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  max-width: 100%;
  padding: 0 11px;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 999px;
  background: rgb(255 255 255 / 5%);
  color: #dfe8e2;
  cursor: pointer;
}

.lens-toggle span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--series-color);
}

.lens-toggle strong,
.lens-toggle small {
  min-width: 0;
  white-space: nowrap;
}

.lens-toggle strong {
  font-size: 12px;
}

.lens-toggle small {
  color: #9ba8a0;
  font-size: 11px;
}

.lens-toggle.is-active {
  border-color: rgb(255 255 255 / 26%);
  background: rgb(255 255 255 / 12%);
}

.lens-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.lens-chart {
  width: 100%;
  height: 320px;
}

.lens-chart-frame {
  position: relative;
}

.lens-grid,
.lens-threshold {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.lens-grid {
  stroke: rgb(255 255 255 / 10%);
  stroke-width: 1;
}

.lens-threshold {
  stroke: rgb(255 255 255 / 20%);
  stroke-dasharray: 5 7;
  stroke-width: 1.5;
}

.lens-line,
.lens-dots {
  fill: none;
  opacity: var(--day-opacity, 0.86);
  stroke-linecap: round;
  stroke-linejoin: round;
  transition:
    opacity 160ms ease,
    stroke-width 160ms ease;
}

.lens-line {
  stroke-width: 1.45;
}

.lens-dots {
  display: none;
  stroke-width: 2.15;
}

.lens-line.is-muted,
.lens-dots.is-muted {
  opacity: 0.1;
  stroke-width: 1;
}

.lens-panel.is-dot-mode .lens-line {
  display: none;
}

.lens-panel.is-dot-mode .lens-dots {
  display: block;
}

.lens-line.is-range-hidden,
.lens-dots.is-range-hidden,
.lens-panel.is-dot-mode .lens-dots.is-range-hidden {
  display: none;
}

.lens-axis {
  fill: #9ba8a0;
  font-size: 12px;
  font-weight: 700;
}

.lens-side {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 16px;
}

.lens-side-section {
  display: grid;
  gap: 12px;
}

.hypothesis-list {
  display: grid;
  gap: 10px;
}

.hypothesis-row {
  display: grid;
  gap: 5px;
  padding-left: 11px;
  border-left: 3px solid #68b995;
}

.hypothesis-row strong {
  color: #f4faf5;
  font-size: 14px;
  line-height: 1.25;
}

.hypothesis-row span {
  color: #aab6af;
  font-size: 12px;
}

.lens-composition {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.lens-composition div {
  min-width: 0;
  padding: 10px;
  border-top: 3px solid var(--series-color);
  border-radius: 8px;
  background: rgb(255 255 255 / 5%);
}

.lens-composition span {
  display: block;
  overflow: hidden;
  color: #aab6af;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.lens-composition strong {
  display: block;
  margin-top: 6px;
  color: #f4faf5;
  font-size: 23px;
  line-height: 1;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid #d9e1d6;
  border-radius: 8px;
  background: #d9e1d6;
}

.metric-strip div {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 16px;
  background: #fbfcfa;
}

.metric-strip span,
.metric-strip small,
.subtle {
  color: #64756b;
}

.metric-strip span {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-strip strong {
  color: #15201b;
  font-size: 28px;
  line-height: 1;
}

.metric-strip small {
  font-size: 13px;
}

.insight-list {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.insight-list li {
  padding-left: 14px;
  border-left: 3px solid #adcabd;
  color: #415047;
  line-height: 1.5;
}

.timeline-panel {
  border-color: #cfd9d4;
}

.timeline-chart {
  display: grid;
  gap: 2px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 78px;
  gap: 14px;
  align-items: center;
  min-height: 88px;
  padding: 8px 0;
  border-top: 1px solid #e1e7de;
}

.timeline-row:first-child {
  border-top: 0;
}

.timeline-row.is-empty {
  opacity: 0.48;
}

.timeline-label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.timeline-label strong {
  color: #15201b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.timeline-label span {
  color: #415047;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.timeline-svg {
  display: block;
  width: 100%;
  height: 76px;
  overflow: visible;
}

.timeline-gridline {
  fill: none;
  stroke: #e5ebe2;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.timeline-line {
  fill: none;
  stroke-width: 2.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.timeline-range {
  display: grid;
  gap: 34px;
  color: #64756b;
  font-size: 11px;
  text-align: right;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(21, minmax(0, 1fr));
  align-items: end;
  gap: 6px;
  min-height: 170px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #e1e7de;
}

.bar-cell {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: end;
  gap: 8px;
  min-width: 0;
  height: 150px;
}

.bar-cell span {
  display: block;
  width: 100%;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: #477663;
}

.bar-cell small {
  overflow: hidden;
  color: #64756b;
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid #e1e7de;
  text-align: left;
  vertical-align: top;
}

th {
  color: #64756b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: #233028;
}

.preview-form {
  display: grid;
  grid-template-columns: 1.25fr repeat(3, minmax(120px, 0.7fr)) auto auto;
  gap: 12px;
  align-items: end;
}

.preview-form label {
  display: grid;
  gap: 6px;
  color: #536158;
  font-size: 13px;
  font-weight: 700;
}

.preview-form input,
.preview-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #c9d3c7;
  border-radius: 7px;
  background: #fff;
  color: #15201b;
  padding: 0 10px;
}

.preview-form .checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  min-width: 120px;
  width: 100%;
}

.preview-form .checkbox input {
  flex: 0 0 auto;
  width: 16px;
  min-height: 16px;
}

.preview-form .checkbox span {
  white-space: nowrap;
}

.import-form {
  grid-template-columns: minmax(180px, 1.4fr) minmax(160px, 1fr) minmax(140px, 0.8fr) auto;
  margin-top: 18px;
}

.export-import-form {
  grid-template-columns: minmax(240px, 1fr) auto;
}

.preview {
  margin-top: 18px;
  border-radius: 8px;
  border: 1px solid #d9e1d6;
  background: #f8faf7;
  overflow: auto;
}

.preview.error {
  border-color: #e3b7b1;
  background: #fff7f6;
  color: #8f2d24;
  padding: 16px;
}

pre {
  margin: 0;
  padding: 16px;
  color: #243028;
  font-size: 13px;
  line-height: 1.5;
}

.alert {
  width: min(1120px, calc(100% - 32px));
  margin: 18px auto 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #d9e1d6;
}

.alert-danger {
  border-color: #e3b7b1;
  color: #8f2d24;
}

.alert-info {
  border-color: #adcabd;
  color: #1f6047;
}

@media (max-width: 860px) {
  .topbar,
  .panel,
  .dashboard-section-heading,
  .source-alert {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

  .grid,
  .preview-form,
  .lens-layout {
    grid-template-columns: 1fr;
  }

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

  .facts div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .timeline-row {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .timeline-range {
    display: none;
  }

  .lens-header {
    display: grid;
  }
}

@media (max-width: 560px) {
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .lens-panel,
  .lens-chart-card,
  .lens-side {
    padding: 14px;
  }

  .lens-toggle {
    grid-template-columns: auto minmax(0, 1fr);
    width: 100%;
  }

  .lens-toggle small {
    grid-column: 2;
  }

  .lens-composition {
    grid-template-columns: 1fr;
  }
}
