:root {
  --ink: #17201d;
  --muted: #66716d;
  --line: #dbe1de;
  --surface: #ffffff;
  --soft: #f4f7f5;
  --green: #146b4a;
  --green-dark: #0d5339;
  --amber: #a85f08;
  --red: #ad342c;
  --blue: #345f8c;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #eef2ef; font: 14px/1.45 Inter, "Segoe UI", Arial, sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.app-header { min-height: 88px; padding: 18px 28px; display: flex; align-items: center; justify-content: space-between; background: #13231d; color: white; border-bottom: 4px solid #d79a35; }
.app-header h1 { margin: 2px 0 0; font-size: 26px; font-weight: 650; }
.eyebrow { color: #8b9994; font-size: 11px; font-weight: 700; }
.app-header .eyebrow { color: #a9bbb4; }
.source-status { display: flex; gap: 8px; align-items: center; color: #d8e3df; font-size: 13px; }
#status-dot { width: 8px; height: 8px; border-radius: 50%; background: #d79a35; }
main { max-width: 1600px; margin: 0 auto; }
.control-band, .results-band, .diagnosis-band { background: var(--surface); border-bottom: 1px solid var(--line); padding: 24px 28px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading > div:first-child { display: flex; align-items: center; gap: 12px; min-width: 0; }
.section-heading h2 { margin: 0; font-size: 19px; }
.step { display: grid; place-items: center; width: 34px; height: 28px; border: 1px solid #aebbb6; border-radius: 4px; color: var(--green); font-size: 12px; font-weight: 800; }
form { display: grid; grid-template-columns: minmax(280px, 2fr) repeat(3, minmax(155px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .compact-field, .search-field { color: #4c5a55; font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #bdc8c3; border-radius: 4px; background: white; color: var(--ink); padding: 10px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 2px #d6ebe1; }
textarea { resize: vertical; }
.conditional-controls { grid-column: 1 / -1; display: grid; grid-template-columns: 220px 1fr; gap: 14px; }
.full { grid-column: 1 / -1; }
.advanced-row { grid-column: 1 / -1; min-height: 48px; display: flex; align-items: center; gap: 18px; padding-top: 8px; border-top: 1px solid #edf0ee; }
.toggle { display: flex; align-items: center; gap: 9px; white-space: nowrap; color: #45524e; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { width: 34px; height: 20px; background: #b9c3bf; border-radius: 12px; position: relative; transition: .18s ease; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: white; transition: .18s ease; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(14px); }
.threshold-controls { display: flex; gap: 10px; }
.threshold-controls label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.threshold-controls input { width: 72px; padding: 7px; }
.compact-field { display: flex; align-items: center; gap: 8px; margin-left: auto; white-space: nowrap; }
.compact-field select { width: 76px; padding: 8px; }
.button { min-height: 38px; border: 1px solid transparent; border-radius: 4px; padding: 8px 14px; font-weight: 700; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: white; color: #34443e; border-color: #bac5c0; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.hidden { display: none !important; }
.progress-band { margin: 14px 28px; padding: 16px; display: flex; gap: 12px; align-items: center; background: #e9f3ee; border: 1px solid #b9d6c8; border-radius: 6px; }
.progress-band span { display: block; color: var(--muted); font-size: 12px; }
.spinner { width: 22px; height: 22px; border: 3px solid #b8d5c7; border-top-color: var(--green); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 5; right: 20px; bottom: 20px; max-width: 520px; padding: 13px 16px; border-radius: 4px; color: white; background: var(--red); box-shadow: 0 8px 30px #0002; }
.results-heading { margin-bottom: 8px; }
.actions { display: flex; gap: 8px; }
.range-notice { margin: 0 0 16px 46px; color: var(--muted); font-size: 12px; }
.summary-strip { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 16px; }
.summary-item { padding: 13px 16px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item strong { display: block; font-size: 21px; font-weight: 650; }
.summary-item span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.result-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 8px 0; }
.drilldown-toggle { margin: 10px 0 14px; font-size: 13px; }
.segmented { display: flex; border: 1px solid #c5ceca; border-radius: 4px; overflow: hidden; }
.segmented button { border: 0; border-right: 1px solid #c5ceca; background: #f8faf9; padding: 8px 11px; color: #44514c; }
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: #eaf1ed; }
.search-field { display: flex; align-items: center; gap: 8px; }
.search-field input { width: 260px; padding: 8px; }
.filters { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.number-filter { display: flex; align-items: center; gap: 6px; color: #4c5a55; font-size: 12px; font-weight: 650; }
.number-filter input { width: 94px; padding: 8px; }
.number-filter select { width: 78px; padding: 8px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0 0; color: var(--muted); font-size: 13px; }
.pager-buttons { display: flex; align-items: center; gap: 10px; }
.pager-buttons button { min-height: 32px; border: 1px solid #c5ceca; border-radius: 4px; background: #fff; color: #34443e; padding: 6px 10px; font-weight: 700; }
.pager-buttons button:disabled { cursor: not-allowed; opacity: .45; }
table { width: 100%; min-width: 1120px; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 1; background: #f1f5f3; color: #53605b; font-size: 11px; text-align: left; text-transform: uppercase; padding: 10px; border-bottom: 1px solid #cfd8d4; }
td { padding: 11px 10px; border-bottom: 1px solid #e6ebe8; vertical-align: middle; }
tbody tr:hover { background: #f8faf9; }
.page-link { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; color: #244f70; cursor: pointer; }
.page-link small { display: block; color: var(--muted); font-weight: 400; }
.tier { display: inline-flex; min-width: 68px; justify-content: center; padding: 4px 7px; border-radius: 3px; font-size: 11px; font-weight: 800; }
.tier-critical { color: #84241f; background: #f9dedb; }
.tier-high { color: #8b4d04; background: #f9ead1; }
.tier-medium { color: #27597c; background: #dfeaf3; }
.tier-low { color: #4c5b56; background: #e8edeb; }
.negative { color: var(--red); font-weight: 700; }
.muted { color: var(--muted); }
.sparkline { width: 150px; height: 34px; display: block; }
.check-cell { width: 38px; text-align: center; }
.check-cell input { width: 16px; height: 16px; accent-color: var(--green); }
.empty-state { padding: 36px; text-align: center; color: var(--muted); }
.trend-detail { margin-top: 16px; padding: 18px 0 0; border-top: 1px solid var(--line); }
.trend-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.trend-heading h3 { margin: 3px 0 14px; font-size: 15px; overflow-wrap: anywhere; }
.icon-button { width: 32px; height: 32px; border: 1px solid #c4ceca; border-radius: 4px; background: white; font-weight: 800; }
#trend-chart { width: 100%; height: 220px; background: #fafcfb; border: 1px solid #e0e6e3; }
.week-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-top: 0; }
.week-cell { padding: 9px; border-right: 1px solid var(--line); font-size: 11px; }
.week-cell strong { display: block; font-size: 14px; }
.diagnosis-page { padding: 18px 0 24px; border-top: 1px solid var(--line); }
.diagnosis-page:first-child { border-top: 0; }
.diagnosis-title { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 10px; }
.diagnosis-title h3 { margin: 0; color: #244f70; font-size: 15px; overflow-wrap: anywhere; }
.cause { color: var(--green); font-weight: 800; white-space: nowrap; }
.cause-Cannibalization { color: var(--amber); }
.query-table { min-width: 1050px; }
@media (max-width: 900px) {
  .app-header, .control-band, .results-band, .diagnosis-band { padding-left: 16px; padding-right: 16px; }
  form { grid-template-columns: 1fr 1fr; }
  .property-field { grid-column: 1 / -1; }
  .advanced-row { flex-wrap: wrap; }
  .compact-field { margin-left: 0; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-item { border-bottom: 1px solid var(--line); }
  .section-heading, .result-toolbar { align-items: stretch; flex-direction: column; }
  .actions { width: 100%; }
  .actions .button { flex: 1; }
  .search-field { justify-content: space-between; }
  .filters { justify-content: flex-start; }
  .pagination { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
  form, .conditional-controls { grid-template-columns: 1fr; }
  .app-header { align-items: flex-start; }
  .app-header h1 { font-size: 21px; }
  .summary-strip { grid-template-columns: 1fr; }
  .segmented { overflow-x: auto; }
}
