:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #171513;
  --soft-ink: #4f4940;
  --paper: #ede7dc;
  --panel: #fffdfa;
  --enamel: #1f5d4d;
  --brass: #7c5a19;
  --rail: #928779;
  --stale: #8a3d2b;
  --unavailable: #5f5a52;
  --focus: #0d5bd7;
  --danger: #a3322a;
}

* {
  box-sizing: border-box;
}

html {
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  overflow-x: hidden;
}

button,
input,
select,
textarea,
a {
  font: inherit;
}

button,
input,
select,
textarea {
  max-width: 100%;
  min-width: 0;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.instrument-page {
  width: min(1320px, calc(100vw - 34px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.instrument-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}

.instrument-header p {
  margin: 0;
  color: var(--soft-ink);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.instrument-header h1 {
  max-width: 900px;
  margin: 5px 0 7px;
  font-size: clamp(1.75rem, 3.1vw, 2.75rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.instrument-place {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--soft-ink);
  font-size: 0.95rem;
  line-height: 1.4;
}

.instrument-nav {
  display: flex;
  gap: 10px;
  align-items: center;
}

.instrument-nav a {
  border: 2px solid var(--rail);
  border-radius: 2px;
  padding: 8px 11px;
  color: var(--soft-ink);
  background: var(--panel);
  text-decoration: none;
  font-weight: 720;
}

.instrument-nav a.active {
  border-color: var(--ink);
  color: var(--ink);
}

.search-console {
  display: grid;
  grid-template-columns: minmax(250px, 1.2fr) minmax(130px, 0.42fr) minmax(170px, 0.55fr) minmax(140px, 0.42fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  padding: 10px 0;
}

.search-console.compact {
  grid-template-columns: minmax(220px, 0.9fr) minmax(220px, 0.8fr) minmax(140px, 0.42fr) auto auto;
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.check-control,
.radius-control,
.rail-heading {
  color: var(--soft-ink);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

input[type="text"],
input:not([type]),
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 2px solid var(--rail);
  border-radius: 2px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 620;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.product-field input {
  font-size: 1rem;
}

.control-button {
  min-height: 40px;
  border: 2px solid var(--enamel);
  border-radius: 2px;
  padding: 8px 12px;
  color: var(--enamel);
  background: var(--panel);
  font-weight: 760;
  white-space: nowrap;
}

.control-button.primary {
  color: #fffaf0;
  background: var(--enamel);
}

.check-control {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--rail);
  color: var(--ink);
  letter-spacing: 0;
  text-transform: none;
}

.check-control input {
  width: 17px;
  height: 17px;
  accent-color: var(--enamel);
}

.instrument-workbench {
  display: grid;
  grid-template-columns: minmax(360px, 0.86fr) minmax(300px, 0.72fr) minmax(360px, 0.82fr);
  gap: 18px;
  align-items: stretch;
}

.instrument-control {
  min-width: 0;
  border: 2px solid var(--ink);
  padding: 14px;
  background: var(--panel);
}

.instrument-dial {
  position: relative;
  min-height: 440px;
  border: 2px solid var(--rail);
  background:
    radial-gradient(circle at center, transparent 0 18%, rgb(47 106 88 / 12%) 18% calc(18% + 2px), transparent calc(18% + 2px) 34%, rgb(47 106 88 / 10%) 34% calc(34% + 2px), transparent calc(34% + 2px) 51%, rgb(47 106 88 / 12%) 51% calc(51% + 2px), transparent calc(51% + 2px)),
    linear-gradient(90deg, transparent 49.8%, rgb(37 31 24 / 15%) 49.8% 50.2%, transparent 50.2%),
    linear-gradient(180deg, transparent 49.8%, rgb(37 31 24 / 15%) 49.8% 50.2%, transparent 50.2%),
    #fffefa;
}

.instrument-dial::after {
  content: "";
  position: absolute;
  inset: calc(50% - (38% * var(--radius-scale)));
  border: 3px solid var(--enamel);
  pointer-events: none;
}

.dial-readout {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 164px;
  transform: translate(-50%, -50%);
  border: 3px double var(--ink);
  padding: 10px;
  background: var(--panel);
  text-align: center;
  z-index: 2;
}

.dial-readout span,
.dial-readout em {
  display: block;
  color: var(--soft-ink);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 650;
}

.dial-readout strong {
  display: block;
  margin: 4px 0;
  font-size: 1.8rem;
  line-height: 1;
}

.instrument-marker {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  display: grid;
  grid-template-columns: auto;
  gap: 0;
  align-items: center;
  min-width: 54px;
  transform: translate(-50%, -50%);
  border: 0;
  border-left: 6px solid var(--enamel);
  border-radius: 0;
  padding: 6px 8px;
  color: var(--ink);
  background: #fffefa;
  box-shadow: 0 3px 0 rgb(23 21 19 / 14%);
  text-align: left;
  z-index: 3;
}

.instrument-marker span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid currentColor;
  font-weight: 780;
}

.instrument-marker b {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.instrument-marker.is-low {
  border-left-color: var(--brass);
}

.instrument-marker.is-stale {
  border-left-color: var(--stale);
  transform: translate(-50%, -50%) rotate(-1.2deg);
}

.instrument-marker.is-unavailable {
  border-left-color: var(--unavailable);
  opacity: 0.62;
}

.instrument-marker.is-out {
  opacity: 0.45;
}

.instrument-marker.is-selected {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.radius-panel {
  margin-top: 14px;
}

.radius-control {
  display: flex;
  justify-content: space-between;
}

input[type="range"] {
  width: 100%;
  margin-top: 14px;
  accent-color: var(--enamel);
}

.status {
  min-height: 28px;
  margin-top: 8px;
  color: var(--soft-ink);
  font-size: 0.88rem;
  font-weight: 620;
}

.status.ok {
  color: var(--enamel);
}

.status.error {
  color: var(--danger);
}

.instrument-lead-rail {
  display: grid;
  align-content: start;
  min-width: 0;
  border-left: 2px solid var(--ink);
  padding-left: 14px;
}

.rail-heading {
  display: grid;
  gap: 2px;
  margin-bottom: 12px;
}

.lead-list {
  display: grid;
  gap: 6px;
}

.lead-slip {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 5px 9px;
  border: 0;
  border-bottom: 2px solid var(--rail);
  border-radius: 0;
  padding: 8px 0 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.lead-slip > span {
  grid-row: span 3;
  color: var(--enamel);
  font-size: 1rem;
  font-weight: 780;
}

.lead-slip strong,
.lead-slip em,
.lead-slip b {
  display: block;
}

.lead-slip strong {
  font-size: 0.98rem;
  line-height: 1.25;
}

.lead-slip em {
  color: var(--soft-ink);
  font-size: 0.84rem;
  font-style: normal;
  line-height: 1.35;
}

.lead-slip b {
  font-size: 0.84rem;
}

.lead-slip.is-selected {
  border-bottom-color: var(--ink);
  background: linear-gradient(90deg, rgb(47 106 88 / 12%), transparent);
}

.lead-slip.is-low > span,
.lead-slip.is-low strong {
  color: var(--brass);
}

.lead-slip.is-stale > span,
.lead-slip.is-stale strong {
  color: var(--stale);
}

.lead-slip.is-unavailable,
.lead-slip.is-out {
  opacity: 0.58;
}

#storeDetail,
#discountDetail {
  min-width: 0;
  border: 2px solid var(--ink);
  padding: 14px;
  background: var(--panel);
}

.detail-kicker {
  color: var(--soft-ink);
  font-size: 0.78rem;
  font-weight: 720;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.detail-shell h2 {
  margin: 7px 0;
  font-size: clamp(1.45rem, 2.1vw, 2rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.detail-lede {
  margin: 0 0 14px;
  color: var(--soft-ink);
  font-size: 0.95rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.offline-boundary {
  margin: -4px 0 14px;
  border-left: 3px solid var(--rail);
  padding-left: 10px;
  color: var(--soft-ink);
  font-size: 0.88rem;
  font-weight: 620;
  line-height: 1.45;
}

.detail-facts {
  display: grid;
  gap: 9px 14px;
  margin: 14px 0;
}

.detail-facts div {
  border-top: 2px solid var(--rail);
  padding-top: 7px;
}

dt {
  color: var(--soft-ink);
  font-size: 0.72rem;
  font-weight: 720;
  text-transform: uppercase;
}

dd {
  margin: 2px 0 0;
  font-weight: 650;
}

.reason-list {
  margin: 0 0 14px 20px;
  padding: 0;
  color: var(--soft-ink);
  line-height: 1.45;
  font-size: 0.9rem;
}

.stale-warning {
  border: 2px solid var(--stale);
  padding: 9px;
  color: var(--stale);
  font-weight: 700;
}

.muted-warning {
  border-color: var(--unavailable);
  color: var(--unavailable);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions a {
  border: 2px solid var(--enamel);
  border-radius: 2px;
  padding: 9px 12px;
  color: var(--enamel);
  background: var(--panel);
  text-decoration: none;
  font-weight: 760;
}

.actions a:first-child {
  color: #fffaf0;
  background: var(--enamel);
}

.listing-report {
  margin-top: 16px;
  border-top: 2px solid var(--rail);
  padding-top: 12px;
}

.listing-report summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 720;
}

.report-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.empty-state {
  border-top: 2px solid var(--rail);
  border-bottom: 2px solid var(--rail);
  padding: 14px 0;
  color: var(--soft-ink);
  font-weight: 620;
  line-height: 1.45;
}

.empty-detail {
  min-height: 260px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .instrument-header {
    grid-template-columns: 1fr;
  }

  .search-console,
  .search-console.compact {
    grid-template-columns: minmax(260px, 1fr) minmax(160px, 0.5fr) minmax(180px, 0.6fr);
  }

  .instrument-workbench {
    grid-template-columns: minmax(390px, 1fr) minmax(320px, 0.8fr);
  }

  #storeDetail,
  #discountDetail {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .instrument-page {
    width: 100%;
    padding: 10px 10px 22px;
  }

  .instrument-header {
    gap: 10px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 10px;
  }

  .instrument-header p {
    font-size: 0.7rem;
  }

  .instrument-header h1 {
    font-size: clamp(1.3rem, 6vw, 1.75rem);
    line-height: 1.12;
  }

  .instrument-place {
    display: grid;
    gap: 5px;
    font-size: 0.84rem;
  }

  .instrument-nav {
    width: 100%;
    gap: 6px;
  }

  .instrument-nav a {
    flex: 1;
    min-height: 38px;
    padding: 8px 10px;
    text-align: center;
  }

  .search-console,
  .search-console.compact {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
    border: 2px solid var(--ink);
    padding: 10px;
    background: var(--panel);
  }

  .field label,
  .check-control,
  .radius-control,
  .rail-heading {
    font-size: 0.78rem;
  }

  .field input,
  .field select,
  .field textarea,
  .control-button {
    min-height: 42px;
  }

  .check-control {
    border: 2px solid var(--rail);
    padding: 8px 10px;
  }

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

  .instrument-control,
  .instrument-lead-rail,
  #storeDetail,
  #discountDetail {
    min-width: 0;
    padding: 10px;
  }

  .instrument-dial {
    min-height: 260px;
  }

  .dial-readout {
    width: 122px;
    padding: 8px;
  }

  .dial-readout strong {
    font-size: 1.45rem;
  }

  .instrument-marker {
    border-left-width: 5px;
    padding: 4px;
    min-width: 42px;
  }

  .instrument-marker span {
    width: 26px;
    height: 26px;
  }

  .instrument-lead-rail {
    margin: 0;
    border-left: 0;
    border-top: 2px solid var(--ink);
    padding: 12px 0 0;
  }

  .detail-facts {
    grid-template-columns: 1fr;
  }

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

  .detail-shell h2 {
    font-size: 1.35rem;
  }

  .detail-lede,
  .offline-boundary,
  .reason-list {
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
