:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #647084;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --err: #b91c1c;
  --err-bg: #fee2e2;
}

* { 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; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 18px; }
.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; font-size: 22px; cursor: pointer;
}
.inline { display: inline; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar {
  width: 220px;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 500;
}
.sidebar a:hover { background: #eef2ff; text-decoration: none; }
.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); }

/* Buttons */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); 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; }

/* 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; }
}
