@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&display=swap');

/* ✦ Maat Tools — Design System ✦ */
:root {
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --bg-sidebar-hover: rgba(255,255,255,.08);
    --bg-sidebar-active: rgba(99,102,241,.25);
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
    --radius: 12px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    --transition: .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    min-height: 100vh;
}

/* ?? Sidebar ?? */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    overflow-y: auto;
}

.app-sidebar .sidebar-brand {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.app-sidebar .sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
}

.app-sidebar .sidebar-brand-icon--svg {
    background: transparent;
    width: 42px;
    height: 42px;
    padding: 0;
    filter: drop-shadow(0 0 10px rgba(251,191,36,0.35));
}
.app-sidebar .sidebar-brand-icon--svg svg { width: 100%; height: 100%; }

.app-sidebar .sidebar-brand-text {
    font-family: 'Cormorant Garamond', 'Inter', serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: #fff;
    letter-spacing: .18em;
    background: linear-gradient(180deg, #fde68a 0%, #fbbf24 70%, #d97706 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-sidebar .sidebar-brand-sub {
    font-size: .7rem;
    color: var(--text-sidebar);
    font-weight: 400;
    display: block;
}

.sidebar-nav {
    list-style: none;
    padding: .75rem .625rem;
    margin: 0;
    flex: 1;
}

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1rem;
    border-radius: 8px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: all var(--transition);
}

.sidebar-nav a:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
}

.sidebar-nav .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: .7;
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav a:hover .nav-icon {
    opacity: 1;
}

.sidebar-nav .nav-badge {
    margin-left: auto;
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #1f2937;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-bottom {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-bottom .btn-logout {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .5rem 1rem;
    border: none;
    border-radius: 8px;
    background: rgba(239,68,68,.15);
    color: #fca5a5;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-bottom .btn-logout:hover {
    background: rgba(239,68,68,.3);
    color: #fff;
}

/* === Sidebar: trwające joby (importy/RFQ/AI) === */
.sidebar-jobs-wrapper {
    border-top: 1px solid rgba(255,255,255,.08);
    padding: .5rem .5rem .25rem .5rem;
    background: rgba(0,0,0,.15);
    display: flex;
    flex-direction: column;
    min-height: 0;       /* pozwala flexowi zmniejszyć ten element */
    max-height: 45vh;
}

.sidebar-jobs-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #9ca3af;
    font-weight: 600;
    padding: 4px 6px 6px;
    flex-shrink: 0;
}

.sidebar-job-banner {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 4px 4px 0;
}

/* Kompaktowa karta wewnątrz sidebara — overrides nad bootstrapowym .card */
.sidebar-job-banner .global-job-card {
    background: rgba(255,255,255,.05) !important;
    color: #e5e7eb !important;
    border: none !important;
    border-left: 3px solid #0d6efd !important;
    border-radius: 6px;
    margin-bottom: 6px;
    box-shadow: none !important;
    transition: background var(--transition);
}
.sidebar-job-banner .global-job-card:hover {
    background: rgba(255,255,255,.1) !important;
}
.sidebar-job-banner .global-job-card .card-body {
    padding: 6px 8px !important;
}
.sidebar-job-banner .global-job-card strong {
    color: #fff;
    font-size: 11px;
    line-height: 1.3;
    word-break: break-word;
}
.sidebar-job-banner .global-job-card .text-muted {
    color: #9ca3af !important;
}
.sidebar-job-banner .global-job-card .small {
    font-size: 10px !important;
    line-height: 1.3;
}
.sidebar-job-banner .global-job-card .text-primary {
    color: #93c5fd !important;
}
.sidebar-job-banner .global-job-card .text-danger {
    color: #fca5a5 !important;
}
.sidebar-job-banner .global-job-card .progress {
    background: rgba(255,255,255,.08) !important;
    height: 4px !important;
}

/* Cienki, ciemny scrollbar wewnątrz sidebara */
.sidebar-job-banner::-webkit-scrollbar { width: 6px; }
.sidebar-job-banner::-webkit-scrollbar-track { background: transparent; }
.sidebar-job-banner::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.15);
    border-radius: 3px;
}
.sidebar-job-banner::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.25);
}

/* === Sidebar zwinięty (compact) — używamy na stronie Projektu (więcej miejsca dla treści) === */
:root.sidebar-compact { --sidebar-width: 56px; }

.sidebar-compact .app-sidebar {
    transition: width .25s cubic-bezier(.4,0,.2,1);
}
/* Po hoverze rozwijaj sidebar na pełną szerokość — overlay nad treścią */
.sidebar-compact .app-sidebar:hover {
    width: 260px;
    box-shadow: 4px 0 16px rgba(0,0,0,.25);
    z-index: 1050;
}
/* Etykiety widoczne tylko po hoverze. Ukrywamy: brand text, .nav-label (etykieta menu), banner importów. */
.sidebar-compact .app-sidebar:not(:hover) .sidebar-brand > div:not(.sidebar-brand-icon),
.sidebar-compact .app-sidebar:not(:hover) .sidebar-brand-text,
.sidebar-compact .app-sidebar:not(:hover) .sidebar-brand-sub,
.sidebar-compact .app-sidebar:not(:hover) .nav-label,
.sidebar-compact .app-sidebar:not(:hover) .sidebar-jobs-wrapper {
    display: none !important;
}
/* W trybie compact bez hovera: brand bez tekstu, ikona wycentrowana */
.sidebar-compact .app-sidebar:not(:hover) .sidebar-brand {
    justify-content: center;
    padding: 1rem .5rem;
}
.sidebar-compact .app-sidebar:not(:hover) .sidebar-nav { padding: .75rem .25rem; }
.sidebar-compact .app-sidebar:not(:hover) .sidebar-nav a {
    justify-content: center;
    padding: .625rem 0;
    gap: 0;
}
.sidebar-compact .app-sidebar:not(:hover) .sidebar-bottom { padding: .5rem .25rem; }
.sidebar-compact .app-sidebar:not(:hover) .sidebar-bottom .btn-logout {
    justify-content: center;
    padding: .5rem 0;
    gap: 0;
}

/* ?? Main Content ?? */
.app-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 0;
    transition: margin-left var(--transition);
}

.app-topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(8px);
}

.app-topbar h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -.02em;
}

.app-topbar .breadcrumb-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .85rem;
    display: flex;
    align-items: center;
    gap: .25rem;
}

.app-content {
    padding: 1.5rem 2rem 3rem;
    max-width: 1400px;
}

/* ?? Cards ?? */
.page-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.page-card:hover {
    box-shadow: var(--shadow-md);
}

.page-card h5 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.page-card h5 .card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}

.card-icon-blue     { background: #eff6ff; color: #3b82f6; }
.card-icon-green    { background: #f0fdf4; color: #22c55e; }
.card-icon-purple   { background: #faf5ff; color: #a855f7; }
.card-icon-orange   { background: #fff7ed; color: #f97316; }
.card-icon-red      { background: #fef2f2; color: #ef4444; }
.card-icon-indigo   { background: #eef2ff; color: #6366f1; }
.card-icon-teal     { background: #f0fdfa; color: #14b8a6; }

/* ?? Stat Tiles ?? */
.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.stat-tile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-tile-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-tile-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-tile-label {
    font-size: .8rem;
    color: var(--text-secondary);
    margin-top: .15rem;
}

/* ?? Tables ?? */
.table-responsive {
    max-height: 520px;
    overflow-y: auto;
    border-radius: 8px;
}

.table {
    font-size: .85rem;
}

.table thead th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .05em;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #fafbfc;
}

.table tbody td {
    vertical-align: middle;
    padding: .5rem .75rem;
}

/* ?? Buttons ?? */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: .85rem;
    padding: .45rem 1rem;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: #fff;
}

.btn-primary:hover {
    opacity: .9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,.35);
}

.btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border: none;
}

.btn-success:hover {
    opacity: .9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34,197,94,.35);
}

.btn-outline-primary {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-sm {
    font-size: .78rem;
    padding: .3rem .65rem;
    border-radius: 6px;
}

/* ?? Forms ?? */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: .85rem;
    padding: .5rem .75rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .3rem;
}

/* ?? Alerts ?? */
.alert {
    border-radius: 10px;
    font-size: .85rem;
    border: none;
    padding: .75rem 1rem;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
}

/* ?? Badges ?? */
.badge {
    font-weight: 500;
    font-size: .72rem;
    padding: .3em .6em;
    border-radius: 6px;
}

/* ?? Progress ?? */
.progress {
    border-radius: 10px;
    background: #f1f5f9;
    overflow: hidden;
}

.progress-bar {
    border-radius: 10px;
    font-size: .75rem;
    font-weight: 600;
}

/* ?? Classification Panel ?? */
.classification-panel {
    background: linear-gradient(135deg, #f0f9ff 0%, #eff6ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 1.25rem;
}

/* ?? Collapsible Sections ?? */
.section-toggle {
    cursor: pointer;
    user-select: none;
}

.section-toggle::after {
    content: '?';
    margin-left: auto;
    font-size: .75rem;
    transition: transform var(--transition);
}

.section-toggle.collapsed::after {
    transform: rotate(-90deg);
}

/* ?? Import Preview ?? */
#importPreviewPanel .table th select {
    min-width: 80px;
}

/* ?? Responsive ?? */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

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

    .app-main {
        margin-left: 0;
    }

    .app-content {
        padding: 1rem;
    }

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

@media (max-width: 575.98px) {
    .stat-tiles {
        grid-template-columns: 1fr;
    }
}

/* ?? Scrollbar ?? */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ?? Misc ?? */
.nav-links a {
    margin-right: .5rem;
}

.small-muted {
    color: var(--text-secondary);
    font-size: .85rem;
}

/* ============================================================
   ✦ MAAT TOOLS — Login (auth-stage)
   ============================================================ */
.auth-stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99,102,241,0.25), transparent 60%),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(217,119,6,0.18), transparent 60%),
        linear-gradient(155deg, #050714 0%, #0a0e27 35%, #1a0f2e 70%, #050714 100%);
    color: #e5e7eb;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* — animated background — */
.auth-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    mix-blend-mode: screen;
    animation: orbFloat 22s ease-in-out infinite;
}

.auth-orb--gold {
    width: 520px; height: 520px;
    background: radial-gradient(circle, #fbbf24 0%, #d97706 40%, transparent 70%);
    top: -120px; left: -100px;
    animation-delay: -3s;
}

.auth-orb--violet {
    width: 600px; height: 600px;
    background: radial-gradient(circle, #8b5cf6 0%, #6366f1 40%, transparent 70%);
    bottom: -180px; right: -140px;
    animation-delay: -11s;
}

.auth-orb--cyan {
    width: 380px; height: 380px;
    background: radial-gradient(circle, #06b6d4 0%, #0891b2 40%, transparent 70%);
    top: 45%; left: 55%;
    opacity: .35;
    animation-delay: -7s;
    animation-duration: 28s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0,0) scale(1); }
    33%      { transform: translate(60px,-40px) scale(1.08); }
    66%      { transform: translate(-50px,30px) scale(.94); }
}

.auth-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 60% 70% at 50% 50%, #000 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 60% 70% at 50% 50%, #000 30%, transparent 80%);
}

/* — glass card — */
.auth-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    padding: 2.75rem 2.5rem 2rem;
    border-radius: 24px;
    background: linear-gradient(160deg, rgba(30,27,75,0.55) 0%, rgba(15,23,42,0.65) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow:
        0 30px 80px -20px rgba(0,0,0,0.7),
        0 0 0 1px rgba(255,255,255,0.04),
        inset 0 1px 0 rgba(255,255,255,0.08);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    z-index: 2;
    animation: cardRise 0.8s cubic-bezier(.16,.84,.3,1) both;
}

@keyframes cardRise {
    from { opacity: 0; transform: translateY(20px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-card.shake { animation: cardShake .45s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes cardShake {
    10%, 90% { transform: translateX(-3px); }
    20%, 80% { transform: translateX(5px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60% { transform: translateX(8px); }
}

.auth-card-glow {
    position: absolute;
    top: 0; left: 50%;
    width: 70%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(251,191,36,0.6), transparent);
    transform: translateX(-50%);
    box-shadow: 0 0 18px rgba(251,191,36,0.5);
}

/* — brand block — */
.auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-logo {
    width: 96px;
    height: 96px;
    margin: 0 auto .9rem;
    filter: drop-shadow(0 0 24px rgba(251,191,36,0.45)) drop-shadow(0 6px 14px rgba(0,0,0,0.45));
    animation: logoPulse 4s ease-in-out infinite;
}
.auth-logo svg { width: 100%; height: 100%; display: block; }

@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 24px rgba(251,191,36,0.45)) drop-shadow(0 6px 14px rgba(0,0,0,0.45)); }
    50%      { filter: drop-shadow(0 0 38px rgba(251,191,36,0.7)) drop-shadow(0 6px 14px rgba(0,0,0,0.45)); }
}

.auth-wordmark {
    font-family: 'Cormorant Garamond', 'Inter', serif;
    font-size: 2.15rem;
    font-weight: 600;
    letter-spacing: .35em;
    margin: 0;
    background: linear-gradient(180deg, #fde68a 0%, #fbbf24 60%, #d97706 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 1px 0 rgba(0,0,0,.2);
}

.auth-tagline {
    margin: .25rem 0 .15rem;
    font-size: .68rem;
    letter-spacing: .42em;
    text-transform: uppercase;
    color: rgba(167,139,250,0.85);
    font-weight: 600;
}

.auth-sub {
    margin: 0;
    font-size: .82rem;
    color: rgba(229,231,235,0.55);
}

/* — form — */
.auth-form { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.25rem; }

.auth-field {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-field-icon {
    position: absolute;
    left: 1rem;
    width: 18px; height: 18px;
    color: rgba(251,191,36,0.7);
    pointer-events: none;
    z-index: 2;
    transition: color .2s ease;
}
.auth-field-icon svg { width: 100%; height: 100%; }

.auth-input {
    width: 100%;
    padding: 1.55rem 1rem .55rem 2.85rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: #fff;
    font-size: .95rem;
    font-family: inherit;
    outline: none;
    line-height: 1.2;
    transition: all .25s cubic-bezier(.4,0,.2,1);
}

.auth-input:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.18);
}

.auth-input:focus {
    background: rgba(15,23,42,0.6);
    border-color: rgba(251,191,36,0.55);
    box-shadow:
        0 0 0 4px rgba(251,191,36,0.12),
        0 0 24px -4px rgba(251,191,36,0.35);
}

.auth-label {
    position: absolute;
    left: 2.85rem;
    top: 50%;
    transform: translateY(-50%) scale(1);
    transform-origin: left top;
    color: rgba(229,231,235,0.55);
    font-size: .9rem;
    font-weight: 500;
    pointer-events: none;
    background: transparent;
    padding: 0;
    transition: all .2s cubic-bezier(.4,0,.2,1);
}

.auth-input:focus + .auth-label,
.auth-input:not(:placeholder-shown) + .auth-label {
    top: .45rem;
    transform: translateY(0) scale(.72);
    color: #fbbf24;
    letter-spacing: .06em;
    font-weight: 600;
}

.auth-input:focus ~ .auth-field-icon,
.auth-field:has(.auth-input:focus) .auth-field-icon {
    color: #fbbf24;
}

/* — submit button — */
.auth-submit {
    position: relative;
    overflow: hidden;
    margin-top: .35rem;
    padding: .95rem 1.25rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 35%, #8b5cf6 100%);
    color: #0f172a;
    font-size: .92rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    box-shadow:
        0 10px 28px -6px rgba(251,191,36,0.45),
        0 0 0 1px rgba(255,255,255,0.15) inset;
    transition: all .3s cubic-bezier(.4,0,.2,1);
}

.auth-submit:hover {
    transform: translateY(-2px);
    box-shadow:
        0 16px 40px -8px rgba(251,191,36,0.6),
        0 0 0 1px rgba(255,255,255,0.25) inset;
}

.auth-submit:active { transform: translateY(0); }

.auth-submit-arrow {
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    font-size: 1.15rem;
    line-height: 1;
}

.auth-submit:hover .auth-submit-arrow { transform: translateX(4px); }

.auth-submit-shine {
    position: absolute;
    top: 0; left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(110deg, transparent, rgba(255,255,255,0.45), transparent);
    transition: left .7s ease;
}
.auth-submit:hover .auth-submit-shine { left: 130%; }

.auth-submit.is-loading {
    pointer-events: none;
    opacity: .75;
}
.auth-submit.is-loading .auth-submit-text::after {
    content: '...';
    display: inline-block;
    animation: dots 1s steps(4, end) infinite;
}
@keyframes dots {
    0%,20% { content: '.'; }
    40%    { content: '..'; }
    60%    { content: '...'; }
    80%,100%{ content: ''; }
}

/* — footer — */
.auth-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    font-size: .72rem;
    color: rgba(229,231,235,0.45);
    text-align: center;
}

.auth-lock svg { width: 12px; height: 12px; vertical-align: middle; color: rgba(251,191,36,0.7); }

.auth-version {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: .7rem;
    letter-spacing: .25em;
    color: rgba(229,231,235,0.3);
    text-transform: uppercase;
    z-index: 2;
}

/* — alert override on dark card — */
.auth-alert {
    background: rgba(239,68,68,0.12) !important;
    border: 1px solid rgba(239,68,68,0.3) !important;
    color: #fecaca !important;
    font-size: .82rem;
    padding: .65rem .9rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

/* — responsive — */
@media (max-width: 520px) {
    .auth-card { padding: 2rem 1.5rem 1.5rem; border-radius: 20px; }
    .auth-wordmark { font-size: 1.7rem; letter-spacing: .25em; }
    .auth-logo { width: 80px; height: 80px; }
}

/* ?? Empty State ?? */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: .75rem;
    opacity: .5;
}

.empty-state-text {
    font-size: .9rem;
}

/* ===== Dashboard główny ===== */
.dash-hero {
    background: linear-gradient(135deg, #0f172a 0%, #312e81 60%, #6366f1 130%);
    border-radius: var(--radius-lg);
    padding: 2rem 2.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: 0 12px 32px -12px rgba(99, 102, 241, .35);
}
.dash-hero::after {
    content: '';
    position: absolute; inset: -40% -20% auto auto;
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(251, 191, 36, .35), transparent 60%);
    pointer-events: none;
}
.dash-hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: .15em;
    font-size: .7rem;
    color: rgba(255,255,255,.65);
    margin-bottom: .35rem;
}
.dash-hero h1 {
    font-size: 1.85rem;
    font-weight: 800;
    margin: 0 0 .35rem 0;
    letter-spacing: -.02em;
}
.dash-hero-sub {
    font-size: .95rem;
    color: rgba(255,255,255,.78);
    margin: 0;
}
.dash-hero-meta {
    margin-top: 1rem;
    display: flex; gap: .5rem; flex-wrap: wrap;
    font-size: .78rem;
}
.dash-hero-chip {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    padding: .25rem .65rem;
    border-radius: 999px;
    backdrop-filter: blur(6px);
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 980px) {
    .dash-grid { grid-template-columns: 1fr; }
}

.dash-shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .85rem;
    margin-bottom: 1.5rem;
}
.dash-shortcut {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    display: flex; align-items: center; gap: .85rem;
    text-decoration: none; color: inherit;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.dash-shortcut:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-light);
    color: inherit;
}
.dash-shortcut-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.dash-shortcut-name { font-weight: 700; font-size: .95rem; }
.dash-shortcut-desc { font-size: .75rem; color: var(--text-secondary); }

/* Quick search (projekty / materiały) */
.quick-search {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
    min-height: 360px;
}
.quick-search-head {
    display: flex; align-items: center; gap: .55rem;
    font-weight: 700; font-size: 1rem; margin-bottom: .9rem;
}
.quick-search-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .6rem .85rem;
    font-size: .9rem;
    transition: all .15s;
}
.quick-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.quick-search-results {
    margin-top: .75rem;
    flex: 1;
    overflow-y: auto;
    max-height: 320px;
    display: flex; flex-direction: column; gap: .35rem;
    padding-right: .25rem;
}
.qs-item {
    display: block;
    padding: .55rem .7rem;
    border-radius: 8px;
    border: 1px solid transparent;
    text-decoration: none; color: inherit;
    transition: all .12s;
    cursor: pointer;
}
.qs-item:hover {
    background: #f8fafc;
    border-color: var(--border);
    color: inherit;
}
.qs-item-title { font-weight: 600; font-size: .88rem; color: var(--text-primary); }
.qs-item-meta  { font-size: .72rem; color: var(--text-secondary); margin-top: .15rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.qs-item-meta b { color: var(--text-primary); font-weight: 600; }
.qs-empty {
    color: var(--text-secondary);
    text-align: center; padding: 1.5rem .5rem;
    font-size: .85rem; font-style: italic;
}

/* Chat AI */
.chat-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    display: flex; flex-direction: column;
    min-height: 460px;
}
.chat-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .85rem; gap: .5rem;
}
.chat-head-left {
    display: flex; align-items: center; gap: .55rem;
    font-weight: 700; font-size: 1.05rem;
}
.chat-head-status {
    font-size: .72rem; padding: .15rem .55rem;
    border-radius: 999px;
    background: #ecfdf5; color: #047857;
    border: 1px solid #a7f3d0;
}
.chat-clear-btn {
    background: transparent; border: 1px solid var(--border);
    border-radius: 8px; padding: .3rem .65rem;
    font-size: .75rem; color: var(--text-secondary);
    cursor: pointer; transition: all .15s;
}
.chat-clear-btn:hover { background: #f1f5f9; color: var(--text-primary); }

.chat-head-right {
    display: flex; align-items: center; gap: .5rem;
    flex-wrap: wrap;
}
.chat-context-label {
    font-size: .78rem; color: var(--text-secondary); margin: 0;
}
.chat-context-select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .3rem .55rem;
    font-size: .78rem;
    background: #fff;
    color: var(--text-primary);
    max-width: 280px;
    cursor: pointer;
    transition: all .15s;
}
.chat-context-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.chat-context-chip {
    margin: .35rem 0 .55rem;
    padding: .55rem .85rem;
    background: linear-gradient(135deg, #faf5ff 0%, #eef2ff 100%);
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    font-size: .82rem;
    color: var(--text-primary);
    line-height: 1.4;
}
.chat-context-chip-hint {
    color: var(--text-secondary);
    font-size: .72rem;
    margin-left: .25rem;
}
.chat-context-chip-divider {
    color: var(--text-secondary);
    margin: 0 .35rem;
    opacity: .6;
}
.chat-scope-select { max-width: 200px; }

/* Przycisk wyboru plików */
.chat-files-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    font-weight: 500;
}
.chat-files-btn-active {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
}
.chat-files-btn-active:hover {
    background: var(--accent-gradient);
    color: #fff;
    opacity: .9;
}
.chat-files-badge {
    background: rgba(255,255,255,.25);
    padding: .05rem .4rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}
.chat-files-btn:not(.chat-files-btn-active) .chat-files-badge {
    background: var(--accent);
    color: #fff;
}

/* Chip-y wybranych plików */
.chat-files-chips {
    display: flex; flex-wrap: wrap; gap: .35rem;
    margin: .35rem 0 .55rem;
    padding: .55rem .65rem;
    background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    border-radius: 10px;
}
.chat-file-chip {
    display: inline-flex; align-items: center; gap: .3rem;
    background: #fff;
    border: 1px solid #fcd34d;
    border-radius: 999px;
    padding: .2rem .5rem .2rem .65rem;
    font-size: .78rem;
    color: var(--text-primary);
    max-width: 280px;
}
.chat-file-chip > span,
.chat-file-chip > strong {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-file-chip-ocr {
    margin-left: .25rem;
    background: #1e293b; color: #fff;
    padding: .05rem .3rem;
    border-radius: 4px;
    font-size: .65rem; font-weight: 700;
}
.chat-file-chip-x {
    background: transparent; border: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 1;
    font-size: 1rem;
}
.chat-file-chip-x:hover { background: #fee2e2; color: #991b1b; }
.chat-file-chip-clear {
    background: transparent; border: 1px dashed #d97706;
    color: #92400e;
    border-radius: 999px;
    padding: .2rem .65rem;
    font-size: .75rem;
    cursor: pointer;
}
.chat-file-chip-clear:hover {
    background: #fed7aa;
}

/* Modal selekcji plików */
.chat-files-list {
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .25rem;
}
.chat-files-group {
    border-bottom: 1px solid var(--border);
}
.chat-files-group:last-child { border-bottom: none; }
.chat-files-group-head {
    display: flex; align-items: center; gap: .5rem;
    padding: .55rem .75rem;
    background: #f8fafc;
    font-weight: 600;
    font-size: .85rem;
    cursor: default;
    position: sticky; top: 0; z-index: 1;
}
.chat-files-group-head label { cursor: pointer; flex: 1; margin: 0; }
.chat-files-group-count {
    font-size: .7rem;
    background: #cbd5e1; color: var(--text-secondary);
    border-radius: 999px;
    padding: .05rem .55rem;
}
.chat-files-group-body { padding: .25rem 0; }
.chat-files-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .45rem .75rem .45rem 2rem;
    cursor: pointer;
    transition: background .12s;
    margin: 0;
    font-size: .85rem;
    border-radius: 4px;
}
.chat-files-item:hover { background: #f1f5f9; }
.chat-files-item input[type="checkbox"] { flex-shrink: 0; }
.chat-files-item-icon { flex-shrink: 0; }
.chat-files-item-name {
    flex: 1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-files-item-meta {
    color: var(--text-secondary);
    font-size: .72rem;
    flex-shrink: 0;
}
.chat-file-tag-ocr {
    display: inline-block;
    background: #1e293b; color: #fff;
    padding: .05rem .3rem;
    border-radius: 4px;
    font-size: .62rem; font-weight: 700;
    margin-left: .35rem;
    vertical-align: 1px;
}

/* === Tryb generacji dokumentów === */
.chat-generate-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    font-weight: 500;
}
.chat-generate-btn-active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border-color: transparent;
}
.chat-generate-btn-active:hover {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    opacity: .9;
}

/* Bubble odpowiedzi z linkiem do pobrania DOCX */
.chat-bubble-doc {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: var(--text-primary);
    border: 1px solid #6ee7b7;
    border-bottom-left-radius: 4px;
    padding: .75rem 1rem;
    line-height: 1.55;
}
.chat-doc-actions {
    margin-top: .85rem;
    padding-top: .65rem;
    border-top: 1px solid rgba(16, 185, 129, .25);
}
.chat-doc-download {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--accent-gradient);
    color: #fff !important;
    padding: .55rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: .85rem;
    transition: transform .12s, box-shadow .12s;
}
.chat-doc-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px -6px rgba(99, 102, 241, .55);
    color: #fff !important;
}

/* === Q&A formularz dla missingFields === */
.chat-bubble-qa {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    border-bottom-left-radius: 4px;
    padding: .85rem 1rem;
    max-width: 95%;
}
.qa-intro { font-weight: 500; margin-bottom: .65rem; }
.qa-form { display: flex; flex-direction: column; gap: .7rem; }
.qa-field { display: flex; flex-direction: column; gap: .25rem; }
.qa-field-label {
    font-size: .82rem; font-weight: 600; color: var(--text-primary);
    display: flex; justify-content: space-between; align-items: center; gap: .5rem;
}
.qa-field-name {
    font-size: .7rem; background: rgba(0,0,0,.08); color: var(--text-secondary);
    padding: .05rem .35rem; border-radius: 4px; font-weight: 400;
}
.qa-field-input {
    background: #fff !important;
    border: 1px solid #fcd34d !important;
}
.qa-field-input:focus {
    border-color: #d97706 !important;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, .15);
}
.qa-field-hint { font-size: .72rem; color: var(--text-secondary); margin-top: .15rem; }
.qa-field-suggestions { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.qa-suggestion {
    background: #fff; border: 1px solid #fcd34d; color: #92400e;
    padding: .15rem .55rem; border-radius: 999px; font-size: .72rem;
    cursor: pointer; transition: all .12s;
}
.qa-suggestion:hover { background: #fcd34d; }
.qa-free {
    margin-top: .5rem; padding-top: .65rem; border-top: 1px dashed #fcd34d;
}
.qa-free ul { margin: .25rem 0 .5rem 1.2rem; padding: 0; font-size: .82rem; }
.qa-free-input { background: #fff !important; }
.qa-actions { display: flex; gap: .35rem; align-items: center; margin-top: .35rem; }
.qa-form-cancelled { opacity: .55; pointer-events: none; }

/* === Tabela ustawień projektu === */
.settings-table code {
    font-size: .82rem;
    background: #f1f5f9;
    padding: .1rem .4rem;
    border-radius: 4px;
}

/* === FilePreview modal === */
.file-preview-dialog {
    height: 92vh;
    max-width: min(1400px, 95vw);
}
.file-preview-dialog .modal-content {
    height: 100%;
}
.file-preview-body {
    overflow: auto;
    padding: 0;
    background: #f8fafc;
}
.file-preview-pdf {
    width: 100%;
    height: 100%;
    min-height: 75vh;
    border: none;
    display: block;
}

/* Renderowanie PDF przez PDF.js — canvasy stron */
.pdf-preview {
    background: #525659;
    padding: 1.25rem 0;
    min-height: 70vh;
}
.pdf-info {
    color: #d1d5db;
    text-align: center;
    font-size: .85rem;
    padding-bottom: .85rem;
}
.pdf-page-wrap {
    text-align: center;
    margin: 0 auto 1rem;
    position: relative;
}
.pdf-page {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
    max-width: 95%;
    height: auto;
    display: inline-block;
}
.pdf-page-num {
    color: #9ca3af;
    font-size: .72rem;
    margin-top: .35rem;
}
.file-preview-img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.file-preview-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: .82rem;
    padding: 1rem 1.5rem;
    margin: 0;
    background: #fff;
    line-height: 1.45;
    min-height: 100%;
}

/* DOCX preview rendered by mammoth.js */
.docx-preview {
    background: #fff;
    max-width: 800px;
    margin: 1.5rem auto;
    padding: 2.5rem 3rem;
    box-shadow: 0 2px 16px rgba(0,0,0,.08);
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #1f2937;
    min-height: 60vh;
}
.docx-preview h1, .docx-preview h2, .docx-preview h3 {
    font-family: inherit;
    font-weight: 700;
    margin-top: 1.4em;
    margin-bottom: .55em;
    line-height: 1.25;
    color: #111827;
}
.docx-preview h1 { font-size: 1.8em; text-align: center; }
.docx-preview h2 { font-size: 1.45em; }
.docx-preview h3 { font-size: 1.2em; }
.docx-preview p { margin: 0 0 .55em 0; text-align: justify; }
.docx-preview ul, .docx-preview ol { margin: .25em 0 .8em 1.5em; }
.docx-preview ul li, .docx-preview ol li { margin-bottom: .15em; }
.docx-preview table.docx-table, .docx-preview table {
    border-collapse: collapse;
    margin: .75em 0;
    width: 100%;
}
.docx-preview table th, .docx-preview table td {
    border: 1px solid #cbd5e1;
    padding: .35em .55em;
    vertical-align: top;
}
.docx-preview table th { background: #f1f5f9; font-weight: 600; }
.docx-preview strong { font-weight: 700; }
.docx-preview em { font-style: italic; }

/* Przycisk podglądu w bubble z wygenerowanym dokumentem */
.chat-doc-preview {
    display: inline-flex; align-items: center; gap: .35rem;
    background: #fff;
    color: #047857 !important;
    border: 1px solid #6ee7b7;
    padding: .5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    margin-right: .5rem;
    transition: all .15s;
}
.chat-doc-preview:hover {
    background: #ecfdf5;
    transform: translateY(-1px);
}

/* ===== Zakładka Pliki w projekcie ===== */
.files-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    min-height: 480px;
}
@media (max-width: 900px) {
    .files-layout { grid-template-columns: 1fr; }
}
.files-tree-pane, .files-content-pane {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex; flex-direction: column;
}
.files-pane-header {
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    font-weight: 600;
    font-size: .9rem;
    display: flex; justify-content: space-between; align-items: center;
}
.files-pane-stats { font-size: .75rem; color: var(--text-secondary); font-weight: 400; }
.files-tree { padding: .35rem 0; overflow-y: auto; flex: 1; max-height: 600px; }

.ft-node {
    display: flex; align-items: center; gap: .4rem;
    padding: .4rem .6rem;
    cursor: pointer;
    font-size: .85rem;
    transition: background .12s;
    border-left: 3px solid transparent;
}
.ft-node:hover { background: #f1f5f9; }
.ft-node.active { background: #eef2ff; border-left-color: var(--accent); font-weight: 600; }
.ft-icon { flex-shrink: 0; }
.ft-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-count {
    font-size: .7rem; padding: .1rem .4rem;
    background: #e2e8f0; color: var(--text-secondary);
    border-radius: 10px; min-width: 20px; text-align: center;
}
.ft-actions {
    display: none; gap: .15rem;
}
.ft-node:hover .ft-actions { display: flex; }
.ft-action-btn {
    background: transparent; border: none;
    width: 24px; height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: .75rem;
    transition: background .12s;
    padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.ft-action-btn:hover { background: #cbd5e1; }
.ft-action-btn.ft-danger:hover { background: #fecaca; }

.files-content-pane { position: relative; }
.files-content-pane > #filesList { flex: 1; overflow-y: auto; padding: .5rem 1rem 1rem; }

.files-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.files-table th {
    text-align: left;
    padding: .5rem .65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .03em;
    font-size: .7rem;
    border-bottom: 1px solid var(--border);
}
.files-table td {
    padding: .55rem .65rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.files-table tr:hover td { background: #f8fafc; }
.files-table .ft-icon-col { font-size: 1.25rem; text-align: center; }
.ft-file-name { font-weight: 500; word-break: break-word; }

.status-badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 500;
    white-space: nowrap;
}
.badge-pending      { background: #fef3c7; color: #92400e; }
.badge-processing   { background: #dbeafe; color: #1e40af; animation: chatPhasePulse 1.5s infinite ease-in-out; }
.badge-done         { background: #d1fae5; color: #065f46; }
.badge-failed       { background: #fee2e2; color: #991b1b; cursor: help; }
.badge-unsupported  { background: #f3e8ff; color: #6b21a8; }
.badge-ocr {
    display: inline-block;
    padding: .1rem .35rem;
    background: #1e293b; color: #fff;
    border-radius: 4px;
    font-size: .65rem;
    font-weight: 700;
    margin-left: .25rem;
    letter-spacing: .05em;
}

/* Drop zone */
.files-drop-overlay {
    position: absolute; inset: 0;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(99, 102, 241, .08);
    border: 3px dashed var(--accent);
    border-radius: var(--radius);
    pointer-events: none;
    z-index: 10;
    font-weight: 700;
    color: var(--accent);
    font-size: 1.1rem;
}
.files-drop-active .files-drop-overlay { display: flex; }

/* Permissions modal */
.files-perms-table th, .files-perms-table td { vertical-align: middle; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: .5rem .25rem;
    display: flex; flex-direction: column; gap: .75rem;
    min-height: 280px;
    max-height: 480px;
    scroll-behavior: smooth;
}
.chat-row { display: flex; gap: .55rem; }
.chat-row-user { justify-content: flex-end; }
.chat-row-ai   { justify-content: flex-start; }

.chat-bubble {
    max-width: 85%;
    padding: .65rem .85rem;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-bubble-user {
    background: var(--accent-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px -4px rgba(99, 102, 241, .45);
}
.chat-bubble-ai {
    background: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-bubble-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-bottom-left-radius: 4px;
}

.chat-phase {
    display: flex; align-items: center; gap: .8rem;
    background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
    border: 1px solid #c7d2fe;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: .7rem 1rem;
    max-width: 85%;
    box-shadow: 0 2px 6px -2px rgba(99, 102, 241, .25);
}
.chat-phase-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: #fff;
    border-radius: 50%;
    font-size: .95rem;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(99, 102, 241, .2);
}
.chat-phase-text { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.chat-phase-label {
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    word-wrap: break-word;
}
.chat-phase-dots { display: flex; gap: .35rem; align-items: center; }
.chat-phase-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: background .2s;
}
.chat-phase-dot.active {
    background: var(--accent);
    animation: chatPhasePulse 1.1s infinite ease-in-out;
}
.chat-phase-dot.done { background: #22c55e; }
@keyframes chatPhasePulse {
    0%, 100% { transform: scale(1);    opacity: 1;   }
    50%      { transform: scale(1.25); opacity: .65; }
}

.chat-typing {
    display: inline-flex; gap: .25rem;
    padding: .65rem 1rem;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.chat-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: #94a3b8;
    animation: chatTypingBounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-row {
    display: flex; gap: .5rem; align-items: stretch;
    margin-top: .75rem;
    padding-top: .85rem;
    border-top: 1px solid var(--border);
}
.chat-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .65rem .85rem;
    font-size: .9rem;
    resize: none;
    min-height: 44px;
    max-height: 140px;
    font-family: inherit;
    transition: all .15s;
}
.chat-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.chat-send-btn {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0 1.1rem;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s, opacity .12s;
}
.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px -6px rgba(99, 102, 241, .55);
}
.chat-send-btn:disabled { opacity: .55; cursor: not-allowed; }

.chat-empty {
    text-align: center; color: var(--text-secondary);
    padding: 2rem 1rem;
    font-size: .9rem;
}
.chat-empty-icon { font-size: 2rem; margin-bottom: .5rem; opacity: .55; }
.chat-suggestions {
    display: flex; flex-wrap: wrap; gap: .4rem;
    justify-content: center; margin-top: .85rem;
}
.chat-suggestion {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .35rem .8rem;
    font-size: .78rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
}
.chat-suggestion:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ============ Commitment popup (zlecenia/protokoły) ============ */
.commitment-popup-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
    gap: 16px;
    align-items: start;
}
@media (max-width: 992px) {
    .commitment-popup-layout {
        grid-template-columns: 1fr;
    }
}
.cp-section {
    background: #fafbfc;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}
.cp-allocations-table th {
    background: #f1f3f5;
    font-size: 12px;
    text-transform: uppercase;
    color: #495057;
    letter-spacing: 0.04em;
}
.cp-allocations-table td {
    vertical-align: middle;
}
.cp-allocations-table input.form-control,
.cp-allocations-table select.form-select {
    font-size: 13px;
    padding: 4px 6px;
}
.cp-alloc-status-ok { color: #198754; font-weight: 600; }
.cp-alloc-status-warn { color: #fd7e14; font-weight: 600; }
.cp-alloc-status-err { color: #dc3545; font-weight: 600; }

.cp-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 480px;
    max-height: 70vh;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    position: sticky;
    top: 0;
}
.cp-chat-header {
    padding: 10px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 14px;
}
.cp-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px;
    background: #fdfdfd;
}
.cp-chat-msg {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.cp-chat-msg-user {
    background: #e7f5ff;
    border-left: 3px solid #228be6;
}
.cp-chat-msg-assistant {
    background: #f1f3f5;
    border-left: 3px solid #868e96;
}
.cp-chat-msg-thinking {
    background: #fff3bf;
    border-left: 3px solid #fab005;
    font-style: italic;
}
.cp-chat-hint {
    color: #868e96;
    font-size: 12px;
    padding: 8px;
}
.cp-chat-input {
    padding: 8px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

/* ============ Finanse tab ============ */
.finance-summary-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
}
.finance-summary-table th {
    background: #f8f9fa;
    padding: 8px 10px;
    text-align: right;
    font-size: 12px;
    text-transform: uppercase;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}
.finance-summary-table th:first-child { text-align: left; }
.finance-summary-table td {
    padding: 8px 10px;
    text-align: right;
    border-bottom: 1px solid #f1f3f5;
}
.finance-summary-table td:first-child { text-align: left; font-weight: 500; }
.finance-summary-table tfoot td {
    font-weight: bold;
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
    border-bottom: none;
}
.finance-pct-pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.finance-pct-low { background: #fff3bf; color: #5c3c00; }
.finance-pct-mid { background: #d3f9d8; color: #2b8a3e; }
.finance-pct-high { background: #d0ebff; color: #1c7ed6; }

.commitment-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .15s;
}
.commitment-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.commitment-card.kind-order { border-left: 4px solid #228be6; }
.commitment-card.kind-protocol { border-left: 4px solid #40c057; }
.commitment-card.status-draft { background: #fff9db; }
.commitment-card.status-cancelled { opacity: .55; }
.commitment-card-title { font-weight: 600; font-size: 14px; }
.commitment-card-meta { font-size: 12px; color: #868e96; }

/* Akcje admin (rename/delete/new child) na węzłach drzewa Zestawienia. Pokazują się on hover. */
.tree-node .tree-actions {
    display: none;
    margin-left: 6px;
    gap: 2px;
}
.tree-node:hover .tree-actions {
    display: inline-flex;
}
.tree-act {
    background: transparent;
    border: 1px solid #dee2e6;
    color: #495057;
    font-size: 11px;
    padding: 0 4px;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1.3;
    height: 18px;
    min-width: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Puste grupy (z toggle „puste") — wyciszone wizualnie. */
.tree-node.tree-empty .label {
    color: #adb5bd;
    font-style: italic;
}
.tree-node.tree-empty .value {
    color: #ced4da;
}
.tree-act:hover {
    background: #e7f5ff;
    border-color: #74c0fc;
    color: #1c7ed6;
}
.tree-act-danger:hover {
    background: #ffe3e3;
    border-color: #ff8787;
    color: #c92a2a;
}
.material-rename-btn {
    background: transparent;
    border: none;
    color: #adb5bd;
    font-size: 12px;
    padding: 0 4px;
    margin-left: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}
tr:hover .material-rename-btn { opacity: 1; }
.material-rename-btn:hover { color: #1c7ed6; }

/* DnD w "Zestawienie materiałów" — admin może przeciągać L2/L3/items. */
.tree-node[draggable="true"] { cursor: grab; }
.tree-node[draggable="true"]:active { cursor: grabbing; }
.dnd-dragging { opacity: 0.4; }
.dnd-drop-target-active {
    background: linear-gradient(to right, #d3f9d8, #f1f3f5) !important;
    border-left: 3px solid #2b8a3e;
    box-shadow: inset 0 0 0 1px #2b8a3e;
}
.dnd-drop-target-invalid {
    background: #ffe3e3 !important;
    cursor: not-allowed;
}
tr[draggable="true"] { cursor: grab; }
tr[draggable="true"]:active { cursor: grabbing; }
tr.dnd-dragging { opacity: 0.4; background: #fff3bf !important; }

/* Mini-podsumowanie commitmentów w drzewku Realizacji pod każdym L1. */
.tree-l1-finance {
    padding: 3px 8px 3px 28px;
    margin-bottom: 3px;
    background: linear-gradient(to right, #fff9db, #fff);
    border-left: 3px solid #ffd43b;
    border-radius: 0 4px 4px 0;
    font-size: 11.5px;
    color: #495057;
    cursor: pointer;
    transition: background .12s;
}
.tree-l1-finance:hover {
    background: linear-gradient(to right, #ffec99, #fff9db);
}
