.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* gap-3 */
    padding: 0.5rem 0.75rem;
    /* py-2 px-3 */
    border-radius: 0.5rem;
    /* rounded-lg */
    font-size: 0.875rem;
    /* text-sm */
    font-weight: 500;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
    background-color: #f8f5f5;
    /* background-light */
}

.dark .sidebar-link:hover {
    background-color: #3a2020;
}

.sidebar-link .material-symbols-outlined {
    font-size: 20px;
    opacity: 0.85;
}

.sidebar-link.is-active {
    background-color: rgba(218, 11, 11, 0.08);
    position: relative;
}

.sidebar-link.is-active::before {
    content: "";
    position: absolute;
    left: -4px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    background-color: #da0b0b;
    border-radius: 4px;
}

/* Hide scrollbar utility */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.scrollbar-hide {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* Mobile-First Base Styles */
:root {
    --primary: #da0b0b;
    --primary-hover: #b00909;
    --primary-light: rgba(218, 11, 11, 0.1);
    --bg-light: #faf7f7;
    --border: #e4d2d2;
    --text-main: #1c0d0d;
    --text-muted: #7d5b5b;
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.min-h-screen {
    min-height: 100vh;
    min-height: 100dvh;
}

.h-screen {
    height: 100vh;
    height: 100dvh;
}

/* =====================================================
   PAGE CONTAINER — ENTERPRISE LTR ALIGNMENT
===================================================== */

.page-container {
    width: 100%;
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
    /* Add bottom padding to ensure content isn't cut by mobile toolbars */
    padding-bottom: 60px;
}

@media (max-width: 640px) {
    .page-container {
        padding: 16px;
        padding-bottom: 60px;
    }
}

/* =====================================================
   INPUT SYSTEM — INDUSTRIAL / ERP GRADE
===================================================== */

/* Force global uniformity on all common input types */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
input[type="tel"],
select,
textarea,
.input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background-color: #faf7f7;
    border: 1px solid #e4d2d2;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #1c0d0d;
    transition: all 0.15s ease;
    outline: none !important;
}

textarea {
    height: auto;
    padding: 12px 14px;
    min-height: 100px;
}

input::placeholder,
textarea::placeholder,
.input::placeholder {
    color: #9c6a6a;
    font-weight: 400;
}

input:hover,
select:hover,
textarea:hover,
.input:hover {
    border-color: #d6b0b0;
}

input:focus,
select:focus,
textarea:focus,
.input:focus {
    background-color: #ffffff;
    border-color: #da0b0b !important;
    box-shadow: 0 0 0 3px rgba(218, 11, 11, 0.12) !important;
    border-width: 1px !important;
}

/* Select Styling with Custom Arrow */
select,
select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='20' viewBox='0 -960 960 960' width='20' fill='%236b4a4a'%3E%3Cpath d='M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px !important;
    cursor: pointer;
}

/* Standardized Selection Controls (Select2 / TomSelect) */
.ts-control,
.select2-container .select2-selection--single {
    height: 44px !important;
    background-color: #faf7f7 !important;
    border: 1px solid #e4d2d2 !important;
    border-radius: 10px !important;
    padding: 0 14px !important;
    display: flex !important;
    align-items: center !important;
    transition: all 0.15s ease !important;
}

.ts-control:focus-within,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #da0b0b !important;
    box-shadow: 0 0 0 3px rgba(218, 11, 11, 0.12) !important;
    background-color: #ffffff !important;
}

.ts-dropdown {
    border-radius: 10px !important;
    border: 1px solid #e4d2d2 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    margin-top: 4px !important;
    overflow: hidden;
}

/* Disabled / Readonly */
input[disabled],
input[readonly],
select[disabled],
.input[disabled],
.input.readonly {
    background-color: #f3eded !important;
    color: #7d5b5b !important;
    cursor: not-allowed !important;
    border-color: #e4d2d2 !important;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.section-subtitle {
    font-size: 13px;
    color: #7d5b5b;
}

/* =====================================================
   BUTTON SYSTEM — ENTERPRISE GRADE
===================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    height: 42px;
    padding: 0 18px;

    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;

    cursor: pointer;
    white-space: nowrap;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        box-shadow 0.15s ease;
}

/* ---------- PRIMARY (SAVE / CONFIRM) ---------- */
.btn-primary {
    background-color: #da0b0b;
    color: #ffffff;
    border: 1px solid #da0b0b;
}

.btn-primary:hover {
    background-color: #b00909;
    border-color: #b00909;
}

.btn-primary:focus {
    box-shadow: 0 0 0 3px rgba(218, 11, 11, 0.18);
}

/* ---------- SECONDARY (CANCEL / MANAGE) ---------- */
.btn-secondary {
    background-color: #ffffff;
    color: #1c0d0d;
    border: 1px solid #e4d2d2;
}

.btn-secondary:hover {
    background-color: #f8f5f5;
    border-color: #d6b0b0;
}

/* ---------- GHOST (TEXT ACTIONS) ---------- */
.btn-ghost {
    background: transparent;
    border: none;
    color: #6b4a4a;
    padding: 0;
    height: auto;
}

.btn-ghost:hover {
    color: #da0b0b;
}

/* ---------- DANGER (DELETE / LOGOUT) ---------- */
.btn-danger {
    background-color: #feecec;
    color: #b00909;
    border: 1px solid #f3b6b6;
}

.btn-danger:hover {
    background-color: #fcdada;
}

/* ---------- CTA (IMPORTANT PROMINENT ACTION) ---------- */
.btn-cta {
    background-color: #1c0d0d;
    color: #ffffff;
    border: none;
}

.btn-cta:hover {
    background-color: #000000;
}

/* Disabled */
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---------- OUTLINE / UTILITY (DOWNLOAD / IMPORT) ---------- */
.btn-outline {
    background-color: #faf7f7;
    color: #1c0d0d;
    border: 1px dashed #e4d2d2;
}

.btn-outline:hover {
    background-color: #f8f5f5;
    border-color: #d6b0b0;
}

/* =====================================================
   CARD SYSTEM — CLEAN & CONSISTENT
===================================================== */

.card {
    background-color: #ffffff;
    border: 1px solid #e8cece;
    border-radius: 14px;

    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.dark .card {
    background-color: #2a1515;
    border-color: #3a2020;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid #e8cece;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 20px 28px;
    /* more breathing room for tables */
    border-top: 1px solid #e8cece;
    background-color: #faf7f7;
}


/* Subtle hover (optional dashboards) */
.card-hover:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

/* =====================================================
   TABLE SYSTEM — ERP GRADE
===================================================== */

.table-wrapper {
    background-color: #ffffff;
    border: 1px solid #e8cece;
    border-radius: 14px;
    overflow-x: auto;
    /* Enable horizontal scroll on mobile */
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

/* Header */
.table thead {
    background-color: #faf7f7;
}

.table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;

    color: #6b4a4a;
    padding: 12px 16px;
    border-bottom: 1px solid #e8cece;
}

/* Body */
.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1dede;
    color: #1c0d0d;
    vertical-align: middle;
}

/* Row hover */
.table tbody tr:hover {
    background-color: #fdf7f7;
}

@media (max-width: 768px) {
    .table-responsive thead {
        /* Hide visually but keep accessible for DataTables/scripts */
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .table-responsive tbody tr {
        display: block;
        margin-bottom: 1rem;
        padding: 1.25rem;
        background-color: #ffffff;
        border: 1px solid #e8cece;
        border-radius: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .table-responsive tbody td {
        display: flex;
        flex-direction: row;
        /* Changed to row for better label alignment */
        flex-wrap: wrap;
        width: 100% !important;
        padding: 0.75rem 0 !important;
        border-bottom: 1px solid #f1dede !important;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }

    .table-responsive tbody td:last-child {
        border-bottom: none !important;
        flex-direction: row;
        justify-content: flex-end;
    }

    /* Add labels on mobile for table cells */
    .table-responsive tbody td::before {
        content: attr(data-label);
        font-size: 10px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: #9c6a6a;
        display: block;
        opacity: 0.8;
        flex-shrink: 0;
    }

    /* Checkboxes alignment on mobile */
    .table-responsive tbody td.text-center {
        text-align: left;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 0.75rem;
    }

    .table-responsive tbody td.text-center::before {
        margin-bottom: 0;
    }

    .btn {
        width: 100%;
    }
}

/* Numeric alignment */
.table .text-right {
    text-align: right;
}

.table .text-center {
    text-align: center;
}

/* Status pill inside table */
.table-status {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.table-status.pending {
    background: rgba(218, 11, 11, 0.08);
    color: #da0b0b;
}

.table-status.success {
    background: #e6f7ed;
    color: #137333;
}

/* Empty state */
.table-empty {
    text-align: center;
    padding: 40px;
    color: #7d5b5b;
}

/* =====================================================
   TABLE ADD ROW — INLINE ACTION (ERP STANDARD)
===================================================== */

.table-add-row {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    padding: 14px 16px;

    border-top: 1px dashed rgba(218, 11, 11, 0.35);

    font-size: 14px;
    font-weight: 600;

    color: #da0b0b;
    background-color: transparent;

    cursor: pointer;
    user-select: none;

    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

/* Hover = intent to add */
.table-add-row:hover {
    background-color: rgba(218, 11, 11, 0.06);
}

/* Icon size consistency */
.table-add-row .material-symbols-outlined {
    font-size: 18px;
}

/* Disabled state (optional future use) */
.table-add-row:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* =====================================================
   DATATABLE — PREMIUM THEME
===================================================== */
.dataTables_wrapper {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e8cece;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    margin-bottom: 0.5rem;
}

/* Container Rows */
.dt-controls-top,
.dt-controls-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background-color: #faf7f7;
    gap: 1rem;
}

.dt-controls-top {
    border-bottom: 1px solid #e8cece;
}

.dt-controls-bottom {
    border-top: 1px solid #e8cece;
}

/* Hide default buttons as we use custom UI */
.dt-buttons {
    display: none !important;
}

/* Mobile adjustments for container rows */
@media (max-width: 640px) {

    .dt-controls-top,
    .dt-controls-bottom {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
        text-align: center;
        gap: 0.75rem;
    }
}

/* Controls Styling */
.dataTables_length select {
    appearance: none;
    background-color: #fff;
    border: 1px solid #e4d2d2;
    border-radius: 10px;
    padding: 0 36px 0 14px !important;
    /* Standard padding */
    height: 44px;
    /* Standardize to 44px */
    font-size: 14px;
    /* Standardize font size */
    font-weight: 500;
    /* Standardize weight */
    color: #1c0d0d;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='20' viewBox='0 -960 960 960' width='20' fill='%236b4a4a'%3E%3Cpath d='M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: all 0.2s ease;
}

.dataTables_length select:focus {
    outline: none;
    border-color: #da0b0b;
    box-shadow: 0 0 0 3px rgba(218, 11, 11, 0.12);
}

.dataTables_filter input {
    border: 1px solid #e4d2d2;
    background-color: #fff;
    border-radius: 10px;
    padding: 0 16px;
    height: 44px;
    /* Standardize to 44px */
    min-width: 240px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dataTables_filter input:focus {
    outline: none;
    border-color: #da0b0b !important;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(218, 11, 11, 0.12) !important;
}

@media (max-width: 640px) {
    .dataTables_filter input {
        min-width: 0;
        width: 100%;
        margin-left: 0 !important;
    }
}

/* Info Text */
.dataTables_info {
    font-size: 13px;
    font-weight: 500;
    color: #7d5b5b;
}

/* Pagination buttons as premium elements */
.dataTables_paginate,
.dataTables_paginate span {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    /* Ensure centered alignment */
    gap: 0.25rem;
    flex-wrap: wrap;
    /* Allow wrapping of pagination buttons */
}

.dataTables_paginate .paginate_button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px !important;
    background: #fff !important;
    border: 1px solid #e4d2d2 !important;
    border-radius: 8px !important;
    font-size: 13px;
    font-weight: 600 !important;
    color: #1c0d0d !important;
    cursor: pointer;
    transition: all 0.2s ease !important;
    margin: 0 !important;
}

.dataTables_paginate .paginate_button:hover:not(.disabled):not(.current) {
    background-color: #f8f5f5 !important;
    border-color: #d6b0b0 !important;
    color: #da0b0b !important;
}

.dataTables_paginate .paginate_button.current {
    background: #da0b0b !important;
    border-color: #da0b0b !important;
    color: #fff !important;
}

.dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: not-allowed !important;
}

/* Table Enhancements */
.table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #faf7f7;
    white-space: nowrap;
}

/* Custom horizontal scroll for all tables if needed */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}