:root {
    --bg-dark: #090d16;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(30, 41, 59, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #6366f1;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.15);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Glassmorphism Surface */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Utility */
.hidden { display: none !important; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1.25rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #ffffff;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--text-main);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}
.btn-block {
    width: 100%;
}

/* Spinner */
.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Login Page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 45%),
                radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.1), transparent 45%),
                var(--bg-dark);
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 1.5rem;
}

.login-card {
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-badge {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.login-header .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
}
.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.req { color: var(--danger); }

input[type="text"],
input[type="password"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 0.7rem 1rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.login-footer {
    text-align: center;
    margin-top: 1.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Dashboard Layout */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.brand-logo {
    font-size: 1.4rem;
}
.brand-title {
    font-weight: 700;
    font-size: 1.05rem;
    display: block;
}
.brand-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.user-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
}

.main-layout {
    max-width: 1280px;
    margin: 1.5rem auto;
    padding: 0 1.5rem 3rem;
}

/* Tab Bar */
.tab-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}
.tab-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25));
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: var(--text-main);
}

.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
    animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.card-header {
    margin-bottom: 1.25rem;
}
.card-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}
.card-header h4 {
    font-size: 1.05rem;
    font-weight: 600;
}

/* Form Grids */
.audit-grid-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.span-2 {
    grid-column: span 2;
}

.form-check {
    display: flex;
    align-items: center;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-main);
}
.checkbox-label input {
    cursor: pointer;
}

.checkbox-group {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.4rem;
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    cursor: pointer;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.metric-card {
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
}
.metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0.4rem 0 0.2rem;
}
.metric-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.data-table th {
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}
.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Tickets */
.tickets-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ticket-item {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: #e2e8f0;
}

/* Code & Previews */
.code-editor,
.code-preview {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    background: #050811;
    color: #e2e8f0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    width: 100%;
    overflow-x: auto;
}

.split-editor-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.preview-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.preview-tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
}
.preview-tab-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed rgba(99, 102, 241, 0.4);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}
.drop-zone:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}
.drop-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}
.drop-filename {
    display: block;
    margin-top: 0.5rem;
    color: var(--success);
    font-weight: 600;
}

.or-separator {
    text-align: center;
    margin: 1.25rem 0;
    position: relative;
}
.or-separator::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}
.or-separator span {
    position: relative;
    background: var(--bg-dark);
    padding: 0 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1e293b;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 999;
    font-size: 0.88rem;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Analytics & Charts Styling */
.analytics-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.flex-gap {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.select-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    width: auto;
    background: rgba(0, 0, 0, 0.4);
}
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}
.chart-container {
    position: relative;
    width: 100%;
    height: 320px;
    margin-top: 0.5rem;
}

/* Rank Movement Badges */
.rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 700;
}
.rank-up {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
}
.rank-down {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
}
.rank-same {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.rank-new {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.5);
    color: #a5b4fc;
}

/* Client Switcher in Header */
.client-switcher-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 1rem;
}
.client-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.client-select {
    min-width: 180px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.4);
}

/* Modal Dialog */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}
.modal-dialog {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.modal-header {
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}
.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.btn-close:hover {
    color: #ffffff;
}
.ml-auto {
    margin-left: auto;
}
.input-sm {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
}
