/* ============================================================
   DARN Group Dashboard - Stylesheet
   ============================================================ */

:root {
    --primary: #1a56db;
    --primary-dark: #1e40af;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #3b82f6;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 200px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: width 0.3s;
    display: flex;
    flex-direction: column;
}
.sidebar.collapsed { width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-header h2 { font-size: 0; }
.sidebar.collapsed .sidebar-header small,
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed ~ .main-content { margin-left: 0; max-width: 100vw; }
.sidebar.collapsed .sidebar-header { padding: 12px 8px; text-align: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 8px; }
.sidebar.collapsed .nav-item i { width: auto; font-size: 1rem; }

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h2 { color: #fff; font-size: 1.1rem; }
.sidebar-header small { color: var(--sidebar-text); font-size: 0.7rem; }

.sidebar-nav { padding: 6px 0; flex: 1; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.nav-item.active {
    background: rgba(59,130,246,0.15);
    color: #fff;
    border-left-color: var(--sidebar-active);
}
.nav-item i { width: 24px; min-width: 24px; text-align: center; font-size: 0.9rem; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 200px;
    min-height: 100vh;
    max-width: calc(100vw - 200px);
    overflow-x: hidden;
    transition: margin-left 0.3s, max-width 0.3s;
}

.top-bar {
    background: var(--card-bg);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.top-bar h1 { font-size: 1.2rem; font-weight: 600; }
.top-bar-right { margin-left: auto; color: var(--text-muted); font-size: 0.85rem; }
.menu-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}

.content-area { padding: 16px; }

/* Section Headers (Dashboard grouping) */
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 28px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border);
}
.section-header:first-child { margin-top: 0; }
.section-header i {
    font-size: 0.85rem;
    color: var(--primary);
    width: 20px;
    text-align: center;
}
.section-header h2 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.section-header .section-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Summary Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.summary-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border);
}
.summary-card .label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.2px;
    margin-bottom: 4px;
}
.summary-card .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.summary-card .value.positive { color: var(--success); }
.summary-card .value.negative { color: var(--danger); }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}
.card-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 0.9rem; font-weight: 600; }
.card-body { padding: 0; }
.card-body.padded { padding: 20px; }

/* Data Table */
.table-wrapper {
    overflow-x: auto;
    max-width: 100%;
    /* Fade hint when content overflows right */
    background:
        linear-gradient(to right, var(--card-bg) 30%, transparent) left center,
        linear-gradient(to left, var(--card-bg) 30%, transparent) right center,
        linear-gradient(to right, rgba(0,0,0,0.08), transparent) left center,
        linear-gradient(to left, rgba(0,0,0,0.08), transparent) right center;
    background-size: 20px 100%, 20px 100%, 10px 100%, 10px 100%;
    background-repeat: no-repeat;
    background-attachment: local, local, scroll, scroll;
}
/* Always show horizontal scrollbar when table overflows */
.table-wrapper::-webkit-scrollbar { height: 10px; }
.table-wrapper::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 5px; }
.table-wrapper::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 5px; }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: #64748b; }
@supports not selector(::-webkit-scrollbar) {
    .table-wrapper { scrollbar-width: auto; scrollbar-color: #94a3b8 #f1f5f9; }
}
table.data-table {
    min-width: 100%;
    width: max-content;
    border-collapse: collapse;
    font-size: 0.78rem;
    table-layout: auto;
}
table.data-table thead th {
    background: #f8fafc;
    padding: 7px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    line-height: 1.3;
}
table.data-table tbody td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}
/* Allow wrapping for text-heavy columns */
table.data-table tbody td.wrap { white-space: normal; word-break: break-word; }
/* Truncate long text columns (koment, shpjegim, etc.) */
table.data-table tbody td.truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.data-table tbody tr:hover { background: #f8fafc; }
table.data-table tbody tr.highlighted { background: #fef9c3; }

/* Row editing */
tr.editing { background: #eff6ff !important; }
tr.editing td { background: #eff6ff !important; }
tr.editing td.editable input,
tr.editing td.editable select {
    width: 100%;
    border: 1px solid var(--primary);
    padding: 4px 6px;
    font-size: 0.82rem;
    border-radius: 3px;
    background: #fff;
}
tr.editing td.editable input:focus,
tr.editing td.editable select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.15);
}
.row-edit-btn { margin-right: 4px; }
.row-save-btn { margin-right: 4px; }
td:last-child { white-space: nowrap; }

/* Number alignment */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Must out-rank `table.data-table thead th` (text-align:left) so numeric headers sit over their values */
table.data-table thead th.num { text-align: right; }
td.amount { text-align: right; font-variant-numeric: tabular-nums; }

/* Summary tables (Pasqyra overview) - center-aligned headers + values */
table.summary-table thead th { text-align: center; }
table.summary-table tbody td.amount { text-align: center; font-size: 0.95rem; font-weight: 600; padding: 10px 4px; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-cash { background: #dcfce7; color: #166534; }
.badge-bank { background: #dbeafe; color: #1e40af; }
.badge-fature { background: #fef3c7; color: #92400e; }
.badge-nopay { background: #fecaca; color: #991b1b; }
.badge-dhurate { background: #e9d5ff; color: #6b21a8; }

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* Add-new inline input */
.add-new-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
}
.add-new-wrap input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.add-new-cancel {
    flex-shrink: 0;
    padding: 6px 8px !important;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }

/* Filters */
.filters {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.filters .form-group { min-width: auto; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
}
.pagination .info { color: var(--text-muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages a, .pagination .pages span {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.8rem;
}
.pagination .pages span.current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Highlight for reconciled/verified rows */
tr.verified td { background: #f0fdf4; }
tr.verified td:first-child { border-left: 3px solid var(--success); }

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--sidebar-bg);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Table Search */
.table-search {
    padding: 8px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.table-search-input-wrap {
    position: relative;
    max-width: 400px;
}
.table-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.82rem;
    pointer-events: none;
}
.table-search-input {
    width: 100%;
    padding: 8px 70px 8px 34px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s;
}
.table-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.table-search-input::placeholder {
    color: #94a3b8;
}
.table-search-count {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
}
.table-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.table-search-clear:hover { color: var(--danger); }

/* Excel-like Column Filters */
.col-filter-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.col-filter-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.65rem;
    padding: 0 3px;
    opacity: 0.5;
    transition: opacity 0.15s;
    line-height: 1;
}
.col-filter-btn:hover,
.col-filter-btn.active { opacity: 1; color: var(--primary); }
.col-filter-dropdown {
    display: none;
    position: fixed;
    z-index: 300;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 220px;
    max-width: 300px;
    padding: 0;
}
.col-filter-dropdown.open { display: block; }
.col-filter-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.col-filter-search input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.78rem;
    font-family: inherit;
}
.col-filter-search input:focus {
    outline: none;
    border-color: var(--primary);
}
.col-filter-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}
.col-filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.1s;
}
.col-filter-item:hover { background: #f1f5f9; }
.col-filter-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}
.col-filter-item label {
    cursor: pointer;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: normal;
    color: var(--text);
}
.col-filter-item.select-all {
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin-bottom: 2px;
}
.col-filter-item.select-all label { font-weight: 600; }
.col-filter-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
}
.col-filter-actions button {
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
}
.col-filter-actions button.cf-ok {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.col-filter-actions button:hover { opacity: 0.85; }

/* Sort icon alongside filter — keep both visible */
th[data-filter] > i.fas { margin-right: 2px; }

/* Column Sorting — client-side (tables without server sort) */
table.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
table.data-table thead th.sortable:hover {
    background: #eef2f7;
}
table.data-table thead th.sort-asc,
table.data-table thead th.sort-desc {
    background: #e8eef6;
    color: var(--primary);
}
.sort-icon {
    font-size: 0.7rem;
    opacity: 0.5;
    margin-left: 2px;
}
th.sortable:hover .sort-icon,
th.sort-asc .sort-icon,
th.sort-desc .sort-icon { opacity: 1; }

/* Column Sorting — server-side (sort links in headers) */
.sort-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sort-link:hover { color: var(--primary); }
.sort-link .fas { font-size: 0.7rem; opacity: 0.4; }
.sort-link:hover .fas { opacity: 0.8; }
.sort-link.sort-active { color: var(--primary); font-weight: 600; }
.sort-link.sort-active .fas { opacity: 1; }

/* Responsive - Medium screens (laptops) */
@media (max-width: 1400px) {
    .sidebar { width: 180px; }
    .sidebar.collapsed { width: 0; overflow: hidden; }
    .main-content { margin-left: 180px; max-width: calc(100vw - 180px); }
    .sidebar.collapsed ~ .main-content { margin-left: 0; max-width: 100vw; }
    .nav-item { font-size: 0.78rem; padding: 6px 14px; }
    table.data-table { font-size: 0.74rem; }
    table.data-table thead th { font-size: 0.65rem; padding: 5px 6px; }
    table.data-table tbody td { padding: 4px 6px; }
    .summary-card .value { font-size: 1.1rem; }
    .badge { padding: 1px 5px; font-size: 0.67rem; }
}

/* Responsive - Smaller screens */
@media (max-width: 1100px) {
    .sidebar { width: 50px; }
    .sidebar.collapsed { width: 0; overflow: hidden; }
    .sidebar .sidebar-header h2 { font-size: 0; }
    .sidebar .sidebar-header small,
    .sidebar .nav-item span { display: none; }
    .main-content { margin-left: 50px; max-width: calc(100vw - 50px); }
    .sidebar.collapsed ~ .main-content { margin-left: 0; max-width: 100vw; }
    .sidebar-header { padding: 12px 8px; text-align: center; }
    .nav-item { justify-content: center; padding: 8px; }
    .nav-item i { width: auto; font-size: 1rem; }
    .summary-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* Responsive - Tablets/phones */
@media (max-width: 768px) {
    /* Sidebar becomes a slide-out overlay */
    .sidebar {
        width: 220px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar .sidebar-header { padding: 14px 16px; text-align: left; }
    .sidebar .sidebar-header h2 { font-size: 1.1rem; }
    .sidebar .sidebar-header small { display: block; }
    .sidebar .nav-item { justify-content: flex-start; padding: 9px 16px; }
    .sidebar .nav-item span { display: inline; }
    .sidebar .nav-item i { width: 24px; min-width: 24px; font-size: 0.9rem; }

    /* Overlay backdrop when sidebar is open */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 150;
    }
    .sidebar-backdrop.active { display: block; }

    /* Main content takes full width */
    .main-content { margin-left: 0; max-width: 100vw; }
    .sidebar.collapsed ~ .main-content { margin-left: 0; max-width: 100vw; }

    /* Top bar */
    .top-bar { padding: 8px 12px; }
    .top-bar h1 { font-size: 0.95rem; }
    .top-bar-right { font-size: 0.75rem; }

    /* Summary cards */
    .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
    .summary-card { padding: 10px 12px; }
    .summary-card .label { font-size: 0.65rem; }
    .summary-card .value { font-size: 1rem; }
    .summary-card small { font-size: 0.6rem; }

    /* Content area */
    .content-area { padding: 8px; }

    /* Tables */
    table.data-table { font-size: 0.7rem; }
    table.data-table thead th { font-size: 0.6rem; padding: 4px 5px; }
    table.data-table tbody td { padding: 3px 5px; }
    .table-wrapper { -webkit-overflow-scrolling: touch; }

    /* Summary tables (overview page) — stack vertically on mobile */
    table.summary-table,
    table.summary-table thead,
    table.summary-table tbody,
    table.summary-table tr,
    table.summary-table th,
    table.summary-table td {
        display: block;
        width: 100%;
    }
    table.summary-table thead tr { display: none; }
    table.summary-table tbody tr { display: flex; flex-direction: column; }
    table.summary-table tbody td.amount {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 14px;
        font-size: 0.9rem;
        text-align: left;
        border-bottom: 1px solid var(--border);
    }
    table.summary-table tbody td.amount::before {
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        flex-shrink: 0;
        max-width: 50%;
    }

    /* Cards */
    .card { margin-bottom: 12px; }
    .card-header { padding: 8px 10px; }
    .card-header h3 { font-size: 0.82rem; }

    /* Forms */
    .form-row { grid-template-columns: 1fr; gap: 8px; }
    .form-group input, .form-group select { font-size: 0.9rem; padding: 10px; }

    /* Modals — full width */
    .modal { width: 95%; max-width: none; border-radius: 8px; }
    .modal-body { padding: 14px; }
    .modal-header { padding: 12px 14px; }
    .modal-footer { padding: 10px 14px; }

    /* Filters */
    .filters { padding: 8px 10px; gap: 8px; }
    .filters .form-group { min-width: 100%; }

    /* Pagination */
    .pagination { padding: 8px 10px; font-size: 0.75rem; flex-wrap: wrap; gap: 6px; }

    /* Buttons */
    .btn { padding: 8px 12px; font-size: 0.8rem; }
    .btn-sm { padding: 5px 8px; font-size: 0.72rem; }

    /* Search */
    .table-search { padding: 6px 10px; }
    .table-search-input-wrap { max-width: 100%; }
}

/* Small phones */
@media (max-width: 400px) {
    .summary-grid { grid-template-columns: 1fr; }
    .summary-card .value { font-size: 1.1rem; }
    .top-bar h1 { font-size: 0.85rem; }
}

/* Utilities */
.hidden { display: none !important; }

/* Print-only elements (hidden on screen) */
/* Client debt modal table */
#clientDebtTable td,
#clientDebtTable th {
    padding: 8px 10px;
    vertical-align: middle;
    text-align: center;
}
#clientDebtTable td:first-child,
#clientDebtTable th:first-child {
    white-space: nowrap;
    text-align: left;
}
#clientDebtTable td:last-child,
#clientDebtTable th:last-child {
    text-align: left;
}
#clientDebtTable td.amount,
#clientDebtTable th.num {
    text-align: center;
}
#clientDebtTable tfoot td {
    border-top: 2px solid var(--border);
}

.print-only { display: none; }

/* Kartela print header */
.kartela-print-header {
    border: 1px solid #ddd;
    padding: 20px;
    margin-bottom: 16px;
}
.kartela-print-header .print-header-top {
    text-align: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #333;
}
.kartela-print-header .print-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    margin-bottom: 16px;
}
.kartela-print-header .print-info-item {
    display: flex;
    gap: 8px;
    font-size: 0.88rem;
    padding: 4px 0;
    border-bottom: 1px dotted #ccc;
}
.kartela-print-header .print-info-label {
    font-weight: 600;
    min-width: 130px;
    color: #555;
}
.kartela-print-header .print-info-value {
    font-weight: 500;
}
.kartela-print-header .print-summary-bar {
    display: flex;
    justify-content: space-around;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Print styles for PDF export */
@media print {
    @page {
        size: A4;
        margin: 0;
    }
    .sidebar, .sidebar-backdrop, .top-bar, .pagination, .btn,
    .print-hide, footer, .filters, .col-filter-btn,
    .table-search, .card-header {
        display: none !important;
    }
    .print-only {
        display: block !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .card {
        box-shadow: none !important;
        border: none !important;
    }
    .summary-grid {
        display: none !important;
    }
    table.data-table {
        font-size: 9pt;
        width: 100%;
    }
    table.data-table th {
        padding: 6px 8px;
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        border-bottom: 2px solid #333;
    }
    table.data-table td {
        padding: 4px 8px;
        border-bottom: 1px solid #e0e0e0;
    }
    table.data-table tfoot td {
        border-top: 2px solid #333;
        padding-top: 8px;
    }
    body {
        background: white;
        margin: 0;
        padding: 12mm 10mm;
    }
    .kartela-print-header .print-summary-bar {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    /* Borxhet print: red background rows */
    #borxhetTable tr[style*="fef2f2"] {
        background: #fef2f2 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ---- Login Page ---- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-header h1 {
    font-size: 1.6rem;
    color: var(--sidebar-bg);
    margin-bottom: 4px;
}
.login-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.login-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}
.login-field {
    margin-bottom: 16px;
}
.login-field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.login-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.login-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}
.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Sidebar footer (logout) */
.sidebar-footer {
    padding: 8px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}
.sidebar-footer .nav-item:hover { color: #fca5a5; }
