:root {
    /* Colors */
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;

    /* Spacing & Utilities */
    --space-md: 20px;
    --space-lg: 30px;
    --space-xl: 40px;

    /* Admin/Layout specific */
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #334155;

    /* Layout */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --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);
}

/* Utilities */
.mt-1 {
    margin-top: 5px;
}

.mt-2 {
    margin-top: 10px;
}

.mt-3 {
    margin-top: 20px;
}

.mt-4 {
    margin-top: 30px;
}

.mt-5 {
    margin-top: 40px;
}

.mb-1 {
    margin-bottom: 5px;
}

.mb-2 {
    margin-bottom: 10px;
}

.mb-3 {
    margin-bottom: 20px;
}

.mb-4 {
    margin-bottom: 25px;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 10px;
}

.w-full {
    width: 100%;
}

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

.list-none {
    list-style: none;
    padding: 0;
}

.border-top {
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.card-md {
    max-width: 600px;
    margin: 40px auto;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Common Components */
.card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.2s;
    text-decoration: none;
    color: white;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
}

.btn-danger {
    background: var(--danger);
}

.btn-secondary {
    background: var(--secondary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    gap: 5px;
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
    /* Make them round or just square-ish */
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    background: white;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    background: white;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Status messages */
.status {
    margin-top: 15px;
    padding: 12px 15px;
    border-radius: var(--radius-md);
    font-size: 14px;
    display: none;
}

.status.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.status.success {
    display: block;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.status.info {
    display: block;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Dashboard Specific Components */
.info {
    background: #f1f5f9;
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.info strong {
    color: var(--primary);
}

.system-list {
    list-style: none;
    padding: 0;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.system-item {
    padding: 15px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.system-item:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.system-item.admin {
    background: #fff7ed;
    border-color: #fed7aa;
}

.system-item.admin .system-item-title {
    color: #9a3412;
}

.system-item.admin .system-item-subtitle {
    color: #c2410c;
}

.system-item-title {
    font-weight: 600;
    color: var(--text);
    display: block;
}

.system-item-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

/* Mobile Responsive Dashboard */
@media (max-width: 640px) {
    .system-item {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        text-align: center;
    }

    .system-item>div:first-child {
        margin-bottom: 5px;
    }

    .sso-buttons {
        justify-content: center;
        width: 100%;
    }

    .sso-buttons .btn {
        flex: 1;
        min-width: 120px !important;
        /* Override inline style safely */
        width: 100%;
    }
}

/* Premium Login/Dashboard specific */
.auth-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-card {
    max-width: 450px;
    width: 100%;
    overflow: hidden;
    padding: 0;
}

.auth-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.auth-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.auth-header p {
    opacity: 0.9;
    font-size: 14px;
}

.auth-body {
    padding: 30px;
}

.divider {
    text-align: center;
    margin: 25px 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.divider span {
    background: white;
    padding: 0 15px;
    position: relative;
    color: var(--text-muted);
    font-size: 14px;
}

.alert-box {
    background: #f8fafc;
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 25px;
}

.tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.3s;
    position: relative;
    white-space: nowrap;
}

/* Mobile responsive tabs */
@media (max-width: 480px) {
    .tab {
        font-size: 13px;
        padding: 10px 6px;
        white-space: normal;
        text-align: center;
        line-height: 1.2;
    }
}

/* Very small screens - show only icons */
@media (max-width: 380px) {
    .tab {
        padding: 10px 4px;
    }

    .tab-label {
        display: none;
    }

    .tab i {
        font-size: 18px;
    }
}

.tab.active {
    color: var(--primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Account Selection Component */
.account-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.account-item:hover {
    border-color: var(--primary);
    background: var(--bg);
    transform: translateY(-2px);
}

.account-icon {
    width: 40px;
    height: 40px;
    background: #e0e7ff;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 15px;
}

.account-info {
    flex: 1;
}

.account-name {
    font-weight: 600;
    color: #334155;
    display: block;
}

.account-system {
    font-size: 12px;
    color: var(--text-muted);
}

/* Modals & Overlays */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.data-table th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 14px;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:hover {
    background: #f8fafc;
}

code {
    background: #f1f5f9;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #475569;
}

/* Sidebar & Admin Layout */
/* Sidebar & Admin Layout */
.admin-body {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 25px 20px;
    font-size: 20px;
    font-weight: bold;
    border-bottom: 1px solid #334155;
    margin-bottom: 20px;
}

.nav-link {
    display: block;
    padding: 12px 25px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: 0.2s;
}

.logout-link {
    color: #f87171 !important;
}

.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    /* Ensure visible on top of everything */
    border: none;
    font-size: 1.2rem;
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    background: var(--primary-dark);
}

.nav-link:hover,
.nav-link.active {
    background: var(--sidebar-active);
    color: white;
}

.nav-link.active {
    border-left: 4px solid var(--primary);
}

.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.text-muted {
    color: var(--text-muted);
}

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

.text-success {
    color: var(--success);
}

/* Modal Styles Refactor */
.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.custom-modal-content {
    background: white;
    width: 450px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 15px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 18px;
    color: #1e293b;
    font-weight: 600;
}

.modal-close {
    border: none;
    background: none;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #334155;
}

.modal-body {
    padding: 20px;
}

.modal-user-info {
    margin-bottom: 20px;
    color: #64748b;
    font-size: 14px;
}

.modal-user-name {
    color: #1e293b;
    font-weight: 600;
}

.modal-footer {
    padding: 0;
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Input Group Styles */
.input-group-label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
    display: block;
}

.input-group-wrapper {
    display: flex;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.input-group-wrapper:focus-within {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    border-color: #6366f1;
}

.input-group-field {
    border: none;
    border-right: 1px solid #e2e8f0;
    border-radius: 0;
    flex-grow: 1;
    padding: 10px 15px;
    outline: none;
}

.input-group-field:focus {
    box-shadow: none;
    border-color: transparent;
}

.input-group-btn {
    background: #fff;
    color: #64748b;
    border: none;
    padding: 0 12px;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.input-group-btn:not(:last-child) {
    border-right: 1px solid #e2e8f0;
}

.input-group-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

/* New User Form Styles */
.add-user-form {
    display: none;
    margin-bottom: 20px;
}

.search-card {
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    gap: 10px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.btn-outline:hover {
    background: var(--bg);
}

.blocked-row {
    opacity: 0.6;
    background: #f9f9f9;
}

.systems-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}