:root{
  --blue:#1a73e8; --blue-d:#1557b0; --bg:#f0f2f5; --line:#e3e7ee;
  --ok:#137333; --danger:#d93025; --text:#202124;
}
*{ box-sizing:border-box; }
body{ margin:0; font-family:system-ui,Segoe UI,Arial,sans-serif; background:var(--bg); color:var(--text); height:100vh; overflow:hidden; }
a{ color:var(--blue); }

.topbar{ position:fixed; top:0; left:0; right:0; height:52px; background:var(--blue); color:#fff;
  display:flex; align-items:center; justify-content:space-between; padding:0 18px; z-index:100;
  box-shadow:0 2px 6px rgba(0,0,0,.2); }
.topbar .brand{ font-weight:600; font-size:16px; }
.topbar .right{ display:flex; align-items:center; gap:12px; font-size:13px; }
.topbar button{ background:rgba(255,255,255,.15); color:#fff; border:1px solid rgba(255,255,255,.4);
  padding:6px 12px; border-radius:7px; cursor:pointer; font-size:13px; }
.topbar button:hover{ background:rgba(255,255,255,.28); }

.sidebar{ position:fixed; top:52px; left:0; bottom:0; width:212px; background:#fff;
  border-right:1px solid var(--line); overflow-y:auto; z-index:90; }
.menu{ list-style:none; margin:0; padding:8px 0; }
.menu > li{ font-size:14px; }
.menu a.ml{ display:block; padding:11px 18px; color:#333; text-decoration:none; border-left:3px solid transparent; cursor:pointer; }
.menu a.ml:hover{ background:#f0f4ff; }
.menu li.active > a.ml{ background:#e8f0fe; color:var(--blue); font-weight:600; border-left-color:var(--blue); }
/* hamburger + zwijanie menu */
.topbar .tbleft{ display:flex; align-items:center; gap:10px; }
.topbar .ham{ background:rgba(255,255,255,.15); color:#fff; border:1px solid rgba(255,255,255,.4); border-radius:7px; padding:3px 10px; cursor:pointer; font-size:15px; line-height:1.4; }
.topbar .ham:hover{ background:rgba(255,255,255,.28); }
.sidebar{ transition:transform .18s ease; }
.main{ transition:left .18s ease; }
body.menu-collapsed .sidebar{ transform:translateX(-100%); }
body.menu-collapsed .main{ left:0; }

/* rozwijane podmenu szybowcow (Spis / Rejestr) */
.menu .has-sub{ padding:0; cursor:default; }
.menu .has-sub:hover{ background:none; }
.menu .has-sub > .parent{ padding:11px 18px; cursor:pointer; font-size:14px; color:#333;
  border-left:3px solid transparent; display:flex; align-items:center; justify-content:space-between; gap:8px; }
.menu .has-sub > .parent:hover{ background:#f0f4ff; }
.menu .has-sub.open > .parent{ color:var(--blue); font-weight:600; border-left-color:var(--blue); background:#e8f0fe; }
.menu .caret{ font-size:11px; opacity:.6; transition:transform .15s; }
.menu .has-sub.open .caret{ transform:rotate(90deg); }
.menu .submenu{ list-style:none; margin:0; padding:0; max-height:0; overflow:hidden; transition:max-height .2s ease; background:#fafbfe; }
.menu .has-sub.open .submenu{ max-height:1400px; }
.menu .sub-item{ font-size:12.5px; }
.menu .sub-item a.sl{ display:flex; align-items:center; justify-content:space-between; gap:8px; padding:5px 16px 5px 30px; color:#444; text-decoration:none; border-left:3px solid transparent; }
.menu .sub-item a.sl:hover{ background:#eef2ff; }
.menu .sub-item.active a.sl{ background:#e8f0fe; color:var(--blue); font-weight:600; border-left-color:var(--blue); }
.menu .sub-item .nm{ min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.menu .sub-item .cnt{ opacity:.55; font-size:11px; }

/* przyciski zjazd/wjazd listy (#5) */
.scroll-fab{ position:fixed; right:20px; bottom:20px; display:flex; flex-direction:column; gap:9px; z-index:80; }
.scroll-fab button{ width:42px; height:42px; border-radius:50%; border:none; background:var(--blue); color:#fff;
  font-size:15px; cursor:pointer; box-shadow:0 2px 8px rgba(0,0,0,.28); opacity:.82; transition:opacity .15s; }
.scroll-fab button:hover{ opacity:1; background:var(--blue-d); }

.main{ position:fixed; top:52px; left:212px; right:0; bottom:0; padding:18px 24px;
  overflow:hidden; display:flex; flex-direction:column; }
h1.page{ font-size:20px; margin:0 0 16px; flex:0 0 auto; }
/* jedna winda: przewija sie tylko obszar tabeli/listy, reszta zablokowana */
.scroll-y{ flex:1 1 auto; overflow:auto; min-height:0; }

.toolbar{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:14px; flex:0 0 auto; }
.toolbar input[type=text]{ padding:7px 10px; border:1px solid #d6dbe5; border-radius:7px; font-size:13px; }

.btn{ padding:7px 13px; border:none; border-radius:7px; cursor:pointer; font-size:13px; }
.btn-primary{ background:var(--blue); color:#fff; } .btn-primary:hover{ background:var(--blue-d); }
.btn-secondary{ background:#e6e9ef; color:#333; } .btn-secondary:hover{ background:#dadfe8; }
.btn-danger{ background:none; color:var(--danger); font-size:15px; padding:2px 6px; cursor:pointer; border:none; }

.tbl-wrap{ background:#fff; border-radius:10px; box-shadow:0 1px 6px rgba(0,0,0,.07);
  overflow:auto; flex:1 1 auto; min-height:0; }
table{ width:100%; border-collapse:separate; border-spacing:0; font-size:13px; }
th{ position:sticky; top:0; background:var(--blue); color:#fff; padding:7px 9px; text-align:left;
  white-space:nowrap; cursor:pointer; z-index:1; }
td{ padding:5px 9px; border-bottom:1px solid var(--line); vertical-align:top; }
tr:nth-child(even) td{ background:#f7f9ff; }
tr:hover td{ background:#eef4ff; }
td[contenteditable]{ cursor:text; min-width:60px; }
td[contenteditable]:focus{ outline:2px solid var(--blue); background:#fff; }
tr.done td{ color:#9aa0a6; }
tr.done td:not(:last-child){ text-decoration:line-through; }
input.cell-date{ position:relative; border:1px solid #d6dbe5; border-radius:5px; padding:2px 5px; font-size:12px; }
/* schowana ikonka kalendarza, ale klik w cala date otwiera picker */
input.cell-date::-webkit-calendar-picker-indicator{ position:absolute; inset:0; width:100%; height:100%; margin:0; padding:0; opacity:0; cursor:pointer; }

/* przeciaganie szerokosci kolumn */
.tbl-wrap{ position:relative; }
.col-grip{ position:absolute; top:0; right:0; width:9px; height:100%; cursor:col-resize; z-index:2; }
.col-grip:hover{ background:rgba(255,255,255,.55); }
.col-guide{ position:absolute; top:0; bottom:0; width:2px; margin-left:-1px; background:var(--blue); opacity:.8; z-index:6; pointer-events:none; }
body.col-resizing{ cursor:col-resize; user-select:none; }
body.col-resizing *{ cursor:col-resize !important; }
/* widoczne, ciensiutkie linie miedzy kolumnami (tylko tabele z regulacja szerokosci) */
table.cols-resizable th, table.cols-resizable td{ border-right:1px solid var(--line); }
table.cols-resizable th{ border-right-color:rgba(255,255,255,.3); }
table.cols-resizable th:last-child, table.cols-resizable td:last-child{ border-right:none; }
table.cols-resizable td{ word-break:break-word; }
/* kolumna skanu/linkow: ikony obok siebie w jednej linii (rowna wysokosc wiersza) */
.link-cell{ white-space:nowrap; }
/* komorka uwag: stala wysokosc, tekst przyciety, ikona zawsze po PRAWEJ, cala komorka klikalna, bez myslnika */
.cell-clamp{ position:relative; }
.cell-clamp.clickable{ cursor:pointer; }
.cell-clamp.clickable:hover{ background:#eef4ff; }
.cell-clamp .ctxt{ display:block; max-width:240px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding-right:16px; }
.cell-clamp .ic{ position:absolute; top:5px; right:7px; color:var(--blue); font-size:13px; line-height:1; pointer-events:none; }
.cell-clamp.clickable:hover .ic{ color:var(--blue-d); }

/* popup Terminy */
.terminy-tbl{ width:100%; border-collapse:collapse; font-size:13px; }
.terminy-tbl th{ position:sticky; top:0; background:var(--blue); color:#fff; padding:6px 9px; text-align:left; white-space:nowrap; cursor:pointer; user-select:none; }
.terminy-bar{ display:flex; gap:8px; align-items:center; margin:0 0 10px; }
.terminy-bar #t-q{ flex:1; padding:7px 10px; border:1px solid #d6dbe5; border-radius:7px; font-size:13px; }
.terminy-tbl td{ padding:5px 9px; border-bottom:1px solid var(--line); }
.terminy-tbl tr:hover td{ background:#f3f7ff; }
.tbadge{ display:inline-block; padding:2px 9px; border-radius:11px; font-size:12px; white-space:nowrap; }
.tbadge.tr{ background:#fce8e6; color:#c5221f; }
.tbadge.ta{ background:#fef7e0; color:#9a6700; }
.tbadge.tg{ background:#e6f4ea; color:#137333; }

/* przyciski-filtry z kolorem stanu */
.btn-toggle{ border:none; color:#fff; padding:7px 13px; border-radius:7px; cursor:pointer; font-size:13px; }
.btn-toggle.off{ background:var(--ok); }
.btn-toggle.off:hover{ background:#0f5c29; }
.btn-toggle.on{ background:var(--danger); }
.btn-toggle.on:hover{ background:#b3271f; }
/* grupowanie po nr zlecenia (Zap. Sprzedaz): scalona komorka nr zlecenia (rowspan) */
td.grp-cell{ background:#eef3fc; border-right:2px solid #c5d4ee; vertical-align:top; }
td.grp-cell .grp-nr{ font-weight:600; color:var(--blue-d); font-family:monospace; font-size:13px; margin-bottom:6px; white-space:nowrap; }
.btn-mini{ border:1px solid var(--blue); background:#fff; color:var(--blue); border-radius:6px; padding:2px 9px; font-size:12px; cursor:pointer; }
.btn-mini:hover{ background:#e8f0fe; }

/* stany wierszy: wyslane do produkcji (zielony pasek), podswietlenie aktywnego */
tr.wyslane td:first-child{ box-shadow: inset 4px 0 0 #1e8e3e; }
tr.row-hi td{ background:#fff3cd; }
/* dziecko (podzespol przypiety do rodzica) w Zapotrzebowaniu */
tr.zap-child > td{ background:#f7faff; }
tr.zap-child > td:nth-child(2){ box-shadow: inset 4px 0 0 #9bb4e0; }
/* popup dodawania wielu pozycji na raz */
.add-row{ display:flex; gap:8px; margin-bottom:8px; align-items:center; }
.add-row input{ padding:7px 9px; border:1px solid #d6dbe5; border-radius:6px; font-size:13px; min-width:0; }
.add-row .ar-nr{ flex:0 0 130px; }
.add-row .ar-nazwa{ flex:1 1 40%; }
.add-row .ar-ilosc{ flex:0 0 80px; }
.add-row .ar-uwagi{ flex:1 1 40%; }
.add-row .ar-del{ flex:0 0 auto; }

.form-row{ background:#fff; border-radius:10px; padding:14px; box-shadow:0 1px 6px rgba(0,0,0,.07);
  margin-bottom:14px; display:none; flex:0 0 auto; }
.form-row.show{ display:block; }
.form-row .fields{ display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; }
.field{ display:flex; flex-direction:column; font-size:12px; color:#555; gap:3px; }
.field input{ padding:7px; border:1px solid #d6dbe5; border-radius:6px; font-size:13px; }

.toast{ position:fixed; bottom:22px; left:50%; transform:translateX(-50%); background:#323232; color:#fff;
  padding:11px 18px; border-radius:8px; font-size:13px; z-index:9999; opacity:0; transition:opacity .2s; pointer-events:none; }
.toast.show{ opacity:1; }
.toast.err{ background:var(--danger); }

/* modale (skan / wybor z bazy) */
.modal-bg{ position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:200; display:flex; align-items:center; justify-content:center; padding:16px; }
.modal{ background:#fff; border-radius:12px; padding:20px 22px; width:min(480px,94vw); max-height:88vh; overflow:auto;
  box-shadow:0 10px 34px rgba(0,0,0,.32); }
.modal h3{ margin:0 0 14px; font-size:16px; }
.modal .opt{ border:1px solid var(--line); border-radius:9px; padding:12px 14px; margin-bottom:10px; }
.modal .opt > label{ font-size:12px; color:#555; display:block; margin-bottom:7px; font-weight:600; }
.modal .opt .row{ display:flex; gap:8px; align-items:center; }
.modal .opt .row input[type=text]{ flex:1; padding:7px 10px; border:1px solid #d6dbe5; border-radius:7px; font-size:13px; }
.file-btn{ display:inline-block; padding:9px 14px; border-radius:8px; background:var(--blue); color:#fff; cursor:pointer; font-size:13px; }
.file-btn:hover{ background:var(--blue-d); }
.file-btn input{ display:none; }
.modal .close-row{ display:flex; justify-content:flex-end; gap:8px; margin-top:6px; }
.picker-list{ border:1px solid var(--line); border-radius:8px; max-height:320px; overflow:auto; margin-top:8px; }
.picker-list .it{ padding:8px 10px; cursor:pointer; font-size:13px; border-bottom:1px solid var(--line); word-break:break-word; }
.picker-list .it:last-child{ border-bottom:none; }
.picker-list .it:hover{ background:#eef4ff; }

/* panel BOM (podzespoly) - rozwijany wiersz */
tr.bom-row > td{ background:#f7faff; padding:0; border-bottom:1px solid var(--line); }
.bom-wrap{ padding:10px 14px 12px; }
.bom-tbl{ width:auto; min-width:460px; border-collapse:collapse; font-size:12.5px; background:#fff; border:1px solid var(--line); border-radius:8px; }
.bom-tbl th{ position:static; background:#eef3fc; color:#33415c; padding:5px 9px; text-align:left; white-space:nowrap; cursor:default; }
.bom-tbl td{ padding:4px 9px; border-top:1px solid var(--line); }
.bom-tbl td[contenteditable]:focus{ outline:2px solid var(--blue); background:#fff; }
.bom-lbl{ font-size:12px; color:#5f6368; margin-bottom:4px; }
.bom-extra .ar-nr{ flex:0 0 120px; }
.bom-extra .ar-nazwa{ flex:1 1 28%; }
.bom-extra .ar-ilosc{ flex:0 0 60px; }
.bom-extra .ar-uwagi{ flex:1 1 32%; }
.bom-add{ display:flex; gap:6px; align-items:center; margin-top:8px; flex-wrap:wrap; }
.bom-add input{ padding:6px 8px; border:1px solid #d6dbe5; border-radius:6px; font-size:12.5px; }
.bom-toggle{ border:1px solid #c5d4ee; background:#fff; color:var(--blue); border-radius:6px; padding:0 7px; font-size:13px; cursor:pointer; line-height:1.6; }
.bom-toggle:hover{ background:#e8f0fe; }
.bom-toggle.open{ background:var(--blue); color:#fff; }

/* autouzupelnianie nr rys / nazwa (dropdown) */
.ac-box{ position:fixed; z-index:300; background:#fff; border:1px solid #cdd6e4; border-radius:8px;
  box-shadow:0 6px 18px rgba(0,0,0,.18); max-height:260px; overflow:auto; }
.ac-it{ padding:7px 10px; cursor:pointer; font-size:13px; border-bottom:1px solid #f0f2f5; white-space:nowrap; display:flex; gap:10px; align-items:baseline; }
.ac-it:last-child{ border-bottom:none; }
.ac-it:hover, .ac-it.on{ background:#eef4ff; }
.ac-it b{ font-family:monospace; flex:0 0 auto; }
.ac-it .ac-nz{ color:#5f6368; overflow:hidden; text-overflow:ellipsis; }

/* Uslugowki: widoki + kalkulator */
#v-list, #v-edit{ flex:1 1 auto; min-height:0; display:flex; flex-direction:column; }
#v-list[hidden], #v-edit[hidden]{ display:none; }
.kalk-tbl{ border-collapse:collapse; font-size:13px; background:#fff; min-width:620px; }
.kalk-tbl th{ position:static; background:#eef3fc; color:#33415c; padding:5px 9px; text-align:left; white-space:nowrap; cursor:default; }
.kalk-tbl th.num{ text-align:right; }
.kalk-tbl td{ padding:3px 6px; border-top:1px solid var(--line); vertical-align:middle; }
.kalk-tbl input{ border:1px solid #d6dbe5; border-radius:5px; padding:4px 6px; font-size:13px; }
.usl-pliki{ display:flex; flex-direction:column; gap:5px; }
.usl-plik{ display:flex; align-items:center; gap:8px; font-size:13px; }
.usl-plik .typ{ font-size:11px; font-weight:600; padding:1px 7px; border-radius:9px; }
.usl-plik .typ.wz{ background:#e6f1fb; color:#0c447c; } .usl-plik .typ.fv{ background:#fef7e0; color:#9a6700; } .usl-plik .typ.inne{ background:#f1efe8; color:#444; }

.muted{ color:#5f6368; }
.tiles{ display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:14px; max-width:760px; }
.tile{ background:#fff; border-radius:10px; padding:18px; box-shadow:0 1px 6px rgba(0,0,0,.07);
  cursor:pointer; text-decoration:none; color:#333; display:block; }
.tile:hover{ box-shadow:0 3px 12px rgba(0,0,0,.13); }
.tile.disabled{ opacity:.5; cursor:default; }
.tile .ic{ font-size:26px; } .tile .t{ margin-top:8px; font-weight:600; font-size:14px; }
