:root {
    --primary: #f1c40f;
    --primary-hover: #d4ac0d;
    --primary-soft: rgba(241, 196, 15, 0.1);
    --primary-text: #1a1a1b;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --success: #22c55e;
    --success-soft: #f0fdf4;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --bg-app: #f1f3f5;
    --surface: #ffffff;
    --border: var(--slate-200);
    --text-main: var(--slate-800);
    --text-muted: var(--slate-500);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
}

code {
    padding: 2px 6px;
    border-radius: 8px;
    background: var(--slate-100);
    font-family: inherit;
    font-size: .82rem;
}

a { color: inherit; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 40px;
    width: min(420px, calc(100vw - 48px));
}

.login-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-soft);
    display: grid;
    place-items: center;
    margin-bottom: 16px;
}

.login-icon i { color: var(--primary-text); font-size: 1.3rem; }
.login-card h1 { margin: 0 0 4px; font-size: 1.25rem; font-weight: 800; color: var(--text-main); }
.login-card p.sub { margin: 0 0 18px; color: var(--text-muted); font-size: .85rem; }

.setup-box {
    background: var(--slate-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 18px;
}

.setup-box strong { display: block; margin-bottom: 8px; font-size: .8rem; }
.setup-list { margin: 0 0 8px 18px; color: #b91c1c; font-size: .82rem; }
.setup-ok, .setup-meta { color: var(--text-muted); font-size: .8rem; margin-top: 6px; }

.flash {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .85rem;
    margin-bottom: 16px;
}

.flash-ok {
    background: var(--success-soft);
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.flash-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 120;
    display: flex;
    width: min(360px, calc(100vw - 24px));
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-radius: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-xl);
    color: var(--text-main);
    transform: translateY(-8px);
    opacity: 0;
    transition: transform .18s ease, opacity .18s ease;
    pointer-events: auto;
}

.toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.toast--success {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.toast--error {
    border-color: #fca5a5;
    background: #fff1f2;
}

.toast__text {
    font-size: .86rem;
    line-height: 1.45;
}

.toast__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.mail-sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--slate-50);
}

.mail-sync-status {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mail-sync-status small {
    color: var(--text-muted);
}

.mailbox-tabs {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.mailbox-tab {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-muted);
    background: #fff;
    font-size: .88rem;
    font-weight: 700;
}

.mailbox-tab span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--slate-100);
    color: var(--text-main);
    font-size: .75rem;
}

.mailbox-tab.is-active {
    border-color: var(--primary);
    background: #fffbe7;
    color: var(--text-main);
}

.mailbox-shell {
    display: grid;
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    gap: 16px;
    min-height: 520px;
}

.mailbox-shell--tri {
    grid-template-columns: minmax(220px, 280px) minmax(250px, 320px) minmax(0, 1fr);
}

.mail-folder-tree {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    padding: 14px;
}

.mail-folder-tree__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.mail-folder-tree__head strong {
    font-size: .9rem;
}

.mail-folder-tree__head span {
    color: var(--text-muted);
    font-size: .78rem;
}

.mail-folder-tree__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 620px;
    overflow: auto;
}

.mail-folder-tree__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    padding-left: calc(12px + (var(--folder-depth, 0) * 18px));
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    text-decoration: none;
    color: var(--text-main);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.mail-folder-tree__item:hover,
.mail-folder-tree__item.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    transform: translateY(-1px);
}

.mail-folder-tree__label {
    font-size: .86rem;
    font-weight: 700;
}

.mail-folder-tree__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--slate-100);
    color: var(--text-muted);
    font-size: .74rem;
    font-weight: 800;
}

.mailbox-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 620px;
    overflow: auto;
    padding-right: 4px;
}

.mailbox-list-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    text-decoration: none;
    background: #fff;
    color: var(--text-main);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.mailbox-list-item strong {
    font-size: .9rem;
}

.mailbox-list-item span {
    color: var(--text-muted);
    font-size: .84rem;
}

.mailbox-list-item small {
    color: var(--slate-400);
    font-size: .75rem;
}

.mailbox-list-item:hover,
.mailbox-list-item.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    transform: translateY(-1px);
}

.mailbox-detail {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    padding: 18px;
    min-height: 420px;
}

.mailbox-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.mailbox-detail-head h3 {
    font-size: 1.15rem;
    line-height: 1.3;
}

.mailbox-detail-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.mailbox-detail-meta div {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--slate-50);
    border: 1px solid var(--border);
}

.mailbox-detail-meta dt {
    margin-bottom: 4px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.mailbox-detail-meta dd {
    font-size: .92rem;
    color: var(--text-main);
}

.mailbox-detail-meta dd small {
    color: var(--text-muted);
}

.mailbox-body {
    padding: 18px;
    border-radius: 16px;
    background: linear-gradient(180deg, #fffdf7 0%, #ffffff 100%);
    border: 1px solid #f5e7a4;
    color: var(--text-main);
    white-space: normal;
    word-break: break-word;
}

.mailbox-body br {
    content: "";
}

@media (max-width: 1080px) {
    .mail-toolbar {
        align-items: stretch;
    }

    .mailbox-shell {
        grid-template-columns: 1fr;
    }

    .mailbox-shell--tri {
        grid-template-columns: 1fr;
    }

    .mailbox-list {
        max-height: none;
    }
}

@media (max-width: 720px) {
    .mail-subnav__link,
    .mail-sync-bar,
    .mailbox-detail-head,
    .mail-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .mailbox-detail-meta {
        grid-template-columns: 1fr;
    }
}

body.modal-open {
    overflow: hidden;
}

.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #475569;
}

.required-mark {
    color: var(--danger);
    margin-left: 4px;
}

.required-note {
    margin: 0 0 14px;
    font-size: .78rem;
    color: var(--text-muted);
}

.form-input {
    max-width: 100%;
    width: 100%;
    padding: 12px 16px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    color: #1e293b;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: .92rem;
    color: var(--text-main);
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

textarea.form-input {
    min-height: 116px;
    resize: vertical;
    display: block;
}

.photo-dropzone {
    position: relative;
    border: 1.5px dashed var(--slate-300);
    border-radius: 16px;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    padding: 18px;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
    cursor: pointer;
}

.photo-dropzone:hover,
.photo-dropzone:focus-visible,
.photo-dropzone.is-focused,
.photo-dropzone.is-dragover {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
    background: #fffef2;
}

.photo-dropzone__input {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.photo-dropzone__empty {
    min-height: 128px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: var(--text-muted);
}

.photo-dropzone__empty i {
    font-size: 1.45rem;
    color: var(--slate-700);
}

.photo-dropzone__empty strong {
    color: var(--text-main);
    font-size: .92rem;
}

.photo-dropzone__empty span {
    max-width: 34rem;
    font-size: .8rem;
}

.photo-dropzone__browse {
    margin-top: 4px;
}

.photo-dropzone__preview {
    display: none;
    gap: 14px;
    align-items: flex-start;
}

.photo-dropzone__preview.is-visible {
    display: flex;
}

.photo-dropzone__preview img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    background: var(--slate-100);
}

.photo-dropzone__meta {
    display: flex;
    min-height: 120px;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
}

.photo-dropzone__meta span {
    font-size: .82rem;
    color: var(--text-main);
    word-break: break-word;
}

.photo-dropzone--compact .photo-dropzone__empty {
    min-height: 104px;
}

.photo-dropzone--compact .photo-dropzone__preview img {
    width: 88px;
    height: 88px;
}

.photo-dropzone--compact .photo-dropzone__meta {
    min-height: 88px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-text);
}

.btn-primary:hover { background-color: var(--primary-hover); }
.btn-block { width: 100%; }

.btn-secondary { background-color: var(--slate-100); color: var(--text-main); border-color: var(--border); }
.btn-secondary:hover { background-color: var(--slate-200); }
.btn-danger { background-color: var(--danger); color: #fff; }
.btn-danger:hover { background-color: #b91c1c; }

/* ── Kontrahent autocomplete ── */
.ac-wrap { position: relative; }
.ac-dropdown {
    display: none;
    position: absolute;
    left: 0; right: 0; top: 100%;
    z-index: 100;
    background: #fff;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    max-height: 260px;
    overflow-y: auto;
}
.ac-dropdown.open { display: block; }
.ac-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--slate-100);
    font-size: .85rem;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.focused { background: var(--slate-50); }
.ac-item__name { font-weight: 600; }
.ac-item__sub { font-size: .75rem; color: var(--slate-500); margin-top: 1px; }
.ac-item--new { color: #4f46e5; font-size: .82rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.ac-tag {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: .8rem;
    color: #166534;
    background: #dcfce7;
    border-radius: 6px;
    padding: 4px 10px;
    width: fit-content;
}
.ac-tag.visible { display: flex; }
.ac-tag__clear {
    background: none; border: none; cursor: pointer;
    color: #166534; padding: 0; margin-left: 2px;
    font-size: 1rem; line-height: 1;
}

/* ── Commission toggle ── */
.kom-fieldset {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}
.kom-legend {
    font-size: .7rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 0 6px;
}
.kom-sub,
.form-label-sub {
    font-size: .75rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
}
.kom-field {
    display: flex;
    align-items: center;
    gap: 10px;
}
.kom-toggle {
    display: flex;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.kom-btn {
    padding: 10px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-muted);
    font-family: inherit;
    line-height: 1;
    transition: background .15s, color .15s;
}
.kom-btn.active {
    background: var(--primary);
    color: var(--primary-text);
}
.kom-input { flex: 1; margin-bottom: 0; }

/* ── New kontrahent inline form ── */
.new-kontrahent-form {
    margin-top: 10px;
    padding: 14px;
    background: var(--slate-50);
    border: 1.5px solid var(--slate-200);
    border-radius: 10px;
}
.nkf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--slate-700);
}
.nkf-error {
    color: var(--danger);
    font-size: .8rem;
    font-weight: 600;
}

/* ── Owner card ── */
.owner-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--primary-soft);
    border: 1.5px solid var(--primary);
    border-radius: 10px;
}
.oc-name {
    font-weight: 700;
    font-size: .9rem;
    color: var(--slate-800);
}
.oc-role {
    font-size: .75rem;
    color: var(--slate-500);
    margin-top: 2px;
}

/* ── Kontrahent card ── */
.kontrahent-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    border-radius: 10px;
}
.kc-info { min-width: 0; }
.kc-name {
    font-weight: 700;
    font-size: .9rem;
    color: var(--slate-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kc-meta {
    font-size: .75rem;
    color: var(--slate-500);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.admin-topbar .brand {
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.menu-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.admin-topbar .user {
    color: var(--text-muted);
    font-size: .8rem;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-topbar .user a {
    color: var(--danger);
    text-decoration: none;
    font-weight: 600;
}

.admin-layout {
    display: block;
    min-height: calc(100vh - 65px);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 19;
}

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 280px);
    transform: translateX(-100%);
    transition: transform .22s ease;
    background: #1e293b;
    overflow-y: auto;
    padding-bottom: 24px;
    z-index: 20;
    padding-top: 72px;
}

body.sidebar-open .admin-sidebar {
    transform: translateX(0);
}

body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
}

.asb-section {
    padding: 18px 16px 5px;
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #475569;
}

.asb-link,
.asb-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    text-decoration: none;
}

.asb-link {
    padding: 9px 16px;
    font-size: .85rem;
    color: #94a3b8;
}

.asb-link--toggle {
    justify-content: space-between;
    cursor: pointer;
    font-family: inherit;
}

.asb-link__label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.asb-link__chevron {
    transition: transform .18s ease;
}

.asb-link--toggle[aria-expanded="true"] .asb-link__chevron {
    transform: rotate(180deg);
}

.asb-link.aktywna {
    background: rgba(99,102,241,.18);
    color: #a5b4fc;
    border-left: 3px solid #6366f1;
    padding-left: 13px;
}

.asb-tree-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: calc(100% - 24px);
    margin: 4px 12px 0;
    padding: 7px 12px 7px 30px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #64748b;
    font-size: .74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    cursor: pointer;
    transition: color .18s ease, background-color .18s ease;
}

.asb-tree-toggle:hover,
.asb-tree-toggle.aktywna {
    color: #cbd5e1;
    background: rgba(148, 163, 184, .08);
}

.asb-tree-toggle i {
    transition: transform .18s ease;
}

.asb-tree-toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.asb-subtree {
    display: grid;
    gap: 6px;
    padding: 6px 12px 10px 12px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .2s ease, opacity .16s ease, padding-top .16s ease, padding-bottom .16s ease;
}

.asb-subtree:not(.asb-subtree--open) {
    padding-top: 0;
    padding-bottom: 0;
}

.asb-subtree.asb-subtree--open {
    max-height: 420px;
    opacity: 1;
}

.asb-sublink {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px 9px 30px;
    border-radius: 12px;
    text-decoration: none;
    color: #94a3b8;
    font-size: .82rem;
    transition: background-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.asb-sublink:hover {
    background: rgba(148, 163, 184, .1);
    color: #e2e8f0;
}

.asb-sublink.aktywna {
    background: rgba(99, 102, 241, .16);
    color: #c7d2fe;
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .34);
}

.asb-sublink--accent {
    background: linear-gradient(135deg, rgba(241, 196, 15, .2) 0%, rgba(250, 204, 21, .08) 100%);
    color: #fef08a;
    box-shadow: inset 0 0 0 1px rgba(250, 204, 21, .16);
}

.asb-sublink--accent:hover,
.asb-sublink--accent.aktywna {
    background: linear-gradient(135deg, rgba(241, 196, 15, .28) 0%, rgba(250, 204, 21, .12) 100%);
    color: #fff7bf;
    box-shadow: inset 0 0 0 1px rgba(250, 204, 21, .3);
}

.asb-sublink i {
    width: 14px;
    text-align: center;
}

.asb-btn {
    padding: 7px 16px 7px 32px;
    font-size: .8rem;
    color: #475569;
    cursor: default;
}

.asb-divider { height: 1px; background: #334155; margin: 8px 16px; }
.admin-main { padding: 16px; }
.admin-section { display: block; width: 100%; max-width: none; }
.stack-form { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.form-row-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-actions { white-space: nowrap; }
.table-actions .btn { flex-shrink: 0; }
.btn-sm { padding: 7px 10px; font-size: .76rem; }
.quick-links { display: grid; gap: 10px; }

.hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 8px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--slate-500);
    font-size: 12px;
    font-weight: 700;
}

.hero h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.15;
}

.lede {
    max-width: none;
    color: var(--text-muted);
    font-size: .92rem;
    line-height: 1.65;
}

.hero-card,
.metrics article,
.panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.hero-card {
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #f8fafc;
    color: var(--text-main);
}

.hero-card strong {
    margin: 6px 0 2px;
    font-size: 1.15rem;
}

.metrics {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.metrics article {
    padding: 16px;
}

.metrics span, .metrics small { display: block; }

.metrics span {
    color: var(--text-muted);
    margin-bottom: 10px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.metrics strong { font-size: 1.8rem; }
.metrics small { color: var(--text-muted); font-size: .78rem; }

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.panel {
    padding: 16px;
    overflow: hidden;
}

.panel-wide {
    min-width: 0;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: baseline;
    margin-bottom: 18px;
}

.panel-head h2 {
    margin: 0;
    font-size: .95rem;
    font-weight: 800;
}

.panel-head span {
    color: var(--text-muted);
    font-size: .75rem;
}

.list-entity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.list-entity__thumb {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #fff, #f8fafc);
    display: grid;
    place-items: center;
    color: var(--slate-500);
}

.list-entity__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.list-entity__thumb--empty {
    background: linear-gradient(180deg, #f8fafc, #eef2f7);
}

.table-wrap[data-mobile-cards="1"] .list-entity__thumb,
table .list-entity__thumb {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.list-entity__content {
    min-width: 0;
}

.list-entity__content strong,
.list-entity__content small {
    display: block;
}

.list-entity__content small {
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.35;
    word-break: break-word;
}

.pipeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.pipeline-card {
    padding: 14px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    border-radius: 999px;
    margin-bottom: 12px;
}

.pipeline-card strong,
.pipeline-card b,
.pipeline-card small {
    display: block;
}

.pipeline-card b {
    font-size: 1.6rem;
    margin: 6px 0 2px;
}

.pipeline-card small { color: var(--text-muted); font-size: .75rem; }

.agenda {
    display: grid;
    gap: 12px;
}

.agenda-item {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.agenda-item:last-child {
    border-bottom: 0;
}

.agenda-item time {
    font-weight: 700;
    color: #1d4ed8;
    font-size: .82rem;
}

.agenda-item p {
    margin: 4px 0 0;
    color: var(--text-muted);
    line-height: 1.5;
    font-size: .8rem;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid #f1f5f9;
    font-size: .85rem;
}

th {
    color: var(--text-muted);
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: #f8fafc;
}

.todo {
    margin: 0;
    padding-left: 18px;
    color: var(--text-muted);
    line-height: 1.7;
    font-size: .85rem;
}

.empty-state {
    padding: 18px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    font-size: .82rem;
}

.empty-cell {
    color: var(--text-muted);
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1e40af;
    font-size: .72rem;
    font-weight: 700;
}

.status-badge-lead {
    border: 1px solid transparent;
    white-space: nowrap;
}

.status-badge-lead-empty {
    background: var(--slate-100);
    color: var(--slate-500);
    border-color: var(--slate-200);
}

.status-badge-ready {
    margin-left: 6px;
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #a7f3d0;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.mail-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.mail-subnav__link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.mail-subnav__link:hover,
.mail-subnav__link.is-active {
    border-color: var(--primary);
    background: #fffbe7;
    color: var(--text-main);
    box-shadow: 0 0 0 3px var(--primary-soft);
    transform: translateY(-1px);
}

.mail-subnav__link i {
    color: var(--primary-text);
}

.mail-layout {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 20px;
    margin-bottom: 20px;
}

.mail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mail-code {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--slate-100);
    color: var(--slate-700);
    font-size: .78rem;
}

.mail-preview {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--slate-50);
    font-size: .88rem;
    color: var(--slate-700);
}

.mail-preview h4 {
    margin-bottom: 10px;
    font-size: .95rem;
    color: var(--slate-900);
}

.mail-preview pre {
    white-space: pre-wrap;
    word-break: break-word;
    font: inherit;
}

.mail-template-list {
    display: grid;
    gap: 12px;
}

.mail-template-card {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}

.mail-template-card strong {
    font-size: .92rem;
}

.mail-template-card span,
.mail-template-card small {
    color: var(--text-muted);
}

.mail-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.mail-toolbar__filters {
    min-width: min(320px, 100%);
}

.mail-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 700;
}

.mail-status-pill--ok {
    background: #dcfce7;
    color: #166534;
}

.mail-status-pill--warn {
    background: #fef3c7;
    color: #92400e;
}

.mail-status-pill--fail {
    background: #fee2e2;
    color: #991b1b;
}

.lead-mail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 22px;
}

.mail-wizard-intro {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.mail-wizard-intro__item {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, #fffef8 0%, #fbfdff 100%);
}

.mail-wizard-intro__item small,
.mail-mode-option small {
    display: block;
    color: var(--text-muted);
    font-size: .72rem;
    line-height: 1.5;
}

.mail-wizard-intro__item strong,
.mail-mode-option strong {
    display: block;
    margin: 4px 0 2px;
    color: var(--slate-900);
    font-size: .88rem;
}

.mail-wizard-intro__item span {
    display: block;
    color: var(--slate-700);
    font-size: .78rem;
    line-height: 1.55;
}

.mail-mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mail-mode-option {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fbfdff;
    cursor: pointer;
    font-size: .84rem;
    font-weight: 700;
    color: var(--slate-800);
}

.mail-mode-option input {
    margin: 2px 0 0;
}

.mail-advanced {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fcfdff;
    overflow: hidden;
}

.mail-advanced summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 16px;
    font-weight: 700;
    color: var(--slate-900);
}

.mail-advanced summary::-webkit-details-marker {
    display: none;
}

.mail-advanced__body {
    padding: 0 16px 16px;
}

.mail-preview-card {
    min-height: 220px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
}

.mail-preview-card--rich {
    padding: 0;
    overflow: hidden;
}

.mail-preview-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--slate-100);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.mail-preview-head small {
    display: block;
    color: var(--text-muted);
    font-size: .72rem;
    line-height: 1.4;
}

.mail-preview-head strong {
    display: block;
    margin-top: 4px;
    color: var(--slate-950);
    font-size: .96rem;
    line-height: 1.45;
}

.mail-preview-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: .72rem;
    font-weight: 800;
    white-space: nowrap;
}

.mail-preview-meta {
    display: grid;
    gap: 6px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
    font-size: .78rem;
    background: #fcfdff;
}

.mail-preview-meta b {
    color: var(--slate-900);
}

.mail-preview-rendered {
    padding: 18px;
    color: var(--slate-800);
    line-height: 1.72;
}

.mail-preview-rendered pre,
.mail-preview-card pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font: inherit;
    line-height: 1.72;
    color: var(--slate-800);
}

.mail-preview-rendered--text {
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.mail-preview-rendered p:first-child {
    margin-top: 0;
}

.mail-preview-rendered p:last-child {
    margin-bottom: 0;
}

.mail-preview-empty {
    margin: 0;
    color: var(--text-muted);
    font-style: italic;
}

.mail-history-list {
    display: grid;
    gap: 12px;
}

.mail-history-item {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fbfdff;
}

.mail-history-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.mail-history-top strong {
    font-size: .92rem;
    line-height: 1.45;
    color: var(--slate-900);
}

.mail-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: .78rem;
}

.mail-history-template {
    margin-top: 8px;
    font-size: .78rem;
    color: var(--slate-700);
    font-weight: 600;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    align-items: center;
    justify-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.56);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}

.modal[hidden] {
    display: none;
}

.modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.modal__dialog {
    width: calc(100vw - 36px);
    max-width: 760px;
    max-height: calc(100vh - 36px);
    overflow: visible;
}

.modal--wide .modal__dialog {
    width: calc(100vw - 36px);
    max-width: 1040px;
}

.modal__panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 36px);
}

.modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fff, #f8fafc);
}

.modal__title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-main);
}

.modal__sub {
    margin-top: 4px;
    font-size: .82rem;
    color: var(--text-muted);
}

.modal__close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
}

.modal__body {
    padding: 20px;
    overflow: auto;
    background:
        radial-gradient(circle at top right, rgba(241, 196, 15, 0.08), transparent 22%),
        linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

/* ── Wyplaty: user cards ── */
.wyp-user-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
}
.wyp-user-info { flex: 1; min-width: 0; }
.wyp-user-name { font-weight: 700; font-size: 1rem; color: var(--text-main); }
.wyp-user-meta { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }
.wyp-user-total { text-align: right; flex-shrink: 0; }
.wyp-user-total-val { font-size: 1.2rem; font-weight: 800; color: var(--primary-text); }
.wyp-user-total-lbl { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

/* ── Wyplaty: summary tiles ── */
.wyp-tile {
    flex: 1;
    min-width: 140px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
}
.wyp-tile-label { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 4px; }
.wyp-tile-val   { font-size: 1.2rem; font-weight: 800; }
.wyp-tile-sub   { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Payment panel ── */
.roz-pay-panel {
    background: var(--surface);
    border: 1.5px solid var(--primary);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 20px;
}
.roz-pay-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.roz-pay-label {
    display: block;
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.roz-pay-firma {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}
.roz-pay-form { display: flex; flex-direction: column; gap: 12px; }
.roz-pay-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 14px;
    background: var(--bg-app);
    border-radius: 8px;
}
.roz-pay-type {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 2px;
}
.roz-pay-type-name {
    font-weight: 700;
    font-size: .9rem;
    color: var(--text-main);
}
.roz-pay-type-val { font-size: .8rem; color: var(--text-muted); }
.roz-pay-type-rem { font-size: .8rem; font-weight: 600; }
.roz-pay-input-wrap { width: 220px; flex-shrink: 0; }
.roz-pay-input-wrap .form-label { margin-bottom: 4px; }
.roz-pay-input-wrap .form-input { margin-bottom: 0; }
@media (max-width: 640px) {
    .roz-pay-row { flex-direction: column; }
    .roz-pay-input-wrap { width: 100%; }
}

/* ── Inline settlement status select ── */
.roz-status-select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}
.roz-status--not_settled       { background:#fee2e2; color:#991b1b; }
.roz-status--partially_settled { background:#fef9c3; color:#854d0e; }
.roz-status--settled            { background:#dcfce7; color:#166534; }
.roz-status-select:hover { filter: brightness(.96); }

.form-group,
.form-row-2 > * {
    min-width: 0;
}

@media (max-width: 1120px) {
}

@media (min-width: 720px) {
    .admin-main,
    .login-card {
        padding: 24px;
    }

    .metrics,
    .pipeline {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row-2 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 719px) {
    .toast-stack {
        top: auto;
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
    }

    .login-page {
        padding: 14px;
    }

    .admin-topbar {
        padding: 10px 12px;
        gap: 10px;
        align-items: flex-start;
    }

    .topbar-left {
        gap: 10px;
        min-width: 0;
        flex: 1;
    }

    .admin-topbar .brand {
        font-size: .94rem;
        gap: 8px;
        line-height: 1.2;
    }

    .admin-topbar .user {
        font-size: .72rem;
        gap: 6px;
        justify-content: flex-start;
        width: 100%;
        padding-left: 50px;
    }

    .login-card,
    .admin-main,
    .panel {
        padding: 14px;
    }

    .hero {
        gap: 14px;
        margin-bottom: 16px;
    }

    .panel-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .page-actions {
        align-items: stretch;
    }

    .page-actions > a.btn {
        width: 100%;
    }

    .actions-row {
        flex-direction: column;
        align-items: stretch;
    }

    .actions-row > .btn,
    .actions-row > a,
    .actions-row > form,
    .actions-row > form > .btn {
        width: 100%;
    }

    .table-wrap {
        margin: 0 -14px;
        padding: 0 14px;
    }

    .table-wrap[data-mobile-cards="1"] {
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    .table-wrap[data-mobile-cards="1"] table,
    .table-wrap[data-mobile-cards="1"] tbody,
    .table-wrap[data-mobile-cards="1"] tr,
    .table-wrap[data-mobile-cards="1"] td {
        display: block;
        width: 100%;
    }

    .table-wrap[data-mobile-cards="1"] thead {
        display: none;
    }

    .table-wrap[data-mobile-cards="1"] tbody {
        display: grid;
        gap: 12px;
    }

    .table-wrap[data-mobile-cards="1"] tr {
        border: 1px solid var(--border);
        border-radius: 16px;
        background: var(--surface);
        box-shadow: var(--shadow-sm);
        padding: 8px 0;
    }

    .table-wrap[data-mobile-cards="1"] td {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 11px 12px;
        border-bottom: 1px solid var(--slate-100);
    }

    .table-wrap[data-mobile-cards="1"] td:last-child {
        border-bottom: 0;
    }

    .table-wrap[data-mobile-cards="1"] td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: .69rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .05em;
    }

    .table-wrap[data-mobile-cards="1"] .table-actions {
        white-space: normal;
        gap: 10px;
    }

    .table-wrap[data-mobile-cards="1"] .table-actions,
    .table-wrap[data-mobile-cards="1"] .table-actions form {
        display: flex;
        width: 100%;
    }

    .table-wrap[data-mobile-cards="1"] .table-actions .btn,
    .table-wrap[data-mobile-cards="1"] .table-actions form .btn {
        width: 100%;
    }

    .lead-mail-grid,
    .mail-layout {
        grid-template-columns: 1fr;
    }

    .mail-wizard-intro,
    .mail-mode-switch {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 10px 8px;
    }

    .modal {
        padding: 0;
        align-items: stretch;
    }

    .modal__dialog,
    .modal--wide .modal__dialog {
        width: 100vw;
        max-height: 100vh;
        height: 100vh;
        max-width: none;
    }

    .modal__panel {
        height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        max-height: none;
        border: 0;
    }

    .modal__header {
        padding: 12px 12px 10px;
        position: sticky;
        top: 0;
        z-index: 1;
        background:
            linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,252,.98)),
            radial-gradient(circle at top right, rgba(241, 196, 15, 0.16), transparent 34%);
        backdrop-filter: blur(10px);
        align-items: center;
        min-height: 58px;
    }

    .modal__title {
        font-size: .98rem;
        line-height: 1.2;
    }

    .modal__body {
        padding: 12px 12px 18px;
        flex: 1;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal__sub {
        font-size: .74rem;
        line-height: 1.35;
        margin-top: 3px;
    }

    .modal__close {
        width: 36px;
        height: 36px;
        border-radius: 11px;
    }

    .new-kontrahent-form,
    .owner-card,
    .kontrahent-card,
    .roz-pay-panel,
    .wyp-user-card {
        border-radius: 14px;
    }

    .new-kontrahent-form,
    .owner-card,
    .kontrahent-card {
        padding: 12px;
    }

    .kc-name,
    .kc-meta {
        white-space: normal;
    }

    .list-entity {
        align-items: flex-start;
    }

    .list-entity__thumb {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .list-entity__content strong {
        font-size: .92rem;
        line-height: 1.25;
    }

    .list-entity__content small {
        font-size: .76rem;
    }

    .form-label {
        font-size: .74rem;
        margin-bottom: 7px;
    }

    .form-input {
        padding: 13px 14px;
        font-size: 16px;
        border-radius: 12px;
    }

    textarea.form-input {
        min-height: 104px;
    }

    .required-note {
        margin-bottom: 12px;
        font-size: .74rem;
    }

    .stack-form .actions-row:last-child {
        position: sticky;
        bottom: -12px;
        margin: 16px -12px -18px;
        padding: 10px 12px max(12px, env(safe-area-inset-bottom));
        background: rgba(255,255,255,.96);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--border);
        z-index: 1;
    }

    .stack-form .actions-row:last-child > * {
        margin: 0;
    }

    .photo-dropzone {
        padding: 12px;
        border-radius: 14px;
    }

    .photo-dropzone__preview.is-visible {
        flex-direction: column;
    }

    .photo-dropzone__preview img,
    .photo-dropzone--compact .photo-dropzone__preview img {
        width: 100%;
        max-width: 220px;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .photo-dropzone__meta {
        min-height: 0;
    }

    .photo-dropzone__empty {
        min-height: 108px;
        gap: 6px;
    }

    .photo-dropzone__empty strong {
        font-size: .88rem;
        line-height: 1.25;
    }

    .photo-dropzone__empty span {
        font-size: .76rem;
        line-height: 1.35;
    }
}

@media (min-width: 1120px) {
    .menu-toggle,
    .sidebar-overlay {
        display: none;
    }

    .admin-topbar {
        padding: 14px 24px;
        height: 52px;
        box-sizing: border-box;
    }

    .admin-layout {
        display: flex;
        min-height: calc(100vh - 52px);
    }

    .admin-sidebar {
        position: static;
        top: auto;
        left: auto;
        bottom: auto;
        width: 240px;
        min-width: 240px;
        transform: none;
        padding-top: 0;
        flex-shrink: 0;
    }

    .admin-main {
        flex: 1;
        overflow-y: auto;
        padding: 24px;
    }

    .admin-section {
        width: 100%;
        max-width: none;
    }

    .hero {
        grid-template-columns: 1fr 240px;
    }

    .grid {
        grid-template-columns: 2fr 1fr;
    }

    .two-col-fixed {
        grid-template-columns: 1fr 1fr;
    }

    .metrics {
        grid-template-columns: repeat(4, 1fr);
    }

    .panel-head {
        flex-direction: row;
        align-items: baseline;
    }
}
