:root {
  --bg: #E5E8EB;          /* szczotkowane aluminium */
  --surface: #FFFFFF;
  --surface-2: #F2F4F6;
  --line: #CBD1D7;
  --line-2: #E0E4E8;
  --ink: #18222B;
  --ink-2: #566471;
  --side: #121C26;        /* grafit */
  --side-2: #1B2937;
  --side-ink: #B9C4CE;
  --arc: #2447D6;         /* błękit łuku TIG */
  --arc-hover: #1B38AE;
  --arc-soft: #DDE4FB;
  --ok: #1B7352;   --ok-bg: #D8EEE2;
  --warn: #9A6200; --warn-bg: #F7E7C3;
  --bad: #B3302A;  --bad-bg: #F4D9D6;
  --radius: 6px;
  --font: Bahnschrift, "DIN Alternate", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; line-height: 1.2; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--arc); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--arc); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- przyciski ---- */
.btn { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; padding: .48rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: #fff; border-color: #A8B0B8; }
.btn.primary { background: var(--arc); border-color: var(--arc); color: #fff; }
.btn.primary:hover { background: var(--arc-hover); border-color: var(--arc-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.small { padding: .25rem .6rem; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }

/* ---- znaczniki ---- */
.chip { display: inline-block; padding: .08rem .55rem; border-radius: 99px; font-size: .82rem; font-weight: 500; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.arc { background: var(--arc-soft); color: var(--arc); }
.tag { display: inline-block; padding: 0 .4rem; border-radius: 4px; font-size: .8rem; line-height: 1.55; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); }
.tag.proc { background: var(--arc-soft); color: var(--arc); border-color: transparent; }
.tag.dim { opacity: .55; }
.norm { display: inline-block; font-size: .78rem; font-weight: 600; letter-spacing: .02em; padding: .05rem .5rem; border-radius: 4px; background: var(--arc-soft); color: var(--arc); }

/* ---- pasek ważności (ścieg) ---- */
.bead { --bead: var(--ok); position: relative; height: 10px; border-radius: 5px; overflow: hidden; background: #D2D7DC; box-shadow: inset 0 1px 2px rgba(24,34,43,.25); }
.bead.warn { --bead: #D18A0C; } .bead.bad { --bead: var(--bad); } .bead.arc { --bead: var(--arc); }
.bead .fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px; transform-origin: left center;
  background: radial-gradient(circle at 100% 50%, transparent 0 52%, rgba(255,255,255,.4) 54% 64%, transparent 66%) 0 0 / 10px 100%,
    linear-gradient(180deg, color-mix(in srgb, var(--bead) 70%, #fff), var(--bead) 45%, color-mix(in srgb, var(--bead) 75%, #000)); }

/* ---- logowanie ---- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-side { background: var(--side); color: #E7ECF0; padding: 3rem clamp(1.5rem, 5vw, 4rem); display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 32px 32px; }
.login-side .brand-row { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: 1.1rem; }
.login-side h1 { font-size: clamp(1.7rem, 3.4vw, 2.6rem); line-height: 1.15; max-width: 18ch; }
.login-side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; color: var(--side-ink); }
.login-side li b { display: inline-block; min-width: 6.2rem; color: #8FB0FF; font-weight: 600; }
.login-form-wrap { display: grid; place-items: center; padding: 2rem 1.25rem; background: #F6F7F8; }
.login-form { width: min(380px, 100%); display: grid; gap: 1rem; }
.login-form .sub { color: var(--ink-2); }
.mark { width: 30px; height: 30px; flex: none; }

/* ---- pola formularzy ---- */
.field { display: grid; gap: .3rem; align-content: start; min-width: 0; }
.field > label, .field > .lbl { font-weight: 500; font-size: .9rem; color: var(--ink-2); }
.field .hint { font-size: .82rem; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; padding: .5rem .65rem; border: 1px solid #A8B0B8; border-radius: var(--radius); background: #fff; }
.input:disabled { background: var(--surface-2); border-color: var(--line); color: var(--ink); opacity: 1; }
textarea.input { min-height: 84px; resize: vertical; }
.input.ocr { background: #FFF6DC; border-color: #D8A93A; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem; }
.checks label { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; background: #fff; font-size: .9rem; }
.checks label:has(input:checked) { background: var(--arc-soft); border-color: var(--arc); color: var(--arc); }
.checks input { accent-color: var(--arc); }
.checks.off label { cursor: default; }
.error { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); padding: .55rem .75rem; font-weight: 500; }
.note { background: var(--surface-2); border-radius: var(--radius); padding: .6rem .8rem; color: var(--ink-2); }

/* ---- układ aplikacji ---- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 1rem 1.05rem .8rem; display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 600; font-size: 1.05rem; }
.company { margin: 0 .7rem .6rem; padding: .55rem .7rem; border-radius: var(--radius); background: var(--side-2); }
.company b { display: block; color: #fff; font-weight: 600; line-height: 1.25; }
.company span { font-size: .8rem; color: var(--side-ink); }
.nav { padding: .3rem .6rem; display: grid; gap: 1px; align-content: start; flex: 1; overflow-y: auto; }
.nav .group { margin: .85rem .7rem .25rem; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: #7B8996; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .46rem .7rem; border-radius: var(--radius); color: var(--side-ink); text-decoration: none; border-left: 3px solid transparent; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--side-2); color: #fff; border-left-color: #5C7CFF; font-weight: 600; }
.nav .badge { min-width: 1.3rem; padding: 0 .35rem; border-radius: 99px; background: #C8372F; color: #fff; font-size: .75rem; font-weight: 600; text-align: center; line-height: 1.35rem; }
.who { padding: .8rem 1rem; border-top: 1px solid #263445; display: grid; gap: .5rem; }
.who .name { color: #fff; font-weight: 600; }
.who .role { font-size: .82rem; }
.who .row { display: flex; gap: .4rem; flex-wrap: wrap; }
.who .btn.ghost { color: var(--side-ink); padding-inline: .5rem; }
.who .btn.ghost:hover { background: var(--side-2); color: #fff; border-color: transparent; }
.main { padding: 1.6rem 2rem 3rem; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head .titles { display: grid; gap: .3rem; max-width: 62ch; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; padding: .7rem .8rem; border-bottom: 1px solid var(--line-2); }
.toolbar .input { width: auto; min-width: 240px; flex: 1 1 240px; max-width: 380px; }
.toolbar .count { margin-left: auto; color: var(--ink-2); font-size: .9rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: .38rem .75rem; cursor: pointer; font-size: .9rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--arc); color: #fff; }

/* ---- tabele ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .9rem; vertical-align: top; }
th { font-weight: 600; font-size: .8rem; color: var(--ink-2); border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--line-2); }
tbody tr:last-child { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #F7F9FF; }
td .sub { display: block; font-size: .84rem; color: var(--ink-2); }
td .line { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-bottom: .25rem; }
td .line:last-child { margin-bottom: 0; }
td.nowrap, .nowrap { white-space: nowrap; }
.empty { padding: 2.2rem 1.2rem; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); margin-bottom: .2rem; }
.due { display: grid; gap: .15rem; justify-items: start; }
.progress { min-width: 130px; display: grid; gap: .25rem; }
.progress small { color: var(--ink-2); font-size: .8rem; }

/* ---- pulpit ---- */
.counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.counter { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .85rem 1rem; display: flex; align-items: baseline; gap: .7rem; border-left: 5px solid var(--line); }
.counter b { font-size: 2rem; font-weight: 600; line-height: 1; }
.counter span { color: var(--ink-2); }
.counter.bad { border-left-color: var(--bad); } .counter.bad b { color: var(--bad); }
.counter.warn { border-left-color: #D18A0C; } .counter.warn b { color: var(--warn); }
.counter.arc { border-left-color: var(--arc); } .counter.arc b { color: var(--arc); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .7rem; margin-bottom: 1.3rem; }
.tile { display: grid; gap: .1rem; padding: .75rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); position: relative; }
.tile:hover { border-color: var(--arc); }
.tile b { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.tile .nm { font-weight: 500; }
.tile .sub { font-size: .8rem; color: var(--ink-2); }
.tile .badge { position: absolute; top: .6rem; right: .7rem; min-width: 1.3rem; padding: 0 .35rem; border-radius: 99px; background: #C8372F; color: #fff; font-size: .75rem; font-weight: 600; text-align: center; line-height: 1.3rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 0 0 .6rem; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert { display: grid; grid-template-columns: 108px minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.alert:last-child { border-bottom: 0; }
.alert:hover { background: #F7F9FF; }
.alert .days { font-weight: 600; }
.alert .days small { display: block; font-weight: 400; font-size: .8rem; color: var(--ink-2); }
.alert .days.warn { color: var(--warn); } .alert .days.bad { color: var(--bad); }
.alert .what { color: var(--ink-2); font-size: .88rem; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.3rem; }
.box { padding: 1rem; display: grid; gap: .8rem; align-content: start; }
.order-row { display: grid; gap: .3rem; }
.order-row .top { display: flex; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.bars { display: grid; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: 3rem minmax(0, 1fr) 2rem; gap: .6rem; align-items: center; }
.bar-row .track { height: 14px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; background: var(--arc); border-radius: 3px; }

/* ---- panel boczny ---- */
.overlay { position: fixed; inset: 0; background: rgba(18,28,38,.5); z-index: 40; display: flex; justify-content: flex-end; }
.overlay.nested { z-index: 45; }
.drawer { width: min(680px, 100vw); height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: -12px 0 36px rgba(0,0,0,.3); }
.drawer-head { padding: 1rem 1.3rem .5rem; display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.drawer-head .t { display: grid; gap: .3rem; min-width: 0; }
.drawer-head h2 { font-size: 1.25rem; overflow-wrap: anywhere; }
.drawer-head .x { flex: none; }
.tabs { display: flex; gap: .2rem; padding: 0 1.3rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: .6rem .8rem; cursor: pointer; color: var(--ink-2); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--arc); font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.1rem 1.3rem; display: grid; gap: 1rem; align-content: start; }
.drawer-foot { padding: .8rem 1.3rem; border-top: 1px solid var(--line); background: var(--surface-2); display: flex; gap: .6rem; }
.drawer-foot .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem 1rem; }
.form-grid .span2 { grid-column: 1 / -1; }
.ocr-strip { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .7rem .9rem; border-radius: var(--radius); background: #FFF3DA; border: 1px solid #E8C877; }
.ocr-strip .txt { flex: 1 1 220px; font-size: .9rem; color: #6B4A00; }
.ocr-strip .btn { border-color: #D8A93A; background: #fff; color: #6B4A00; }
.ocr-result { padding: .7rem .9rem; border-radius: var(--radius); background: var(--ok-bg); color: #14563C; display: grid; gap: .4rem; }
.ocr-result label { display: flex; align-items: center; gap: .5rem; }
.ocr-result details summary { cursor: pointer; }
.ocr-result pre { margin: .4rem 0 0; white-space: pre-wrap; max-height: 180px; overflow: auto; font: .8rem/1.4 var(--font); background: #fff; padding: .5rem; border-radius: 4px; color: var(--ink); }
.filelist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.filelist li { display: flex; align-items: center; gap: .8rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line-2); }
.filelist li:last-child { border-bottom: 0; }
.filelist .nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.filelist .nm small { display: block; color: var(--ink-2); }
.match-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.match { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: .7rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius); }
.match .mk { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--ok); }
.match.no .mk { background: var(--bad); }
.match .mk svg { width: 14px; height: 14px; }
.match .why { color: var(--bad); font-size: .9rem; }
.match .okmsg { color: var(--ok); font-size: .9rem; }

dialog { border: 0; padding: 0; border-radius: 10px; width: min(560px, calc(100vw - 2rem)); background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); max-height: calc(100vh - 2rem); }
dialog::backdrop { background: rgba(18,28,38,.55); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.dlg-head { padding: 1.1rem 1.4rem .6rem; }
.dlg-body { padding: .4rem 1.4rem 1rem; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: .85rem 1rem; }
.dlg-body .span2 { grid-column: 1 / -1; }
.dlg-foot { padding: .9rem 1.4rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; background: var(--surface-2); }
.dlg-foot .spacer { flex: 1; }
.dlg-msg { padding: .2rem 1.4rem 1.2rem; }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 80; max-width: min(420px, calc(100vw - 2.4rem)); }

@media (max-width: 960px) {
  .two { grid-template-columns: 1fr; }
  .counters { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; }
  .company:not(.has-menu) { display: none; }
  .company.has-menu { margin: 0 .7rem .5rem; }
  .company-menu { position: static; }
  .nav { display: flex; flex-wrap: wrap; padding: .4rem; max-height: 220px; }
  .nav .group { display: none; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; }
  .nav a[aria-current="page"] { border-bottom-color: #5C7CFF; }
  .who { flex-direction: row; align-items: center; justify-content: space-between; }
  .main { padding: 1.2rem 1rem 2.5rem; }
  .alert { grid-template-columns: 1fr; gap: .2rem; }
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 1.5rem 1.25rem; }
  .login-side ul { display: none; }
  .form-grid, .dlg-body { grid-template-columns: 1fr; }
  td, th { padding: .55rem .6rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .bead .fill { animation: grow .7s ease-out; }
  @keyframes grow { from { transform: scaleX(0); } }
  .drawer { animation: slide .18s ease-out; }
  @keyframes slide { from { transform: translateX(32px); opacity: .6; } }
}

/* ---- firmy: znak, przełącznik, lista ---- */
.cmark { display: inline-grid; place-items: center; flex: none; border-radius: 8px; background: #2A3A4D; color: #fff; font-weight: 700; font-size: .8rem; overflow: hidden; }
.cmark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.company { display: flex; align-items: center; gap: .6rem; position: relative; }
.company .cname { min-width: 0; display: grid; }
.company .cname b { overflow-wrap: anywhere; }
.company.has-menu { padding: 0; display: block; }
.company-btn { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; cursor: pointer; border-radius: var(--radius); }
.company-btn:hover { background: #1E2B3A; }
.company-btn:focus-visible { outline: 2px solid #8FA6FF; outline-offset: 1px; }
.company-btn .cname { flex: 1; min-width: 0; display: grid; }
.company-btn .cname b { color: #fff; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.company-btn .cname span { font-size: .78rem; color: var(--side-ink); }
.company .chev { color: var(--side-ink); font-size: .9rem; }
.company-menu { list-style: none; margin: .3rem 0 0; padding: .3rem; position: absolute; left: 0; right: 0; top: 100%; z-index: 40; background: #fff; color: var(--ink, #14202B); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-height: 60vh; overflow: auto; }
.company-menu[hidden] { display: none; }
.company-menu li > button { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: .55rem; padding: .45rem .5rem; border-radius: 7px; cursor: pointer; color: #14202B; }
.company-menu li > button:hover, .company-menu li > button:focus-visible { background: #EEF1F5; outline: none; }
.company-menu li[aria-selected="true"] > button { font-weight: 600; }
.company-menu .cmark { background: #DDE3EA; color: #2A3A4D; }
.company-menu .cur { margin-left: auto; color: #2447D6; }
.company-menu .sep { border-top: 1px solid #E1E6EC; margin-top: .25rem; padding-top: .25rem; }
.company-menu .sep a { display: block; padding: .45rem .5rem; color: #2447D6; text-decoration: none; font-size: .9rem; border-radius: 7px; }
.company-menu .sep a:hover { background: #EEF1F5; }
.company-list { display: grid; gap: .75rem; }
.company-card { display: flex; align-items: center; gap: 1rem; padding: .9rem 1rem; flex-wrap: wrap; }
.company-card.current { border-color: var(--arc); box-shadow: 0 0 0 1px var(--arc) inset; }
.company-card .cmark { background: #DDE3EA; color: #2A3A4D; font-size: 1.1rem; }
.company-card .info { display: grid; min-width: 180px; flex: 1; }
.company-card .acts { display: flex; gap: .4rem; flex-wrap: wrap; }
.company-card .btn.ghost { border-color: transparent; }
.company-menu span, .company-menu b { color: inherit; font-size: inherit; font-weight: inherit; display: inline; }
.company-menu .cmark span { display: inline; }
.company-menu .cur { color: #2447D6; }
.titles .norm { justify-self: start; width: fit-content; }
