/* MP1Hub – wygląd przeniesiony z poprzedniego MP1Hub/Invoicera: ciemny pasek boczny, logo na białej karcie,
   zielony akcent MP1 (#7a9a3b), kafelki. Kolory wyłącznie jako zmienne; ciemny motyw nadpisuje te same zmienne. */
:root {
  --ink: #2b2b2b;
  --ink-2: #555;
  --muted: #8a8f98;
  --line: #e3e6ea;
  --bg: #f3f4f6;
  --panel: #fff;
  --hover: #f7f8f9;
  --green: #7a9a3b;
  --green-dark: #5f7a2c;
  --green-soft: #eef3e3;
  --grey-soft: #eef0f2;
  --red: #c0392b;
  --red-soft: #fdecea;
  --note-bg: #fbfbe8;
  --note-line: #ecebc4;
  --err-bg: #fdf2f1;
  --err-line: #f2c4bf;
  --ok-bg: #f1f7e8;
  --ok-line: #cfe0b2;
  --amber: #a1661a;
  --amber-soft: #fff3e0;
  --yellow: #8a6d00;
  --yellow-soft: #fff4b8;
  --blue: #1a56b0;
  --blue-soft: #e8f0fe;
  --side-bg: #232526;
  --side-ink: #d7d9dc;
  --side-hover: #33373a;
  --side-line: #3a3e41;
  --radius: 10px;
  --font: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6e8eb;
    --ink-2: #b8bcc2;
    --muted: #8a8f98;
    --line: #30343a;
    --bg: #17191b;
    --panel: #1f2224;
    --hover: #262a2d;
    --green: #8bb045;
    --green-dark: #a6c766;
    --green-soft: #2a3320;
    --grey-soft: #2b2f33;
    --red: #e5675a;
    --red-soft: #3a2220;
    --note-bg: #2c2a1c;
    --note-line: #4a4627;
    --err-bg: #33201e;
    --err-line: #5c302b;
    --ok-bg: #243020;
    --ok-line: #3d5228;
    --amber: #e0a85a;
    --amber-soft: #3a2e1a;
    --yellow: #f0d24a;
    --yellow-soft: #3a3410;
    --blue: #8ab4f8;
    --blue-soft: #1e2a40;
    --side-bg: #111314;
    --side-hover: #24282b;
    --side-line: #2a2e31;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e6e8eb;
  --ink-2: #b8bcc2;
  --muted: #8a8f98;
  --line: #30343a;
  --bg: #17191b;
  --panel: #1f2224;
  --hover: #262a2d;
  --green: #8bb045;
  --green-dark: #a6c766;
  --green-soft: #2a3320;
  --grey-soft: #2b2f33;
  --red: #e5675a;
  --red-soft: #3a2220;
  --note-bg: #2c2a1c;
  --note-line: #4a4627;
  --err-bg: #33201e;
  --err-line: #5c302b;
  --ok-bg: #243020;
  --ok-line: #3d5228;
  --amber: #e0a85a;
  --amber-soft: #3a2e1a;
  --yellow: #f0d24a;
  --yellow-soft: #3a3410;
  --blue: #8ab4f8;
  --blue-soft: #1e2a40;
  --side-bg: #111314;
  --side-hover: #24282b;
  --side-line: #2a2e31;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--green-dark); }

/* Układ: pasek boczny 220 px + treść */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side-bg); color: var(--side-ink);
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto;
}
/* Logo zawsze na białej karcie – także w ciemnym motywie (znak ma ciemne litery). */
.sidebar .logo { display: block; background: #fff; border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.sidebar .logo img { width: 100%; height: auto; display: block; }
.sidebar .brand { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 0 0 16px 4px; }
.sidebar nav a, .sidebar .nav-item {
  display: block; padding: 9px 12px; border-radius: 8px; color: var(--side-ink);
  text-decoration: none; margin-bottom: 2px;
}
.sidebar nav a:hover { background: var(--side-hover); }
.sidebar nav a.active { background: var(--green); color: #fff; font-weight: 600; }
.sidebar .nav-item.off { color: #6f747b; }
.nav-group { margin: 14px 12px 4px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.sidebar .foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--side-line); display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: flex; border: 1px solid var(--side-line); border-radius: 8px; overflow: hidden; }
.seg a { padding: 5px 10px; min-width: 34px; text-align: center; color: var(--side-ink); text-decoration: none; font-size: 12px; }
.seg a:hover { background: var(--side-hover); }
.seg a.on { background: var(--green); color: #fff; font-weight: 600; }

.main { padding: 22px 26px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; }
.lead { color: var(--muted); margin: 0 0 18px; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 12px; font-weight: 700; }

/* Panele */
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.ok { color: var(--green-dark); font-weight: 600; }
.err { color: var(--red); font-weight: 600; }

/* Kafelki modułów (jak w poprzednim Hubie) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; color: var(--ink); text-decoration: none;
  display: flex; flex-direction: column; gap: 8px; min-height: 130px;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
a.tile:hover, .tile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); border-color: var(--green); }
.tile .icon { font-size: 28px; line-height: 1; }
.tile b { font-size: 16px; }
.tile .desc { color: var(--muted); font-size: 13px; }
.tile .meta { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.tile.off { border-style: dashed; }
.tile.off b, .tile.off .icon { opacity: .6; }

.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-weight: 600; }
.tag.grey { background: var(--grey-soft); color: var(--ink-2); }

/* Telefon: pasek z logo i ☰, menu boczne wysuwane */
.mobilebar, .scrim { display: none; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .mobilebar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20;
    height: 56px; padding: 0 16px; background: var(--side-bg);
  }
  .burger { color: var(--side-ink); font-size: 24px; cursor: pointer; line-height: 1; padding: 4px; }
  .mobile-logo { background: #fff; border-radius: 6px; padding: 4px 8px; display: block; }
  .mobile-logo img { height: 28px; display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px; height: auto; z-index: 30;
    transform: translateX(-100%); transition: transform .2s;
  }
  .nav-toggle:checked ~ .app .sidebar { transform: none; }
  .nav-toggle:checked ~ .app .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.4); }
  .main { padding: 16px 16px 48px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .tile { padding: 16px; min-height: 110px; }
}

/* ===== Formularze, tabele, przyciski (jak w MP1 Invoicer) ===== */
button, input, select, textarea { font: inherit; color: inherit; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.big { padding: 12px 20px; font-size: 16px; justify-content: center; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 12px; }
form.inline { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-actions { display: flex; gap: 8px; margin: 0 0 16px; }

.panel { margin-bottom: 16px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel h2 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 8px; }
.grid { display: grid; gap: 12px; margin-bottom: 4px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.field { margin-bottom: 8px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
.field input:not([type=checkbox]), .field select, .field textarea, .filters input, .filters select, td input:not([type=checkbox]), td select, .inline-form input, .dev-login input, .upload input[type=file] {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus { outline: 2px solid var(--green-soft); border-color: var(--green); }
.field textarea { min-height: 80px; resize: vertical; }
input.narrow { max-width: 80px; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin-right: 14px; cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 4px; padding: 4px 0 8px; }
.checks.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-bottom: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { flex: 1 1 260px; max-width: 520px; }
.filters select { width: auto; }
details.add { margin-top: 12px; }
details.add > summary { list-style: none; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { margin-bottom: 12px; }
.inline-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.upload { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px; border-bottom: 1px solid var(--line); font-weight: 600; }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tr[onclick] { cursor: pointer; }
table.list tbody tr:hover td { background: var(--hover); }
table.list a { color: var(--ink); text-decoration: none; }
table.list tr.inactive td { opacity: .5; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.thumb-col { width: 52px; }
.thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; background: var(--grey-soft); font-size: 20px; }

.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.note { font-size: 13px; color: var(--ink-2); background: var(--note-bg); border: 1px solid var(--note-line); padding: 8px 12px; border-radius: 7px; margin-bottom: 14px; }
.note.err { background: var(--err-bg); border-color: var(--err-line); color: var(--red); }
.note.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--green-dark); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.card form { margin-top: 8px; }
.card-head { margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.chip-x { border: 0; background: var(--grey-soft); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; color: var(--ink-2); font-size: 11px; }

.product-top { display: flex; gap: 16px; align-items: stretch; }
.product-top .grow { flex: 1; min-width: 0; }
.photo-box { width: 180px; flex-shrink: 0; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; overflow: hidden; font-size: 54px; }
.photo-box img { width: 100%; height: 100%; object-fit: contain; }
.photo-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-option { padding: 0; border: 2px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; width: 96px; height: 96px; overflow: hidden; }
.photo-option:hover { border-color: var(--green); }
.photo-option img { width: 100%; height: 100%; object-fit: contain; }

/* Pasek boczny: preferencje i użytkownik */
.sidebar .foot { flex-direction: column; align-items: stretch; }
.prefs-row { display: flex; gap: 8px; flex-wrap: wrap; }
.me { display: flex; gap: 8px; align-items: center; font-size: 12px; color: #b8bcc2; margin-top: 10px; }
.me img { width: 28px; height: 28px; border-radius: 50%; }
.me-name { font-weight: 600; color: var(--side-ink); overflow: hidden; text-overflow: ellipsis; max-width: 150px; white-space: nowrap; }

/* Kafelek modułu, który już ma ekran – klikalny */
a.tile { cursor: pointer; }
.tile.soon { cursor: default; }
.tile.soon:hover { transform: none; box-shadow: none; border-color: var(--line); }

/* Logowanie */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: min(420px, 100%); text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.auth-card h1 { margin: 14px 0 6px; font-size: 22px; }
.auth-logo { width: 170px; margin: 0 auto; background: #fff; border-radius: 10px; padding: 10px 14px; }
.auth-logo img { width: 100%; display: block; }
.auth-card .btn.big { width: 100%; margin-top: 10px; }
.dev-login { display: flex; gap: 6px; margin-top: 16px; }
.auth-prefs { margin-top: 18px; font-size: 12px; }
.auth-prefs a { color: var(--muted); }

@media (max-width: 1000px) {
  .grid.c4, .grid.c5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .grid.c2, .grid.c3, .grid.c4, .grid.c5 { grid-template-columns: 1fr; }
  .product-top { flex-direction: column; }
  .photo-box { width: 100%; height: 200px; }
  /* Tabele jako karty: każda komórka z etykietą kolumny */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.responsive td { border: 0; padding: 3px 0; text-align: left; }
  table.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
  table.responsive td.num { text-align: left; }
  table.responsive td.thumb-col { float: right; width: auto; }
  table.responsive td.row-actions { text-align: left; padding-top: 6px; }
  .filters input[type=search] { max-width: none; }
}
/* ===== Sprzedaż ===== */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--green); border-radius: 10px; padding: 10px 16px; text-decoration: none; color: var(--ink); min-width: 180px; }
.stat span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat b { font-size: 20px; }
.stat.red { border-top-color: var(--red); }
.err { color: var(--red); }
.docbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.issues { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.issues li { font-size: 13px; }
.issues li.err { color: var(--red); }
.checks-panel { border-left: 3px solid var(--amber); }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain[disabled] input, fieldset.plain[disabled] select, fieldset.plain[disabled] textarea { background: var(--grey-soft); }
.parties { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 8px 0 10px; font-size: 13px; }
.line { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 4px; margin-bottom: 10px; background: var(--panel); }
.line-main { display: grid; grid-template-columns: 3fr 1.1fr 1fr .9fr 1fr auto; gap: 10px; }
.line-pack { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.line-pack .field label { color: var(--muted); }
.line-pack input, .line-pack select { font-size: 12px; }
.line .field { margin-bottom: 6px; }
input.num { text-align: right; }
.add-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.add-line select { flex: 1 1 260px; max-width: min(520px, 100%); min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); }
.totals-row { margin-top: 14px; text-align: right; }
.totals-row .big { font-size: 20px; }
table.compact td, table.compact th { padding: 6px 8px; font-size: 13px; }
tr.sum td { font-weight: 700; border-top: 2px solid var(--ink); background: var(--hover); }
.savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 10px; margin-bottom: 16px; }
@media (max-width: 800px) {
  .line-main, .line-pack { grid-template-columns: 1fr 1fr; }
  .line-main .grow2 { grid-column: 1 / -1; }
  .docbar { flex-direction: column; align-items: stretch; }
}
/* ===== Zakładki modułu, magazyn, zakupy ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--green); }
.tag.lot-available { background: var(--green-soft); color: var(--green-dark); }
.tag.lot-quarantine { background: var(--amber-soft); color: var(--amber); }
.tag.lot-hold { background: var(--blue-soft); color: var(--blue); }
.tag.lot-expired { background: var(--red-soft); color: var(--red); }
.line-head { margin-bottom: 6px; }
.line-pack.rcv { grid-template-columns: 1.4fr 1fr 1fr .8fr 1fr; }
.line-main.po { grid-template-columns: 3fr 1fr .8fr .8fr 1fr auto; }
@media print {
  .sidebar, .mobilebar, .no-print, .actions, .tabs { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
}

/* ===== Import i przypomnienia ===== */
.timeline { display: flex; gap: 0; margin: 0 0 16px; overflow-x: auto; padding-bottom: 4px; }
.timeline .step { flex: 1 0 90px; text-align: center; font-size: 11px; color: var(--muted); position: relative; padding-top: 18px; }
.timeline .step span { position: absolute; top: 4px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--line); z-index: 1; }
.timeline .step::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 2px; background: var(--line); z-index: 0; }
.timeline .step.done span, .timeline .step.done::before { background: var(--green); }
.timeline .step.now { color: var(--ink); font-weight: 700; }
.timeline .step.now span { box-shadow: 0 0 0 4px var(--green-soft); }
.doccheck { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 3px; font-size: 13px; }
.doccheck li.missing { color: var(--muted); }
.events { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; font-size: 13px; }
.tag.imp-on_water, .tag.imp-loaded { background: var(--blue-soft); color: var(--blue); }
.tag.imp-at_port, .tag.imp-customs { background: var(--amber-soft); color: var(--amber); }
.tag.imp-cancelled { background: var(--grey-soft); color: var(--ink-2); }
.rem { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rem-date { min-width: 92px; font-variant-numeric: tabular-nums; font-size: 13px; }
.rem-title { flex: 1; color: var(--ink); text-decoration: none; min-width: 200px; }
.rem form { margin-left: auto; }
.copy input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--hover); color: var(--ink); }

.stats.dash .stat { flex: 1 1 170px; }
.panel h2 a.hint { float: right; text-transform: none; letter-spacing: 0; font-weight: 500; }

.report h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
.result { display: flex; justify-content: space-between; margin-top: 16px; padding: 12px 14px; border-left: 3px solid var(--green); background: var(--hover); font-size: 16px; }
.result.err { border-left-color: var(--red); }

.add-tile { gap: 6px; border-style: dashed; }
.add-tile select, .add-tile input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); }

pre.code { background: var(--hover); border: 1px solid var(--line); border-radius: 7px; padding: 10px; font-size: 12px; white-space: pre-wrap; }
pre.mailbody { white-space: pre-wrap; font-family: inherit; font-size: 14px; margin: 10px 0 0; }
tr.unread td { font-weight: 600; }

.filters input[type=date], .filters input[type=file], .filters input[type=email]:not([type=search]) { width: auto; flex: 0 1 auto; }
.filter-date { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; color: var(--muted); }
.list-count { margin: -6px 0 10px; }
.filter-toggle { display: none; }
@media (max-width: 800px) {
  .filters.collapsible > input[type=search] { flex: 1 1 60%; min-width: 0; }
  .filters.collapsible .filter-toggle { flex: 0 0 auto; }
  .filters.collapsible .filter-toggle { display: inline-flex; }
  .filters.collapsible:not(.open) > select, .filters.collapsible:not(.open) > label.filter-date, .filters.collapsible:not(.open) > label.checkbox { display: none; }
  .filters.collapsible.open > select { flex: 1 1 45%; }
}
.filters input[name=name], .filters input[name=tags], .filters input[name=note] { width: auto; flex: 1 1 160px; }
.filters input[name=email] { flex: 1 1 240px; max-width: 420px; }
.filters input[name=code] { width: 9em; flex: 0 0 auto; letter-spacing: 2px; }

/* Nic nie może rozpychać strony w bok (telefon/tablet): pola dopasowują się do kolumny,
   szeroka tabela przewija się wewnątrz panelu zamiast całej strony. */
input, select, textarea { max-width: 100%; min-width: 0; }
.filters select { min-width: 0; }
.main { min-width: 0; }
.panel:has(table.list) { overflow-x: auto; }

/* Wypełnienie kontenerów (plan zakupów, karta zamówienia) */
.fills { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.fill-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); }
.fill-row { display: grid; grid-template-columns: 70px 1fr 64px; gap: 8px; align-items: center; font-size: 12px; margin: 4px 0; }
.fill-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.fillbar { height: 8px; background: var(--grey-soft); border-radius: 4px; overflow: hidden; }
.fillbar i { display: block; height: 100%; background: var(--green); }
.fillbar i.over { background: var(--red); }

/* Długie napisy bez spacji (numery, linki, błędnie wpisane nazwy) zawijają się zamiast rozpychać stronę. */
.main { overflow-wrap: anywhere; }
.api-path { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); font-weight: 600; }
/* Skaner */
.scanbox { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 6px; }
.scanbox #code { flex: 1 1 240px; font-size: 20px; padding: 12px 14px; font-family: ui-monospace, Consolas, monospace; }
#video { width: 100%; max-height: 50vh; border-radius: 10px; background: #000; margin-bottom: 10px; }
#result .panel { margin-top: 10px; }
tr.hl td, tr.pick-done td { background: var(--ok-bg); }
tr.pick-over td { background: var(--err-bg); }
/* Role kontrahentów: klient – zielony, dostawca – żółty, pozostałe – szare */
.tag.role-customer { background: var(--green-soft); color: var(--green-dark); }
.tag.role-vendor { background: var(--yellow-soft); color: var(--yellow); }
.tag.role-forwarder, .tag.role-customs_broker, .tag.role-carrier, .tag.role-lab, .tag.role-vet, .tag.role-bank, .tag.role-other { background: var(--grey-soft); color: var(--ink-2); }
/* Teczka SKU (dokumenty produktu importowanego) */
.tag.green { background: var(--green-soft); color: var(--green-dark); }
a.tag { text-decoration: none; }
.dossier-issues { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 6px; }
.dossier-issues .note { margin: 0; }
table.dossier td { vertical-align: top; }
table.dossier tr.dossier-missing td:first-child, table.dossier tr.dossier-expired td:first-child { box-shadow: inset 3px 0 0 var(--red); }
table.dossier tr.dossier-expiring td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.dossier-file { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0; }
.dossier-actions { min-width: 150px; }
.dossier-actions details[open] { min-width: min(320px, 80vw); }
.dossier-actions form { margin-top: 8px; }
.dossier-actions details.also { margin: 6px 0; }
.dossier-actions details.also label { display: block; }
.scroll-x { overflow-x: auto; }
table.dossier-matrix { border-collapse: collapse; }
table.dossier-matrix th.rot { vertical-align: bottom; padding: 4px 2px; width: 34px; }
table.dossier-matrix th.rot span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 11px; }
table.dossier-matrix th.vendor span { color: var(--amber); }
table.dossier-matrix td.cell { text-align: center; font-weight: 700; padding: 6px 2px; }
table.dossier-matrix td.cell.ok { background: var(--green-soft); color: var(--green-dark); }
table.dossier-matrix td.cell.expiring { background: var(--amber-soft); color: var(--amber); }
table.dossier-matrix td.cell.missing, table.dossier-matrix td.cell.expired { background: var(--red-soft); color: var(--red); }
details.profile { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 8px 0; }
details.profile .checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 12px; margin: 6px 0 10px; }
.sku-docs .missing-list { display: flex; flex-wrap: wrap; gap: 4px; }
.sku-docs th, .sku-docs td.nowrap, .sku-docs td b { white-space: nowrap; }
.sku-docs td.missing-cell { min-width: 220px; }
/* Pasek „Sesja wygasła” (static/sesja.js) – przyklejony u góry, nad treścią i menu. */
.session-expired { position: sticky; top: 0; z-index: 100; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: center; padding: 10px 16px; background: var(--err-bg); border-bottom: 1px solid var(--err-line); color: var(--red); font-size: 14px; font-weight: 600; }
.session-expired[hidden] { display: none; }
