/* assets/css/style.css - Atom CRM */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
    --accent: #f97316;
    --accent-strong: #ea580c;
    --accent-soft: rgba(249, 115, 22, 0.14);
    --success: #16a34a;
    --bg: #f3f5fb;
    --bg-deep: #e9eef8;
    --surface: rgba(255, 255, 255, 0.84);
    --surface-strong: #ffffff;
    --surface-dark: #111827;
    --text: #0f172a;
    --muted: #64748b;
    --border: rgba(148, 163, 184, 0.22);
    --border-strong: rgba(148, 163, 184, 0.34);
    --shadow-xl: 0 24px 80px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.08);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* Pionowy pasek przewijania jest ukryty - zastępuje go rysowana przez scroll-progress.js
   cienka (1px) pomarańczowa linia, która startuje od góry i "dorysowuje się" w dół w miarę
   przewijania (patrz .scroll-progress-line). Poziomy zostaje natywny, też przycięty do 1px. */
* {
    scrollbar-width: none;
}

*::-webkit-scrollbar {
    width: 0;
    height: 1px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: 0;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent-strong);
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

.scroll-progress-line {
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 0px;
    background: var(--accent);
    pointer-events: none;
    z-index: 9999;
}

/* Globalny rozmiar czcionki (przełącznik w headerze) - skaluje wszystkie jednostki rem w serwisie */
html[data-text-scale="small"] {
    font-size: 87.5%;
}

html[data-text-scale="large"] {
    font-size: 112.5%;
}

body {
    font-family: 'Manrope', sans-serif;
    background:
        radial-gradient(circle at top left, rgba(249, 115, 22, 0.12), transparent 24%),
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 20%),
        linear-gradient(180deg, #f8faff 0%, var(--bg) 42%, var(--bg-deep) 100%);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.4) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 72%);
    opacity: 0.55;
}

h1, h2, h3, h4 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    letter-spacing: -0.03em;
    margin-top: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

input, select, textarea, button {
    font: inherit;
}

.sidebar {
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(15, 23, 42, 0.92) 100%);
    width: 292px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 18px 0 60px rgba(15, 23, 42, 0.18);
    z-index: 50;
    transition: left 0.25s ease;
    overflow-y: auto;
}

.logo-container {
    padding: 20px 24px 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 49;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

.sidebar-mobile-close {
    display: none;
    position: absolute;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.1rem;
    line-height: 1;
    align-items: center;
    justify-content: center;
}

body.sidebar-locked {
    overflow: hidden;
}

.topbar {
    position: fixed;
    top: 0;
    left: 292px;
    right: 0;
    height: 92px;
    background: rgba(243, 245, 251, 0.72);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    z-index: 40;
}

.main-content {
    margin-left: 292px;
    padding-top: 92px;
    min-height: 100vh;
}

.page-shell {
    padding: 32px;
}

.page-hero {
    position: relative;
    overflow: hidden;
    padding: 32px;
    border-radius: 32px;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.8), transparent 32%),
        linear-gradient(135deg, #0f172a 0%, #18243d 58%, #1e293b 100%);
    color: #fff;
    box-shadow: var(--shadow-xl);
}

.page-hero::after {
    content: '';
    position: absolute;
    inset: auto -40px -70px auto;
    width: 240px;
    height: 240px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.18);
    filter: blur(10px);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.glass-card,
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
}

.card {
    color: var(--text);
}

.panel-card {
    background: var(--surface-strong);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.section-header h1,
.section-header h2 {
    margin-bottom: 8px;
}

.muted {
    color: var(--muted);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 24px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.92);
    box-shadow: var(--shadow-lg);
}

.metric-card::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    top: -48px;
    right: -42px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.1);
}

.metric-label {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.metric-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    margin-top: 18px;
}

.metric-trend {
    margin-top: 8px;
    color: #0f766e;
    font-size: 0.95rem;
    font-weight: 700;
}

.toolbar-search,
.field-input,
.field-select,
.field-textarea,
.topbar-search {
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(203, 213, 225, 0.9);
    color: var(--text);
    border-radius: 18px;
    padding: 14px 18px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.toolbar-search::placeholder,
.field-input::placeholder,
.field-textarea::placeholder,
.topbar-search::placeholder {
    color: #94a3b8;
}

.toolbar-search:focus,
.field-input:focus,
.field-select:focus,
.field-textarea:focus,
.topbar-search:focus {
    border-color: rgba(249, 115, 22, 0.9);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.12);
    transform: translateY(-1px);
}

/* Pole wyboru z AJAX-owym podpowiadaniem (assets/js/relation-select.js) - kontrahent/kontakt/
   szansa/lead/produkt/partner/użytkownik, żeby nie trzeba było przewijać setek opcji. */
.relation-select-wrap {
    position: relative;
}

.relation-select-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.relation-select-input {
    padding-right: 38px;
}

.relation-select-clear {
    display: none;
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 999px;
}

.relation-select-clear:hover {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text);
}

.relation-select-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 200;
    max-height: 260px;
    overflow-y: auto;
    background: var(--surface-strong, #ffffff);
    border: 1px solid rgba(203, 213, 225, 0.9);
    border-radius: 16px;
    box-shadow: var(--shadow-lg, 0 20px 40px rgba(15, 23, 42, 0.14));
    padding: 6px;
}

.relation-select-option {
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.relation-select-option:hover,
.relation-select-option.is-highlighted {
    background: rgba(249, 115, 22, 0.1);
}

.relation-select-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: #94a3b8;
}

.global-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid rgba(203, 213, 225, 0.9);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
    max-height: 420px;
    overflow-y: auto;
    z-index: 40;
    padding: 8px;
}

.global-search-group {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    padding: 10px 12px 4px;
}

.global-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
}

.global-search-item:hover {
    background: rgba(249, 115, 22, 0.08);
}

.global-search-item-label {
    font-weight: 600;
}

.global-search-item-meta {
    font-size: 0.78rem;
    color: #94a3b8;
}

.global-search-empty {
    padding: 16px;
    color: #94a3b8;
    text-align: center;
    font-size: 0.9rem;
}

.field-label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #334155;
}

.field-hint {
    display: block;
    margin-top: 8px;
    color: #94a3b8;
    font-size: 0.82rem;
}

/* Pola uzupełnione automatycznie z GUS, które warto ręcznie zweryfikować (modules/kontrahenci/
   form.php) - znika samo, gdy użytkownik dotknie/poprawi dane pole. */
.field-needs-verification {
    border-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.08) !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15) !important;
}

/* Kreator dokumentów: drag & drop */
.doc-builder {
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
}

.doc-builder-tabs {
    display: flex;
    gap: 4px;
    padding: 10px;
    background: rgba(248, 250, 252, 0.9);
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

.doc-builder-tab {
    border: 0;
    background: transparent;
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
}

.doc-builder-tab.active {
    background: #fff;
    color: #ea580c;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* ============ Zakładki widoku modułu (zamiast kilku paneli naraz na jednym ekranie) ============ */
.view-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.view-tab .material-symbols-outlined,
.zadania-view-tab .material-symbols-outlined {
    font-size: 19px;
}

.view-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 14px;
    background: transparent;
    border: 1px solid transparent;
    color: #64748b;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    text-decoration: none;
}

.view-tab:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #334155;
}

.view-tab.active {
    background: #fff;
    border-color: rgba(226, 232, 240, 0.95);
    color: #ea580c;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.view-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: #475569;
    font-size: 0.72rem;
    font-weight: 800;
}

.view-tab.active .view-tab-count {
    background: rgba(249, 115, 22, 0.14);
    color: #c2410c;
}

.doc-builder-pane.hidden {
    display: none;
}

.doc-builder-pane[data-pane="html"] {
    padding: 16px;
}

.doc-builder-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    min-height: 420px;
}

.doc-builder-palette {
    border-right: 1px solid rgba(226, 232, 240, 0.95);
    background: rgba(248, 250, 252, 0.6);
    padding: 16px 12px;
    overflow-y: auto;
}

.doc-builder-palette-label {
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 4px 8px;
}

.doc-palette-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    cursor: grab;
}

.doc-palette-item:hover {
    border-color: rgba(249, 115, 22, 0.4);
    background: rgba(249, 115, 22, 0.06);
}

.doc-palette-variable {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.74rem;
    color: #ea580c;
}

.doc-builder-hint {
    margin-top: 12px;
    color: #94a3b8;
    font-size: 0.74rem;
    line-height: 1.5;
    padding: 0 4px;
}

.doc-builder-canvas {
    padding: 16px;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.4), rgba(255, 255, 255, 0.95));
}

.doc-builder-empty {
    display: grid;
    place-items: center;
    min-height: 320px;
    border: 2px dashed rgba(203, 213, 225, 0.9);
    border-radius: 16px;
    color: #94a3b8;
    text-align: center;
    padding: 20px;
}

.doc-block-card {
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 10px;
    cursor: grab;
    transition: box-shadow 0.15s ease;
}

.doc-block-card.is-dragging {
    opacity: 0.4;
}

.doc-block-card.drop-before {
    box-shadow: 0 -3px 0 0 #ea580c;
}

.doc-block-card.drop-after {
    box-shadow: 0 3px 0 0 #ea580c;
}

.doc-block-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.doc-block-handle {
    font-size: 0.72rem;
    font-weight: 800;
    color: #94a3b8;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.doc-block-remove {
    border: 0;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
}

.doc-block-remove:hover {
    color: #ef4444;
}

.doc-block-input {
    width: 100%;
    border-radius: 10px;
}

.doc-block-variable-badge {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(249, 115, 22, 0.1);
    color: #c2410c;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.82rem;
    font-weight: 700;
}

/* ============ Pełnoekranowy kreator szablonu (jak edytor dokumentów, z podglądem na żywo) ============ */
.doc-shell {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.doc-shell-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    flex-shrink: 0;
}

.doc-shell-header-fields {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.doc-shell-name-input {
    flex: 1;
    max-width: 420px;
    border: 0;
    outline: none;
    padding: 8px 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    border-bottom: 2px solid transparent;
}

.doc-shell-name-input:focus {
    border-bottom-color: rgba(249, 115, 22, 0.6);
}

.doc-shell-type-select {
    width: auto;
    padding: 8px 14px;
}

.doc-shell-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.doc-shell-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 24px;
    background: rgba(248, 250, 252, 0.9);
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    flex-shrink: 0;
}

.doc-shell-body {
    flex: 1;
    min-height: 0;
}

.doc-shell-pane {
    height: 100%;
}

.doc-shell-pane-visual {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1fr);
    height: 100%;
}

.doc-shell-pane-visual .doc-builder-palette {
    border-right: 1px solid rgba(226, 232, 240, 0.95);
    overflow-y: auto;
    height: 100%;
}

.doc-shell-pane-visual .doc-builder-canvas {
    height: 100%;
    border-right: 1px solid rgba(226, 232, 240, 0.95);
}

.doc-shell-preview {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f1f5f9;
}

.doc-shell-preview-label {
    padding: 12px 20px;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    background: #fff;
    flex-shrink: 0;
}

.doc-preview-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.doc-preview-page {
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    padding: 56px 64px;
    border-radius: 4px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
    min-height: 400px;
    font-family: Arial, Helvetica, sans-serif;
    color: #1e293b;
    line-height: 1.7;
}

.doc-preview-page h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 16px;
    color: #0f172a;
}

.doc-preview-page h3 {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0 0 12px;
    color: #0f172a;
}

.doc-preview-page p {
    margin: 0 0 14px;
}

.doc-preview-page ul {
    margin: 0 0 14px;
    padding-left: 22px;
}

.doc-preview-page blockquote {
    margin: 0 0 14px;
    padding: 12px 18px;
    border-left: 3px solid #f97316;
    background: rgba(249, 115, 22, 0.06);
    color: #475569;
    font-style: italic;
}

.doc-preview-page hr {
    margin: 24px 0;
    border: 0;
    border-top: 1px solid #e2e8f0;
}

.doc-preview-variable-marker {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(249, 115, 22, 0.12);
    color: #c2410c;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85em;
}

.doc-preview-empty {
    color: #94a3b8;
    font-style: italic;
}

.doc-shell-html-textarea {
    height: calc(100% - 60px);
    margin: 24px;
    width: calc(100% - 48px);
    font-family: 'SFMono-Regular', Consolas, monospace;
}

@media (max-width: 1024px) {
    .doc-shell-pane-visual {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    .doc-shell-pane-visual .doc-builder-palette,
    .doc-shell-pane-visual .doc-builder-canvas {
        height: auto;
        max-height: 320px;
    }
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.sidebar-link {
    transition: all 0.2s ease;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    padding: 15px 24px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 18px 35px rgba(249, 115, 22, 0.24);
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(249, 115, 22, 0.28);
}

.voice-meter-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 16px;
    background: #fef2f2;
    border-bottom: 1px solid #fecaca;
    font-size: 12px;
    color: #7f1d1d;
}

.voice-meter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.voice-meter-interim {
    font-style: italic;
    color: #991b1b;
    min-height: 16px;
}

.voice-meter-icon {
    font-size: 14px;
}

.voice-meter-bar {
    width: 90px;
    height: 8px;
    border-radius: 999px;
    background: #fecaca;
    overflow: hidden;
    flex-shrink: 0;
}

.voice-meter-fill {
    height: 100%;
    width: 0%;
    background: #dc2626;
    border-radius: 999px;
    transition: width 80ms linear;
}

.voice-meter-status {
    color: #7f1d1d;
    font-weight: 600;
}

.btn-secondary.is-recording {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
    animation: btn-recording-pulse 1.4s ease-in-out infinite;
}

@keyframes btn-recording-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    padding: 14px 22px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.btn-secondary:hover,
.btn-ghost:hover {
    transform: translateY(-2px);
    border-color: rgba(148, 163, 184, 0.78);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 14px 20px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.14);
    color: #475569;
}

.badge-success {
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
}

.badge-accent {
    background: rgba(249, 115, 22, 0.12);
    color: var(--accent-strong);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.16);
    color: #92400e;
}

.badge-danger {
    background: rgba(220, 38, 38, 0.14);
    color: #b91c1c;
}

.table-shell {
    overflow: hidden;
}

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

.crm-table thead th {
    position: relative;
    padding: 13px 20px;
    text-align: left;
    vertical-align: middle;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(248, 250, 252, 0.92);
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

.crm-table tbody td {
    padding: 13px 20px;
    border-bottom: 1px solid rgba(241, 245, 249, 1);
    vertical-align: middle;
    font-size: 0.88rem;
    overflow-wrap: break-word;
}

.resizable-th {
    padding-right: 18px;
}

.col-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 10px;
    cursor: col-resize;
    z-index: 5;
}

.col-resize-handle::after {
    content: '';
    position: absolute;
    top: 20%;
    bottom: 20%;
    right: 4px;
    width: 2px;
    border-radius: 2px;
    background: rgba(148, 163, 184, 0.4);
}

.col-resize-handle:hover::after,
.is-resizing-column .col-resize-handle::after {
    background: #ea580c;
}

.is-resizing-column {
    cursor: col-resize !important;
    user-select: none;
}

.crm-table tbody tr {
    transition: background 0.2s ease, transform 0.2s ease;
}

.crm-table tbody tr:hover {
    background: rgba(248, 250, 252, 0.88);
}

/* Zaznaczanie wielu rekordów na liście (assets/js/bulk-select.js) - kolumna z checkboxami
   plus pływający pasek narzędzi pokazujący się, gdy coś jest zaznaczone. */
.bulk-select-col {
    width: 44px;
    text-align: center;
}

/* Generyczny modal wyśrodkowany na ekranie (moduł Poczty: kompozycja/stopka) - pierwsze użycie
   tego wzorca w projekcie, więc zdefiniowany tu od podstaw zamiast per-moduł. */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(3px);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modal-fade-in 0.15s ease;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-pop-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-box {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-pop-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.mail-body-frame {
    border-radius: 16px;
    overflow: hidden;
}

.mail-body-frame iframe {
    min-height: 200px;
}

/* Klient pocztowy (moduł Poczta) - toolbar, layout 3-kolumnowy, lista wiadomości, panel odczytu. */
.mail-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.mail-toolbar .btn-primary,
.mail-toolbar .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.mail-search {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
}

.mail-search input {
    flex: 1;
    border: 0;
    background: none;
    outline: none;
    font-size: 0.9rem;
    color: var(--text);
}

#mailSyncBtn.is-syncing svg {
    animation: mail-spin 0.8s linear infinite;
}

@keyframes mail-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mail-layout {
    display: grid;
    grid-template-columns: 210px 350px minmax(0, 1fr);
    gap: 16px;
    /* Ograniczenie wysokości MUSI działać czysto w CSS (nie tylko przez JS) - inaczej przy
       błędzie/braku JS-a lista wiadomości rośnie w nieskończoność i przewija się cała strona
       zamiast samego okna poczty. 92px topbar + 32px górny/dolny padding .page-shell + nagłówek
       strony i pasek narzędzi nad layoutem (~304px razem) - assets/js/poczta.js tylko DOPRECYZOWUJE
       tę wartość, gdy się wykona, ale strona jest bezpieczna nawet bez niego. */
    height: calc(100vh - 304px);
    min-height: 320px;
    max-height: 900px;
}

.mail-sidebar {
    background: #fff;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mail-folder-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mail-folder-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #475569;
    font-size: 0.88rem;
    font-weight: 600;
}

.mail-folder-link:hover {
    background: rgba(248, 250, 252, 0.95);
}

.mail-folder-link.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
}

.mail-folder-icon {
    display: inline-flex;
    flex-shrink: 0;
}

.mail-folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-folder-badge {
    background: rgba(15, 23, 42, 0.08);
    color: #334155;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
}

.mail-folder-link.is-active .mail-folder-badge {
    background: rgba(255, 255, 255, 0.28);
    color: #fff;
}

.mail-list-pane {
    background: #fff;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.mail-filter-bar {
    display: flex;
    gap: 8px;
    padding: 14px 16px;
    background: rgba(248, 250, 252, 0.6);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
}

.mail-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: 999px;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.mail-filter-chip:hover {
    border-color: rgba(249, 115, 22, 0.45);
    color: var(--accent-strong);
    transform: translateY(-1px);
}

.mail-filter-chip.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.35);
}

.mail-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.mail-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px 14px 13px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    border-left: 3px solid transparent;
    position: relative;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.mail-row:hover {
    background: rgba(248, 250, 252, 0.95);
}

.mail-row.is-unread {
    border-left-color: var(--accent);
    background: rgba(249, 115, 22, 0.03);
}

.mail-row.is-active {
    background: var(--accent-soft);
    border-left-color: var(--accent-strong);
}

.mail-row-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
}

.mail-avatar-lg {
    width: 46px;
    height: 46px;
    font-size: 1.1rem;
}

.mail-row-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mail-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mail-row-sender {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-row.is-unread .mail-row-sender,
.mail-row.is-unread .mail-row-subject {
    color: #0f172a;
    font-weight: 800;
}

.mail-row-date {
    font-size: 0.72rem;
    color: #94a3b8;
    flex-shrink: 0;
}

.mail-row-subject {
    font-size: 0.85rem;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-row-snippet {
    font-size: 0.78rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-row-tags {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

.mail-tag-icon {
    font-size: 0.75rem;
}

.mail-row-star {
    flex-shrink: 0;
    border: 0;
    background: none;
    color: #e2e8f0;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    padding: 2px;
}

.mail-row-star:hover {
    color: #cbd5e1;
}

.mail-row-star.is-flagged {
    color: #f59e0b;
}

.mail-reading-pane {
    background: #fff;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 26px;
    overflow-y: auto;
    min-height: 0;
}

.mail-empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #cbd5e1;
    text-align: center;
    padding: 40px;
}

.mail-read-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.mail-icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid transparent;
    background: none;
    color: #64748b;
    cursor: pointer;
}

.mail-icon-btn:hover {
    background: rgba(248, 250, 252, 0.95);
    border-color: var(--border);
}

.mail-icon-btn.is-active-icon {
    color: #f59e0b;
}

.mail-icon-danger:hover {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.25);
}

.mail-toolbar-sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 6px;
}

.mail-read-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}

/* Okno pisania/odpowiadania (modules/poczta/view.php #composeModal) - stylizowane na wzór
   nowoczesnych klientów pocztowych (Spark/Superhuman): pola bez ramek (tylko podkreślenie),
   pasek narzędzi z ikonami, chipy załączników z usuwaniem, dolny pasek z akcją wysyłki. */
.compose-box {
    max-width: 680px;
}

.compose-box form {
    padding: 22px 26px 20px;
}

.compose-field-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.compose-field-row label {
    flex-shrink: 0;
    width: 44px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
}

.compose-field-input {
    flex: 1;
    border: 0;
    outline: none;
    background: none;
    font-size: 0.92rem;
    color: var(--text);
    padding: 4px 0;
}

.compose-field-input::placeholder {
    color: #cbd5e1;
}

.compose-field-toggle {
    flex-shrink: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 999px;
}

.compose-field-toggle:hover {
    background: rgba(248, 250, 252, 0.95);
    color: var(--accent-strong);
}

.mail-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 3px;
    margin: 14px 0 8px;
}

.mail-editor-toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
}

.mail-editor-toolbar button {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid transparent;
    background: none;
    color: #64748b;
    cursor: pointer;
}

.mail-editor-toolbar button:hover {
    background: rgba(248, 250, 252, 0.95);
    border-color: var(--border);
    color: var(--accent-strong);
}

.mail-editor {
    min-height: 200px;
    max-height: 360px;
    overflow-y: auto;
    line-height: 1.6;
    font-size: 0.92rem;
    padding: 4px 2px;
}

.mail-editor:focus {
    outline: none;
}

.mail-editor:empty::before {
    content: 'Napisz wiadomość...';
    color: #cbd5e1;
}

.compose-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.compose-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(248, 250, 252, 0.95);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 8px 6px 10px;
    font-size: 0.78rem;
    color: #475569;
    max-width: 220px;
}

.compose-attachment-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compose-attachment-chip button {
    flex-shrink: 0;
    border: 0;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 2px;
}

.compose-attachment-chip button:hover {
    color: #ef4444;
}

.compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.compose-send-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 11px 26px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(249, 115, 22, 0.32);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.compose-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(249, 115, 22, 0.4);
}

.compose-attach-btn {
    cursor: pointer;
}

/* Menu kontekstowe (prawy przycisk myszy na wierszu wiadomości) - assets/js/poczta.js */
.mail-context-menu {
    position: fixed;
    z-index: 1000;
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    padding: 6px;
    min-width: 210px;
}

.mail-context-menu.hidden {
    display: none;
}

/* Atrybut hidden musi wygrywać z "display: block" przycisków (inaczej ukryte pozycje menu zostawały widoczne). */
.mail-context-menu [hidden] {
    display: none !important;
}

.mail-context-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border-radius: 8px;
    border: 0;
    background: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.mail-context-menu button:hover {
    background: rgba(248, 250, 252, 0.95);
}

.mail-context-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}

.mail-context-menu-danger {
    color: #ef4444 !important;
}

.mail-context-menu-danger:hover {
    background: rgba(239, 68, 68, 0.08) !important;
}

/* Poniżej 1025 px działa układ „telefon/tablet” (jedna kolumna, szuflada) - patrz sekcja POCZTA na końcu pliku; tu tylko węższe kolumny. */
@media (max-width: 1280px) {
    .mail-layout {
        grid-template-columns: 230px 300px minmax(0, 1fr);
    }
}

/* Siatka miesiąca w module Kalendarz (modules/kalendarz/view.php) */
.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.82rem;
    color: var(--muted);
}

.calendar-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.calendar-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    display: inline-block;
}

.calendar-dot-accent, .calendar-event-accent { background: var(--accent); }
.calendar-dot-neutral, .calendar-event-neutral { background: #94a3b8; }
.calendar-dot-success, .calendar-event-success { background: var(--success); }
.calendar-dot-danger, .calendar-event-danger { background: #ef4444; }
.calendar-dot-warning, .calendar-event-warning { background: #f59e0b; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.calendar-weekday {
    background: rgba(248, 250, 252, 0.9);
    padding: 10px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
}

.calendar-cell {
    background: #fff;
    min-height: 110px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.calendar-cell:hover {
    background: rgba(249, 115, 22, 0.05);
}

.calendar-cell.is-outside {
    background: rgba(248, 250, 252, 0.6);
    color: #cbd5e1;
}

.calendar-cell.is-outside .calendar-cell-date {
    color: #cbd5e1;
}

.calendar-cell.is-today {
    background: rgba(249, 115, 22, 0.08);
}

.calendar-cell-date {
    font-weight: 700;
    font-size: 0.85rem;
    color: #334155;
    margin-bottom: 6px;
}

.calendar-cell-events {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.calendar-event-chip {
    display: block;
    font-size: 0.72rem;
    padding: 3px 6px;
    border-radius: 6px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 900px) {
    .calendar-grid {
        grid-template-columns: repeat(7, minmax(36px, 1fr));
    }
    .calendar-cell {
        min-height: 70px;
        padding: 4px;
    }
    .calendar-event-chip {
        font-size: 0.62rem;
    }
}

.bulk-toolbar {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 14px;
    padding: 14px 20px;
    max-width: min(94vw, 760px);
    background: var(--surface-dark);
    color: #fff;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    font-size: 0.9rem;
}

.bulk-toolbar.hidden {
    display: none;
}

#bulkActionCount {
    font-weight: 700;
    white-space: nowrap;
    padding-left: 6px;
}

.bulk-toolbar-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.bulk-toolbar-label {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    white-space: nowrap;
}

.bulk-toolbar-select {
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: #1f2937;
    color: #fff;
    font-size: 0.85rem;
    max-width: 200px;
}

.bulk-toolbar-btn {
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.bulk-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.bulk-toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bulk-toolbar-btn-danger {
    background: #ef4444;
    border-color: #ef4444;
}

.bulk-toolbar-btn-danger:hover {
    background: #dc2626;
}

.bulk-toolbar-btn-accent {
    background: var(--accent);
    border-color: var(--accent);
}

.bulk-toolbar-btn-accent:hover {
    background: var(--accent-strong);
}

.sortable-th {
    cursor: pointer;
    user-select: none;
}

.sortable-th:hover {
    color: #ea580c;
}

.sort-arrow {
    display: inline-block;
    margin-left: 4px;
    color: #ea580c;
    font-size: 0.7rem;
}

/* Pasek narzędzi tabeli: szybki filtr + przycisk "Filtry" */
.crm-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 10px 24px;
    background: rgba(248, 250, 252, 0.7);
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

.crm-table-filter-anchor {
    position: relative;
}

.crm-table-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 12px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: #fff;
    color: #334155;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.crm-table-filter-btn:hover,
.crm-table-filter-btn.has-active {
    border-color: rgba(249, 115, 22, 0.5);
    color: #ea580c;
}

.crm-table-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ea580c;
    color: #fff;
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 800;
}

.crm-table-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 24px 0;
    background: rgba(248, 250, 252, 0.5);
}

.crm-table-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.1);
    color: #9a3412;
    font-size: 0.8rem;
}

.crm-table-chip strong {
    color: #7c2d12;
}

.crm-table-chip-remove {
    border: 0;
    background: transparent;
    color: #c2410c;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0;
    line-height: 1;
}

.crm-table-filter-popover {
    z-index: 65;
    width: min(320px, calc(100vw - 24px));
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
    padding: 16px;
}

.crm-table-filter-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.crm-table-filter-popover-header strong {
    color: #0f172a;
    font-size: 0.95rem;
}

.crm-table-filter-clear {
    border: 0;
    background: transparent;
    color: #ea580c;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.crm-table-filter-fields {
    display: grid;
    gap: 12px;
}

.crm-table-filter-field span {
    display: block;
    margin-bottom: 5px;
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.crm-table-filter-field input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    outline: none;
    font-size: 0.86rem;
}

.crm-table-filter-field input:focus,
.crm-table-filter-field select:focus {
    border-color: rgba(249, 115, 22, 0.6);
}

.crm-table-filter-field select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: #fff;
    outline: none;
    font-size: 0.86rem;
}

/* Zakres dat "od" / "do" (filtr kolumny z kalendarzem) */
.crm-table-filter-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.crm-table-filter-range label {
    display: block;
}

.crm-table-filter-range em {
    display: block;
    margin-bottom: 3px;
    color: #94a3b8;
    font-size: 0.7rem;
    font-style: normal;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.crm-table-filter-range input {
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    outline: none;
    font-size: 0.82rem;
}

/* Filtr kolumny z wielokrotnym wyborem: zwinięty pasek z podsumowaniem, lista dopiero po kliknięciu */
.crm-table-multi-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: #fff;
    font-size: 0.86rem;
    cursor: pointer;
    list-style: none;
}

.crm-table-multi-summary::-webkit-details-marker {
    display: none;
}

.crm-table-multi-summary b {
    font-weight: 500;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-table-multi-wrap.has-selection > .crm-table-multi-summary {
    border-color: rgba(249, 115, 22, 0.6);
    background: rgba(249, 115, 22, 0.06);
}

.crm-table-multi-summary::after {
    content: '';
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-right: 2px solid #94a3b8;
    border-bottom: 2px solid #94a3b8;
    transform: rotate(45deg) translateY(-2px);
}

.crm-table-multi-wrap[open] > .crm-table-multi-summary::after {
    transform: rotate(-135deg) translateY(-2px);
}

.crm-table-multi-wrap > .crm-table-multi {
    margin-top: 6px;
    max-height: 170px;
}

/* Filtr kolumny z wielokrotnym wyborem (checkboxy) */
.crm-table-multi {
    display: grid;
    gap: 2px;
    max-height: 190px;
    overflow-y: auto;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: #fff;
}

.crm-table-multi-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 8px;
    cursor: pointer;
}

.crm-table-multi-item:hover {
    background: rgba(248, 250, 252, 0.95);
}

.crm-table-filter-field .crm-table-multi-item input {
    width: auto;
    padding: 0;
    flex: 0 0 auto;
}

.crm-table-multi-item b {
    font-size: 0.84rem;
    font-weight: 600;
    color: #334155;
}

/* Lista wielokrotnego wyboru w lewym panelu filtrów (Zadania) */

.multi-filter details > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.multi-filter details > summary::-webkit-details-marker {
    display: none;
}

.multi-filter details > summary::after {
    content: '';
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid #94a3b8;
    border-bottom: 2px solid #94a3b8;
    transform: rotate(45deg) translateY(-2px);
}

.multi-filter details[open] > summary::after {
    transform: rotate(-135deg) translateY(-2px);
}

.multi-filter-list {
    /* Rozwija się w panelu (nie jako lista nad treścią), bo panel filtrów ma własne przewijanie. */
    margin-top: 6px;
    padding: 6px;
    border-radius: 14px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: #fff;
}

.multi-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 9px;
    font-size: 0.88rem;
    cursor: pointer;
}

.multi-filter-item:hover {
    background: rgba(248, 250, 252, 0.95);
}

/* --- Komunikacja (modules/komunikacja): oś czasu rozmów, SMS-ów, maili i wysyłek --- */
.comm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.comm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: #fff;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
}

.comm-chip em {
    font-style: normal;
    font-size: 0.74rem;
    color: #94a3b8;
}

.comm-chip.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

.comm-timeline {
    display: grid;
    gap: 10px;
}

.comm-day {
    margin-top: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.comm-item {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 14px;
    padding: 14px 18px;
    border-radius: 20px;
    background: var(--surface-strong);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.comm-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: rgba(100, 116, 139, 0.12);
    color: #475569;
}

.comm-ch-email .comm-icon { background: rgba(59, 130, 246, 0.14); color: #1d4ed8; }
.comm-ch-telefon .comm-icon { background: rgba(34, 197, 94, 0.15); color: #15803d; }
.comm-ch-sms .comm-icon { background: rgba(249, 115, 22, 0.16); color: #c2410c; }
.comm-ch-spotkanie .comm-icon { background: rgba(168, 85, 247, 0.15); color: #7e22ce; }
.comm-ch-newsletter .comm-icon,
.comm-ch-kampania_sms .comm-icon { background: rgba(236, 72, 153, 0.15); color: #be185d; }

.comm-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.comm-subject {
    font-size: 0.98rem;
    color: var(--text);
    overflow-wrap: anywhere;
}

.comm-time {
    flex: 0 0 auto;
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
}

.comm-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 5px;
    font-size: 0.8rem;
    color: #475569;
}

.comm-meta .material-symbols-outlined {
    font-size: 15px;
    vertical-align: -3px;
}

.comm-dir.is-in { color: #15803d; font-weight: 700; }
.comm-dir.is-out { color: #1d4ed8; font-weight: 700; }

.comm-link {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: none;
}

.comm-link:hover {
    text-decoration: underline;
}

.comm-text {
    margin: 8px 0 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: #334155;
    overflow-wrap: anywhere;
}

details.comm-text summary {
    cursor: pointer;
    list-style: none;
}

details.comm-text summary::-webkit-details-marker {
    display: none;
}

details.comm-text[open] summary {
    display: none;
}

.comm-more {
    color: var(--accent-strong);
    font-weight: 700;
}

.comm-next {
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(249, 115, 22, 0.08);
    font-size: 0.82rem;
    color: #9a3412;
}

.comm-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-top: 8px;
}

.comm-act {
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    text-decoration: none;
    cursor: pointer;
}

.comm-act:hover {
    color: var(--accent-strong);
}

.comm-act-danger:hover {
    color: #b91c1c;
}

.comm-assign .field-select {
    min-width: 220px;
}

.comm-code {
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.78rem;
    overflow-x: auto;
}

@media (max-width: 700px) {
    .comm-item {
        grid-template-columns: 1fr;
    }

    .comm-icon {
        width: 34px;
        height: 34px;
    }
}

/* Przewodnik po module finansowym (Dashboard finansowy) */
.finance-guide {
    padding: 18px 22px;
}

.finance-guide-summary {
    cursor: pointer;
    list-style: none;
    font-size: 1rem;
}

.finance-guide-summary::-webkit-details-marker {
    display: none;
}

.finance-guide-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 14px 0 6px;
}

.finance-guide-flow span {
    padding: 7px 12px;
    border-radius: 12px;
    background: rgba(249, 115, 22, 0.1);
    color: #9a3412;
    font-size: 0.84rem;
    font-weight: 700;
}

.finance-guide-flow span em {
    font-style: normal;
    font-weight: 500;
    opacity: 0.8;
}

.finance-guide-flow i {
    color: #94a3b8;
    font-style: normal;
    font-weight: 800;
}

.finance-guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 14px;
}

.finance-guide-group-title {
    margin-bottom: 8px;
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.finance-guide-item {
    display: block;
    margin-bottom: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.7);
    text-decoration: none;
}

.finance-guide-item:hover {
    border-color: rgba(249, 115, 22, 0.45);
}

.finance-guide-item strong {
    display: block;
    color: var(--text);
    font-size: 0.92rem;
}

.finance-guide-item span {
    display: block;
    margin-top: 2px;
    color: #475569;
    font-size: 0.82rem;
}

.finance-guide-item em {
    display: block;
    margin-top: 4px;
    color: #94a3b8;
    font-size: 0.78rem;
    font-style: normal;
}

/* Termin w liście zadań: stała minimalna szerokość, żeby data nie łamała się na kilka linii. */
.task-due-cell {
    min-width: 150px;
}

.task-due-inline {
    flex-direction: column;
    align-items: flex-start;
}

.task-due-inline .task-due-date,
.task-due-inline .task-due-rel {
    white-space: nowrap;
}

.table-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    color: var(--text);
}

/* Kompaktowe akcje w wierszu tabeli: jedna widoczna akcja + reszta pod "⋮" */
.table-actions-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.table-actions-row .table-action-primary {
    padding: 7px 14px !important;
    border-radius: 10px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    white-space: nowrap;
    box-shadow: none !important;
}

.table-action-menu {
    position: relative;
    flex-shrink: 0;
}

.table-action-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.9);
    background: #fff;
    color: #64748b;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.table-action-trigger:hover {
    border-color: rgba(249, 115, 22, 0.5);
    color: #ea580c;
}

.table-action-dropdown {
    z-index: 65;
    min-width: 170px;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.table-action-dropdown a,
.table-action-dropdown button,
.table-action-dropdown form {
    width: 100%;
}

.table-action-dropdown a,
.table-action-dropdown button {
    display: flex !important;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 9px 10px !important;
    border-radius: 10px !important;
    border: 0 !important;
    background: transparent !important;
    color: #334155;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    box-shadow: none !important;
    white-space: nowrap;
}

.table-action-dropdown a:hover,
.table-action-dropdown button:hover {
    background: rgba(248, 250, 252, 0.95) !important;
    transform: none !important;
}

.table-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.surface-split {
    display: grid;
    grid-template-columns: 1.35fr 0.85fr;
    gap: 24px;
}

.stack-card {
    padding: 28px;
}

.helper-list {
    display: grid;
    gap: 14px;
}

.helper-item {
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.95);
}

.helper-item strong {
    display: block;
    color: var(--text);
    margin-bottom: 6px;
}

.helper-item span {
    color: var(--muted);
    font-size: 0.92rem;
}

/* --- Pulpit (modules/dashboard/view.php): nagłówek ze skrótami + siatka okien (widgetów) 6-kolumnowa.
   Okna: small = 2/6, normal = 3/6, wide = 6/6 szerokości; użytkownik przeciąga je, dodaje/ukrywa, zmienia rozmiar i opcje. --- */
.dash-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.dash-head-text h1 {
    margin: 0;
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.dash-head-text p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.dash-head-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.dash-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: var(--surface-strong);
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.dash-chip b {
    color: var(--accent);
    font-size: 1.05rem;
    line-height: 1;
}

.dash-chip:hover {
    border-color: rgba(249, 115, 22, 0.5);
    color: var(--accent-strong);
}

.dash-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dash-edit-btn.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

.dash-editor {
    background: var(--surface-strong);
    border: 1px solid rgba(249, 115, 22, 0.35);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 22px 26px;
    margin-bottom: 18px;
    display: grid;
    gap: 18px;
}

.dash-editor-label {
    font-weight: 800;
    font-size: 0.92rem;
    color: var(--text);
    margin-bottom: 8px;
}

.dash-editor-label span {
    margin-left: 8px;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--muted);
}

.dash-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.dash-preset {
    text-align: left;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: rgba(248, 250, 252, 0.8);
    cursor: pointer;
}

.dash-preset:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.dash-preset strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text);
}

.dash-preset span {
    display: block;
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--muted);
}

.dash-checks,
.dw-setting-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.dash-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.86rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.dash-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.dash-gallery-card {
    text-align: left;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px dashed rgba(249, 115, 22, 0.5);
    background: rgba(249, 115, 22, 0.05);
    cursor: pointer;
}

.dash-gallery-card:hover {
    background: rgba(249, 115, 22, 0.12);
}

.dash-gallery-card strong {
    display: block;
    font-size: 0.88rem;
    color: var(--accent-strong);
}

.dash-gallery-card span,
.dash-gallery-empty {
    display: block;
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--muted);
}

.dash-editor-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.dash-editor-foot p {
    margin: 0;
    max-width: 560px;
    font-size: 0.82rem;
    color: var(--muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.dashboard-widget {
    grid-column: span 3;
    background: var(--surface-strong);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 20px 22px;
    min-width: 0;
    transition: box-shadow 0.2s ease, opacity 0.2s ease;
}

.dashboard-widget[data-size="small"] {
    grid-column: span 2;
}

.dashboard-widget[data-size="wide"] {
    grid-column: span 6;
}

.dashboard-widget[hidden],
.dashboard-widget[data-visible="0"],
.dashboard-widget[data-available="0"] {
    display: none;
}

.dashboard-editing .dashboard-widget[data-visible="0"][data-available="1"] {
    display: none; /* ukryte okna dodaje się z galerii "Dodaj okno" */
}

.dashboard-editing .dashboard-widget {
    cursor: grab;
    border-style: dashed;
    border-color: rgba(249, 115, 22, 0.45);
}

.dashboard-widget-dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.dashboard-widget-editbar {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: -6px -8px 14px;
    padding: 7px 10px;
    border-radius: 14px;
    background: rgba(249, 115, 22, 0.08);
    border: 1px dashed rgba(249, 115, 22, 0.35);
}

.dashboard-editing .dashboard-widget-editbar {
    display: flex;
}

.dashboard-widget-handle {
    cursor: grab;
    font-weight: 700;
    color: var(--muted);
}

.dashboard-widget-name {
    flex: 1;
    min-width: 80px;
    font-size: 0.74rem;
    font-weight: 800;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-widget-editbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.dw-size-group {
    display: inline-flex;
    gap: 2px;
    margin-right: 4px;
}

.dashboard-widget-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 9px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #fff;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
}

.dashboard-widget-btn:hover,
.dashboard-widget-btn.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

.dw-settings {
    display: grid;
    gap: 12px;
    margin: -4px 0 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.95);
}

.dw-setting-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.dw-placeholder {
    display: grid;
    gap: 4px;
    padding: 18px 4px;
    color: var(--muted);
    font-size: 0.86rem;
}

.dw-placeholder strong {
    color: var(--text);
}

/* Zawartość okien */
.dw-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.dw-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
}

.dw-link {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-strong);
    text-decoration: none;
    white-space: nowrap;
}

.dw-link:hover {
    text-decoration: underline;
}

.dw-sub {
    margin: -4px 0 10px;
    font-size: 0.86rem;
    color: #475569;
}

.dw-foot {
    margin: 12px 0 0;
    padding-top: 10px;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    font-size: 0.82rem;
}

.dw-list {
    display: grid;
    gap: 6px;
}

.dw-row {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 10px;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.8);
    text-decoration: none;
    color: inherit;
}

a.dw-row:hover {
    background: var(--accent-soft);
}

.dw-row-alert {
    background: rgba(220, 38, 38, 0.07);
    box-shadow: inset 3px 0 0 rgba(220, 38, 38, 0.6);
}

.dw-time {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #64748b;
    padding-top: 2px;
}

.dw-row-alert .dw-time {
    color: #b91c1c;
}

.dw-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.dw-main strong {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    overflow-wrap: anywhere;
}

.dw-main em {
    font-style: normal;
    font-size: 0.78rem;
    color: #64748b;
    overflow-wrap: anywhere;
}

.dw-empty {
    padding: 14px 6px;
    font-size: 0.88rem;
    color: var(--muted);
}

.dw-more {
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-strong);
    text-decoration: none;
}

.dw-action {
    margin-top: 12px;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid rgba(249, 115, 22, 0.4);
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 0.84rem;
    cursor: pointer;
}

.dw-action:hover {
    background: rgba(249, 115, 22, 0.2);
}

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

.dw-kpi {
    display: grid;
    gap: 3px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.9);
    text-decoration: none;
    color: inherit;
    border-top: 3px solid #cbd5e1;
}

.dw-kpi:hover {
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.dw-kpi-label {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.dw-kpi-value {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.dw-kpi-hint {
    font-size: 0.78rem;
    color: #64748b;
}

.dw-tone-ok {
    border-top-color: #22c55e;
}

.dw-tone-warn {
    border-top-color: #f59e0b;
}

.dw-tone-danger {
    border-top-color: #dc2626;
}

.dw-tone-danger .dw-kpi-value {
    color: #b91c1c;
}

.dw-bars {
    display: grid;
    gap: 8px;
}

.dw-bar-row {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    font-size: 0.82rem;
}

.dw-bar-label {
    font-weight: 700;
    color: var(--text);
}

.dw-bar-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(226, 232, 240, 0.8);
    overflow: hidden;
}

.dw-bar-track i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #fb923c, #f97316);
}

.dw-bar-value {
    font-weight: 700;
    color: #475569;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .dw-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dw-kpi-value {
        font-size: 1.35rem;
    }

    .dw-bar-row {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .dw-bar-value {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1100px) {
    .dashboard-widget[data-size="small"],
    .dashboard-widget {
        grid-column: span 3;
    }

    .dashboard-widget[data-size="wide"] {
        grid-column: span 6;
    }
}

/* --- Moduł Zadania (modules/zadania) - tablica Kanban w stylu Jiry + karty projektów --- */
.zadania-view-tabs {
    display: flex;
    gap: 4px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 14px;
    padding: 4px;
}

.zadania-view-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

.zadania-view-tab.active {
    background: var(--surface-strong);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}

/* Układ modułu: lewy panel filtrów + treść (tablica / lista / projekty / archiwum). */
.zadania-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

/* Pasek widoków i akcji (Tablica / Lista / Projekty, Nowe zadanie...) zostaje na górze podczas przewijania. */
.zadania-toolbar {
    position: sticky;
    top: 104px; /* pod stałym paskiem górnym aplikacji (92 px) */
    z-index: 35;
}

.zadania-filters {
    position: sticky;
    top: calc(116px + var(--zadania-toolbar-h, 76px)); /* pod paskiem górnym i paskiem widoków */
    max-height: calc(100vh - 132px - var(--zadania-toolbar-h, 76px));
    overflow-y: auto;
}

.kanban-lane-title-link:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

/* "Wyczyść filtry" jest zawsze widoczny, ale przygaszony, gdy nie ma czego czyścić. */
.zadania-clear-idle {
    opacity: 0.55;
}

.zadania-layout-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.zadania-layout-toggle a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 34px;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
}

.zadania-layout-toggle a:hover {
    color: var(--text);
}

.zadania-layout-toggle a.active {
    background: var(--surface-strong);
    color: var(--accent-strong);
    box-shadow: var(--shadow-lg);
}

.task-card-link {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-meta-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.task-card-link .material-symbols-outlined,
.task-meta-icon .material-symbols-outlined {
    font-size: 16px;
}

.zadania-hidden-note {
    background: rgba(249, 115, 22, 0.08);
    border: 1px solid rgba(249, 115, 22, 0.25);
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #7c2d12;
}

.zadania-hidden-note a {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: underline;
    margin-left: 6px;
}

/* Tablica per projekt (jak w Jirze): pas z nagłówkiem projektu i czterema kolumnami statusu. */
.kanban-lane {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-lg);
    padding: 12px 14px 14px;
}

.kanban-lane-header {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    list-style: none;
    padding: 6px 10px;
    margin-bottom: 10px;
    border-left: 4px solid #cbd5e1;
    border-radius: 6px;
    user-select: none;
}

.kanban-lane-header::-webkit-details-marker {
    display: none;
}

.kanban-lane-chevron {
    display: inline-flex;
    transition: transform 0.15s ease;
    color: var(--muted);
}

.kanban-lane:not([open]) .kanban-lane-chevron {
    transform: rotate(-90deg);
}

.kanban-lane:not([open]) .kanban-lane-header {
    margin-bottom: 0;
}

.kanban-lane-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    flex-shrink: 0;
}

.kanban-lane-title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text);
}

.kanban-lane-meta {
    font-size: 0.78rem;
    color: var(--muted);
}

.kanban-lane-edit {
    display: inline-flex;
    color: var(--muted);
}

.kanban-lane-edit:hover {
    color: var(--accent-strong);
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(200px, 1fr));
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 6px;
    align-items: start;
}

.kanban-column {
    background: rgba(241, 245, 249, 0.7);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-lg);
    padding: 12px;
    max-height: 620px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    padding: 4px 6px 12px;
}

.kanban-column-count {
    background: rgba(148, 163, 184, 0.2);
    color: var(--muted);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.78rem;
    font-weight: 700;
}

.kanban-column-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 60px;
}

.kanban-empty-hint {
    border: 1px dashed rgba(148, 163, 184, 0.4);
    border-radius: 14px;
    padding: 20px 10px;
    text-align: center;
    color: var(--muted);
    font-size: 0.82rem;
}

.task-card {
    display: block;
    background: var(--surface-strong);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-left: 4px solid #94a3b8;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: var(--shadow-lg);
    cursor: grab;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.task-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-xl);
}

.task-card-dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.task-card-project {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 6px;
}

.task-card-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text);
    margin-bottom: 4px;
}

.task-card-link {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 8px;
}

.task-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    color: var(--muted);
}

.task-card-priority {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    display: inline-block;
}

/* Termin - wyraźnie wyodrębniony (jak w Jirze): etykieta, duża data i informacja "za ile dni". */
.task-due {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 6px 10px;
    margin: 2px 0 8px;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.14);
    color: #334155;
    font-size: 0.82rem;
}

.task-due .material-symbols-outlined {
    font-size: 18px;
}

.task-due-label {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.75;
}

.task-due-date {
    font-size: 0.95rem;
    font-weight: 800;
}

.task-due-rel {
    font-size: 0.74rem;
    font-weight: 700;
    opacity: 0.85;
}

.task-due.is-overdue {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.task-due.is-today {
    background: rgba(249, 115, 22, 0.16);
    color: #c2410c;
}

.task-due.is-soon {
    background: rgba(245, 158, 11, 0.16);
    color: #92400e;
}

.task-due.is-done {
    background: rgba(34, 197, 94, 0.12);
    color: #166534;
}

.task-due-inline {
    display: inline-flex;
    margin: 0;
    padding: 4px 10px;
}

.task-due-lg {
    display: inline-flex;
    padding: 8px 14px;
}

.task-due-lg .task-due-date {
    font-size: 1.1rem;
}

.task-card-avatar {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.68rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-card {
    background: var(--surface-strong);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-top: 4px solid #6366f1;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 20px;
}

.project-progress-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    overflow: hidden;
}

.project-progress-fill {
    height: 100%;
    border-radius: 999px;
}

@media (max-width: 900px) {
    .zadania-toolbar {
        position: static;
    }
}

@media (max-width: 1100px) {
    .zadania-filters {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 1100px) {
    .zadania-layout {
        grid-template-columns: 1fr;
    }

    .zadania-filters {
        position: static;
    }
}

@media (max-width: 900px) {
    .kanban-board {
        grid-template-columns: repeat(4, 82vw);
    }

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

    .dashboard-widget,
    .dashboard-widget[data-size="small"],
    .dashboard-widget[data-size="wide"] {
        grid-column: span 1;
    }

    .dash-head-text h1 {
        font-size: 1.5rem;
    }
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 14px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 0.92rem;
    color: rgba(226, 232, 240, 0.72);
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(249, 115, 22, 0.08));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.26);
}

.sidebar-link-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Material Symbols (fonts.google.com/icons) - zamiast emoji w nawigacji, spójniejszy,
   "biznesowy" wygląd niezależny od tego, jak dany emoji renderuje się na czyimś systemie. */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Czcionka ikon jeszcze się nie wczytała albo jest zablokowana: nie pokazujemy nazw ikon jako tekstu (patrz skrypt w index.php). */
html.icons-pending .material-symbols-outlined,
html.icons-failed .material-symbols-outlined {
    display: inline-block;
    width: 1em;
    max-width: 1em;
    overflow: hidden;
    color: transparent !important;
    -webkit-text-fill-color: transparent;
}

.sidebar-link.active .sidebar-link-icon {
    background: rgba(249, 115, 22, 0.22);
}

.sidebar-groups {
    display: grid;
    gap: 6px;
}

.sidebar-group {
    border-radius: 18px;
}

.sidebar-group-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    list-style: none;
    color: rgba(148, 163, 184, 0.92);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    user-select: none;
}

.sidebar-group-summary::-webkit-details-marker {
    display: none;
}

.sidebar-group-chevron {
    transition: transform 0.18s ease;
    flex-shrink: 0;
}

.sidebar-group[open] .sidebar-group-chevron {
    transform: rotate(180deg);
}

.sidebar-group-links {
    display: grid;
    gap: 4px;
    padding-bottom: 4px;
}

/* Mobile drill-down: domyślnie ukryty (desktop pokazuje akordeon .sidebar-groups-desktop),
   włączany w media query poniżej. Panele są ułożone jeden na drugim (grid, ta sama komórka)
   i przełączane klasą .active + krótkim fade-in, żeby "przejście" wyglądało jak zmiana ekranu. */
.sidebar-mobile-nav {
    display: none;
}

.sidebar-pane {
    display: none;
    grid-area: 1 / 1;
    padding: 4px 16px 16px;
}

.sidebar-pane.active {
    display: block;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.sidebar-pane.active.fade-in {
    opacity: 1;
}

.sidebar-category-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 12px;
    border: 0;
    background: transparent;
    color: rgba(226, 232, 240, 0.85);
    font: inherit;
    text-align: left;
    border-radius: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-category-row.active {
    color: #fff;
}

.sidebar-category-row.active .sidebar-category-label {
    color: var(--accent);
}

.sidebar-category-label {
    flex: 1;
    font-weight: 700;
}

.sidebar-category-chevron {
    color: rgba(148, 163, 184, 0.7);
    font-size: 1.3rem;
    line-height: 1;
}

.sidebar-pane-back {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    border: 0;
    background: transparent;
    color: #fff;
    font: inherit;
    font-weight: 800;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-pane-back-arrow {
    font-size: 1.4rem;
    line-height: 1;
    color: var(--accent);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.14);
}

.account-card-wrap {
    position: relative;
}

button.account-card {
    cursor: pointer;
    font: inherit;
    -webkit-appearance: none;
}

.account-menu-caret {
    color: var(--muted);
    font-size: 0.7rem;
    margin-left: -4px;
}

/* Pudełko menu zaczyna się DOKŁADNIE na dole przycisku (top: 100%, zero przerwy) - dzięki temu
   nie ma "martwej strefy" między przyciskiem a menu, przez którą kursor jadący w dół zrywałby
   :hover na .account-card-wrap (co wcześniej zamykało menu, zanim dojechał do jego zawartości).
   Wizualny odstęp od przycisku jest tylko przezroczystym paddingiem TEGO pudełka - realna,
   klikalna/najeżdżalna powierzchnia jest więc ciągła od przycisku aż do samej karty menu. */
.account-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 220px;
    padding-top: 8px;
    z-index: 120;
}

.account-dropdown-inner {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.account-card-wrap:hover .account-dropdown,
.account-card-wrap.is-open .account-dropdown {
    display: block;
}

.account-dropdown-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
    padding: 6px 10px 2px;
}

.account-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border-radius: 10px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}

.account-dropdown-item:hover {
    background: var(--bg-deep);
}

.account-dropdown-item.is-active {
    font-weight: 700;
    color: var(--accent-strong);
}

.account-dropdown-item.is-danger {
    color: #dc2626;
}

.account-dropdown-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 2px;
}

.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(18px);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.08);
    padding: 6px max(6px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right));
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    padding: 6px 4px;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font: inherit;
    border-radius: 14px;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.bottom-nav-label {
    font-size: 0.66rem;
    font-weight: 700;
}

.bottom-nav-item.active {
    color: var(--accent-strong);
}

/* Przełącznik globalnego rozmiaru czcionki (S/M/L) w headerze */
.text-scale-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.95);
}

.text-scale-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-weight: 800;
    cursor: pointer;
    line-height: 1;
}

.text-scale-option[data-size="small"] {
    font-size: 0.72rem;
}

.text-scale-option[data-size="medium"] {
    font-size: 0.86rem;
}

.text-scale-option[data-size="large"] {
    font-size: 1rem;
}

.text-scale-option:hover {
    color: #334155;
}

.text-scale-option.active {
    background: #fff;
    color: #ea580c;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 20px;
    align-items: stretch;
}

.hero-note {
    padding: 22px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-note strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 8px;
}

.hero-note p {
    margin: 0;
    color: rgba(226, 232, 240, 0.82);
}

/* ============ Kompaktowy nagłówek strony (zastępuje duży baner + "metryki" bez danych) ============ */
.page-header-compact {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 18px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.page-header-compact-text {
    min-width: 0;
}

.eyebrow-sm {
    display: inline-block;
    color: var(--accent-strong);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.page-header-compact-text h1 {
    margin: 0;
    color: var(--text);
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1.25;
}

.page-header-compact-text p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    max-width: 640px;
}

.page-header-compact-side {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.page-header-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 14px;
    border-radius: 14px;
    background: rgba(148, 163, 184, 0.1);
    min-width: 64px;
}

.stat-chip strong {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-chip span {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
}

.login-shell::before,
.login-shell::after {
    content: '';
    position: fixed;
    border-radius: 999px;
    filter: blur(18px);
    pointer-events: none;
}

.login-shell::before {
    width: 260px;
    height: 260px;
    top: 8%;
    left: 10%;
    background: rgba(249, 115, 22, 0.2);
}

.login-shell::after {
    width: 320px;
    height: 320px;
    right: 8%;
    bottom: 8%;
    background: rgba(59, 130, 246, 0.16);
}

.login-layout {
    width: min(1100px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 24px;
    align-items: stretch;
}

.login-brand {
    padding: 42px;
    border-radius: 36px;
    background: linear-gradient(155deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

.login-brand::after {
    content: '';
    position: absolute;
    inset: auto -80px -120px auto;
    width: 280px;
    height: 280px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.22);
}

.login-card {
    padding: 42px;
    border-radius: 36px;
}

.login-card-mobile-brand {
    display: none;
}

.message-success,
.message-error,
.message-info {
    padding: 16px 18px;
    border-radius: 18px;
    margin-bottom: 24px;
    font-weight: 700;
}

.message-success {
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
    border: 1px solid rgba(22, 163, 74, 0.18);
}

.message-error {
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.16);
}

.message-info {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, 0.16);
}

.chat-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 999px;
    border: 0;
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: #fff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.chat-fab:hover {
    transform: translateY(-2px);
}

.chat-fab.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-style: normal;
    font-size: 0.75rem;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.4);
    border: 2px solid #fff;
}

.chat-scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 68;
}

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

/* Panel dokowany z prawej krawędzi ekranu, pełna wysokość - wysuwa się transformem translateX */
.chat-panel-v2 {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(400px, 100vw);
    background: #fff;
    border-left: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: -24px 0 60px rgba(15, 23, 42, 0.18);
    z-index: 70;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.26s ease;
}

.chat-panel-v2.is-open {
    transform: translateX(0);
}

.chat-panel-v2-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    flex-shrink: 0;
}

.chat-panel-v2-title {
    flex: 1;
    min-width: 0;
}

.chat-panel-v2-title strong {
    display: block;
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-panel-v2-title span {
    display: block;
    color: #64748b;
    font-size: 0.78rem;
    margin-top: 2px;
}

.chat-panel-v2-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.chat-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    background: rgba(248, 250, 252, 0.9);
    color: #334155;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-icon-btn:hover {
    background: rgba(249, 115, 22, 0.1);
    border-color: rgba(249, 115, 22, 0.3);
    color: #ea580c;
}

.chat-view-v2 {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-search-box {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    flex-shrink: 0;
}

.chat-search-box input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    background: rgba(248, 250, 252, 0.9);
    outline: none;
}

.chat-search-box input:focus {
    border-color: rgba(249, 115, 22, 0.6);
}

.chat-thread-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 10px 16px;
}

.chat-thread-section-label {
    padding: 14px 10px 6px;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chat-thread-list-v2 {
    display: grid;
    /* minmax(0, 1fr): bez tego kolumna rosła do szerokości najdłuższego podglądu wiadomości (np. długiej wiadomości ze
       Slacka) i wypychała kropkę "nieprzeczytane" poza widoczny panel. */
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
}

.chat-thread-v2.is-unread .chat-thread-v2-body strong {
    font-weight: 800;
}

.chat-thread-v2.is-unread .chat-thread-v2-preview {
    color: #475569;
    font-weight: 600;
}

.chat-thread-v2.is-unread {
    background: rgba(249, 115, 22, 0.07);
}

.chat-thread-empty {
    padding: 10px;
    color: #94a3b8;
    font-size: 0.85rem;
}

.chat-thread-v2 {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 10px;
    border-radius: 14px;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.chat-thread-v2:hover {
    background: rgba(248, 250, 252, 0.95);
}

.chat-thread-v2.active {
    background: rgba(249, 115, 22, 0.1);
}

.chat-thread-v2-avatar {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.06);
    color: #334155;
    font-weight: 800;
}

.chat-avatar-group {
    background: rgba(249, 115, 22, 0.14);
    color: #c2410c;
}

.chat-thread-v2-body {
    flex: 1;
    min-width: 0;
}

.chat-thread-v2-body strong {
    display: block;
    color: #0f172a;
    font-size: 0.92rem;
}

.chat-thread-v2-preview {
    display: block;
    margin-top: 2px;
    color: #94a3b8;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-thread-v2-dot {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #f97316;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.18);
}

.chat-messages-v2 {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.5), rgba(255, 255, 255, 0.95));
    display: flex;
    flex-direction: column;
}

.chat-bubble-row-v2 {
    display: flex;
    margin-bottom: 10px;
}

.chat-bubble-row-v2.is-own {
    justify-content: flex-end;
}

.chat-bubble-v2 {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.chat-bubble-row-v2.is-own .chat-bubble-v2 {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.16), rgba(255, 255, 255, 0.98));
    border-color: rgba(249, 115, 22, 0.2);
}

.chat-bubble-v2-sender {
    display: block;
    margin-bottom: 3px;
    color: #ea580c;
    font-size: 0.75rem;
    font-weight: 800;
}

.chat-bubble-v2 p {
    margin: 0;
    color: #0f172a;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble-v2-time {
    display: block;
    margin-top: 4px;
    color: #94a3b8;
    font-size: 0.7rem;
}

.chat-empty-state-v2 {
    margin: auto;
    color: #94a3b8;
    text-align: center;
    padding: 20px;
}

.chat-composer-v2 {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid rgba(226, 232, 240, 0.95);
    background: #fff;
    flex-shrink: 0;
}

#chatEmojiBtn {
    font-size: 1.15rem;
    line-height: 1;
}

.chat-emoji-picker {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 72px;
    z-index: 20;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 10px;
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
}

.chat-emoji-item {
    border: 0;
    background: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 6px 0;
    border-radius: 8px;
}

.chat-emoji-item:hover {
    background: rgba(249, 115, 22, 0.12);
}

.chat-composer-v2 textarea {
    flex: 1;
    resize: none;
    max-height: 120px;
    padding: 10px 14px;
    border-radius: 16px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}

.chat-composer-v2 textarea:focus {
    border-color: rgba(249, 115, 22, 0.6);
}

.chat-send-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 0;
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-compose-form {
    padding: 18px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-member-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.chat-member-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.95);
    color: #334155;
}

.chat-attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 16px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.25);
    font-size: 0.82rem;
    color: #9a3412;
}

.chat-attachment-preview button {
    border: 0;
    background: none;
    color: #9a3412;
    cursor: pointer;
    font-weight: 700;
    flex-shrink: 0;
}

.chat-attachment-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.95);
    text-decoration: none;
    color: inherit;
}

.chat-attachment-chip-icon {
    font-size: 1.2rem;
}

.chat-attachment-chip-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-attachment-chip-body strong {
    font-size: 0.82rem;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment-chip-body span {
    font-size: 0.7rem;
    color: #94a3b8;
}

.chat-attachment-image {
    display: block;
    margin-bottom: 6px;
}

.chat-attachment-image img {
    max-width: 220px;
    max-height: 220px;
    border-radius: 12px;
    display: block;
}

.chat-settings-panel {
    padding: 18px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-settings-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.95);
    cursor: pointer;
}

.chat-settings-toggle input {
    margin-top: 3px;
    flex-shrink: 0;
}

.chat-settings-toggle strong {
    display: block;
    color: #0f172a;
    font-size: 0.9rem;
}

.chat-settings-hint {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 0.78rem;
}


@media (max-width: 1280px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .surface-split,
    .hero-grid,
    .login-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        left: -292px;
        z-index: 50;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-mobile-close {
        display: flex;
    }

    .sidebar-groups-desktop {
        display: none;
    }

    .sidebar-mobile-nav {
        display: grid;
    }

    .sidebar-intro,
    .sidebar-footer-note {
        display: none;
    }

    .logo-container {
        padding: 18px 20px 16px;
    }

    .logo-container img {
        height: 40px;
    }

    .topbar,
    .main-content {
        left: 0;
        margin-left: 0;
    }

    .main-content {
        padding-bottom: 76px;
    }

    .bottom-nav {
        display: flex;
    }

    .page-shell {
        padding: 22px;
    }

    .chat-fab {
        bottom: 84px;
    }

    .chat-panel-v2 {
        width: min(360px, 100vw);
    }
}

@media (max-width: 768px) {
    /* Tekst na telefonie nie musi być tak duży jak na desktopie - skalujemy globalnie przez rem
       (ten sam mechanizm co przełącznik rozmiaru czcionki w headerze). Tailwind (px-8, gap-4 itd.)
       też liczy w rem, więc to samo automatycznie zmniejsza odstępy/marginesy w całym serwisie,
       nie tylko tekst - stąd "wszystko mieści się" bez poprawiania każdego komponentu z osobna. */
    html {
        font-size: 87%;
    }

    .topbar {
        height: auto;
        min-height: 64px;
    }

    .main-content {
        padding-top: 64px;
    }

    /* Przełącznik rozmiaru czcionki i opis konta to drugorzędne, "desktopowe" elementy -
       na telefonie zostaje sam tytuł i awatar z wylogowaniem (hamburger jest już tylko
       w dolnym pasku, nie duplikujemy go w headerze). */
    .text-scale-switch,
    .account-card-detail {
        display: none;
    }

    .account-card {
        padding: 6px 10px;
        gap: 8px;
    }

    .page-shell {
        padding: 14px;
    }

    .page-hero,
    .stack-card,
    .card,
    .login-brand,
    .login-card {
        padding: 18px;
        border-radius: 20px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 12px 18px;
        border-radius: 14px;
    }

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

    .crm-table tbody tr {
        padding: 14px;
    }

    .crm-table thead {
        display: none;
    }

    .crm-table,
    .crm-table tbody,
    .crm-table tr,
    .crm-table td {
        display: block;
        width: 100%;
    }

    .crm-table tbody td {
        padding: 8px 0;
        border-bottom: 0;
    }

    .crm-table tbody td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        color: #94a3b8;
        font-size: 0.75rem;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .chat-fab {
        right: 16px;
        bottom: 84px;
        width: 52px;
        height: 52px;
    }

    .chat-panel-v2 {
        width: 100vw;
    }

    .chat-member-grid {
        grid-template-columns: 1fr;
    }

    /* Logowanie na telefonie: tylko to, co potrzebne żeby się zalogować - bez hero/marketingu. */
    .login-shell {
        padding: 0;
        min-height: 100dvh;
        align-items: stretch;
    }

    .login-shell::before,
    .login-shell::after {
        display: none;
    }

    .login-layout {
        width: 100%;
        min-height: 100dvh;
        display: flex;
        align-items: center;
    }

    .login-brand {
        display: none;
    }

    .login-card {
        width: 100%;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 32px 24px;
        border-radius: 0;
        box-shadow: none;
        margin: 0 auto;
    }

    .login-card .eyebrow,
    .login-card p.muted {
        display: none;
    }

    .login-card h2 {
        font-size: 1.6rem;
        margin-bottom: 20px;
    }

    .login-card-mobile-brand {
        display: block;
        text-align: center;
        margin-bottom: 18px;
    }
}

/* Małe telefony - jeszcze ciaśniej, żeby nic się nie ucinało na wąskich ekranach. */
@media (max-width: 400px) {
    html {
        font-size: 82%;
    }

    .page-shell {
        padding: 10px;
    }

    .page-hero,
    .stack-card,
    .card {
        padding: 14px;
        border-radius: 18px;
    }
}

/* Nawigacja i zapis formularzy przez AJAX (assets/js/ajax-nav.js) - brak przeładowania strony */
body.is-ajax-navigating #mainContent {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

button.is-ajax-loading,
input.is-ajax-loading {
    opacity: 0.6;
    cursor: wait;
}

/* Moduł Notatki (modules/notatki) - pełnoszerokościowa lista, edytor pod przyciskiem "+ Nowa" (jak reszta modułów) */
.notes-editor-wrap {
    min-height: 60vh;
}

/* Kliknięcie "Rysunek" podmienia edytor tekstu na warstwę rysowania w tym samym miejscu
   (zamiast dokładać kolejny panel pod spodem) - pełny ekran dotyczy wyłącznie rysowania. */
#noteDrawingPanel {
    flex-direction: column;
}

.note-draw-canvas {
    width: 100%;
    height: 420px;
    touch-action: none;
    display: block;
}

#noteDrawingPanel.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 260;
    background: #fff;
    border-radius: 0;
}

#noteDrawingPanel.is-fullscreen .note-draw-canvas-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#noteDrawingPanel.is-fullscreen .note-draw-canvas {
    flex: 1;
    height: auto;
    min-height: 0;
}

li.note-todo {
    list-style: none;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
}

li.note-todo::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.2em;
    width: 16px;
    height: 16px;
    border: 2px solid #94a3b8;
    border-radius: 5px;
    background: #fff;
}

li.note-todo[data-checked="1"] {
    color: #94a3b8;
    text-decoration: line-through;
}

li.note-todo[data-checked="1"]::before {
    background: #f97316;
    border-color: #f97316;
    content: '✓';
    color: #fff;
    font-size: 11px;
    line-height: 14px;
    text-align: center;
}

/* ============================================================
   Moduł "Wymiana plików" - siatka kafelków w stylu Dropbox/Explorer,
   z przeciąganiem, menu kontekstowym i podglądem plików.
   ============================================================ */

.pliki-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pliki-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
}

.pliki-breadcrumbs a {
    font-weight: 700;
    color: var(--muted);
}

.pliki-breadcrumbs a:hover,
.pliki-breadcrumbs a.is-current {
    color: var(--accent-strong);
}

.pliki-breadcrumbs .sep {
    color: #cbd5e1;
}

.pliki-actions {
    display: flex;
    gap: 10px;
}

.pliki-dropzone {
    position: relative;
    border-radius: var(--radius-lg);
    min-height: 220px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.pliki-dropzone.is-drag-active {
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 2px dashed var(--accent);
    outline: 2px dashed var(--accent);
    outline-offset: -8px;
}

.pliki-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 14px;
    padding: 22px;
}

.pliki-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 10px;
    border-radius: 20px;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    user-select: none;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.pliki-tile:hover {
    background: rgba(248, 250, 252, 0.9);
    border-color: var(--border);
}

.pliki-tile.is-dragging {
    opacity: 0.4;
}

.pliki-tile.is-dragover {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: scale(1.04);
}

.pliki-tile-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    border-radius: 18px;
    background: linear-gradient(155deg, rgba(249, 115, 22, 0.14), rgba(249, 115, 22, 0.05));
}

.pliki-tile.is-folder .pliki-tile-icon {
    background: linear-gradient(155deg, rgba(249, 115, 22, 0.22), rgba(249, 115, 22, 0.08));
}

.pliki-tile-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    max-width: 128px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pliki-tile-meta {
    font-size: 0.7rem;
    color: var(--muted);
}

.pliki-tile-badge {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent-strong);
    background: var(--accent-soft);
    padding: 2px 8px;
    border-radius: 999px;
}

.pliki-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

/* Menu kontekstowe (prawy klik) */
.pliki-context-menu {
    position: fixed;
    z-index: 200;
    min-width: 200px;
    background: var(--surface-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    padding: 6px;
    display: none;
}

.pliki-context-menu.is-open {
    display: block;
}

.pliki-context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    background: transparent;
    border-radius: 12px;
    font: inherit;
    font-weight: 600;
    font-size: 0.88rem;
    text-align: left;
    color: var(--text);
}

.pliki-context-menu-item:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.pliki-context-menu-item.is-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.pliki-context-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
}

/* Podgląd pliku */
.pliki-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 210;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.pliki-preview-overlay.is-open {
    display: flex;
}

.pliki-preview-modal {
    width: min(1000px, 100%);
    height: min(85vh, 900px);
    background: var(--surface-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pliki-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.pliki-preview-title {
    font-weight: 800;
    font-size: 1.05rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pliki-preview-body {
    flex: 1;
    overflow: auto;
    background: #f8fafc;
    position: relative;
}

.pliki-preview-body iframe,
.pliki-preview-body img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 0;
}

.pliki-preview-body .docx-preview-container {
    background: #fff;
    padding: 24px;
}

.pliki-preview-textarea {
    width: 100%;
    height: 100%;
    border: 0;
    resize: none;
    padding: 20px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85rem;
    background: #fff;
}

.pliki-preview-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
}

.pliki-preview-unsupported {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 14px;
    color: var(--muted);
    text-align: center;
    padding: 40px;
}

.pliki-upload-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: var(--surface-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 220;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pliki-upload-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border);
    font-weight: 800;
    font-size: 0.9rem;
}

.pliki-upload-panel-close {
    cursor: pointer;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    background: none;
    border: 0;
    padding: 0 2px;
}

.pliki-upload-panel-close:hover {
    color: var(--text);
}

.pliki-upload-list {
    max-height: 280px;
    overflow-y: auto;
    padding: 10px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pliki-upload-row-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.82rem;
    margin-bottom: 5px;
}

.pliki-upload-row-name .pliki-upload-row-filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pliki-upload-row-status {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.pliki-upload-row.is-done .pliki-upload-row-status {
    color: var(--success);
}

.pliki-upload-row.is-error .pliki-upload-row-status {
    color: #dc2626;
}

.pliki-upload-progress-track {
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.pliki-upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.pliki-upload-row.is-done .pliki-upload-progress-bar {
    background: var(--success);
    width: 100% !important;
}

.pliki-upload-row.is-error .pliki-upload-progress-bar {
    background: #dc2626;
}

@media (max-width: 768px) {
    .pliki-grid {
        grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
        gap: 10px;
        padding: 14px;
    }
    .pliki-tile-icon {
        width: 52px;
        height: 52px;
        font-size: 1.5rem;
    }
    .pliki-preview-modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .pliki-upload-panel {
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
    }
}


/* Kategoria produktu jako etykieta - nie zawija się w środku słowa i nie rozjeżdża kolumny */
.product-category-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: #334155;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Pola wymagane / błędy walidacji (czerwone podświetlenie) --- */
.is-invalid,
.field-input.is-invalid,
.field-select.is-invalid,
.field-textarea.is-invalid,
.relation-select-wrap.is-invalid .relation-select-input {
    border-color: #dc2626 !important;
    background-color: rgba(254, 226, 226, 0.45) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}

.field-error-text {
    display: block;
    margin-top: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #dc2626;
}

/* --- Rozliczenie (moduł Cenniki): tabela pozycji jak arkusz "Rozliczenie" --- */
.settle-scroll {
    overflow-x: auto;
    padding-bottom: 4px;
}

.settle-table {
    min-width: 930px;
}

.settle-head,
.settle-row {
    display: grid;
    grid-template-columns: minmax(210px, 2.6fr) 70px 112px 112px 84px 112px 140px 36px;
    gap: 10px;
    align-items: start;
}

.settle-head {
    padding: 0 10px 8px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.settle-row {
    position: relative;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.8);
}

.settle-cell-label {
    display: none;
    margin-bottom: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

.settle-value,
.settle-margin {
    padding-top: 11px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
}

.settle-margin.is-positive {
    color: #15803d;
}

.settle-margin.is-negative {
    color: #dc2626;
}

.settle-notes {
    font-size: 0.82rem;
}

.settle-remove {
    width: 34px;
    height: 34px;
    margin-top: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
}

.settle-remove:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.settle-row-errors {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    font-weight: 600;
    color: #dc2626;
}

.settle-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.settle-totals > div {
    min-width: 130px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.95);
}

.settle-totals span {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.settle-totals strong {
    display: block;
    margin-top: 2px;
    font-size: 1rem;
    color: #0f172a;
    white-space: nowrap;
}

/* Wąskie ekrany: wiersz pozycji jako karta z podpisami pól */
@media (max-width: 900px) {
    .settle-table {
        min-width: 0;
    }

    .settle-head {
        display: none;
    }

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

    .settle-cell-product {
        grid-column: 1 / -1;
    }

    .settle-cell-label {
        display: block;
    }

    .settle-cell-remove {
        grid-column: 1 / -1;
        text-align: right;
    }

    .settle-value,
    .settle-margin {
        padding-top: 4px;
    }
}

/* Podsumowanie rozliczeń na karcie projektu */
.project-settlement {
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.95);
    display: grid;
    gap: 6px;
}

.project-settlement-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 800;
    color: #475569;
}

.project-settlement-title .material-symbols-outlined {
    font-size: 17px;
}

.project-settlement-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.project-settlement-grid span {
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
}

.project-settlement-grid strong {
    font-size: 0.88rem;
}

/* Profil kontrahenta: zwijane sekcje i pasek pustych sekcji */
.profile-collapsible > summary {
    list-style: none;
}

.profile-collapsible > summary::-webkit-details-marker {
    display: none;
}

.profile-collapsible-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 32px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.7);
    border-radius: inherit;
}

.profile-collapsible[open] > .profile-collapsible-summary {
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.profile-collapsible-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: #475569;
    font-size: 0.85rem;
    font-weight: 700;
}

.profile-collapsible-meta .material-symbols-outlined {
    transition: transform 0.15s ease;
}

.profile-collapsible[open] .profile-collapsible-meta .material-symbols-outlined {
    transform: rotate(180deg);
}

.profile-empty-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 18px;
    border: 1px dashed rgba(148, 163, 184, 0.6);
    background: rgba(255, 255, 255, 0.55);
}

.profile-empty-strip-title {
    margin-right: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
}

.profile-empty-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: #fff;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.profile-empty-chip .material-symbols-outlined {
    font-size: 17px;
}

.profile-empty-chip:hover {
    border-color: rgba(249, 115, 22, 0.5);
    color: #c2410c;
}

.profile-empty-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    padding: 10px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(226, 232, 240, 0.9);
    font-size: 0.85rem;
    color: #94a3b8;
}

.profile-empty-note a {
    color: #ea580c;
    font-weight: 700;
    text-decoration: none;
}

.profile-empty-note a:hover {
    text-decoration: underline;
}

/* --- Ustawienia > Duplikaty --- */
.dup-summary-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.9rem;
}

.dup-summary-card:hover {
    border-color: rgba(249, 115, 22, 0.5);
}

.dup-summary-card.has-duplicates {
    background: rgba(255, 247, 237, 0.9);
    border-color: rgba(249, 115, 22, 0.35);
}

.dup-summary-card.is-selected {
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.55);
}

.dup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.dup-table th {
    padding: 6px 10px;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    white-space: nowrap;
}

.dup-table td {
    padding: 10px;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    vertical-align: top;
    background: #fff;
}

.dup-table tr.is-primary td {
    background: rgba(240, 253, 244, 0.95);
}

.dup-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: #334155;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ============ Asystent AI (templates/layout/ai_assistant.php + assets/js/ai-assistant.js) ============ */
.ai-fab {
    position: fixed;
    right: 24px;
    bottom: 96px;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #fff;
    box-shadow: 0 16px 36px rgba(234, 88, 12, 0.38);
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.ai-fab .material-symbols-outlined {
    font-size: 26px;
}

.ai-fab:hover {
    transform: translateY(-2px);
}

.ai-fab.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.ai-fab-badge {
    top: -6px;
    right: -6px;
}

.ai-toast {
    position: fixed;
    right: 24px;
    bottom: 162px;
    z-index: 61;
    max-width: 320px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    background: #111827;
    color: #f8fafc;
    font-size: 0.84rem;
    line-height: 1.4;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
}

.ai-toast button {
    border: 0;
    background: transparent;
    color: #fdba74;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.ai-toast button[data-ai-dismiss] {
    color: #94a3b8;
    font-size: 1.2rem;
    line-height: 1;
}

.ai-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(440px, 100vw);
    z-index: 72;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: -24px 0 60px rgba(15, 23, 42, 0.2);
    transform: translateX(105%);
    transition: transform 0.26s ease;
}

.ai-panel.is-open {
    transform: translateX(0);
}

.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), rgba(255, 255, 255, 0.95));
}

.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-panel-title > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ai-panel-title strong {
    font-size: 0.98rem;
    color: #0f172a;
}

.ai-panel-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    flex-shrink: 0;
}

.ai-panel-logo .material-symbols-outlined {
    font-size: 20px;
}

.ai-context-chip {
    font-size: 0.72rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 230px;
}

.ai-panel-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.ai-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #475569;
    cursor: pointer;
}

.ai-icon-btn:hover {
    background: rgba(148, 163, 184, 0.18);
}

.ai-pulse {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    background: rgba(248, 250, 252, 0.9);
}

.ai-pulse-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 2px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #16a34a;
}

.ai-pulse-live i {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #22c55e;
    animation: aiPulseDot 1.6s ease-in-out infinite;
}

@keyframes aiPulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.7); }
}

.ai-pulse-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    max-width: 100%;
}

.ai-pulse-chip .material-symbols-outlined {
    font-size: 15px;
}

.ai-pulse-chip.danger {
    border-color: rgba(220, 38, 38, 0.35);
    color: #b91c1c;
    background: rgba(254, 242, 242, 0.9);
}

.ai-pulse-chip.warn {
    border-color: rgba(249, 115, 22, 0.4);
    color: #c2410c;
    background: rgba(255, 247, 237, 0.95);
}

.ai-history {
    max-height: 45%;
    overflow-y: auto;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    background: #fff;
}

.ai-history-item {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid rgba(241, 245, 249, 1);
}

.ai-history-item > button:first-child {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 0.86rem;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
}

.ai-history-item small {
    color: #94a3b8;
    font-weight: 500;
}

.ai-history-item > button:first-child:hover {
    background: rgba(248, 250, 252, 1);
}

.ai-history-del {
    width: 40px;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 1.3rem;
    cursor: pointer;
}

.ai-history-del:hover {
    color: #dc2626;
}

.ai-history-empty {
    padding: 16px;
    color: #94a3b8;
    font-size: 0.85rem;
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(248, 250, 252, 0.6);
}

.ai-msg {
    max-width: 92%;
    font-size: 0.9rem;
    line-height: 1.5;
}

.ai-msg-user {
    align-self: flex-end;
    padding: 9px 13px;
    border-radius: 16px 16px 4px 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-msg-assistant {
    align-self: flex-start;
    width: 100%;
    max-width: 100%;
}

.ai-md {
    padding: 10px 14px;
    border-radius: 16px 16px 16px 4px;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    color: #1e293b;
    word-break: break-word;
}

.ai-md:empty {
    display: none;
}

.ai-md p {
    margin: 0 0 6px;
}

.ai-md p:last-child,
.ai-md ul:last-child,
.ai-md ol:last-child {
    margin-bottom: 0;
}

.ai-md ul,
.ai-md ol {
    margin: 4px 0 8px 18px;
    padding: 0;
}

.ai-md ul {
    list-style: disc;
}

.ai-md ol {
    list-style: decimal;
}

.ai-md li {
    margin-bottom: 3px;
}

.ai-md a {
    color: var(--accent-strong);
    font-weight: 600;
    text-decoration: underline;
}

.ai-md code {
    padding: 1px 5px;
    border-radius: 6px;
    background: rgba(148, 163, 184, 0.18);
    font-size: 0.85em;
}

.ai-md pre {
    overflow-x: auto;
    padding: 10px;
    border-radius: 10px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.8rem;
}

.ai-md pre code {
    background: transparent;
}

.ai-h {
    margin: 4px 0;
    font-weight: 800;
    color: #0f172a;
}

.ai-errors .ai-error,
.ai-error {
    margin-top: 6px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(254, 226, 226, 0.7);
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: #b91c1c;
    font-size: 0.84rem;
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 0;
    padding: 4px 4px 0;
    color: #64748b;
    font-size: 0.8rem;
}

.ai-status:empty {
    display: none;
}

.ai-dots {
    display: inline-flex;
    gap: 3px;
}

.ai-dots i {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--accent);
    animation: aiDots 1.1s ease-in-out infinite;
}

.ai-dots i:nth-child(2) { animation-delay: 0.15s; }
.ai-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiDots {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.ai-proposals {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.ai-proposals:empty {
    display: none;
}

.ai-proposal {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(249, 115, 22, 0.4);
    background: rgba(255, 247, 237, 0.9);
}

.ai-proposal.is-confirmed {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(240, 253, 244, 0.9);
}

.ai-proposal.is-rejected,
.ai-proposal.is-expired {
    border-color: rgba(203, 213, 225, 0.9);
    background: rgba(248, 250, 252, 0.9);
}

.ai-proposal.is-failed {
    border-color: rgba(220, 38, 38, 0.4);
    background: rgba(254, 242, 242, 0.9);
}

.ai-proposal-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #c2410c;
}

.ai-proposal-head .material-symbols-outlined {
    font-size: 17px;
}

.ai-proposal-summary {
    margin: 6px 0;
    font-weight: 700;
    color: #0f172a;
    font-size: 0.9rem;
}

.ai-proposal-fields {
    display: grid;
    gap: 3px;
    font-size: 0.8rem;
}

.ai-proposal-fields div {
    display: flex;
    gap: 8px;
}

.ai-proposal-fields span {
    flex: 0 0 96px;
    color: #94a3b8;
}

.ai-proposal-fields strong {
    font-weight: 600;
    color: #334155;
    word-break: break-word;
}

.ai-proposal-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.ai-btn-primary,
.ai-btn-ghost {
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
}

.ai-btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
}

.ai-btn-ghost {
    background: #fff;
    border-color: rgba(203, 213, 225, 0.95);
    color: #475569;
}

.ai-btn-primary:disabled,
.ai-btn-ghost:disabled {
    opacity: 0.55;
    cursor: wait;
}

.ai-proposal-result {
    margin-top: 8px;
    font-size: 0.82rem;
    color: #64748b;
}

.ai-proposal-result.is-ok {
    color: #15803d;
    font-weight: 600;
}

.ai-proposal-result.is-error {
    color: #b91c1c;
}

.ai-proposal-result a {
    margin-left: 6px;
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: underline;
}

.ai-empty {
    margin: auto 0;
    padding: 12px 6px;
    text-align: center;
}

.ai-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
}

.ai-empty h3 {
    margin: 10px 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
}

.ai-empty p {
    margin: 0 auto 14px;
    max-width: 320px;
    font-size: 0.86rem;
    color: #64748b;
}

.ai-chips {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.ai-chip {
    padding: 9px 14px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 14px;
    background: #fff;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.ai-chip:hover {
    border-color: rgba(249, 115, 22, 0.5);
    color: #c2410c;
}

.ai-notice {
    margin: 0 14px 6px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(241, 245, 249, 1);
    color: #475569;
    font-size: 0.8rem;
}

.ai-notice.is-warning {
    background: rgba(255, 247, 237, 1);
    color: #9a3412;
}

.ai-notice.is-error {
    background: rgba(254, 226, 226, 0.8);
    color: #b91c1c;
}

.ai-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px 4px;
    border-top: 1px solid rgba(226, 232, 240, 0.95);
}

.ai-form textarea {
    flex: 1;
    resize: none;
    max-height: 140px;
    padding: 10px 14px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    border-radius: 16px;
    outline: none;
    font-size: 0.9rem;
    line-height: 1.4;
    background: #fff;
}

.ai-form textarea:focus {
    border-color: rgba(249, 115, 22, 0.6);
}

.ai-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    cursor: pointer;
}

.ai-send.ai-stop {
    background: #334155;
}

.ai-footnote {
    padding: 4px 16px 10px;
    font-size: 0.68rem;
    color: #94a3b8;
    text-align: center;
}

@media (max-width: 1024px) {
    .ai-fab {
        bottom: 156px;
    }

    .ai-toast {
        bottom: 222px;
    }
}

@media (max-width: 480px) {
    .ai-panel {
        width: 100vw;
    }

    .ai-fab {
        right: 16px;
    }
}

/* ===== Asystent AI: podsumowanie dnia na pulpicie ===== */
.ai-briefing {
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.ai-briefing-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(14, 165, 233, 0.06));
}

.ai-briefing-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    flex-shrink: 0;
}

.ai-briefing-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ai-briefing-title small {
    color: #64748b;
    font-size: 0.76rem;
}

.ai-briefing-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-briefing-actions .btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.ai-briefing.is-collapsed .ai-briefing-body,
.ai-briefing.is-collapsed .ai-briefing-chips {
    display: none;
}

.ai-briefing.is-collapsed [data-briefing-toggle] .material-symbols-outlined {
    transform: rotate(180deg);
}

.ai-briefing-body {
    padding: 14px 20px 6px;
    color: #1e293b;
    font-size: 0.93rem;
    line-height: 1.5;
    word-break: break-word;
}

.ai-briefing-body p {
    margin: 0 0 8px;
}

.ai-briefing-body ul,
.ai-briefing-body ol {
    margin: 4px 0 10px 20px;
    padding: 0;
}

.ai-briefing-body ul {
    list-style: disc;
}

.ai-briefing-body ol {
    list-style: decimal;
}

.ai-briefing-body li {
    margin-bottom: 4px;
}

.ai-briefing-body a {
    color: var(--accent-strong);
    font-weight: 600;
    text-decoration: underline;
}

.ai-briefing-body .ai-h {
    margin: 10px 0 4px;
}

.ai-briefing-body .ai-error {
    margin-top: 0;
}

.ai-briefing-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 20px 16px;
}

.ai-briefing-skeleton {
    display: grid;
    gap: 8px;
    padding-bottom: 10px;
}

.ai-briefing-skeleton i {
    display: block;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(226, 232, 240, 0.6), rgba(241, 245, 249, 1), rgba(226, 232, 240, 0.6));
    background-size: 200% 100%;
    animation: aiShimmer 1.4s linear infinite;
}

.ai-briefing-skeleton i:nth-child(1) { width: 70%; }
.ai-briefing-skeleton i:nth-child(2) { width: 92%; }
.ai-briefing-skeleton i:nth-child(3) { width: 55%; }

@keyframes aiShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (max-width: 640px) {
    .ai-briefing-head { padding: 12px 14px; }
    .ai-briefing-body { padding: 12px 14px 4px; }
    .ai-briefing-chips { padding: 6px 14px 14px; }
    .ai-briefing-actions .btn-sm { display: none !important; }
}

/* ===== Asystent AI: przypomnienia (czuwanie) ===== */
.ai-reminders {
    display: grid;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    background: rgba(255, 251, 235, 0.7);
    max-height: 36%;
    overflow-y: auto;
}

.ai-reminders-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #b45309;
}

.ai-reminders-head button,
.ai-reminders-foot button {
    border: 0;
    background: transparent;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    text-decoration: underline;
}

.ai-reminders-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.ai-reminder {
    padding: 9px 11px;
    border-radius: 14px;
    border: 1px solid rgba(245, 158, 11, 0.45);
    background: #fff;
}

.ai-reminder.is-urgent {
    border-color: rgba(220, 38, 38, 0.45);
    background: rgba(254, 242, 242, 0.95);
}

.ai-reminder-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: #1e293b;
}

.ai-reminder-detail {
    margin-top: 2px;
    font-size: 0.78rem;
    color: #475569;
}

.ai-reminder-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
}

.ai-reminder-actions button,
.ai-reminder-actions a {
    padding: 3px 10px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.ai-reminder-actions .is-primary {
    border-color: transparent;
    background: var(--accent-strong);
    color: #fff;
}

.ai-icon-btn.is-muted {
    opacity: 0.45;
}

/* ===== Asystent AI: oceny odpowiedzi i preferencje ===== */
.ai-feedback {
    display: flex;
    gap: 2px;
    margin-top: 2px;
    opacity: 0.55;
    transition: opacity 0.15s;
}

.ai-msg-assistant:hover .ai-feedback,
.ai-feedback:focus-within {
    opacity: 1;
}

.ai-feedback button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
}

.ai-feedback button .material-symbols-outlined {
    font-size: 16px;
}

.ai-feedback button:hover {
    background: rgba(148, 163, 184, 0.2);
}

.ai-feedback button.is-active {
    color: var(--accent-strong);
    background: rgba(249, 115, 22, 0.12);
}

.ai-feedback[data-rating="1"],
.ai-feedback[data-rating="-1"] {
    opacity: 1;
}

.ai-prefs {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
}

.ai-prefs-label {
    font-size: 0.78rem;
    color: #475569;
}

.ai-prefs textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    border-radius: 12px;
    font-size: 0.82rem;
    resize: vertical;
    background: #fff;
}

.ai-prefs-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-prefs-status {
    font-size: 0.75rem;
    color: #64748b;
}

.ai-screen-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    padding: 1px 8px 1px 5px;
    border: 1px solid rgba(203, 213, 225, 0.95);
    border-radius: 999px;
    background: #fff;
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
}

.ai-screen-toggle .material-symbols-outlined {
    font-size: 13px;
}

.ai-screen-toggle.is-on {
    border-color: rgba(249, 115, 22, 0.45);
    color: var(--accent-strong);
    background: rgba(255, 247, 237, 0.9);
}

/* ===== Poczta: ocena ważności maili przez asystenta AI ===== */
.mail-triage {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
    white-space: nowrap;
}

.mail-triage-wazne {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.mail-triage-moze_poczekac {
    background: rgba(245, 158, 11, 0.16);
    color: #92400e;
}

.mail-triage-bez_akcji {
    background: rgba(148, 163, 184, 0.2);
    color: #475569;
}

.mail-ai-box {
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-left: 4px solid #94a3b8;
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.85);
    font-size: 0.85rem;
}

.mail-ai-box.mail-ai-wazne {
    border-left-color: #ef4444;
    background: rgba(254, 242, 242, 0.7);
}

.mail-ai-box.mail-ai-moze_poczekac {
    border-left-color: #f59e0b;
    background: rgba(255, 251, 235, 0.8);
}

.mail-ai-box.is-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    border-left-color: #cbd5e1;
}

.mail-ai-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.mail-ai-title {
    font-weight: 700;
    color: #334155;
}

.mail-ai-actions {
    margin-left: auto;
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.mail-ai-link {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: #64748b;
    font-size: 1rem;
}

.mail-ai-summary {
    margin: 8px 0 4px;
    color: #1e293b;
}

.mail-ai-meta {
    margin: 2px 0 0;
    color: #475569;
    font-size: 0.8rem;
}

/* Komunikacja: pole „opisz własnymi słowami” (asystent AI wypełnia formularz) */
.comm-ai-box { margin: 0 0 1.25rem; padding: 0.9rem 1rem; border: 1px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); }

/* Asystent AI: zbiorcze zatwierdzanie propozycji oraz lista „Co zmienił asystent” */
.ai-batch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 12px; font-weight: 600; }
.ai-batch span { flex: 1 1 100%; }
.ai-action-item { align-items: center; gap: 8px; padding: 8px 12px 8px 16px; }
.ai-action-item .ai-action-text { flex: 1; min-width: 0; font-size: 0.82rem; font-weight: 600; color: #0f172a; overflow-wrap: anywhere; }
.ai-action-item .ai-btn-ghost { flex: 0 0 auto; padding: 6px 12px; }
.ai-action-item .ai-action-text small { display: block; opacity: 0.65; }
.ai-action-item.is-undone .ai-action-text { text-decoration: line-through; opacity: 0.6; }
.ai-action-link { flex: 0 0 auto; text-decoration: none; font-weight: 700; padding: 0 4px; color: var(--accent-strong); }

/* =====================================================================================================================
   TELEFON - wersja mobilna v2 (assets/js/mobile-enhance.js dokłada klasy m-* do kart na listach i przycisk „Filtry”)
   Cel: mniej przewijania (zwarte karty, jeden rząd akcji, zwinięte filtry), brak powiększania ekranu przy wpisywaniu (iOS),
   wygodne cele dotyku (min. 44 px), wyszukiwarka dostępna z nagłówka, bezpieczne marginesy (notch / pasek gestów).
   ===================================================================================================================== */
.topbar-search-toggle { display: none; }
.mobile-filters-toggle { display: none; }

@media (max-width: 768px) {
    html { -webkit-text-size-adjust: 100%; }
    body { -webkit-tap-highlight-color: transparent; }
    a, button, summary, label, select, input, textarea { touch-action: manipulation; }

    /* iOS Safari powiększa stronę po dotknięciu pola, jeśli ma ono mniej niż 16 px. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
    select, textarea, .field-input, .field-select, .field-textarea, .toolbar-search, .topbar-search {
        font-size: 16px !important;
    }
    .field-input, .field-select, .field-textarea, .toolbar-search { padding: 12px 14px; border-radius: 14px; }
    .field-input:focus, .field-select:focus, .field-textarea:focus, .toolbar-search:focus, .topbar-search:focus { transform: none; }

    /* Cele dotyku */
    .btn-primary, .btn-secondary { min-height: 46px; }
    .btn-sm { min-height: 38px; }
    .chat-icon-btn, .ai-icon-btn { min-width: 40px; min-height: 40px; }
    .account-card { min-height: 44px; }
    .bulk-select-col input, .bulk-select-all, .crm-table td input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent-strong); }

    /* Treść nie chowa się pod dolnym paskiem i przyciskami czatu/AI */
    .main-content { padding-bottom: calc(var(--bottom-nav-h, 62px) + 28px + env(safe-area-inset-bottom)); }
    .chat-fab { bottom: calc(var(--bottom-nav-h, 62px) + 14px + env(safe-area-inset-bottom)); width: 50px; height: 50px; right: 14px; }
    .ai-fab { bottom: calc(var(--bottom-nav-h, 62px) + 74px + env(safe-area-inset-bottom)); width: 48px; height: 48px; right: 14px; }
    .chat-fab, .ai-fab { transition: transform 0.25s ease, opacity 0.25s ease; }
    body.fabs-tucked .chat-fab, body.fabs-tucked .ai-fab { transform: translateX(70px); opacity: 0.0; pointer-events: none; }
    body.has-sticky-actions .chat-fab, body.has-sticky-actions .ai-fab { transform: translateX(70px); opacity: 0; pointer-events: none; }
    .ai-toast { right: 14px; bottom: calc(var(--bottom-nav-h, 62px) + 130px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); }
    .ai-panel, .chat-panel-v2 { height: 100dvh; }
    .ai-panel { padding-bottom: env(safe-area-inset-bottom); }

    /* Nagłówek strony: tytuł, krótki opis i liczby w jednym rzędzie, bez wielkich odstępów */
    .page-header-compact { gap: 8px; padding-bottom: 10px; margin-bottom: 12px; }
    .page-header-compact-text h1 { font-size: 1.3rem; }
    .page-header-compact-text p { font-size: 0.82rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .page-header-compact-side { width: 100%; gap: 8px; }
    .page-header-stats { flex-wrap: nowrap; overflow-x: auto; gap: 8px; scrollbar-width: none; margin-right: -14px; padding-right: 14px; }
    .page-header-stats::-webkit-scrollbar { display: none; }
    .stat-chip { flex: 0 0 auto; padding: 5px 12px; min-width: 0; }
    .page-header-compact-side > .btn-primary, .page-header-compact-side > .btn-secondary { flex: 1 1 auto; justify-content: center; text-align: center; }

    /* Karty wskaźników: dwie kolumny, bez opisów */
    .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric-card { padding: 14px; border-radius: 18px; }
    .metric-card::before { display: none; }
    .metric-value { font-size: 1.5rem; }
    .metric-label { font-size: 0.68rem; }
    .metric-trend { display: none; }
    .metric-card-filler { display: none; }

    /* Rzędy przycisków: jeden przewijany poziomo pasek zamiast 3-4 zawijanych rzędów */
    .comm-toolbar > div, .dash-head-actions, .zadania-view-tabs, .calendar-legend, .cal-toolbar-row {
        flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
        margin-left: -2px; padding: 2px;
    }
    .comm-toolbar > div::-webkit-scrollbar, .dash-head-actions::-webkit-scrollbar,
    .zadania-view-tabs::-webkit-scrollbar, .calendar-legend::-webkit-scrollbar, .cal-toolbar-row::-webkit-scrollbar { display: none; }
    .comm-toolbar > div > *, .dash-head-actions > *, .zadania-view-tabs > *, .calendar-legend > * { flex: 0 0 auto; white-space: nowrap; scroll-snap-align: start; }
    /* Zadania: zakładki w osobnym, przewijanym rzędzie; pod nimi główna akcja na całą szerokość, potem akcje porządkowe */
    .zadania-toolbar > div { gap: 8px; }
    .zadania-toolbar > div > .flex-1 { display: none; }
    .zadania-view-tabs { flex: 1 1 100%; width: 100%; }
    .zadania-toolbar .btn-primary { order: 1; flex: 1 1 auto; text-align: center; justify-content: center; }
    .zadania-layout-toggle { order: 2; }
    .zadania-toolbar > div > form, .zadania-toolbar > div > a.btn-secondary { order: 3; }
    .comm-toolbar .btn-primary, .comm-toolbar .btn-secondary, .zadania-toolbar .btn-primary, .zadania-toolbar .btn-secondary { min-height: 42px; padding: 9px 14px; }
    .dash-head-actions .dash-edit-btn { min-height: 40px; padding: 8px 14px; }

    /* Przyciski formularzy: nie wielkie jak na desktopie */
    form .btn-primary.text-lg, form .btn-secondary.text-lg { padding: 14px 18px; font-size: 1rem; }
    .mobile-sticky-actions {
        position: sticky; bottom: calc(var(--bottom-nav-h, 62px) + env(safe-area-inset-bottom) + 8px); z-index: 30;
        padding: 10px; margin: 8px -6px 0; border-radius: 20px; background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(14px);
        border: 1px solid rgba(203, 213, 225, 0.8); box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.1);
    }
    .mobile-sticky-actions { display: flex !important; flex-direction: row !important; flex-wrap: wrap; gap: 8px !important; }
    .mobile-sticky-actions > .btn-primary, .mobile-sticky-actions > .btn-secondary { margin: 0; flex: 1 1 40%; padding: 12px 10px !important; font-size: 0.95rem !important; min-height: 46px; text-align: center; justify-content: center; }
    .mobile-sticky-actions > .btn-primary { flex-basis: 55%; }
    .modal-sticky { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 5; margin-top: 12px; box-shadow: 0 -14px 14px 10px #fff; }

    /* Zwinięte filtry */
    .mobile-filters-toggle {
        display: flex; align-items: center; gap: 8px; width: 100%; min-height: 46px; padding: 10px 14px; margin: 0 0 12px;
        border: 1px solid rgba(203, 213, 225, 0.9); border-radius: 14px; background: #fff; color: var(--text); font: inherit; font-weight: 700; text-align: left;
    }
    .mobile-filters-toggle .mf-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 0.78rem; line-height: 22px; text-align: center; display: none; }
    .mobile-filters-toggle.has-active .mf-count { display: inline-block; }
    .mobile-filters-toggle .mf-caret { transition: transform 0.2s ease; }
    .mobile-filters-toggle[aria-expanded="true"] .mf-caret { transform: rotate(180deg); }
    .mobile-filters-collapsed { display: none !important; }

    /* Listy: zwarta karta zamiast kilkunastu wierszy (etykieta nad wartością, po dwie kolumny) */
    .crm-table tbody tr {
        display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 0; position: relative;
        padding: 12px 14px 10px; border-bottom: 1px solid rgba(226, 232, 240, 0.9); background: transparent;
    }
    .crm-table tbody td { display: block; width: auto; min-width: 0; padding: 5px 0; border-bottom: 0; overflow-wrap: anywhere; }
    .crm-table tbody td::before { margin-bottom: 1px; font-size: 0.62rem; letter-spacing: 0.06em; }
    .crm-table tbody td.m-primary { grid-column: 1 / -1; padding: 0 40px 6px 0; font-size: 0.98rem; font-weight: 700; }
    .crm-table tbody td.m-primary::before { display: none; }
    .crm-table tbody td.m-empty, .crm-table tbody td.m-extra { display: none; }
    .crm-table tbody tr.is-expanded td.m-extra:not(.m-empty) { display: block; }
    .crm-table tbody td.bulk-select-col { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; padding: 0; }
    .crm-table tbody td.bulk-select-col::before { display: none; }
    .crm-table tbody td.m-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 8px; }
    .crm-table tbody td.m-actions::before { display: none; }
    .crm-table tbody td.m-actions .btn-primary, .crm-table tbody td.m-actions .btn-secondary, .crm-table tbody td.m-actions a, .crm-table tbody td.m-actions button { min-height: 38px; }
    .crm-table tbody td.m-actions .btn-primary, .crm-table tbody td.m-actions .btn-secondary { padding: 7px 14px; }
    .crm-table .m-more {
        grid-column: 1 / -1; justify-self: start; margin-top: 2px; padding: 6px 0; border: 0; background: transparent; color: var(--accent-strong);
        font: inherit; font-size: 0.82rem; font-weight: 700;
    }

    /* Wyszukiwarka w nagłówku (na telefonie była niedostępna) */
    .topbar-search-toggle {
        display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 14px; border: 1px solid rgba(226, 232, 240, 0.95);
        background: rgba(255, 255, 255, 0.85); color: #334155; font-size: 1.4rem;
    }
    .global-search-wrap { display: none; }
    .global-search-wrap.is-mobile-open {
        display: block; position: fixed; left: 0; right: 0; top: 0; z-index: 90; padding: 10px 12px; background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(16px);
        border-bottom: 1px solid rgba(226, 232, 240, 0.95); box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    }
    .global-search-wrap.is-mobile-open .topbar-search { width: 100%; }
    .global-search-wrap.is-mobile-open .global-search-results { position: static; margin-top: 8px; max-height: calc(100dvh - 90px); box-shadow: none; border: 0; padding: 0; }

    /* Pulpit */
    .dash-head-actions { align-items: center; }
    .dw-kpis { gap: 8px; }
    .dw-kpi { padding: 12px 12px 10px; }
    .dw-kpi-hint { display: none; }

    /* Logo na ekranie logowania jest jasne - na białej karcie było niewidoczne */
    .login-card-mobile-brand img { filter: brightness(0) opacity(0.82); }
}

/* Kalendarz na telefonie: siatka z kropkami + lista wydarzeń wybranego dnia */
.cal-dots, .cal-agenda { display: none; }
@media (max-width: 768px) {
    .calendar-grid { gap: 0; border-radius: 18px; }
    .calendar-cell { min-height: 54px; padding: 4px 2px; text-align: center; display: flex; flex-direction: column; align-items: center; }
    .calendar-cell-events { display: none; }
    .calendar-cell-date { font-size: 0.82rem; }
    .calendar-cell.is-selected { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); border-radius: 10px; }
    .cal-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 3px; max-width: 34px; }
    .cal-dots .calendar-dot { width: 6px; height: 6px; }
    .calendar-weekday { font-size: 0.68rem; padding: 6px 0; }
    .cal-toolbar .btn-primary, .cal-toolbar .btn-secondary { min-height: 40px; padding: 8px 14px; }
    .cal-toolbar { gap: 8px; margin-bottom: 12px; }
    .cal-agenda { display: block; margin-top: 14px; }
    .cal-agenda-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
    .cal-agenda-head strong { font-size: 1rem; }
    .cal-agenda-day { display: none; }
    .cal-agenda-day.is-active { display: grid; gap: 8px; }
    .cal-agenda-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: #fff; border: 1px solid rgba(226, 232, 240, 0.95); text-decoration: none; color: var(--text); }
    .cal-agenda-item .cal-time { flex: 0 0 48px; font-weight: 800; font-size: 0.85rem; color: var(--accent-strong); }
    .cal-agenda-item em { display: block; font-style: normal; font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
    .cal-agenda-empty { padding: 18px; text-align: center; color: #94a3b8; font-size: 0.9rem; }
}

/* Profil klienta: szybki kontakt (tylko telefon) */
.profile-quick { display: none; }
@media (max-width: 768px) {
    .profile-quick { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: -4px -2px 4px; padding: 2px; }
    .profile-quick::-webkit-scrollbar { display: none; }
    .profile-quick-btn {
        flex: 0 0 auto; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 84px; min-height: 64px; padding: 8px 14px;
        border-radius: 16px; background: #fff; border: 1px solid rgba(203, 213, 225, 0.9); color: var(--text); text-decoration: none; font-size: 0.78rem; font-weight: 700;
    }
    .profile-quick-btn .material-symbols-outlined { font-size: 1.4rem; color: var(--accent-strong); }
    .profile-quick-btn small { font-size: 0.66rem; font-weight: 600; color: var(--muted); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .profile-quick-btn.is-primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%); border-color: transparent; color: #fff; }
    .profile-quick-btn.is-primary .material-symbols-outlined, .profile-quick-btn.is-primary small { color: #fff; }
    .profile-collapsible-summary p { display: none; }
}

.ai-send.ai-mic { background: #f1f5f9; color: #475569; }
.ai-send.ai-mic.is-recording { background: #dc2626; color: #fff; animation: aiMicPulse 1.1s ease-in-out infinite; }
@keyframes aiMicPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); } 50% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); } }

/* =====================================================================================================================
   POCZTA - wiele skrzynek (dowolna domena) i wersja mobilna (assets/js/poczta.js, poczta-accounts.js, modules/poczta/view.php)
   ===================================================================================================================== */
.mail-layout { grid-template-columns: 250px 350px minmax(0, 1fr); }
.mail-mobile-bar, .mail-fab, .mail-drawer-backdrop, .mail-mobile-readbar, .mail-more-btn, .mail-ptr { display: none; }

/* Lista skrzynek w panelu bocznym */
.mail-accounts { display: flex; flex-direction: column; gap: 2px; padding-bottom: 12px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.mail-accounts-title { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #94a3b8; padding: 0 8px 6px; }
.mail-account-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; color: #334155; text-decoration: none; }
.mail-account-item:hover { background: rgba(248, 250, 252, 0.95); }
.mail-account-item.is-active { background: var(--accent-soft); }
.mail-account-avatar { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 0.8rem; }
.mail-account-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mail-account-text strong { font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-account-text small { font-size: 0.7rem; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-accounts-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px 0; }
.mail-accounts-btn { border: 1px dashed var(--border); background: transparent; border-radius: 10px; padding: 6px 10px; font: inherit; font-size: 0.76rem; font-weight: 700; color: #64748b; cursor: pointer; }
.mail-accounts-btn:hover { border-color: var(--accent); color: var(--accent-strong); }

/* Formularz skrzynki */
.ma-form { display: grid; gap: 16px; }
.ma-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ma-opt { font-weight: 500; color: #94a3b8; font-size: 0.78rem; }
.ma-password { position: relative; }
.ma-password .field-input { padding-right: 76px; }
.ma-pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--accent-strong); font: inherit; font-weight: 700; font-size: 0.8rem; padding: 8px; cursor: pointer; }
.ma-note { padding: 10px 14px; border-radius: 14px; background: rgba(59, 130, 246, 0.08); border: 1px solid rgba(59, 130, 246, 0.2); color: #1e3a8a; font-size: 0.84rem; line-height: 1.45; }
.ma-note.is-warn { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); color: #92400e; }
.ma-advanced { border: 1px solid var(--border); border-radius: 14px; padding: 0 14px; }
.ma-advanced summary { cursor: pointer; padding: 12px 0; font-weight: 700; font-size: 0.88rem; color: #475569; }
.ma-advanced-body { display: grid; gap: 12px; padding-bottom: 14px; }
.ma-server-title { font-size: 0.74rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: #94a3b8; }
.ma-server-row { display: grid; grid-template-columns: 2fr 0.9fr 1.3fr; gap: 10px; }
.ma-result { padding: 12px 14px; border-radius: 14px; font-size: 0.88rem; line-height: 1.45; }
.ma-result.is-error { background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.25); color: #991b1b; }
.ma-result.is-warn { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); color: #92400e; }
.ma-continue { display: inline-block; margin-top: 10px; text-align: center; }
.ma-onboarding { max-width: 640px; }
.ma-list { padding: 8px 14px; display: grid; gap: 4px; }
.ma-item { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--border); }
.ma-item:last-child { border-bottom: 0; }
.ma-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.ma-item-text small { font-size: 0.74rem; color: #64748b; overflow-wrap: anywhere; }
.ma-item-error { color: #b91c1c !important; }
.ma-item-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.ma-danger { color: #dc2626 !important; }

/* Podpowiedzi adresatów w oknie pisania */
.compose-suggest { position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; padding: 4px; }
.compose-suggest.hidden { display: none; }
.compose-suggest button { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 10px; font: inherit; cursor: pointer; }
.compose-suggest button:hover, .compose-suggest button:active { background: var(--accent-soft); }
.compose-suggest strong { font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-suggest span { grid-column: 1; font-size: 0.74rem; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-suggest em { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-style: normal; font-size: 0.66rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; }

/* ---------- Telefon i tablet (do 1024 px, jak dolny pasek nawigacji) ---------- */
@media (max-width: 1024px) {
    .mail-app .page-header-compact { display: none; }
    .mail-app .message-success, .mail-app .message-error { margin-bottom: 10px; }
    .mail-layout { display: block; grid-template-columns: none; max-height: none; min-height: 0; gap: 0; }
    .mail-list-pane { height: 100%; border-radius: 18px; }

    /* Pasek aplikacji nad listą */
    .mail-mobile-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
    .mail-mbar-btn { position: relative; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--border); background: #fff; color: #334155; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; }
    .mail-mbar-btn.is-syncing .material-symbols-outlined { animation: mail-spin 0.8s linear infinite; }
    .mail-mbar-dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 999px; background: var(--accent); border: 2px solid #fff; }
    .mail-mbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; padding: 0 4px; }
    .mail-mbar-title strong { font-size: 1.1rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mail-mbar-title small { font-size: 0.74rem; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Wyszukiwarka zawsze na wierzchu, reszta przycisków znika (nowa wiadomość = przycisk plusowy, synchronizacja = pasek) */
    .mail-toolbar { margin-bottom: 10px; gap: 8px; flex-wrap: nowrap; }
    .mail-toolbar > .btn-primary, #mailSyncBtn, #mailLastSync { display: none; }
    .mail-search { min-width: 0; padding: 4px 14px; border-radius: 14px; background: #fff; }
    .mail-search input { min-height: 38px; }
    #mailAiTriageBtn { padding: 10px 12px; font-size: 0; min-height: 44px; }
    #mailAiTriageBtn::before { content: '✨'; font-size: 1.1rem; }
    #mailAiTriageStatus { display: none; }
    .mail-filter-bar { padding: 10px 12px; gap: 6px; scrollbar-width: none; }
    .mail-filter-bar::-webkit-scrollbar { display: none; }
    .mail-filter-chip { padding: 8px 14px; font-size: 0.82rem; }

    /* Lista wiadomości */
    .mail-list { overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
    .mail-row { padding: 12px 12px 12px 10px; gap: 12px; background: #fff; transition: transform 0.2s ease; touch-action: pan-y; }
    .mail-row.is-dragging { transition: none; }
    .mail-row-avatar { width: 42px; height: 42px; font-size: 1rem; }
    .mail-row-sender { font-size: 0.95rem; }
    .mail-row-subject { font-size: 0.9rem; }
    .mail-row-snippet { font-size: 0.82rem; }
    .mail-row-star { min-width: 36px; min-height: 36px; }
    .mail-swipe-tray { position: absolute; left: 100%; top: 0; bottom: 0; width: 168px; display: flex; }
    .mail-swipe-tray button { flex: 1; border: 0; color: #fff; background: #64748b; font-size: 1.15rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
    .mail-swipe-tray button small { font-size: 0.64rem; font-weight: 700; }
    .mail-swipe-tray button[data-swipe="flag"] { background: #f59e0b; }
    .mail-swipe-tray button[data-swipe="read"] { background: #3b82f6; }
    .mail-swipe-tray button.is-danger { background: #ef4444; }
    .mail-ptr { display: block; height: 0; overflow: hidden; text-align: center; font-size: 0.8rem; color: #94a3b8; line-height: 54px; background: rgba(248, 250, 252, 0.9); transition: height 0.15s ease; flex-shrink: 0; }
    .mail-ptr.is-ready { color: var(--accent-strong); font-weight: 700; }

    /* Szuflada: skrzynki i foldery */
    .mail-sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; width: min(88vw, 330px); z-index: 85; border-radius: 0 22px 22px 0; padding: calc(18px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
        transform: translateX(-105%); transition: transform 0.26s ease, box-shadow 0.26s ease; box-shadow: none;
    }
    body.mail-drawer-open .mail-sidebar { transform: translateX(0); box-shadow: 24px 0 60px rgba(15, 23, 42, 0.3); }
    .mail-drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 84; background: rgba(15, 23, 42, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
    body.mail-drawer-open .mail-drawer-backdrop { opacity: 1; pointer-events: auto; }
    .mail-folder-link { padding: 12px 12px; font-size: 0.95rem; }
    .mail-account-item { padding: 10px; }
    .mail-accounts-btn { padding: 10px 12px; font-size: 0.82rem; }

    /* Przycisk nowej wiadomości */
    .mail-fab {
        display: inline-flex; align-items: center; justify-content: center; position: fixed; right: 16px; z-index: 60; width: 58px; height: 58px; border-radius: 18px; border: 0;
        bottom: calc(var(--bottom-nav-h, 62px) + 16px + env(safe-area-inset-bottom)); background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
        color: #fff; font-size: 1.6rem; box-shadow: 0 16px 34px rgba(234, 88, 12, 0.4);
    }
    body.mail-reading .mail-fab, body.mail-compose-open .mail-fab, body.mail-drawer-open .mail-fab { display: none; }
    body.is-mail-page .chat-fab, body.is-mail-page .ai-fab { display: none; }
    body.mail-reading .bottom-nav, body.mail-compose-open .bottom-nav { display: none; }
    /* Własny pasek poczty zastępuje nagłówek aplikacji - więcej miejsca na wiadomości */
    body.is-mail-page .topbar { display: none; }
    body.is-mail-page .main-content { padding-top: env(safe-area-inset-top); }
    body.is-mail-page .page-shell { padding-top: 10px; }

    /* Czytanie wiadomości: pełny ekran z paskiem wstecz u góry i akcjami na dole */
    .mail-app:not(.is-reading) .mail-reading-pane { display: none; }
    .mail-app.is-reading .mail-reading-pane {
        position: fixed; inset: 0; z-index: 80; border-radius: 0; border: 0; box-shadow: none; padding: 0 16px calc(120px + env(safe-area-inset-bottom)); background: #fff; overflow-y: auto; -webkit-overflow-scrolling: touch;
    }
    .mail-mobile-readbar { display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 3; margin: 0 -16px 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
    .mail-back-btn { flex: 0 0 auto; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; color: #334155; }
    .mail-back-btn:active { background: var(--accent-soft); }
    .mail-readbar-title { flex: 1; min-width: 0; font-weight: 800; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mail-read-header { gap: 12px; }
    .mail-read-header h2 { font-size: 1.15rem; line-height: 1.3; overflow-wrap: anywhere; }
    .mail-read-header .text-xs, .mail-read-header p { overflow-wrap: anywhere; }
    .mail-read-header > .text-xs.whitespace-nowrap { display: none; }
    .mail-body-frame { border-radius: 8px; overflow-x: hidden; }
    .mail-body-frame iframe { min-height: 120px; }

    .mail-read-toolbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 82; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--border);
        background: rgba(255, 255, 255, 0.97); backdrop-filter: blur(16px); display: flex; flex-wrap: wrap; justify-content: space-around; gap: 0; box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
    }
    .mail-read-toolbar .mail-toolbar-sep { display: none; }
    .mail-read-toolbar .mail-icon-btn {
        flex: 1 1 0; width: auto; min-width: 0; height: 54px; flex-direction: column; gap: 3px; border-radius: 14px; font-size: 1.3rem; line-height: 1;
    }
    .mail-read-toolbar .mail-icon-btn::after { content: attr(data-label); font-size: 0.64rem; font-weight: 700; color: #64748b; }
    .mail-read-toolbar .mail-icon-btn svg { width: 22px; height: 22px; }
    .mail-read-toolbar .mail-more-btn { display: inline-flex; }
    .mail-read-toolbar .mail-icon-btn[data-sec] { display: none; }
    .mail-read-toolbar.is-more-open { flex-wrap: wrap; }
    .mail-read-toolbar.is-more-open .mail-icon-btn[data-sec] { display: inline-flex; order: -1; flex: 1 1 25%; }
    .mail-read-toolbar.is-more-open::before { content: ''; order: -2; flex: 1 1 100%; height: 0; }

    /* Okno pisania na cały ekran, pole „Wyślij” przy kciuku */
    #composeModal.modal-overlay { padding: 0; align-items: stretch; background: #fff; backdrop-filter: none; z-index: 950; }
    .compose-box { max-width: none; width: 100%; max-height: none; height: 100dvh; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; overflow: hidden; animation: none; position: fixed; left: 0; right: 0; top: 0; }
    .compose-box .modal-header { padding: calc(10px + env(safe-area-inset-top)) 12px 10px 18px; flex: 0 0 auto; }
    .compose-box form { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding: 4px 16px 0; -webkit-overflow-scrolling: touch; }
    .compose-field-row { padding: 6px 0; min-height: 48px; }
    .compose-field-input { font-size: 16px; min-height: 36px; }
    .mail-editor-toolbar { position: sticky; top: 0; z-index: 2; background: #fff; flex: 0 0 auto; }
    .mail-editor { flex: 1 0 auto; min-height: 180px; max-height: none; overflow-y: visible; font-size: 16px; padding: 10px 2px; }
    .compose-footer { position: sticky; bottom: 0; z-index: 3; background: #fff; margin: auto -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); gap: 8px; box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.06); }
    .compose-send-btn { flex: 1; justify-content: center; min-height: 48px; }
    .compose-footer .mail-icon-btn { width: 46px; height: 46px; }
    .compose-suggest { z-index: 1100; }

    /* Pozostałe okna poczty jako arkusze od dołu */
    body.is-mail-page .modal-overlay:not(#composeModal) { align-items: flex-end; padding: 0; }
    body.is-mail-page .modal-overlay:not(#composeModal) .modal-box { border-radius: 24px 24px 0 0; max-width: none !important; max-height: 92dvh; animation: none; padding-bottom: env(safe-area-inset-bottom); }
    .ma-grid-2 { grid-template-columns: 1fr; }
    .ma-server-row { grid-template-columns: 1fr 1fr; }
    .ma-server-row > div:first-child { grid-column: 1 / -1; }
    .ma-item { flex-wrap: wrap; }
    .ma-item-actions { width: 100%; justify-content: flex-end; }
    .ma-onboarding { padding: 18px; }
}

/* =====================================================================================================================
   Profil kontrahenta: własny układ sekcji, grupa firm, notatki (modules/kontrahenci/profile.php)
   ===================================================================================================================== */
.profile-layout-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.profile-layout-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff; cursor: grab; }
.profile-layout-item.is-dragging { opacity: 0.4; }
.profile-layout-handle { color: #94a3b8; display: inline-flex; }
.profile-layout-eye { display: inline-flex; align-items: center; cursor: pointer; color: #64748b; }
.profile-layout-eye input { position: absolute; opacity: 0; pointer-events: none; }
.profile-layout-eye span { display: inline-flex; padding: 6px; border-radius: 10px; }
.profile-layout-eye input:checked + span { color: var(--accent-strong); background: var(--accent-soft); }
.profile-layout-eye input:not(:checked) + span { opacity: 0.45; }
.profile-layout-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.profile-layout-text strong { font-size: 0.92rem; }
.profile-layout-text small { color: #94a3b8; font-size: 0.76rem; }
.profile-layout-move { display: inline-flex; gap: 4px; }
.profile-layout-move button { width: 34px; height: 34px; border: 1px solid var(--border); background: #fff; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #475569; cursor: pointer; }
.profile-layout-move button:hover { border-color: var(--accent); color: var(--accent-strong); }

.group-label { font-size: 0.76rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: #94a3b8; margin-right: 8px; }
.group-parent { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.group-crumbs { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.9rem; }
.group-crumbs a { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.group-crumbs .sep { color: #94a3b8; margin: 0 2px; }
.group-parent-form { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 280px; }
.group-parent-form .relation-select-wrap, .group-parent-form select { min-width: 200px; }
.group-summary { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 0.86rem; color: #64748b; padding: 10px 14px; border-radius: 14px; background: rgba(148, 163, 184, 0.1); }
.group-summary strong { color: var(--text); }
.group-tree { display: grid; gap: 6px; }
.group-node { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-left: calc(var(--depth, 0) * 22px); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 12px; background: #fff; }
.group-node-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.group-node-name { font-weight: 700; color: var(--text); text-decoration: none; }
.group-node-name:hover { color: var(--accent-strong); }
.group-node-main small { color: #94a3b8; font-size: 0.76rem; }
.group-node-stats { display: flex; gap: 12px; font-size: 0.82rem; color: #64748b; white-space: nowrap; }
.group-node-stats .material-symbols-outlined { font-size: 1rem; vertical-align: -3px; }
.group-link-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; padding: 4px; }
.group-link-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.group-link-item:hover { background: rgba(248, 250, 252, 0.95); }
.group-link-item[hidden] { display: none; }
.group-link-item input { margin-top: 4px; width: 18px; height: 18px; }
.group-link-item span { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.group-link-item small { color: #94a3b8; font-size: 0.76rem; }

.profile-notes { display: grid; gap: 8px; padding: 14px 24px 22px; }
.profile-note { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: #fff; text-decoration: none; color: var(--text); }
.profile-note:hover { border-color: var(--accent); }
.profile-note span { color: #64748b; font-size: 0.86rem; overflow-wrap: anywhere; }
.profile-note small { color: #94a3b8; font-size: 0.74rem; }

@media (max-width: 768px) {
    .profile-layout-item { padding: 8px 10px; gap: 8px; }
    .profile-layout-text small { display: none; }
    .group-parent-form { margin-left: 0; width: 100%; flex-wrap: wrap; }
    .group-parent-form .relation-select-wrap, .group-parent-form select { flex: 1 1 100%; }
    .group-node { flex-wrap: wrap; gap: 6px 10px; margin-left: calc(var(--depth, 0) * 12px); }
    .group-node-stats { order: 3; width: 100%; }
    .profile-notes { padding: 12px 14px 18px; }
}

/* =====================================================================================================================
   Statystyki (modules/statystyki/view.php, assets/js/stats-charts.js)
   ===================================================================================================================== */
.stats-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.stats-nav { position: sticky; top: 100px; background: #fff; border: 1px solid var(--border); border-radius: 22px; padding: 14px; display: grid; gap: 14px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 130px); overflow-y: auto; }
.stats-nav-title { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #94a3b8; padding: 0 8px 4px; }
.stats-nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; color: #475569; font-size: 0.86rem; font-weight: 600; text-decoration: none; }
.stats-nav-item .material-symbols-outlined { font-size: 1.15rem; color: #94a3b8; }
.stats-nav-item:hover { background: rgba(248, 250, 252, 0.95); }
.stats-nav-item.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.stats-nav-item.is-active .material-symbols-outlined { color: var(--accent-strong); }
.stats-main { display: grid; gap: 18px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.stats-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 16px; }
.stats-periods { display: flex; flex-wrap: wrap; gap: 6px; }
.stats-chip { padding: 7px 13px; border-radius: 999px; border: 1.5px solid var(--border); background: #fff; color: #64748b; font-size: 0.78rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.stats-chip:hover { border-color: rgba(249, 115, 22, 0.45); color: var(--accent-strong); }
.stats-chip.is-active { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); border-color: transparent; color: #fff; }
.stats-custom { display: flex; align-items: center; gap: 6px; }
.stats-custom .field-input { padding: 7px 10px; border-radius: 12px; width: 140px; font-size: 0.82rem; }
.stats-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.stats-report-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.stats-report-head h2 { margin: 0; font-size: 1.5rem; font-weight: 800; }
.stats-report-head p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; max-width: 620px; }
.stats-period-label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(148, 163, 184, 0.12); color: #475569; font-size: 0.8rem; font-weight: 700; }
.stats-period-label .material-symbols-outlined { font-size: 1.05rem; }
.stats-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stats-kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: 20px; background: #fff; border: 1px solid var(--border); border-top: 4px solid #cbd5e1; box-shadow: var(--shadow-lg); text-decoration: none; color: inherit; }
a.stats-kpi:hover { transform: translateY(-2px); }
.stats-kpi.tone-ok { border-top-color: #10b981; }
.stats-kpi.tone-warn { border-top-color: #f59e0b; }
.stats-kpi.tone-danger { border-top-color: #ef4444; }
.stats-kpi-label { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: #94a3b8; }
.stats-kpi-value { font-size: 1.6rem; font-weight: 800; line-height: 1.15; color: var(--text); }
.stats-delta { font-size: 0.78rem; font-weight: 700; color: #94a3b8; }
.stats-delta.is-up { color: #059669; }
.stats-delta.is-down { color: #dc2626; }
.stats-delta small { font-weight: 500; color: #94a3b8; }
.stats-kpi-hint { font-size: 0.74rem; color: #94a3b8; }
.stats-insights { padding: 16px 20px; border-radius: 20px; background: linear-gradient(135deg, rgba(255, 247, 237, 0.95), rgba(255, 255, 255, 0.95)); border: 1px solid rgba(249, 115, 22, 0.25); }
.stats-insights-title { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 8px; color: #9a3412; }
.stats-insights ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 0.9rem; color: #334155; }
.stats-ai { padding: 16px 20px; border-radius: 20px; background: #fff; border: 1px solid rgba(99, 102, 241, 0.25); box-shadow: var(--shadow-lg); }
.stats-ai.hidden { display: none; }
.stats-ai-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stats-ai-refresh { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; color: #64748b; }
.stats-ai-body { font-size: 0.92rem; color: #334155; }
.stats-ai small { display: block; margin-top: 8px; color: #94a3b8; }
.stats-ai-error { color: #b91c1c; }
.stats-ai-loading { color: #64748b; display: flex; align-items: center; gap: 10px; }
.stats-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.stats-chart-card { padding: 18px 20px; border-radius: 22px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); min-width: 0; }
.stats-chart-card h3 { margin: 0 0 12px; font-size: 0.98rem; font-weight: 800; }
.stats-scroll { overflow-x: auto; }
.stats-svg { width: 100%; height: auto; display: block; }
.stats-grid { stroke: #e2e8f0; stroke-width: 1; stroke-dasharray: 3 4; }
.stats-axis { font-size: 11px; fill: #94a3b8; font-family: inherit; }
.stats-svg rect, .stats-donut path { transition: opacity 0.15s ease; }
.stats-svg rect:hover, .stats-donut path:hover { opacity: 0.8; }
.stats-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 0.78rem; color: #64748b; }
.stats-legend i, .stats-donut-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.stats-empty { padding: 36px 0; text-align: center; color: #cbd5e1; font-size: 0.9rem; }
.stats-hbars { display: grid; gap: 9px; }
.stats-hbar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 0.82rem; }
.stats-hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #475569; font-weight: 600; }
.stats-hbar-track { height: 14px; border-radius: 999px; background: rgba(148, 163, 184, 0.16); overflow: hidden; }
.stats-hbar-fill { display: block; height: 100%; border-radius: 999px; }
.stats-hbar-value { font-weight: 700; color: #334155; min-width: 70px; text-align: right; }
.stats-donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.stats-donut { width: 170px; height: 170px; flex: 0 0 auto; }
.stats-donut-total { font-size: 17px; font-weight: 800; fill: #0f172a; }
.stats-donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; min-width: 160px; font-size: 0.82rem; }
.stats-donut-legend li { display: flex; align-items: center; gap: 4px; }
.stats-donut-legend span { flex: 1; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-donut-legend b { color: #0f172a; }
.stats-donut-legend em { font-style: normal; color: #94a3b8; min-width: 44px; text-align: right; }
.stats-tip { display: none; position: fixed; z-index: 2000; background: #0f172a; color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 0.8rem; line-height: 1.4; pointer-events: none; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3); max-width: 260px; }
.stats-table-card .crm-table td { font-size: 0.86rem; }

@media (max-width: 1024px) {
    .stats-layout { grid-template-columns: minmax(0, 1fr); }
    .stats-app { max-width: 100%; overflow-x: clip; }
    .stats-nav { position: static; max-height: none; display: flex; gap: 6px; overflow-x: auto; padding: 8px; border-radius: 18px; scrollbar-width: none; }
    .stats-nav::-webkit-scrollbar { display: none; }
    .stats-nav-group { display: contents; }
    .stats-nav-title { display: none; }
    .stats-nav-item { flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--border); background: #fff; padding: 8px 12px; }
    .stats-nav-item.is-active { border-color: transparent; }
}
@media (max-width: 768px) {
    .stats-toolbar { padding: 12px; }
    .stats-toolbar, .stats-toolbar > * { min-width: 0; max-width: 100%; }
    .stats-periods { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0; padding: 0 2px; width: 100%; flex: 0 0 100%; }
    .stats-periods::-webkit-scrollbar { display: none; }
    .stats-custom { width: 100%; }
    .stats-custom .field-input { flex: 1; width: auto; }
    .stats-actions { margin-left: 0; width: 100%; }
    .stats-actions > * { flex: 1 1 auto; text-align: center; justify-content: center; }
    .stats-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stats-kpi { padding: 12px 14px; border-radius: 16px; }
    .stats-kpi-value { font-size: 1.25rem; }
    .stats-charts { grid-template-columns: 1fr; }
    .stats-chart-card { padding: 14px; border-radius: 18px; }
    .stats-hbar { grid-template-columns: minmax(70px, 38%) 1fr auto; }
    .stats-donut { width: 140px; height: 140px; }
}
@media print {
    .topbar, .sidebar, .bottom-nav, .stats-nav, .stats-toolbar, .chat-fab, .ai-fab, .page-header-compact { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    .stats-layout { display: block; }
    .stats-chart-card, .stats-kpi, .stats-table-card { break-inside: avoid; box-shadow: none; }
}

/* Dyski zewnętrzne w Wymianie plików (modules/pliki/drives_view.php) */
.drive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.drive-card { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 20px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.drive-card-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.drive-card-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; flex: 0 0 auto; }
.drive-card-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.drive-card-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-card-text small { color: #94a3b8; font-size: 0.76rem; }

/* Dziennik połączeń z dyskami zewnętrznymi (modules/pliki/drives_view.php) */
.drive-log-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.drive-log-badge.is-ok { background: #dcfce7; color: #166534; }
.drive-log-badge.is-fail { background: #fee2e2; color: #991b1b; }
.drive-log-diagnosis { margin-bottom: 6px; padding: 8px 10px; border-radius: 12px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 0.84rem; line-height: 1.45; max-width: 560px; }
.drive-log-details summary { cursor: pointer; font-size: 0.8rem; color: #64748b; }
.drive-log-details dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 8px 0; font-size: 0.8rem; }
.drive-log-details dt { color: #94a3b8; }
.drive-log-details dd { margin: 0; word-break: break-word; min-width: 0; }
.drive-log-trace { max-height: 260px; overflow: auto; margin: 6px 0 0; padding: 10px; border-radius: 12px; background: #0f172a; color: #e2e8f0; font-size: 0.72rem; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }

/* Telefon: nagłówek ("WORKSPACE" + tytuł modułu) ma symetryczny odstęp od góry i od dołu zamiast przylegać do górnej krawędzi. */
@media (max-width: 768px) {
    .topbar { height: auto; min-height: 0; padding-top: env(safe-area-inset-top); }
    .topbar > div { height: auto; min-height: 76px; padding-top: 14px; padding-bottom: 14px; box-sizing: border-box; }
    .main-content { padding-top: calc(77px + env(safe-area-inset-top)); }
}

/* Sekcja "Notatki" na profilu kontrahenta: przycisk dodawania w nagłówku (jak w innych sekcjach), link do modułu jako cichy pasek pod listą. */
.profile-collapsible-actions { display: inline-flex; align-items: center; gap: 12px; flex-shrink: 0; }
.profile-notes-footer {
    display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 24px; border-top: 1px solid rgba(226, 232, 240, 0.8);
    color: var(--accent-strong); font-size: 0.88rem; font-weight: 700; text-decoration: none; background: rgba(255, 255, 255, 0.5);
}
.profile-notes-footer:hover { background: var(--accent-soft); }
.profile-notes-footer .material-symbols-outlined { font-size: 1.1rem; }
@media (max-width: 768px) {
    .profile-collapsible-actions { gap: 8px; }
    .profile-collapsible-actions .btn-primary { padding: 8px 14px; min-height: 40px; font-size: 0.85rem; }
}

/* Weryfikacja dwuetapowa: wybór metody, konfiguracja aplikacji (QR, klucz, kody awaryjne) - login.php i Ustawienia -> Moje konto */
.twofa-options { display: grid; gap: 12px; }
.twofa-option {
    display: flex; align-items: flex-start; gap: 14px; width: 100%; padding: 16px 18px; text-align: left; cursor: pointer; font: inherit; color: var(--text);
    border: 1.5px solid var(--border); border-radius: 20px; background: #fff; transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.twofa-option:hover, .twofa-option:focus-visible { border-color: var(--accent); box-shadow: 0 10px 28px rgba(249, 115, 22, 0.14); transform: translateY(-1px); outline: none; }
.twofa-option.is-recommended { border-color: rgba(249, 115, 22, 0.45); background: var(--accent-soft); }
.twofa-option-icon { flex: 0 0 auto; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; background: #f1f5f9; color: #475569; font-size: 1.5rem; }
.twofa-option.is-recommended .twofa-option-icon { background: #fff; color: var(--accent-strong); }
.twofa-option-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.twofa-option-text strong { font-size: 1rem; line-height: 1.3; }
.twofa-option-text small { color: #64748b; font-size: 0.84rem; line-height: 1.45; }
.twofa-option-text em { font-style: normal; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; margin-left: 6px; border-radius: 999px; background: rgba(148, 163, 184, 0.2); color: #475569; vertical-align: 2px; }
.twofa-option.is-recommended em { background: var(--accent); color: #fff; }
.twofa-qr { width: 240px; max-width: 100%; margin: 0 auto; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06); }
.twofa-qr svg { display: block; width: 100%; height: auto; }
.twofa-manual summary { cursor: pointer; font-size: 0.88rem; font-weight: 700; color: var(--accent-strong); }
.twofa-key { display: block; padding: 12px 14px; border-radius: 12px; background: #f1f5f9; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: 0.08em; word-break: break-word; user-select: all; }
.twofa-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.twofa-codes code { padding: 10px 8px; text-align: center; border-radius: 12px; background: #f1f5f9; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; letter-spacing: 0.06em; user-select: all; }
.twofa-codes-card { padding: 16px 18px; border-radius: 18px; background: #fff7ed; border: 1px solid #fed7aa; }
.twofa-setup-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.twofa-actions { display: grid; gap: 14px; }
@media (max-width: 768px) {
    .twofa-setup-grid { grid-template-columns: minmax(0, 1fr); }
    .twofa-option { padding: 14px; }
}

