:root {
  --bg: #f4f2ee; --card: #fff; --ink: #1d1d1b; --muted: #6d6a64; --line: #ddd8cf;
  --accent: #c0563a; --accent-ink: #fff; --ok: #2f7d4f; --warn: #b7791f; --bad: #b42318;
  --sel: #fdf0eb; --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171614; --card: #22201d; --ink: #ece8e1; --muted: #a29d94; --line: #3a3732;
          --sel: #3a2a24; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
       background: var(--bg); color: var(--ink); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--field, var(--card)); border: 1px solid var(--field-line, var(--line));
       border-radius: 6px; padding: 6px 8px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
@media (prefers-color-scheme: dark) { :root { --field: #2d2a26; --field-line: #5a554d; } }
.login-card input { padding: 10px 12px; font-size: 16px; }
textarea { resize: vertical; }
button { background: var(--card); border: 1px solid var(--line); border-radius: 6px;
         padding: 7px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { border-color: transparent; background: none; color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.wide { width: 100%; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label > * { color: var(--ink); font-size: 14px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.err { color: var(--bad); } .ok { color: var(--ok); } .warn { color: var(--warn); }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 14px; margin-bottom: 12px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center;
       padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.top a { color: var(--muted); }
.icon { display: none; border: none; background: none; font-size: 18px; padding: 2px 6px; }
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 46px); }
aside { border-right: 1px solid var(--line); padding: 12px; background: var(--card); }
aside input { margin: 10px 0; }
#jobList { list-style: none; margin: 0; padding: 0; }
#jobList li { padding: 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
#jobList li:hover { border-color: var(--line); }
#jobList li.on { background: var(--sel); }
#jobList .jn { font-weight: 600; } #jobList .js { font-size: 11px; color: var(--muted); }
main { padding: 16px; max-width: 1200px; width: 100%; }

.job-head { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.job-head .grow { flex: 1; min-width: 200px; }
.job-meta { font-size: 12px; color: var(--muted); width: 100%; }
#pasteBox summary { cursor: pointer; font-weight: 600; }
#pasteBox textarea { margin-top: 8px; }

.door-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
             border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; }
.door-head .tag { width: 180px; font-weight: 600; }
.door-head .qty { flex-direction: row; align-items: center; }
.door-head .qty input { width: 64px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--muted); }
.badge.ok { background: #e3f3e8; color: var(--ok); } .badge.bad { background: #fde8e6; color: var(--bad); }
.door-body { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
fieldset { border: none; border-top: 1px solid var(--line); margin: 0 0 6px; padding: 8px 0 4px; }
legend { font-weight: 600; padding-right: 8px; }
.sub { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.seg-row { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.tiles .t { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer;
            font-size: 12px; background: var(--card); text-align: center; }
.tiles .t.on { border-color: var(--accent); background: var(--sel); box-shadow: 0 0 0 1px var(--accent); }
.tiles.pics .t { width: 92px; padding: 4px; }
.tiles.pics img { width: 100%; height: 110px; object-fit: contain; display: block; }
.tiles.pics .t span { display: block; font-size: 11px; line-height: 1.2; margin-top: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches .s { width: 64px; cursor: pointer; text-align: center; font-size: 10px; line-height: 1.15; }
.swatches .s .chip { height: 34px; border-radius: 5px; border: 1px solid var(--line);
                     background-size: cover; background-position: center; }
.swatches .s.on .chip { box-shadow: 0 0 0 2px var(--accent); }
.assumptions { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--warn); }
.adv summary { cursor: pointer; color: var(--muted); margin-top: 6px; }
.adv select, .adv input { width: auto; max-width: 100%; }
.ovr-list .o { font-size: 12px; display: flex; gap: 6px; align-items: center; }

.door-side { border-left: 1px solid var(--line); padding-left: 16px; }
.drawing { min-height: 220px; display: grid; place-items: center; border: 1px dashed var(--line);
           border-radius: 6px; margin-bottom: 10px; background: #fff; }
.drawing img { max-width: 100%; max-height: 300px; }
.price { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.price .small { font-weight: 400; }
.door-side .check { width: 100%; margin-bottom: 10px; }
.needs .n { border: 1px solid var(--warn); border-radius: 6px; padding: 8px; margin-bottom: 8px; font-size: 12px; }
.needs .n select { margin-top: 4px; }
.answers { font-size: 11px; border-collapse: collapse; width: 100%; }
.answers td { border-top: 1px solid var(--line); padding: 3px 2px; vertical-align: top; }
.answers td:first-child { color: var(--muted); width: 45%; }
.bottom-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
.log { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 10px;
       font-size: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: min(360px, calc(100vw - 32px)); background: var(--card); border: 1px solid var(--line);
              border-radius: 10px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }

@media (max-width: 860px) {
  .icon { display: inline-block; }
  .layout { grid-template-columns: 1fr; }
  aside { position: fixed; inset: 46px auto 0 0; width: 270px; z-index: 4; transform: translateX(-100%);
          transition: transform .2s; overflow: auto; }
  aside.open { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  main { padding: 10px 16px; }
  .door-body { grid-template-columns: 1fr; }
  .door-side { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 12px; }
}
