:root {
  color-scheme: light;
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-soft: #f7f7f9;
  --surface-strong: #111216;
  --ink: #111216;
  --muted: #686b73;
  --line: #e1e2e6;
  --line-strong: #c8cad1;
  --blue: #2f6af6;
  --cyan: #22d5d0;
  --green: #008f68;
  --amber: #d97900;
  --red: #ef3156;
  --teal: #007f84;
  --purple: #7357c7;
  --shadow: 0 8px 24px rgba(17, 18, 22, 0.055);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(34, 213, 208, 0.35);
  outline-offset: 2px;
}

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

.app-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-height: 100vh;
  padding: 22px 14px 18px;
  overflow-y: auto;
  background: var(--surface-strong);
  color: #fff;
}

.app-sidebar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--cyan) 0 48%, var(--red) 48% 100%);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 52px;
  padding: 0 8px;
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  border: 1px solid #303138;
  border-radius: 8px;
}

.sidebar-brand div,
.sidebar-signal div {
  display: grid;
  min-width: 0;
}

.sidebar-brand strong {
  font-size: 14px;
  letter-spacing: 0.04em;
}

.sidebar-brand span {
  margin-top: 3px;
  color: #9b9da6;
  font-size: 11px;
  font-weight: 650;
}

.sidebar-label {
  margin: 34px 10px 10px;
  color: #747780;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-signal {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid #2a2b31;
}

.live-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 4px rgba(34, 213, 208, 0.12);
}

.sidebar-signal strong {
  font-size: 12px;
}

.sidebar-signal span {
  margin-top: 3px;
  color: #8e9099;
  font-size: 11px;
}

.app-workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-start;
  min-height: 118px;
  padding: 22px 28px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand-block h1 {
  max-width: 520px;
  margin: 6px 0 0;
  font-size: 25px;
  line-height: 1.18;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.topbar-utilities {
  display: grid;
  justify-items: end;
  gap: 10px;
  width: min(100%, 460px);
}

.source-block {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
}

.source-block span,
.panel-tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

#source-sync {
  border-color: rgba(0, 143, 104, 0.24);
  background: #edf9f5;
  color: var(--green);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 7px;
  width: 100%;
}

.language-control {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  gap: 8px;
  padding: 0 7px 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  justify-content: space-between;
}

.language-control select {
  min-width: 104px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 750;
}

.period-toolbar {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(520px, 1fr) minmax(190px, auto);
  gap: 12px 18px;
  align-items: center;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.period-heading {
  display: grid;
  gap: 3px;
}

.period-heading span,
.custom-period label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.period-heading strong {
  font-size: 13px;
}

.period-segmented {
  display: grid;
  grid-template-columns: repeat(6, minmax(72px, 1fr));
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.period-segmented button {
  min-width: 0;
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
}

.period-segmented button:last-child {
  border-right: 0;
}

.period-segmented button:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.period-segmented button.active {
  background: var(--surface-strong);
  color: #fff;
}

.custom-period {
  grid-column: 2 / -1;
  display: flex;
  align-items: end;
  gap: 9px;
  min-width: 0;
}

.custom-period[hidden] {
  display: none;
}

.custom-period label {
  display: grid;
  gap: 4px;
}

.custom-period input {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.period-divider {
  padding-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.period-coverage {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  text-align: right;
}

.ghost-button,
.file-button,
.preset-button,
.tab {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}

.ghost-button,
.file-button,
.preset-button {
  padding: 0 11px;
  font-size: 12px;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.toolbar .ghost-button,
.toolbar .file-button {
  justify-content: center;
  width: 100%;
}

.ghost-button:hover,
.file-button:hover,
.preset-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.file-button {
  display: inline-flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.tabs {
  display: grid;
  gap: 5px;
}

.tab {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: #aaacb4;
  font-size: 13px;
  text-align: left;
  transition: background 160ms ease, color 160ms ease;
}

.tab span {
  color: #656871;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.tab.active {
  border-color: #2d2f36;
  background: #25262c;
  color: #fff;
}

.tab.active span {
  color: var(--cyan);
}

.tab:hover {
  background: #1d1e23;
  color: #fff;
}

main {
  max-width: 1720px;
  margin: 0 auto;
  padding: 18px 28px 42px;
}

.status-line {
  min-height: 28px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric-grid.compact {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.metric-card {
  position: relative;
  min-height: 124px;
  padding: 17px 16px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.metric-card .value {
  margin-top: 11px;
  font-size: 26px;
  font-weight: 850;
  line-height: 1.08;
  word-break: break-word;
}

.metric-card .delta {
  margin-top: 11px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.metric-card.good {
  border-top: 3px solid var(--green);
}

.metric-card.warn {
  border-top: 3px solid var(--amber);
}

.metric-card.bad {
  border-top: 3px solid var(--red);
}

.metric-card.info {
  border-top: 3px solid var(--blue);
}

.two-column,
.pricing-layout,
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  gap: 12px;
  margin-bottom: 12px;
}

.pricing-layout {
  grid-template-columns: minmax(340px, 1fr) minmax(340px, 0.85fr);
}

.pricing-decision-layout {
  grid-template-columns: minmax(520px, 1.12fr) minmax(360px, 0.78fr);
}

.split-layout {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  margin-bottom: 0;
}

.tiktok-sync-panel {
  margin-bottom: 12px;
  border-top: 3px solid var(--ink);
}

.compass-command {
  margin-bottom: 12px;
  border-top: 3px solid var(--cyan);
}

.compass-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 -18px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.compass-filter {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 270px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compass-filter select {
  width: 100%;
  min-height: 36px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 760;
}

.compass-filter select:focus {
  border-color: var(--cyan);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(34, 213, 208, 0.13);
}

.compass-data-note {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 -18px -18px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.compass-data-note > div {
  min-width: 0;
  min-height: 104px;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.compass-data-note > div:last-child {
  border-right: 0;
}

.compass-data-note span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.compass-data-note strong {
  display: block;
  margin-top: 7px;
  font-size: 17px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.compass-data-note p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.compass-analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.compass-comparison-panel {
  margin-bottom: 12px;
}

.compass-comparison-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.compass-comparison-item {
  min-width: 0;
  padding: 15px 16px;
  border-right: 1px solid var(--line);
}

.compass-comparison-item:last-child {
  border-right: 0;
}

.compass-comparison-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compass-comparison-item strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.compass-comparison-item small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  line-height: 1.4;
}

.compass-comparison-item small.good {
  color: var(--green);
}

.compass-comparison-item small.warn {
  color: var(--amber);
}

.compass-comparison-item small.bad {
  color: var(--red);
}

.compass-analysis-grid > .panel {
  min-width: 0;
}

.compass-chart {
  min-height: 278px;
}

.compass-sku-table {
  max-height: 560px;
  overflow: auto;
}

.compass-sku-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.compass-actions {
  display: grid;
  border-top: 1px solid var(--line);
}

.compass-action {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.compass-action-index {
  color: var(--line-strong);
  font-size: 20px;
  font-weight: 880;
  font-variant-numeric: tabular-nums;
}

.compass-action-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.compass-action-title strong {
  font-size: 15px;
  line-height: 1.35;
}

.compass-action p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.compass-action small {
  display: block;
  margin-top: 7px;
  color: #435061;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.45;
}

.sync-review-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 0;
  margin: 0 -18px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sync-review-card {
  min-height: 116px;
  padding: 15px 18px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-soft);
}

.sync-review-card:last-child {
  border-right: 0;
}

.sync-review-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.sync-review-card strong {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.2;
}

.sync-review-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.inline-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.inline-link:hover {
  text-decoration: underline;
}

.sync-tables {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.82fr);
  gap: 18px;
}

.sync-tables > div {
  min-width: 0;
}

.orders-command,
.ads-command {
  border-top: 3px solid var(--blue);
}

.order-progress {
  display: grid;
  gap: 9px;
  margin: 0 -18px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.order-progress-copy,
.order-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.order-progress-copy strong {
  font-size: 18px;
}

.order-progress-copy span,
.order-progress-meta {
  color: var(--muted);
  font-size: 12px;
}

.order-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #dde4ee;
}

.order-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.full-order-table {
  margin-top: 16px;
  overflow-x: auto;
}

.full-order-table table {
  min-width: 980px;
}

.table-actions {
  display: flex;
  justify-content: center;
  padding-top: 14px;
}

.table-actions button:disabled {
  cursor: default;
  opacity: 0.55;
}

.sync-tables h3 {
  margin: 0 0 9px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0;
}

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 12px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 3px 0 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.chart-wrap {
  min-height: 330px;
  overflow: hidden;
}

.chart-wrap.small {
  min-height: 240px;
}

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

.chart-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.chart-title {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

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

.brief-list,
.alert-list,
.contract-grid {
  display: grid;
  gap: 10px;
}

.brief-item,
.alert-item,
.contract-item,
.scenario-card,
.result-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.brief-item strong,
.alert-item strong,
.contract-item strong,
.scenario-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.brief-item p,
.alert-item p,
.contract-item p,
.scenario-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.alert-item.high {
  border-left: 4px solid var(--red);
}

.alert-item.medium {
  border-left: 4px solid var(--amber);
}

.alert-item.low {
  border-left: 4px solid var(--blue);
}

.alert-item.ok {
  border-left: 4px solid var(--green);
}

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

.bar-row {
  display: grid;
  grid-template-columns: 156px minmax(120px, 1fr) 92px;
  align-items: center;
  gap: 10px;
}

.bar-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.bar-track {
  height: 9px;
  border-radius: 3px;
  background: #e8e9ed;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--blue);
}

.bar-value {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-align: right;
}

.mini-table,
.checks-table {
  max-width: 100%;
  overflow-x: auto;
}

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

#tiktok-product-table th:nth-child(4),
#tiktok-product-table td:nth-child(4) {
  min-width: 82px;
  white-space: nowrap;
}

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

th {
  color: #555861;
  font-size: 12px;
  font-weight: 850;
  background: #f2f2f5;
}

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

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

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.preset-button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.control {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.control input[type="number"] {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 780;
}

.control select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 780;
}

.pricing-control-grid {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.checkbox-control {
  align-content: start;
}

.checkbox-control input {
  width: 22px;
  height: 22px;
  accent-color: var(--red);
}

.control input[type="range"] {
  width: 100%;
  accent-color: var(--red);
}

.control input[type="number"]:focus,
.control select:focus {
  border-color: var(--cyan);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(34, 213, 208, 0.13);
}

.control strong {
  color: var(--ink);
  font-size: 13px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.decision-box {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.decision-box strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}

.decision-box p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.decision-box.good {
  border-left: 4px solid var(--green);
}

.decision-box.warn {
  border-left: 4px solid var(--amber);
}

.decision-box.bad {
  border-left: 4px solid var(--red);
}

.result-card .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.result-card .value {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 850;
  word-break: break-word;
}

.waterfall {
  display: grid;
  gap: 9px;
}

.waterfall-row {
  display: grid;
  grid-template-columns: 110px minmax(120px, 1fr) 98px;
  align-items: center;
  gap: 10px;
}

.waterfall-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.waterfall-track {
  height: 9px;
  border-radius: 3px;
  background: #e8e9ed;
  overflow: hidden;
}

.waterfall-fill {
  height: 100%;
  border-radius: inherit;
}

.waterfall-fill.positive {
  background: var(--green);
}

.waterfall-fill.negative {
  background: var(--red);
}

.waterfall-value {
  text-align: right;
  color: var(--ink);
  font-size: 12px;
  font-weight: 820;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.scenario-card {
  min-height: 156px;
}

.scenario-card.good {
  border-top: 4px solid var(--green);
}

.scenario-card.bad {
  border-top: 4px solid var(--red);
}

.scenario-price {
  margin: 8px 0 8px;
  font-size: 24px;
  font-weight: 880;
}

.scenario-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.scenario-meta span {
  padding: 6px 8px;
  border-radius: 5px;
  background: #e9eaee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.contract-grid {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.erp-top-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.75fr);
}

.integration-grid,
.requirement-grid,
.engine-grid {
  display: grid;
  gap: 12px;
}

.integration-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.requirement-grid {
  grid-template-columns: repeat(4, minmax(210px, 1fr));
}

.engine-grid {
  grid-template-columns: repeat(4, minmax(190px, 1fr));
}

.status-card,
.requirement-card,
.engine-card,
.roadmap-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.status-card.good,
.requirement-card.good {
  border-left: 4px solid var(--green);
}

.status-card.warn,
.requirement-card.warn {
  border-left: 4px solid var(--amber);
}

.status-card.info,
.requirement-card.info {
  border-left: 4px solid var(--blue);
}

.status-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.status-card-head strong,
.engine-card strong {
  font-size: 15px;
  line-height: 1.3;
}

.status-card p,
.engine-card p,
.engine-card small {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.48;
}

.engine-card small {
  display: block;
  margin-top: 12px;
  color: #435061;
  font-weight: 720;
}

.status-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.status-badge.good {
  background: var(--green);
}

.status-badge.warn {
  background: var(--amber);
}

.status-badge.info {
  background: var(--blue);
}

.requirement-card ul,
.roadmap-item ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.requirement-card li + li,
.roadmap-item li + li {
  margin-top: 6px;
}

.url-stack,
.callback-details {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.url-stack span,
.callback-details span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.url-stack code {
  display: block;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f1f1f4;
  color: var(--ink);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.callback-details div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.callback-details b {
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.roadmap {
  display: grid;
  gap: 0;
}

.roadmap-item {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  box-shadow: none;
}

.roadmap-item:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.roadmap-item:last-child {
  border-bottom: 1px solid var(--line);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.roadmap-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 5px rgba(34, 213, 208, 0.14);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .topbar {
    flex-direction: column;
    min-height: 0;
  }

  .topbar-utilities {
    justify-items: start;
    max-width: none;
  }

  .source-block,
  .toolbar {
    justify-content: flex-start;
  }

  .metric-grid,
  .metric-grid.compact,
  .contract-grid,
  .scenario-grid,
  .compass-comparison-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .compass-comparison-item:nth-child(2) {
    border-right: 0;
  }

  .compass-comparison-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .two-column,
  .pricing-layout,
  .pricing-decision-layout,
  .split-layout,
  .compass-analysis-grid,
  .erp-top-grid,
  .sync-tables {
    grid-template-columns: 1fr;
  }

  .integration-grid,
  .requirement-grid,
  .engine-grid,
  .sync-review-grid,
  .compass-data-note {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .compass-data-note > div:nth-child(2) {
    border-right: 0;
  }

  .compass-data-note > div:last-child {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    position: sticky;
    z-index: 30;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    min-height: 0;
    max-height: none;
    padding: 9px 14px;
    overflow: visible;
  }

  .app-sidebar::before {
    inset: auto 0 0;
    height: 3px;
  }

  .sidebar-brand {
    min-height: 40px;
    padding: 0;
  }

  .sidebar-brand img {
    width: 34px;
    height: 34px;
  }

  .sidebar-brand div,
  .sidebar-label,
  .sidebar-signal {
    display: none;
  }

  .tabs {
    display: flex;
    gap: 5px;
    padding-left: 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    display: inline-flex;
    width: auto;
    min-width: max-content;
    min-height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }

  .tab span {
    display: none;
  }

  .topbar {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .period-toolbar,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    gap: 18px;
    padding-top: 18px;
    padding-bottom: 16px;
  }

  .brand-block h1 {
    font-size: 21px;
  }

  .topbar-utilities,
  .source-block,
  .toolbar {
    width: 100%;
  }

  .period-toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .period-heading {
    grid-template-columns: auto 1fr;
    align-items: baseline;
    gap: 8px;
  }

  .period-segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .period-segmented button:nth-child(3) {
    border-right: 0;
  }

  .period-segmented button:nth-child(-n + 3) {
    border-bottom: 1px solid var(--line);
  }

  .custom-period {
    grid-column: auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
  }

  .custom-period .ghost-button {
    grid-column: 1 / -1;
  }

  .custom-period input {
    width: 100%;
  }

  .period-coverage {
    text-align: left;
  }

  .compass-filter-bar {
    display: grid;
  }

  .compass-filter {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .language-control,
  .ghost-button,
  .file-button {
    justify-content: center;
    min-width: 0;
  }

  .language-control select {
    min-width: 0;
  }

  .metric-grid,
  .metric-grid.compact,
  .control-grid,
  .pricing-control-grid,
  .result-grid,
    .contract-grid,
    .scenario-grid,
    .integration-grid,
    .requirement-grid,
    .engine-grid,
    .sync-review-grid,
    .compass-data-note,
    .compass-comparison-grid {
    grid-template-columns: 1fr;
  }

  .compass-comparison-item,
  .compass-comparison-item:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .compass-comparison-item:last-child {
    border-bottom: 0;
  }

  .compass-data-note > div,
  .compass-data-note > div:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .compass-data-note > div:last-child {
    grid-column: auto;
    border-top: 0;
    border-bottom: 0;
  }

  .sync-review-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sync-review-card:last-child {
    border-bottom: 0;
  }

  .panel-heading {
    display: grid;
    gap: 10px;
  }

  .panel-heading .panel-tag {
    justify-self: start;
  }

  .sync-tables,
  .sync-tables > div,
  .mini-table,
  .checks-table {
    min-width: 0;
  }

  .panel,
  .metric-card {
    box-shadow: none;
  }

  .bar-row,
  .waterfall-row {
    grid-template-columns: 1fr;
  }

  .bar-value,
  .waterfall-value {
    text-align: left;
  }
}
