:root {
  --navy: #123a5a;
  --navy-dark: #0d2c45;
  --text: #1d1c1d;
  --muted: #616061;
  --border: #e2e2e2;
  --hover: #f6f8fa;
  --bg: #f4f6f8;
  --link: #1264a3;
  --green: #007a5a;
  --red: #e01e5a;
  --orange: #e8912d;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Lato, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Logowanie ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 12px; padding: 36px 32px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.auth-logo { width: 52px; height: 52px; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 900; font-size: 22px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.auth h1 { text-align: center; font-size: 26px; font-weight: 900; margin: 0 0 6px; }
.auth p.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 12px; }
.field input:not([type=checkbox]), .field textarea, .field select, .input {
  width: 100%; padding: 9px 11px; border: 1px solid #b9b9b9; border-radius: 6px; background: #fff; outline: none;
}
.input { width: auto; }
.field input:focus, .field textarea:focus, .field select:focus, .input:focus { border-color: var(--link); box-shadow: 0 0 0 3px rgba(29,155,209,.25); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; margin-bottom: 14px; }

.btn { border-radius: 6px; padding: 8px 14px; font-weight: 700; font-size: 14px; background: #fff; border: 1px solid #c8c8c8; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #148567; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-small { padding: 4px 9px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }
.error { color: var(--red); font-size: 14px; min-height: 18px; margin-bottom: 10px; }

/* ---------- Układ ---------- */
.topbar { height: 52px; background: var(--navy); color: #fff; display: flex; align-items: center; padding: 0 16px; gap: 20px; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 900; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo { background: #fff; color: var(--navy); border-radius: 6px; padding: 2px 6px; font-size: 13px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #d6e2ec; padding: 7px 12px; border-radius: 6px; font-weight: 700; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; }
.icon-btn { background: transparent; border: none; color: inherit; padding: 4px 8px; border-radius: 4px; font-size: 18px; }
.menu-btn { display: none; }
.me-btn { background: rgba(255,255,255,.15); color: #fff; border: none; border-radius: 16px; padding: 5px 12px; font-weight: 700; font-size: 14px; }
.main { max-width: 1400px; margin: 0 auto; padding: 20px 16px 60px; }
h2 { font-size: 22px; font-weight: 900; margin: 0 0 16px; }
h3 { font-size: 16px; font-weight: 900; margin: 20px 0 10px; }

.panel { background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab { border: 1px solid var(--border); background: #fff; border-radius: 16px; padding: 5px 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.tab .n { opacity: .75; margin-left: 4px; }

/* ---------- Tabele ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--hover); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-size: 14px; color: var(--muted); }
.items-text { max-width: 360px; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.badge { display: inline-block; border-radius: 10px; padding: 2px 9px; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; }
.chip { display: inline-block; border-radius: 4px; padding: 1px 6px; font-size: 12px; background: #eef2f5; color: #34495e; white-space: nowrap; }
.chip.ok { background: #e3f4ee; color: var(--green); }
.chip.warn { background: #fdf0e1; color: #a85d0b; }
.chip.err { background: #fde7ee; color: var(--red); }
.stock-low { color: var(--red); font-weight: 700; }

/* ---------- Szczegóły zamówienia (panel z prawej) ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; display: flex; justify-content: flex-end; }
.drawer { background: #fff; width: 100%; max-width: 620px; height: 100%; overflow-y: auto; padding: 20px 22px 40px; box-shadow: -4px 0 20px rgba(0,0,0,.15); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.drawer-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.box { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.box b { display: block; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; margin-bottom: 4px; }
.history { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.history li { padding: 6px 0; border-bottom: 1px solid #f0f0f0; }

/* ---------- Okna ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 520px; padding: 22px 24px; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- Integracje ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-weight: 900; font-size: 16px; }
.card .jobs { margin: 12px 0; font-size: 13px; }
.card .job { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid #f0f0f0; align-items: center; }
.card .job .err-text { color: var(--red); font-size: 12px; word-break: break-word; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #bbb; margin-right: 6px; }
.dot.on { background: var(--green); }
.dot.err { background: var(--red); }

.log-level-error td { background: #fff6f8; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d1c1d; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; font-size: 14px; max-width: 90vw; }

@media (max-width: 760px) {
  .topbar { gap: 10px; }
  .menu-btn { display: block; }
  .nav { display: none; position: absolute; top: 52px; left: 0; right: 0; background: var(--navy-dark); flex-direction: column; padding: 8px; }
  .nav.open { display: flex; }
  .brand { flex: 1; }
  .grid2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
}
