:root {
  --primary: #123458;
  --secondary: #d4c9be;
  --ink: #111;
  --muted: #5d5d5d;
  --line: #e4ded7;
  --paper: #fff;
  --soft: #f7f4f1;
  --red: #c0392b;
  --amber: #c27c0e;
  --green: #2e7d4f;
  --head: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--body); color: var(--ink); background: var(--paper); display: flex; flex-direction: column; overflow: hidden; }
h1, h2, h3, h4 { font-family: var(--head); text-transform: uppercase; letter-spacing: .02em; margin: 0; }
button, input, select { font: inherit; }

/* masthead */
.masthead { background: #000; color: #fff; display: flex; align-items: center; gap: 24px; padding: 10px 20px; }
.brand { display: flex; flex-direction: column; line-height: 1; }
.wordmark { font: 800 26px/1 var(--head); letter-spacing: .08em; }
.brand .sub { font: 600 9px/1 var(--body); letter-spacing: .35em; opacity: .75; margin-top: 3px; }
.masthead h1 { font-size: 22px; font-weight: 700; flex: 1; }
.head-actions { display: flex; gap: 8px; }
.stepbar { background: var(--primary); color: #fff; display: flex; gap: 28px; padding: 7px 20px; font-size: 13px; overflow-x: auto; white-space: nowrap; }
.stepbar b { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: #fff; color: var(--primary); font-size: 11px; margin-right: 6px; }

/* buttons */
.btn { border: 1px solid #cfc7bf; background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #0c2640; }
.btn.ghost { background: transparent; }
.masthead .btn.ghost { color: #fff; border-color: #444; }
.btn.danger { color: var(--red); }
.btn.block { display: block; width: 100%; margin-top: 8px; padding: 10px; }
.btn.icon { width: 34px; height: 34px; padding: 0; font-size: 18px; line-height: 1; }
.btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* layout */
.app { flex: 1; display: grid; grid-template-columns: 300px 1fr 300px; min-height: 0; }
.panel { overflow-y: auto; padding: 14px 16px 24px; background: var(--soft); }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }
.panel h3 { font-size: 16px; margin: 18px 0 8px; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.panel h3:first-child { margin-top: 4px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 10px; }
.tab { border: 0; background: #e9e3dc; padding: 9px; border-radius: 6px; font: 700 15px var(--head); text-transform: uppercase; letter-spacing: .04em; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--primary); color: #fff; }
.tabpane { display: none; }
.tabpane.active { display: block; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
label input:not([type=checkbox]):not([type=range]):not([type=file]), label select { display: block; width: 100%; margin-top: 3px; padding: 7px 9px; border: 1px solid #cfc7bf; border-radius: 6px; background: #fff; color: var(--ink); font-weight: 500; }
label.inline { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.row-btns.end { justify-content: flex-end; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0; }
.hint.small { font-size: 11px; }
.muted { color: var(--muted); }
.upload { border: 1.5px dashed #b9ada1; border-radius: 8px; padding: 14px; text-align: center; cursor: pointer; background: #fff; color: var(--primary); font-weight: 600; font-size: 13px; }
.upload input { display: none; }
.upload:hover { border-color: var(--primary); }
.plan-tools { margin-top: 10px; }
.plan-steps { padding-left: 18px; margin: 6px 0; font-size: 12px; color: var(--muted); }
.plan-steps li { margin-bottom: 8px; }
.plan-steps .btn { margin: 0 6px 4px 0; }
.wall-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wall-list label { display: flex; align-items: center; gap: 6px; }
.wall-list label span { min-width: 34px; font-family: var(--head); font-size: 14px; color: var(--primary); }
.wall-list input { margin: 0 !important; padding: 5px 7px !important; }

/* equipment list */
#search { width: 100%; padding: 8px 10px; border: 1px solid #cfc7bf; border-radius: 6px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chip { border: 1px solid #cfc7bf; background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
#catSelect { width: 100%; padding: 7px; border: 1px solid #cfc7bf; border-radius: 6px; background: #fff; }
.equip-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.eq { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; cursor: grab; touch-action: pan-y; user-select: none; }
.eq:hover { border-color: var(--primary); }
.eq svg { width: 44px; height: 44px; }
.eq .n { font-weight: 600; font-size: 12.5px; line-height: 1.25; }
.eq .m { font-size: 11px; color: var(--muted); }
.eq .warn { color: var(--amber); font-weight: 600; }
.group-h { font: 700 13px var(--head); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 0 2px; }

/* stage */
.stage-wrap { position: relative; min-width: 0; min-height: 0; background: #fbfaf8; }
#stage { width: 100%; height: 100%; display: block; touch-action: none; cursor: default; user-select: none; }
#stage.panning { cursor: grabbing; }
#stage.crosshair { cursor: crosshair; }
.zoom-ctl { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.sel-bar { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,.08); border-radius: 10px; padding: 6px 8px; display: flex; gap: 6px; align-items: center; max-width: calc(100% - 24px); }
.sel-bar #selName { font-weight: 600; font-size: 12.5px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.mode-banner { position: absolute; left: 12px; top: 12px; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 13px; max-width: 420px; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.mode-banner .btn { margin-left: 8px; padding: 3px 9px; }
.mobile-toggle { display: none; }

/* summary */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
.stat .v { display: block; font: 700 24px/1.1 var(--head); color: var(--primary); }
.stat .k { font-size: 11px; color: var(--muted); }
.usebar { height: 8px; background: #e9e3dc; border-radius: 99px; overflow: hidden; margin-top: 12px; }
.usefill { height: 100%; width: 0; background: var(--green); transition: width .25s, background .25s; }
.badge { background: var(--secondary); color: var(--ink); border-radius: 99px; font: 700 12px var(--body); padding: 1px 8px; }
.badge.bad { background: var(--red); color: #fff; }
.warnings, .bom { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.warnings li { padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; background: #fff; border-left: 3px solid var(--amber); cursor: pointer; }
.warnings li.red { border-left-color: var(--red); }
.warnings li.ok { border-left-color: var(--green); cursor: default; }
.bom li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.bom li b { color: var(--primary); }
.cta-box { margin-top: 18px; background: #000; color: #fff; border-radius: 10px; padding: 14px; }
.cta-box h4 { font-size: 18px; }
.cta-box p { font-size: 12.5px; opacity: .85; margin: 6px 0 4px; }
.cta-box .btn:not(.primary) { background: transparent; color: #fff; border-color: #555; }
.cta-box .btn.primary { background: var(--primary); }

.cta-footer { background: #000; color: #fff; display: flex; justify-content: center; gap: 28px; padding: 6px; font: 600 12px var(--body); letter-spacing: .04em; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 12px; padding: 22px; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; position: relative; border-top: 6px solid var(--primary); }
.modal-card.small { width: min(380px, 100%); }
.modal-card h2 { font-size: 26px; color: var(--primary); }
.modal-card .close { position: absolute; right: 12px; top: 10px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; color: var(--ink); font-size: 13px; margin: 8px 0; }
.form-error { color: var(--red); font-weight: 600; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* svg text */
.lbl { font-family: var(--body); font-weight: 600; fill: #1a1a1a; pointer-events: none; }
.dim { font-family: var(--head); font-weight: 700; fill: var(--primary); pointer-events: none; }

/* responsive */
@media (max-width: 1100px) { .app { grid-template-columns: 270px 1fr 260px; } }
@media (max-width: 860px) {
  .masthead { padding: 8px 12px; gap: 10px; }
  .masthead h1 { font-size: 17px; }
  .head-actions #btnUndo, .head-actions #btnRedo { display: none; }
  .stepbar { padding: 6px 12px; gap: 16px; font-size: 12px; }
  .app { grid-template-columns: 1fr; position: relative; }
  .panel { position: absolute; z-index: 20; top: 0; bottom: 0; width: min(340px, 92vw); box-shadow: 0 0 30px rgba(0,0,0,.2); transition: transform .25s; }
  .panel.left { left: 0; transform: translateX(-105%); }
  .panel.right { right: 0; transform: translateX(105%); }
  .panel.open { transform: none; }
  .mobile-toggle { display: block; position: absolute; left: 12px; bottom: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
  .mobile-toggle.right { left: auto; right: 58px; }
  .row3 { grid-template-columns: 1fr; }
  .cta-footer { gap: 14px; font-size: 11px; }
  .sel-bar { top: auto; bottom: 60px; }
}

@media print {
  .masthead .head-actions, .stepbar, .panel.left, .zoom-ctl, .sel-bar, .mobile-toggle, .cta-box, .mode-banner { display: none !important; }
  body { overflow: visible; height: auto; }
  .app { display: block; }
  .stage-wrap { height: 60vh; border: 1px solid #ccc; }
  .panel.right { position: static; transform: none; box-shadow: none; border: 0; background: #fff; }
}
