:root{
  --bg:#f3f1ec; --surface:#fff; --ink:#171816; --muted:#74756f;
  --line:#dedbd2; --dark:#1d211e; --accent:#9a7b52; --accent2:#c8b08d;
  --danger:#8d2f2f;
}
*{box-sizing:border-box}
body{margin:0;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:var(--bg);color:var(--ink)}
a{color:inherit;text-decoration:none}
button,input,select,textarea{font:inherit}
.topbar{height:68px;padding:0 34px;display:flex;align-items:center;justify-content:space-between;background:#151815;color:#f5f2ea;border-bottom:1px solid #2c312d}
.logo{font-weight:700;letter-spacing:.27em;font-size:18px}
.top-actions{display:flex;align-items:center;gap:20px;font-size:13px;color:#d8d5cd}
.saved{padding:5px 9px;border:1px solid #3b403c;border-radius:999px}
.container{max-width:1220px;margin:auto;padding:46px 32px}
.hero{display:flex;justify-content:space-between;align-items:end;gap:24px;margin-bottom:44px}
.hero h1{font-size:42px;line-height:1.08;margin:7px 0 10px;max-width:680px;font-weight:600}
.hero p{color:var(--muted);max-width:620px}
.eyebrow{font-size:11px;letter-spacing:.22em;color:#7f6b50}
.btn{display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:10px;padding:11px 15px;cursor:pointer;font-weight:600}
.btn.primary{background:#20241f;color:#fff}
.btn.ghost{background:transparent;border:1px solid var(--line)}
.btn.danger{background:#fff0f0;color:var(--danger);border:1px solid #e6b9b9;margin-top:10px;width:100%}
.project-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:20px}
.project-card{background:var(--surface);border:1px solid var(--line);border-radius:16px;overflow:hidden;transition:.18s}
.project-card:hover{transform:translateY(-2px);border-color:#c8c3b8}
.project-preview{height:180px;background:linear-gradient(145deg,#d9d4ca,#f7f4ee);display:grid;place-items:center}
.preview-cabinet{width:92px;height:118px;border:5px solid #474943;display:grid;grid-template-columns:1fr 1fr}
.preview-cabinet span{border:1px solid #767970}
.project-info{padding:16px;display:flex;flex-direction:column;gap:5px}
.project-info span{color:var(--muted);font-size:13px}
.section-head{display:flex;justify-content:space-between;gap:20px;align-items:center;margin-bottom:18px}
.section-head h2{margin:0;font-size:20px}
.section-head p{margin:5px 0 0;color:var(--muted);font-size:13px}
.auth-bg{background:#151815;min-height:100vh}
.auth-shell{min-height:100vh;display:grid;grid-template-columns:1.15fr .85fr}
.brand-panel{padding:70px;display:flex;flex-direction:column;justify-content:flex-end;color:#f1eee6;background:radial-gradient(circle at 25% 20%,#3a3932 0,#20231f 35%,#151815 70%)}
.brand-mark{font-size:26px;letter-spacing:.35em;margin-bottom:34px}
.brand-panel h1{font-size:46px;max-width:640px;margin:0 0 15px;font-weight:500}
.brand-panel p{color:#bdbbb3}
.auth-card{background:#f7f5f0;padding:70px;display:flex;flex-direction:column;justify-content:center}
.auth-card h2{font-size:30px;margin:0 0 24px}
.form-stack{display:grid;gap:14px}
.form-stack h3{margin:12px 0 0}
label{display:grid;gap:6px;font-size:12px;color:#5e605a;font-weight:600}
input,select,textarea{width:100%;border:1px solid #cbc8bf;border-radius:9px;background:#fff;padding:11px 12px;color:#171816}
input:focus,select:focus,textarea:focus{outline:2px solid #c8b08d;outline-offset:1px}
.notice{padding:12px 14px;border-radius:10px;margin-bottom:16px}
.notice.ok{background:#e7f2e7}
.notice.error{background:#f7e5e5}
.workspace{padding:28px 34px 50px;max-width:1600px;margin:auto}
.project-titlebar{display:flex;justify-content:space-between;align-items:end;margin-bottom:22px}
.project-titlebar h1{margin:6px 0 4px;font-size:29px}
.project-titlebar span,.back{font-size:12px;color:var(--muted)}
.tabs{display:flex;gap:3px;border-bottom:1px solid var(--line);margin-bottom:22px}
.tabs a{padding:11px 15px;font-size:13px;color:var(--muted);border-bottom:2px solid transparent}
.tabs a.active{color:var(--ink);border-color:var(--accent)}
.tabs .disabled{opacity:.45}
.tabs small{font-size:9px}
.panel{background:var(--surface);border:1px solid var(--line);border-radius:15px;padding:20px}
.stats-row{display:grid;grid-template-columns:repeat(4,minmax(130px,1fr));gap:12px;margin-bottom:16px}
.metric{background:#252a26;color:#fff;padding:15px 17px;border-radius:13px;display:flex;justify-content:space-between;align-items:end}
.metric span{font-size:11px;color:#c6c8c2}
.metric strong{font-size:22px;font-variant-numeric:tabular-nums}
.work-grid{display:grid;grid-template-columns:1fr;gap:16px}
.work-grid.with-inspector{grid-template-columns:minmax(0,1fr) 340px}
.table-panel{min-width:0}
.table-wrap{overflow:auto}
.pieces-table{width:100%;border-collapse:collapse;font-size:13px}
.pieces-table th{text-align:left;color:var(--muted);font-size:10px;text-transform:uppercase;letter-spacing:.07em;padding:9px;border-bottom:1px solid var(--line);white-space:nowrap}
.pieces-table td{padding:10px 9px;border-bottom:1px solid #ece9e2;white-space:nowrap;font-variant-numeric:tabular-nums}
.pieces-table tr{cursor:pointer}
.pieces-table tbody tr:hover,.pieces-table tr.selected{background:#f4f0e8}
.pieces-table td.edge{text-align:center;font-weight:700}
.inspector{padding:18px}
.inspector-head{display:flex;justify-content:space-between;gap:10px}
.inspector-head span{font-size:10px;letter-spacing:.12em;color:var(--muted)}
.inspector-head h2{font-size:20px;margin:3px 0}
.inspector-head a{font-size:24px;color:var(--muted)}
.piece-visual{height:220px;position:relative;display:grid;place-items:center;margin:14px 10px 20px}
.piece-rect{width:150px;height:100px;border:2px solid #62655f;background:#e6e0d4}
.edge-tag{position:absolute;font-size:10px;font-weight:700;color:#555}
.edge-tag.l1{top:15px}.edge-tag.l2{bottom:15px}.edge-tag.a1{left:0;top:50%}.edge-tag.a2{right:0;top:50%}
.edge-l1-D{border-top-width:3px}.edge-l1-G{border-top-width:7px}
.edge-l2-D{border-bottom-width:3px}.edge-l2-G{border-bottom-width:7px}
.edge-a1-D{border-left-width:3px}.edge-a1-G{border-left-width:7px}
.edge-a2-D{border-right-width:3px}.edge-a2-G{border-right-width:7px}
.compact input,.compact select{padding:8px 9px}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.form-grid .full{grid-column:1/-1}
.edge-editor{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.edge-editor h3{grid-column:1/-1;margin:4px 0 0;font-size:13px}
.material-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px}
.material-card{border:1px solid var(--line);border-radius:12px;padding:13px;display:flex;flex-direction:column;gap:5px}
.material-card span{font-size:12px;color:var(--muted)}
.swatch{height:60px;border-radius:8px;background:linear-gradient(120deg,#c7b89f,#e5dfd3)}
.empty{padding:24px;color:var(--muted)}
.empty.large{padding:60px;text-align:center}
.modal{border:0;border-radius:16px;padding:0;max-width:560px;width:calc(100% - 32px);box-shadow:0 24px 80px #0004}
.modal::backdrop{background:#121412aa}
.modal form{padding:22px}
.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}
.modal-head h2{margin:0}
.modal-head button{background:none;border:0;font-size:25px;cursor:pointer}
@media(max-width:900px){
  .auth-shell{grid-template-columns:1fr}.brand-panel{display:none}.auth-card{padding:30px}
  .work-grid.with-inspector{grid-template-columns:1fr}
  .stats-row{grid-template-columns:1fr 1fr}
  .hero{align-items:start;flex-direction:column}
}

.fit{display:inline-flex;padding:4px 7px;border-radius:999px;font-size:10px;font-weight:700;white-space:nowrap}
.fit-ok{background:#e5efe5;color:#325c38}.fit-rotate{background:#f4edda;color:#765d20}
.fit-grain{background:#f5e7d4;color:#7b4e18}.fit-error{background:#f5dddd;color:#842e2e}
.fit-unknown{background:#eee;color:#666}
.cut-strategies{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-top:20px}
.cut-card{border:1px solid var(--line);border-radius:14px;padding:14px;background:#faf9f6}
.cut-card-head,.cut-meta{display:flex;justify-content:space-between;gap:8px;font-size:12px}
.cut-card-head span,.cut-meta{color:var(--muted)}
.cut-board{position:relative;aspect-ratio:1.35/1;background:#e8e3d9;border:2px solid #4f514d;margin:12px 0;overflow:hidden}
.cut-piece{position:absolute;border:1px solid #3f423f;background:#f8f6f0;overflow:hidden;padding:3px;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center}
.cut-piece span{font-size:9px;font-weight:700}.cut-piece small,.grain-arrow{font-size:8px;color:#666}
@media(max-width:1000px){.cut-strategies{grid-template-columns:1fr}}
