:root {
  --bg: #f3f4f6; --surface: #fff; --text: #1f2937; --muted: #6b7280; --border: #e2e5ea;
  --primary: #0f766e; --primary-d: #0b5d57; --primary-l: #e6f4f2;
  --side: #1e293b; --side-text: #cbd5e1;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); display: flex; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0; font-weight: 650; }
h3 { font-size: 14px; margin: 14px 0 8px; }
.ic { flex: none; vertical-align: -3px; }
.muted { color: var(--muted); font-weight: 400; }
.sub { color: var(--muted); font-size: 12.5px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.mt { margin-top: 8px; }
.late { color: var(--bad); font-weight: 600; }

/* --- menu boczne --- */
.side { width: 218px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.side nav, .side-bottom { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; }
.side-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-bottom: 14px; }
.side a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 9px 10px; border-radius: 8px; }
.side a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.side a.active { background: rgba(255,255,255,.12); color: #fff; }
.side a.primary { background: var(--primary); color: #fff; font-weight: 600; margin-bottom: 8px; }
.side a.primary:hover { background: var(--primary-d); }

/* --- pasek górny --- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 16px; padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.gsearch { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; color: var(--muted); }
.gsearch input { border: 0; background: transparent; padding: 9px 0; flex: 1; outline: none; font-size: 14px; }
.counters { display: flex; gap: 6px; margin-left: auto; }
.cnt { display: flex; flex-direction: column; align-items: center; padding: 3px 12px; border-radius: 8px; color: var(--text); min-width: 74px; }
.cnt:hover { background: var(--bg); text-decoration: none; }
.cnt b { font-size: 18px; line-height: 1.1; }
.cnt span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cnt.ok b { color: var(--ok); }
.cnt.warn.on b { color: var(--warn); }
.cnt.bad.on b { color: var(--bad); }
.content { padding: 20px 22px 60px; max-width: 1500px; width: 100%; }

/* --- elementy --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; margin-bottom: 4px; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cols { display: flex; gap: 16px; align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.side-card, .side-col { width: 340px; flex: none; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert.ok { background: #ecfdf3; border-color: #abefc6; color: #05603a; }
.alert.err { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.alert.info { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 11px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; align-items: stretch; }
.btn-group > .btn, .btn-group > input { border-radius: 0; margin-left: -1px; }
.btn-group > :first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group > :last-child { border-radius: 0 8px 8px 0; }
.btn-group .qty, .qty { width: 64px !important; flex: none; text-align: center; border: 1px solid var(--border); font: inherit; font-weight: 600; }
.qty.big { width: 68px; font-size: 16px; }
.qty-suffix { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--border); background: #f9fafb; color: var(--muted); font-size: 13px; margin-left: -1px; }
.print-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.link { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; text-decoration: underline; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: color-mix(in srgb, var(--c) 18%, #fff); border: 1px solid color-mix(in srgb, var(--c) 55%, #fff); color: #111; white-space: nowrap; vertical-align: middle; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.badge.big { font-size: 13.5px; padding: 4px 12px 4px 10px; margin-left: 8px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--primary-l); color: var(--primary-d); font-size: 12.5px; margin: 0 2px 3px 0; }
.tag.warn { background: #fff4e5; color: #9a5b00; }

/* --- tabele --- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f0f1f3; vertical-align: top; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #f9fafb; }
.repairs-tbl td:first-child { border-left: 4px solid var(--st, transparent); }
.tbl td.num a { font-weight: 700; font-family: ui-monospace, Consolas, monospace; }
.tbl td.clip { max-width: 320px; }
.tbl tr.inactive td { opacity: .5; }
.pager { display: flex; gap: 4px; flex-wrap: wrap; }
.pager a { padding: 5px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.pager a.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- formularze --- */
input, select, textarea { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
textarea { resize: vertical; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.4; white-space: pre; }
.lbl, .form label:not(.chk):not(.chip) { display: block; font-size: 12.5px; font-weight: 600; color: #344054; margin-bottom: 10px; }
.lbl > input, .lbl > select, .lbl > textarea, .lbl > .with-btn, .form label > input, .form label > select, .form label > textarea { margin-top: 4px; font-weight: 400; font-size: 14px; }
div.lbl { margin-bottom: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0 12px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; margin-right: 12px; }
.field-err { color: var(--bad); font-size: 12.5px; margin: -6px 0 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.filters .frow { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters .frow + .frow { margin-top: 4px; }
.filters label:not(.chk) { margin-bottom: 0; font-size: 12.5px; font-weight: 600; }
.filters label > input, .filters label > select { margin-top: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 0; padding: 6px 0; }
.narrow { max-width: 480px; }
.hint { font-size: 13px; color: var(--muted); }
details > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--primary); margin: 4px 0 10px; }
.w60 { width: 70px !important; }

/* chipy (przyciski wyboru) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 6px 11px; border: 1px solid #d0d5dd; border-radius: 999px; background: #fff; font-size: 13px; user-select: none; }
.chip:hover span { border-color: var(--primary); }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(15,118,110,.25); }

/* --- przyjęcie --- */
.intake-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.intake-grid .card { margin: 0; }
.span2 { grid-column: span 2; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-no { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.sn-info { border-radius: 8px; padding: 10px 12px; margin: -4px 0 12px; font-size: 13px; border: 1px solid #b2ddff; background: #eff8ff; }
.sn-info.found { border-color: #abefc6; background: #ecfdf3; }
.sn-info.warn { border-color: #fedf89; background: #fffaeb; }
.sn-info ul { margin: 6px 0; padding-left: 18px; }
.client-card { border: 1px solid #abefc6; background: #f6fef9; border-radius: 8px; padding: 12px; }
.cc-name { font-weight: 700; font-size: 15px; }
.cc-line { margin-top: 2px; }
.cc-actions { display: flex; gap: 6px; margin-top: 8px; }
.submit-bar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); margin-top: 8px; }
.thumbs, .gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.gallery img { width: 130px; height: 100px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.specs-box { border-top: 1px dashed var(--border); padding-top: 6px; }

/* podpowiedzi */
.ac-wrap { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); background: #fff; border: 1px solid #d0d5dd; border-radius: 8px; box-shadow: 0 8px 24px rgba(16,24,40,.12); z-index: 50; max-height: 320px; overflow-y: auto; padding: 4px; }
.ac-item { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-weight: 400; color: var(--text); }
.ac-item small { display: block; color: var(--muted); font-size: 12px; }
.ac-item.on, .ac-item:hover { background: var(--primary-l); }
.ac-new { color: var(--primary); font-weight: 600; border-top: 1px solid var(--border); margin-top: 4px; }

/* --- karta naprawy --- */
.kv-grid { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; }
.kv-grid .k { color: var(--muted); font-size: 13px; }
.kv-grid .v.strong { font-weight: 600; font-size: 15px; }
.kv-grid .v.internal { background: #fffaeb; padding: 6px 8px; border-radius: 6px; }
.edit-card > summary { list-style: none; margin: 0; }
.edit-card > summary::-webkit-details-marker { display: none; }
.edit-card[open] > summary { margin-bottom: 12px; }
.status-card { border-top: 4px solid var(--c); }
.status-card select { margin-bottom: 8px; font-weight: 600; }
.status-card input { margin-bottom: 8px; }
.notes { list-style: none; padding: 0; margin: 10px 0 0; }
.notes li { padding: 8px 10px; border-left: 3px solid var(--border); margin-bottom: 8px; background: #fafafa; border-radius: 0 6px 6px 0; }
.notes li.imp { border-left-color: var(--bad); background: #fef3f2; }
.note-form textarea { margin-bottom: 6px; }
.note-actions { display: flex; justify-content: space-between; align-items: center; }
.log, .mini-list { list-style: none; padding: 0; margin: 0; }
.log li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f2f4f7; font-size: 13px; }
.log .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; }
.mini-list li { padding: 5px 0; border-bottom: 1px solid #f2f4f7; }
.side-col .card div + div { margin-top: 3px; }

dialog.dlg { border: 0; border-radius: 14px; padding: 24px 26px; box-shadow: 0 24px 60px rgba(0,0,0,.25); max-width: 560px; width: 92%; }
dialog.dlg::backdrop { background: rgba(15,23,42,.45); }
.dlg h2 { font-size: 19px; display: flex; gap: 8px; align-items: center; color: var(--ok); }
.dlg-actions { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; align-items: flex-start; }
.dlg-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 12px; }

/* --- pulpit --- */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; color: var(--text); box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; border-color: var(--primary); }
.tile .ic { grid-row: span 2; color: var(--primary); align-self: center; }
.tile b { font-size: 26px; line-height: 1.1; }
.tile span { color: var(--muted); font-size: 12.5px; }
.tile.ok .ic { color: var(--ok); } .tile.warn .ic { color: var(--warn); } .tile.bad .ic { color: var(--bad); }

/* --- konfiguracja --- */
.tabs, .subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tabs a, .subtabs a { display: inline-flex; gap: 6px; align-items: center; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on, .subtabs a.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.subtabs { border-bottom: 0; }
.subtabs a { border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; margin: 0; }
.subtabs a.on { background: var(--primary-l); border-color: var(--primary); }
.tbl.dict td { padding: 5px 6px; }
.tbl.dict tr.new-row td { background: #f6fef9; }
.logo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo-prev { max-height: 60px; max-width: 220px; border: 1px solid var(--border); border-radius: 6px; padding: 4px; background: #fff; }
.tags dt { font-weight: 700; font-size: 12.5px; margin-top: 8px; }
.tags dd { margin: 2px 0 0; font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #344054; word-spacing: 6px; }
code { background: #f2f4f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.tpl-cols .side-card { width: 360px; }

/* --- logowanie / instalacja --- */
body.auth { display: grid; place-items: center; background: var(--side); }
.auth-card { background: #fff; padding: 30px; border-radius: 14px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card.wide { width: 560px; }
.auth-card h1 { margin-bottom: 16px; }
.auth-card label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
.auth-card label input { margin-top: 4px; }
.auth-brand { display: flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 700; font-size: 17px; margin-bottom: 18px; }

/* --- responsywność (telefon do zdjęć, tablet) --- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .cols { flex-direction: column; }
  .side-card, .side-col { width: 100%; }
  .counters .cnt span { display: none; }
}
@media (max-width: 760px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; }
  .side nav, .side-bottom { flex-direction: row; padding: 6px; border: 0; margin: 0; }
  .brand span, .side a span { display: none; }
  .top { flex-wrap: wrap; position: static; }
  .counters { margin: 0; overflow-x: auto; }
  .intake-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .row2, .row3, .row4 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .kv-grid { grid-template-columns: 1fr; gap: 2px; }
  .kv-grid .v { margin-bottom: 8px; }
  .content { padding: 14px; }
}
.repairs-tbl td:nth-child(3), .repairs-tbl td:nth-child(4) { min-width: 150px; }
.repairs-tbl td.clip { min-width: 200px; }

.brand-logo { display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 8px; padding: 6px 10px; width: 100%; height: 52px; }
.brand-logo img { max-height: 40px; max-width: 100%; display: block; }
.auth-brand .brand-logo { height: 76px; border: 1px solid var(--border); justify-content: flex-start; padding: 8px 12px; }
.auth-brand .brand-logo img { max-height: 58px; }
@media (max-width: 760px) { .brand-logo { width: 90px; height: 36px; padding: 3px 6px; } .brand-logo img { max-height: 28px; } }
.danger-zone { border-color: #fecdca; }
.danger-zone summary { color: var(--bad); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #b42318; }
.block-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f2f4f7; margin: 0; width: 100%; }
.block-row input { margin-top: 4px; }
.steps { padding-left: 20px; margin: 0 0 14px; }
.steps li { margin-bottom: 6px; }
code.copy { cursor: copy; display: inline-block; margin-top: 4px; padding: 4px 8px; user-select: all; }
