/* ═══════════════════════════════════════════════════════════════════════
   KOMPONENTY WSPÓŁDZIELNE — „Kontrola jakości”
   Nowa warstwa frontendu KaniewskiMagazyn.

   Zasady: jeden system elewacji (obrys + warstwy), jeden system promieni
   (koncentryczny), jeden akcent (kobalt) wydawany oszczędnie, cyfry
   tabelaryczne w danych, ruch cichy i przerywalny (transitions, nie
   keyframes dla interakcji).
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── RESET ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: var(--leading-normal);
    min-height: 100vh;
}

a { color: var(--text-link); }
button, input, select, textarea { font: inherit; color: inherit; }

img { max-width: 100%; height: auto; }

/* ─── UTILITIES ─────────────────────────────────────── */
.mono, .code {
    font-family: var(--font-mono);
    font-size: 0.92em;
    letter-spacing: -0.01em;
}
.tnum { font-variant-numeric: tabular-nums; }
.hide-mobile { }

:focus-visible {
    outline: 2px solid var(--accent-500);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ─── IKONA (SVG, currentColor) ────────────────────── */
.icon {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
    vertical-align: -0.22em;
}

/* ─── SHELL ─────────────────────────────────────────── */
.main-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}

.page-header {
    margin-bottom: var(--space-8);
}
.page-header h1 {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    letter-spacing: -0.01em;
    line-height: 1.2;
    text-wrap: balance;
}
.page-header p {
    margin-top: var(--space-1);
    color: var(--text-secondary);
    font-size: var(--text-base);
    text-wrap: pretty;
}

/* ─── SEKCJE ────────────────────────────────────────── */
.section { margin-bottom: var(--space-10); }
.section-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-4);
    letter-spacing: -0.01em;
}

/* ─── NAVBAR (jasny) ────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--ink-100);
    box-shadow: 0 1px 2px oklch(0 0 0 / 0.03);
}
.topbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    height: var(--navbar-height);
    padding: 0 var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: var(--ink-900);
    font-weight: var(--font-semibold);
    font-size: 1rem;
    letter-spacing: -0.01em;
    flex-shrink: 0;
}
.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--accent-500);
    color: var(--on-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.brand-mark .icon { width: 16px; height: 16px; }

.nav-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-width: 0;
}

.mainnav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}
.mainnav::-webkit-scrollbar { display: none; }

.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--ink-500);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: var(--font-medium);
    white-space: nowrap;
    border: none;
    background: none;
    cursor: pointer;
    transition-property: color, background-color;
    transition-duration: var(--t-fast);
    transition-timing-function: var(--ease-out);
}
.nav-link .icon { width: 18px; height: 18px; }
.nav-link:hover { color: var(--ink-900); background: var(--bg-surface-2); }
.nav-link.active {
    color: var(--accent-500);
}
.nav-link.active::after {
    content: "";
    position: absolute;
    left: var(--space-3);
    right: var(--space-3);
    bottom: 2px;
    height: 2px;
    border-radius: 1px;
    background: var(--accent-500);
}

/* Dropdown admina */
.nav-dropdown { position: relative; }
.nav-dropdown-arrow { width: 14px; height: 14px; transition: transform var(--t-fast) var(--ease-out); }
.nav-dropdown.open .nav-dropdown-arrow { transform: rotate(180deg); }

.nav-dropdown-menu {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    min-width: 230px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-raised);
    padding: var(--space-1);
    z-index: var(--z-dropdown);
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--ink-700);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: var(--font-normal);
}
.nav-dropdown-item .icon { width: 18px; height: 18px; color: var(--ink-400); }
.nav-dropdown-item:hover { background: var(--bg-surface-2); color: var(--ink-900); }

/* Nagłówek drawera (widoczny tylko w mobile) */
.nav-shell .drawer-head { display: none; }

/* Użytkownik */
.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}
.topbar-username {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.875rem;
    font-weight: var(--font-medium);
    color: var(--ink-700);
    max-width: 14rem;
}
.topbar-username > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-badge {
    font-size: 0.6875rem;
    font-weight: var(--font-semibold);
    letter-spacing: 0.04em;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    background: var(--accent-100);
    color: var(--accent-600);
    text-transform: uppercase;
}

/* Hamburger */
.hamburger {
    display: none;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--ink-900);
}
.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform var(--t-base) var(--ease-out), opacity var(--t-base) var(--ease-out);
}
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Backdrop mobilny */
.nav-backdrop {
    position: fixed;
    inset: 0;
    background: oklch(0.12 0.02 260 / 0.4);
    z-index: calc(var(--z-sticky) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base) var(--ease-out);
}
.nav-backdrop.show { opacity: 1; pointer-events: auto; }

/* ─── KARTY ─────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.card {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-border);
    overflow: hidden;
}
.card-header {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--ink-100);
}
.card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent-100);
    color: var(--accent-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}
.card-icon .icon { width: 22px; height: 22px; }
.card-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    letter-spacing: -0.01em;
}
.card-description {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-wrap: pretty;
}
.card-body {
    padding: var(--space-4) var(--space-5) var(--space-5);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* ─── KAFELEK MODUŁU (strona główna) ───────────────── */
.module-tile {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--bg-surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition-property: border-color, box-shadow, transform;
    transition-duration: var(--t-fast);
    transition-timing-function: var(--ease-out);
}
.module-tile:hover {
    border-color: var(--accent-500);
    box-shadow: var(--shadow-border);
}
.module-tile:active { transform: scale(0.99); }
.module-tile-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-2);
    color: var(--ink-700);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.module-tile-icon .icon { width: 22px; height: 22px; }
.module-tile-body { flex: 1; min-width: 0; }
.module-tile-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.module-tile-title .chevron {
    margin-left: auto;
    color: var(--ink-400);
    transition: transform var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.module-tile:hover .module-tile-title .chevron { transform: translateX(2px); color: var(--accent-500); }
.module-tile-desc {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-wrap: pretty;
}

/* ─── PRZYCISKI ─────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    height: 40px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
    transition-property: background-color, border-color, color, scale;
    transition-duration: var(--t-fast);
    transition-timing-function: var(--ease-out);
}
.btn:active { scale: 0.96; }
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    scale: none;
}
.btn .icon { width: 18px; height: 18px; }

.btn-primary {
    background: var(--accent-500);
    color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-600); }

.btn-ghost {
    background: transparent;
    color: var(--ink-700);
    border-color: var(--ink-200);
}
.btn-ghost:hover { background: var(--bg-surface-2); color: var(--ink-900); border-color: var(--ink-300); }

.btn-subtle {
    background: transparent;
    color: var(--ink-500);
}
.btn-subtle:hover { background: var(--bg-surface-2); color: var(--ink-900); }

.btn-success { background: var(--success-500); color: #fff; }
.btn-success:hover { background: var(--success-600); }
.btn-warning { background: var(--warning-500); color: #fff; }
.btn-warning:hover { background: var(--warning-600); }
.btn-danger  { background: var(--danger-500); color: #fff; }
.btn-danger:hover  { background: var(--danger-600); }

.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn-sm .icon { width: 16px; height: 16px; }
.btn-lg { height: 48px; padding: 0 var(--space-6); font-size: var(--text-base); }

.btn-block { width: 100%; }

/* ─── FORMULARZE ────────────────────────────────────── */
.form-group { margin-bottom: var(--space-5); }
.form-group label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: var(--font-medium);
    font-size: var(--text-sm);
    color: var(--ink-700);
}
.form-group label.required::after { content: " *"; color: var(--danger-500); }

.form-input, .form-control, select.form-input, select.form-control, textarea.form-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    min-height: 40px;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--ink-900);
    font-size: var(--text-base);
    line-height: 1.4;
    transition-property: border-color, box-shadow;
    transition-duration: var(--t-fast);
    transition-timing-function: var(--ease-out);
}
.form-input::placeholder, .form-control::placeholder { color: var(--ink-400); }
.form-input:hover, .form-control:hover { border-color: var(--ink-300); }
.form-input:focus, .form-control:focus {
    outline: none;
    border-color: var(--accent-500);
    box-shadow: 0 0 0 3px oklch(0.55 0.2 263 / 0.16);
}
.form-input:disabled, .form-control:disabled {
    background: var(--bg-surface-2);
    color: var(--ink-400);
    cursor: not-allowed;
}

textarea.form-input { resize: vertical; min-height: 96px; }

select.form-input, select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235B6577' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m6 9 6 6 6-6'/%3e%3c/svg%3e");
    background-position: right var(--space-3) center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: var(--space-10);
}

input[type="checkbox"], input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-500);
    cursor: pointer;
    vertical-align: -4px;
}

.form-hint { margin-top: var(--space-1); font-size: var(--text-xs); color: var(--ink-400); }
.form-error { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--danger-600); }
.form-help  { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--ink-400); }

/* ─── ALERTY ────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    text-wrap: pretty;
}
.alert-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }

.alert-success { background: var(--success-100); border-color: oklch(0.55 0.16 150 / 0.3); color: var(--success-600); }
.alert-error   { background: var(--danger-100);  border-color: oklch(0.55 0.2 25 / 0.25);  color: var(--danger-600); }
.alert-warning { background: var(--warning-100); border-color: oklch(0.65 0.14 75 / 0.35); color: var(--warning-600); }
.alert-info    { background: var(--accent-100);  border-color: oklch(0.55 0.2 263 / 0.25); color: var(--accent-600); }

/* ─── BADGE ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: var(--font-medium);
    white-space: nowrap;
}
.badge-success   { background: var(--success-100); color: var(--success-600); }
.badge-warning   { background: var(--warning-100); color: var(--warning-600); }
.badge-danger    { background: var(--danger-100);  color: var(--danger-600); }
.badge-info      { background: var(--accent-100);  color: var(--accent-600); }
.badge-secondary { background: var(--bg-surface-2); color: var(--ink-500); }

/* ─── TABELA ────────────────────────────────────────── */
.table-wrap {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-border);
    overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.data-table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: 0.75rem;
    font-weight: var(--font-semibold);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--ink-500);
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--ink-200);
    white-space: nowrap;
}
.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--ink-100);
    color: var(--ink-700);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background-color var(--t-fast) var(--ease-out); }
.data-table tbody tr:hover { background: var(--bg-surface-2); }
.data-table tbody tr.row-suspended { background: var(--danger-100); }
.data-table tbody tr.row-suspended:hover { background: #F6DADA; }
.data-table tbody tr.row-removed { background: var(--bg-surface-2); }
.data-table tbody tr.row-removed:hover { background: var(--ink-100); }
.data-table td.num, .data-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ─── MODAL ─────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: oklch(0.12 0.02 260 / 0.45);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}
.modal[hidden] { display: none; }
.modal-content {
    position: relative;
    background: var(--bg-surface);
    width: 100%;
    max-width: 520px;
    max-height: min(90vh, 720px);
    overflow-y: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-raised);
    padding: var(--space-6);
}
.modal-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    letter-spacing: -0.01em;
    margin-bottom: var(--space-4);
    padding-right: var(--space-8);
}
.modal-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--ink-400);
    cursor: pointer;
}
.modal-close:hover { background: var(--bg-surface-2); color: var(--ink-900); }
.modal-close .icon { width: 18px; height: 18px; }

/* ─── BREADCRUMB ────────────────────────────────────── */
.breadcrumb { margin-bottom: var(--space-6); }
.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    list-style: none;
    font-size: var(--text-sm);
}
.breadcrumb-item { color: var(--ink-500); }
.breadcrumb-item:not(:last-child)::after { content: "/"; margin-left: var(--space-2); color: var(--ink-300); }
.breadcrumb-item a { color: var(--ink-500); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--accent-500); }
.breadcrumb-item.active { color: var(--ink-900); font-weight: var(--font-medium); }

.back-button-container { margin-bottom: var(--space-4); }
.back-button-container .btn { width: auto; }

/* ─── STAT ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--ink-100);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
}
.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-2);
    color: var(--ink-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}
.stat-icon .icon { width: 18px; height: 18px; }
.stat-number {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.stat-label { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--text-secondary); }

/* ─── EMPTY STATE ───────────────────────────────────── */
.empty-state {
    background: var(--bg-surface);
    border: 1px dashed var(--ink-200);
    border-radius: var(--radius-lg);
    padding: var(--space-10) var(--space-6);
    text-align: center;
    color: var(--ink-500);
}
.empty-state .empty-icon { margin-bottom: var(--space-3); color: var(--ink-300); }
.empty-state .empty-icon .icon { width: 32px; height: 32px; }
.empty-state-text { font-size: var(--text-base); font-weight: var(--font-medium); color: var(--ink-700); }
.empty-state-hint { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--ink-400); }

/* ─── LOADER ────────────────────────────────────────── */
.loader-container { text-align: center; padding: var(--space-10); }
.loader {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--ink-100);
    border-top-color: var(--accent-500);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { margin-top: var(--space-3); color: var(--ink-400); font-size: var(--text-sm); }

/* ─── STOPKA ────────────────────────────────────────── */
.footer {
    max-width: 1440px;
    margin: var(--space-10) auto 0;
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--ink-100);
    color: var(--ink-400);
    font-size: var(--text-xs);
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.footer .sep { color: var(--ink-300); }

/* ─── PRINT ─────────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .main-container { max-width: 100%; padding: 0; }
}

/* ─── REDUCED MOTION ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

/* ═══════════════════════════════════════════════════════
   RESPONSYWNOŚĆ — mobile to inna kompozycja, nie mniejszy
   desktop. Poniżej 960px nawigacja chowa się za hamburgerem
   i otwiera jako wysuwany drawer.
   ═══════════════════════════════════════════════════════ */
@media (max-width: 960px) {
    .hamburger { display: inline-flex; margin-left: auto; }
    .topbar-user { display: none; }

    .nav-shell {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(340px, 88vw);
        background: var(--bg-surface);
        box-shadow: var(--shadow-raised);
        z-index: var(--z-drawer);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 0;
        padding: var(--space-4);
        transform: translateX(100%);
        transition: transform var(--t-slow) var(--ease-out);
    }
    .nav-shell.open { transform: translateX(0); }

    .nav-shell .drawer-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: var(--space-4);
        margin-bottom: var(--space-2);
        border-bottom: 1px solid var(--ink-100);
    }
    .nav-shell .drawer-head .drawer-close {
        width: 40px;
        height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-radius: var(--radius-sm);
        color: var(--ink-500);
        cursor: pointer;
    }
    .nav-shell .drawer-close:hover { background: var(--bg-surface-2); }

    .mainnav {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-1);
        overflow: visible;
        padding-top: var(--space-2);
    }
    .nav-link {
        width: 100%;
        padding: var(--space-3) var(--space-3);
        font-size: 1rem;
        border-radius: var(--radius-md);
        justify-content: flex-start;
    }
    .nav-link.active::after { display: none; }
    .nav-link.active { background: var(--accent-100); color: var(--accent-600); }

    .nav-dropdown { width: 100%; }
    .nav-dropdown-menu {
        position: static;
        display: none;
        box-shadow: none;
        padding: 0 0 0 var(--space-4);
        margin: var(--space-1) 0;
        border-left: 2px solid var(--ink-100);
        border-radius: 0;
        min-width: 0;
    }
    .nav-dropdown.open .nav-dropdown-menu { display: block; }
    .nav-dropdown-item { padding: var(--space-2) var(--space-3); font-size: 0.9375rem; }

    /* użytkownik w stopce drawera */
    .nav-shell .topbar-user {
        display: flex;
        margin-top: auto;
        padding-top: var(--space-4);
        border-top: 1px solid var(--ink-100);
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    .topbar-username { max-width: none; }
}

@media (max-width: 768px) {
    .main-container { padding: var(--space-6) var(--space-4); }
    .cards-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header h1 { font-size: var(--text-xl); }

    /* formularze: pełna szerokość, pola nie mniejsze niż 16px (brak zoom iOS) */
    .form-input, .form-control { font-size: 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .module-tile { padding: var(--space-4); }
}

/* ─── Utility (tekst, linki w tabelach, panel) ───────── */
.text-muted { color: var(--ink-500); }
.text-xs { font-size: var(--text-xs); line-height: var(--leading-normal); }
.text-sm { font-size: var(--text-sm); line-height: var(--leading-normal); }

.table-link { color: var(--accent-500); text-decoration: none; }
.table-link:hover { text-decoration: underline; }

.history-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: var(--space-2);
    font-size: var(--text-xs);
    color: var(--ink-400);
    text-decoration: none;
    vertical-align: middle;
}
.history-link:hover { color: var(--accent-500); }
.history-link svg { width: 13px; height: 13px; }

.panel-body.pad-0 { padding: 0; }
.cell-badge { text-align: center; }

.edited-mark {
    display: inline-flex;
    align-items: center;
    margin-left: var(--space-1);
    color: var(--accent-500);
    vertical-align: middle;
}
.edited-mark svg { width: 14px; height: 14px; }

.inline-edit { display: flex; gap: var(--space-2); align-items: flex-start; }
.inline-edit .form-input { min-width: 240px; }
.inline-edit textarea.form-input { flex: 1; min-height: 64px; resize: vertical; }
.inline-edit .btn { flex-shrink: 0; }
.row-name { max-width: 420px; }
