:root {
  --bg: #060913;
  --surface: rgba(13, 18, 30, 0.9);
  --surface-strong: rgba(18, 25, 40, 0.96);
  --ink: #eafff9;
  --muted: #8aa4ae;
  --line: rgba(87, 255, 221, 0.14);
  --line-strong: rgba(87, 255, 221, 0.3);
  --teal: #41f0d0;
  --teal-strong: #a7fff2;
  --mint: rgba(65, 240, 208, 0.14);
  --amber: #ffc44d;
  --rose: #ff5ca8;
  --violet: #7a6dff;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(65, 240, 208, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(65, 240, 208, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, #05070f 0%, #0b111a 52%, #060913 100%);
  background-size: 28px 28px, 28px 28px, auto;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(125deg, transparent 0 64%, rgba(255, 92, 168, 0.06) 64% 66%, transparent 66%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 28%);
}

[hidden] {
  display: none !important;
}

.auth-gate {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px 16px;
}

.auth-card {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(18, 25, 40, 0.96), rgba(8, 13, 22, 0.98));
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 22px;
}

.auth-copy {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-copy h2,
.auth-copy p {
  margin: 0;
}

.auth-copy h2 {
  font-size: clamp(28px, 8vw, 44px);
  line-height: 1;
}

.auth-copy p {
  color: var(--muted);
  line-height: 1.5;
}

.auth-status {
  margin-bottom: 14px;
}

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

.boot-error {
  position: fixed;
  inset: 16px 16px auto;
  z-index: 30;
  display: grid;
  gap: 4px;
  max-width: 560px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 92, 168, 0.36);
  border-radius: 8px;
  background: rgba(36, 12, 28, 0.96);
  color: #ffe6f3;
  box-shadow: var(--shadow);
}

.boot-error span {
  color: rgba(255, 230, 243, 0.82);
}

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

button {
  cursor: pointer;
}

button,
input,
select,
textarea,
summary {
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: none;
  border-color: var(--line-strong);
  box-shadow:
    0 0 0 1px rgba(65, 240, 208, 0.26),
    0 0 0 4px rgba(65, 240, 208, 0.08);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(138, 164, 174, 0.34);
  background-clip: padding-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(288px, 340px) minmax(0, 1fr);
  min-height: 100vh;
  z-index: 1;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(10, 16, 27, 0.98), rgba(6, 11, 20, 0.98)),
    rgba(8, 12, 19, 0.98);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.02);
  color: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(135deg, #41f0d0 0%, #18b8ff 58%, #ffc44d 100%);
  color: #061017;
  box-shadow:
    0 0 0 1px rgba(65, 240, 208, 0.14),
    0 18px 34px rgba(24, 184, 255, 0.18);
}

.brand-mark svg {
  width: 31px;
  height: 31px;
  fill: currentColor;
}

.brand h1,
.brand p,
.section-title h3,
.topbar h2,
.control-group p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.15;
  text-shadow: 0 0 16px rgba(65, 240, 208, 0.08);
}

.brand p {
  margin-top: 4px;
  color: rgba(234, 255, 249, 0.7);
  font-size: 13px;
}

.planner-form {
  display: grid;
  gap: 18px;
}

.control-group {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(19, 26, 40, 0.92), rgba(11, 17, 29, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 16px 36px rgba(0, 0, 0, 0.22);
}

.group-heading,
.field,
.section-title,
.topbar,
.topbar-actions,
.api-actions {
  display: flex;
  align-items: center;
}

.group-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(234, 255, 249, 0.7);
}

.district-list,
.supply-article-list {
  display: grid;
  gap: 8px;
}

.district-option,
.supply-article-option {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.district-option input,
.supply-article-option input {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
}

.district-option:hover,
.supply-article-option:hover {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.06);
}

.district-option:has(input:checked),
.supply-article-option:has(input:checked) {
  border-color: var(--line-strong);
  background:
    linear-gradient(90deg, rgba(65, 240, 208, 0.18), rgba(18, 25, 40, 0.92) 26%);
  box-shadow:
    inset 0 0 0 1px rgba(65, 240, 208, 0.12),
    0 0 22px rgba(65, 240, 208, 0.08);
}

.district-option span,
.supply-article-option span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.district-option small,
.supply-article-option small {
  color: rgba(234, 255, 249, 0.58);
  font-size: 12px;
}

.supply-article-list {
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.supply-article-option {
  min-height: 50px;
}

.supply-article-option span {
  display: grid;
  gap: 2px;
}

.supply-article-option strong {
  font-size: 14px;
}

.supply-article-option em {
  color: rgba(234, 255, 249, 0.58);
  font-style: normal;
  font-size: 12px;
}

.supply-article-option small {
  text-align: right;
  white-space: nowrap;
}

.field {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 16px;
  color: rgba(234, 255, 249, 0.88);
  font-size: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field output {
  font-weight: 800;
  color: #fff;
}

.field input[type="range"] {
  flex-basis: 100%;
  width: 100%;
  accent-color: var(--amber);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  height: 42px;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.04);
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  height: 34px;
  border-radius: 7px;
  color: rgba(234, 255, 249, 0.68);
  font-size: 13px;
  font-weight: 700;
}

.segmented input:checked + span {
  color: #061017;
  background: linear-gradient(135deg, var(--teal), #7fffe9);
  box-shadow: 0 0 18px rgba(65, 240, 208, 0.18);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  color: #091018;
  background: linear-gradient(135deg, var(--amber), #ffe07d);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 16px 32px rgba(255, 196, 77, 0.22);
}

.primary-button:hover {
  background: linear-gradient(135deg, #ffd46d, #ffea93);
  transform: translateY(-1px);
}

.secondary-button,
.ghost-button {
  padding: 0 14px;
  color: var(--ink);
  background: rgba(18, 25, 40, 0.94);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: var(--line-strong);
  color: var(--teal-strong);
  background: rgba(20, 32, 50, 0.98);
}

.secondary-button:disabled,
.ghost-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  box-shadow: none;
}

.icon-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  color: currentColor;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.topbar .icon-button,
.section-title .icon-button {
  color: var(--ink);
  background: rgba(18, 25, 40, 0.94);
  border: 1px solid var(--line);
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--teal-strong);
  transform: translateY(-1px);
}

button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.workspace {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 42px) 42px;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h2 {
  margin-top: 5px;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.05;
  max-width: 860px;
  text-shadow: 0 0 18px rgba(65, 240, 208, 0.08);
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.eyebrow {
  margin: 0;
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 5px;
  margin-bottom: 20px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tab {
  min-width: max-content;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.is-active {
  color: #081017;
  background: linear-gradient(135deg, var(--teal), #9ffff1);
  box-shadow: 0 0 20px rgba(65, 240, 208, 0.14);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric-card,
.recommendations,
.insight-panel,
.product-card,
.warehouse-card,
.api-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(16, 23, 37, 0.92), rgba(10, 15, 26, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 16px 44px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
}

.metric-card {
  min-height: 112px;
  padding: 18px;
  position: relative;
}

.metric-card small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.help-dot {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--teal-strong);
  background: rgba(9, 14, 22, 0.96);
  font-size: 12px;
  font-weight: 900;
}

.help-dot::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 12;
  width: min(260px, 72vw);
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(6, 10, 18, 0.98);
  color: var(--ink);
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: normal;
}

.help-dot:hover::after,
.help-dot:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
  color: var(--teal-strong);
  text-shadow: 0 0 14px rgba(65, 240, 208, 0.08);
}

.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric-card small .help-dot {
  display: inline-grid;
  margin-top: 0;
  color: var(--teal-strong);
}

.comparison-panel,
.blockers-panel {
  margin-bottom: 20px;
}

.period-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.period-select select {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-strong);
  font-weight: 850;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
}

.comparison-card {
  min-height: 144px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(16, 23, 37, 0.92), rgba(10, 15, 26, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 16px 44px rgba(0, 0, 0, 0.24);
}

.comparison-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.comparison-card header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.comparison-card header strong {
  font-size: 21px;
  line-height: 1.1;
  text-align: right;
}

.stacked-bar {
  display: flex;
  width: 100%;
  height: 18px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(255, 255, 255, 0.06);
}

.stacked-bar span {
  display: block;
  min-width: 0;
}

.bar-local {
  background: var(--teal);
}

.bar-nonlocal {
  background: var(--rose);
}

.bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.bar-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.local-dot {
  background: var(--teal);
}

.nonlocal-dot {
  background: var(--rose);
}

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

.constraint-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
}

.constraint-card {
  min-height: 148px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(16, 23, 37, 0.92), rgba(10, 15, 26, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 16px 44px rgba(0, 0, 0, 0.24);
}

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

.constraint-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.constraint-card > strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  line-height: 1;
  color: var(--teal-strong);
  text-shadow: 0 0 14px rgba(65, 240, 208, 0.08);
}

.constraint-card p {
  margin: 10px 0 0;
  color: var(--ink);
  font-weight: 850;
  line-height: 1.35;
}

.constraint-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.blocker-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.blocker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.74);
}

.blocker-row strong,
.blocker-row span {
  display: block;
}

.blocker-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.blocker-row dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 8px;
  margin: 0;
  min-width: 160px;
}

.blocker-row dt {
  color: var(--muted);
  font-size: 12px;
}

.blocker-row dd {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.answer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}

.recommendations,
.insight-panel,
.api-panel {
  padding: 18px;
}

.section-title {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.section-title.compact {
  margin-bottom: 10px;
}

.section-title h3 {
  margin-top: 4px;
  font-size: 20px;
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

.warehouse-filter {
  position: relative;
}

.warehouse-filter summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 25, 40, 0.94);
  color: var(--ink);
  font-weight: 850;
  list-style: none;
  cursor: pointer;
}

.warehouse-filter summary::-webkit-details-marker {
  display: none;
}

.warehouse-filter summary svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.warehouse-filter-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 15;
  width: min(420px, calc(100vw - 32px));
  max-height: 420px;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 12, 20, 0.98);
  box-shadow: var(--shadow);
}

.filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.filter-toolbar strong {
  font-size: 13px;
}

.filter-toolbar button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(18, 25, 40, 0.94);
  color: var(--teal-strong);
  font-weight: 850;
}

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

.warehouse-check {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 13px;
}

.warehouse-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.warehouse-check:hover {
  border-color: rgba(255, 255, 255, 0.06);
}

.warehouse-check:has(input:checked) {
  border-color: var(--line-strong);
  background: linear-gradient(90deg, rgba(65, 240, 208, 0.16), rgba(18, 25, 40, 0.92) 32%);
}

.warehouse-check span {
  overflow-wrap: anywhere;
}

.warehouse-check small {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tbody tr:hover {
  background: rgba(65, 240, 208, 0.08);
}

.product-name {
  display: block;
  max-width: 250px;
  font-weight: 850;
}

.sku {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.alt-warehouse {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.supply-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  margin-top: 5px;
  border-radius: 6px;
  color: #091018;
  background: rgba(255, 196, 77, 0.92);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.supply-badge.is-locked {
  color: #fff4fb;
  background: rgba(255, 92, 168, 0.84);
}

.qty-pill,
.score-pill,
.district-chip,
.risk-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.qty-pill {
  color: #102421;
  background: var(--amber);
}

.score-pill {
  color: var(--teal-strong);
  background: rgba(65, 240, 208, 0.12);
  border: 1px solid rgba(65, 240, 208, 0.18);
}

.district-chip {
  color: #d7d4ff;
  background: rgba(122, 109, 255, 0.16);
  border: 1px solid rgba(122, 109, 255, 0.18);
}

.risk-pill.high {
  color: #ffd1e9;
  background: rgba(255, 92, 168, 0.14);
  border: 1px solid rgba(255, 92, 168, 0.16);
}

.risk-pill.medium {
  color: #ffe3a3;
  background: rgba(255, 196, 77, 0.14);
  border: 1px solid rgba(255, 196, 77, 0.18);
}

.risk-pill.low {
  color: var(--teal-strong);
  background: rgba(65, 240, 208, 0.12);
  border: 1px solid rgba(65, 240, 208, 0.18);
}

.reasoning-list {
  display: grid;
  gap: 12px;
}

.reason-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.72);
}

.reason-item strong {
  display: block;
  margin-bottom: 5px;
}

.reason-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.product-grid,
.warehouse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

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

.account-summary-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.74);
}

.account-summary-card strong,
.account-summary-card span,
.account-summary-card small {
  display: block;
}

.account-summary-card strong {
  font-size: 22px;
  color: var(--teal-strong);
}

.account-summary-card span {
  margin-top: 6px;
  font-weight: 800;
}

.account-summary-card small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.account-list {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.scenario-compare-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
}

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

.scenario-compare-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.74);
}

.scenario-compare-card h4,
.scenario-compare-card p,
.scenario-compare-card small {
  margin: 0;
}

.scenario-compare-card h4 {
  margin-top: 4px;
  font-size: 16px;
}

.scenario-compare-card p,
.scenario-compare-card small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}

.scenario-compare-metrics,
.scenario-compare-diff {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.scenario-compare-metrics div,
.scenario-compare-diff div,
.scenario-compare-verdict {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 19, 31, 0.82);
}

.scenario-compare-metrics span,
.scenario-compare-diff span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.scenario-compare-metrics strong,
.scenario-compare-diff strong,
.scenario-compare-verdict strong {
  display: block;
  margin-top: 6px;
  color: var(--teal-strong);
}

.scenario-compare-verdict {
  margin-top: 12px;
}

.scenario-compare-verdict p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.account-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.74);
}

.account-list-row strong,
.account-list-row span,
.account-list-row small {
  display: block;
}

.account-list-row strong {
  color: var(--ink);
  font-size: 14px;
}

.account-list-row span {
  margin-top: 4px;
  line-height: 1.35;
}

.account-list-row small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.account-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.danger-button {
  border-color: rgba(255, 92, 168, 0.24);
  color: #ffd3ea;
}

.danger-button:hover {
  border-color: rgba(255, 92, 168, 0.36);
  color: #fff3fa;
  background: rgba(255, 92, 168, 0.1);
}

.warehouse-admin-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(16, 23, 37, 0.92), rgba(10, 15, 26, 0.98));
}

.warehouse-reference-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.warehouse-summary-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.74);
}

.warehouse-summary-card strong,
.warehouse-summary-card span,
.warehouse-summary-card small {
  display: block;
}

.warehouse-summary-card strong {
  font-size: 24px;
  line-height: 1;
  color: var(--teal-strong);
}

.warehouse-summary-card span {
  margin-top: 6px;
  color: var(--ink);
  font-weight: 800;
}

.warehouse-summary-card small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.warehouse-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-button {
  position: relative;
  overflow: hidden;
}

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

.product-card,
.warehouse-card {
  padding: 16px;
}

.product-card header,
.warehouse-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.product-card h4,
.warehouse-card h4 {
  margin: 0;
  font-size: 17px;
}

.product-card dl,
.warehouse-card dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px 12px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.product-card dd,
.warehouse-card dd {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.warehouse-cover {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.warehouse-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.warehouse-editor {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.warehouse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.warehouse-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

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

.warehouse-editor label,
.warehouse-notes {
  display: grid;
  gap: 6px;
}

.warehouse-editor label span,
.warehouse-notes span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.warehouse-editor input,
.warehouse-notes input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(7, 12, 21, 0.86);
  font: inherit;
}

.api-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 18px;
}

.api-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(8, 13, 22, 0.76);
  color: var(--muted);
  font-weight: 750;
}

.compact-status {
  min-height: 36px;
  margin-top: -4px;
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--amber);
}

.api-status.ok .status-dot {
  background: #21a67a;
}

.api-status.error .status-dot {
  background: var(--rose);
}

.api-actions {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.token-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.76);
}

.token-field {
  display: grid;
  gap: 7px;
}

.token-field span,
.token-save {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.token-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(6, 10, 18, 0.94);
  font: inherit;
}

.token-save {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.token-save input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

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

.token-form p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.api-cooldown {
  min-height: 36px;
  margin: -2px 0 14px;
  padding: 9px 12px;
  border: 1px solid rgba(65, 240, 208, 0.16);
  border-radius: 8px;
  background: rgba(65, 240, 208, 0.08);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.api-cooldown.is-waiting {
  border-color: rgba(184, 81, 81, 0.24);
  background: rgba(184, 81, 81, 0.08);
  color: #8c3d3d;
}

.api-history-panel {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.76);
}

.api-history {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.api-history-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.1fr) minmax(110px, 0.8fr) minmax(86px, 0.55fr);
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.api-history-row:first-child {
  border-top: 0;
}

.api-history-row strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.api-history-row span {
  display: block;
  line-height: 1.35;
}

.api-schema {
  color: var(--teal-strong);
  overflow-wrap: anywhere;
}

.api-log {
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070c15;
  color: #d7fff7;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  box-shadow: inset 0 0 0 1px rgba(65, 240, 208, 0.06);
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 9px;
  min-height: 196px;
  padding: 20px;
  border: 1px dashed rgba(65, 240, 208, 0.34);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.72);
  color: var(--teal-strong);
  text-align: center;
  font-weight: 850;
}

.drop-zone input {
  display: none;
}

.drop-zone svg {
  width: 34px;
  height: 34px;
  fill: currentColor;
}

.schema-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.schema-note code {
  color: var(--ink);
  background: rgba(65, 240, 208, 0.12);
  padding: 2px 5px;
  border-radius: 5px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(6, 10, 18, 0.96);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1120px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .answer-layout,
  .api-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .auth-gate {
    align-items: start;
    padding: 18px 12px;
  }

  .auth-card {
    padding: 18px;
  }

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

  .app-shell {
    grid-template-columns: 1fr;
  }

  .comparison-grid,
  .constraint-grid {
    grid-template-columns: 1fr;
  }

  .warehouse-reference-summary,
  .warehouse-editor-grid,
  .account-summary-grid,
  .scenario-compare-grid,
  .scenario-compare-toolbar,
  .scenario-compare-metrics,
  .scenario-compare-diff {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding-inline: 14px;
  }

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

  .ghost-button,
  .secondary-button {
    width: 100%;
  }

  .api-history-row {
    grid-template-columns: 1fr;
  }

  .account-list-row {
    grid-template-columns: 1fr;
  }

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

  .topbar-actions,
  .api-actions {
    width: 100%;
  }

  .metric-card strong {
    font-size: 26px;
  }
}
