:root {
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --ink: #182126;
  --ink-muted: #66757d;
  --border: #dfe5e8;
  --border-strong: #cbd4d9;
  --accent: #176b5b;
  --accent-soft: #e4f2ee;
  --focus: #0b63ce;
  --shadow: 0 18px 45px rgba(34, 52, 61, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(23, 107, 91, 0.09), transparent 28rem),
    var(--canvas);
}

button,
input,
select {
  font: inherit;
}

button,
select,
a {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid rgba(11, 99, 206, 0.28);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--focus);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(100% - 32px, 1600px);
  margin: 0 auto;
  padding: 48px 0 32px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.72);
}

.view-tab {
  min-height: 38px;
  padding: 0 15px;
  border: 0;
  border-radius: 7px;
  color: var(--ink-muted);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 680;
  cursor: pointer;
}

.view-tab:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.view-tab.is-active {
  color: white;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(23, 107, 91, 0.2);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--ink-muted);
  font-size: 1rem;
}

.sheet-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.875rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.sheet-link:hover {
  border-color: #9eabb1;
  background: white;
}

.sheet-link svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.analytics-panel {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.analytics-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.analytics-header h2,
.chart-card h3 {
  margin: 0;
  letter-spacing: -0.025em;
}

.analytics-header h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.analytics-subtitle,
.chart-card header p,
.analytics-note {
  color: var(--ink-muted);
}

.analytics-subtitle {
  margin: 7px 0 0;
  font-size: 0.88rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

.legend-swatch.callcenter {
  background: #d77828;
}

.legend-swatch.peeranalyst {
  background: #176b5b;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--ink-muted);
}

.metric-card span {
  margin-bottom: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-bottom: 5px;
  font-size: clamp(1.5rem, 2.4vw, 2.15rem);
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.metric-card small {
  overflow: hidden;
  font-size: 0.74rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.chart-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: white;
}

.chart-card-wide {
  grid-column: 1 / -1;
}

.chart-card-wide .chart-plot {
  max-width: 900px;
  margin-inline: auto;
}

.chart-card h3 {
  font-size: 1rem;
}

.chart-card header p {
  margin: 4px 0 14px;
  font-size: 0.75rem;
}

.chart-plot {
  position: relative;
  min-height: 260px;
  border-radius: 9px;
  background: linear-gradient(180deg, #fbfcfc, #ffffff);
}

.chart-plot:focus-visible {
  outline: 3px solid rgba(11, 99, 206, 0.28);
  outline-offset: 3px;
}

.chart-plot svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-loading {
  margin: 0;
  padding: 100px 20px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  text-align: center;
}

.chart-grid-line {
  stroke: #e7ecee;
  stroke-width: 1;
}

.chart-axis-label {
  fill: #7b898f;
  font-size: 12px;
  font-family: inherit;
}

.chart-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.rate-area {
  fill: rgba(165, 67, 80, 0.09);
}

.chart-guide {
  stroke: #8b989e;
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.chart-point {
  stroke: white;
  stroke-width: 3;
}

.chart-tooltip {
  position: absolute;
  top: 12px;
  z-index: 4;
  min-width: 150px;
  padding: 9px 11px;
  transform: translateX(-50%);
  border: 1px solid #263238;
  border-radius: 8px;
  color: white;
  background: #182126;
  box-shadow: 0 8px 24px rgba(24, 33, 38, 0.2);
  font-size: 0.72rem;
  line-height: 1.45;
  pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip span {
  color: #d2dadd;
}

.analytics-note {
  margin: 14px 2px 0;
  font-size: 0.74rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.search-field {
  position: relative;
  flex: 1 1 340px;
  max-width: 440px;
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--ink-muted);
  stroke-linecap: round;
  stroke-width: 1.7;
}

input,
select,
button {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--ink);
  background: var(--surface);
}

input {
  width: 100%;
  padding: 0 14px 0 42px;
}

input::placeholder {
  color: #87949a;
}

select {
  max-width: 190px;
  padding: 0 34px 0 12px;
  cursor: pointer;
}

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-menu {
  position: relative;
}

.column-menu summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

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

.column-menu summary::after {
  content: "▾";
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.column-menu[open] summary {
  border-color: var(--accent);
}

#visible-column-count {
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.column-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: min(320px, calc(100vw - 40px));
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(34, 52, 61, 0.18);
}

.column-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.column-popover-header strong {
  font-size: 0.82rem;
}

.column-popover-header button {
  min-height: 32px;
  padding: 0 9px;
  border-color: transparent;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
}

.column-options {
  display: grid;
  max-height: 340px;
  overflow-y: auto;
  gap: 2px;
}

.column-options label {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 9px;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.column-options label:hover {
  background: var(--surface-muted);
}

.column-options input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.clear-button {
  padding: 0 12px;
  border-color: transparent;
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}

.clear-button:hover {
  background: var(--accent-soft);
}

.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-muted);
  background: var(--surface-muted);
  font-size: 0.8125rem;
}

.table-meta p {
  margin: 0;
}

.scroll-hint {
  white-space: nowrap;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  scrollbar-gutter: stable;
  scrollbar-color: #aeb9be #eef2f3;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #eef2f3;
}

.table-wrap::-webkit-scrollbar-thumb {
  border: 3px solid #eef2f3;
  border-radius: 999px;
  background: #aeb9be;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: #87969d;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}

th,
td {
  max-width: 360px;
  padding: 11px 14px;
  border-right: 1px solid #edf0f2;
  border-bottom: 1px solid #edf0f2;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0;
  color: #49575e;
  background: #f7f9fa;
  font-size: 0.73rem;
  font-weight: 720;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  white-space: nowrap;
}

th button {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

th button:hover {
  color: var(--accent);
  background: #eef4f2;
}

.sort-indicator {
  width: 12px;
  color: #97a3a9;
  font-size: 0.8rem;
}

tbody tr:hover td {
  background: #f8fbfa;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.numeric {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

td a {
  color: var(--accent);
  font-weight: 650;
  text-underline-offset: 2px;
}

td.product-cell {
  min-width: 310px;
  max-width: 380px;
}

.product-name {
  display: block;
  margin-bottom: 7px;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-timeline {
  position: relative;
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: crosshair;
}

.product-timeline:focus-visible {
  outline: 3px solid rgba(11, 99, 206, 0.28);
  outline-offset: 2px;
}

.timeline-track {
  position: relative;
  display: block;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(80, 95, 103, 0.2);
  border-radius: 999px;
  background-color: #edf1f2;
  box-shadow: inset 0 1px 2px rgba(24, 33, 38, 0.08);
}

.timeline-marker {
  position: absolute;
  top: -1px;
  bottom: -1px;
  z-index: 1;
  width: 2px;
  transform: translateX(-1px);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(24, 33, 38, 0.12);
  pointer-events: none;
}

.timeline-scrubber {
  position: absolute;
  top: -4px;
  bottom: -4px;
  z-index: 2;
  width: 2px;
  transform: translateX(-1px) scaleY(0.65);
  border-radius: 2px;
  background: #182126;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.product-timeline:hover .timeline-scrubber,
.product-timeline:focus-visible .timeline-scrubber {
  transform: translateX(-1px) scaleY(1);
  opacity: 1;
}

.timeline-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  color: #77858c;
  font-size: 0.67rem;
  line-height: 1.1;
}

.timeline-caption span:last-child {
  text-align: right;
}

.timeline-tooltip {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 0;
  z-index: 12;
  min-width: 156px;
  max-width: 220px;
  padding: 8px 10px;
  transform: translate(-50%, 4px);
  border: 1px solid #263238;
  border-radius: 7px;
  color: white;
  background: #182126;
  box-shadow: 0 8px 24px rgba(24, 33, 38, 0.22);
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.timeline-tooltip strong,
.timeline-tooltip span {
  display: block;
}

.timeline-tooltip strong {
  margin-bottom: 2px;
  color: white;
  font-weight: 700;
}

.timeline-tooltip span {
  color: #ced7da;
}

.product-timeline:hover .timeline-tooltip,
.product-timeline:focus-visible .timeline-tooltip {
  transform: translate(-50%, 0);
  opacity: 1;
}

.timeline-current-only {
  cursor: default;
}

.cell-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 9px;
  border: 1px solid #d8e0e3;
  border-radius: 999px;
  color: #4f5d64;
  background: #f2f5f6;
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}

.pill.on-track,
.pill.solicit {
  border-color: #b9dfd4;
  color: #14604f;
  background: #e8f6f2;
}

.pill.at-risk,
.pill.yellow,
.pill.within-1st-month {
  border-color: #ead69b;
  color: #705614;
  background: #fff7d9;
}

.pill.behind-schedule,
.pill.do-not-solicit,
.pill.peach {
  border-color: #efc3b9;
  color: #863b2b;
  background: #fff0ec;
}

.empty-value {
  color: #a2adb2;
}

.loading-row td,
.empty-row td,
.error-row td {
  min-width: min(900px, 90vw);
  padding: 48px 20px;
  color: var(--ink-muted);
  text-align: center;
}

.error-row td {
  color: #8a3026;
}

.updated-at {
  margin: 12px 4px 0;
  color: var(--ink-muted);
  font-size: 0.75rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 20px, 1600px);
    padding-top: 28px;
  }

  .page-header {
    align-items: flex-start;
  }

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

  .search-field {
    flex-basis: auto;
    max-width: none;
  }

  .filters {
    overflow-x: auto;
    padding-bottom: 2px;
  }

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

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

@media (max-width: 600px) {
  .page-header {
    flex-direction: column;
  }

  .view-tabs {
    display: flex;
  }

  .view-tab {
    flex: 1;
  }

  .analytics-panel {
    padding: 16px;
  }

  .analytics-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

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

  .sheet-link {
    width: 100%;
    justify-content: center;
  }

  .header-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .table-meta {
    align-items: flex-start;
    flex-direction: column;
    padding-block: 12px;
  }

  .scroll-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button,
  a,
  input,
  select {
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
