:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --ok: #dcf3dc;
  --ok-line: #8cc98c;
  --zam: #fdeec4;
  --zam-line: #e2b84a;
  --brak: #fadada;
  --brak-line: #d97777;
  --sel: #dbe7fb;
  --red: #b42318;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.strong { font-weight: 600; padding: 6px 0; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: #1d2330; color: #fff; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.top-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top .muted { color: #b8bfcc; }
.top .btn { background: #2f3a4f; color: #fff; border-color: #44516b; }
.top .btn:hover { background: #3a4762; }
.link { color: #b8d0ff; text-decoration: none; }
.pill { background: #e2b84a; color: #1d2330; border-radius: 10px; padding: 1px 8px; font-size: 11px; margin-left: 6px; }

.alert { margin: 12px 20px 0; padding: 10px 14px; border-radius: 6px; background: var(--brak); border: 1px solid var(--brak-line); }
.alert.info { background: var(--sel); border-color: #9bb8e8; }

.tabs { display: flex; gap: 2px; padding: 14px 20px 0; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line); border-bottom: none; background: #e9ebef; color: var(--text);
  padding: 9px 16px; border-radius: 6px 6px 0 0; cursor: pointer; font: inherit;
}
.tab.active { background: var(--panel); font-weight: 600; }
.cnt { font-size: 12px; background: #d6dae2; border-radius: 9px; padding: 0 7px; margin-left: 4px; }
.cnt.red { background: var(--red); color: #fff; }
.cnt:empty { display: none; }

main { padding: 0 20px 30px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 0 6px 6px 6px; padding: 14px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.hint { color: var(--muted); margin: 4px 0 10px; font-size: 13px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-left: 10px; }
.sw.ok { background: var(--ok); border: 1px solid var(--ok-line); }
.sw.zamowione { background: var(--zam); border: 1px solid var(--zam-line); }
.sw.brak { background: var(--brak); border: 1px solid var(--brak-line); }

.btn {
  font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid #c9ced8;
  background: #fff; color: var(--text); cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { background: #194f9f; }
.btn:disabled { opacity: .5; cursor: default; }
.ico {
  font: inherit; border: 1px solid transparent; background: transparent; cursor: pointer;
  padding: 3px 7px; border-radius: 4px; color: #3b4456;
}
.ico:hover { background: rgba(0,0,0,.07); border-color: rgba(0,0,0,.1); }
.input { font: inherit; padding: 7px 10px; border: 1px solid #c9ced8; border-radius: 6px; width: 100%; }
#szukaj-cz { max-width: 320px; }
.check { display: flex; align-items: center; gap: 6px; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th {
  text-align: left; font-weight: 600; font-size: 12.5px; color: #4b5363; background: #f7f8fa;
  border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap;
}
.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid .r { text-align: right; font-variant-numeric: tabular-nums; }
.grid .c { text-align: center; }
.grid .akcje { white-space: nowrap; text-align: right; }
.grid tr.ok td { background: var(--ok); }
.grid tr.zamowione td { background: var(--zam); }
.grid tr.brak td { background: var(--brak); }
.grid tr.blad td { background: #ececec; }
#t-lista tbody tr { cursor: pointer; }
#t-lista tbody tr.sel td { box-shadow: inset 0 2px 0 #1f5fbf, inset 0 -2px 0 #1f5fbf; }
#t-lista tbody tr.sel td:first-child { box-shadow: inset 3px 2px 0 #1f5fbf, inset 0 -2px 0 #1f5fbf; }
.status-txt { font-weight: 600; }
tr.brak .status-txt { color: var(--red); }
.small { font-size: 12.5px; color: #3b4456; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.detail { margin-top: 18px; border-top: 2px solid var(--line); padding-top: 6px; }
.detail h3 { margin: 8px 0 10px; font-size: 15px; }

dialog { border: none; border-radius: 10px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,25,35,.45); }
#dlg-form { padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; }
#dlg-form h3 { margin: 0 0 8px; }
#dlg-form label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.picker { list-style: none; margin: 6px 0 0; padding: 0; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.picker li { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid #f0f1f4; }
.picker li:hover { background: #f3f6fb; }
.picker li.sel { background: var(--accent); color: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.err { color: var(--red); min-height: 18px; font-size: 13px; }

@media (max-width: 700px) {
  main, .tabs { padding-left: 8px; padding-right: 8px; }
  .top { padding: 10px 12px; }
  .panel { padding: 10px; }
  .row2 { grid-template-columns: 1fr; }
}
