:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #647084;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  /* yellowSPORT — akcent marki */
  --accent: #f2c200;
  --accent-dark: #d4a800;
  --accent-ink: #1a1a1a;
  /* Ciemna, granatowa powłoka (topbar + sidebar) — motyw jak w skanerze */
  --shell: #0e1729;
  --shell-2: #16223c;
  --shell-line: #24324e;
  --shell-ink: #c7d2e4;
  --shell-muted: #8ba0c2;
  --topbar: #0e1729;
  /* Złoty gradient chipów ikon */
  --gold-a: #ffd451;
  --gold-b: #e0a800;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  /* Barwy grup funkcjonalnych launchera (pulpit) */
  --g-recv: #2563eb;
  --g-stock: #0891b2;
  --g-issue: #ea580c;
  --g-ops: #7c3aed;
  --g-report: #4f46e5;
  --g-admin: #475569;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Ikony SVG (sprite, styl liniowy).
   fill/stroke ustawione tu, bo są dziedziczone i wchodzą do shadow-DOM <use>,
   dzięki czemu ikony renderują się jako ostre linie, a nie wypełnione plamy. */
svg.ic {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  vertical-align: -0.18em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--topbar);
  color: #fff;
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 3px solid var(--accent);
}
.topbar .brand { color: #fff; font-weight: 800; font-size: 18px; letter-spacing: .01em; }
.topbar .brand .ys { color: var(--accent); }
.brand-sub { opacity: .55; font-weight: 600; font-size: 14px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { color: #cbd5e1; font-size: 13px; }
.menu-toggle {
  display: none;
  background: none; border: none; color: #fff; cursor: pointer;
  padding: 4px; line-height: 0;
}
.menu-toggle svg.ic { width: 26px; height: 26px; }
.inline { display: inline; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar {
  width: 224px;
  background: var(--shell);
  border-right: 1px solid var(--shell-line);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--shell-ink);
  font-weight: 500;
}
.sidebar a svg.ic { color: var(--shell-muted); transition: color .12s ease; }
.sidebar a:hover {
  background: rgba(242, 194, 0, .12);
  color: #fff;
  text-decoration: none;
}
.sidebar a:hover svg.ic { color: var(--accent); }
.content { flex: 1; padding: 22px; max-width: 1100px; }

/* Cards & grids */
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 18px; margin: 24px 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.card .kpi { font-size: 30px; font-weight: 700; }
.card .kpi-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--card); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .02em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-DO_ULOZENIA { background: var(--warn-bg); color: var(--warn); }
.badge-ZMAGAZYNOWANY { background: var(--ok-bg); color: var(--ok); }
.badge-PUSTY { background: #e2e8f0; color: #475569; }
.badge-PICKING { background: #dbeafe; color: #1d4ed8; }
.badge-ZAPAS { background: #f1f5f9; color: #475569; }
.badge-OTWARTY { background: var(--warn-bg); color: var(--warn); }
.badge-ZREALIZOWANY { background: var(--ok-bg); color: var(--ok); }
.badge-ZAMKNIETY { background: var(--ok-bg); color: var(--ok); }
.badge-SPAKOWANY { background: #dbeafe; color: #1d4ed8; }
.badge-WYSLANY { background: #ede9fe; color: #6d28d9; }
.badge-ADMIN { background: #fee2e2; color: #b91c1c; }
.badge-OPERATOR { background: #dbeafe; color: #1d4ed8; }
.badge-VIEWER { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn svg.ic { width: 17px; height: 17px; vertical-align: middle; }
.btn:hover { background: var(--accent-dark); color: var(--accent-ink); text-decoration: none; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger { background: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

/* Forms */
form .field { margin-bottom: 14px; }
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 14px; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
}
.helptext { color: var(--muted); font-size: 12px; margin-top: 4px; }
.errorlist { color: var(--err); list-style: none; padding: 0; margin: 4px 0; font-size: 13px; }
ul.radio { list-style: none; padding: 0; margin: 0; }
ul.radio li { margin-bottom: 4px; }
ul.radio label { display: inline; font-weight: 500; }
.form-narrow { max-width: 560px; }

/* Messages */
.messages { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 11px 14px; border-radius: 8px; font-size: 14px; }
.msg-success { background: var(--ok-bg); color: var(--ok); }
.msg-error, .msg-danger { background: var(--err-bg); color: var(--err); }
.msg-warning { background: var(--warn-bg); color: var(--warn); }
.msg-info { background: #e0f2fe; color: #075985; }

.muted { color: var(--muted); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f172a; padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 32px; width: 100%; max-width: 380px; }
.login-card h1 { text-align: center; }

/* Launcher (pulpit) — kafle pogrupowane funkcjonalnie, inspiracja LFS */
.cards .card { position: relative; overflow: hidden; }
.cards .card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent);
}
.cards .card.alert::before { background: var(--warn); }
.cards .card.alert .kpi { color: var(--warn); }

.section-title { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 14px; }

.groups { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px 24px; }
.group { display: flex; flex-direction: column; gap: 10px; }
.group-head {
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.group-head::before {
  content: ""; width: 10px; height: 10px; border-radius: 3px;
  background: linear-gradient(145deg, var(--gold-a), var(--gold-b));
}
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.tile {
  position: relative;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 108px; padding: 14px 13px;
  border-radius: 14px; text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px -14px rgba(16, 24, 40, .45);
  border-color: #e0c766;
  text-decoration: none;
}
.tile:focus-visible { outline: 3px solid rgba(242, 194, 0, .55); outline-offset: 2px; }
.tile-ic {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
  color: #1c1400;
  background: linear-gradient(150deg, var(--gold-a), var(--gold-b));
  box-shadow: 0 2px 5px -2px rgba(84, 63, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.tile-ic svg.ic { width: 24px; height: 24px; stroke-width: 2.1; }
.tile-code {
  position: absolute; top: 12px; right: 13px;
  font-size: 11px; font-weight: 800; color: var(--muted); opacity: .7; font-variant-numeric: tabular-nums;
}
.tile-lab { font-size: 13px; font-weight: 600; line-height: 1.25; margin-top: auto; }

@media (max-width: 900px) { .groups { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

/* Responsive */
@media (max-width: 820px) {
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed;
    left: -240px;
    top: 52px;
    bottom: 0;
    transition: left .2s ease;
    z-index: 30;
  }
  body.nav-open .sidebar { left: 0; }
  .content { padding: 16px; }
  .btn, .sidebar a { min-height: 44px; }
}
