:root {
    --bg-primary: #0a0c10;
    --bg-secondary: #0f1218;
    --bg-tertiary: #161b22;
    --bg-card: linear-gradient(145deg, #12161d 0%, #161b24 100%);
    --bg-hover: #1c222d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #238636;
    --accent-light: #2ea043;
    --accent-dark: #1a7f37;
    --accent-glow: rgba(35, 134, 54, 0.25);
    --blue: #1f6feb;
    --blue-glow: rgba(31, 111, 235, 0.25);
    --success: #238636;
    --success-glow: rgba(35, 134, 54, 0.25);
    --warning: #d29922;
    --warning-glow: rgba(210, 153, 34, 0.2);
    --danger: #da3633;
    --danger-glow: rgba(218, 54, 51, 0.2);
    --border: rgba(240, 246, 252, 0.1);
    --border-light: rgba(240, 246, 252, 0.15);
    --shadow: 0 3px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.5);
    --glass: rgba(240, 246, 252, 0.02);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 13px;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--bg-primary);
}

.login-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 6px;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.login-box p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 13px;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

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

.btn-danger:hover {
    background: #e5534b;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-size: 16px;
    font-weight: 600;
    padding: 0 12px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.15s;
    cursor: pointer;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--blue);
    color: white;
}

.nav-item svg {
    width: 16px;
    height: 16px;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--blue);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: white;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 500;
    font-size: 13px;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

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

.page-title {
    font-size: 20px;
    font-weight: 600;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border);
    transition: border-color 0.15s;
}

.stat-card:hover {
    border-color: var(--border-light);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.stat-value.success {
    color: var(--success);
}

.stat-value.warning {
    color: var(--warning);
}

.stat-value.accent {
    color: var(--blue);
}

/* Tables */
.table-container {
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.table-title {
    font-size: 14px;
    font-weight: 600;
}

.table-filters {
    display: flex;
    gap: 8px;
}

.table-filters input,
.table-filters select {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
}

.table-filters input:focus,
.table-filters select:focus {
    border-color: var(--blue);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--bg-tertiary);
}

tr:hover {
    background: var(--glass);
}

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

/* Status Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-new {
    background: rgba(31, 111, 235, 0.15);
    color: var(--blue);
}

.badge-contacted {
    background: rgba(210, 153, 34, 0.15);
    color: var(--warning);
}

.badge-converted {
    background: rgba(35, 134, 54, 0.15);
    color: var(--success);
}

.badge-lost {
    background: rgba(218, 54, 51, 0.15);
    color: var(--danger);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s;
    border: 1px solid var(--border);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* Messages */
.messages-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.message {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 75%;
    font-size: 13px;
}

.message.incoming {
    background: var(--bg-tertiary);
    margin-right: auto;
}

.message.outgoing {
    background: var(--blue);
    margin-left: auto;
    color: white;
}

.message-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

.message.outgoing .message-time {
    color: rgba(255, 255, 255, 0.6);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
}

.alert-error {
    background: rgba(218, 54, 51, 0.1);
    color: var(--danger);
    border: 1px solid rgba(218, 54, 51, 0.2);
}

.alert-success {
    background: rgba(35, 134, 54, 0.1);
    color: var(--success);
    border: 1px solid rgba(35, 134, 54, 0.2);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 12px;
}

.pagination button {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-hover);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 13px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 10px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value {
        font-size: 20px;
    }

    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }

    .page-title {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.empty-state p {
    font-size: 13px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Selection */
::selection {
    background: var(--blue);
    color: white;
}

/* Focus */
:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* Page animation */
.page {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
