/* Rejestr licencji — pasek z zakładkami, widoki jako tabele-rejestry. */
:root {
  --bg: #F3F5F4; --surface: #FFFFFF; --sunk: #E9EEEC; --line: #D5DDDA; --line-soft: #E6ECEA;
  --ink: #14211E; --muted: #55635F; --faint: #7D8A86;
  --accent: #0E6B63; --accent-ink: #FFFFFF; --accent-soft: #DDEFEC;
  --ok: #1D6B3E; --ok-bg: #DFF1E6; --warn: #8A5300; --warn-bg: #FBEFD7; --bad: #A12F21; --bad-bg: #FBE3DF;
  --off: #4E5A57; --off-bg: #E4E9E7; --shadow: 0 10px 40px rgba(20, 33, 30, .16);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1716; --surface: #16211F; --sunk: #1C2927; --line: #2C3B38; --line-soft: #233230;
    --ink: #E5EEEB; --muted: #A2B2AD; --faint: #7E8E89;
    --accent: #4FC2B5; --accent-ink: #062320; --accent-soft: #173A36;
    --ok: #7DD3A0; --ok-bg: #173428; --warn: #F2C26B; --warn-bg: #3A2D12; --bad: #F49A8C; --bad-bg: #3D1E19;
    --off: #B5C2BE; --off-bg: #26332F; --shadow: 0 10px 40px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1716; --surface: #16211F; --sunk: #1C2927; --line: #2C3B38; --line-soft: #233230;
  --ink: #E5EEEB; --muted: #A2B2AD; --faint: #7E8E89;
  --accent: #4FC2B5; --accent-ink: #062320; --accent-soft: #173A36;
  --ok: #7DD3A0; --ok-bg: #173428; --warn: #F2C26B; --warn-bg: #3A2D12; --bad: #F49A8C; --bad-bg: #3D1E19;
  --off: #B5C2BE; --off-bg: #26332F; --shadow: 0 10px 40px rgba(0, 0, 0, .5); color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-family: var(--f-display); text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 12px 20px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
nav.tabs { width: 100%; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer;
                  border-bottom: 3px solid transparent; white-space: nowrap; }
nav.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
nav.tabs .count { font-weight: 500; color: var(--faint); margin-left: 4px; }

main { max-width: 1240px; margin: 0 auto; padding-block: 20px 60px; padding-inline: 20px; display: flex; flex-direction: column; gap: 18px; }
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
       background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-family: var(--f-display); font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.kpi .s { color: var(--faint); font-size: 13px; }
.kpi.alert { border-color: var(--bad); background: var(--bad-bg); } .kpi.alert .v, .kpi.alert .l { color: var(--bad); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; flex-wrap: wrap; }
.panel-h h2 { font-size: 17px; font-weight: 700; margin-right: auto; }
.panel-b { padding: 0 16px 14px; }
.list-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.list-row .main { flex: 1; min-width: 0; }
.list-row .main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { color: var(--muted); font-size: 13px; }
.list-row .main > a.linkish { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 18px 0; }
.empty b { color: var(--ink); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .grow { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
input[type=search], .field input, .field select, .field textarea {
  width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--surface); }
input[type=search] { max-width: 280px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
     padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--sunk); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:hover td { background: var(--sunk); }
td.num, th.num { text-align: right; white-space: nowrap; }
td .sub { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--f-mono); font-size: 13px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.linkish { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; }
.linkish:hover { color: var(--accent); text-decoration: underline; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.off { background: var(--off-bg); color: var(--off); }
.pill.ex { background: var(--accent-soft); color: var(--accent); }
.bar { height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); }

.scrim { position: fixed; inset: 0; background: rgba(10, 18, 16, .35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); z-index: 21; box-shadow: var(--shadow);
          display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.drawer-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { font-size: 19px; margin-right: auto; }
.drawer-b { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.drawer-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field textarea { min-height: 76px; resize: vertical; }
.field.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.field.check input { width: 18px; min-height: 18px; }
.hint { font-weight: 400; color: var(--faint); font-size: 12px; }
.err { color: var(--bad); font-size: 13px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.confirm { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg);
         padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 30; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.banner { background: var(--accent-soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner p { margin: 0; flex: 1; min-width: 220px; }

@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .form { grid-template-columns: 1fr; } .kpi .v { font-size: 22px; } .brand span { display: none; } }
@media (prefers-reduced-motion: no-preference) { .drawer { animation: slide .18s ease-out; } @keyframes slide { from { transform: translateX(24px); opacity: .6; } } }

body { margin: 0; }
.tabs a { display: inline-block; padding: 10px 14px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: var(--accent-ink); }
.chip { text-decoration: none; display: inline-block; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.msg { border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.msg.success { background: var(--ok-bg); color: var(--ok); } .msg.error { background: var(--bad-bg); color: var(--bad); }
.formcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; max-width: 820px; }
.field ul.errorlist { margin: 0; padding: 0; list-style: none; color: var(--bad); font-weight: 600; }
.field input[type=checkbox] { width: 18px; min-height: 18px; }
.login { max-width: 400px; margin: 10vh auto 0; }
.user { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.user form { margin: 0; }
.inline { display: inline; margin: 0; }
details.danger summary { cursor: pointer; color: var(--bad); font-weight: 600; }
.secret { font-family: var(--f-mono); font-size: 18px; letter-spacing: .08em; background: var(--sunk); padding: 10px 12px; border-radius: 8px; overflow-wrap: anywhere; }
#qr { background: #fff; padding: 10px; border-radius: 8px; display: inline-block; }

/* Zlecenia: etapy, tablica, historia */
.stage { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--off-bg); color: var(--off); }
.stage.new { background: #E3ECF8; color: #24518C; } .stage.work { background: var(--accent-soft); color: var(--accent); }
.stage.warn { background: var(--warn-bg); color: var(--warn); } .stage.ok { background: var(--ok-bg); color: var(--ok); }
.stage.done { background: var(--ink); color: var(--bg); } .stage.bad { background: var(--bad-bg); color: var(--bad); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; }
.dot.new { background: #3B73BF; } .dot.work { background: var(--accent); } .dot.warn { background: #C98A1A; } .dot.ok { background: var(--ok); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stage.new { background: #1B2B44; color: #9DC0F0; } }
:root[data-theme="dark"] .stage.new { background: #1B2B44; color: #9DC0F0; }

.board { display: grid; grid-template-columns: repeat(6, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board-col { background: var(--sunk); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.board-col header { display: flex; align-items: center; gap: 8px; }
.board-col h2 { font-size: 14px; font-weight: 700; flex: 1; }
.board-col .count { color: var(--muted); font-size: 13px; font-weight: 600; }
.col-sum { color: var(--muted); font-size: 13px; margin-top: -4px; }
.card { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
        text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--accent); }
.card b { font-size: 14px; line-height: 1.3; }
.card .sub { color: var(--muted); font-size: 13px; }
.card .val { font-weight: 700; font-size: 13px; }
.card .step { font-size: 12px; color: var(--muted); }
.card .step.bad { color: var(--bad); font-weight: 700; } .card .step.warn { color: var(--warn); font-weight: 600; }
.empty.small { padding: 6px 2px; font-size: 13px; }
@media (max-width: 900px) { .board { grid-template-columns: repeat(6, minmax(230px, 80vw)); scroll-snap-type: x mandatory; } .board-col { scroll-snap-align: start; } }

.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; overflow-x: auto; counter-reset: st; }
.stepper li { flex: 1; min-width: 110px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px 6px; border-top: 4px solid var(--line); counter-increment: st; }
.stepper li::before { content: counter(st) ". "; }
.stepper li.now { color: var(--ink); border-top-color: var(--accent); }
.note { border-top: 1px solid var(--line-soft); padding: 10px 0; }
.note .when { color: var(--faint); font-size: 12px; }
.note.is-stage .what { color: var(--accent); font-weight: 600; }
.field select { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--surface); }
.field input[type=text] { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--surface); }
.stepper li.past { border-top-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--ink); }

/* Pliki firmowe */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 17px; min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 600; } .crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs span { color: var(--faint); } .crumbs b { color: var(--ink); overflow-wrap: anywhere; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 14px 18px; background: var(--surface); transition: background .15s, border-color .15s; }
.dropzone p { margin: 0; } .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { opacity: .7; pointer-events: none; } .dropzone .sending { font-weight: 700; color: var(--accent); margin-top: 6px; }
table.files td { vertical-align: middle; padding-block: 8px; }
.fname { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; overflow-wrap: break-word; word-break: normal; min-width: 0; }
.fname:hover { color: var(--accent); text-decoration: underline; }
.ficon { flex: none; width: 34px; height: 26px; border-radius: 5px; background: var(--sunk); color: var(--muted); border: 1px solid var(--line);
         font: 700 9.5px/24px var(--f-mono); text-transform: uppercase; text-align: center; letter-spacing: .02em; overflow: hidden; }
.ficon.dir { border: 0; background: var(--amber, #E4A73E); clip-path: polygon(0 12%, 38% 12%, 46% 0, 100% 0, 100% 100%, 0 100%); }
.ficon.up { border: 0; background: none; font: 700 16px/26px var(--f-body); }
details.pop { position: relative; } details.pop > summary { list-style: none; } details.pop > summary::-webkit-details-marker { display: none; }
.pop-b { position: absolute; z-index: 10; top: calc(100% + 6px); right: 0; width: min(320px, 85vw); background: var(--surface); border: 1px solid var(--line);
         border-radius: 10px; box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.files-head { row-gap: 12px; }
@media (max-width: 700px) {
  table.files thead { display: none; }
  table.files tbody tr { display: block; border-bottom: 1px solid var(--line-soft); padding: 4px 0; }
  table.files td { display: block; border: 0; padding: 6px 12px; }
  table.files td:nth-child(2), table.files td:nth-child(3) { display: none; }
  table.files td:last-child { padding-top: 0; } table.files .row-actions { justify-content: flex-start; margin-left: 32px; }
  .fname { display: flex; } .dropzone .hint { display: block; } }


td.nowrap, .nowrap { white-space: nowrap; }
