:root {
    --accent: #6f4e37;
    --accent-dark: #5a3e2c;
    --muted: #8a8580;
    --border: #e4e0d8;
    --bg: #f0efec;
    --card-bg: #ffffff;
    --text: #2a2420;

    --sidebar-bg: #17161a;
    --sidebar-text: #a3a09c;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: #26242a;
    --sidebar-border: #2a282e;

    --status-new-bg: #dbeafe;     --status-new-text: #1d4ed8;
    --status-processing-bg: #fef3c7; --status-processing-text: #b45309;
    --status-shipped-bg: #ede9fe; --status-shipped-text: #6d28d9;
    --status-completed-bg: #dcfce7; --status-completed-text: #15803d;
    --status-cancelled-bg: #fee2e2; --status-cancelled-text: #b91c1c;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

/* ---------------------------------------------------------------------- */
/* Logowanie (bez sidebaru)                                               */
/* ---------------------------------------------------------------------- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
}

.login-wrap {
    width: 100%;
    max-width: 360px;
    margin: 0 16px;
    padding: 32px;
    border-radius: 10px;
    background: var(--card-bg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.login-wrap .login-logo {
    display: block;
    height: 34px;
    margin: 0 auto 28px;
}

.login-wrap label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 4px;
}

.login-wrap input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
}

.login-wrap button {
    width: 100%;
    padding: 10px 12px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}
.login-wrap button:hover { background: var(--accent-dark); }

.error {
    background: #fdecea;
    color: #b3261e;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 16px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(23, 22, 26, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-box {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 24px;
    width: 460px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.modal-box h2 { margin-top: 0; font-size: 16px; }
.modal-close {
    float: right;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
}
.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0 16px;
}
.section-hint {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 12px;
}

/* ---------------------------------------------------------------------- */
/* Layout aplikacji: sidebar + treść                                      */
/* ---------------------------------------------------------------------- */

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

.sidebar {
    width: 224px;
    flex: 0 0 224px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
}

.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo img {
    height: 26px;
    /* logo źródłowe jest czarne — odwracamy na biało pod ciemny sidebar */
    filter: brightness(0) invert(1);
}

.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
}
.sidebar-nav a:hover { color: var(--sidebar-text-hover); background: var(--sidebar-active-bg); }
.sidebar-nav a.active { color: var(--sidebar-text-hover); background: var(--sidebar-active-bg); }
.sidebar-nav a svg { flex: 0 0 auto; opacity: .85; }
.sidebar-nav .nav-section {
    padding: 16px 12px 6px;
    font-size: 10.5px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #5c5a60;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--sidebar-border);
    font-size: 12.5px;
    color: var(--sidebar-text);
}
.sidebar-footer a { color: var(--sidebar-text); }
.sidebar-footer a:hover { color: var(--sidebar-text-hover); }
.sidebar-footer .who { color: #fff; font-weight: 600; display: block; margin-bottom: 2px; }

.main {
    flex: 1;
    margin-left: 224px;
    min-width: 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 19px; margin: 0; }

.page-body { padding: 28px 32px; }

/* ---------------------------------------------------------------------- */
/* Karty                                                                   */
/* ---------------------------------------------------------------------- */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-row { display: flex; gap: 16px; }
.card-row .card { flex: 1; }

/* ---------------------------------------------------------------------- */
/* Przyciski                                                               */
/* ---------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.3;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover { background: #f7f2ee; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

/* ---------------------------------------------------------------------- */
/* Formularze                                                              */
/* ---------------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
    width: 100%; max-width: 360px; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: 4px; font-size: 14px;
    font-family: inherit; background: #fff; color: var(--text);
}
.field-row { display: flex; gap: 20px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------- */
/* Tabele (karta z tabelą w środku)                                       */
/* ---------------------------------------------------------------------- */

.table-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }

table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left; padding: 10px 14px; font-size: 11.5px; text-transform: uppercase;
    letter-spacing: .03em; color: var(--muted); background: #fafaf9;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fbfaf8; }
table.data .num { text-align: right; }
table.data .empty-row td { padding: 28px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------------- */
/* Toolbar listy (filtry + akcje)                                         */
/* ---------------------------------------------------------------------- */

.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar select {
    padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; background: #fff; color: var(--text);
}

/* ---------------------------------------------------------------------- */
/* Statusy — kolorowe plakietki                                           */
/* ---------------------------------------------------------------------- */

.status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-new { background: var(--status-new-bg); color: var(--status-new-text); }
.status-processing { background: var(--status-processing-bg); color: var(--status-processing-text); }
.status-shipped { background: var(--status-shipped-bg); color: var(--status-shipped-text); }
.status-completed { background: var(--status-completed-bg); color: var(--status-completed-text); }
.status-cancelled { background: var(--status-cancelled-bg); color: var(--status-cancelled-text); }

/* ---------------------------------------------------------------------- */
/* Plakietka kanału sprzedaży                                             */
/* ---------------------------------------------------------------------- */

.channel-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 7px;
    font-size: 10px; font-weight: 700; color: #fff; letter-spacing: -.02em;
}

/* ---------------------------------------------------------------------- */
/* Klient + tooltip                                                       */
/* ---------------------------------------------------------------------- */

.customer-cell { position: relative; display: inline-block; cursor: default; }
.customer-name { font-weight: 600; }
.customer-company { display: block; font-size: 12px; color: var(--muted); }

.customer-tooltip {
    display: none;
    position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
    min-width: 230px; background: #1f1e22; color: #fff;
    padding: 12px 14px; border-radius: 8px; font-size: 12.5px; line-height: 1.6;
    box-shadow: 0 12px 28px rgba(0,0,0,.28);
}
.customer-tooltip a { color: #fff; text-decoration: underline; }
.customer-cell:hover .customer-tooltip { display: block; }

/* ---------------------------------------------------------------------- */
/* Kolumna akcji — ikony                                                  */
/* ---------------------------------------------------------------------- */

.actions-cell { display: flex; align-items: center; gap: 4px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 6px;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.icon-btn[disabled], .icon-btn.is-disabled {
    opacity: .35; cursor: not-allowed; pointer-events: none;
}
.icon-btn.is-positive:hover { border-color: #15803d; color: #15803d; }

/* ---------------------------------------------------------------------- */
/* Checkbox                                                                */
/* ---------------------------------------------------------------------- */

.checkbox-cell { width: 36px; }
.checkbox-cell input, th.checkbox-cell input { width: 16px; height: 16px; }
