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

:root {
    --blue:       #0ea5e9;
    --blue-dark:  #0284c7;
    --blue-light: #e0f2fe;
    --bg:         #ffffff;
    --bg2:        #f8fafc;
    --bg3:        #f1f5f9;
    --border:     #e2e8f0;
    --text:       #0f172a;
    --muted:      #64748b;

    /* Ciemna szyna boczna (operator rail) - stale ciemna, taka sama jak tlo logo-icon.svg */
    --rail-bg:        #0f1318;
    --rail-bg-2:      #161b22;
    --rail-border:    #1e2633;
    --rail-text:      #e2e8f0;
    --rail-muted:     #7c8798;
    --rail-active-bg: rgba(56,189,248,.14);
    --rail-active-fg: #7dd3fc;

    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

html { font-size: 14px; }

html, body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg2);
    color: var(--text);
    line-height: 1.55;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }

.container { max-width: 1400px; margin: 0 auto; padding: 0 1.75rem; }
/* Zalogowany widok z przypiętym menu: tresc przesunieta blizej menu, nie wycentrowana na cala reszte ekranu */
html.sidebar-pinned main .container { margin-left: 0; }
@media (min-width: 701px) {
    html.sidebar-pinned main .container { padding-left: 2.75rem; }
}

/* ── NAV ─────────────────────────────────────────────────────── */
.panel-nav {
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 12px rgba(0,0,0,.06);
    padding: .9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.panel-nav .nav-left { display: flex; align-items: center; gap: 1.2rem; }
.panel-nav img.logo { height: 34px; display: block; }
.panel-nav .nav-right { display: flex; align-items: center; gap: 1rem; font-size: .88rem; color: var(--muted); }
.panel-nav .nav-right strong { color: var(--text); }
.nav-search input {
    padding: .4rem .7rem; border: 1.5px solid var(--border); border-radius: 999px;
    font-size: .82rem; width: 160px; background: var(--bg2); color: var(--text);
}
.nav-search input:focus { outline: none; border-color: var(--blue); background: var(--bg); width: 200px; transition: width .2s; }
@media (max-width: 700px) {
    .nav-search { display: none; }
}

/* ── HAMBURGER TOGGLE ────────────────────────────────────────── */
.nav-toggle {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 5px; width: 38px; height: 38px; border: none; background: transparent;
    cursor: pointer; border-radius: 8px; flex-shrink: 0;
}
.nav-toggle:hover { background: var(--bg3); }
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── SIDEBAR (wysuwane menu) ─────────────────────────────────── */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.45);
    opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 90;
}
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 240px; max-width: 85vw;
    background: var(--rail-bg); box-shadow: 4px 0 24px rgba(0,0,0,.12);
    transform: translateX(-100%); transition: transform .25s ease; z-index: 100;
    display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.2rem 1.2rem .8rem; border-bottom: 1px solid var(--rail-border);
}
.sidebar-brand { display: flex; align-items: center; }
.sidebar-head .logo { height: 26px; }
.sidebar-close {
    border: none; background: transparent; font-size: 1.6rem; line-height: 1;
    cursor: pointer; color: var(--rail-muted); padding: .2rem .5rem; border-radius: 6px;
}
.sidebar-close:hover { background: var(--rail-bg-2); color: var(--rail-text); }
.sidebar-head-actions { display: flex; align-items: center; gap: .2rem; }
.sidebar-section-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
    color: var(--rail-muted); padding: .7rem 1rem .3rem;
}
.sidebar ul { list-style: none; padding: 0 .6rem; display: flex; flex-direction: column; gap: .1rem; }
.sidebar ul a {
    display: block; padding: .7rem .9rem; border-radius: 8px;
    color: var(--rail-muted); font-weight: 600; font-size: .89rem;
    border-left: 2.5px solid transparent; transition: background .15s, color .15s;
}
.sidebar ul a:hover { background: var(--rail-bg-2); color: var(--rail-text); }
.sidebar ul a.active { background: var(--rail-active-bg); color: var(--rail-active-fg); border-left-color: var(--rail-active-fg); }
.sidebar ul a.active .badge { filter: brightness(1.1); }
.sidebar-foot {
    margin-top: auto; padding: 1rem 1.2rem 1.4rem; border-top: 1px solid var(--rail-border);
    display: flex; flex-direction: column; gap: .6rem; font-size: .85rem; color: var(--rail-muted);
}
.sidebar-foot .nav-user strong { color: var(--rail-text); }
.sidebar-foot .btn { width: 100%; justify-content: center; }
.sidebar-foot .btn-outline { color: var(--rail-text); border-color: var(--rail-border); }
.sidebar-foot .btn-outline:hover { border-color: var(--blue); color: var(--blue); }

@media (min-width: 701px) {
    .nav-right .nav-user { display: inline; }
    .sidebar-foot { display: none; }
    .sidebar-close { display: none; }
}
@media (max-width: 700px) {
    .nav-right .nav-user { display: none; }
}

/* ── PRZYPIETE MENU (stale widoczne, przesuwa tresc zamiast nakladki) ── */
html.sidebar-pinned .sidebar {
    transform: translateX(0);
    box-shadow: none;
    border-right: 1px solid var(--rail-border);
}
html.sidebar-pinned .sidebar-overlay { display: none; }
html.sidebar-pinned .panel-nav,
html.sidebar-pinned main {
    margin-left: 240px;
}
html.sidebar-pinned .nav-toggle { display: none; }

@media (max-width: 700px) {
    /* na telefonie przypiecie nie ma sensu - zawsze zachowuje sie jak chowane menu */
    html.sidebar-pinned .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0,0,0,.12);
        border-right: none;
    }
    html.sidebar-pinned .sidebar.open { transform: translateX(0); }
    html.sidebar-pinned .sidebar-overlay.open { display: block; }
    html.sidebar-pinned .panel-nav,
    html.sidebar-pinned main { margin-left: 0; }
    html.sidebar-pinned .nav-toggle { display: flex; }
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .58rem 1rem; border-radius: 8px;
    font-weight: 650; font-size: .9rem; text-decoration: none;
    transition: background .15s, border-color .15s, filter .15s; cursor: pointer;
    border: 1.5px solid transparent; font-family: inherit;
}
.btn-sm { padding: .4rem .75rem; font-size: .82rem; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-outline { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue-dark); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }

/* ── CARDS / PANELS ──────────────────────────────────────────── */
.card {
    background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
    padding: 1.5rem; transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: var(--border); box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px -12px rgba(15,23,42,.14); }
.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.3rem; flex-wrap: wrap; gap: 1rem; }
.page-head h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.015em; }
.page-wrap { padding: 2.5rem 0 4rem; }

/* ── FORMS ───────────────────────────────────────────────────── */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.field { margin-bottom: 1.2rem; }
input:not([type="checkbox"]):not([type="radio"]), textarea, select {
    background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px;
    padding: .8rem 1rem; color: var(--text); font-family: inherit; font-size: .9rem;
    transition: border-color .2s, box-shadow .2s; width: 100%;
}
input:not([type="checkbox"]):not([type="radio"]):focus, textarea:focus, select:focus {
    outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(14,165,233,.12);
}
input[type="checkbox"], input[type="radio"] {
    width: 1.05rem; height: 1.05rem; flex-shrink: 0; accent-color: var(--blue); cursor: pointer;
}
textarea { resize: vertical; min-height: 120px; }
.auth-card { max-width: 400px; margin: 4rem auto; }

/* ── BADGES (pigułka z kropką statusu) ──────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .22rem .65rem .22rem .55rem; border-radius: 999px;
    font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge--nowe       { background: var(--blue-light); color: var(--blue-dark); }
.badge--w_trakcie  { background: #fef3c7; color: #92400e; }
.badge--oczekuje_zewnetrzna { background: #ede9fe; color: #6d28d9; }
.badge--rozwiazane { background: #dcfce7; color: #166534; }
.badge--zamkniete  { background: var(--bg3); color: var(--muted); }
.badge--niski     { background: var(--bg3); color: var(--muted); }
.badge--sredni    { background: var(--blue-light); color: var(--blue-dark); }
.badge--wysoki    { background: #fed7aa; color: #9a3412; }
.badge--krytyczny { background: #fee2e2; color: #991b1b; }

/* ── ZAŁĄCZNIKI: MINIATURKI + LIGHTBOX ──────────────────────────── */
.attachment-thumb {
    display: block; width: 88px; height: 88px; border-radius: 10px; overflow: hidden;
    border: 1.5px solid var(--border); flex-shrink: 0; transition: border-color .15s;
}
.attachment-thumb:hover { border-color: var(--blue); }
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lightbox-overlay {
    display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .88);
    z-index: 1000; align-items: center; justify-content: center; padding: 3rem 1.5rem; cursor: zoom-out;
}
.lightbox-overlay.is-open { display: flex; }
.lightbox-overlay img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); cursor: default; }
.lightbox-close {
    position: absolute; top: 1rem; right: 1.4rem; background: none; border: none;
    color: #fff; font-size: 2.2rem; line-height: 1; cursor: pointer; padding: .3rem .6rem;
}

/* ── TABLE ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; background: var(--bg); border-radius: 14px; overflow: hidden; border: 1px solid var(--border); }
table th, table td { padding: .78rem .95rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .87rem; }
table th { color: var(--muted); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; background: var(--bg2); }
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--bg2); }
table a.row-link { color: var(--text); font-weight: 600; }
table a.row-link:hover { color: var(--blue); }
table tr.is-selected td { background: var(--blue-light); }
.row-preview-btn { text-decoration: none; opacity: .45; margin-right: .3rem; }
.row-preview-btn:hover { opacity: 1; }
@media (max-width: 1150px) { .row-preview-btn { display: none; } }
table.compact-table th, table.compact-table td { padding: .55rem .75rem; }
.unread-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--blue); margin-right: 6px; vertical-align: middle;
}
table tr.priority-krytyczny td:first-child { border-left: 4px solid #991b1b; }
table tr.priority-wysoki td:first-child { border-left: 4px solid #9a3412; }
table tr.priority-sredni td:first-child { border-left: 4px solid #0284c7; }
table tr.priority-niski td:first-child { border-left: 4px solid var(--border); }

/* ── STAT CARDS ──────────────────────────────────────────────── */
.stat-cards { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 130px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: .9rem 1rem; display: flex; flex-direction: column; text-align: left; }
.stat-card .num { order: 0; font-family: var(--font-mono); font-size: 1.55rem; font-weight: 600; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-card .label { order: -1; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .45rem; }
.stat-card.stat-krytyczny .num { color: #991b1b; }

/* ── THREAD ──────────────────────────────────────────────────── */
.thread-msg { border: 1.5px solid var(--border); border-radius: 14px; padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.thread-msg--admin { background: var(--blue-light); border-color: rgba(14,165,233,.3); }
.thread-msg--client { background: var(--bg); }
.thread-msg .meta { font-size: .78rem; color: var(--muted); margin-bottom: .4rem; }
.thread-msg .meta strong { color: var(--text); }
.thread-msg .body { white-space: pre-wrap; font-size: .92rem; }

/* ── FLASH ───────────────────────────────────────────────────── */
.flash { padding: .9rem 1.2rem; border-radius: 10px; margin-bottom: 1.5rem; font-size: .9rem; font-weight: 600; }
.flash--success { background: #dcfce7; color: #166534; }
.flash--error { background: #fee2e2; color: #991b1b; }

/* ── AI BOX ──────────────────────────────────────────────────── */
.ai-box { background: #f5f3ff; border: 1.5px solid #ddd6fe; border-radius: 14px; padding: 1.2rem 1.5rem; margin-bottom: 1.5rem; }
.ai-box-title { font-size: .85rem; font-weight: 700; color: #6d28d9; margin-bottom: .6rem; }
.ai-box-body { font-size: .92rem; color: var(--text); white-space: pre-wrap; line-height: 1.6; }
.ai-suggestion-note { font-size: .8rem; color: #6d28d9; background: #f5f3ff; border: 1px solid #ddd6fe; border-radius: 8px; padding: .5rem .8rem; margin-top: .5rem; }

/* ── TICKET DETAIL LAYOUT ────────────────────────────────────── */
.ticket-thread { display: flex; flex-direction: column; gap: 0; }
.ticket-modules { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; margin-top: 1.5rem; }
.ticket-mod-col { display: flex; flex-direction: column; gap: 1rem; }
.ticket-modules-full { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
@media (max-width: 800px) {
    .ticket-modules { grid-template-columns: 1fr; }
}

/* ── MASTER-DETAIL (kolejka zgłoszeń obok szczegółu) ─────────── */
.md-shell { display: grid; grid-template-columns: 340px 1fr; align-items: start; gap: 0; min-height: calc(100vh - 65px); }
.md-rail {
    border-right: 1px solid var(--border); background: var(--bg2);
    position: sticky; top: 65px; height: calc(100vh - 65px);
    display: flex; flex-direction: column;
}
.md-rail-head {
    padding: 1rem 1.2rem .8rem; font-size: .95rem; font-weight: 800; letter-spacing: -.01em;
    color: var(--text); flex-shrink: 0; border-bottom: 1px solid var(--border);
    display: flex; align-items: baseline; gap: .4rem;
}
.md-rail-list { overflow-y: auto; flex: 1; padding: .6rem; display: flex; flex-direction: column; gap: .4rem; }
.md-rail-item {
    display: block; padding: .7rem .8rem; border-radius: 10px; border-left: 4px solid transparent;
    text-decoration: none; color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-left-width: 4px;
}
.md-rail-item:hover { border-color: var(--border-strong, var(--border)); box-shadow: 0 1px 4px rgba(15,23,42,.06); }
.md-rail-item.active { background: var(--blue-light); border-color: var(--blue); box-shadow: 0 1px 6px rgba(14,165,233,.15); }
.md-rail-item--krytyczny { border-left-color: #991b1b; }
.md-rail-item--wysoki { border-left-color: #9a3412; }
.md-rail-item--sredni { border-left-color: #0284c7; }
.md-rail-item--niski { border-left-color: var(--border-strong, #cbd5e1); }
.md-rail-item-top { display: flex; align-items: center; gap: .4rem; margin-bottom: .35rem; }
.md-rail-item-id { font-size: .74rem; color: var(--faint, var(--muted)); }
.md-rail-item-status { margin-left: auto; font-size: .66rem; padding: .16rem .5rem .16rem .4rem; }
.md-rail-item-subject {
    font-size: .88rem; font-weight: 650; line-height: 1.35; margin-bottom: .3rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.md-rail-item-meta { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-rail-empty { padding: 1rem 1.2rem; font-size: .85rem; color: var(--muted); }
.md-rail-foot { padding: .8rem 1.2rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.md-rail-foot a { font-size: .84rem; font-weight: 600; }
.md-detail { min-width: 0; }
@media (max-width: 1150px) {
    .md-shell { display: block; }
    .md-rail { display: none; }
}

/* ── DASHBOARD: LISTA + PODGLĄD (master-detail) ──────────────── */
.dash-shell { display: grid; grid-template-columns: 1fr 460px; grid-template-rows: auto 1fr; column-gap: 1.5rem; row-gap: .6rem; align-items: start; }
.dash-col-head { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; }
.list-panel {
    background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
    overflow: hidden;
}
.list-panel table { border: none; border-radius: 0; }
.list-panel .empty-state { padding: 3rem 1.5rem; }

/* ── LISTA ZGŁOSZEŃ JAKO KARTY (jak kolejka w widoku zgłoszenia) ── */
.tix-list-head {
    display: flex; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid var(--border);
    background: var(--bg2); font-size: .82rem; color: var(--muted); font-weight: 600;
}
.tix-list-head label { display: flex; align-items: center; gap: .5rem; margin: 0; font: inherit; }
.tix-list { display: flex; flex-direction: column; gap: .5rem; padding: .6rem; }
.tix-card {
    display: flex; align-items: flex-start; gap: .7rem; padding: .8rem .9rem;
    background: var(--bg); border: 1px solid var(--border); border-left: 4px solid var(--border);
    border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
.tix-card:hover { box-shadow: 0 1px 4px rgba(15,23,42,.06); }
.tix-card.is-selected { background: var(--blue-light); border-color: var(--blue); }
.tix-card.priority-krytyczny { border-left-color: #991b1b; }
.tix-card.priority-wysoki { border-left-color: #9a3412; }
.tix-card.priority-sredni { border-left-color: #0284c7; }
.tix-card.priority-niski { border-left-color: var(--border); }
.tix-card-cb { margin-top: .2rem; flex-shrink: 0; }
.tix-card-main { min-width: 0; flex: 1; }
.tix-card-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.tix-card-id { font-size: .76rem; color: var(--muted); }
.tix-card-status { margin-left: auto; }
.tix-card-subject {
    display: block; font-size: .94rem; font-weight: 650; color: var(--text); margin-bottom: .4rem;
    line-height: 1.35;
}
.tix-card-subject:hover { color: var(--blue-dark); }
.tix-card-meta {
    display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
    font-size: .8rem; color: var(--muted);
}
@media (max-width: 700px) {
    .tix-card { flex-wrap: wrap; }
    .tix-card-meta { gap: .5rem .9rem; }
}
.dash-preview {
    position: sticky; top: calc(65px + 1.5rem);
    height: calc(100vh - 65px - 3rem);
    overflow-y: auto; overflow-anchor: none;
    background: var(--bg); border: 1.5px solid var(--border); border-radius: 14px;
}
.dash-preview-empty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); font-size: .9rem; }
.dash-preview-head { padding: 1.3rem 1.4rem 1rem; border-bottom: 1px solid var(--border); }
.dash-preview-head h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: .5rem; text-wrap: balance; }
.dash-preview-meta { font-size: .82rem; color: var(--muted); margin-bottom: .7rem; }
.dash-preview-badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.dash-preview-section { padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); }
.dash-preview-section:last-child { border-bottom: none; }
.dash-preview-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .6rem; }
.dash-preview-desc { font-size: .87rem; white-space: pre-wrap; line-height: 1.55; }
.dash-preview-thread { display: flex; flex-direction: column; gap: .7rem; max-height: 260px; overflow-y: auto; }
.dash-preview-msg { font-size: .85rem; background: var(--bg2); border-radius: 8px; padding: .6rem .7rem; }
.dash-preview-msg--admin { background: var(--blue-light); }
.dash-preview-msg .meta { font-size: .74rem; color: var(--muted); margin-bottom: .25rem; }
.dash-preview-msg .meta strong { color: var(--text); }
.dash-preview-status-form { display: flex; gap: .5rem; }
.dash-preview-status-form select { flex: 1; }
.dash-preview-reply-form textarea { min-height: 80px; margin-bottom: .6rem; }
.dash-preview-open-link { display: block; text-align: center; padding: .7rem; font-size: .83rem; font-weight: 600; }
@media (max-width: 1150px) {
    .dash-shell { display: block; }
    .dash-preview, .dash-col-head:nth-of-type(2) { display: none; }
}

/* ── UKLAD "GLOWNA KOLUMNA + BOCZNA" (harmonogramy, zadania) ─── */
.ticket-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start; }
.ticket-col-main, .ticket-col-side { display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 900px) {
    .ticket-layout { grid-template-columns: 1fr; }
}

/* ── FILTER BAR ──────────────────────────────────────────────── */
.filter-bar { display: flex; gap: .75rem; margin-bottom: 1.5rem; flex-wrap: wrap; align-items: center; }
.filter-bar select { width: auto; min-width: 160px; }

/* ── CHIP FILTERS ────────────────────────────────────────────── */
.chip-row { display: flex; gap: .45rem; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .38rem .85rem; border-radius: 999px; font-size: .86rem; font-weight: 600;
    background: var(--bg); border: 1px solid var(--border); color: var(--muted);
    text-decoration: none; transition: all .15s;
}
.chip:hover { border-color: var(--blue); color: var(--blue-dark); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }
.chip .chip-count { font-variant-numeric: tabular-nums; opacity: .75; }

.muted { color: var(--muted); }
.text-sm { font-size: .85rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* ── CALENDAR GRID ───────────────────────────────────────────── */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cal-nav-group, .cal-view-group { display: flex; gap: .4rem; }
.cal-title { font-size: 1.05rem; }

.cal-allday { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.cal-allday-chip { background: #ede9fe; color: #6d28d9; border-radius: 999px; padding: .3rem .9rem; font-size: .82rem; font-weight: 600; }

.cal-grid-wrap { overflow-x: auto; padding-bottom: .5rem; }

.cal-frame {
    display: grid;
    grid-auto-rows: auto 1fr;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    min-width: 100%;
    overflow: hidden;
}
.cal-corner { border-bottom: 1px solid var(--border); }
.cal-day-header {
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    text-align: center;
    font-size: .76rem;
    color: var(--muted);
    padding: .5rem 0;
    line-height: 1.4;
}
.cal-day-header strong { display: block; font-size: .85rem; color: var(--text); }

.cal-hours-col { width: 56px; }
.cal-hours-grid { display: grid; grid-template-columns: 1fr; height: 100%; }
.cal-hour-label {
    font-size: .7rem;
    color: var(--muted);
    text-align: right;
    padding: 2px 6px 0 0;
}

.cal-day-col { border-left: 1px solid var(--border); min-width: 100px; }
.cal-day-grid { display: grid; grid-template-columns: 1fr; height: 100%; position: relative; }
.cal-line { border-top: 1px solid #f1f5f9; }
.cal-line:first-child { border-top: none; }

.cal-event {
    background: var(--blue-light);
    border-left: 3px solid var(--blue);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: .72rem;
    line-height: 1.3;
    overflow: hidden;
    margin: 1px 3px;
    color: var(--blue-dark);
    text-decoration: none;
    display: block;
}
.cal-event:hover { filter: brightness(0.96); }
.cal-event--ticket { background: #ede9fe; border-left-color: #6d28d9; color: #6d28d9; }
.cal-event--task { background: #fef3c7; border-left-color: #d97706; color: #92400e; }
.cal-event-time { font-weight: 700; margin-right: 3px; }
.cal-event-badge { margin-left: 3px; }

@media (max-width: 700px) {
    .cal-hours-col { width: 44px; }
    .cal-day-col { min-width: 90px; }
}

/* ── AGENDA (lista pod kalendarzem z pełnymi godzinami) ───── */
.cal-agenda-section { margin-top: 1.5rem; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cal-agenda-heading { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg2); }
.cal-agenda-row { display: flex; align-items: baseline; gap: 1rem; padding: .6rem 1rem; border-bottom: 1px solid var(--border); font-size: .88rem; }
.cal-agenda-row:last-child { border-bottom: none; }
.cal-agenda-row--ticket { background: #f5f3ff; }
.cal-agenda-row--task { background: #fffbeb; }
.cal-agenda-time { min-width: 100px; font-variant-numeric: tabular-nums; color: var(--muted); flex-shrink: 0; font-size: .82rem; }
.cal-agenda-row--ticket .cal-agenda-time { color: #6d28d9; font-weight: 600; }
.cal-agenda-row--task .cal-agenda-time { color: #92400e; font-weight: 600; }
.cal-agenda-day { min-width: 44px; flex-shrink: 0; font-size: .82rem; }
.cal-agenda-title { flex: 1; font-weight: 500; }
.cal-agenda-title a { color: var(--text); text-decoration: none; }
.cal-agenda-title a:hover { text-decoration: underline; }
.cal-agenda-badge { flex-shrink: 0; }
.cal-agenda-row--slot-booked { background: #f0fdf4; }
.cal-agenda-row--slot-booked .cal-agenda-time { color: #15803d; font-weight: 600; }
.cal-agenda-row--slot-free { background: var(--bg); }
.cal-agenda-row--slot-free .cal-agenda-time { color: var(--muted); }
.cal-agenda-row--slot-done { background: var(--bg2); opacity: .7; }
.cal-agenda-row--slot-done .cal-agenda-time { color: var(--muted); }
.cal-agenda-row--slot-done .cal-agenda-title { text-decoration: line-through; text-decoration-color: var(--border); }
.cal-agenda-row--slot-failed { background: #fef2f2; }
.cal-agenda-row--slot-failed .cal-agenda-time { color: #b91c1c; font-weight: 600; }

/* ── SLOTY HARMONOGRAMU W SIATCE KALENDARZA ──────────────── */
.cal-event--slot-booked { background: #bbf7d0; border-left: 3px solid #16a34a; color: #14532d; }
.cal-event--slot-booked:hover { filter: brightness(0.95); }
.cal-event--slot-free { background: #f0fdf4; border-left: 3px solid #86efac; color: #6b7280; }
.cal-event--slot-free:hover { filter: brightness(0.97); }
.cal-slot-free-label { font-style: italic; }
.cal-event--slot-done { background: var(--bg2); border-left: 3px solid var(--border); color: var(--muted); opacity: .75; }
.cal-event--slot-done:hover { filter: brightness(0.97); }
.cal-event--slot-failed { background: #fee2e2; border-left: 3px solid #b91c1c; color: #7f1d1d; }
.cal-event--slot-failed:hover { filter: brightness(0.96); }
.cal-slot-status-icon { margin-right: 2px; }

/* ── STRONA REZERWACJI KLIENTA ───────────────────────────── */
.booking-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.booking-slot { border: 1.5px solid var(--border); border-radius: 12px; padding: 1rem; background: var(--bg); }
.booking-slot--free { border-color: #86efac; background: #f0fdf4; }
.booking-slot--taken { border-color: var(--border); background: var(--bg2); opacity: .7; }
.booking-slot--mine { border-color: #a78bfa; background: #f5f3ff; }
.booking-slot-time { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: .3rem; }
.booking-slot--free .booking-slot-time { color: #15803d; }
.booking-slot--mine .booking-slot-time { color: #6d28d9; }
.booking-slot-label { font-size: .82rem; color: var(--muted); }
.booking-slot--mine .booking-slot-label { color: #6d28d9; font-weight: 600; }
.booking-slot--done { border-color: var(--border); background: var(--bg2); opacity: .75; }
.booking-slot--done .booking-slot-time { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border); }
.booking-slot--done .booking-slot-label { color: #15803d; font-weight: 600; }
.booking-slot--failed { border-color: #fca5a5; background: #fef2f2; }
.booking-slot--failed .booking-slot-time { color: #b91c1c; }
.booking-slot--failed .booking-slot-label { color: #b91c1c; font-weight: 600; }

@media (max-width: 700px) {
    table.cards-on-mobile { border: none; background: transparent; }
    table.cards-on-mobile thead { display: none; }
    table.cards-on-mobile tr {
        display: block; background: var(--bg); border: 1.5px solid var(--border);
        border-radius: 14px; margin-bottom: .9rem; padding: .4rem .2rem;
    }
    table.cards-on-mobile tr.priority-krytyczny { border-left: 4px solid #991b1b; }
    table.cards-on-mobile tr.priority-wysoki { border-left: 4px solid #9a3412; }
    table.cards-on-mobile tr.priority-sredni { border-left: 4px solid #0284c7; }
    table.cards-on-mobile tr.priority-niski { border-left: 4px solid var(--border); }
    table.cards-on-mobile td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        border-bottom: none; padding: .45rem .8rem; text-align: right;
    }
    table.cards-on-mobile td[data-label]::before {
        content: attr(data-label); font-size: .72rem; font-weight: 700; color: var(--muted);
        text-transform: uppercase; letter-spacing: .04em; text-align: left;
    }
    table.cards-on-mobile td:empty { display: none; }

    .stat-cards { gap: .6rem; }
    .stat-card { min-width: 100px; padding: .8rem; }
    .stat-card .num { font-size: 1.4rem; }
}

/* ── PAGINACJA ───────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 1rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.pagination-info { font-size: .85rem; color: var(--muted); }

/* ── SZABLONY ODPOWIEDZI (canned) ────────────────────────────── */
.canned-picker { margin-bottom: .5rem; }
.canned-picker select { width: auto; min-width: 220px; font-size: .85rem; }

/* ── MASOWE OPERACJE ─────────────────────────────────────────── */
.bulk-bar { display: none; align-items: center; gap: .7rem; flex-wrap: wrap; padding: .7rem 1rem; background: #eff6ff; border: 1.5px solid #bfdbfe; border-radius: 10px; margin-bottom: 1rem; }
.bulk-bar.active { display: flex; }
.bulk-count { font-size: .85rem; font-weight: 600; color: #1d4ed8; min-width: 7rem; }
.bulk-bar select { width: auto; min-width: 200px; font-size: .85rem; }

/* ── AUDIT TIMELINE ──────────────────────────────────────────── */
.audit-timeline { display: flex; flex-direction: column; gap: 0; }
.audit-entry { display: flex; align-items: flex-start; gap: .7rem; padding: .45rem 0; position: relative; }
.audit-entry:not(:last-child)::after { content: ''; position: absolute; left: 5px; top: 22px; bottom: -4px; width: 1.5px; background: #e2e8f0; }
.audit-dot { width: 11px; height: 11px; border-radius: 50%; background: #94a3b8; border: 2px solid #e2e8f0; flex-shrink: 0; margin-top: 3px; }
.audit-body { font-size: .82rem; color: #334155; line-height: 1.4; }
.audit-author { font-weight: 700; }
.audit-old { color: #ef4444; text-decoration: line-through; }
.audit-new { color: #22c55e; font-weight: 600; }
.audit-time { font-size: .73rem; color: var(--muted); margin-top: .1rem; }

/* ── WYKRESY (overview) ──────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem; }
.chart-card { padding: 1.2rem; }
.chart-card--sm { }
.chart-title { font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 1rem; }
@media (max-width: 700px) {
  .charts-grid { grid-template-columns: 1fr; }
}

/* ── TYP PRACY (work_type) ───────────────────────────────────── */
.badge--work-zdalna    { background: #dbeafe; color: #1e40af; }
.badge--work-u_klienta { background: #fce7f3; color: #9d174d; }
