/* ======================================================
   Satin Alma Sistemi - Custom Styles
   ====================================================== */

/* --- CSS Variables --- */
:root {
    --sidebar-width: 250px;
    --navbar-height: 56px;
    --sidebar-bg: #1a1a2e;
    --sidebar-hover: rgba(255,255,255,0.05);
    --sidebar-active-bg: rgba(60,85,209,0.15);
    --sidebar-active-color: #7c8aff;
    --sidebar-text: #8e95a9;
    --sidebar-text-hover: #c5cad8;
    --sidebar-section: #505668;

    /* Theme variables (light defaults) */
    --body-bg: #f8f9fa;
    --card-bg: #fff;
    --card-border: rgba(0,0,0,0.08);
    --text-color: #333;
    --text-muted: #6c757d;
    --text-heading: #333;
    --navbar-bg: #fff;
    --navbar-border: #e9ecef;
    --table-hover-bg: rgba(13, 110, 253, 0.04);
    --table-header-bg: #fafbfc;
    --border-color: #e9ecef;
    --border-light: #e0e0e0;
    --input-bg: #fff;
    --input-border: #ced4da;
    --dropdown-bg: #fff;
    --dropdown-border: rgba(0,0,0,0.15);
    --dropdown-hover: #f8f9fa;
    --placeholder-bg: #f0f0f0;
    --placeholder-color: #999;
    --highlight-bg: #f0f7ff;
    --highlight-border: #0d6efd;
    --avatar-bg: #eef0ff;
    --avatar-color: #3c55d1;
    --step-done: #198754;
    --step-pending: #dee2e6;
    --score-good-bg: #dbeafe;
    --score-good-color: #1e40af;
    --score-warn-bg: #fef3cd;
    --score-warn-color: #856404;
    --score-danger-color: #991b1b;
    --pct-good: #065f46;
    --pct-warn: #856404;
    --pct-danger: #991b1b;
    --bulk-bar-bg: #e8f0fe;
    --bulk-bar-border: #c5d5f5;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --body-bg: #0f172a;
    --card-bg: #1e293b;
    --card-border: rgba(255,255,255,0.06);
    --text-color: #e2e8f0;
    --text-muted: #94a3b8;
    --navbar-bg: #1e293b;
    --navbar-border: #334155;
    --table-hover-bg: rgba(255,255,255,0.04);
    --table-header-bg: #1a2332;
    --border-color: #334155;
    --input-bg: #0f172a;
    --input-border: #475569;
    --dropdown-bg: #1e293b;
    --dropdown-border: #334155;
    --dropdown-hover: #334155;
    --sidebar-bg: #0c1222;
    --text-heading: #e2e8f0;
    --border-light: #334155;
    --placeholder-bg: #1a2332;
    --placeholder-color: #64748b;
    --highlight-bg: rgba(59,130,246,0.1);
    --highlight-border: #3b82f6;
    --avatar-bg: rgba(60,85,209,0.15);
    --avatar-color: #7c8aff;
    --step-done: #22c55e;
    --step-pending: #334155;
    --score-good-bg: rgba(59,130,246,0.15);
    --score-good-color: #93c5fd;
    --score-warn-bg: rgba(234,179,8,0.15);
    --score-warn-color: #fde047;
    --score-danger-color: #fca5a5;
    --pct-good: #6ee7b7;
    --pct-warn: #fde047;
    --pct-danger: #fca5a5;
    --bulk-bar-bg: rgba(59,130,246,0.12);
    --bulk-bar-border: #334155;
}

[data-theme="dark"] .card {
    background: var(--card-bg) !important;
    border-color: var(--card-border) !important;
}
[data-theme="dark"] .card-header {
    background: var(--card-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--text-color) !important;
}
[data-theme="dark"] .card-body { color: var(--text-color); }
[data-theme="dark"] .table { color: var(--text-color); --bs-table-bg: transparent; }
[data-theme="dark"] .table th { color: var(--text-muted) !important; }
[data-theme="dark"] .table td { border-color: var(--border-color); }
[data-theme="dark"] .table-light { background: var(--table-header-bg) !important; }
[data-theme="dark"] .table-hover tbody tr:hover { background-color: var(--table-hover-bg) !important; }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-color) !important;
}
[data-theme="dark"] .form-label { color: var(--text-muted) !important; }
[data-theme="dark"] .breadcrumb-item a { color: #7c8aff; }
[data-theme="dark"] .breadcrumb-item.active { color: var(--text-muted); }
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] .text-dark { color: var(--text-color) !important; }
[data-theme="dark"] .dropdown-menu {
    background: var(--dropdown-bg) !important;
    border-color: var(--dropdown-border) !important;
}
[data-theme="dark"] .dropdown-item { color: var(--text-color) !important; }
[data-theme="dark"] .dropdown-item:hover { background: var(--dropdown-hover) !important; }
[data-theme="dark"] .dropdown-divider { border-color: var(--border-color); }
[data-theme="dark"] .list-group-item {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}
[data-theme="dark"] .bg-light { background: var(--table-header-bg) !important; }
[data-theme="dark"] .modal-content {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--border-color); }
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
    color: var(--text-color);
}
[data-theme="dark"] .page-title { color: var(--text-color); }
[data-theme="dark"] .inv-header { border-color: var(--border-color); }
[data-theme="dark"] .inv-meta-row { border-color: var(--border-color); }
[data-theme="dark"] .inv-meta-item { border-color: var(--border-color); }
[data-theme="dark"] .inv-meta-item .meta-value { color: var(--text-color); }
[data-theme="dark"] .inv-meta-item .meta-label { color: var(--text-muted); }
[data-theme="dark"] .inv-items-table thead th { background: var(--table-header-bg); color: var(--text-muted); border-color: var(--border-color); }
[data-theme="dark"] .inv-items-table tbody td { border-color: var(--border-color); }
[data-theme="dark"] .inv-summary-section { background: var(--table-header-bg); border-color: var(--border-color); }
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection { background: var(--input-bg); border-color: var(--input-border); color: var(--text-color); }
[data-theme="dark"] .select2-dropdown { background: var(--dropdown-bg); border-color: var(--dropdown-border); }
[data-theme="dark"] .select2-results__option { color: var(--text-color); }
[data-theme="dark"] .select2-results__option--highlighted { background: var(--dropdown-hover) !important; }
[data-theme="dark"] .swal2-popup {
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
}
[data-theme="dark"] .swal2-title { color: var(--text-color) !important; }
[data-theme="dark"] .swal2-html-container { color: var(--text-muted) !important; }

/* --- Utility Classes (theme-aware) --- */
.filter-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-heading);
}

.filter-area {
    border-bottom: 1px solid var(--border-color);
    background: var(--table-header-bg);
}

.filter-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}

.thumb-img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

.thumb-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--placeholder-bg);
    color: var(--placeholder-color);
    font-size: 0.9rem;
}

.user-avatar {
    background: var(--avatar-bg);
    color: var(--avatar-color);
}

.step-line {
    height: 3px;
}

.step-line-done {
    background: var(--step-done);
}

.step-line-pending {
    background: var(--step-pending);
}

.score-badge-good {
    background: var(--score-good-bg);
    color: var(--score-good-color);
}

.score-badge-warn {
    background: var(--score-warn-bg);
    color: var(--score-warn-color);
}

.pct-text-good { color: var(--pct-good); }
.pct-text-warn { color: var(--pct-warn); }
.pct-text-danger { color: var(--pct-danger); }

.bulk-bar {
    font-size: 0.85rem;
    background: var(--bulk-bar-bg);
    border-bottom: 1px solid var(--bulk-bar-border);
}

.highlight-section {
    background: var(--highlight-bg);
    border-top: 2px solid var(--highlight-border);
}

.section-border-right {
    border-right: 1px solid var(--border-color);
}

.section-border-top {
    border-top: 1px solid var(--border-color);
}

.section-border-bottom {
    border-bottom: 1px solid var(--border-color);
}

/* --- Body --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Top Navbar --- */
.navbar {
    z-index: 1030;
    background: var(--navbar-bg) !important;
    border-bottom: 1px solid var(--navbar-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* --- Navbar Icon Buttons --- */
.navbar-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}
.navbar-icon-btn:hover {
    background: var(--dropdown-hover);
    color: var(--text-color);
    border-color: var(--text-muted);
}
.navbar-icon-btn .navbar-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    background: #dc3545;
    color: #fff;
    border-radius: 10px;
}

/* --- Notification Dropdown --- */
.notification-dropdown {
    width: 360px;
    max-height: 420px;
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--dropdown-border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.notification-dropdown .notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--dropdown-bg);
}
.notification-dropdown .notif-header h6 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-color);
}
.notification-dropdown .notif-body {
    max-height: 320px;
    overflow-y: auto;
}
.notification-dropdown .notif-item {
    display: flex;
    gap: 0.65rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.15s ease;
}
.notification-dropdown .notif-item:hover {
    background: var(--dropdown-hover);
}
.notification-dropdown .notif-item.unread {
    background: rgba(60,85,209,0.04);
}
[data-theme="dark"] .notification-dropdown .notif-item.unread {
    background: rgba(124,138,255,0.08);
}
.notification-dropdown .notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}
.notification-dropdown .notif-dot.info { background: #3b82f6; }
.notification-dropdown .notif-dot.success { background: #22c55e; }
.notification-dropdown .notif-dot.warning { background: #f59e0b; }
.notification-dropdown .notif-dot.error { background: #ef4444; }
.notification-dropdown .notif-content { flex: 1; min-width: 0; }
.notification-dropdown .notif-title {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 2px;
}
.notification-dropdown .notif-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.notification-dropdown .notif-footer {
    text-align: center;
    padding: 0.6rem;
    border-top: 1px solid var(--border-color);
    background: var(--dropdown-bg);
}
.notification-dropdown .notif-footer a {
    font-size: 0.8rem;
    font-weight: 600;
    color: #3c55d1;
    text-decoration: none;
}

/* --- Profile Dropdown --- */
.profile-dropdown {
    min-width: 200px;
}
.profile-dropdown .profile-info {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.profile-dropdown .profile-info .fw-bold { color: var(--text-color); }
.profile-dropdown .profile-info small { color: var(--text-muted); }

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform 0.3s ease;
}

/* Sidebar Brand / Logo */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 0.5rem;
}
.sidebar-brand .brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #3c55d1, #7c8aff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-brand .brand-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e0e3eb;
    letter-spacing: -0.01em;
}

/* Sidebar Section Labels */
.sidebar-section {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-section);
    padding: 1.2rem 1.25rem 0.5rem;
}

.sidebar-inner {
    padding-top: 0;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.55rem 1.25rem;
    margin: 1px 0.65rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.sidebar .nav-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-hover);
}

.sidebar .nav-link.active {
    color: var(--sidebar-active-color);
    background: var(--sidebar-active-bg);
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}

/* Sidebar Accordion Groups */
.sidebar-group {
    margin-top: 2px;
}

.sidebar .sidebar-toggle {
    display: flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sidebar-section);
    padding: 0.7rem 1.25rem;
    margin: 0 0.65rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sidebar .sidebar-toggle:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-hover);
}

.sidebar .sidebar-toggle.active {
    color: var(--sidebar-text-hover);
    background: none;
    font-weight: 700;
}

.sidebar .sidebar-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}

.sidebar .sidebar-toggle[aria-expanded="true"] .sidebar-arrow {
    transform: rotate(180deg);
}

.sidebar .sidebar-sub {
    padding: 2px 0 4px 0;
    position: relative;
}

/* Tree vertical line */
.sidebar .sidebar-sub::before {
    content: '';
    position: absolute;
    left: calc(0.65rem + 1.25rem + 7px);
    top: 0;
    bottom: 12px;
    width: 1px;
    background: rgba(255,255,255,0.08);
}

/* Tree branch connector */
.sidebar .sidebar-sub .nav-item {
    position: relative;
}

.sidebar .sidebar-sub .nav-item::before {
    content: '';
    position: absolute;
    left: calc(0.65rem + 1.25rem + 7px);
    top: 50%;
    width: 10px;
    height: 1px;
    background: rgba(255,255,255,0.08);
}

/* Last item: trim the vertical line */
.sidebar .sidebar-sub .nav-item:last-child::after {
    content: '';
    position: absolute;
    left: calc(0.65rem + 1.25rem + 7px);
    top: 50%;
    bottom: 0;
    width: 1px;
    background: var(--sidebar-bg);
}

/* Active branch highlight */
.sidebar .sidebar-sub .nav-item:has(.nav-link.active)::before {
    background: var(--sidebar-active-color);
    opacity: 0.5;
}

.sidebar .sidebar-sub .nav-link {
    padding: 0.4rem 1.25rem 0.4rem 2.8rem;
    font-size: 0.82rem;
    margin: 0 0.65rem;
}

.sidebar-divider {
    border-top: 1px solid rgba(255,255,255,0.06);
    margin: 0.5rem 1.25rem;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
    padding: 0;
}

/* --- Messages Container --- */
.messages-container {
    position: fixed;
    top: calc(var(--navbar-height) + 1rem);
    right: 1rem;
    z-index: 1050;
    max-width: 400px;
    width: 100%;
}

.messages-container .alert {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 0.5rem;
}

/* --- Cards --- */
.card {
    box-shadow: 0 1px 3px var(--card-border);
    border-radius: 0.5rem;
    background: var(--card-bg);
}

.card-header {
    border-radius: 0.5rem 0.5rem 0 0 !important;
}

/* --- Tables --- */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #495057;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
    font-size: 0.9rem;
}

.table-hover tbody tr:hover {
    background-color: var(--table-hover-bg);
}

/* --- Status Badges --- */
.badge {
    font-weight: 500;
    padding: 0.4em 0.65em;
    font-size: 0.78rem;
}

/* --- DataTables Row Group Headers --- */
tr.dtrg-group {
    background-color: #e9ecef !important;
    cursor: pointer;
    user-select: none;
}

tr.dtrg-group:hover {
    background-color: #dee2e6 !important;
}

tr.dtrg-group td {
    color: #333;
    font-weight: 700;
}

tr.dtrg-group .group-toggle {
    color: #555;
}

/* Group end separator - hidden */
tr.dtrg-end {
    display: none !important;
}

/* Need links hover */
.need-link:hover {
    text-decoration: underline !important;
}

/* Overdue row bg */
.table tr.table-danger {
    background-color: #fde8e8 !important;
}

.table tr.table-danger:hover {
    background-color: #fbd5d5 !important;
}

/* --- Overdue / Urgent Row Highlighting --- */
.table-danger-subtle {
    background-color: rgba(220, 53, 69, 0.08) !important;
}

.table-danger-subtle:hover {
    background-color: rgba(220, 53, 69, 0.15) !important;
}

tr.table-danger td {
    color: #842029;
}

tr.table-warning td {
    color: #664d03;
}

/* --- Breadcrumbs --- */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0;
    font-size: 0.85rem;
}

.breadcrumb-item a {
    text-decoration: none;
}

/* --- Form Styling --- */
.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: #495057;
}

/* --- Buttons --- */
.btn {
    font-size: 0.875rem;
    border-radius: 0.375rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* --- Definition Lists (detail pages) --- */
dl.row dt {
    font-size: 0.85rem;
    color: #6c757d;
}

dl.row dd {
    font-size: 0.9rem;
}

/* --- Quote Comparison Cards --- */
.card.border-success.border-2 {
    box-shadow: 0 0 0 1px rgba(25, 135, 84, 0.3), 0 4px 12px rgba(25, 135, 84, 0.15);
}

.card.border-primary.border-2 {
    box-shadow: 0 0 0 1px rgba(13, 110, 253, 0.3), 0 4px 12px rgba(13, 110, 253, 0.15);
}

/* --- Pagination --- */
.pagination .page-link {
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
}

/* --- HTMX Loading Indicator --- */
.htmx-request {
    opacity: 0.65;
    transition: opacity 300ms linear;
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

/* --- Scrollbar (sidebar) --- */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

/* --- Login Page --- */
.login-wrapper-outer {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100%;
}

.login-wrapper {
    margin-left: 0 !important;
    margin-top: 0 !important;
}

/* ======================================================
   Responsive Adjustments
   ====================================================== */

/* --- Medium screens and below --- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .navbar {
        margin-left: 0;
        width: 100%;
    }

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

    .messages-container {
        max-width: 90%;
        right: 5%;
    }

    /* Sidebar overlay backdrop */
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1035;
        display: none;
    }
    .sidebar-backdrop.show {
        display: block;
    }
}

/* --- Small screens --- */
@media (max-width: 575.98px) {
    .table th,
    .table td {
        font-size: 0.8rem;
        padding: 0.35rem;
    }

    .btn-sm {
        padding: 0.2rem 0.35rem;
        font-size: 0.75rem;
    }

    .card-header h5 {
        font-size: 1rem;
    }

    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* --- Page Title --- */
.page-title {
    font-size: 1.25rem;
    font-weight: 700;
}

/* --- Filter Label --- */
.filter-label {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

/* --- Standard Table (replaces inline font-size:13px / 12px) --- */
.table-standard {
    font-size: 0.8125rem;
}

.table-standard > thead {
    font-size: 0.75rem;
}

/* --- Action Buttons (table row actions) --- */
.btn-action {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.4;
}

/* --- Empty State Icon --- */
.empty-state-icon {
    font-size: 2.5rem;
}

/* --- Treeview Group Header --- */
.group-header {
    cursor: pointer;
    user-select: none;
}

/* --- Collapse Chevron --- */
.collapse-chevron {
    transition: transform 0.2s ease;
}

[aria-expanded="false"] .collapse-chevron {
    transform: rotate(-90deg);
}

/* --- Status Left Border --- */
.border-status-success   { border-left: 3px solid #198754; }
.border-status-danger    { border-left: 3px solid #dc3545; }
.border-status-warning   { border-left: 3px solid #ffc107; }
.border-status-info      { border-left: 3px solid #0dcaf0; }
.border-status-primary   { border-left: 3px solid #0d6efd; }
.border-status-secondary { border-left: 3px solid #6c757d; }
.border-status-dark      { border-left: 3px solid #212529; }
.border-status-orange    { border-left: 3px solid #fd7e14; }
.border-status-muted     { border-left: 3px solid #adb5bd; }

/* --- Progress Bar Heights --- */
.progress-sm { height: 8px; }
.progress-md { height: 16px; }

/* --- Micro Animations --- */
.card {
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.table-hover tbody tr {
    transition: background-color 0.15s ease;
}

/* --- Utility: text-purple --- */
.text-purple { color: #7c3aed; }

/* ======================================================
   Dashboard
   ====================================================== */

/* KPI Cards — Xintra style: tinted background, right-aligned circle icon */
.kpi-card {
    border: none;
    border-radius: 0.75rem;
    overflow: hidden;
}
.kpi-card:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    transition: all 0.2s ease;
}
.kpi-card .card-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kpi-card .kpi-content { flex: 1; }
.kpi-card .kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
    opacity: 0.75;
}
.kpi-card .kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}
.kpi-card .kpi-trend {
    font-size: 0.72rem;
    font-weight: 500;
}
.kpi-card .kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-left: 1rem;
}

/* KPI tinted card themes */
.kpi-danger  { background: linear-gradient(135deg, #fff0f0, #ffe0e0); }
.kpi-danger .kpi-label, .kpi-danger .kpi-value { color: #c0392b; }
.kpi-danger .kpi-icon  { background: rgba(192,57,43,0.15); color: #c0392b; }

.kpi-warning { background: linear-gradient(135deg, #fff8eb, #fff0d4); }
.kpi-warning .kpi-label, .kpi-warning .kpi-value { color: #b8860b; }
.kpi-warning .kpi-icon { background: rgba(184,134,11,0.15); color: #b8860b; }

.kpi-info    { background: linear-gradient(135deg, #eef6ff, #ddeeff); }
.kpi-info .kpi-label, .kpi-info .kpi-value { color: #2471a3; }
.kpi-info .kpi-icon    { background: rgba(36,113,163,0.15); color: #2471a3; }

.kpi-primary { background: linear-gradient(135deg, #eef0ff, #dde3ff); }
.kpi-primary .kpi-label, .kpi-primary .kpi-value { color: #3c55d1; }
.kpi-primary .kpi-icon { background: rgba(60,85,209,0.15); color: #3c55d1; }

.kpi-success { background: linear-gradient(135deg, #eefbf3, #d4f5e2); }
.kpi-success .kpi-label, .kpi-success .kpi-value { color: #1a8a4a; }
.kpi-success .kpi-icon { background: rgba(26,138,74,0.15); color: #1a8a4a; }

.kpi-purple  { background: linear-gradient(135deg, #f5f0ff, #ebe0ff); }
.kpi-purple .kpi-label, .kpi-purple .kpi-value { color: #7c3aed; }
.kpi-purple .kpi-icon  { background: rgba(124,58,237,0.15); color: #7c3aed; }

/* Clickable KPI cards */
.kpi-clickable { cursor: pointer; }

/* PR Pipeline flow */
.pipeline-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem 0;
}
.pipeline-step {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-radius: 0.5rem;
    transition: background 0.15s;
}
.pipeline-step:hover {
    background: var(--table-hover-bg);
}
.pipeline-count {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
}
.pipeline-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}
.pipeline-bar {
    height: 4px;
    border-radius: 2px;
    margin-top: 0.25rem;
}
.pipeline-arrow {
    font-size: 0.65rem;
    flex-shrink: 0;
}

/* Dashboard card headers */
.dash-card-header {
    background: #fff;
    border-bottom: 1px solid #f0f0f5;
    padding: 1rem 1.25rem;
}
.dash-card-header h6 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0;
}

/* Dashboard tables */
.dash-table { font-size: 0.8125rem; margin-bottom: 0; }
.dash-table thead { font-size: 0.75rem; }
.dash-table tbody tr:last-child td { border-bottom: none; }

/* Activity feed */
.activity-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f0f5;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}
.activity-time {
    font-size: 0.7rem;
    color: #adb5bd;
    white-space: nowrap;
}

/* ======================================================
   Invoice Form — Xintra style
   ====================================================== */
.invoice-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f0f0f5;
}

.invoice-items-table {
    font-size: 0.8125rem;
    margin-bottom: 0;
}
.invoice-items-table thead th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    border-bottom: 2px solid #e9ecef;
    padding: 0.6rem 0.5rem;
    white-space: nowrap;
}
.invoice-items-table tbody td {
    padding: 0.5rem;
    vertical-align: middle;
}
.invoice-items-table .form-control,
.invoice-items-table .form-select {
    font-size: 0.8125rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.375rem;
}
.invoice-items-table .row-total {
    font-weight: 600;
    color: #1a1a2e;
    min-width: 90px;
    text-align: right;
}

.invoice-summary {
    border-top: 2px solid #e9ecef;
    padding-top: 1rem;
}
.invoice-summary .summary-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.35rem 0;
    font-size: 0.875rem;
}
.invoice-summary .summary-label {
    color: #6c757d;
    font-weight: 500;
    min-width: 140px;
    text-align: right;
    margin-right: 1rem;
}
.invoice-summary .summary-value {
    min-width: 120px;
    text-align: right;
    font-weight: 600;
    color: #1a1a2e;
}
.invoice-summary .summary-total {
    font-size: 1.1rem;
    font-weight: 700;
    border-top: 2px solid #1a1a2e;
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}
.invoice-summary .summary-total .summary-value {
    font-size: 1.1rem;
    color: #3c55d1;
}

/* --- Invoice Detail — Xintra Style --- */
.inv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e9ecef;
}
.inv-header .inv-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}
.inv-header .inv-title .inv-number {
    color: #3c55d1;
}

.inv-party-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
    margin-bottom: 0.5rem;
}
.inv-party-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.35rem;
}
.inv-party-detail {
    font-size: 0.82rem;
    color: #6c757d;
    line-height: 1.6;
}
.inv-party-detail a {
    color: #3c55d1;
    text-decoration: none;
}

.inv-meta-row {
    display: flex;
    gap: 0;
    border-top: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
}
.inv-meta-item {
    flex: 1;
    padding: 0.85rem 1.25rem;
    border-right: 1px solid #e9ecef;
}
.inv-meta-item:last-child {
    border-right: none;
}
.inv-meta-item .meta-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    margin-bottom: 0.2rem;
}
.inv-meta-item .meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}
.inv-meta-item .meta-value.text-primary {
    color: #3c55d1 !important;
}

.inv-items-table {
    margin-bottom: 0;
    font-size: 0.85rem;
}
.inv-items-table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #e9ecef;
    background: #fafbfc;
}
.inv-items-table tbody td {
    padding: 0.7rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f1f3;
}
.inv-items-table tbody tr:hover {
    background: #f8f9ff;
}

.inv-summary-section {
    padding: 1rem 1.25rem;
    background: #fafbfc;
    border-top: 1px solid #e9ecef;
}
.inv-summary-row {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    padding: 0.3rem 0;
    font-size: 0.85rem;
}
.inv-summary-row .s-label {
    color: #6c757d;
    min-width: 140px;
    text-align: right;
}
.inv-summary-row .s-value {
    min-width: 120px;
    text-align: right;
    font-weight: 600;
    color: #333;
}
.inv-summary-row.total-row {
    border-top: 2px solid #e9ecef;
    padding-top: 0.6rem;
    margin-top: 0.3rem;
}
.inv-summary-row.total-row .s-label {
    font-weight: 700;
    color: #333;
}
.inv-summary-row.total-row .s-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #3c55d1;
}

.inv-notes {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e9ecef;
    font-size: 0.85rem;
}
.inv-notes .notes-label {
    font-weight: 700;
    color: #333;
    margin-bottom: 0.3rem;
}
.inv-notes p {
    color: #6c757d;
    margin-bottom: 0;
}

/* Invoice sidebar card */
.inv-sidebar-card .sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #333;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 0.75rem;
}
.inv-sidebar-card .sidebar-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.83rem;
}
.inv-sidebar-card .sidebar-item .si-label {
    color: #6c757d;
}
.inv-sidebar-card .sidebar-item .si-value {
    font-weight: 600;
    color: #333;
}
.inv-sidebar-card .sidebar-item .si-value.text-primary {
    color: #3c55d1 !important;
}

.inv-status-alert {
    border-radius: 0.5rem;
    padding: 0.65rem 0.85rem;
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

/* Match status icons in table */
.match-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    padding: 0.2rem 0.55rem;
    border-radius: 1rem;
}
.match-badge.matched {
    background: #d1fae5;
    color: #065f46;
}
.match-badge.mismatched {
    background: #fee2e2;
    color: #991b1b;
}
.match-badge.pending {
    background: #f3f4f6;
    color: #6b7280;
}
.match-badge.warning {
    background: #fef3cd;
    color: #856404;
}
.match-badge.info {
    background: #dbeafe;
    color: #1e40af;
}
.match-badge.cancelled {
    background: #e2e3e5;
    color: #41464b;
}
.match-badge.paid {
    background: #cff4fc;
    color: #055160;
}

/* Dark theme badge overrides */
[data-theme="dark"] .match-badge.matched {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}
[data-theme="dark"] .match-badge.mismatched {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}
[data-theme="dark"] .match-badge.pending {
    background: rgba(156, 163, 175, 0.15);
    color: #d1d5db;
}
[data-theme="dark"] .match-badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}
[data-theme="dark"] .match-badge.info {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}
[data-theme="dark"] .match-badge.cancelled {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}
[data-theme="dark"] .match-badge.paid {
    background: rgba(6, 182, 212, 0.15);
    color: #67e8f9;
}

/* DataTables row group header */
.dt-row-group-header {
    padding: 10px 14px;
    font-size: 14px;
    background: var(--table-header-bg);
    border-top: 2px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    color: var(--text-color);
}

/* Audit log action badges */
.match-badge.action-update {
    background: #dbeafe;
    color: #1e40af;
}
.match-badge.action-status {
    background: #fef3cd;
    color: #856404;
}
[data-theme="dark"] .match-badge.action-update {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}
[data-theme="dark"] .match-badge.action-status {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}

/* Filter labels */
.filter-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}

/* Link color utility — theme-aware */
.link-primary-themed {
    color: #3c55d1;
    text-decoration: none;
}
.link-primary-themed:hover {
    color: #2d42a8;
    text-decoration: underline;
}
[data-theme="dark"] .link-primary-themed {
    color: #7c8aff;
}
[data-theme="dark"] .link-primary-themed:hover {
    color: #a5b0ff;
}

/* Group header — theme-aware */
.group-header-row {
    background: var(--table-header-bg);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

/* Overdue row — theme-aware */
.row-overdue {
    background: rgba(220, 53, 69, 0.06);
}
[data-theme="dark"] .row-overdue {
    background: rgba(239, 68, 68, 0.1);
}

/* Subtle background — theme-aware */
.bg-subtle-section {
    background: var(--table-header-bg);
    border-color: var(--border-color);
}

/* Invoice highlight section */
.bg-highlight-section {
    background: rgba(13, 110, 253, 0.04);
    border-top: 2px solid #0d6efd;
}
[data-theme="dark"] .bg-highlight-section {
    background: rgba(59, 130, 246, 0.08);
    border-top-color: #3b82f6;
}

/* --- Print Styles --- */
@media print {
    .sidebar,
    .navbar,
    .messages-container,
    .btn {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        margin-top: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}
