/* ------------------------------------------------------------------
   Synchronizacja hurtowni -> ShopGold
   Styl panelu. Mobile-first: układ jednokolumnowy od 320 px,
   tabele zwijane w karty, menu pod przyciskiem.
   ------------------------------------------------------------------ */

:root {
    --bg: #eef1f6;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --line: #dde3ec;
    --line-strong: #c6cfdd;
    --ink: #16212e;
    --ink-2: #4a5a6e;
    --ink-3: #7c8ca1;

    --primary: #1f6feb;
    --primary-ink: #ffffff;
    --primary-dark: #1557c0;
    --primary-soft: #e8f0fe;

    --danger: #c92a2a;
    --danger-soft: #fdeaea;
    --warning: #9a6700;
    --warning-soft: #fff6dd;
    --success: #1a7f45;
    --success-soft: #e6f6ec;
    --info-soft: #e9f1fb;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(22, 33, 46, .06), 0 4px 14px rgba(22, 33, 46, .06);
    --shadow-lg: 0 10px 40px rgba(22, 33, 46, .18);
    --sidebar: 248px;
    --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 var(--font);
    -webkit-text-size-adjust: 100%;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
code, kbd, pre { font-family: var(--mono); font-size: 13px; }

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

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #10243d;
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .08);
}

.topbar .brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 650;
    color: #fff;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
}

.topbar .brand > span { min-width: 0; overflow: hidden; }
.topbar .brand b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand small { color: #9fb6d1; font-weight: 400; font-size: 12px; display: none; }
.topbar .spacer { flex: 1 1 auto; }

.nav-toggle {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, .25);
    background: rgba(255, 255, 255, .08);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    flex: 0 0 auto;
}
.nav-toggle:hover { background: rgba(255, 255, 255, .16); }

/* Login chowamy na wąskich ekranach — na pasku liczy się nazwa i wylogowanie. */
.topbar .who { display: none; }
@media (min-width: 560px) {
    .topbar .who {
        display: block;
        font-size: 12px;
        color: #9fb6d1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 30vw;
    }
}

.shell { display: flex; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }

/* Na wąskim ekranie menu rozwija się nad treścią, na całą szerokość —
   nie zabiera miejsca treści i nie powoduje przewijania w poziomie. */
.sidebar {
    display: none;
    flex: 1 1 100%;
    width: 100%;
    background: #15304f;
    padding: 14px 10px 24px;
}
.sidebar.open { display: block; }

.side-group { margin-bottom: 16px; }
.side-group > span {
    display: block;
    padding: 0 10px 6px;
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #7f9cbd;
}

.sidebar a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: #d6e2f0;
    font-size: 14px;
}
.sidebar a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.sidebar a.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar a .pill {
    background: rgba(255, 255, 255, .16);
    border-radius: 20px;
    padding: 1px 7px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.sidebar a.active .pill { background: rgba(0, 0, 0, .22); }

.main { flex: 1 1 auto; min-width: 0; padding: 16px; }
.wrap { max-width: 1180px; margin: 0 auto; }
.stack > * + * { margin-top: 16px; }

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

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.page-header .ph-text { flex: 1 1 220px; min-width: 0; }
.page-header .ph-text p { color: var(--ink-2); font-size: 13px; margin: 3px 0 0; }
.page-header .ph-side { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px; }

/* ----------------------------------------------------------- karty */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card > header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}
.card > header h2 { font-size: 15px; }
.card > header p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-2); }
.card > .body { padding: 14px; }
.card > .body.tight { padding: 0; }
.card > footer {
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
}

.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid.g2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1020px) { .grid.g3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1020px) { .grid.g4 { grid-template-columns: repeat(4, 1fr); } }

/* ---------------------------------------------------------- kafelki */

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    min-width: 0;
}
.tile .k { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .s { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.tile.accent-ok .v { color: var(--success); }
.tile.accent-warn .v { color: var(--warning); }
.tile.accent-bad .v { color: var(--danger); }

/* -------------------------------------------------------- przyciski */

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font: inherit;
    font-size: 14px;
    font-weight: 560;
    line-height: 1.2;
    cursor: pointer;
    background: var(--primary);
    color: var(--primary-ink);
    flex-shrink: 0;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:focus-visible { outline: 2px solid #0b57d0; outline-offset: 2px; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: not-allowed; }

.btn.gray { background: #eef1f6; color: var(--ink); border-color: var(--line-strong); }
.btn.gray:hover { background: #e3e8f0; }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a81f1f; }
.btn.warning { background: #b8820b; }
.btn.warning:hover { background: #996c08; }
.btn.success { background: var(--success); }
.btn.success:hover { background: #156836; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.lg { padding: 12px 18px; font-size: 15px; }
.btn.block { width: 100%; }

.action-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.action-bar.end { justify-content: flex-end; }
.action-bar.between { justify-content: space-between; }
.action-bar form { display: inline-flex; flex-wrap: wrap; gap: 10px; margin: 0; }

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

.field { margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--ink);
}
.field .hint { font-size: 12.5px; color: var(--ink-2); margin-top: 5px; }
.field .hint code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }

input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], select, textarea {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    font: inherit;
    font-size: 14px;
    background: #fff;
    color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, .15);
}
input[readonly] { background: var(--surface-2); color: var(--ink-2); }
select { background-image: none; }

.row { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
    .row.c2 { grid-template-columns: 1fr 1fr; }
    .row.c3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
    .row.c4 { grid-template-columns: repeat(4, 1fr); }
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 14px;
    flex: 1 1 210px;
    min-width: 0;
    cursor: pointer;
}
.check input { width: 17px; height: 17px; margin: 1px 0 0; flex: 0 0 auto; }
.check span { min-width: 0; }
.check small { display: block; color: var(--ink-2); font-size: 12px; margin-top: 2px; }
.check-group { display: flex; flex-wrap: wrap; gap: 10px; }

fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin: 0 0 16px;
    min-width: 0;
}
legend { padding: 0 6px; font-size: 13px; font-weight: 650; color: var(--ink-2); }

/* ---------------------------------------------------------- tabele */

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.list th, table.list td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
table.list thead th {
    background: var(--surface-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-3);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
table.list tbody tr:hover { background: #fafcff; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list td.mid { vertical-align: middle; }
table.list .sub { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; }

/* Na wąskich ekranach każdy wiersz staje się kartą z etykietami. */
@media (max-width: 719px) {
    table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
    table.list thead { display: none; }
    table.list tbody tr {
        border: 1px solid var(--line);
        border-radius: var(--radius-sm);
        margin: 0 0 10px;
        padding: 4px 0;
        background: #fff;
    }
    table.list tbody tr:last-child { margin-bottom: 0; }
    table.list td {
        border: 0;
        display: flex;
        gap: 10px;
        justify-content: space-between;
        align-items: flex-start;
        padding: 6px 12px;
        text-align: right;
    }
    table.list td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        text-align: left;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--ink-3);
        font-weight: 600;
    }
    table.list td:not([data-label]) { text-align: left; }
    table.list td:not([data-label])::before { content: none; }
    table.list td.num { text-align: right; }
    table.list td.actions { justify-content: flex-end; flex-wrap: wrap; }
    .table-wrap { overflow-x: visible; }

    /* Kontrolki formularza w komórce: nie rozpychają wiersza, a gdy jest ich
       więcej niż jedna, układają się jedna pod drugą. */
    table.list td { flex-wrap: wrap; }
    table.list td > select,
    table.list td > input,
    table.list td > textarea {
        flex: 1 1 55%;
        min-width: 0;
        margin-top: 0;
    }
    table.list td > select + select,
    table.list td > input + input {
        margin-top: 6px;
    }
    table.list td > img.thumb { margin-left: auto; }
}

/* ----------------------------------------------------------- znaczki */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--ink-2);
    border: 1px solid var(--line);
}
.tag.ok { background: var(--success-soft); color: var(--success); border-color: #bfe4cd; }
.tag.warn { background: var(--warning-soft); color: var(--warning); border-color: #f0dca6; }
.tag.bad { background: var(--danger-soft); color: var(--danger); border-color: #f3c9c9; }
.tag.info { background: var(--info-soft); color: var(--primary-dark); border-color: #c6dcf8; }
.tag.mono { font-family: var(--mono); font-weight: 500; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: 0 0 auto; }
.dot.ok { background: #28a745; }
.dot.warn { background: #d99e00; }
.dot.bad { background: #d33; }

/* ------------------------------------------------------- komunikaty */

.note {
    border: 1px solid var(--line);
    border-left: 4px solid var(--ink-3);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    font-size: 13.5px;
    background: var(--surface-2);
    color: var(--ink);
}
.note + .note { margin-top: 10px; }
.note.info { border-left-color: var(--primary); background: var(--info-soft); }
.note.ok { border-left-color: var(--success); background: var(--success-soft); }
.note.warn { border-left-color: #d99e00; background: var(--warning-soft); }
.note.bad { border-left-color: var(--danger); background: var(--danger-soft); }
/* Tylko pogrubienie otwierające ramkę jest tytułem w osobnej linii —
   pogrubienia w środku zdania muszą zostać w wierszu. */
.note > b:first-child { display: block; margin-bottom: 3px; }
.note ol, .note ul { margin: 6px 0 0; padding-left: 20px; }
.note li + li { margin-top: 4px; }

/* ----------------------------------------------------------- toasty */

#toasts {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    pointer-events: none;
}
@media (min-width: 640px) {
    #toasts { left: auto; width: 360px; align-items: flex-end; }
}

.toast {
    pointer-events: auto;
    width: 100%;
    background: #10243d;
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: toast-in .18s ease-out;
}
.toast .tx { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.toast .tx b { display: block; font-size: 13px; }
.toast button {
    appearance: none;
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, .7);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
.toast.ok { background: #14532d; }
.toast.bad { background: #7f1d1d; }
.toast.warn { background: #78410b; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------- postęp */

.progress {
    height: 10px;
    background: #e3e8f0;
    border-radius: 20px;
    overflow: hidden;
}
.progress > i {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #2f80ed, #1f6feb);
    transition: width .25s ease;
}

.log {
    max-height: 340px;
    overflow: auto;
    background: #0f1d2d;
    color: #d8e3ef;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.55;
    word-break: break-word;
}
.log div + div { margin-top: 2px; }
.log .t { color: #6f8aa6; }
.log .warn { color: #f0c36d; }
.log .error { color: #ff9b9b; }

/* ------------------------------------------------------- pozostałe */

.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.break { word-break: break-all; }
.mt0 { margin-top: 0; }
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

.kv { display: grid; grid-template-columns: 1fr; gap: 2px 14px; font-size: 14px; }
@media (min-width: 560px) { .kv { grid-template-columns: max-content 1fr; } }
.kv dt { color: var(--ink-3); font-size: 12.5px; }
.kv dd { margin: 0 0 8px; min-width: 0; word-break: break-word; }
@media (min-width: 560px) { .kv dt { padding-top: 1px; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}
.toolbar .field { margin: 0; flex: 1 1 170px; min-width: 0; }
.toolbar .grow { flex: 2 1 240px; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.pager a, .pager span {
    display: inline-block;
    min-width: 34px;
    text-align: center;
    padding: 6px 9px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: #fff;
}
.pager span.cur { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.pager span.gap { border: 0; background: transparent; min-width: 0; }

.thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    flex: 0 0 auto;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px 14px;
    background: linear-gradient(160deg, #10243d, #1d4063 60%, #10243d);
}
.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 22px;
}
.login-box h1 { margin-bottom: 4px; }
.login-box p.sub { color: var(--ink-2); font-size: 13px; margin-bottom: 18px; }

/* Szerokie ekrany: menu boczne na stałe. */
@media (min-width: 1000px) {
    .nav-toggle { display: none; }
    .shell { flex-wrap: nowrap; }
    .sidebar {
        display: block;
        flex: 0 0 var(--sidebar);
        width: var(--sidebar);
    }
    .topbar .brand small { display: block; }
    .main { padding: 20px 24px 40px; }
}

@media print {
    .topbar, .sidebar, .action-bar, #toasts { display: none !important; }
    .card { break-inside: avoid; box-shadow: none; }
}
