:root{
  --bg:#eef1f5; --panel:#ffffff; --ink:#0f172a; --muted:#64748b; --line:#e2e8f0;
  --accent:#f97316; --accent-soft:#ffedd5; --blue:#0ea5e9; --dark:#111827;
  --radius:10px; --shadow:0 4px 14px rgba(15,23,42,.08);
}
*{box-sizing:border-box; margin:0; padding:0}
html,body{height:100%}
body{font-family:'Segoe UI',system-ui,-apple-system,Roboto,Arial,sans-serif; background:var(--bg); color:var(--ink); overflow:hidden; font-size:14px}
button{font:inherit; cursor:pointer}
svg{width:17px;height:17px;display:block}

/* ---------- Topbar ---------- */
#topbar{height:52px; background:var(--dark); color:#e5e7eb; display:flex; align-items:center; gap:10px; padding:0 12px; user-select:none}
.brand{display:flex; align-items:center; gap:8px; margin-right:8px; white-space:nowrap}
.brand b{color:#fff; font-size:15px}
.brand-dot{width:14px;height:14px;border-radius:4px;background:var(--accent); box-shadow:0 0 10px rgba(249,115,22,.7)}
.brand-sub{color:#9ca3af; font-size:12px}
.tb-group{display:flex; align-items:center; gap:4px}
.tb-spacer{flex:1}
.tbtn{display:flex; align-items:center; gap:6px; background:transparent; color:#d1d5db; border:1px solid transparent; border-radius:8px; padding:6px 10px; font-size:13px}
.tbtn:hover{background:#1f2937; color:#fff}
.tbtn.icon{padding:6px}
.tbtn.icon-w{font-weight:700; letter-spacing:.5px}
.tbtn.accent{background:var(--accent); color:#fff; font-weight:600}
.tbtn.accent:hover{background:#ea580c}
.tbtn.on{background:#374151; color:#fff}
.seg{background:#1f2937; border-radius:9px; padding:3px}
.seg .tbtn{border-radius:7px; padding:4px 12px}
.seg .tbtn.on{background:var(--accent); color:#fff}
.tsel{background:#1f2937; color:#e5e7eb; border:1px solid #374151; border-radius:7px; padding:5px 6px; font-size:12.5px}

/* ---------- Layout ---------- */
#layout{display:flex; height:calc(100% - 52px)}
aside{background:var(--panel); overflow-y:auto; overflow-x:hidden}
#palette{width:212px; border-right:1px solid var(--line); padding:10px}
#props{width:264px; border-left:1px solid var(--line); padding:12px}
#stage{flex:1; position:relative; min-width:200px}
#stage{user-select:none; -webkit-user-select:none}
#stage input, #stage textarea{user-select:text; -webkit-user-select:text}
#cv2d{position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; -webkit-user-drag:none}
#view3d{position:absolute; inset:0}
#view3d canvas{display:block; touch-action:none; user-select:none; -webkit-user-select:none; -webkit-user-drag:none}
.hidden{display:none !important}

/* ---------- Palette ---------- */
.pal-cat{margin-bottom:14px}
.pal-cat h4{font-size:11px; text-transform:uppercase; letter-spacing:.8px; color:var(--muted); margin:4px 2px 7px}
.pal-grid{display:grid; grid-template-columns:1fr 1fr; gap:6px}
.pal-item{display:flex; flex-direction:column; align-items:center; gap:4px; padding:7px 4px 6px; background:#f8fafc; border:1px solid var(--line); border-radius:9px; font-size:11.3px; color:#334155; text-align:center; line-height:1.15; user-select:none; touch-action:none}
.pal-item:hover{border-color:var(--accent); background:var(--accent-soft)}
.pal-item.armed{border-color:var(--accent); background:var(--accent-soft); box-shadow:0 0 0 2px rgba(249,115,22,.35)}
.pal-item canvas{width:46px; height:34px}
.pal-item.wide{grid-column:1/-1; flex-direction:row; justify-content:flex-start; padding:8px 10px; gap:8px; font-weight:600}
.pal-item .dot{width:10px;height:10px;border-radius:3px;background:var(--accent)}

/* ---------- Props panel ---------- */
#props h3{font-size:13.5px; margin-bottom:10px; display:flex; justify-content:space-between; align-items:center}
#props .kind-tag{font-size:10.5px; background:var(--accent-soft); color:#c2410c; border-radius:20px; padding:2px 9px; font-weight:700; text-transform:uppercase; letter-spacing:.5px}
.pr-row{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px}
.pr-row label{font-size:12.5px; color:#475569; flex:1}
.pr-row input[type=number], .pr-row input[type=text], .pr-row select{width:118px; padding:6px 7px; border:1px solid var(--line); border-radius:7px; font-size:13px; background:#fff; color:var(--ink)}
.pr-row input:focus, .pr-row select:focus{outline:2px solid rgba(249,115,22,.35); border-color:var(--accent)}
/* dropdown compozitii: cautare + optiuni proprii */
.combo{position:relative; width:118px}
.combo-btn{width:100%; padding:6px 7px; border:1px solid var(--line); border-radius:7px; font-size:12px; background:#fff; color:var(--ink); text-align:left; cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.combo-btn:hover{border-color:var(--accent)}
.combo-pop{position:absolute; right:0; top:calc(100% + 4px); z-index:60; width:250px; background:#fff; border:1px solid var(--line); border-radius:9px; box-shadow:0 10px 26px rgba(15,23,42,.16); padding:6px}
.combo-q{width:100%; padding:6px 8px; border:1px solid var(--line); border-radius:7px; font-size:12.5px; margin-bottom:5px}
.combo-q:focus{outline:2px solid rgba(249,115,22,.35); border-color:var(--accent)}
.combo-list{max-height:230px; overflow:auto}
.combo-it{display:flex; align-items:center; justify-content:space-between; gap:6px; padding:6px 7px; border-radius:6px; font-size:12px; line-height:1.35; cursor:pointer; color:var(--ink)}
.combo-it:hover{background:var(--accent-soft)}
.combo-it.on{background:#fff7ed; outline:1px solid var(--accent)}
.combo-del{flex:0 0 auto; width:16px; height:16px; line-height:14px; text-align:center; border-radius:4px; color:#b91c1c; border:1px solid #fecaca; background:#fef2f2; font-size:11px}
.combo-del:hover{background:#fee2e2}
.combo-add{margin-top:4px; padding:6px 7px; border-top:1px dashed var(--line); font-size:12px; color:#c2410c; cursor:pointer; border-radius:6px}
.combo-add:hover{background:var(--accent-soft)}
/* sectiuni pliabile in paleta */
.pal-cat h4.pal-toggle{cursor:pointer; user-select:none}
.pal-cat h4.pal-toggle::before{content:'▾ '; font-size:9px; color:#94a3b8}
.pal-cat.closed h4.pal-toggle::before{content:'▸ '}
.pal-cat.closed .pal-grid{display:none}
.pal-search{grid-column:1 / -1; padding:6px 8px; border:1px solid var(--line); border-radius:7px; font-size:12px; margin-bottom:2px}
.pal-search:focus{outline:2px solid rgba(249,115,22,.35); border-color:var(--accent)}
/* integrare termopane-sbn.ro */
.pal-item.tsbn-link{border-style:dashed; color:#c2410c; font-weight:600}
.pal-item.tsbn-link:hover{background:var(--accent-soft)}
.pal-note{grid-column:1 / -1; font-size:10.5px; color:var(--muted); line-height:1.4; padding:4px 2px}
/* comanda de productie PVC */
.tsbn-tab{border-collapse:collapse; width:100%; margin:10px 0; font-size:12.5px}
.tsbn-tab th, .tsbn-tab td{border:1px solid var(--line); padding:5px 8px; text-align:left}
.tsbn-tab th{background:#f1f5f9; font-size:11px; text-transform:uppercase; letter-spacing:.4px; color:#475569}
.tsbn-form{display:grid; grid-template-columns:1fr 1fr; gap:7px; margin:10px 0}
.tsbn-form input{padding:7px 9px; border:1px solid var(--line); border-radius:7px; font-size:13px}
.tsbn-form input:focus{outline:2px solid rgba(249,115,22,.35); border-color:var(--accent)}
.tsbn-form .tsbn-note{grid-column:1 / -1}
.tsbn-status{font-size:12.5px; color:var(--muted); align-self:center}
.tsbn-thumb{width:34px; height:32px; object-fit:contain; display:block; background:#fff; border:1px solid var(--line); border-radius:4px}
.tsbn-cfg{font-size:11px; color:#c2410c; margin-left:6px; text-decoration:none}
.tsbn-cfg:hover{text-decoration:underline}
.tsbn-status.ok{color:#15803d; font-weight:600}
.tsbn-status.err{color:#b91c1c; font-weight:600}
/* bara de descarcare PDF (rezerva daca browserul blocheaza descarcarea automata) */
.pdf-dl{position:fixed; right:16px; bottom:64px; z-index:80; display:flex; align-items:center; gap:8px; background:#0f172a; color:#fff; border-radius:10px; padding:9px 12px; box-shadow:0 10px 26px rgba(15,23,42,.35)}
.pdf-dl a{color:#fdba74; font-weight:700; font-size:13.5px; text-decoration:none}
.pdf-dl a:hover{text-decoration:underline}
.pdf-dl button{background:none; border:none; color:#94a3b8; font-size:15px; cursor:pointer; padding:0 2px}
/* editor straturi */
.ly-row{display:flex; gap:5px; align-items:center; margin-bottom:6px}
.ly-name{flex:1; padding:6px 8px; border:1px solid var(--line); border-radius:7px; font-size:12.5px}
.ly-th{width:64px; padding:6px 6px; border:1px solid var(--line); border-radius:7px; font-size:12.5px}
.ly-btn{width:26px; height:28px; border:1px solid var(--line); border-radius:6px; background:#fff; cursor:pointer; font-size:12px; color:var(--ink)}
.ly-btn:hover{border-color:var(--accent); background:var(--accent-soft)}
.ly-btn.danger{color:#b91c1c; border-color:#fecaca; background:#fef2f2}
.ly-btn.danger:hover{background:#fee2e2}
.pr-sec{border-top:1px solid var(--line); margin:12px 0 10px; padding-top:10px}
.pr-sec h5{font-size:11px; text-transform:uppercase; color:var(--muted); letter-spacing:.7px; margin-bottom:8px}
.pr-note{font-size:11.5px; color:var(--muted); line-height:1.45; background:#f8fafc; border:1px solid var(--line); border-radius:8px; padding:7px 9px; margin-bottom:8px}
.pr-btns{display:flex; gap:6px; flex-wrap:wrap; margin-top:6px}
.btn{padding:7px 12px; border-radius:8px; border:1px solid var(--line); background:#fff; font-size:12.5px; color:var(--ink)}
.btn:hover{border-color:var(--accent); color:#c2410c; background:var(--accent-soft)}
.btn.primary{background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600}
.btn.primary:hover{background:#ea580c}
.btn.danger{color:#dc2626}
.btn.danger:hover{background:#fee2e2; border-color:#dc2626}
.btn.block{width:100%; text-align:center; margin-bottom:6px}
.cont-list button{display:flex; width:100%; justify-content:space-between; margin-bottom:5px}
.cont-list .dim{color:var(--muted); font-size:11.5px}

/* ---------- Status bar ---------- */
#statusbar{position:absolute; left:0; right:0; bottom:0; height:30px; background:rgba(255,255,255,.92); backdrop-filter:blur(4px); border-top:1px solid var(--line); display:flex; align-items:center; gap:16px; padding:0 12px; font-size:12px; color:#475569}
#statusbar select{border:1px solid var(--line); border-radius:5px; padding:1px 3px; font-size:12px}
#statusbar .hint{color:var(--accent); font-weight:600}
#stCoords{min-width:110px}
.chk{display:flex; align-items:center; gap:5px}

/* ---------- 3D bar ---------- */
#bar3d{position:absolute; top:10px; left:10px; display:flex; gap:6px; align-items:center; background:rgba(255,255,255,.94); border:1px solid var(--line); border-radius:10px; padding:6px 8px; box-shadow:var(--shadow); z-index:5}
.mini{padding:5px 10px; font-size:12px; border:1px solid var(--line); background:#fff; border-radius:7px; color:#334155}
.mini:hover{border-color:var(--accent); background:var(--accent-soft)}
#bar3d .sep{width:1px; height:18px; background:var(--line)}
#bar3d .chk{border:none; background:none; padding:3px 4px}

/* ---------- Modal ---------- */
#modalWrap{position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:50; display:flex; align-items:center; justify-content:center}
#modal{width:min(860px, 94vw); max-height:86vh; background:#fff; border-radius:14px; box-shadow:0 20px 60px rgba(0,0,0,.3); display:flex; flex-direction:column; overflow:hidden}
#modalHead{display:flex; justify-content:space-between; align-items:center; padding:14px 18px; border-bottom:1px solid var(--line); font-size:15px}
#modalBody{padding:16px 18px; overflow:auto; font-size:13.5px; line-height:1.55}
#modalBody table{width:100%; border-collapse:collapse; font-size:13px}
#modalBody th{background:#f1f5f9; text-align:left; padding:7px 9px; border:1px solid var(--line); font-size:12px; text-transform:uppercase; letter-spacing:.4px; color:#475569}
#modalBody td{padding:6px 9px; border:1px solid var(--line)}
#modalBody td.num{text-align:right; font-variant-numeric:tabular-nums}
#modalBody h4{margin:14px 0 8px; font-size:13px}
#modalBody .bom-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:6px}
#modalBody .fl-sec{margin-top:18px; border-top:2px solid var(--line); padding-top:10px}
#modalBody .fl-sec h4{font-size:14px; margin:0 0 8px; color:var(--ink)}
#modalBody .fl-opts{display:flex; flex-wrap:wrap; gap:8px 22px; margin-bottom:10px; font-size:12.5px; color:#334155}
#modalBody .fl-opts label{display:inline-flex; align-items:center; gap:5px; flex-wrap:wrap}
#modalBody .fl-opts input[type=number]{width:62px; padding:4px 6px; border:1px solid var(--line); border-radius:6px; font-size:13px}
#modalBody .fl-opts select{padding:4px 6px; border:1px solid var(--line); border-radius:6px; font-size:13px; max-width:100%; background:#fff}
#modalBody .fl-sw{display:inline-block; width:14px; height:14px; border-radius:3px; border:1px solid #94a3b8; vertical-align:-2px}
#modalBody .fl-scroll{overflow-x:auto; margin-bottom:10px}
#modalBody .fl-tbl{margin-bottom:0}
#modalBody .fl-tbl th.num{text-align:right}
#modalBody .fl-tbl tr.muted td{color:var(--muted)}
#modalBody .muted{color:var(--muted); font-size:12px}
#modalBody ul.fl-rules{margin:6px 0 0 18px; padding:0; font-size:12px; color:#475569; line-height:1.45}
kbd{background:#f1f5f9; border:1px solid var(--line); border-bottom-width:2px; border-radius:5px; padding:1px 6px; font-size:12px; font-family:inherit}

/* ---------- Toasts ---------- */
#toasts{position:fixed; bottom:44px; left:50%; transform:translateX(-50%); z-index:60; display:flex; flex-direction:column; gap:8px; align-items:center}
.toast{background:#111827; color:#f9fafb; padding:9px 16px; border-radius:10px; font-size:13px; box-shadow:var(--shadow); animation:tin .2s ease; max-width:80vw}
.toast.warn{background:#b45309}
@keyframes tin{from{opacity:0; transform:translateY(8px)}to{opacity:1}}

/* ---------- Error overlay ---------- */
#errOverlay{position:fixed; right:14px; top:64px; z-index:99; background:#fef2f2; border:1px solid #fecaca; color:#991b1b; border-radius:10px; padding:12px 14px; max-width:380px; font-size:12.5px; box-shadow:var(--shadow)}
#errOverlay b{display:block; margin-bottom:4px}
#errOverlay .err-msg{margin-bottom:8px; word-break:break-word}
#errOverlay button{background:#991b1b; color:#fff; border:none; border-radius:6px; padding:5px 10px}

@media (max-width: 980px){
  #palette{width:170px}
  #props{width:225px}
  .brand-sub{display:none}
  .tbtn span{display:none}
  .seg .tbtn span{display:inline}
}

/* bara plutitoare a selectiei multiple de containere (doar in planul 2D) */
body.mode3d .msel-bar{display:none !important}
.msel-bar{position:absolute; z-index:30; display:flex; gap:3px; align-items:center;
  background:#fff; border:1px solid #cbd5e1; border-radius:9px; padding:4px 5px;
  box-shadow:0 6px 20px rgba(15,23,42,.16)}
.msel-bar button{width:28px; height:28px; display:flex; align-items:center; justify-content:center;
  border:0; border-radius:6px; background:transparent; color:#334155; cursor:pointer; padding:0}
.msel-bar button svg{width:16px; height:16px}
.msel-bar button:hover{background:#f1f5f9; color:#0f172a}
.msel-bar button.danger{color:#b91c1c}
.msel-bar button.danger:hover{background:#fef2f2}
/* ---------- instalatii: plimbare 3D + inregistrare ---------- */
#walkHint{position:absolute;left:50%;bottom:60px;transform:translateX(-50%);
  background:rgba(15,23,42,.85);color:#fff;font-size:12.5px;padding:7px 15px;
  border-radius:999px;pointer-events:none;z-index:40;white-space:nowrap;box-shadow:0 4px 14px rgba(0,0,0,.25)}
#walkHint.hidden{display:none}
#v3walk.on{background:#0f766e;color:#fff;border-color:#0f766e}
#v3rec.on{background:#dc2626;color:#fff;border-color:#dc2626;animation:recblink 1.1s infinite}
@keyframes recblink{50%{opacity:.55}}

/* ---------- ofertare licitatie ---------- */
.spec-wrap{display:flex;flex-direction:column;gap:10px;min-width:min(680px,80vw)}
.spec-txt{width:100%;min-height:240px;resize:vertical;font:12.5px/1.45 ui-monospace,Consolas,monospace;
  padding:10px;border:1px solid #cbd5e1;border-radius:8px;background:#f8fafc;color:#0f172a}
.spec-txt:focus{outline:2px solid #f97316;border-color:transparent}
.spec-note{font-size:12.5px;color:#475569;margin:0}
.spec-note.small{font-size:11.5px;color:#64748b}
.spec-chk{font-size:12.5px;color:#334155;display:flex;align-items:center;gap:7px}
.spec-btns{display:flex;gap:8px}
.spec-btns .tbtn{padding:9px 18px;font-weight:600}
.spec-rep h4{margin:10px 0 4px;font-size:13.5px;color:#0f172a}
.spec-rep .spec-type{font-weight:400;color:#64748b;font-size:11.5px;text-transform:uppercase;letter-spacing:.04em}
.spec-rep ul{margin:0 0 6px;padding-left:18px;font-size:12.5px;color:#334155}
.spec-rep li{margin:2px 0}

/* statusbar: nu se mai revarsa peste panouri la latimi mici */
#statusbar{flex-wrap:wrap;row-gap:2px;overflow:hidden;height:auto;min-height:30px}
@media (max-width:1500px){ #statusbar #stHint{display:none} }

/* necesar panouri in proprietati (perete / fatada / container) */
.pan-tbl{width:100%; border-collapse:collapse; font-size:11.5px; margin-bottom:8px}
.pan-tbl td{padding:3px 4px; border-bottom:1px solid var(--line); color:#334155; vertical-align:middle}
.pan-tbl td.num{text-align:right; font-weight:600; white-space:nowrap}
.pan-tbl tr.bad td{color:#b91c1c; background:#fef2f2}
.pan-chip{display:inline-block; width:11px; height:11px; border-radius:2px; vertical-align:-1px; margin-right:6px; border:1px solid rgba(0,0,0,.18)}
.pr-note.warn{color:#b45309; background:#fffbeb; border-color:#fcd34d}
.pr-note.ok{color:#166534; background:#f0fdf4; border-color:#86efac}

/* legenda panourilor in 3D (activa cu "Culori panouri") */
#panLegend{position:absolute; right:12px; top:58px; z-index:4; background:rgba(255,255,255,.94); border:1px solid var(--line);
  border-radius:10px; padding:8px 10px; box-shadow:var(--shadow); font-size:11.5px; color:#334155; max-height:70%; overflow:auto; min-width:150px}
#panLegend h6{font-size:10.5px; text-transform:uppercase; letter-spacing:.6px; color:var(--muted); margin:0 0 6px}
#panLegend .lg-row{display:flex; align-items:center; gap:7px; padding:2px 0; white-space:nowrap}
#panLegend .lg-row b{min-width:22px}
#panLegend .lg-row .n{margin-left:auto; color:var(--muted); font-weight:600}

/* meniu derulant in bara de sus (JSON: import / export) */
.tb-menu{position:relative}
.tb-dd{position:absolute; top:40px; left:0; min-width:200px; background:#fff; border:1px solid var(--line); border-radius:9px;
  box-shadow:0 12px 32px rgba(0,0,0,.22); padding:5px; z-index:70}
.tb-dd button{display:block; width:100%; text-align:left; background:none; border:0; padding:8px 12px; font-size:13px; color:var(--ink); border-radius:6px; white-space:nowrap}
.tb-dd button:hover{background:var(--accent-soft); color:#c2410c}

/* lista de proiecte din baza: cautare + randul proiectului deschis */
.cl-head{display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:10px}
.cl-search{flex:1; min-width:200px; padding:8px 11px; border:1px solid var(--line); border-radius:8px; font-size:13.5px}
.cl-search:focus{outline:2px solid rgba(249,115,22,.35); border-color:var(--accent)}
#modalBody tr.cl-cur td{background:#fff7ed}
#modalBody tr.cl-row{cursor:pointer}
#modalBody tr.cl-row:hover td{background:#f8fafc}
#modalBody tr.cl-cur:hover td{background:#ffedd5}
.cl-count{color:var(--muted); font-size:12px; white-space:nowrap}
#modalBody .kind-tag{font-size:10.5px; background:var(--accent-soft); color:#c2410c; border-radius:20px; padding:2px 9px; font-weight:700; text-transform:uppercase; letter-spacing:.5px; white-space:nowrap}

/* comanda tamplarie PVC (API Termopane SBN 2026-09-06) */
.tsbn-form select{padding:7px 9px; border:1px solid var(--line); border-radius:7px; font-size:13px; background:#fff}
.tsbn-std{font-size:11px; color:#c2410c; font-weight:700; margin-left:5px; white-space:nowrap}
.tsbn-desc{font-size:11.5px; color:#475569; max-width:240px}
.tsbn-tab td.num{text-align:right; white-space:nowrap}
.tsbn-tab tr.bad td{background:#fef2f2}
.tsbn-tot{display:flex; flex-wrap:wrap; gap:16px; font-size:13px; margin:8px 0 6px; padding:8px 10px; background:#f8fafc; border:1px solid var(--line); border-radius:8px}
.tsbn-prev{font-size:12px; color:#475569; margin:6px 0 8px}
.tsbn-prev span{display:inline-block; background:#f1f5f9; border:1px solid var(--line); border-radius:6px; padding:2px 8px; margin:2px 4px 2px 0}
.tsbn-ok{font-size:15px; font-weight:700; color:#15803d; margin-bottom:6px}
.tsbn-code{font-size:14px; margin-bottom:10px}
.tsbn-warn{color:#b91c1c; font-weight:700; font-size:11.5px}

/* ============ TELEFON / TOUCH (<= 760 px) ============
   Paleta, proprietatile si bara de straturi devin panouri de jos comutate din #mobBar;
   planul ocupa tot ecranul. Bara de sus se aseaza pe doua randuri (icoane). */
body{display:flex; flex-direction:column}
#topbar{flex:0 0 auto}
#layout{flex:1; min-height:0; height:auto}
@supports (height:100dvh){ html,body{height:100dvh} }
#mobBar, #mobBackdrop{display:none}
@media (max-width:760px){
  body{-webkit-touch-callout:none; overscroll-behavior:none}
  #topbar{height:auto; min-height:46px; flex-wrap:wrap; gap:3px 4px; padding:4px 6px}
  .brand{margin-right:0} .brand b, .brand-sub{display:none}
  .tbtn{padding:8px 7px} .tbtn span{display:none} .seg .tbtn span{display:inline}
  .tb-spacer{display:none}
  /* pe telefon nu au rost: export STL (+ scara) si PNG */
  #btnSTL, #stlScale, #btnPNG{display:none}
  .tb-dd{left:auto; right:0}
  #layout{margin-bottom:calc(48px + env(safe-area-inset-bottom))}
  #palette, #props{position:fixed; left:0; right:0; top:auto; bottom:calc(48px + env(safe-area-inset-bottom)); width:auto;
    height:min(62vh, 470px); border:0; border-top:1px solid var(--line); border-radius:14px 14px 0 0;
    box-shadow:0 -10px 30px rgba(15,23,42,.18); z-index:46; padding:12px 12px 18px;
    transform:translateY(112%); transition:transform .22s ease; user-select:none; -webkit-user-select:none}
  #props input, #props textarea{user-select:text; -webkit-user-select:text}
  body.mob-pal #palette, body.mob-props #props{transform:none}
  .pal-grid{grid-template-columns:repeat(4, 1fr)}
  .pal-item{font-size:12px; padding:9px 4px 8px}
  #statusbar{position:fixed; left:0; right:0; top:auto; bottom:calc(48px + env(safe-area-inset-bottom)); height:auto; min-height:0;
    display:none; flex-wrap:wrap; gap:10px 16px; padding:14px 14px 18px; z-index:46; border-radius:14px 14px 0 0;
    box-shadow:0 -10px 30px rgba(15,23,42,.18); background:#fff; font-size:14px; overflow:visible}
  body.mob-layers #statusbar{display:flex}
  #statusbar #stHint{display:none}
  #statusbar .chk input{width:20px; height:20px}
  #mobBar{display:flex; position:fixed; left:0; right:0; bottom:0; height:calc(48px + env(safe-area-inset-bottom));
    padding-bottom:env(safe-area-inset-bottom); z-index:47; background:#111827; border-top:1px solid #1f2937}
  #mobBar button{flex:1; position:relative; background:none; border:0; color:#cbd5e1; font-size:12.5px; font-weight:600;
    display:flex; align-items:center; justify-content:center; gap:7px; -webkit-tap-highlight-color:transparent}
  #mobBar button svg{width:18px; height:18px}
  #mobBar button.on{color:#fff; background:#1f2937}
  #mobBar button .mb-dot{position:absolute; top:9px; right:calc(50% - 46px); width:8px; height:8px; border-radius:50%; background:var(--accent); display:none}
  #mobBar button.has-sel .mb-dot{display:block}
  #mobBackdrop{position:fixed; inset:0; bottom:calc(48px + env(safe-area-inset-bottom)); background:rgba(15,23,42,.22); z-index:45}
  body.mob-pal #mobBackdrop, body.mob-props #mobBackdrop, body.mob-layers #mobBackdrop{display:block}
  /* iOS mareste pagina la focus pe inputuri sub 16 px */
  input, select, textarea, .combo-btn{font-size:16px !important}
  .pr-row input[type=number], .pr-row input[type=text], .pr-row select, .combo{width:150px}
  #modalBody .fl-opts input[type=number]{font-size:16px; width:72px}
  #modalBody .fl-tbl{font-size:12px; min-width:760px}
  .pr-row input[type=number], .pr-row input[type=text], .pr-row select{padding:8px 9px}
  .btn{padding:10px 14px; font-size:14px}
  .mini{padding:8px 11px; font-size:13px}
  #bar3d{left:6px; right:6px; top:6px; flex-wrap:wrap; gap:4px; padding:5px 6px}
  #bar3d .sep, #v3walk, #v3rec{display:none}   /* plimbarea are nevoie de tastatura */
  #panLegend{top:auto; bottom:8px; right:6px; max-height:38%; font-size:10.5px; min-width:0}
  #modalWrap{align-items:flex-end}
  #modal{width:100vw; max-height:92vh; border-radius:14px 14px 0 0}
  #modalHead{padding:12px 14px}
  #modalBody{padding:12px 12px 26px; user-select:text; -webkit-user-select:text}
  #toasts{bottom:calc(60px + env(safe-area-inset-bottom)); width:calc(100% - 20px)}
  .toast{max-width:100%}
  #errOverlay{left:8px; right:8px; max-width:none; top:auto; bottom:calc(58px + env(safe-area-inset-bottom))}
  .msel-bar button{width:38px; height:38px}
  #walkHint{display:none}
  .pdf-dl{right:8px; left:8px; bottom:calc(58px + env(safe-area-inset-bottom))}
  .spec-wrap{min-width:0}
  .tsbn-form{grid-template-columns:1fr}
  .cl-search{min-width:0}
}
/* telefon tinut orizontal (inaltime mica): bara de sus pe un singur rand, derulabila */
@media (max-width:760px) and (max-height:500px){
  #topbar{flex-wrap:nowrap; overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch; scrollbar-width:none; height:46px}
  #topbar::-webkit-scrollbar{display:none}
  #palette, #props{height:min(78vh, 470px)}
}

/* ---------- Autentificare / partajare / vizualizare pentru client ---------- */
#authOverlay{position:fixed; inset:0; z-index:95; background:radial-gradient(1200px 600px at 20% 0%, #1f2937, #0b1220 70%); display:flex; align-items:center; justify-content:center; padding:16px}
.auth-card{width:min(400px, 100%); background:#fff; border-radius:16px; box-shadow:0 30px 80px rgba(0,0,0,.45); padding:26px 26px 20px}
.auth-brand{display:flex; align-items:center; gap:8px; color:var(--muted); font-size:12.5px; margin-bottom:14px}
.auth-brand b{color:var(--ink); font-size:15px}
.auth-card h2{font-size:20px; margin-bottom:4px; line-height:1.3}
.auth-sub{color:var(--muted); font-size:13px; margin-bottom:14px; line-height:1.45; white-space:pre-line}
.auth-sub b{color:var(--ink)}
.auth-foot a{color:var(--muted); text-decoration:none} .auth-foot a:hover{color:var(--accent)}
.auth-card label{display:block; margin-bottom:11px; font-size:12.5px; color:#334155}
.auth-card label span{display:block; margin-bottom:4px; font-weight:600}
.auth-card input[type=text], .auth-card input[type=password]{width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:9px; font-size:15px}
.auth-card input:focus{outline:2px solid rgba(249,115,22,.35); border-color:var(--accent)}
.auth-card label.auth-chk{display:flex; align-items:center; gap:8px; cursor:pointer}
.auth-card label.auth-chk span{margin:0; font-weight:500}
.auth-err{background:#fef2f2; color:#991b1b; border:1px solid #fecaca; border-radius:8px; padding:8px 10px; font-size:12.5px; margin-bottom:10px; line-height:1.4}
.auth-err.info{background:#eff6ff; color:#1e3a8a; border-color:#bfdbfe}
.auth-card .btn.block{padding:11px; font-size:14px; margin-top:4px}
.auth-card .btn.block:disabled{opacity:.6; cursor:default}
.auth-foot{color:var(--muted); font-size:11.5px; margin-top:12px; line-height:1.4}
#userName{max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.badge{display:inline-block; min-width:18px; height:18px; border-radius:9px; background:var(--accent); color:#fff; font-size:11px; font-weight:700; line-height:18px; text-align:center; padding:0 5px; font-style:normal}
.vm-only{display:none !important}
/* modul de vizualizare (link partajat): doar 2D/3D + observatii; restul interfetei este ascuns */
body.view-mode .vm-only{display:flex !important}
body.view-mode #palette, body.view-mode #props, body.view-mode #statusbar, body.view-mode #btnNew, body.view-mode #btnOpen,
body.view-mode #btnSave, body.view-mode .tb-menu, body.view-mode #btnUndo, body.view-mode #btnRedo, body.view-mode #btnSTL,
body.view-mode #stlScale, body.view-mode #btnPNG, body.view-mode #btnOrderPVC, body.view-mode #btnSpec, body.view-mode #btnBOM,
body.view-mode #btnCloud, body.view-mode #btnShare, body.view-mode #btnUser, body.view-mode #btnHelp, body.view-mode #bar3d .pro,
body.view-mode #mobPal, body.view-mode #mobProps, body.view-mode #mobLayers, body.view-mode .msel-bar{display:none !important}
body.view-mode .brand-sub{display:inline; color:#fff; font-weight:600; max-width:44vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
#notesPanel{width:300px; border-left:1px solid var(--line); background:var(--panel); display:flex; flex-direction:column; padding:0}
.np-head{display:flex; justify-content:space-between; align-items:center; padding:12px 14px; border-bottom:1px solid var(--line); font-size:14px}
.np-hint{color:var(--muted); font-size:12px; padding:10px 14px 0; line-height:1.45}
#notesList{flex:1; overflow-y:auto; padding:10px 14px}
.note{background:#f8fafc; border:1px solid var(--line); border-radius:10px; padding:8px 10px; margin-bottom:8px; font-size:13px; line-height:1.45; white-space:pre-wrap; word-break:break-word}
.note.sbn{background:#fff7ed; border-color:#fed7aa}
.note .nm{font-size:11.5px; color:var(--muted); margin-bottom:3px; white-space:normal}
.note .nm b{color:var(--ink)}
#notesForm{padding:10px 14px 14px; border-top:1px solid var(--line)}
#notesForm label{display:block; font-size:12px; color:#334155; margin-bottom:8px}
#notesForm label span{display:block; margin-bottom:3px; font-weight:600}
#notesForm input, #notesForm textarea{width:100%; padding:8px 10px; border:1px solid var(--line); border-radius:8px; font:inherit; font-size:13.5px; resize:vertical}
.note-empty{color:var(--muted); font-size:12.5px}
/* dialogul de partajare (admin) */
.sh-intro{color:var(--muted); font-size:12.5px; margin-bottom:10px; line-height:1.45}
.sh-new{display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:12px}
.sh-new input{flex:1; min-width:160px; padding:8px 10px; border:1px solid var(--line); border-radius:8px; font-size:13.5px}
.sh-item{border:1px solid var(--line); border-radius:12px; padding:10px 12px; margin-bottom:10px}
.sh-item.off{opacity:.6}
.sh-row{display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-top:6px}
.sh-link{font-family:ui-monospace, Consolas, monospace; font-size:12px; background:#f1f5f9; border-radius:7px; padding:6px 9px; flex:1; min-width:180px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.sh-pass{font-family:ui-monospace, Consolas, monospace; font-size:15px; font-weight:700; letter-spacing:1px; background:#fff7ed; border:1px dashed #fdba74; border-radius:8px; padding:6px 10px}
.sh-meta{color:var(--muted); font-size:12px; margin-top:4px}
.sh-notes{margin-top:8px; border-top:1px dashed var(--line); padding-top:8px}
.sh-notes textarea{width:100%; padding:7px 9px; border:1px solid var(--line); border-radius:8px; font:inherit; font-size:13px; margin-bottom:6px}
.us-tbl input, .us-tbl select{padding:5px 7px; border:1px solid var(--line); border-radius:6px; font-size:13px}
.us-tbl td{vertical-align:middle}
@media (max-width:760px){
  #notesPanel{position:fixed; left:0; right:0; top:auto; bottom:calc(48px + env(safe-area-inset-bottom)); width:auto; height:min(70vh, 520px);
    border:0; border-top:1px solid var(--line); border-radius:14px 14px 0 0; box-shadow:0 -10px 30px rgba(15,23,42,.18); z-index:46;
    transform:translateY(112%); transition:transform .22s ease}
  body.mob-notes #notesPanel{transform:none}
  body.mob-notes #mobBackdrop{display:block}
  body.view-mode #btnNotes{display:none !important}
  #notesForm input, #notesForm textarea{font-size:16px !important}
}
