﻿
.toolbar {
    display: flex;
    position: sticky;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    z-index: 10;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--dash-card-bg);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    padding: 0 0.75rem;
}

    .search-box i {
        color: var(--dash-text-faint);
        font-size: 0.875rem;
    }

    .search-box input {
        flex: 1;
        border: none;
        outline: none;
        font-size: 0.875rem;
        color: var(--dash-text);
        background: transparent;
        min-width: 0;
        height: 38px;
    }

        .search-box input::placeholder {
            color: var(--dash-text-faint);
        }

.btn-clear {
    background: none;
    border: none;
    color: var(--dash-text-faint);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .btn-clear:hover {
        color: var(--dash-text-muted);
    }

.btn-action {
    height: 38px;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    background: var(--dash-card-bg);
    color: var(--dash-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

    .btn-action:hover {
        border-color: var(--dash-primary);
        color: var(--dash-primary);
    }

    .btn-action:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.sort-box {
    flex-shrink: 0;
    display: flex;
    justify-items: center;
    flex-direction: row;
    gap: 0.25rem;
}

    .sort-box select {
        height: 38px;
        padding: 0 2rem 0 0.75rem;
        border: 1px solid var(--dash-border);
        border-radius: var(--dash-radius-sm);
        background: var(--dash-card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
        font-size: 0.8125rem;
        color: var(--dash-text);
        cursor: pointer;
        appearance: none;
    }

        .sort-box select:focus {
            outline: none;
            border-color: var(--dash-primary);
        }

/* ── Column settings ── */
.column-settings {
    background: var(--dash-card-bg);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--dash-shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

    .column-settings h4 {
        font-size: 0.8125rem;
        font-weight: 600;
        color: var(--dash-text);
        margin: 0;
    }

.column-toggle {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--dash-text-muted);
    cursor: pointer;
}

    .column-toggle input {
        width: 14px;
        height: 14px;
        accent-color: var(--dash-primary);
    }

.table-card {
    flex: 0 1 auto;
    background: var(--dash-card-bg);
    border-radius: var(--dash-radius);
    box-shadow: var(--dash-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.table-scroll {
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 55vh;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    table-layout: auto;
    margin-bottom: 0;
}

    .table thead th:last-child,
    .table tbody td:last-child {
        width: 100%;
    }

    .table-card .table tfoot td:last-child {
        width: auto;
    }

    .table thead {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--dash-bg);
    }

    .table tr{
        width: 100%;
    }

    .table th {
        padding: 0.625rem 0.75rem;
        text-align: left;
        font-weight: 600;
        color: var(--dash-text-muted);
        font-size: 0.6875rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        border-bottom: 1px solid var(--dash-border);
        white-space: nowrap;
        background: var(--dash-bg);
        width: 100%;
    }

        .table th.text-right {
            text-align: right;
        }

    .table td {
        padding: 0.625rem 0.75rem;
        color: var(--dash-text);
        border-bottom: 1px solid var(--dash-bg-subtle);
        white-space: nowrap;
    }

    .table tbody{
        overflow-y: auto;
    }

    .table tbody tr:hover {
        background: var(--dash-bg);
    }

    .table tfoot {
        position: sticky;
        bottom: 0;
        font-weight: 400;
        background: var(--dash-bg-subtle);
        z-index: 10;
    }

        .table tfoot td {
            padding: 0.75rem;
            border-bottom: none;
            border-top: 2px solid var(--dash-border);
            font-weight: 400;
            background: var(--dash-bg-subtle);
        }

/* ── Cell helpers ── */
.text-right {
    text-align: right;
}

    .text-right.amount-positive {
        color: var(--dash-primary);
        font-weight: 600;
    }

.doc-cell {
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.opis-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--dash-text-muted);
    font-size: 0.75rem;
}

/* ── Loading / empty ── */
.loading-state {
    padding: 1rem;
    flex: 1;
}

.skeleton-row {
    height: 44px;
    background: linear-gradient(90deg, var(--dash-bg-subtle) 25%, var(--dash-border) 50%, var(--dash-bg-subtle) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--dash-radius-xs);
    margin-bottom: 6px;
}

    .skeleton-row:last-child {
        margin-bottom: 0;
    }

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--dash-text-faint);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

    .empty-state i {
        font-size: 2rem;
        margin-bottom: 0.75rem;
        opacity: 0.5;
    }

    .empty-state p {
        margin: 0;
        font-size: 0.875rem;
    }

/* ── Responsive ── */
@media (max-width: 768px) {
    .toolbar {
        margin-bottom: 0.5rem;
    }

    .search-box input {
        font-size: 0.8125rem;
    }

    .sort-box select {
        height: 36px;
        font-size: 0.75rem;
        padding: 0 1.75rem 0 0.625rem;
    }

    .btn-action {
        height: 36px;
        width: 36px;
    }

    .table-card {
        border-radius: 10px;
    }

    .table {
        font-size: 0.75rem;
    }

        .table th,
        .table td {
            padding: 0.5rem 0.625rem;
        }

        .table th {
            font-size: 0.625rem;
        }

    .column-settings {
        padding: 0.625rem;
        gap: 0.5rem;
    }

        .column-settings h4 {
            width: 100%;
            font-size: 0.75rem;
        }

    .column-toggle {
        font-size: 0.6875rem;
    }
}

@media (max-width: 480px) {
    .toolbar {
        flex-direction: column;
        gap: 0.375rem;
    }

    .search-box {
        width: 100%;
    }

    .sort-box {
        width: 100%;
    }

        .sort-box select {
            flex: 1;
        }

    .table {
        font-size: 0.6875rem;
    }

        .table th,
        .table td {
            padding: 0.375rem 0.5rem;
        }
}

.cell-link {
    color: var(--dash-primary);
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s, opacity 0.15s;
    padding-bottom: 1px;
}

    .cell-link:hover {
        border-bottom-color: var(--dash-primary);
        opacity: 0.85;
    }