:root {
  color-scheme: dark;
  --bg: #101819; --panel: #192324; --raised: #202d2e; --text: #eef5f0;
  --muted: #b7c5c1; --line: #3b4d4e; --mint: #b6efd5; --mint-ink: #142c22;
  --orange: #ffd0a1; --bad: #ffb6a7; --mono: "IBM Plex Mono", Consolas, monospace;
  font-family: "Instrument Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1, h2, h3, p, figure { margin: 0; }
h2 { font-size: 1.16rem; letter-spacing: -.025em; }
h3 { font-size: .98rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, select, textarea { border: 1px solid var(--line); border-radius: 6px; min-height: 44px; }
button { background: var(--raised); padding: .5rem .72rem; cursor: pointer; font-weight: 650; }
button:hover { border-color: var(--mint); }
button:disabled { opacity: .48; cursor: default; }
a { color: var(--mint); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
input, select, textarea { width: 100%; background: var(--bg); padding: .5rem .65rem; }
textarea { resize: vertical; }
label[hidden] { display: none; }
label { display: grid; gap: .38rem; font-size: .88rem; }
small { color: var(--muted); }
.primary { color: var(--mint-ink); background: var(--mint); border-color: var(--mint); }
.wrap { width: min(1270px, calc(100% - 3rem)); margin-inline: auto; }
header { border-bottom: 1px solid var(--line); background: #172324; }
.top { min-height: 70px; display: flex; align-items: center; gap: 1rem; justify-content: space-between; }
.brand { font: .78rem var(--mono); text-transform: uppercase; letter-spacing: .12em; display: flex; gap: .65rem; align-items: center; }
.brand span { border: 1px solid var(--line); border-radius: 4px; padding: .35rem; color: var(--mint); }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.action-link { display: inline-flex; align-items: center; min-height: 44px; padding: .5rem .72rem; color: var(--mint); font-weight: 650; }
main { padding-block: 1.75rem; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.eyebrow { font: .75rem var(--mono); color: var(--mint); text-transform: uppercase; letter-spacing: .13em; }
h1 { font-size: clamp(2.65rem, 6vw, 4.5rem); line-height: .98; letter-spacing: -.065em; margin: .36rem 0 .65rem; }
.intro p { color: var(--muted); }
.plan-input { width: min(24rem, 100%); }
.layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.stack { display: grid; gap: 1rem; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; min-width: 0; }
.panel-head { display: flex; gap: .75rem; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.panel-head small { display: block; margin-top: .24rem; }
.panel-summary {
  width: 100%; flex-wrap: nowrap; border: 0; border-radius: 8px; list-style: none;
}
.panel-summary::-webkit-details-marker { display: none; }
.panel-summary::after {
  content: ""; flex: none; width: .56rem; height: .56rem; margin-inline-end: .2rem;
  border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(-45deg);
}
.panel-summary:hover { background: var(--raised); }
.panel-summary:hover::after { border-color: var(--mint); }
details[open] > .panel-summary { border-radius: 8px 8px 0 0; border-bottom: 1px solid var(--line); }
details[open] > .panel-summary::after { transform: rotate(45deg); }
.panel-title { display: block; font-size: 1.16rem; font-weight: 700; letter-spacing: -.025em; }
.grid-shell { padding: .75rem 1rem .85rem; }
.grid-info { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .62rem; }
.grid-info strong { color: var(--mint); font-size: 1.08rem; }
.load-panel { border: 1px solid var(--line); border-radius: 6px; padding: .58rem .68rem; margin-bottom: .68rem; background: var(--bg); }
.load-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .3rem .6rem; }
.load-top strong { font: .82rem var(--mono); }
.load-top span { font-size: .88rem; font-weight: 650; }
.load-panel progress { display: block; width: 100%; height: 7px; margin: .42rem 0; accent-color: var(--mint); }
.load-panel[data-level="near"] progress { accent-color: var(--orange); }
.load-panel[data-level="over"] progress { accent-color: var(--bad); }
.load-panel[data-level="over"] { border-color: var(--bad); }
.load-panel small { display: block; font-size: .78rem; line-height: 1.35; }
.grid { position: relative; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); aspect-ratio: var(--cols) / var(--rows); background: #10191a; border: 1px solid var(--line); border-radius: 6px; }
.cell { min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0; border-right: 1px solid #354748; border-bottom: 1px solid #354748; background: transparent; }
.cell:hover, .cell:focus-visible { background: #30403f; outline-offset: -2px; }
.tile { position: relative; overflow: hidden; z-index: 1; margin: 2px; display: grid; place-items: center; align-content: center; gap: .12rem; min-width: 0; min-height: 0; border: 1px solid currentColor; border-radius: 5px; padding: 2px; color: var(--tile-ink); background: var(--tile); text-align: center; }
.tile:hover { border-color: var(--tile-ink); filter: brightness(1.13); }
.tile[aria-pressed="true"] { outline: 2px solid white; outline-offset: 1px; z-index: 2; opacity: .58; }
.tile-code { font: 750 clamp(.61rem, 1.25vw, .83rem) var(--mono); }
.tile-name { display: block; max-width: 100%; padding-inline: .2rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: clamp(.67rem, 1.05vw, .81rem); }
.tile-qty { color: inherit; font: .6rem var(--mono); }
.tile[data-small] .tile-name { display: none; }
.grid[data-dense] .tile-name, .grid[data-dense] .tile-qty { display: none; }
.grid .tile[data-weapon] .tile-name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.05;
  font-size: clamp(.52rem, 1.1vw, .81rem);
}
.tile[data-weapon][data-small] .tile-emblem .icon { display: none; }
.preview { z-index: 3; pointer-events: none; margin: 1px; border: 2px dashed #d3ffed; background: #a9efd381; border-radius: 5px; }
.module-tile { z-index: 2; display: grid; place-items: center; min-width: 0; min-height: 0; margin: 2px; border: 1px solid #e0b58a; border-radius: 4px; background: repeating-linear-gradient(-45deg,#4a3b31 0 5px,#382c23 5px 10px); color: #ffdfba; font: 750 .72rem var(--mono); }
.module-tile[data-active] { border-color: #ffe0a3; color: #fff2c8; background: repeating-linear-gradient(-45deg,#684d25 0 5px,#483617 5px 10px); }
.module-tile[data-module="arm"] { margin-block-end: 0; border-end-start-radius: 0; border-end-end-radius: 0; }
.item-main .item-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.module-list .module-card {
  display: grid; grid-template-columns: minmax(88px, .7fr) minmax(0, 1.3fr); gap: .55rem .72rem;
  align-items: start; padding: .8rem .85rem;
}
.module-card .row-tools { grid-column: 2; justify-content: start; }
.module-thumb { display: block; position: relative; min-height: 0; padding: 0; overflow: hidden; border-color: #70817f; background: #10191a; }
.module-thumb img { display: block; width: 100%; aspect-ratio: 3 / 2; height: auto; }
.module-thumb span { display: block; color: var(--muted); font-size: .73rem; padding: .27rem .32rem; }
.module-thumb:hover span { color: var(--mint); }
.module-price { color: var(--mint); }
.module-image-dialog { width: min(1120px, calc(100% - 24px)); max-height: calc(100% - 24px); }
.module-image-head { display: flex; justify-content: space-between; align-items: start; gap: .65rem; margin-bottom: .65rem; }
.module-image-head small { display: block; margin-top: .3rem; }
.module-image-dialog img { display: block; width: 100%; max-height: min(65vh, 68vw); height: auto; object-fit: contain; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.module-image-dialog figcaption { padding-inline: 0; }
@media (max-width: 550px) {
  .module-list .module-card { grid-template-columns: minmax(78px, .65fr) minmax(0, 1.35fr); }
  .module-card .row-tools button { min-height: 40px; }
}
.module-list .row-tools { flex-wrap: wrap; justify-content: end; }
.module-list small[role="note"] { color: var(--orange); }
.module-swatch { background: repeating-linear-gradient(-45deg,#b48556 0 2px,#483617 2px 4px); }
.preview.invalid { border-color: var(--bad); background: #f59b906a; }
.grid-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-top: .7rem; min-height: 44px; }
.grid-tools p { flex: 1 1 225px; font-size: .83rem; color: var(--muted); line-height: 1.42; }
.notice { color: var(--bad); }
.queue { border-top: 1px solid var(--line); padding: .75rem 1rem; }
.queue h3 { color: var(--orange); margin-bottom: .48rem; }
.queue li + li { margin-top: .35rem; }
.queue ul { list-style: none; margin: 0; padding: 0; }
.queue button { padding-block: .35rem; min-height: 40px; text-align: left; }
.feedback { border-top: 1px solid var(--line); min-height: 2.35rem; padding: .58rem 1rem; font-size: .83rem; color: var(--muted); }
#catalog-feedback:empty { padding: 0; min-height: 0; border-top: 0; }
.reference img { display: block; width: 100%; height: auto; border-radius: 8px 8px 0 0; }
figcaption { color: var(--muted); padding: .55rem .8rem; font-size: .78rem; }
.catalog-filters > .sample-filters { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .45rem; }
.catalog-filters > .sample-filters[hidden] { display: none; }
.sample-filters small { grid-column: 1 / -1; }
.catalog-quick { color: var(--mint); }
.catalog-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .45rem; padding: .65rem .85rem; border-bottom: 1px solid var(--line); }
.catalog-filters input[type="search"] { grid-column: 1 / -1; }
#catalog-panel { scroll-margin-block-start: .7rem; }
.list { list-style: none; padding: 0; margin: 0; }
.catalog-list { max-height: 470px; overflow: auto; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: .65rem; padding: .62rem .85rem; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 0; }
.item-main h3 { overflow-wrap: anywhere; display: flex; align-items: baseline; gap: .5rem; }
.item-main small { display: block; margin-top: .23rem; font-size: .78rem; line-height: 1.4; }
.swatch { flex: none; width: .72rem; height: .72rem; border-radius: 3px; background: var(--tile); display: inline-block; }
.catalog-plus { min-width: 44px; color: var(--mint); }
.row-tools { flex: none; display: flex; gap: .35rem; }
.row-tools button { min-width: 40px; }
.row-tools .remove { color: var(--bad); }
.empty { color: var(--muted); line-height: 1.4; }
footer { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-block: .75rem; color: var(--muted); font-size: .88rem; line-height: 1.5; }
summary { color: var(--text); cursor: pointer; width: fit-content; font-weight: 650; }
footer p { margin-top: .5rem; max-width: 85ch; }
dialog { color: var(--text); border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 1.15rem; width: min(520px, calc(100% - 24px)); }
dialog::backdrop { background: #080e0ed6; }
dialog form { display: grid; gap: .8rem; }
dialog .actions { justify-content: end; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#weapon-fields { display: grid; gap: .5rem; }
#weapon-fields[hidden], #item-error:empty { display: none; }
#weapon-fields select { min-width: 0; }
.notice.help { color: var(--bad); }
.help, output { color: var(--muted); font-size: .83rem; line-height: 1.45; display: block; }
.icon { width: 1.15rem; height: 1.15rem; flex: none; display: inline-block; }
.tile { border-color: var(--tile-edge); }
.tile .icon, .module-tile .icon { width: clamp(.82rem, 1.7vw, 1.35rem); height: clamp(.82rem, 1.7vw, 1.35rem); }
.tile-emblem { display: inline-flex; align-items: center; justify-content: center; gap: .26rem; min-width: 0; }
.tile[data-small] .tile-emblem { flex-wrap: wrap; gap: .1rem .2rem; }
.module-tile .tile-emblem { color: inherit; }
.swatch.icon-swatch { display: inline-grid; place-items: center; width: 1.42rem; height: 1.42rem; border: 1px solid var(--tile-edge, #a98156); color: var(--tile-ink, #ffe1be); }
.swatch .icon { width: .92rem; height: .92rem; }
.screen-legend { margin-top: .66rem; font-size: .72rem; color: var(--muted); }
.screen-legend span { color: var(--tile-ink, #ffdfba); }
.screen-legend .icon { width: .82rem; height: .82rem; }
.weapon-placements {
  margin: .55rem 0 0; padding: 0; list-style: none; color: var(--muted);
  font-size: .75rem; display: flex; flex-wrap: wrap; gap: .25rem .75rem;
}
.weapon-placements[hidden] { display: none; }
.pack .panel-head { border-top: 2px solid #82c8b7; border-radius: 8px 8px 0 0; }
.grid-shell { background: linear-gradient(180deg,#1b2c2c 0%,var(--panel) 100%); }
@media (max-width: 850px) {
  .wrap { width: calc(100% - 1.6rem); }
  .layout { display: flex; flex-direction: column; }
  .stack { display: contents; }
  .layout .panel { width: 100%; }
  .pack { order: 0; } .manifest-panel { order: 1; } .catalog-panel { order: 2; } .modules-panel { order: 3; } .reference { order: 4; }
}
@media (max-width: 550px) {
  .wrap { width: calc(100% - 1rem); }
  .top { padding-block: .45rem; }
  .brand { font-size: .67rem; letter-spacing: .03em; gap: .35rem; }
  .top button { padding-inline: .38rem; font-size: .74rem; }
  .top .actions { justify-content: end; }
  .intro { flex-direction: column; align-items: stretch; }
  .panel-head, .grid-shell { padding-inline: .65rem; }
  .grid-tools button, .panel-head button, .catalog-quick, .action-link { font-size: .8rem; }
  .grid-tools p { flex-basis: 100%; }
  .tile { margin: 1px; gap: 0; }
  .tile-name { display: none; }
  .tile .icon, .module-tile .icon { width: .8rem; height: .8rem; }
  .grid[data-dense] .tile-code { font-size: .49rem; }
  .row-tools button { padding-inline: .35rem; }
  #weapon-fields .fields { grid-template-columns: minmax(0, 1fr); }
}
.print-preview-bar, .print-report { display: none; }
body.show-print > header, body.show-print > main { display: none; }
body.show-print .print-preview-bar { display: flex; }
body.show-print .print-report { display: block; }
.print-preview-bar {
  position: sticky; top: 0; z-index: 4; justify-content: space-between; align-items: center; gap: .75rem;
  flex-wrap: wrap; padding: .7rem max(1rem, calc((100vw - 900px) / 2)); background: var(--panel); border-bottom: 1px solid var(--line);
}
.print-preview-bar .primary { display: inline-flex; align-items: center; gap: .38rem; }
.print-preview-bar label { display: flex; align-items: center; gap: .4rem; }
.print-preview-bar input { width: 1rem; min-height: 0; accent-color: var(--mint); }
.print-report {
  --report-ink: #17282b; --report-muted: #45585b; --report-line: #708186;
  color-scheme: light; color: var(--report-ink); background: white;
  width: min(190mm, calc(100% - 1rem)); margin: 1rem auto; padding: clamp(.6rem, 2.5vw, 1.25rem);
  font: 10pt/1.4 "Instrument Sans", system-ui, sans-serif; overflow-wrap: anywhere;
}
.report-head { position: relative; display: block; padding: 3mm 4mm; color: var(--report-ink); background: transparent; border: 1px solid var(--report-ink); }
.report-head::before, .report-head::after {
  content: ""; position: absolute; width: 14mm; height: 4mm; pointer-events: none; border: 2px solid var(--report-ink);
}
.report-head::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.report-head::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.report-headline { display: flex; gap: .75rem; justify-content: space-between; align-items: center; }
.report-kicker, .report-section-title, .report-fine { color: var(--report-muted); font: 8pt/1.4 var(--mono); letter-spacing: .07em; }
.report-kicker, .report-section-title { text-transform: uppercase; font-weight: 700; }
.report-title { font-size: clamp(16pt, 4vw, 26pt); line-height: 1.04; margin: 1mm 0 0; letter-spacing: -.04em; }
.report-mark { flex: 0 0 14mm; width: 14mm; height: 11mm; color: var(--report-ink); }
.report-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; margin: 3mm 0; break-inside: avoid; }
.report-stat { padding: 2mm 3mm; border: 1px solid var(--report-line); border-left: 2px solid var(--report-ink); }
.report-stat strong { display: block; margin-top: .5mm; }
.report-stat small { display: block; color: var(--report-muted); }
.report-schematic { border: 1px solid var(--report-line); padding: 2.5mm; margin-bottom: 3mm; break-inside: avoid; }
.report-schematic .report-section-title { margin: 0 0 2mm; }
.report-raster {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0,1fr)); grid-template-rows: repeat(var(--rows), minmax(0,1fr));
  width: min(100%, var(--report-grid-width)); aspect-ratio: var(--cols) / var(--rows); margin-inline: auto;
  border: 1px solid var(--report-line);
}
.report-cell { border-right: 1px solid #bac6c9; border-bottom: 1px solid #bac6c9; }
.report-piece {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; align-content: center;
  gap: .1rem .25rem; z-index: 1; min-width: 0; min-height: 0; overflow: hidden; margin: 1px;
  border: 1px solid currentColor; color: var(--print-category, var(--report-ink));
  font: 700 clamp(5.5pt, 1.35vw, 8pt) var(--mono);
}
.report-piece.module-piece { border: 1.5px dashed currentColor; }
.report-piece .icon { width: 3.5mm; height: 3.5mm; }
.report-weapon-name {
  flex-basis: 100%; text-align: center; padding-inline: 1px; overflow-wrap: anywhere;
  font: 600 .85em/1.1 system-ui, sans-serif; display: -webkit-box;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.report-legend, .screen-legend { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .65rem; }
.screen-legend[hidden], .report-legend[hidden] { display: none; }
.report-legend { margin-top: 2mm; justify-content: center; font-size: 7.5pt; }
.report-legend span, .screen-legend span { display: inline-flex; align-items: center; gap: .23rem; }
.report-legend span { color: var(--print-category, var(--report-ink)); }
.report-legend .icon { width: 3.3mm; height: 3.3mm; }
.report-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9pt; }
.report-table col:first-child { width: 49%; }
.report-table col:nth-child(2) { width: 17%; }
.report-table col:nth-child(3) { width: 22%; }
.report-table col:nth-child(4) { width: 12%; }
.report-table caption { border-top: 2px solid var(--report-ink); text-align: left; padding: 2mm 0 1mm; }
.report-table th, .report-table td { padding: 1.5mm 1mm; border-bottom: 1px solid var(--report-line); text-align: left; vertical-align: top; }
.report-table th { font: 700 7.5pt/1.4 var(--mono); color: var(--report-muted); }
.report-table td:last-child, .report-table th:last-child { text-align: right; }
.report-table td p { color: var(--report-muted); margin-top: .5mm; font-size: 8pt; white-space: pre-wrap; }
.report-table td .report-item-name { display: flex; align-items: baseline; gap: 1mm; }
.report-table .icon { flex: none; align-self: center; width: 3.4mm; height: 3.4mm; color: var(--print-category, var(--report-ink)); }
.report-table tr { break-inside: avoid; }
.report-fixed-note { margin-top: 3mm; }
.print-report.mono-report { filter: grayscale(1); }
@media (max-width: 550px) {
  .report-summary { gap: 1.5mm; }
  .report-piece .icon { width: 2.9mm; height: 2.9mm; }
  .report-table { font-size: 8pt; }
  .report-table td p { font-size: 7.5pt; }
}
@page { size: A4 portrait; margin: 11mm 10mm; }
@media print {
  :root { color-scheme: light; }
  html, body { margin: 0; padding: 0; background: white; color: #17282b; }
  body > header, body > main, body > dialog, body > .print-preview-bar { display: none !important; }
  body > .print-report { display: block; width: auto; margin: 0; padding: 0; background: transparent; }
  .print-report * { box-shadow: none !important; text-shadow: none !important; }
  .print-report.mono-report { filter: none; }
  .mono-report .report-piece, .mono-report .report-legend span, .mono-report .report-table .icon { color: var(--report-ink); }
  .report-title { font-size: 25pt; }
  .report-piece { font-size: 7pt; }
  .report-table thead { display: table-header-group; }
}
