:root {
  color-scheme: light;
  --paper: #f4f4ee;
  --surface: #fffefa;
  --ink: #202820;
  --muted: #70796f;
  --line: #d9ded4;
  --forest: #245c46;
  --mint: #cce9b9;
  --coral: #e66c50;
  --yellow: #f1ce64;
  --mono: 'Cascadia Mono', Consolas, monospace;
  --sans: 'Avenir Next', 'Trebuchet MS', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 14px; }
button, input, select { font: inherit; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(28px, calc((100vw - 1320px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255, 254, 250, .7); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.brand b { color: var(--coral); }
.brand-mark { width: 24px; height: 24px; position: relative; display: inline-block; }
.brand-mark::before, .brand-mark::after, .brand-mark i { content: ''; position: absolute; width: 6px; height: 6px; border: 2px solid var(--forest); border-radius: 50%; background: var(--paper); z-index: 1; }
.brand-mark::before { left: 1px; top: 9px; }
.brand-mark::after { right: 1px; top: 2px; }
.brand-mark i:first-child { right: 2px; bottom: 1px; }
.brand-mark i:nth-child(2) { position: absolute; width: 15px; height: 2px; border: 0; border-radius: 0; top: 8px; left: 5px; background: var(--forest); transform: rotate(-27deg); }
.brand-mark i:nth-child(3) { position: absolute; width: 15px; height: 2px; border: 0; border-radius: 0; top: 14px; left: 5px; background: var(--forest); transform: rotate(27deg); }
.data-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
.state-dot.ready { background: #5c9b68; }
.state-dot.error { background: var(--coral); }
main { max-width: 1320px; margin: 0 auto; padding: 50px 28px 28px; }
.intro { max-width: 830px; margin-bottom: 38px; animation: arrive .55s ease both; }
.eyebrow { margin: 0 0 10px; color: var(--forest); font: 500 10px var(--mono); letter-spacing: .1em; }
.eyebrow span { color: var(--coral); }
h1 { max-width: 760px; margin: 0; font-size: clamp(34px, 4vw, 54px); line-height: 1.08; letter-spacing: -.035em; font-weight: 800; }
h1 em { color: var(--forest); font-family: Georgia, serif; font-weight: 500; }
.intro-copy { max-width: 650px; margin: 16px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.workspace { display: grid; grid-template-columns: 290px minmax(0, 1fr); align-items: start; gap: 44px; }
.control-panel { position: sticky; top: 18px; padding: 22px 20px 18px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--forest); animation: arrive .55s .06s ease both; }
.panel-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.step-number { display: grid; place-items: center; width: 28px; height: 28px; background: var(--mint); color: var(--forest); font: 500 11px var(--mono); }
h2, h3, p { margin-top: 0; }
.panel-heading h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
form label { display: block; margin: 17px 0 7px; font-size: 12px; font-weight: 700; }
.input-with-unit { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 11px; border: 1px solid var(--line); background: #fff; }
.input-with-unit input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); font: 500 17px var(--mono); }
.input-with-unit span { flex: none; color: var(--muted); font: 11px var(--mono); }
select { width: 100%; height: 42px; padding: 0 10px; border: 1px solid var(--line); color: var(--ink); background: #fff; }
.field-hint { margin: 7px 0 12px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.primary-button { width: 100%; min-height: 46px; margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; color: white; background: var(--forest); font-weight: 700; cursor: pointer; transition: background .18s, transform .18s; }
.primary-button:hover:not(:disabled) { background: #174831; transform: translateY(-1px); }
.primary-button:disabled { opacity: .48; cursor: wait; }
.primary-button span { font-size: 18px; }
.calculation-progress { display: grid; grid-template-columns: 16px 1fr; align-items: center; column-gap: 8px; row-gap: 9px; margin-top: 12px; color: var(--forest); font: 10px var(--mono); }
.calculation-progress[hidden] { display: none; }
.loading-spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--coral); border-radius: 50%; animation: spinner-turn .7s linear infinite; }
.progress-track { grid-column: 1 / -1; display: block; height: 3px; overflow: hidden; background: #e3e8df; }
.progress-track i { display: block; width: 36%; height: 100%; background: var(--coral); animation: progress-sweep 1s ease-in-out infinite alternate; }
.method-note { display: grid; grid-template-columns: 3px 1fr; gap: 12px; margin-top: 24px; padding-top: 17px; border-top: 1px solid var(--line); }
.note-rule { background: var(--coral); }
.method-note p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.method-note strong { color: var(--ink); }
.results-column { min-width: 0; animation: arrive .55s .12s ease both; }
.status-message { min-height: 28px; margin: 0 0 10px; color: var(--muted); font-size: 11px; }
.status-message.error { color: #a53c2b; }
.result-section { padding: 0 0 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-heading .eyebrow { margin-bottom: 5px; }
.section-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.03em; }
.text-button { padding: 7px 0; border: 0; color: var(--forest); background: transparent; font-size: 11px; font-weight: 700; cursor: pointer; }
.text-button:disabled { opacity: .4; cursor: default; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.picking-list-wrap { max-height: 354px; overflow-y: scroll; overflow-x: hidden; scrollbar-gutter: stable; scrollbar-width: auto; scrollbar-color: var(--forest) #e2e7de; }
.picking-list-wrap::-webkit-scrollbar { width: 12px; }
.picking-list-wrap::-webkit-scrollbar-track { background: #e2e7de; }
.picking-list-wrap::-webkit-scrollbar-thumb { border: 2px solid #e2e7de; border-radius: 8px; background: var(--forest); }
.picking-list-wrap thead th { position: sticky; top: 0; z-index: 1; }
.picking-list-wrap th { height: 32px; padding-top: 0; padding-bottom: 0; }
.picking-list-wrap tbody td { height: 32px; padding-top: 0; padding-bottom: 0; white-space: nowrap; }
.picking-scroll-hint { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; color: var(--forest); font: 10px var(--mono); }
.picking-scroll-hint[hidden] { display: none; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 10px 13px; background: #ecefe7; color: var(--muted); font: 500 9px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
td { padding: 9px 13px; border-top: 1px solid #e9ece5; font-size: 11px; }
td:first-child { font-family: var(--mono); }
td:nth-child(2) { width: 80px; font-family: var(--mono); }
.empty-row { padding: 18px; color: var(--muted); text-align: center; }
.stock-state { display: inline-flex; align-items: center; gap: 6px; color: var(--forest); font-size: 10px; }
.stock-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #5c9b68; }
.stock-state.short { color: #a53c2b; }
.stock-state.short::before { background: var(--coral); }
.count-badge { padding: 6px 8px; background: #e4eadf; color: var(--forest); font: 10px var(--mono); }
.network-frame { border: 1px solid var(--line); background: var(--surface); }
#network-map { display: block; width: 100%; height: auto; min-height: 230px; }
.map-edge { stroke: #d9ded4; stroke-width: 1.1; }
.map-edge.mst { stroke: var(--coral); stroke-width: 3; animation: draw-in .5s ease both; }
.map-edge.traversal-pass { stroke-width: 2.5; }
.edge-weight { fill: #995342; font: 10px var(--mono); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.map-node { fill: #fffefa; stroke: #acb5aa; stroke-width: 2; }
.map-node.used { fill: var(--mint); stroke: var(--forest); stroke-width: 2.5; }
.map-node.base { fill: var(--forest); stroke: var(--forest); }
.map-label { fill: var(--ink); font: 10px var(--mono); text-anchor: middle; }
.map-label.base { fill: var(--forest); font-size: 9px; font-weight: 700; }
.map-legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 14px 12px; color: var(--muted); font-size: 9px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.legend-base { background: var(--forest); }
.legend-pick { border: 1px solid var(--forest); background: var(--mint); }
.legend-edge { height: 3px !important; width: 13px !important; border-radius: 0 !important; background: var(--coral); }
.legend-edge.return { opacity: .55; }
.cost-definition { margin: -5px 0 14px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.algorithm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.algorithm-card { position: relative; min-height: 145px; padding: 17px 15px; border: 1px solid var(--line); border-top: 3px solid var(--forest); background: var(--surface); }
.algorithm-card.prim { border-top-color: #d0a627; }
.algorithm-card.boruvka { border-top-color: var(--coral); }
.algorithm-index { position: absolute; top: 14px; right: 14px; color: #a6ada2; font: 10px var(--mono); }
.algorithm-card h3 { margin: 0 0 12px; font-size: 14px; }
.algorithm-metric-label { display: block; margin-bottom: 4px; color: var(--muted); font: 9px var(--mono); text-transform: uppercase; }
.algorithm-card strong { display: block; font: 500 23px var(--mono); }
.algorithm-card strong small { color: var(--muted); font-size: 10px; }
.algorithm-card p { margin: 9px 0 0; color: var(--muted); font-size: 9px; }
.validation-label { display: inline-block; margin-top: 7px; color: var(--forest); font: 500 9px var(--mono); }
.route-caption { margin: 11px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.route-details { display: grid; gap: 0; margin-top: 14px; border-top: 1px solid var(--line); }
.route-details p { display: grid; grid-template-columns: 82px minmax(0, 1fr) auto; align-items: center; gap: 8px; margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--muted); font: 10px var(--mono); line-height: 1.7; }
.route-details strong { color: var(--ink); }
.route-details .route-sequence { min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; scrollbar-color: var(--forest) var(--line); color: var(--muted); white-space: nowrap; touch-action: pan-x; }
.route-details .route-distance { color: var(--forest); font-weight: 500; white-space: nowrap; }
.tsp-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1px; margin: 17px 0; background: var(--line); border: 1px solid var(--line); }
.tsp-metric { display: flex; flex-direction: column; gap: 7px; min-height: 86px; justify-content: center; padding: 14px 17px; background: var(--surface); }
.tsp-metric span { color: var(--muted); font-size: 10px; }
.tsp-metric strong { color: var(--forest); font: 500 25px var(--mono); }
.tsp-metric.primary-metric { border-left: 3px solid var(--coral); }
.tsp-order { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 5px 0 12px; scrollbar-width: thin; scrollbar-color: var(--forest) var(--line); white-space: nowrap; }
.tsp-order span { padding: 7px 9px; background: #e5ecdf; color: var(--ink); font: 10px var(--mono); }
.tsp-order span:first-child, .tsp-order span:last-of-type { background: var(--forest); color: white; }
.tsp-order b { color: var(--coral); font: 12px var(--mono); }
.tsp-explanation { margin: 3px 0 12px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.tsp-table-wrap table { min-width: 620px; }
.tsp-table-wrap td:nth-child(3) { color: var(--muted); font: 10px var(--mono); }
.tsp-table-wrap td:last-child { color: var(--forest); font-family: var(--mono); white-space: nowrap; }
footer { display: flex; justify-content: space-between; gap: 16px; padding-top: 14px; color: var(--muted); font: 9px var(--mono); }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes draw-in { from { opacity: .2; } to { opacity: 1; } }
@keyframes spinner-turn { to { transform: rotate(360deg); } }
@keyframes progress-sweep { from { transform: translateX(-15%); } to { transform: translateX(190%); } }

@media (prefers-reduced-motion: reduce) {
  .loading-spinner, .progress-track i { animation-duration: 2.5s; }
}

@media (max-width: 850px) {
  main { padding-top: 36px; }
  .workspace { grid-template-columns: 250px minmax(0, 1fr); gap: 24px; }
  .algorithm-grid { grid-template-columns: 1fr; }
  .algorithm-card { min-height: 116px; }
}
@media (max-width: 640px) {
  .topbar { height: 56px; padding: 0 16px; }
  main { padding: 30px 16px 22px; }
  .intro { margin-bottom: 25px; }
  h1 { font-size: 36px; }
  .intro-copy { font-size: 12px; }
  .workspace { grid-template-columns: 1fr; gap: 27px; }
  .control-panel { position: static; }
  .algorithm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .algorithm-card { min-height: 128px; padding: 13px 9px; }
  .algorithm-card h3 { font-size: 12px; margin-bottom: 16px; }
  .algorithm-card strong { font-size: 18px; }
  .algorithm-card p { font-size: 8px; }
  .route-details p { grid-template-columns: 64px minmax(0, 1fr); gap: 6px; font-size: 9px; }
  .route-details .route-sequence { grid-column: 2; grid-row: 1; }
  .route-details .route-distance { grid-column: 2; grid-row: 2; }
  .tsp-summary { grid-template-columns: 1fr 1fr; }
  .tsp-metric { min-height: 78px; padding: 11px; }
  .tsp-metric strong { font-size: 20px; }
  .tsp-order span { font-size: 9px; }
  .section-heading h2 { font-size: 17px; }
  #network-map { min-height: 0; }
  .map-legend { gap: 10px; font-size: 8px; }
  footer { flex-direction: column; }
}
