/* ===== Magazyn - system projektowy ==========================================
   Paleta „papierowa” jak DN-1. Kolor niesie znaczenie i jedna rodzina = jedno
   znaczenie w całym panelu:
     niebieski  = zakup (towar wchodzi)      fiolet  = wydanie (towar wychodzi)
     czerwień   = brak / pod progiem / po terminie
     bursztyn   = zamówione, czeka / termin dziś
     zieleń     = zaksięgowane, OK
     morski     = interakcja (guziki, upuszczanie, fokus) - nigdy stan
   ========================================================================== */

[x-cloak] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --surface: #fffefb;
  --inset: #efece4;
  --ink: #24221d;
  --muted: #716b5d;
  --faint: #97917f;
  --line: #e5e1d5;
  --line-strong: #d3cdbd;

  --accent: #0d6b60;
  --accent-ink: #0a564d;
  --accent-soft: rgba(13, 107, 96, .10);
  --on-accent: #ffffff;

  --in: #2f64a0;
  --in-soft: rgba(47, 100, 160, .10);
  --out: #6d58b5;
  --out-soft: rgba(109, 88, 181, .11);
  --bad: #b23a30;
  --bad-soft: rgba(178, 58, 48, .10);
  --warn: #96650c;
  --warn-soft: rgba(150, 101, 12, .12);
  --ok: #2e7d43;
  --ok-soft: rgba(46, 125, 67, .10);

  --shadow: 0 1px 2px rgba(36, 34, 29, .05), 0 4px 14px rgba(36, 34, 29, .05);
  --shadow-lift: 0 10px 30px rgba(36, 34, 29, .16);
  --radius: 10px;
  --h: 32px; /* jedna wysokość kontrolek w każdym pasku */
}

.dark {
  color-scheme: dark;
  --bg: #15171b;
  --surface: #1d2025;
  --inset: #191b20;
  --ink: #e9e7e1;
  --muted: #a09a8c;
  --faint: #7a7568;
  --line: #2c3038;
  --line-strong: #3a3f49;

  --accent: #45b0a1;
  --accent-ink: #63c4b6;
  --accent-soft: rgba(69, 176, 161, .14);
  --on-accent: #0c1a18;

  --in: #6ea3d6;
  --in-soft: rgba(110, 163, 214, .14);
  --out: #a795e6;
  --out-soft: rgba(167, 149, 230, .14);
  --bad: #e2695f;
  --bad-soft: rgba(226, 105, 95, .14);
  --warn: #d8a13f;
  --warn-soft: rgba(216, 161, 63, .14);
  --ok: #5cb576;
  --ok-soft: rgba(92, 181, 118, .14);

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .2);
  --shadow-lift: 0 12px 32px rgba(0, 0, 0, .5);
}

/* --- baza ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
h1, h2, h3, h4, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
kbd {
  font: 11px/1 ui-monospace, monospace;
  color: var(--faint);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 2px 5px;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.r { text-align: right; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hint { color: var(--faint); font-size: 12.5px; }
.is-bad { color: var(--bad) !important; }

/* --- nagłówek ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__row {
  max-width: 1640px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand { display: flex; align-items: baseline; gap: 10px; flex: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand__mark {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: .02em;
  padding: 4px 10px;
  border-radius: 7px;
}
.brand__sub { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 2px; align-self: stretch; }
.tabs button {
  position: relative;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); }
.tabs button.on::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.cnt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--inset);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.cnt--bad { background: var(--bad); color: #fff; }

.topbar__meta { margin-left: auto; color: var(--faint); font-size: 12.5px; min-width: 0; white-space: nowrap; }
.topbar__meta.is-bad { color: var(--bad); font-weight: 600; }

.kto {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--h);
  padding: 0 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--faint);
  font-size: 12.5px;
  flex: none;
}
.kto input {
  width: 130px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  outline: none;
}
.kto.is-missing { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
/* Zalogowany z Google: imię zamiast pola „Kto” - podpisu nie da się wpisać ręcznie. */
.me { display: flex; align-items: center; gap: 10px; height: var(--h); flex: none; font-size: 13px; }
.me__name { font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ekran logowania (sso.py) - te same tokeny, jeden guzik. */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login__box {
  width: min(420px, 100%); display: grid; gap: 12px; justify-items: start; padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.login__box h1 { font-size: 20px; font-weight: 650; }
.login__btn { margin-top: 6px; }
.login__btn:hover { text-decoration: none; }
.login__err { color: var(--bad); font-weight: 600; }

/* Kopia pola w stopce okna: tło okna przykrywa pasek, a pierwszy zapis bez podpisu musi dać się dokończyć. */
.kto--inline input { width: 120px; }

.icon-btn {
  width: var(--h);
  height: var(--h);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
}
.icon-btn:hover:not(:disabled) { background: var(--inset); color: var(--ink); }

.banner {
  max-width: 1640px;
  margin: 12px auto 0;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
}
.banner--bad { background: var(--bad-soft); color: var(--bad); font-weight: 550; }

/* --- układ strony -------------------------------------------------------- */

.page { max-width: 1640px; margin: 0 auto; padding: 16px 24px 48px; }
.view--narrow { max-width: 1240px; margin: 0 auto; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar__flex { flex: 1 1 0; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 320px;
  min-width: 180px;
}
.search input {
  width: 100%;
  height: var(--h);
  padding: 0 34px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd, .search__x { position: absolute; right: 9px; }
.search__x { color: var(--faint); font-size: 12px; padding: 4px; }
.search__x:hover { color: var(--ink); }

.seg {
  display: inline-flex;
  height: var(--h);
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--inset);
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
}
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg button b { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--faint); }
.seg button.on b { color: var(--ink); }
.seg--full { display: flex; width: 100%; }
.seg--full button { flex: 1; justify-content: center; }

.kdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kdot--zakup { background: var(--in); }
.kdot--wydanie { background: var(--out); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--h);
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn--danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn--danger-ghost { color: var(--bad); border-color: transparent; background: transparent; }
.btn--danger-ghost:hover:not(:disabled) { background: var(--bad-soft); border-color: transparent; }
.btn-link { color: var(--accent-ink); font-weight: 600; font-size: 12.5px; }
.btn-link:hover:not(:disabled) { text-decoration: underline; }

/* --- tablica ------------------------------------------------------------- */

.board-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 20px;
  align-items: start;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}
.board__loading { grid-column: 1 / -1; color: var(--faint); padding: 40px; text-align: center; }

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 240px;
  max-height: calc(100vh - 150px);
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, background-color .15s;
}
.col.is-drop { border-color: var(--accent); background: var(--accent-soft); }

.col__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 11px 12px 7px;
  flex-wrap: wrap;
}
.col__name { font-weight: 650; font-size: 13.5px; }
.col__cnt { color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.col__hint { width: 100%; color: var(--faint); font-size: 11.5px; line-height: 1.3; min-height: 15px; }

.col__list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.col__empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px 10px;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
}
.board.is-dragging .col__empty { border-color: var(--accent); color: var(--accent-ink); }
.col__foot { padding: 7px 12px 10px; color: var(--faint); font-size: 11.5px; border-top: 1px solid var(--line); }

.slot { display: flex; flex-direction: column; gap: 8px; }
.drop-line { height: 3px; border-radius: 2px; background: var(--accent); margin: -2px 2px; }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 10px 8px 11px;
  box-shadow: var(--shadow);
  cursor: grab;
  user-select: none;
  transition: box-shadow .15s, transform .15s, opacity .15s;
}
.card:hover { box-shadow: var(--shadow-lift); }
.card:active { cursor: grabbing; }
.card--zakup { border-left-color: var(--in); }
.card--wydanie { border-left-color: var(--out); }
.card.is-dragged { opacity: .35; }
.card.is-flash { animation: flash 2.4s ease-out; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 3px var(--accent), var(--shadow-lift); }
  100% { box-shadow: var(--shadow); }
}

.card__top { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.kind { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.kind--zakup { color: var(--in); }
.kind--wydanie { color: var(--out); }
.card__id { color: var(--faint); font-size: 11.5px; }
.due {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 6px;
  border-radius: 5px;
  background: var(--inset);
  white-space: nowrap;
}
.due--warn { color: var(--warn); background: var(--warn-soft); }
.due--bad { color: var(--bad); background: var(--bad-soft); }

.card__title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.card__party { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card__lines { margin-top: 6px; display: grid; gap: 1px; font-size: 12.5px; }
.card__lines li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; color: var(--muted); }
.card__lines li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__lines li b { color: var(--ink); font-weight: 600; }
.card__more { color: var(--faint) !important; font-size: 11.5px; }

.card__foot { display: flex; align-items: center; gap: 6px; margin-top: 7px; min-height: 22px; }
.who {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--inset);
  border-radius: 5px;
  padding: 1px 6px;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flag { font-size: 11.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flag--ok { color: var(--ok); }
.flag--bad { color: var(--bad); }
.next {
  margin-left: auto;
  flex: none;
  width: 26px;
  height: 22px;
  border-radius: 6px;
  color: var(--faint);
  font-size: 17px;
  line-height: 1;
  border: 1px solid transparent;
}
.next:hover { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }

/* Ważność sprzętu: ▲ krytyczny (czerwień - bez tego stoi praca), ● ważny (bursztyn), standard bez znaku. */
.imp { font-size: 10px; margin-right: 5px; vertical-align: 1px; }
.imp--krytyczny { color: var(--bad); }
.imp--wazny { color: var(--warn); }
.imp-tag { font-size: 10.5px; font-weight: 700; padding: 0 5px; border-radius: 4px; white-space: nowrap; }
.imp-tag--krytyczny { color: var(--bad); background: var(--bad-soft); }
.imp-tag--wazny { color: var(--warn); background: var(--warn-soft); }
.card__sum { color: var(--muted) !important; font-size: 11.5px; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* --- boczna kolumna ------------------------------------------------------ */

/* Przyklejona do ekranu: długa lista towarów przewija się w sobie, żeby każdy dało się przeciągnąć na tablicę. */
.side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 12px; min-width: 0; max-height: calc(100vh - 88px); }
.side > .panel { flex: none; }
.side > .panel--wares { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel__title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; margin-bottom: 8px; }
.panel__empty { color: var(--faint); font-size: 12.5px; padding: 4px 0; }
.panel__empty--ok { color: var(--ok); }
.panel__hint { margin-left: auto; color: var(--faint); font-size: 11.5px; font-weight: 400; }
.in--side { flex: none; margin-bottom: 8px; }

/* Grupa = pudełko w kolorze stanu: czerwień pod progiem, bursztyn zamówione, zieleń OK, szare bez progu. */
.grps { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.grp { flex: none; border-left: 3px solid var(--line-strong); border-radius: 8px; background: var(--inset); padding: 0 9px; }
.grp--low { border-left-color: var(--bad); background: var(--bad-soft); }
.grp--ordered { border-left-color: var(--warn); background: var(--warn-soft); }
.grp--ok { border-left-color: var(--ok); background: var(--ok-soft); }
.grp__head { display: flex; align-items: center; gap: 6px; padding: 7px 0; font-size: 12.5px; font-weight: 650; color: var(--muted); cursor: pointer; list-style: none; user-select: none; }
.grp__head::-webkit-details-marker { display: none; }
.grp__head::before { content: "▸"; font-size: 10px; transition: transform .15s; }
.grp[open] > .grp__head::before { transform: rotate(90deg); }
.grp--low .grp__head { color: var(--bad); }
.grp--ordered .grp__head { color: var(--warn); }
.grp--ok .grp__head { color: var(--ok); }
.grp__cnt { font-weight: 600; opacity: .8; }

.ware {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  cursor: grab;
  user-select: none;
}
.ware:hover .ware__name { color: var(--accent-ink); }
.ware:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.ware.is-dragged { opacity: .35; }
.ware__main { flex: 1; min-width: 0; }
.ware__name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ware__nums { color: var(--muted); font-size: 12px; }
.grp--low .ware__nums b { color: var(--bad); }
.grp--ordered .ware__nums b { color: var(--warn); }

.tag {
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tag--warn { background: var(--warn-soft); color: var(--warn); }
.tag--warn:hover { box-shadow: inset 0 0 0 1px var(--warn); }

.slack { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.slack .btn-link { padding: 5px 4px; margin: -5px -4px; } /* cel dotyku >= 24 px */
.slack__txt { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.sdot--ok { background: var(--ok); }
.sdot--bad { background: var(--bad); }

/* --- zapasy -------------------------------------------------------------- */

.stock {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stock__row {
  display: grid;
  grid-template-columns: 150px minmax(160px, 1fr) 110px 70px 96px 96px 110px 124px;
  gap: 12px;
  align-items: center;
  padding: 0 14px 0 11px;
  min-height: 44px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.stock__row:hover { background: var(--inset); }
.stock__row--head {
  min-height: 36px;
  cursor: default;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--inset);
}
.stock__row--head:hover { background: var(--inset); }
.stock__item:last-child .stock__row { border-bottom: none; }
.stock__item.is-open .stock__row { background: var(--inset); }
.st--low { border-left-color: var(--bad); }
.st--ordered { border-left-color: var(--warn); }
.st--archived { opacity: .6; }
.sku { font: 12.5px ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock__qty b { font-size: 15px; font-weight: 700; }
.stock__qty small { color: var(--faint); font-size: 11.5px; }
.st--low .stock__qty b { color: var(--bad); }
.st--ordered .stock__qty b { color: var(--warn); }
.stock__empty { padding: 28px; text-align: center; color: var(--faint); }
.stock__name { display: grid; min-width: 0; line-height: 1.3; padding: 5px 0; }
.stock__name small { color: var(--faint); font-size: 11.5px; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 650;
  background: var(--inset);
  color: var(--muted);
  white-space: nowrap;
}
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--low { background: var(--bad-soft); color: var(--bad); }
.pill--ordered { background: var(--warn-soft); color: var(--warn); }

.stock__col { display: grid; gap: 12px; align-content: start; min-width: 0; }
.stock__detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  align-items: start;
  gap: 12px;
  padding: 12px 14px 16px;
  background: var(--inset);
  border-bottom: 1px solid var(--line);
}
.box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.box h4 { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.box__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; }
.box--log { max-height: 330px; overflow-y: auto; gap: 0; }
.box--log h4 { margin-bottom: 8px; }

.mrow {
  display: grid;
  grid-template-columns: 86px 50px minmax(0, 1fr) 54px 70px;
  gap: 8px;
  font-size: 12.5px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.mrow:last-child { border-bottom: none; }
.mrow__d { font-weight: 700; text-align: right; }
.mrow__d.is-in { color: var(--ok); }
.mrow__d.is-out { color: var(--out); }
.mrow--log { grid-template-columns: 86px 90px minmax(0, 1fr); }

/* --- formularze ---------------------------------------------------------- */

.fgrid {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 10px 14px;
  align-items: center;
}
.fgrid > label { text-align: right; color: var(--muted); font-size: 13px; font-weight: 550; align-self: start; padding-top: 6px; }
.fgrid--tight { grid-template-columns: 96px minmax(0, 1fr); gap: 8px 10px; }

.in {
  width: 100%;
  height: var(--h);
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  min-width: 0;
}
textarea.in { height: auto; padding: 7px 10px; resize: vertical; }
select.in { padding-right: 4px; }
.in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.in:disabled { background: var(--inset); color: var(--muted); }
.in--qty { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.in--short { width: 180px; }
.in--date { width: 170px; }
.in--cat { width: 240px; }
.in--pick { width: 200px; }
.in--money { width: 112px; text-align: right; font-variant-numeric: tabular-nums; }
.in--vat { width: 76px; }
.in--filter { width: auto; max-width: 220px; color: var(--muted); }
.in--filter.is-on { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }
textarea.in.is-missing { border-color: var(--warn); background: var(--warn-soft); }
.cat-add { margin-top: 6px; }

/* Przelicznik ceny: netto · VAT · brutto w jednym rzędzie, podpis nad polem. */
.price { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.price__cell { display: grid; gap: 2px; font-size: 11.5px; color: var(--faint); }
.price__cell .in { color: var(--ink); font-size: 14px; }
.in--status { width: 170px; }
.inline { display: flex; align-items: center; gap: 10px; min-width: 0; }

.lines { display: grid; gap: 6px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 96px 150px var(--h); gap: 8px; align-items: center; }
.line__info { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line__sub { grid-column: 1 / -1; margin-top: -3px; color: var(--faint); font-size: 12px; overflow-wrap: anywhere; }
.lines__sum { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lines__foot { display: flex; gap: 12px; align-items: center; min-height: 20px; }

/* --- modal --------------------------------------------------------------- */

.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 18, 14, .42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  overflow-y: auto;
  animation: fade .12s ease-out;
}
.modal {
  width: min(780px, 100%);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
  border: 1px solid var(--line);
  animation: rise .16s ease-out;
}
.modal--sm { width: min(560px, 100%); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.modal__head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.modal__head h2 { font-size: 16px; font-weight: 650; }
.modal__x { margin-left: auto; }
.modal__body { padding: 18px 20px 6px; }
.modal__foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; }
.modal__log { border-top: 1px solid var(--line); padding: 12px 20px 16px; max-height: 220px; overflow-y: auto; }
.modal__log h4 { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.cat-new { margin-bottom: 12px; }
.cats { display: grid; }
.cats__row { display: grid; grid-template-columns: minmax(0, 1fr) 64px auto auto; gap: 12px; align-items: center; min-height: 40px; border-bottom: 1px solid var(--line); }
.cats__row:last-of-type { border-bottom: none; }
.cats__name { font-weight: 600; }
.btn-link--bad { color: var(--bad); }
.confirm { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--bad); font-size: 13px; }

/* --- historia ------------------------------------------------------------ */

.hist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.hist__row {
  display: grid;
  grid-template-columns: 96px 130px 110px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  align-items: baseline;
}
.hist__row:last-child { border-bottom: none; }
.hist__by { font-weight: 600; }
.hist__ref { display: flex; gap: 8px; font-variant-numeric: tabular-nums; }
.hist__text { overflow-wrap: anywhere; }

/* --- powiadomienia ------------------------------------------------------- */

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 550;
  box-shadow: var(--shadow-lift);
  cursor: pointer;
  animation: rise .16s ease-out;
}
.toast--ok { background: var(--ok); color: #fff; }
.toast--bad { background: var(--bad); color: #fff; }

/* --- węższe ekrany ------------------------------------------------------- */

@media (max-width: 1200px) {
  .board-wrap { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; order: -1; display: grid; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; max-height: none; }
  .grps { max-height: 300px; }
  .stock__row { grid-template-columns: 130px minmax(140px, 1fr) 100px 60px 86px 86px 100px 124px; }
  .stock__detail { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  /* Zakładki schodzą do drugiego rzędu - w jednym na telefonie pole „Kto” wyjeżdżało za ekran. */
  .topbar__row { padding: 8px 16px 0; gap: 10px; height: auto; flex-wrap: wrap; }
  .tabs { order: 5; width: 100%; height: 40px; }
  .brand__sub, .topbar__meta { display: none; }
  .kto { margin-left: auto; }
  .kto input { width: 90px; }
  .me { margin-left: auto; }
  .me__name { max-width: 140px; }
  .page { padding: 12px 16px 40px; }
  .board { grid-template-columns: repeat(4, minmax(250px, 82vw)); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
  .col { scroll-snap-align: start; max-height: none; }
  .side { grid-template-columns: minmax(0, 1fr); }
  .search { flex: 1 1 100%; }
  .stock__row { grid-template-columns: minmax(0, 1fr) 90px 104px; }
  .stock__row > :nth-child(1), .stock__row > :nth-child(4), .stock__row > :nth-child(5), .stock__row > :nth-child(6), .stock__row > :nth-child(7) { display: none; }
  .stock__detail { grid-template-columns: minmax(0, 1fr); }
  .hist__row { grid-template-columns: 86px minmax(0, 1fr); }
  .hist__ref { grid-column: 2; }
  .hist__text { grid-column: 1 / -1; }
  .fgrid { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .fgrid > label { text-align: left; padding-top: 6px; }
  .line { grid-template-columns: minmax(0, 1fr) 80px var(--h); }
  .line__info { grid-column: 1 / -1; grid-row: 2; }
  .next { width: 34px; height: 30px; }
}

@media (max-width: 560px) {
  .tabs button { padding: 0 7px; }
  .kto > span { display: none; }
  .seg button { padding: 0 8px; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
}

/* Palcem nie przeciągniesz - na dotyku kartę zakłada stuknięcie w towar. */
@media (hover: none) { .panel__hint { display: none; } }

/* Powrót do wersji na telefon (/m) - tylko na dotyku, po wybraniu tam „Wersja komputerowa”. */
.to-m { display: none; font-size: 12.5px; font-weight: 600; padding: 6px 2px; }
@media (pointer: coarse) { .to-m { display: inline; } }
