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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.section {
    width: 100%;
}

.hidden {
    display: none !important;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.card h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2em;
}

.card h2 {
    color: #555;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.card-tabs {
    padding-top: 0;
}

.card-tabs > .tabs {
    margin: 0 -30px 0 -30px;
}

.subtitle {
    color: #666;
    margin-bottom: 25px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.header h1 {
    color: #333;
    font-size: 1.8em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e8e8ef;
    margin-bottom: 24px;
    padding: 0 30px;
    background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
    border-radius: 12px 12px 0 0;
}

.tab-btn {
    flex: 1;
    min-width: 0;
    max-width: none;
    padding: 14px 12px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    font-family: inherit;
}

.tab-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.06);
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

.tab-panel {
    display: none;
    padding-top: 4px;
}

.tab-panel.active {
    display: block;
}

.tab-panel-title {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 20px;
    font-size: 1.25rem;
}

.bulk-hint {
    color: #64748b;
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 20px;
}

.bulk-upload-form {
    margin-bottom: 12px;
}

.bulk-upload-form input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1.5px dashed #c7d2fe;
    border-radius: 10px;
    background: #fafbff;
    font-size: 0.95rem;
}

.bulk-summary {
    margin-top: 12px;
    padding: 12px 14px;
    background: #f1f5f9;
    border-radius: 8px;
    color: #334155;
    font-size: 0.95rem;
}

.bulk-download-wrap {
    margin-top: 16px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #4b5563;
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

/* Text fields — shared base */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"] {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.45;
    color: #1f2937;
    background: #fafbfc;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="tel"]:hover {
    border-color: #cbd5e1;
    background: #fff;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
    box-shadow:
        inset 0 1px 2px rgba(15, 23, 42, 0.04),
        0 0 0 3px rgba(102, 126, 234, 0.2);
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="tel"]::placeholder {
    color: #9ca3af;
}

/* Search field — icon + stronger affordance */
input.search-field[type="search"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    padding: 13px 16px 13px 44px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.45;
    color: #1f2937;
    background-color: #f4f6fb;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.2-3.2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px 50%;
    background-size: 18px 18px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow:
        inset 0 1px 2px rgba(15, 23, 42, 0.06),
        0 1px 0 rgba(255, 255, 255, 0.8);
}

input.search-field[type="search"]:hover {
    border-color: #c7d2fe;
    background-color: #fafbff;
}

input.search-field[type="search"]:focus {
    outline: none;
    border-color: #667eea;
    background-color: #fff;
    box-shadow:
        inset 0 1px 2px rgba(15, 23, 42, 0.04),
        0 0 0 3px rgba(102, 126, 234, 0.22);
}

input.search-field[type="search"]::placeholder {
    color: #94a3b8;
}

input.search-field[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 18px;
    margin-right: 2px;
    cursor: pointer;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / contain no-repeat;
    opacity: 0.85;
}

input.search-field[type="search"]::-webkit-search-cancel-button:hover {
    opacity: 1;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-test {
    background: #28a745;
    color: white;
    margin-bottom: 10px;
}

.btn-test:hover {
    background: #218838;
}

.error-message {
    color: #dc3545;
    margin-top: 15px;
    padding: 10px;
    background: #f8d7da;
    border-radius: 6px;
    display: none;
}

.error-message.show {
    display: block;
}

.message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    display: none;
}

.message.success {
    display: block;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.users-list {
    margin-top: 20px;
}

.user-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid #667eea;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.um-access-col {
    flex: 0 0 auto;
    min-width: 200px;
    max-width: 240px;
}

.um-access-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    line-height: 1.35;
}

.um-access-label input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    flex-shrink: 0;
}

.user-info-item {
    flex: 1;
    min-width: 200px;
}

.user-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.875rem;
    border-radius: 8px;
}

.btn-edit-user {
    background: #fff;
    color: #667eea;
    border: 1.5px solid #667eea;
}

.btn-edit-user:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: none;
    box-shadow: none;
}

.btn-reset-pw {
    background: #fff;
    color: #b45309;
    border: 1.5px solid #f59e0b;
}

.btn-reset-pw:hover {
    background: #fffbeb;
    transform: none;
    box-shadow: none;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.modal-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    margin: 0;
}

.modal-title {
    color: #333;
    font-size: 1.35rem;
    margin-bottom: 8px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.modal-hint {
    color: #64748b;
    font-size: 0.875rem;
    margin-bottom: 16px;
    line-height: 1.45;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.user-info-item strong {
    color: #667eea;
}

.loading {
    text-align: center;
    color: #666;
    padding: 20px;
}

.actions {
    margin-bottom: 15px;
}

.actions-with-search {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
}

.actions-with-search .user-search-wrap {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.actions-with-search .btn {
    flex-shrink: 0;
    align-self: flex-end;
}

.users-count {
    margin-bottom: 15px;
}

.api-tests {
    display: grid;
    gap: 20px;
}

.test-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.test-item h3 {
    margin-bottom: 10px;
    color: #555;
}

.test-result {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin-top: 10px;
    font-size: 12px;
    display: none;
}

.test-result.show {
    display: block;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
    }

    .tabs {
        flex-direction: column;
        padding: 0 0;
    }

    .tab-btn {
        max-width: none;
        border-bottom: 1px solid #e8e8ef;
        border-left: 3px solid transparent;
        margin-bottom: 0;
    }

    .tab-btn.active {
        border-left-color: #667eea;
        border-bottom-color: #e8e8ef;
    }
}

/* Top Navigation Menu */
.top-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    margin: -20px -20px 20px -20px;
    padding: 0;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

.nav-logo {
    font-size: 1.8rem;
}

.nav-title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 5px;
    margin: 0;
    padding: 0;
}

.nav-item {
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    color: #555;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-link:hover {
    background: #f0f0f0;
    color: #667eea;
    transform: translateY(-1px);
}

.nav-item.active .nav-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.nav-icon {
    font-size: 1.2rem;
}

.nav-text {
    white-space: nowrap;
}

/* Adjust container padding for nav */
body {
    padding-top: 0;
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    
    .nav-link {
        padding: 8px 15px;
        font-size: 0.85rem;
    }
    
    .nav-text {
        display: none;
    }
    
    .nav-icon {
        font-size: 1.4rem;
    }
}
