:root {
    /* Light mode colors */
    --bg: #f8fafc;
    --card: #ffffff;
    --muted: #64748b;
    --text: #1e293b;
    --primary: #3b82f6;
    --primary-600: #2563eb;
    --primary-light: #dbeafe;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warn: #f59e0b;
    --warn-light: #fef3c7;
    --ok: #10b981;
    --ok-light: #d1fae5;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body.dark-mode {
    /* Dark mode colors */
    --bg: #0e1325;
    --card: #121a33;
    --muted: #a9b6d7b0;
    --text: #f2f6ff;
    --primary: #7aa2ff;
    --primary-600: #5e86ff;
    --primary-light: rgba(122, 162, 255, 0.15);
    --danger: #ff7e8a;
    --danger-light: rgba(255, 126, 138, 0.16);
    --warn: #d97706;
    --warn-light: rgba(146, 64, 14, 0.3);
    --ok: #58d9a3;
    --ok-light: rgba(88, 217, 163, 0.16);
    --border: #25365c;
    --border-light: #1b2742;
    --shadow: 0 18px 40px rgba(0,0,0,.35);
    --shadow-lg: 0 25px 50px rgba(0,0,0,.4);
    --shadow-xl: 0 30px 60px rgba(0,0,0,.45);
}

* { 
    box-sizing: border-box; 
}
html, body { 
    height: 100%; 
    width: 100%;
    overflow-x: hidden;
    max-width: 100vw;
}
body {
    margin: 0;
    font-family: Heebo, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: white;
    color: var(--text);
    color-scheme: light;
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

/* Dark mode */
body.dark-mode {
    background: #0e1325;
    color: var(--text);
    color-scheme: dark;
}

/* Ensure all backgrounds use dark mode properly */
body.dark-mode .app-header {
    background: rgba(18, 26, 51, 0.95) !important;
}

body.dark-mode .mobile-menu {
    background: var(--card);
}

body.dark-mode input[type="search"],
body.dark-mode input[type="text"],
body.dark-mode input[type="tel"],
body.dark-mode input[type="number"],
body.dark-mode input[type="date"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode textarea,
body.dark-mode select {
    background: var(--card);
    color: var(--text);
}

body.dark-mode input:focus,
body.dark-mode textarea:focus,
body.dark-mode select:focus {
    background: var(--card);
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}


.brand { 
    display: flex; 
    align-items: center; 
    gap: 14px; 
    flex-shrink: 0;
    min-width: 0;
    overflow: hidden;
}
.brand h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.brand .logo {
    width: 48px; height: 48px; border-radius: 14px;
    display: grid; place-items: center; font-weight: 900; font-size: 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-600));
    color: white;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.brand .logo:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}
.brand h1 { 
    margin: 0; 
    font-size: 26px; 
    letter-spacing: .3px; 
    font-weight: 700;
    color: var(--text);
    background: linear-gradient(135deg, var(--primary), var(--primary-600));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.header-actions { 
    display: flex; 
    gap: 10px; 
    align-items: center; 
    flex-wrap: wrap;
    flex-shrink: 1;
    min-width: 0;
}
.company-name { 
    color: var(--muted); 
    font-size: 13px; 
    font-weight: 500; 
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    min-width: 100px;
    outline: none;
}
.company-name:hover {
    background: var(--border-light);
    color: var(--text);
}
.company-name:focus {
    background: var(--card);
    border: 1px solid var(--primary);
    color: var(--text);
}

/* Buttons */
.btn {
    background: var(--card);
    color: var(--text);
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}
.btn:hover { 
    transform: translateY(-2px); 
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}
.btn:active { transform: translateY(0) scale(.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-600));
    border-color: transparent;
    box-shadow: var(--shadow-lg);
    color: white;
    font-weight: 600;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600), var(--primary));
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
}
.btn-secondary { 
    background: var(--primary-light); 
    color: var(--primary-600);
    border-color: var(--primary-light);
}
.btn-secondary:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    border-color: transparent;
    box-shadow: var(--shadow-lg);
    color: white;
    font-weight: 600;
}
.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, var(--danger));
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
}
.btn-ghost { 
    background: transparent; 
    border-color: var(--border);
    color: var(--muted);
}
.btn-ghost:hover {
    background: var(--border-light);
    color: var(--text);
    border-color: var(--border);
}

.icon-btn {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}
.icon-btn .bell { font-size: 20px; }
.icon-btn:hover { 
    transform: translateY(-2px); 
    box-shadow: var(--shadow-lg);
    background: var(--primary-light);
    border-color: var(--primary);
}
.badge-count {
    position: absolute; top: -6px; left: -6px;
    background: var(--danger); color: white; border-radius: 999px; padding: 3px 7px;
    font-size: 11px; font-weight: 700; border: 2px solid var(--card); box-shadow: var(--shadow);
}

/* Inputs */
.container { 
    max-width: 1100px; 
    margin: 24px auto; 
    padding: 0 16px; 
    width: 100%;
    box-sizing: border-box;
}
.toolbar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 16px; 
    margin-bottom: 16px; 
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
}
.filters { display: flex; gap: 10px; align-items: center; }

input[type="search"], input[type="text"], input[type="tel"], input[type="number"], input[type="date"], input[type="email"], input[type="password"], textarea, select {
    background: var(--card);
    border: 2px solid var(--border);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 12px;
    outline: none;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.6; }
input:focus, textarea:focus, select:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1), var(--shadow-lg);
    background: var(--card);
}
input:-webkit-autofill,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--card) inset !important;
    box-shadow: 0 0 0px 1000px var(--card) inset !important;
    transition: background-color 0s ease-in-out 0s;
}

/* Table */
.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    text-align: right;
    background: var(--bg);
    font-weight: 600;
    padding: 16px 14px;
    border-bottom: 2px solid var(--border);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    font-size: 14px;
    transition: background 0.2s ease;
}
.data-table thead th:hover {
    background: var(--primary-light);
    color: var(--primary-600);
}
.data-table thead th:nth-child(1) { min-width: 120px; }
.data-table thead th:nth-child(2) { min-width: 120px; }
.data-table thead th:nth-child(3) { min-width: 100px; }
.data-table thead th:nth-child(4) { min-width: 140px; }
.data-table thead th:nth-child(5) { min-width: 200px; }
.data-table tbody td { 
    padding: 16px 14px; 
    border-bottom: 1px solid var(--border-light); 
    word-wrap: break-word;
}
.data-table tbody td:nth-child(1) { min-width: 120px; }
.data-table tbody td:nth-child(2) { min-width: 120px; }
.data-table tbody td:nth-child(3) { min-width: 100px; }
.data-table tbody td:nth-child(4) { min-width: 140px; }
.data-table tbody td:nth-child(5) { min-width: 200px; }
.data-table tbody tr { transition: all 0.2s ease; }
.data-table tbody tr:nth-child(even) { background: var(--bg); }
.data-table tbody tr:hover { 
    background: var(--primary-light);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}
.row-actions { display: flex; gap: 8px; }

/* States */
.badge { 
    padding: 6px 12px; 
    border-radius: 999px; 
    font-size: 12px; 
    font-weight: 600; 
    display: inline-flex;
    align-items: center;
}
.badge.overdue { 
    background: var(--danger-light); 
    color: #dc2626; 
    border: 1px solid var(--danger);
}
.badge.soon { 
    background: var(--warn-light); 
    color: #d97706; 
    border: 1px solid var(--warn);
}
.badge.ok { 
    background: var(--ok-light); 
    color: #059669; 
    border: 1px solid var(--ok);
}

.empty-state { display: grid; place-items: center; padding: 36px; }
.empty-card {
    text-align: center; background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; padding: 24px; box-shadow: var(--shadow);
}
.empty-icon { font-size: 44px; margin-bottom: 8px; }

/* Reminders & Notifs */
.reminder-panel {
    margin-top: 20px; 
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid var(--warn); 
    border-radius: 16px; 
    padding: 20px 24px; 
    box-shadow: var(--shadow-lg);
    transition: background 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .reminder-panel {
    background: linear-gradient(135deg, rgba(146, 64, 14, 0.25) 0%, rgba(146, 64, 14, 0.35) 100%);
    border-color: rgba(217, 119, 6, 0.6);
}
.reminder-panel h3 { 
    margin: 0 0 16px 0; 
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
}
.reminder-panel ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.reminder-panel li {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    background: var(--card); 
    border: 1px solid var(--border); 
    padding: 16px 18px; 
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}
.reminder-panel li:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--warn);
}

.notif-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.notif-list li {
    display: grid; gap: 12px; 
    background: var(--card); 
    border: 1px solid var(--border);
    padding: 20px 24px; 
    border-radius: 16px; 
    line-height: 1.75; 
    font-size: 15px; 
    color: var(--text); 
    box-shadow: var(--shadow-lg);
    transition: all 0.2s ease;
}
.notif-list li:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}
.notif-list li strong { font-size: 18px; color: var(--text); }
.notif-item .notif-title { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.notif-item .notif-details { display: flex; gap: 20px; color: var(--muted); font-size: 14px; }
.notif-item .notif-phone { font-size: 18px; font-weight: 700; letter-spacing: .3px; color: var(--primary-600); }

.app-footer { text-align: center; color: var(--muted); padding: 16px; border-top: 1px solid var(--border); margin-top: 24px; }

/* Modals */
.modal { border: none; padding: 0; background: transparent; }
.modal::backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(4px); }
.modal-card {
    width: min(680px, 92vw); 
    background: var(--card); 
    border: 1px solid var(--border);
    border-radius: 20px; 
    box-shadow: var(--shadow-xl);
}
.modal-card header { 
    padding: 24px 24px 20px; 
    border-bottom: 2px solid var(--border-light);
    background: var(--bg);
}
.modal-card header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    background: linear-gradient(135deg, var(--primary), var(--primary-600));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.modal-card .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 24px; }
.modal-card .grid .full { grid-column: 1 / -1; }
.modal-card label { 
    display: grid; 
    gap: 8px; 
    font-size: 14px; 
    color: var(--text);
    font-weight: 500;
}
.modal-card label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.modal-actions { 
    display: flex; 
    justify-content: space-between; 
    gap: 12px; 
    padding: 20px 24px 24px; 
    border-top: 2px solid var(--border-light);
    background: var(--bg);
}

/* Hamburger Menu Button */
.menu-burger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
}

.menu-burger span {
    width: 100%;
    height: 3px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.menu-burger:hover {
    background: var(--primary-light);
    border-radius: 10px;
}
.menu-burger:hover span {
    background: var(--primary);
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: var(--card);
    border-left: 2px solid var(--border);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease, background-color 0.3s ease;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.mobile-menu.menu-open {
    transform: translateX(0);
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(2px);
}

.mobile-menu-overlay.overlay-open {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-content {
    padding: 20px;
    height: 100%;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.mobile-menu-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text);
}

.close-menu-btn {
    background: var(--border-light);
    border: none;
    color: var(--text);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.close-menu-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
    transform: rotate(90deg);
}

.mobile-menu-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-menu-item {
    width: 100%;
    justify-content: flex-start;
    text-align: right;
    padding: 14px 16px;
}

.mobile-menu-item.icon-btn {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-item.icon-btn .bell {
    font-size: 18px;
}

.mobile-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

.mobile-menu-email {
    color: var(--muted);
    font-size: 13px;
    padding: 12px 16px;
    text-align: right;
    font-weight: 500;
}

/* Table Responsive - Stack buttons vertically on mobile */
.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Reminder panel - desktop stays horizontal, mobile stacks */

/* Notifications list responsive */
.notif-list li .row-actions {
    flex-direction: column;
    width: 100%;
}

.notif-list li .row-actions .btn {
    width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    /* Hide header buttons, show hamburger */
    .header-actions {
        display: none;
    }
    
    .menu-burger {
        display: flex;
    }
    
    /* Brand adjustments */
    .brand h1 {
        font-size: 18px;
    }
    
    .brand .logo {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    /* Table responsive - make it fit without horizontal scroll */
    .table-wrap {
        overflow-x: visible;
        margin: 0;
        padding: 0;
    }
    
    .data-table {
        width: 100%;
        display: block;
        border-collapse: separate;
    }
    
    .data-table thead {
        display: none;
    }
    
    .data-table tbody {
        display: block;
        width: 100%;
    }
    
    .data-table tbody tr {
        display: block;
        margin-bottom: 12px;
        background: var(--card);
        border: 2px solid var(--border);
        border-radius: 12px;
        padding: 16px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        box-shadow: var(--shadow);
        transition: all 0.2s ease;
        overflow: hidden;
    }
    
    .data-table tbody tr:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
        border-color: var(--primary);
    }
    
    .data-table tbody td {
        display: block;
        padding: 8px 0;
        border: none;
        text-align: right;
        width: 100%;
        position: relative;
    }
    
    .data-table tbody td:not(:last-child):before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary-600);
        display: inline-block;
        margin-left: 8px;
        min-width: 80px;
        font-size: 13px;
    }
    
    .data-table tbody td:last-child {
        padding-top: 12px;
        margin-top: 12px;
        border-top: 1px solid var(--border);
    }
    
    .data-table tbody td:last-child .row-actions {
        width: 100%;
    }
    
    /* Stack row actions vertically on mobile */
    .row-actions {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }
    
    .row-actions .btn {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Toolbar responsive */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .filters {
        flex-direction: column;
        width: 100%;
    }
    
    .filters input,
    .filters select {
        width: 100%;
    }
    
    .stats {
        width: 100%;
        text-align: center;
    }
    
    /* Modal responsive */
    .modal-card .grid {
        grid-template-columns: 1fr;
    }
    
    /* Container padding */
    .container {
        padding: 0 12px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Header padding */
    .app-header {
        padding: 12px 16px;
        box-sizing: border-box;
    }
    
    /* Ensure no horizontal overflow */
    body {
        overflow-x: hidden;
        width: 100%;
    }
    
    html {
        overflow-x: hidden;
    }
    
    /* Reminder panel - stack on mobile */
    .reminder-panel {
        padding: 12px;
    }
    
    .reminder-panel li {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .reminder-panel .row-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .reminder-panel .row-actions .btn {
        width: 100%;
    }
    
    /* Notifications */
    .notif-item .notif-details {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .brand h1 {
        font-size: 16px;
    }
    
    /* Modal adjustments for very small screens */
    .modal-card {
        padding: 16px 20px;
        min-width: 280px;
        max-width: 95vw;
    }
    
    /* Reduce button padding on small screens */
    .btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    /* Reduce icon button size */
    .icon-btn {
        padding: 10px;
    }
    
    /* Smaller header logo */
    .brand .logo {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    /* Adjust container padding */
    .container {
        padding: 0 8px;
    }
    
    /* Adjust header padding */
    .app-header {
        padding: 10px 12px;
    }
    
    /* Smaller stats pills */
    .pill {
        padding: 4px 10px;
        font-size: 11px;
    }
}

/* Extra small screens (Galaxy S9 and similar) */
@media (max-width: 360px) {
    .brand h1 {
        font-size: 14px;
    }
    
    .modal-card {
        padding: 12px 16px;
        min-width: 260px;
        max-width: 96vw;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .icon-btn {
        padding: 8px;
    }
    
    .brand .logo {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .container {
        padding: 0 6px;
    }
    
    .app-header {
        padding: 8px 10px;
    }
    
    /* Ensure table cards fit */
    .data-table tbody tr {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    /* Smaller input padding */
    input[type="search"], 
    input[type="text"], 
    input[type="tel"], 
    input[type="number"], 
    input[type="date"], 
    input[type="email"], 
    input[type="password"], 
    textarea, 
    select {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    /* Company name smaller */
    .company-name {
        font-size: 12px;
        padding: 3px 6px;
        min-width: 80px;
    }
}

.mono { font-feature-settings: "tnum" on, "lnum" on; font-variant-numeric: tabular-nums; }
.pill { 
    padding: 6px 12px; 
    border-radius: 999px; 
    background: var(--primary-light); 
    border: 1px solid var(--primary); 
    color: var(--primary-600); 
    font-size: 12px; 
    font-weight: 600;
    box-shadow: var(--shadow);
}
.link { 
    color: var(--primary-600); 
    text-decoration: none; 
    font-weight: 500;
    transition: color 0.2s ease;
}
.link:hover { 
    color: var(--primary);
    text-decoration: underline; 
}

/* Small helper for "no results" (when there ARE debts but filter=0) */
#noResults {
    display: none;
    margin-top: 12px;
    color: var(--muted);
    background: var(--card);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    font-weight: 500;
    box-shadow: var(--shadow);
}
/* Confirm dialog */
.modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.modal {
    border: none;
    padding: 0;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.modal-card {
    padding: 20px 24px;
    min-width: 280px;
    max-width: 92vw;
    background: var(--card);
    color: var(--text);
    width: 100%;
    box-sizing: border-box;
}

.modal-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 700;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-start; /* RTL – buttons flow right-to-left visually */
    margin-top: 16px;
}

.btn.btn-danger {
    background: #e11d48;
    color: #fff;
    border: none;
}

.btn.btn-danger:hover {
    filter: brightness(0.95);
}

/* Empty state */
.empty-state { 
    display: grid; 
    place-items: center; 
    padding: 48px 24px; 
}
.empty-card {
    text-align: center; 
    background: var(--card); 
    border: 2px solid var(--border);
    border-radius: 20px; 
    padding: 40px 32px; 
    box-shadow: var(--shadow-xl);
    max-width: 500px;
}
.empty-icon { 
    font-size: 64px; 
    margin-bottom: 16px; 
    opacity: 0.6;
}
.empty-card h2 {
    color: var(--text);
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 12px 0;
}
.empty-card p {
    color: var(--muted);
    font-size: 15px;
    margin: 0 0 24px 0;
}

#loginModal {
    padding: 0;
    border: none;
    background: transparent;
}

#loginModal::backdrop {
    backdrop-filter: blur(12px);
    background: rgba(15, 23, 42, 0.55);
}

.auth-card {
    position: relative;
    min-width: 0;
    width: min(520px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 32px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 28px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 28px 64px -32px rgba(15, 23, 42, 0.6);
    overflow: hidden;
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(14, 116, 144, 0.18));
    pointer-events: none;
}

.auth-card > * {
    position: relative;
    z-index: 1;
}

.auth-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
    padding-bottom: 18px;
}

.auth-header h3 {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    color: var(--primary-600);
}

.auth-header h3::before {
    content: "🔐";
    font-size: 24px;
}

.auth-subtitle {
    margin: 0;
    font-size: 15px;
    color: rgba(71, 85, 105, 0.85);
}

.auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    background: rgba(226, 232, 240, 0.6);
    border-radius: 16px;
    padding: 6px;
}

.auth-tab {
    position: relative;
    border: none;
    background: transparent;
    color: rgba(30, 41, 59, 0.8);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab[data-active="true"] {
    background: #fff;
    box-shadow: 0px 8px 20px -12px rgba(15, 23, 42, 0.55);
    color: var(--primary-600);
}

.auth-tab:hover {
    color: var(--primary-600);
}

.auth-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.auth-step {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-step label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: rgba(30, 41, 59, 0.85);
    font-size: 14px;
    font-weight: 600;
}

body.dark-mode #loginModal input[type="tel"],
body.dark-mode #loginModal input[type="text"],
body.dark-mode #loginModal input[type="email"],
body.dark-mode #loginModal input[type="password"] {
    height: 48px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.48);
    background: rgba(248, 250, 252, 0.7);
    padding: 12px 16px;
    font-size: 15px;
    color: #0f172a;
    transition: all 0.2s ease;
}

body.dark-mode #loginModal input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    background: #fff;
    outline: none;
}

.auth-hint {
    margin: -6px 0 4px;
    font-size: 13px;
    color: rgba(71, 85, 105, 0.85);
}

.auth-error {
    display: none;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #b91c1c;
    font-size: 13px;
    font-weight: 600;
    min-height: 48px;
    max-height: 96px;
    overflow-y: auto;
    line-height: 1.35;
    word-break: break-word;
    align-items: center;
}

body.dark-mode .auth-card {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(51, 65, 85, 0.6);
}

body.dark-mode .auth-card::before {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(13, 148, 136, 0.15));
}

body.dark-mode .auth-header h3 {
    color: #38bdf8;
}

body.dark-mode .auth-subtitle,
body.dark-mode .auth-step label,
body.dark-mode .auth-hint {
    color: rgba(226, 232, 240, 0.8);
}

body.dark-mode .auth-tabs {
    background: rgba(30, 41, 59, 0.7);
}

body.dark-mode .auth-tab[data-active="true"] {
    background: rgba(15, 23, 42, 0.95);
    color: #38bdf8;
}

body.dark-mode .auth-tab {
    color: rgba(203, 213, 225, 0.85);
}

body.dark-mode .auth-error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

.auth-error.success {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.35);
    color: #047857;
}

.auth-links {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
}

.auth-links--right {
    justify-content: flex-end;
}

.auth-links--stack {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}

.auth-links--stack.auth-links--right {
    align-items: flex-end;
}

.auth-links--stack.auth-links--right .auth-info-msg {
    width: 100%;
}

.auth-info-msg {
    font-size: 13px;
    color: rgba(30, 41, 59, 0.78);
    background: rgba(148, 163, 184, 0.16);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 12px;
    padding: 10px 12px;
    line-height: 1.45;
    text-align: right;
}

.auth-link {
    font-size: 13px;
    color: var(--primary-600);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    text-align: right;
}

body.dark-mode .auth-info-msg {
    color: rgba(226, 232, 240, 0.9);
    background: rgba(30, 41, 59, 0.45);
    border-color: rgba(100, 116, 139, 0.4);
}

.auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.auth-actions .btn {
    flex: 1 1 100%;
    min-height: 48px;
    font-size: 15px;
}

.auth-actions--inline .btn {
    flex: 1 1 calc(50% - 12px);
    min-width: 140px;
}

.auth-actions--inline .btn:only-child {
    flex: 1 1 100%;
    min-width: 0;
}

@media (max-width: 540px) {
    .auth-card {
        width: min(460px, 94vw);
        padding: 28px 24px;
        gap: 20px;
        border-radius: 24px;
    }

    .auth-header h3 {
        font-size: 24px;
    }

    .auth-tabs {
        gap: 6px;
        padding: 4px;
    }

    .auth-tab {
        padding: 10px 12px;
        font-size: 13px;
    }

    #loginModal input[type="tel"],
    #loginModal input[type="text"],
    #loginModal input[type="email"],
    #loginModal input[type="password"] {
        height: 46px;
        font-size: 14px;
    }

    .auth-actions .btn {
        min-height: 46px;
    }
}

@media (max-width: 380px) {
    .auth-card {
        padding: 24px 20px;
        width: min(340px, 96vw);
    }

    .auth-header h3 {
        font-size: 22px;
    }

    .auth-actions--inline .btn {
        flex: 1 1 100%;
    }
}

.super-admin {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 16px 48px;
}

.super-admin__container {
    display: flex;
    flex-direction: column;
    gap: 32px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 28px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: 0 28px 64px -36px rgba(15, 23, 42, 0.55);
    padding: 32px;
}

.dark-mode .super-admin__container {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(71, 85, 105, 0.45);
    box-shadow: 0 28px 64px -32px rgba(15, 23, 42, 0.9);
}

.super-admin__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.super-admin__headline h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-600);
}

.super-admin__headline p {
    margin: 6px 0 0;
    color: rgba(30, 41, 59, 0.78);
    font-size: 15px;
}

.dark-mode .super-admin__headline p {
    color: rgba(226, 232, 240, 0.78);
}

.super-admin__actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.super-admin__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.super-admin__card {
    background: rgba(15, 23, 42, 0.04);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.dark-mode .super-admin__card {
    background: rgba(15, 23, 42, 0.45);
    border-color: rgba(71, 85, 105, 0.45);
}

.super-admin__card span {
    font-size: 14px;
    color: rgba(30, 41, 59, 0.68);
}

.dark-mode .super-admin__card span {
    color: rgba(226, 232, 240, 0.65);
}

.super-admin__card strong {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-600);
}

.super-admin__status {
    padding: 14px 18px;
    border-radius: 16px;
    background: rgba(56, 189, 248, 0.14);
    border: 1px solid rgba(56, 189, 248, 0.28);
    color: rgba(15, 118, 110, 0.92);
    font-weight: 600;
}

.super-admin__status.error {
    background: rgba(248, 113, 113, 0.2);
    border-color: rgba(248, 113, 113, 0.35);
    color: #b91c1c;
}

.super-admin__status.success {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.35);
    color: #047857;
}

.super-admin__section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.super-admin__section--danger {
    border-top: 1px solid rgba(248, 113, 113, 0.25);
    padding-top: 16px;
}

.super-admin__hint {
    margin: 0;
    font-size: 13px;
    color: rgba(30, 41, 59, 0.65);
}

.dark-mode .super-admin__hint {
    color: rgba(226, 232, 240, 0.65);
}

.super-admin__delete {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.super-admin__delete-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.super-admin__delete-search {
    flex: 1 1 260px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: rgba(30, 41, 59, 0.85);
}

.dark-mode .super-admin__delete-search {
    color: rgba(226, 232, 240, 0.85);
}

.super-admin__delete-search input {
    height: 48px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 0 14px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.92);
}

.dark-mode .super-admin__delete-search input {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(71, 85, 105, 0.45);
    color: rgba(226, 232, 240, 0.92);
}

.super-admin__delete-details {
    border: 1px solid rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.08);
    border-radius: 18px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dark-mode .super-admin__delete-details {
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.18);
}

.super-admin__delete-details dl {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px 24px;
    margin: 0;
}

.super-admin__delete-details dt {
    font-weight: 700;
    font-size: 14px;
    color: rgba(30, 41, 59, 0.75);
}

.dark-mode .super-admin__delete-details dt {
    color: rgba(226, 232, 240, 0.8);
}

.super-admin__delete-details dd {
    margin: 2px 0 0;
    font-size: 14px;
    color: rgba(30, 41, 59, 0.9);
}

.dark-mode .super-admin__delete-details dd {
    color: rgba(226, 232, 240, 0.9);
}

.super-admin__delete-details .btn-danger {
    align-self: flex-start;
    min-width: 180px;
}

.super-admin__section-head h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.super-admin__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.super-admin__list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.02);
}

.dark-mode .super-admin__list-item {
    background: rgba(15, 23, 42, 0.45);
    border-color: rgba(71, 85, 105, 0.45);
}

.super-admin__list-item strong {
    font-size: 16px;
}

.super-admin__list-item span {
    font-size: 13px;
    color: rgba(30, 41, 59, 0.65);
}

.dark-mode .super-admin__list-item span {
    color: rgba(226, 232, 240, 0.65);
}

.super-admin__modal {
    max-width: 640px;
    gap: 24px;
}

.super-admin__form-grid {
    gap: 16px;
}

.super-admin__form-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: rgba(30, 41, 59, 0.85);
}

.dark-mode .super-admin__form-grid label {
    color: rgba(226, 232, 240, 0.85);
}

.super-admin__form-grid input,
.super-admin__form-grid select {
    height: 48px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 0 14px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.92);
}

.dark-mode .super-admin__form-grid input,
.dark-mode .super-admin__form-grid select {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(71, 85, 105, 0.45);
    color: rgba(226, 232, 240, 0.92);
}

.super-admin__form-grid small {
    font-size: 12px;
    color: rgba(30, 41, 59, 0.55);
}

.dark-mode .super-admin__form-grid small {
    color: rgba(226, 232, 240, 0.55);
}

@media (max-width: 768px) {
    .super-admin__container {
        padding: 24px 20px;
    }

    .super-admin__stats {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

@media (max-width: 480px) {
    .super-admin__header {
        align-items: flex-start;
    }

    .super-admin__actions {
        width: 100%;
        justify-content: stretch;
    }

    .super-admin__actions .btn {
        flex: 1 1 auto;
    }
}