:root {
  --bg: #f4f3f1;
  --panel: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e2e0dc;
  --accent: #c8102e;
  --accent-text: #ffffff;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: #b00020; min-height: 1em; }

.login { display: grid; place-items: center; height: 100%; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.login .card { width: min(360px, 100% - 32px); display: grid; gap: 12px; }
.login h1 { margin: 0; font-size: 20px; }

.app { display: grid; grid-template-columns: 360px 1fr; height: 100%; }
.panel { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 0 16px 24px; }
.brand { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
section { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin: 0; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
label.radio { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 13px; }
input, select, textarea { font: inherit; color: var(--text); padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%; }
input[type=radio], input[type=checkbox] { width: auto; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
button, .file-btn { font: inherit; border: 0; border-radius: 6px; padding: 8px 12px; background: var(--accent); color: var(--accent-text); cursor: pointer; text-align: center; }
button.secondary, .file-btn.secondary { background: #ecebe8; color: var(--text); }
button.link { background: none; color: var(--muted); padding: 0; text-decoration: underline; justify-self: start; }
button:disabled { opacity: .5; cursor: default; }
.file-btn { position: relative; overflow: hidden; display: inline-block; font-size: 13px; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.results { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.results li { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.results li:hover, .results li.active { background: #f1efec; }
.results .sku { color: var(--muted); font-size: 12px; }

.docs { display: flex; flex-wrap: wrap; gap: 6px; }
.docs a { font-size: 12px; color: var(--text); background: #f1efec; padding: 4px 8px; border-radius: 999px; text-decoration: none; }
.chart-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chart-grid label { font-size: 11px; }
.chart-grid input { padding: 5px 6px; }
.chart-grid .current input { border-color: var(--accent); }

.placement { display: grid; gap: 8px; margin-bottom: 8px; }

.stage { display: grid; grid-template-rows: auto 1fr auto auto; min-width: 0; height: 100%; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs { display: flex; gap: 4px; }
.tab { background: #ecebe8; color: var(--text); }
.tab.active { background: var(--text); color: #fff; }
.toggle { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 13px; }
.small-btn { font-size: 12px; padding: 6px 10px; }
.canvas-wrap { position: relative; overflow: hidden; display: grid; place-items: center; padding: 16px; min-height: 0; }
#canvas { max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); touch-action: none; }
.empty { position: absolute; color: var(--muted); }
.status { padding: 6px 16px; min-height: 28px; font-size: 13px; }
.status.warn { color: #8a5300; }
.status.err { color: #b00020; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 0 16px 10px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.hps { background: #0077cc; }
.dot.collar { background: #e07b00; }
.dot.chest { background: #11998e; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage { height: 80vh; }
}
