:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-mute: #94a3b8;
  --line: #e2e8f0;
  --nav: #0b1220;
  --nav-soft: #1e293b;
  --accent: #f59e0b;
  --accent-dark: #b45309;
  --blue: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

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

.layout { display: flex; min-height: 100vh; }

/* --- nawigacja --- */
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--nav);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: .2px; }
.brand span { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 1px; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  margin-bottom: 2px;
  font-weight: 500;
}
.nav a:hover { background: var(--nav-soft); color: #fff; text-decoration: none; }
.nav a.active { background: var(--accent); color: #1c1917; }
.nav .sep { padding: 14px 12px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #475569; }
.nav .pill {
  background: var(--bad); color: #fff; border-radius: 999px;
  padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.nav a.active .pill { background: #1c1917; color: #fff; }
.sidebar footer { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: #64748b; }

/* --- treść --- */
.content { flex: 1; min-width: 0; }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; }
.topbar .sub { color: var(--ink-mute); font-size: 12px; margin-top: 2px; }
.wrap { padding: 22px 26px 60px; max-width: 1500px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.card > h2 {
  margin: 0; padding: 13px 18px; font-size: 14px; font-weight: 650;
  border-bottom: 1px solid var(--line); background: #fbfdff;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card .body { padding: 16px 18px; }
.card .body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid.c4 { grid-template-columns: repeat(2, 1fr); } .grid.c3, .grid.c2 { grid-template-columns: 1fr; } }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow); }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-mute); }
.stat .v { font-size: 26px; font-weight: 680; margin-top: 4px; letter-spacing: -.5px; }
.stat .d { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat.alert { border-color: #fecaca; background: #fff5f5; }
.stat.alert .v { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8fafc; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); font-weight: 650; position: sticky; top: 0; }
tbody tr:hover { background: #f8fbff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.table-scroll { overflow-x: auto; max-height: 72vh; overflow-y: auto; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 640; background: #e2e8f0; color: var(--ink-soft); white-space: nowrap;
}
.badge.ok { background: #dcfce7; color: #14532d; }
.badge.warn { background: #fef3c7; color: #78350f; }
.badge.bad { background: #fee2e2; color: #7f1d1d; }
.badge.info { background: #dbeafe; color: #1e3a8a; }
.badge.mute { background: #f1f5f9; color: #64748b; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13px; font-weight: 560; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1c1917; }
.btn.primary:hover { background: #fbbf24; }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.blue:hover { background: #1d4ed8; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--ink); max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; outline-offset: -1px; border-color: var(--blue); }
label.field { display: block; margin-bottom: 12px; }
label.field span.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
label.field .hint { display: block; font-size: 11.5px; color: var(--ink-mute); margin-top: 3px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fbfdff; }
.spacer { flex: 1; }

.flash { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 520; border: 1px solid; }
.flash.ok { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.flash.bad { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.flash.info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }

.muted { color: var(--ink-mute); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius); padding: 11px 14px; font-size: 13px; color: #78350f; }

/* --- deduplikacja --- */
.dup-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dup-side { border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; background: #fbfdff; }
.dup-side h4 { margin: 0 0 6px; font-size: 13px; }
.dup-side dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0 0; font-size: 12.5px; }
.dup-side dt { color: var(--ink-mute); }
.dup-side dd { margin: 0; font-weight: 550; }
.dup-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

dialog {
  border: none; border-radius: 12px; padding: 0; width: min(880px, 94vw);
  box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog header { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog header h3 { margin: 0; font-size: 15px; }
dialog .dbody { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }

/* --- sklep demo --- */
.shop-head { background: linear-gradient(115deg, #0b1220, #1e3a5f); color: #fff; padding: 26px; border-radius: var(--radius); margin-bottom: 18px; }
.shop-head h2 { margin: 0 0 6px; font-size: 22px; }
.shop-head p { margin: 0; color: #94a3b8; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.tile .thumb { height: 132px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tile .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tile .thumb .ph { color: #cbd5e1; font-size: 11px; text-align: center; padding: 10px; line-height: 1.35; }
.tile .t-body { padding: 11px 13px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.tile .t-name { font-weight: 600; font-size: 13px; line-height: 1.35; }
.tile .t-mfr { font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .4px; }
.tile .t-price { font-size: 18px; font-weight: 700; margin-top: auto; }
.tile .t-price small { font-size: 11px; font-weight: 500; color: var(--ink-mute); display: block; }
.tile .t-stock { font-size: 11.5px; }

.pager { display: flex; gap: 6px; align-items: center; padding: 12px 18px; flex-wrap: wrap; }
.pager a, .pager span { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; }
.pager span.cur { background: var(--accent); border-color: var(--accent); color: #1c1917; font-weight: 650; }

/* --- logowanie --- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(140deg, #0b1220, #1e3a5f); }
.login-box { background: #fff; padding: 30px; border-radius: 14px; width: 370px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-box h1 { margin: 0 0 4px; font-size: 20px; }
.login-box p.sub { margin: 0 0 20px; color: var(--ink-mute); font-size: 13px; }

.logbox { background: #0b1220; color: #cbd5e1; padding: 14px 16px; border-radius: var(--radius); font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 460px; overflow-y: auto; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.flags { display: flex; gap: 9px; flex-wrap: wrap; }
