:root {
    --blue: #1263ff;
    --dark: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f5f7fb;
    --white: #fff;
    --danger: #b91c1c;
    --ok: #166534;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--dark);
}
a { color: var(--blue); text-decoration: none; font-weight: 700; margin-right: 10px; }
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 245px;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    font-size: 19px;
    font-weight: 800;
    margin-bottom: 22px;
}
.sidebar a {
    display: block;
    color: #111827;
    padding: 12px 14px;
    margin: 6px 0;
    border-radius: 12px;
}
.sidebar a.active,
.sidebar a:hover {
    background: var(--blue);
    color: white;
}
.content {
    flex: 1;
    padding: 28px;
}
h1 { margin-top: 0; }
.panel, .login-box {
    background: white;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 22px;
    box-shadow: 0 6px 18px rgba(0,0,0,.04);
}
.login-box {
    max-width: 420px;
    margin: 80px auto;
}
.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
label {
    display: block;
    margin: 10px 0 6px;
    font-weight: 700;
}
input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
}
textarea { min-height: 80px; }
button {
    margin-top: 14px;
    border: 0;
    background: var(--blue);
    color: white;
    font-size: 16px;
    font-weight: 800;
    padding: 12px 18px;
    border-radius: 12px;
    cursor: pointer;
}
button:hover { filter: brightness(.95); }
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}
th, td {
    text-align: left;
    padding: 13px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
th { background: #f9fafb; }
.cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
}
.card b {
    display: block;
    font-size: 34px;
}
.card span { color: var(--muted); }
.ok, .err, .suggest {
    padding: 13px 15px;
    border-radius: 12px;
    margin-bottom: 16px;
    background: #ecfdf5;
    color: var(--ok);
    border: 1px solid #bbf7d0;
}
.err {
    background: #fef2f2;
    color: var(--danger);
    border-color: #fecaca;
}
.suggest {
    background: #eff6ff;
    color: #1e3a8a;
    border-color: #bfdbfe;
}
.pill, .tag {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 13px;
    font-weight: 700;
}
.tag { margin: 6px 4px 0 0; }
@media (max-width: 800px) {
    .app {
        display: block;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 1000;
        padding: 10px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: #fff;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        display: flex;
        gap: 8px;
        align-items: center;
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .sidebar::-webkit-scrollbar {
        display: none;
    }
    .brand {
        margin-bottom: 0 !important;
        margin-right: 12px;
        font-size: 15px !important;
        flex: 0 0 auto;
    }
    .sidebar a {
        display: inline-block !important;
        margin: 0 !important;
        padding: 8px 12px !important;
        font-size: 13px !important;
        flex: 0 0 auto;
    }
    .content {
        padding: 16px;
        margin-top: 0;
    }
    .grid, .cards {
        grid-template-columns: 1fr;
    }
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 13px;
    }
    th, td {
        padding: 9px;
    }
}

@media (max-width: 600px) {
    .cards {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    .card {
        padding: 10px !important;
        text-align: center;
        border-radius: 12px !important;
    }
    .card b {
        font-size: 22px !important;
    }
    .card span {
        font-size: 10px !important;
    }
    .grid-2-mobile {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
}


.attachments-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.attachment-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    background: #fff;
}
.attachment-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
}
.pdf-box {
    height: 150px;
    border-radius: 10px;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    font-weight: 900;
    color: #6b7280;
    background: #f9fafb;
}
.attachment-name {
    margin-top: 8px;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.attachment-date {
    color: var(--muted);
    font-size: 12px;
    margin: 4px 0 8px;
}
.mini-upload {
    margin-top: 20px;
    border-top: 1px solid var(--line);
    padding-top: 15px;
}
.image-preview-btn {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}
.image-preview-btn img:hover {
    filter: brightness(.92);
}
.image-preview-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, .82);
    padding: 30px;
    align-items: center;
    justify-content: center;
}
.image-preview-modal.show {
    display: flex;
}
.image-preview-box {
    position: relative;
    max-width: 96vw;
    max-height: 92vh;
    text-align: center;
}
.image-preview-box img {
    max-width: 96vw;
    max-height: 84vh;
    width: auto;
    height: auto;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.image-preview-close {
    position: absolute;
    top: -18px;
    right: -18px;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 0;
    background: #fff;
    color: #111827;
    font-size: 30px;
    line-height: 38px;
    padding: 0;
    margin: 0;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.image-preview-name {
    color: #fff;
    margin-top: 10px;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.no-scroll {
    overflow: hidden;
}
@media (max-width: 900px) {
    .attachments-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .attachments-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .attachment-card { padding: 6px; border-radius: 10px; }
    .attachment-card img, .pdf-box { height: 95px; border-radius: 8px; }
    .attachment-name { font-size: 11px; margin-top: 4px; }
    .attachment-date { font-size: 10px; margin: 2px 0 4px; }
    .image-preview-modal { padding: 12px; }
    .image-preview-close { top: 8px; right: 8px; }
    .image-preview-box img { max-width: 96vw; max-height: 82vh; }
}

/* @media print - stylizacja wydruku i zapisu do PDF */
@media print {
    .sidebar, .no-print, .report-filter, .btn-link, button, .mini-upload, .image-preview-modal {
        display: none !important;
    }
    .app {
        display: block !important;
    }
    .content {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt !important;
    }
    .panel, table {
        border: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
    }
    th {
        background: #f3f4f6 !important;
        color: #000 !important;
    }
    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        background: #fff !important;
    }
    table {
        font-size: 10pt !important;
        width: 100% !important;
    }
    tr {
        page-break-inside: avoid !important;
    }
}
