:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #111032;
  background: #fff;
  --sidebar: #27183f;
  --purple: #5424c7;
  --purple-soft: #f1ecfe;
  --muted: #514e6d;
  --line: #e5e3ef;
  --panel: #faf9fc;
  --teal: #007e72;
  --radius: .65rem;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  display: grid;
  grid-template-columns: 10.75rem minmax(0, 1fr);
  min-height: 100vh;
  margin: 0;
  font-size: .875rem;
  line-height: 1.45;
}

button, input, select { font: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }
a { color: var(--purple); }
p, dl { margin: 0; }

.icon-library { position: absolute; width: 0; height: 0; }

.icon {
  width: 1.15rem;
  height: 1.15rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  color: #fff;
  background: linear-gradient(152deg, #24153b, var(--sidebar) 60%, #30204d);
}

.brand {
  display: grid;
  place-items: center;
  min-height: 5.35rem;
  padding: .6rem 1rem;
  font-weight: 700;
}

.brand img { display: block; width: 7.3rem; height: 3.35rem; object-fit: contain; }
.module-list { display: grid; gap: .35rem; padding: 0 .4rem .85rem; }
.module-list::after { content: ""; height: 1px; margin: .3rem .6rem 0; background: #8b789e; }

.module {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 3.6rem;
  padding: .6rem .95rem;
  border-radius: .65rem;
  line-height: 1.35;
}

.module-active { background: #5d42bd; font-weight: 650; }
.module .icon { width: 1.35rem; height: 1.35rem; }

.main {
  position: relative;
  width: 100%;
  max-width: 112rem;
  min-width: 0;
  margin-inline: auto;
  padding: .75rem 1.35rem 1rem;
}

.page-header { padding-bottom: .9rem; }
.page-heading { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 1.88rem);
  letter-spacing: -.035em;
  line-height: 1.16;
}

h2 {
  margin: 0;
  font-size: 1.075rem;
  letter-spacing: -.02em;
  line-height: 1.25;
}

.page-header p { margin-top: .27rem; color: #2e2a52; }
.version, .demo-tag {
  padding: .15rem .55rem;
  border-radius: .42rem;
  background: var(--purple-soft);
  color: #4621a1;
  font-size: .78rem;
  font-weight: 750;
  line-height: 1.4;
}
.demo-tag { background: #fff0d5; color: #794600; }

.session-tools {
  position: absolute;
  top: .9rem;
  right: 1.35rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .18rem .2rem .18rem .65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: .82rem;
}

.main:has(#dashboard:not([hidden])) .page-header { padding-right: 10rem; }
.session-tools > span, .button, .footer-meta p { display: inline-flex; align-items: center; gap: .4rem; }
.session-tools .button { min-height: 2rem; padding: .25rem .65rem; }

.button {
  justify-content: center;
  min-height: 2.25rem;
  padding: .42rem .78rem;
  border: 1px solid #dcd6ef;
  border-radius: .52rem;
  background: #fff;
  color: #321873;
  font-weight: 625;
  line-height: 1.25;
  text-align: center;
}

.button:hover:not(:disabled) { background: var(--purple-soft); }
.button:disabled { border-color: var(--line); color: #625d76; background: #f3f1f7; }
.button.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.button.primary:hover:not(:disabled) { background: #431aa7; }
.button.reset { background: #f6f3fe; white-space: nowrap; }

.filter-panel {
  padding: .56rem .5rem .65rem;
  border-block: 1px solid var(--line);
  background: linear-gradient(#faf9fc, #fff);
}

[id$="-filters"] {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: .7rem clamp(.6rem, 1.4vw, 1.35rem);
}

.field, .select-wrap { min-width: 0; }
.field label, #login-form label { display: block; margin-bottom: .22rem; font-size: .81rem; font-weight: 700; }
.select-wrap { position: relative; }
.select-wrap .icon { position: absolute; top: .55rem; left: .62rem; color: #55506d; pointer-events: none; }

select, input {
  width: 100%;
  min-width: 0;
  min-height: 2.25rem;
  padding: .36rem .6rem;
  border: 1px solid #dbd8eb;
  border-radius: .52rem;
  background-color: #fff;
  color: inherit;
}

.select-wrap select { padding-left: 2.25rem; text-overflow: ellipsis; }
.date-fields { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: end; gap: .7rem; }
.date-fields .field { flex: 0 1 10rem; }
.period-caption, .scope-caption { margin-top: .38rem; color: var(--muted); font-size: .76rem; }
.period-caption { font-weight: 650; }
.period-caption:empty { display: none; }
.scope-caption span { display: inline-block; margin-right: .65rem; }

.card, .feedback {
  min-width: 0;
  padding: .55rem .75rem .65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 2px #24153b08;
}

.feedback { margin-top: .85rem; padding: .75rem .9rem; background: var(--panel); }
.feedback .button { margin-top: .5rem; }
.feedback:has(.button[hidden]) p:empty { display: none; }
.login-card { max-width: 28rem; margin-top: 1rem; padding: 1.25rem; }
.login-card > p { margin-block: .5rem .75rem; color: var(--muted); }
#login-form .field + .field { margin-top: .65rem; }
#login-form .button { margin-top: .8rem; }
.session-message:empty { display: none; }

.overview { margin: .6rem 0 1.1rem; }
.overview-heading { display: flex; align-items: center; gap: .45rem; margin-bottom: .6rem; }
.info-link { display: inline-flex; color: var(--muted); }
.info-link .icon { width: 1rem; height: 1rem; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .68rem;
}

.metric {
  display: flex;
  align-items: flex-start;
  gap: .68rem;
  min-width: 0;
  min-height: 5.35rem;
  padding: .62rem .8rem;
  border: 1px solid #e8e6f0;
  border-radius: var(--radius);
  background: var(--panel);
}

.metric-conversion { border-color: #d6f2e9; background: #e0f8ee; }
.metric-icon { flex: 0 0 1.55rem; color: #651cff; }
.metric-icon svg { display: block; width: 1.55rem; height: 1.55rem; }
.metric-conversion .metric-icon { color: var(--teal); }
.metric-content { min-width: 0; }
.metric-label, .metric-note, .metric-value { display: block; overflow-wrap: anywhere; }
.metric-label { margin: 0; color: #24213e; font-size: .79rem; font-weight: 625; line-height: 1.25; }
.metric-value { margin-top: .18rem; font-size: clamp(1.08rem, 1.55vw, 1.53rem); font-weight: 775; line-height: 1.16; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.metric-note { margin-top: .2rem; color: var(--muted); font-size: .7rem; line-height: 1.3; }

.visualizations, .performance-grid { display: grid; gap: .8rem; margin-bottom: .72rem; }
.visualizations { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1.24fr) minmax(0, 1fr); }
.visualizations > .card { min-height: 11rem; }
.performance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
[id$="-quote-performance"][hidden] + [id$="-order-performance"] { grid-column: 1 / -1; }
.visualizations h2, .performance-grid h2 { margin-bottom: .5rem; }
.trend { min-width: 0; }
.trend svg { display: block; width: 100%; height: auto; max-height: 9.25rem; overflow: visible; }
.trend svg text { fill: #3c385b; font-family: inherit; }
.trend-grid { stroke: #eeedf5; }
.trend-label { font-size: .75rem; }
.trend-line { fill: none; stroke: #008b7d; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.trend-dot { fill: #fff; stroke: #008b7d; stroke-width: 1.5; }
.trend p, .cohort-result > p { color: var(--muted); font-size: .74rem; }

.cohort-result { display: flex; align-items: center; gap: .8rem; min-height: 8rem; }
.cohort-chart { flex: 0 0 min(45%, 8.3rem); min-width: 0; color: #1b1743; }
.cohort-chart svg, svg.cohort-chart { display: block; width: 100%; height: auto; }
.cohort-track, .cohort-empty, .cohort-converted { fill: none; stroke-width: 19; }
.cohort-track { stroke: #957afa; }
.cohort-empty { stroke: #e6e1ee; }
.cohort-converted { stroke: #008b79; }
.cohort-count { fill: currentColor; font-size: 1.45rem; font-weight: 780; }
.cohort-caption { fill: currentColor; font-size: .7rem; }
.cohort-legend { min-width: 0; margin: 0; padding: 0; list-style: none; font-size: .8rem; }
.cohort-legend > * + * { margin-top: .38rem; }
.cohort-legend > div { position: relative; padding-left: 1rem; }
.cohort-legend > div::before { content: ""; position: absolute; top: .28rem; left: 0; width: .65rem; height: .65rem; border-radius: .16rem; background: #957afa; }
.cohort-legend > [data-key="converted"]::before { background: #008b79; }
.cohort-legend dd { margin: .1rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.stat-list { font-size: .8rem; }
.stat-list > div { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; padding: .42rem .05rem; }
.stat-list > div + div { border-top: 1px solid var(--line); }
.stat-list dt { min-width: 0; overflow-wrap: anywhere; }
.stat-list dd { flex: 0 0 auto; max-width: 48%; margin: 0; overflow-wrap: anywhere; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
[id$="-status-list"] dt, .handoff-list dt { position: relative; padding-left: 1.15rem; }
[id$="-status-list"] dt::before, .handoff-list dt::before { content: ""; position: absolute; top: .29rem; left: .12rem; width: .58rem; height: .58rem; border: 2px solid #7b7395; border-radius: 50%; }
[id$="-status-list"] [data-key="created"] dt::before { border-color: #008b79; background: #008b79; }
[id$="-status-list"] [data-key="cancelled"] dt::before { border-color: #b32851; background: #b32851; }
.handoff-list [data-key="same"] dt::before { border-color: #6c37d0; background: #6c37d0; }
.handoff-list [data-key="other"] dt::before { border-color: #9c5900; background: #9c5900; }

.table-scroll { max-width: 100%; overflow-x: auto; border-radius: .35rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .73rem;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

th, td { padding: .26rem .38rem; }
thead { background: #f1eefc; font-size: .69rem; line-height: 1.28; }
thead th, tfoot th, tfoot td { font-weight: 750; }
tbody th { font-weight: 550; }
tbody tr + tr { border-top: 1px solid #f0eef4; }
tbody tr:nth-child(even) { background: #faf9fc; }
tfoot { background: #ebe5fb; }
.performance-grid tr > :not(:first-child), [id$="-orders-table"] tr > :nth-child(n + 7):nth-child(-n + 12) { text-align: right; }
.performance-grid td:not(:first-child), [id$="-orders-table"] td:nth-child(n + 7):nth-child(-n + 12) { white-space: nowrap; }
.finance-emphasis { font-weight: 750; color: var(--purple); }
.metric-amount-label { display: block; font-size: .78rem; font-weight: 700; }
.secondary-amount { margin-top: .4rem; }
.metric-secondary-value { display: block; font-size: .95rem; }
.metric-content:has(.metric-secondary-value) .metric-note { min-height: 0; }
.order-finance-detail details { min-width: 9rem; white-space: normal; }
.order-finance-detail details[open] { min-width: 15rem; }
.performance-grid tr > :first-child { min-width: 7.2rem; }
.performance-grid tbody th:first-child { overflow-wrap: anywhere; }
.cell-coverage { display: block; color: var(--muted); font-size: .65rem; font-weight: 500; }
.table-empty { color: var(--muted); }

.handoff-card {
  display: grid;
  grid-template-columns: minmax(10rem, auto) minmax(0, 1fr);
  gap: .75rem 1.5rem;
  width: min(100%, 62rem);
}

.handoff-list { padding-inline: .65rem; border: 1px solid var(--line); border-radius: .5rem; background: #fcfbfe; }
.handoff-list dt { font-weight: 650; }
.handoff-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .5rem; }
.handoff-actions .button { min-height: 2rem; font-size: .75rem; }

.orders-panel { margin-top: .72rem; }
.orders-heading, .pager { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem; }
.handoff-field { max-width: 20rem; margin-block: .65rem; }
.orders-status { margin-bottom: .45rem; color: var(--muted); }
[id$="-orders-table"] { min-width: 64rem; }
[id$="-quote-list-table"] { min-width: 42rem; }
[id$="-quote-list-table"] tr > :nth-child(n+4) { text-align: right; }
[id$="-quote-list-table"] td:nth-child(n+4) { white-space: nowrap; }
.pager { justify-content: flex-end; margin-top: .6rem; }

.report-footer { margin-top: .55rem; font-size: .74rem; }
.footer-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .7rem; }
.footer-meta p { color: var(--muted); }
.footer-meta .icon { width: .95rem; height: .95rem; }
.footer-meta .button { min-height: 1.75rem; padding: .23rem .55rem; }
.footer-version { margin-left: auto; padding: .2rem .6rem; border: 1px solid #d8d3e5; border-radius: 2rem; }
.report-notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: .5rem .75rem; margin-top: .45rem; }
.report-notes summary { width: fit-content; color: var(--purple); font-weight: 650; }
.detail-content { display: grid; gap: .5rem; margin-top: .38rem; padding: .65rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }

@media (max-width: 73rem) {
  body { grid-template-columns: 9.25rem minmax(0, 1fr); }
  .main { padding-inline: 1rem; }
  .session-tools { right: 1rem; }
  .module { padding-inline: .65rem; }
  .metric { gap: .45rem; padding-inline: .57rem; }
  .metric-icon { flex-basis: 1.2rem; }
  .metric-icon svg { width: 1.2rem; height: 1.2rem; }
  .performance-grid table { min-width: 30rem; }
}

@media (max-width: 64rem) {
  [id$="-filters"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reset { justify-self: start; }
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .visualizations { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visualizations > .card:last-child { grid-column: 1 / -1; min-height: auto; }
  .performance-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 43rem) {
  body { display: block; }
  .sidebar { position: static; display: flex; align-items: center; min-height: auto; }
  .brand { min-height: auto; padding: .45rem .65rem; }
  .brand img { width: 4.85rem; height: 2.4rem; }
  .module-list { display: flex; align-items: stretch; gap: .3rem; min-width: 0; padding: .4rem .4rem .4rem 0; }
  .module-list::after { display: none; }
  .module { gap: .3rem; min-width: 0; min-height: 2.65rem; padding: .32rem .48rem; font-size: .7rem; }
  .module .icon { width: .85rem; height: .85rem; }
  .main { padding: .85rem .75rem; }
  .main:has(#dashboard:not([hidden])) .page-header { padding-right: 0; }
  .session-tools { position: static; width: fit-content; margin-bottom: .6rem; }
  .filter-panel { padding-inline: 0; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .metric { min-height: 4.95rem; }
  .visualizations { grid-template-columns: minmax(0, 1fr); gap: .65rem; }
  .visualizations > .card { min-height: auto; }
  .handoff-card, .report-notes { grid-template-columns: minmax(0, 1fr); }
  .footer-version { margin-left: 0; }
}

@media (max-width: 22rem) {
  .module .icon { display: none; }
  [id$="-filters"] { grid-template-columns: minmax(0, 1fr); }
  .metric { gap: .32rem; padding-inline: .42rem; }
  .metric-label { font-size: .74rem; }
}

/* Each column owns its filters, report, chart and detail list. */
.comparison-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1.2rem; align-items:start; }
.comparison-view { min-width:0; padding:.8rem; border:1px solid var(--line); border-radius:var(--radius); background:linear-gradient(#fcfbff,#fff 18rem); }
.view-heading { display:flex; align-items:center; justify-content:space-between; gap:.75rem; margin-bottom:.65rem; }
.view-heading label { color:var(--muted); font-weight:700; }
.view-heading select { width:12rem; font-weight:750; color:var(--purple); background:var(--purple-soft); }
.comparison-view [id$="-filters"] { grid-template-columns:repeat(3,minmax(0,1fr)); gap:.5rem; }
.comparison-view .reset { grid-column:1 / -1; justify-self:start; min-height:1.85rem; font-size:.73rem; }
.comparison-view .scope-caption { min-height:2.2em; }
.comparison-view .metrics-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
.comparison-view .metric { min-height:6rem; padding:.6rem; gap:.45rem; }
.comparison-view .metric-label { min-height:2.5em; }
.comparison-view .metric-note { min-height:2.6em; }
.comparison-view .filter-panel .scope-caption { min-height:3em; }
.comparison-view .metric-value { font-size:clamp(1rem,1.2vw,1.3rem); }
.comparison-view .metric-icon { flex-basis:1.2rem; }
.comparison-view .metric-icon svg { width:1.2rem; height:1.2rem; }
.comparison-view .visualizations, .comparison-view .performance-grid { grid-template-columns:minmax(0,1fr); }
.comparison-view .visualizations > .card { min-height:11rem; }
.comparison-view .visualizations h2 { font-size:.98rem; }
.comparison-view .handoff-card { display:block; width:100%; }
.comparison-view .handoff-card h2, .activity-card h2 { margin-bottom:.5rem; }
.comparison-view .handoff-list { padding-inline:0; border:0; }
.comparison-view .activity-card { margin-bottom:.7rem; min-height:16rem; }
.comparison-view .handoff-card { min-height:16rem; }
.comparison-view .report-notes { grid-template-columns:minmax(0,1fr); }
.comparison-view .footer-meta { align-items:start; }
.comparison-view .performance-grid h2 { font-size:1rem; }
.comparison-view table { min-width:34rem; }
.comparison-view [id$="-orders-table"] { min-width:64rem; }
.comparison-view .trend svg { max-height:9rem; }
.comparison-view [id$="-status-chart"] svg { display:block; width:100%; height:auto; }
.comparison-view .scope-caption[data-partial="true"] { color:#8c5400; }
@media(max-width:76rem) {
  .comparison-grid { grid-template-columns:minmax(0,1fr); }
  .comparison-view .metrics-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .comparison-view .metric-value { font-size:1.35rem; }
}
@media(max-width:43rem) {
  .comparison-grid { gap:1rem; }
  .comparison-view { padding:.6rem; }
  .comparison-view [id$="-filters"] { grid-template-columns:minmax(0,1fr); }
  .comparison-view .metrics-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .comparison-view .metric { min-height:6.2rem; }
  .comparison-view .metric-value { font-size:1.1rem; }
  .comparison-view .cohort-result { gap:.5rem; }
  .comparison-view .stat-list > div { gap:.5rem; }
  .comparison-view .visualizations > .card { min-height:10rem; }
}
