*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html {
    scroll-behavior: smooth
}

body {
    font-family: 'Inter', sans-serif;
    background: #f8f9fb;
    color: #1e293b;
    overflow-x: hidden;
    transition: background .3s, color .3s
}

.dark body,
.dark {
    background: #0f1117;
    color: #e2e8f0
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px
}

::-webkit-scrollbar-track {
    background: transparent
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 99px
}

.dark ::-webkit-scrollbar-thumb {
    background: #334155
}

#sidebar {
    width: 260px;
    transition: width .3s cubic-bezier(.4, 0, .2, 1), transform .3s cubic-bezier(.4, 0, .2, 1);
    background: #fff;
    border-right: 1px solid #f1f5f9
}

.dark #sidebar {
    background: #141920;
    border-right-color: #1e2736
}

#sidebar.collapsed {
    width: 72px
}

#sidebar.collapsed .sidebar-label,
#sidebar.collapsed .sidebar-group-label,
#sidebar.collapsed .sidebar-badge,
#sidebar.collapsed .brand-text {
    display: none !important
}

#sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0
}

#sidebar.collapsed .sidebar-icon {
    margin-right: 0
}

#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 39;
    backdrop-filter: blur(2px)
}

#sidebar-overlay.active {
    display: block
}

@media(max-width:1023px) {
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 40;
        transform: translateX(-100%);
        width: 260px !important
    }

    #sidebar.mobile-open {
        transform: translateX(0)
    }

    #sidebar.collapsed {
        width: 260px !important
    }

    #sidebar.collapsed .sidebar-label,
    #sidebar.collapsed .sidebar-group-label,
    #sidebar.collapsed .sidebar-badge,
    #sidebar.collapsed .brand-text {
        display: flex !important
    }

    #sidebar.collapsed .sidebar-item {
        justify-content: flex-start;
        padding-left: 1rem;
        padding-right: 1rem
    }

    #sidebar.collapsed .sidebar-icon {
        margin-right: .75rem
    }
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: .55rem 1rem;
    margin: 1px .5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background .18s, color .18s;
    position: relative;
    gap: .65rem;
    font-size: .875rem;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    white-space: nowrap
}

.sidebar-item:hover {
    background: #fff7ed;
    color: #f97316
}

.dark .sidebar-item:hover {
    background: #1e2736;
    color: #fb923c
}

.sidebar-item.active {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    color: #f97316;
    font-weight: 600
}

.dark .sidebar-item.active {
    background: linear-gradient(135deg, #1e2736 0%, #1e2030 100%);
    color: #fb923c
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: -.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #f97316;
    border-radius: 0 3px 3px 0
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0
}

.sidebar-badge {
    margin-left: auto;
    background: #f97316;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
    line-height: 1.4
}

.sidebar-group-label {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 1rem 1.5rem .35rem
}

#sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1
}

#navbar {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 30;
    height: 64px
}

.dark #navbar {
    background: rgba(20, 25, 32, .9);
    border-bottom-color: #1e2736
}

.card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .04), 0 1px 2px -1px rgba(0, 0, 0, .04);
    transition: box-shadow .2s, transform .2s, border-color .2s
}

.dark .card {
    background: #141920;
    border-color: #1e2736
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem 1.1rem;
    border-radius: 10px;
    font-size: .845rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s;
    border: none;
    outline: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden
}

.btn:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px
}

.btn-primary {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    box-shadow: 0 2px 8px rgba(249, 115, 22, .3)
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ea580c, #c2410c);
    box-shadow: 0 4px 14px rgba(249, 115, 22, .4);
    transform: translateY(-1px)
}

.btn-secondary {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569
}

.dark .btn-secondary {
    background: #1e2736;
    border-color: #2d3748;
    color: #94a3b8
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155
}

.btn-ghost {
    background: transparent;
    color: #64748b
}

.btn-ghost:hover {
    background: #f8fafc;
    color: #1e293b
}

.dark .btn-ghost:hover {
    background: #1e2736;
    color: #e2e8f0
}

.btn-sm {
    padding: .35rem .75rem;
    font-size: .78rem;
    border-radius: 8px
}

.btn-icon {
    padding: .5rem;
    border-radius: 10px
}

.btn-danger {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #fff;
    box-shadow: 0 2px 8px rgba(244, 63, 94, .3)
}

.btn-outline-primary {
    background: transparent;
    border: 1.5px solid #f97316;
    color: #f97316
}

.btn-outline-primary:hover {
    background: #fff7ed
}

.dark .btn-outline-primary:hover {
    background: rgba(249, 115, 22, .1)
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .6rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600
}

.badge-orange {
    background: #fff7ed;
    color: #ea580c
}

.badge-emerald {
    background: #ecfdf5;
    color: #059669
}

.badge-rose {
    background: #fff1f2;
    color: #e11d48
}

.badge-sky {
    background: #f0f9ff;
    color: #0284c7
}

.badge-amber {
    background: #fffbeb;
    color: #d97706
}

.badge-slate {
    background: #f8fafc;
    color: #475569
}

.badge-violet {
    background: #f5f3ff;
    color: #7c3aed
}

.dark .badge-orange {
    background: #431407;
    color: #fb923c
}

.dark .badge-emerald {
    background: #022c22;
    color: #34d399
}

.dark .badge-rose {
    background: #4c0519;
    color: #fb7185
}

.dark .badge-sky {
    background: #082f49;
    color: #38bdf8
}

.dark .badge-amber {
    background: #451a03;
    color: #fbbf24
}

.dark .badge-slate {
    background: #1e2736;
    color: #94a3b8
}

.dark .badge-violet {
    background: #2e1065;
    color: #a78bfa
}

.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%
}

.dot-green {
    background: #10b981
}

.dot-red {
    background: #f43f5e
}

.dot-amber {
    background: #f59e0b
}

.dot-gray {
    background: #94a3b8
}

@keyframes livePulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, .4)
    }

    50% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0)
    }
}

.live-dot {
    animation: livePulse 1.5s ease-in-out infinite
}

.data-table th {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: .85rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap
}

.dark .data-table th {
    background: #0f1420;
    border-color: #1e2736;
    color: #64748b
}

.data-table td {
    padding: .9rem 1rem;
    border-bottom: 1px solid #f8fafc;
    font-size: .845rem;
    vertical-align: middle;
    color: #475569
}

.dark .data-table td {
    border-color: #1a2232;
    color: #94a3b8
}

.table-wrap {
    overflow-x: auto
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 14px;
    box-shadow: 0 20px 40px -8px rgba(0, 0, 0, .12);
    z-index: 50;
    min-width: 220px;
    animation: slideDown .18s ease-out;
    overflow: hidden
}

.dark .dropdown-menu {
    background: #141920;
    border-color: #1e2736
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem 1rem;
    font-size: .845rem;
    color: #475569;
    cursor: pointer;
    transition: background .15s, color .15s
}

.dark .dropdown-item {
    color: #94a3b8
}

.dropdown-item:hover {
    background: #f8fafc;
    color: #1e293b
}

.dark .dropdown-item:hover {
    background: #1a2232;
    color: #e2e8f0
}

.dropdown-divider {
    border-top: 1px solid #f1f5f9;
    margin: 4px 0
}

.dark .dropdown-divider {
    border-color: #1e2736
}

#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem
}

.toast {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.1rem;
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    min-width: 280px;
    max-width: 360px;
    animation: fadeIn .3s ease-out;
    font-size: .845rem;
    font-weight: 500
}

.dark .toast {
    background: #141920;
    border-color: #1e2736;
    color: #e2e8f0
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(4px);
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn .2s ease-out
}

.modal-box {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .18);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeIn .25s ease-out
}

.dark .modal-box {
    background: #141920;
    border: 1px solid #1e2736
}

.form-input {
    width: 100%;
    padding: .6rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: .875rem;
    background: #fff;
    color: #1e293b;
    outline: none;
    transition: border-color .2s, box-shadow .2s
}

.dark .form-input {
    background: #0f1420;
    border-color: #1e2736;
    color: #e2e8f0
}

.form-input:focus {
    border-color: #f97316;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .12)
}

[data-tooltip] {
    position: relative
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    font-size: .72rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    z-index: 99
}

[data-tooltip]:hover::after {
    opacity: 1
}

.switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: #d1d5db;
    border-radius: 99px;
    cursor: pointer;
    transition: background .2s;
    flex-shrink: 0;
    display: inline-block
}

.dark .switch {
    background: #374151
}

.switch.active {
    background: #10b981
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12)
}

.switch.active::after {
    transform: translateX(18px)
}

.custom-check {
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
    position: relative;
    flex-shrink: 0
}

.dark .custom-check {
    border-color: #374151;
    background: #0f1420
}

.custom-check:checked {
    background: #f97316;
    border-color: #f97316
}

.custom-check:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 10px;
    font-weight: 700
}

* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-duration: .2s;
    transition-timing-function: ease
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-15px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

/* ─── SETTINGS SPECIFIC ─── */
.settings-tab {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all .18s;
    color: #64748b;
    font-size: .86rem;
    font-weight: 500;
    position: relative;
    text-decoration: none
}

.settings-tab:hover {
    background: #f8fafc;
    color: #1e293b
}

.dark .settings-tab:hover {
    background: #1a2232;
    color: #e2e8f0
}

.settings-tab.active {
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    color: #f97316;
    font-weight: 600
}

.dark .settings-tab.active {
    background: linear-gradient(135deg, rgba(249, 115, 22, .1), rgba(245, 158, 11, .05));
    color: #fb923c
}

.settings-tab.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #f97316;
    border-radius: 0 3px 3px 0
}

.settings-tab-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    background: #f1f5f9;
    color: #64748b;
    transition: all .18s
}

.dark .settings-tab-icon {
    background: #1e2736;
    color: #94a3b8
}

.settings-tab.active .settings-tab-icon {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    box-shadow: 0 2px 6px rgba(249, 115, 22, .35)
}

.settings-tab-desc {
    font-size: .7rem;
    color: #94a3b8;
    margin-top: 1px;
    display: block;
    font-weight: 400
}

.settings-tab.active .settings-tab-desc {
    color: #c2410c
}

.dark .settings-tab.active .settings-tab-desc {
    color: #fdba74
}

/* Setting row */
.setting-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f1f5f9
}

.dark .setting-row {
    border-bottom-color: #1e2736
}

.setting-row:last-child {
    border-bottom: none
}

.setting-label {
    font-size: .86rem;
    font-weight: 600;
    color: #1e293b;
    display: block
}

.dark .setting-label {
    color: #e2e8f0
}

.setting-desc {
    font-size: .75rem;
    color: #94a3b8;
    margin-top: 2px;
    line-height: 1.5
}

/* Section header */
.section-header {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: .85rem
}

.dark .section-header {
    border-bottom-color: #1e2736
}

.section-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    color: #f97316;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0
}

.dark .section-icon {
    background: linear-gradient(135deg, #431407, #7c2d12);
    color: #fdba74
}

.section-body {
    padding: .5rem 1.5rem 1.5rem
}

/* Section panel */
.section-panel {
    display: none;
    animation: slideRight .35s ease-out
}

.section-panel.active {
    display: block
}

/* Language flag */
.lang-flag {
    font-size: 1.5rem;
    line-height: 1
}

/* Avatar upload preview */
.avatar-upload {
    position: relative;
    width: 96px;
    height: 96px;
    border-radius: 24px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1)
}

.dark .avatar-upload {
    border-color: #141920
}

.avatar-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover
}

.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .18s;
    font-size: 11px;
    font-weight: 600
}

.avatar-upload:hover .avatar-upload-overlay {
    opacity: 1
}

/* Theme card */
.theme-card {
    padding: 1rem;
    border: 2px solid #f1f5f9;
    border-radius: 14px;
    cursor: pointer;
    transition: all .2s;
    text-align: center;
    position: relative;
    background: #fff
}

.dark .theme-card {
    background: #141920;
    border-color: #1e2736
}

.theme-card:hover {
    border-color: #fed7aa;
    transform: translateY(-2px)
}

.theme-card.selected {
    border-color: #f97316;
    background: #fff7ed
}

.dark .theme-card.selected {
    background: rgba(249, 115, 22, .08)
}

.theme-preview {
    height: 70px;
    border-radius: 8px;
    margin-bottom: .5rem;
    position: relative;
    overflow: hidden;
    border: 1px solid #f1f5f9
}

.theme-light {
    background: linear-gradient(135deg, #f8fafc, #fff)
}

.theme-dark {
    background: linear-gradient(135deg, #141920, #0f1117)
}

.theme-auto {
    background: linear-gradient(90deg, #fff 50%, #141920 50%)
}

/* Color swatch (accent) */
.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    transition: all .18s;
    position: relative;
    border: 2px solid transparent
}

.color-swatch:hover {
    transform: scale(1.1)
}

.color-swatch.selected {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px currentColor
}

.dark .color-swatch.selected {
    box-shadow: 0 0 0 3px #141920, 0 0 0 5px currentColor
}

/* Session/device row */
.session-row {
    padding: 1rem;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    display: flex;
    gap: 1rem;
    align-items: center;
    background: #fff;
    transition: all .18s
}

.dark .session-row {
    background: #141920;
    border-color: #1e2736
}

.session-row:hover {
    border-color: #fed7aa
}

.session-row.current {
    background: linear-gradient(135deg, #f0fdf4, #fff);
    border-color: #86efac
}

.dark .session-row.current {
    background: linear-gradient(135deg, rgba(16, 185, 129, .08), #141920);
    border-color: #059669
}

.device-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0
}

/* Integration card */
.integration-card {
    padding: 1.15rem;
    border: 1px solid #f1f5f9;
    border-radius: 14px;
    background: #fff;
    transition: all .2s
}

.dark .integration-card {
    background: #141920;
    border-color: #1e2736
}

.integration-card:hover {
    box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .08);
    transform: translateY(-1px)
}

.integration-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
    font-weight: 800
}

/* API key row */
.api-key-input {
    font-family: 'SFMono-Regular', 'Monaco', 'Consolas', monospace;
    letter-spacing: .05em;
    font-size: .75rem
}

/* Save bar */
.save-bar {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, .95) 20%, #fff 100%);
    padding: 1.5rem 0 .25rem;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    transition: all .3s
}

.dark .save-bar {
    background: linear-gradient(180deg, transparent 0%, rgba(20, 25, 32, .95) 20%, #141920 100%)
}

.save-bar.hidden {
    display: none
}

/* Danger zone */
.danger-zone {
    background: linear-gradient(135deg, #fff1f2, #ffe4e6);
    border: 1px solid #fecaca;
    border-radius: 14px;
    padding: 1.25rem
}

.dark .danger-zone {
    background: linear-gradient(135deg, rgba(244, 63, 94, .05), rgba(239, 68, 68, .05));
    border-color: rgba(244, 63, 94, .25)
}

/* Password strength meter */
.strength-bar {
    height: 4px;
    border-radius: 99px;
    background: #f1f5f9;
    overflow: hidden;
    display: flex;
    gap: 2px
}

.dark .strength-bar {
    background: #1e2736
}

.strength-segment {
    flex: 1;
    height: 100%;
    background: #e2e8f0;
    border-radius: 99px;
    transition: background .3s
}

.dark .strength-segment {
    background: #2d3748
}

/* Timezone card */
.tz-card {
    padding: .85rem 1rem;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 12px
}

.dark .tz-card {
    background: #0f1420;
    border-color: #1e2736
}

/* Setting sub-header inside section */
.sub-header {
    padding: 1.25rem 0 .75rem;
    font-size: .7rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .08em;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: .5rem
}

.dark .sub-header {
    border-bottom-color: #1e2736
}

.sub-header:first-child {
    padding-top: 0
}