/* ============================================
   TheTripIndia Admin Panel — Enterprise Design
   Dark Theme | Inter Font | 8px Grid
   ============================================ */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Background */
    --bg-primary: #0a0e17;
    --bg-surface: #121822;
    --bg-surface-hover: #1a2230;
    --bg-elevated: #1e2a3a;
    --bg-input: #0d1219;

    /* Border */
    --border-primary: #1e2a3a;
    --border-secondary: #253347;
    --border-active: #3b82f6;

    /* Text */
    --text-primary: #e8ecf1;
    --text-secondary: #8892a4;
    --text-muted: #5a6578;
    --text-inverse: #0a0e17;

    /* Accent Colors */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.15);

    /* Semantic */
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --info: #6366f1;
    --info-light: rgba(99, 102, 241, 0.15);

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.5);

    /* Layout */
    --sidebar-width: 240px;
    --topbar-height: 56px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

html { font-size: 14px; -webkit-font-smoothing: antialiased; overflow-x: clip; }

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: clip;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

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

/* === Top Bar === */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    z-index: 100;
    gap: var(--space-4);
}

.topbar-logo {
    width: var(--sidebar-width);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
}

.topbar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.topbar-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    padding: 8px 16px 8px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--transition-fast);
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.topbar-search::before {
    content: "🔍";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.5;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
}

.topbar-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    position: relative;
    transition: all var(--transition-fast);
}

.topbar-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.topbar-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px 8px 4px 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.topbar-user:hover {
    background: var(--bg-surface-hover);
}

.topbar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.topbar-user-info {
    line-height: 1.2;
}

.topbar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

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

.topbar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s;
}

.topbar-logout svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.topbar-logout:hover {
    background: var(--bg-surface-hover);
    color: var(--danger);
}

/* Mobile responsive: larger touch target, always visible */
@media (max-width: 768px) {
    .topbar-logout {
        width: 40px;
        height: 40px;
        color: var(--text-secondary);
    }
    .topbar-logout svg {
        width: 22px;
        height: 22px;
    }
    .topbar-logout:hover {
        background: var(--bg-surface-hover);
        color: var(--danger);
    }
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 50;
    scrollbar-width: thin;
    scrollbar-color: var(--border-secondary) transparent;
}

.sidebar-section {
    padding: var(--space-4) 0 0;
}

.sidebar-section-title {
    padding: 0 var(--space-5) var(--space-2);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px var(--space-5);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 450;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    cursor: pointer;
}

.sidebar-link:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.sidebar-link-active {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.sidebar-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--danger-light);
    color: var(--danger);
}

.sidebar-footer {
    margin-top: auto;
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-primary);
}

.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: var(--space-6);
    min-height: calc(100vh - var(--topbar-height));
    width: calc(100% - var(--sidebar-width));
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.page-actions {
    display: flex;
    gap: var(--space-3);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

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

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

.card-header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
}

.btn-icon--view:hover {
    color: var(--accent);
}

.btn-icon--delete:hover {
    color: #ef4444;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Cards === */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    overflow: hidden;
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* === Stat Cards === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
}

.stat-card-accent::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
}

.stat-card-success::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--success);
}

.stat-card-warning::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--warning);
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: var(--space-2);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 12px;
    font-weight: 500;
    margin-top: var(--space-2);
}

.stat-change-up { color: var(--success); }
.stat-change-down { color: var(--danger); }

.stat-icon {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--accent-light);
    color: var(--accent);
}

/* === Grid Layouts === */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: var(--space-4); }

/* === Table === */
.table-container {
    overflow-x: auto;
}

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

.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-primary);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-primary);
    font-size: 13px;
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: var(--bg-surface-hover);
}

.data-table .cell-muted { color: var(--text-muted); }
.data-table .cell-number { font-family: var(--font-mono); text-align: right; }
.data-table .cell-actions { text-align: right; white-space: nowrap; }

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-neutral { background: var(--bg-elevated); color: var(--text-secondary); }

/* === Status Dot === */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot-active { background: var(--success); }
.status-dot-pending { background: var(--warning); }
.status-dot-inactive { background: var(--text-muted); }
.status-dot-danger { background: var(--danger); }

/* === Tabs === */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-primary);
    margin-bottom: var(--space-5);
    gap: 0;
    overflow-x: auto;
}

.tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab:hover { color: var(--text-primary); }
.tab-active { color: var(--accent); border-bottom-color: var(--accent); }

/* === Form Controls === */
.form-group {
    margin-bottom: var(--space-4);
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.hb-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 10px 0;
}
.hb-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}
.hb-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent, #059669);
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* === Toggle Switch === */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-elevated);
    border-radius: 22px;
    transition: var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.alert-success { background: var(--success-light); color: var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning); }
.alert-danger { background: var(--danger-light); color: var(--danger); }
.alert-info { background: var(--info-light); color: var(--info); }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

/* === Loading === */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-surface-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 23, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

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

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

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

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

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

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

.modal-body { padding: var(--space-5); }

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-primary);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination-btns {
    display: flex;
    gap: var(--space-1);
}

.pagination-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-primary);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all var(--transition-fast);
}

.pagination-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.pagination-btn-active { background: var(--accent); color: white; border-color: var(--accent); }

/* === Toast === */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-height) + var(--space-4));
    right: var(--space-4);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    animation: toast-in 0.3s ease;
    min-width: 280px;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }

/* === Progress Bar === */
.progress {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width var(--transition-normal);
}

.progress-bar-accent { background: var(--accent); }
.progress-bar-success { background: var(--success); }
.progress-bar-warning { background: var(--warning); }

/* === Chart Container === */
.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* === Section Title === */
.section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

/* === Utility === */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none; }

/* === Login Page === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image: radial-gradient(ellipse at top, var(--bg-surface) 0%, var(--bg-primary) 70%);
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: var(--space-8);
    width: 400px;
    box-shadow: var(--shadow-xl);
}

.login-logo {
    text-align: center;
    margin-bottom: var(--space-6);
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin-top: var(--space-3);
}

.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: var(--space-4);
}

/* === Hamburger Button === */
.topbar-hamburger {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}
.topbar-hamburger:hover {
    background: var(--bg-surface-hover);
}

/* === Sidebar Overlay === */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
    opacity: 0;
}

/* === Responsive === */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .topbar-hamburger { display: flex; }
    .topbar-logo { width: auto; }
    .topbar-logo span { display: none; }
    .topbar-search { display: none; }

    .sidebar {
        display: flex;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
        top: 0;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
        opacity: 1;
    }

    .main-content { margin-left: 0; width: 100%; padding: var(--space-4); }
    .topbar { padding: 0 var(--space-4); }

    .stat-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }

    .filter-bar__group { flex-wrap: wrap; }
    .table { min-width: 600px; }
}

/* ── Site Guard ── */
.sg-domain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}
.sg-domain-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.sg-domain-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.sg-domain-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
}
.sg-domain-status {
    font-size: 12px;
    font-weight: 700;
    margin-top: var(--space-2);
}
.sg-domain-meta {
    margin-top: var(--space-2);
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
}
.sg-detail-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.sg-filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}
.sg-checks-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.sg-check-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.sg-check-status {
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}
.sg-check-info {
    flex: 1;
    min-width: 0;
}
.sg-check-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.sg-check-detail {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    word-break: break-word;
}
.sg-check-id {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

/* ============================================
   SETTINGS PAGE — Enterprise Design
   ============================================ */

:root {
    --sidebar-settings-width: 260px;
    --sidebar-settings-collapsed: 48px;
    --dirty-color: var(--warning);
    --dirty-light: var(--warning-light);
    --valid-color: var(--success);
    --invalid-color: var(--danger);
    --valid-light: var(--success-light);
    --invalid-light: var(--danger-light);
}

/* === Settings Layout === */
.settings-layout {
    display: grid;
    grid-template-columns: var(--sidebar-settings-width) 1fr;
    min-height: calc(100vh - var(--topbar-height));
}

/* === Settings Sidebar === */
.settings-sidebar {
    position: sticky;
    top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
    background: var(--bg-surface);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--transition-normal);
    z-index: 50;
}

.settings-sidebar.collapsed {
    width: var(--sidebar-settings-collapsed);
}

.sidebar-search {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--transition-fast);
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.sidebar-search {
    position: relative;
}

.sidebar-search::before {
    content: "🔍";
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.5;
    pointer-events: none;
}

.sidebar-sections {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) 0;
}

.sidebar-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px var(--space-4);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 450;
    cursor: pointer;
    text-align: left;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
}

.sidebar-section-toggle:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

/* Freeze the settings submenu: keep it sticky and always visible (never collapse) */
.settings-sidebar {
    position: sticky;
    top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
}

.sidebar-sections {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) 0;
}

/* Prevent the collapse from hiding submenu labels on the settings page */
.settings-sidebar.collapsed { width: var(--sidebar-settings-width); }
.settings-sidebar.collapsed .sidebar-section-toggle .label,
.settings-sidebar.collapsed .sidebar-section-toggle .badge,
.settings-sidebar.collapsed .sidebar-search { display: block; }
.settings-sidebar.collapsed .sidebar-section-toggle .label { display: inline; }

.sidebar-section-toggle.active {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-section-toggle .icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-section-toggle .badge {
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-section-toggle .badge.dirty {
    background: var(--warning);
}

.sidebar-section-toggle .badge.error {
    background: var(--danger);
}

.sidebar-section-toggle .badge[hidden] {
    display: none;
}

.settings-sidebar.collapsed .sidebar-section-toggle .label,
.settings-sidebar.collapsed .sidebar-section-toggle .badge {
    display: none;
}

.settings-sidebar.collapsed .sidebar-search {
    display: none;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.settings-sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar-footer .btn {
    width: 100%;
    justify-content: center;
}

/* === Settings Main Content === */
.settings-main {
    overflow-y: auto;
    padding: var(--space-6);
}

.settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 2px 0 0;
}

.header-actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* === Section Card === */
.settings-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    margin-bottom: var(--space-5);
    overflow: hidden;
    transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.settings-section:hover {
    box-shadow: var(--shadow-md);
}

.settings-section.dirty {
    border-color: var(--warning);
}

.settings-section.has-error {
    border-color: var(--danger);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-primary);
    flex-wrap: wrap;
}

.section-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.section-meta {
    flex: 1;
    min-width: 200px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.section-description {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 2px 0 0;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.section-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.section-badge.dirty {
    background: var(--dirty-light);
    color: var(--dirty-color);
}

.section-badge.error {
    background: var(--invalid-light);
    color: var(--invalid-color);
}

.section-body {
    padding: var(--space-4) var(--space-5) var(--space-5);
}

/* === Setting Row === */
.setting-row {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-primary);
    align-items: start;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-row.dirty .setting-label::before {
    content: "";
    position: absolute;
    left: -var(--space-5);
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--warning);
    border-radius: 2px;
}

.setting-row.has-error .setting-input-wrapper .form-input,
.setting-row.has-error .setting-input-wrapper .form-select,
.setting-row.has-error .setting-input-wrapper .form-textarea,
.setting-row.has-error .setting-input-wrapper .secret-input {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--invalid-light);
}

.setting-label {
    position: relative;
    padding-right: var(--space-4);
}

.setting-label label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.setting-type {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 4px;
}

.setting-warning {
    display: inline-block;
    margin-left: var(--space-2);
    font-size: 11px;
    color: var(--warning);
    font-weight: 500;
}

.setting-input-wrapper {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.setting-hint {
    grid-column: 2;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.5;
}

.setting-help {
    grid-column: 2;
    font-size: 12px;
    color: #6d28d9;
    background: #f5f3ff;
    border: 1px solid #ede9fe;
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 6px;
    line-height: 1.5;
}

.email-helper-card {
    grid-column: 1 / -1;
    margin: 18px 0 6px;
    padding: 18px 20px;
    background: linear-gradient(180deg, #f0fdfa 0%, #ecfeff 100%);
    border: 1px solid #99f6e4;
    border-radius: 12px;
}

.email-helper-head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.email-helper-icon {
    font-size: 22px;
    line-height: 1;
}

.email-helper-head h3 {
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 700;
    color: #0f766e;
}

.email-helper-head p {
    margin: 0;
    font-size: 13px;
    color: #155e75;
}

.email-helper-steps {
    margin: 12px 0 0;
    padding-left: 20px;
    color: #134e4a;
    font-size: 13px;
    line-height: 1.7;
}

.email-helper-steps code {
    background: #ccfbf1;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
    color: #115e59;
}

.email-test-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.email-test-status {
    font-size: 13px;
    font-weight: 600;
}

.email-test-status.success { color: #059669; }
.email-test-status.error { color: #dc2626; }

.setting-validation {
    grid-column: 2;
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.setting-validation[hidden] {
    display: none;
}

.setting-validation::before {
    content: "⚠";
    font-size: 10px;
}

/* === Input Variants === */
.secret-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    min-width: 0;
}

.secret-input-wrapper .form-input {
    flex: 1;
    min-width: 0;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.input-with-unit .form-input {
    flex: 1;
}

.input-unit {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-primary);
    white-space: nowrap;
}

/* === Toggle Switch (Large) === */
.toggle-lg {
    width: 48px;
    height: 26px;
}

.toggle-lg .toggle-slider {
    border-radius: 26px;
}

.toggle-lg .toggle-slider::before {
    height: 22px;
    width: 22px;
}

.toggle-lg input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* === Reset Button === */
.reset-setting {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.setting-row.dirty .reset-setting,
.setting-row:focus-within .reset-setting {
    opacity: 1;
}

.reset-setting:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

/* === Secret Toggle & Copy Buttons === */
.toggle-secret,
.copy-secret {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toggle-secret:hover,
.copy-secret:hover {
    background: var(--bg-surface-hover);
}

/* === Footer Actions === */
.section-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-primary);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

.section-footer .btn {
    min-width: 100px;
}

/* === Toast Container Position for Settings === */
.toast-container {
    top: calc(var(--topbar-height) + var(--space-4));
}

/* === Responsive === */
@media (max-width: 1024px) {
    .settings-layout {
        grid-template-columns: var(--sidebar-settings-width) 1fr;
    }
}

@media (max-width: 768px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height);
        bottom: 0;
        width: var(--sidebar-settings-width);
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: var(--shadow-xl);
        border-right: none;
    }

    .settings-sidebar.open {
        transform: translateX(0);
    }

    .settings-sidebar.collapsed {
        width: var(--sidebar-settings-width);
    }

    .settings-sidebar.collapsed .sidebar-section-toggle .label,
    .settings-sidebar.collapsed .sidebar-section-toggle .badge,
    .settings-sidebar.collapsed .sidebar-search,
    .settings-sidebar.collapsed .sidebar-footer {
        display: block;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 150;
        opacity: 0;
        transition: opacity var(--transition-normal);
    }

    .sidebar-overlay.open {
        display: block;
        opacity: 1;
    }

    .main-content {
        padding: var(--space-4);
    }

    .setting-row {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .setting-label {
        padding-right: 0;
    }

    .setting-row.dirty .setting-label::before {
        display: none;
    }

    .setting-row.dirty {
        border-left: 3px solid var(--warning);
        padding-left: var(--space-3);
        margin-left: calc(-1 * var(--space-5));
        padding-right: var(--space-5);
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* === Focus Visible === */
.setting-input-wrapper .form-input:focus-visible,
.setting-input-wrapper .form-select:focus-visible,
.setting-input-wrapper .form-textarea:focus-visible,
.setting-input-wrapper .secret-input:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    .settings-sidebar,
    .sidebar-section-toggle,
    .setting-row,
    .reset-setting,
    .toggle-secret,
    .copy-secret {
        transition: none;
    }
}

/* === High Contrast === */
@media (prefers-contrast: high) {
    .setting-row.dirty .setting-label::before {
        width: 4px;
    }

    .settings-section.dirty,
    .settings-section.has-error {
        border-width: 2px;
    }
}
