/**
 * Indian Plaza CRM - Professional Dashboard Theme
 * Black topbar, white sidebar, clean modern design
 */

/* ===== RESET ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #000000;
    --white: #ffffff;
    --sidebar-width: 220px;
    --topbar-height: 56px;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
    --radius: 10px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: all 0.15s ease;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ===== BODY ===== */
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-900);
    background: #f8f9fa;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--gray-900);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 0.5rem; }

a {
    color: var(--gray-900);
    text-decoration: none;
    transition: var(--transition);
}

a:hover { color: var(--gray-600); }

/* ===============================================
   TOPBAR - Full width black bar
   =============================================== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--white);
    padding: 4px 6px;
    margin-right: 4px;
    border-radius: 6px;
    transition: background 0.15s;
    flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.12); }
.hamburger-btn i { width: 22px; height: 22px; }

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.topbar-brand i {
    width: 20px;
    height: 20px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--white);
}

.topbar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
}

.topbar-user-role {
    font-size: 0.6875rem;
    color: var(--gray-400);
}

.topbar-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--white);
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.topbar-logout:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.4);
    color: var(--white);
}

.topbar-logout i {
    width: 15px;
    height: 15px;
}

/* ===============================================
   SIDEBAR - White, below topbar
   =============================================== */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
}

.sidebar-label {
    padding: 16px 20px 6px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-400);
}

.sidebar-menu {
    list-style: none;
    padding: 0 8px;
}

.sidebar-menu li {
    margin-bottom: 1px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--gray-600);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin-left: 0;
}

.sidebar-menu a i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-menu a:hover {
    background: var(--gray-50);
    color: var(--gray-900);
    opacity: 1;
}

.sidebar-menu a.active {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
    border-left-color: var(--primary);
    border-radius: var(--radius-sm);
}

.sidebar-menu a.active i {
    stroke: var(--white);
}

.notif-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    background: #ef4444;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}
.sidebar-menu a.active .notif-dot {
    background: #fff;
    opacity: 0.85;
}

/* ===============================================
   MAIN CONTENT
   =============================================== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 28px 32px;
    min-height: calc(100vh - var(--topbar-height));
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title i {
    width: 24px;
    height: 24px;
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 0.8125rem;
    margin: 0;
}

.page-subtitle a {
    color: var(--gray-500);
    font-weight: 500;
}

.page-subtitle a:hover {
    color: var(--primary);
}

/* ===============================================
   CARDS
   =============================================== */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    font-size: 0.875rem;
    background: var(--white);
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ===== STAT CARDS ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.stat-card .stat-icon i {
    width: 20px;
    height: 20px;
}

.stat-card .stat-number {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 2px;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* ===============================================
   FORMS
   =============================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--gray-700);
}

.form-label.required::after {
    content: " *";
    color: var(--gray-400);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--gray-900);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-xs);
    transition: var(--transition);
    outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--gray-400);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--gray-400);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

.form-hint {
    color: var(--gray-400);
    font-size: 0.75rem;
    margin-top: 4px;
}

/* File Input */
input[type="file"].form-input {
    padding: 7px 12px;
    cursor: pointer;
}

input[type="file"].form-input::file-selector-button {
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    margin-right: 10px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    background: var(--gray-100);
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
}

input[type="file"].form-input::file-selector-button:hover {
    background: var(--gray-200);
}

/* ===============================================
   BUTTONS
   =============================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn i {
    width: 15px;
    height: 15px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--gray-800);
    border-color: var(--gray-800);
    color: var(--white);
    opacity: 1;
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-900);
    opacity: 1;
}

.btn-danger {
    background: var(--white);
    color: var(--gray-600);
    border-color: var(--gray-300);
}

.btn-danger:hover {
    background: var(--gray-900);
    color: var(--white);
    border-color: var(--gray-900);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn-lg {
    padding: 11px 24px;
    font-size: 0.9375rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===============================================
   TABLES
   =============================================== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.table th,
.table td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

.table th {
    font-weight: 700;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
    padding: 12px 16px;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-row-clickable {
    cursor: pointer;
}

.table-row-clickable:hover {
    background: var(--gray-100) !important;
}

/* ===== NUMBER BADGE ===== */
.num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--gray-900);
    color: var(--white);
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* ===== FILE TYPE BADGE ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 4px;
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

/* ===============================================
   ALERTS
   =============================================== */
.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-xs);
    font-size: 0.8125rem;
    font-weight: 500;
    animation: alertSlideIn 0.3s ease-out;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: var(--gray-900);
    color: var(--white);
}

.alert-error {
    background: var(--white);
    color: var(--gray-900);
    border: 1.5px solid var(--gray-900);
}

.alert-info {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

/* ===============================================
   PAGINATION
   =============================================== */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 4px 0;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xs);
    transition: var(--transition);
    color: var(--gray-600);
}

.pagination a:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--primary);
    opacity: 1;
}

.pagination .active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ===============================================
   AUTH LAYOUT
   =============================================== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: 14px;
    padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: none;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.auth-logo i {
    width: 24px;
    height: 24px;
    stroke: var(--white);
}

.auth-header h1 {
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 2px;
}

.auth-header p {
    color: var(--gray-500);
    font-size: 0.8125rem;
    margin: 0;
}

/* ===============================================
   DANGER ZONE
   =============================================== */
.danger-zone {
    border: 1px solid var(--gray-300);
}

.danger-zone .card-header {
    background: var(--gray-900);
    color: var(--white);
    border-bottom-color: var(--gray-900);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ===============================================
   DETAIL TABLE
   =============================================== */
.detail-table {
    width: 100%;
}

.detail-table tr {
    border-bottom: 1px solid var(--gray-200);
}

.detail-table tr:last-child {
    border-bottom: none;
}

.detail-table td {
    padding: 10px 0;
    vertical-align: top;
    font-size: 0.8125rem;
}

.detail-table td:first-child {
    font-weight: 600;
    color: var(--gray-500);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    width: 120px;
    padding-right: 16px;
}

.detail-table td:last-child {
    color: var(--gray-900);
}

/* ===============================================
   GRID SYSTEM
   =============================================== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.row > * {
    padding: 0 10px;
    width: 100%;
}

.col { flex: 1 0 0%; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-12 { flex: 0 0 auto; width: 100%; }

@media (min-width: 768px) {
    .col-md-4 { width: 33.333%; }
    .col-md-6 { width: 50%; }
    .col-md-8 { width: 66.667%; }
}

@media (min-width: 992px) {
    .col-lg-3 { width: 25%; }
    .col-lg-4 { width: 33.333%; }
    .col-lg-6 { width: 50%; }
    .col-lg-8 { width: 66.667%; }
}

/* ===============================================
   RESULT INFO BAR
   =============================================== */
.result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 12px;
    font-size: 0.8125rem;
}

.result-bar .result-count {
    color: var(--gray-900);
    font-weight: 600;
}

.result-bar .result-count span {
    color: var(--gray-500);
    font-weight: 400;
}

/* ===============================================
   UTILITIES
   =============================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-small { font-size: 0.75rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.d-inline { display: inline; }
.d-none { display: none; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.w-100 { width: 100%; }

/* ===============================================
   RESPONSIVE
   =============================================== */
@media (max-width: 768px) {
    .hamburger-btn { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(.4,0,.2,1);
        z-index: 200;
        width: 280px;
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 199;
    }
    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .table th, .table td {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .btn {
        padding: 7px 12px;
        font-size: 0.75rem;
    }
}

/* ===== MODULE CHECKBOXES ===== */
.module-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.module-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-600);
    transition: var(--transition);
    user-select: none;
}

.module-checkbox-item:hover {
    border-color: var(--gray-400);
    background: var(--gray-50);
}

.module-checkbox-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
}

.module-checkbox-item:has(input:checked) {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ===== ANIMATIONS ===== */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===============================================
   CUSTOMERS MODULE - RESPONSIVE
   =============================================== */
@media (max-width: 768px) {
    /* Header: stack buttons vertically */
    .page-header .d-flex.justify-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .page-header .d-flex.justify-between > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .page-header .d-flex.justify-between > div:last-child .btn {
        flex: 1;
        justify-content: center;
        min-width: 140px;
    }

    /* Table: hide address on mobile, enable horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table th:nth-child(5),
    .table td:nth-child(5) {
        display: none;
    }

    /* Search form: full width inputs */
    .d-flex.gap-2.align-end.flex-wrap .form-group {
        flex: 1 1 100% !important;
        min-width: 0 !important;
    }
    .d-flex.gap-2.align-end.flex-wrap .btn {
        width: 100%;
        justify-content: center;
    }

    /* Result bar */
    .result-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Show detail page: make edit form full width */
    #editFormCard {
        width: 100%;
    }
}

/* ── Documents module — responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    /* Upload form: single column on mobile */
    .doc-upload-grid {
        grid-template-columns: 1fr !important;
    }

    /* Documents table: hide Description (col 3), Uploaded By (col 6) */
    .doc-table th:nth-child(3),
    .doc-table td:nth-child(3),
    .doc-table th:nth-child(6),
    .doc-table td:nth-child(6) {
        display: none;
    }

    /* Download button: hide text, keep icon */
    .doc-table .btn-primary span,
    .doc-table td:last-child a.btn {
        font-size: 0.8125rem;
    }
}

/* ── Sales module — responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Admin date picker: wrap label/input/badge on small screens */
    .admin-date-row {
        flex-wrap: wrap !important;
    }
    .admin-date-row #adminDatePicker {
        flex: 1 1 140px;
    }

    /* Analytics range selector: make date inputs full-width so they don't overflow */
    #rangeSelector {
        gap: 6px !important;
    }
    #rangeSelector .form-input {
        width: 100% !important;
        flex: 1 1 120px;
    }

    /* Monthly entries table: hide Notes (col 3) and Saved date (col 4) */
    .monthly-table th:nth-child(3),
    .monthly-table td:nth-child(3),
    .monthly-table th:nth-child(4),
    .monthly-table td:nth-child(4) {
        display: none;
    }

    /* History card bottom row: let it wrap */
    .sales-grid-compact {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

/* ── Reviews module — responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Admin clients table: hide stat columns, keep Client/Credits/Reviews/Actions */
    .rev-clients-table th:nth-child(4),
    .rev-clients-table td:nth-child(4),
    .rev-clients-table th:nth-child(5),
    .rev-clients-table td:nth-child(5),
    .rev-clients-table th:nth-child(6),
    .rev-clients-table td:nth-child(6),
    .rev-clients-table th:nth-child(7),
    .rev-clients-table td:nth-child(7) {
        display: none;
    }
}

/* ── Payslip module — responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* index: KPI cards stack to 1 column */
    .payslip-kpi-grid {
        grid-template-columns: 1fr !important;
    }

    /* index: Employees + Recent Payslips stack */
    .payslip-main-grid {
        grid-template-columns: 1fr !important;
    }

    /* generate: form stacks above A4 preview */
    .payslip-gen-grid {
        grid-template-columns: 1fr !important;
    }
    .payslip-form-card {
        position: static !important;
    }

    /* history table: hide #, Hours, Gross, Deductions, Date */
    .payslip-history-table th:nth-child(1),
    .payslip-history-table td:nth-child(1),
    .payslip-history-table th:nth-child(4),
    .payslip-history-table td:nth-child(4),
    .payslip-history-table th:nth-child(5),
    .payslip-history-table td:nth-child(5),
    .payslip-history-table th:nth-child(6),
    .payslip-history-table td:nth-child(6),
    .payslip-history-table th:nth-child(8),
    .payslip-history-table td:nth-child(8) {
        display: none;
    }

    /* settings: company info grid → 1 col */
    .payslip-company-grid {
        grid-template-columns: 1fr !important;
    }

    /* settings: hourly rate 4-col → 2 col */
    .payslip-rate-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ── Admin Users — responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Users table: hide Email (col 3) and Last Login (col 6) */
    .users-table th:nth-child(3),
    .users-table td:nth-child(3),
    .users-table th:nth-child(6),
    .users-table td:nth-child(6) {
        display: none;
    }
}

/* ── Admin Logs & Modules — responsive ───────────────────────────────────── */
@media (max-width: 768px) {
    /* Logs table: hide Module (col 4) and IP (col 6) */
    .logs-table th:nth-child(4),
    .logs-table td:nth-child(4),
    .logs-table th:nth-child(6),
    .logs-table td:nth-child(6) {
        display: none;
    }

    /* Modules table: hide Name slug (col 2) and Version (col 3) */
    .modules-table th:nth-child(2),
    .modules-table td:nth-child(2),
    .modules-table th:nth-child(3),
    .modules-table td:nth-child(3) {
        display: none;
    }
}

/* ── Users table: mobile card layout (overrides column-hide rules above) ─── */
@media (max-width: 768px) {
    .users-table,
    .users-table tbody,
    .users-table tr {
        display: block;
        width: 100%;
    }
    .users-table thead { display: none; }

    .users-table tr {
        padding: 12px 16px;
        border-bottom: 1px solid #f3f4f6;
        background: #fff;
    }

    /* Full Name */
    .users-table td:nth-child(1) {
        display: inline;
        padding: 0;
        border: none;
        font-size: 0.9rem;
    }
    /* Username — inline after name */
    .users-table td:nth-child(2) {
        display: inline;
        padding: 0 0 0 6px;
        border: none;
        color: #6b7280;
        font-size: 0.8rem;
    }
    /* Email — hidden */
    .users-table td:nth-child(3) { display: none; }
    /* Role badge — inline */
    .users-table td:nth-child(4) {
        display: inline-block;
        padding: 0 0 0 8px;
        border: none;
        vertical-align: middle;
    }
    /* Status dot — inline */
    .users-table td:nth-child(5) {
        display: inline-block;
        padding: 0 0 0 8px;
        border: none;
        vertical-align: middle;
    }
    /* Last Login — hidden */
    .users-table td:nth-child(6) { display: none; }
    /* Actions — full-width block below */
    .users-table td:nth-child(7) {
        display: block;
        padding: 10px 0 2px;
        border: none;
        text-align: left;
    }
    .users-table td:nth-child(7) .btn-group {
        justify-content: flex-start !important;
    }
}

/* ── Users table: revert card layout, use sticky actions instead ─────────── */
@media (max-width: 768px) {
    /* Restore normal table display */
    .users-table,
    .users-table tbody,
    .users-table tr,
    .users-table thead {
        display: revert;
    }

    /* Hide Email (col 3) and Last Login (col 6) */
    .users-table th:nth-child(3),
    .users-table td:nth-child(3),
    .users-table th:nth-child(6),
    .users-table td:nth-child(6) {
        display: none;
    }

    /* Restore all other tds */
    .users-table td:nth-child(1),
    .users-table td:nth-child(2),
    .users-table td:nth-child(4),
    .users-table td:nth-child(5),
    .users-table td:nth-child(7) {
        display: table-cell;
        padding: 8px 10px;
        border: revert;
    }

    /* Sticky Actions column — always visible on right */
    .users-table th:nth-child(7),
    .users-table td:nth-child(7) {
        position: sticky;
        right: 0;
        background: #fff;
        box-shadow: -3px 0 6px rgba(0,0,0,0.06);
        z-index: 1;
    }
    .users-table th:nth-child(7) {
        background: #f9fafb;
    }
}

/* -- Modules table: ensure actions col always visible ------------------- */
@media (max-width: 768px) {
    .modules-table th:nth-child(4),
    .modules-table td:nth-child(4),
    .modules-table th:nth-child(5),
    .modules-table td:nth-child(5) {
        display: table-cell !important;
        position: static !important;
        box-shadow: none !important;
    }
    .modules-table th:nth-child(5),
    .modules-table td:nth-child(5) {
        text-align: center;
    }
}
