* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Segoe UI", sans-serif;
}

:root {
    color-scheme: light;
    --bg-page: #eef2ff;
    --bg-surface: rgba(255, 255, 255, 0.78);
    --bg-elevated: #ffffff;
    --bg-muted: #f5f7ff;
    --bg-accent: linear-gradient(135deg, #6c5ce7, #8b80f9);
    --border-color: rgba(126, 98, 231, 0.14);
    --border-strong: rgba(126, 98, 231, 0.26);
    --text-primary: #1f2940;
    --text-secondary: #667085;
    --text-muted: #8c95a8;
    --accent: #5e4fd7;
    --accent-strong: #4a3db7;
    --accent-soft: rgba(108, 92, 231, 0.12);
    --shadow-soft: 0 18px 44px rgba(77, 63, 176, 0.12);
    --shadow-card: 0 12px 28px rgba(77, 63, 176, 0.1);
    --danger-bg: #ffe8e8;
    --danger-text: #b42318;
    --warning-bg: #fff4d6;
    --warning-text: #b54708;
    --success-bg: #e8fff4;
    --success-text: #027a48;
}

body[data-theme="dark"] {
    color-scheme: dark;
    --bg-page: #09101d;
    --bg-surface: rgba(14, 23, 40, 0.88);
    --bg-elevated: #101a2d;
    --bg-muted: #162238;
    --bg-accent: linear-gradient(135deg, #6f86ff, #4fbcff);
    --border-color: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(129, 140, 248, 0.42);
    --text-primary: #eef4ff;
    --text-secondary: #c4cfde;
    --text-muted: #93a2bb;
    --accent: #8ea2ff;
    --accent-strong: #bfd2ff;
    --accent-soft: rgba(113, 134, 255, 0.18);
    --shadow-soft: 0 24px 54px rgba(0, 0, 0, 0.36);
    --shadow-card: 0 14px 34px rgba(0, 0, 0, 0.24);
    --danger-bg: rgba(180, 35, 24, 0.18);
    --danger-text: #ffb4ab;
    --warning-bg: rgba(181, 71, 8, 0.18);
    --warning-text: #ffd28d;
    --success-bg: rgba(2, 122, 72, 0.18);
    --success-text: #94f0c4;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(108, 92, 231, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 24%),
        var(--bg-page);
    color: var(--text-primary);
    transition: background 0.25s ease, color 0.25s ease;
}

body.modal-open {
    overflow: hidden;
}

.container {
    display: flex;
    min-height: 100vh;
}

.page-view[hidden] {
    display: none !important;
}

.sidebar {
    width: 260px;
    padding: 28px 20px;
    background: rgba(241, 237, 255, 0.82);
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

body[data-theme="dark"] .sidebar {
    background: rgba(10, 18, 33, 0.88);
}

.logo {
    margin-bottom: 28px;
    color: var(--accent);
    font-size: 1.7rem;
    letter-spacing: -0.03em;
}

.nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav li {
    border-radius: 14px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.nav li:hover,
.nav li.active {
    background: var(--accent-soft);
}

.nav li a,
.nav-button {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    text-decoration: none;
    font-size: 0.96rem;
    font-weight: 600;
    cursor: pointer;
}

.nav li:hover a,
.nav li.active a,
.nav li.active .nav-button,
.nav-button:hover {
    color: var(--accent);
}

.sidebar-utility-separator {
    border: none;
    border-top: 1px solid #c9bfff;
    margin: 12px 0 8px;
}

.nav li.sidebar-signout-item,
.nav li.sidebar-signout-item:hover,
.nav li.sidebar-signout-item.active {
    background: transparent;
}

.sidebar-signout-button {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--text-muted);
    text-align: left;
    font-size: 0.96rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

.sidebar-signout-button:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.restricted-preview-link::after {
    content: " Locked";
    font-size: 0.74rem;
    color: #8f7aea;
}

.main {
    flex: 1;
    padding: 28px 34px 36px;
    overflow-y: auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.topbar input,
.settings-search input,
.settings-select {
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.topbar input {
    width: min(560px, 100%);
    padding: 14px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow-card);
}

.topbar input:focus,
.settings-search input:focus,
.settings-select:focus {
    outline: none;
    border-color: var(--border-strong);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.profile {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-card);
}

.profile-button {
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.plans-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(31, 26, 68, 0.62);
    z-index: 1000;
}

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

.plans-dialog {
    width: min(960px, 100%);
    background: var(--bg-elevated);
    border-radius: 24px;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(45, 27, 105, 0.24);
}

.plans-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.plans-header h2 {
    margin: 0 0 6px;
    color: var(--text-primary);
}

.plans-header p {
    margin: 0;
    color: var(--text-secondary);
}

.plans-close {
    border: none;
    background: #f3efff;
    color: var(--accent);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

.danger-button {
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    background: #d63031;
    color: #fff;
}

.danger-button.ghost {
    background: #fceaea;
    color: #b42318;
}

.danger-note {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 18px;
}

.danger-warning {
    padding: 14px 16px;
    border-radius: 14px;
    background: #fff2f2;
    color: #b42318;
    font-weight: 600;
    margin-bottom: 20px;
}

.profile-avatar-small {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--bg-accent);
    background-size: cover;
    background-position: center;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
}

.page-header,
.settings-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-header h1,
.settings-page-header h1 {
    font-size: clamp(1.8rem, 2vw, 2.35rem);
    letter-spacing: -0.03em;
}

.page-header-date,
.settings-page-header p,
.settings-card-head p,
.settings-tab-copy,
.settings-footer-note,
.card-meta,
.activity li,
.setting-row p,
.settings-info-item span,
.settings-kicker,
.quick-link-label {
    color: var(--text-secondary);
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.card,
.chart-box,
.activity,
.alerts,
.settings-section-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.card {
    padding: 22px;
}

.card h4,
.chart-box h3,
.activity h3,
.alerts h3,
.settings-card-head h3,
.setting-row h4 {
    color: var(--text-primary);
}

.card h4 {
    margin-bottom: 12px;
    font-size: 0.95rem;
    font-weight: 600;
}

.card h2 {
    color: var(--accent);
    font-size: 2rem;
    margin-bottom: 6px;
}

.card-meta {
    font-size: 0.82rem;
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.quick-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px;
    border-radius: 18px;
    text-decoration: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.quick-link:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
}

.quick-link-title {
    color: var(--text-primary);
    font-size: 1.18rem;
    font-weight: 700;
}

.quick-link-label {
    font-size: 0.82rem;
    font-weight: 600;
}

.quick-link-primary {
    background: var(--bg-accent);
}

.quick-link-primary .quick-link-title,
.quick-link-primary .quick-link-label {
    color: #fff;
}

.charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.chart-box,
.activity,
.alerts {
    padding: 22px;
}

.chart-box-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.chart-meta {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.chart-status {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.chart-status.is-empty {
    background: rgba(9, 132, 227, 0.08);
    color: #0984e3;
}

.chart-status.is-error {
    background: rgba(214, 48, 49, 0.1);
    color: #b42318;
}

.chart-box canvas {
    margin-top: 18px;
    max-height: 320px;
}

.activity {
    margin-bottom: 20px;
}

.activity ul {
    list-style: none;
    margin-top: 14px;
}

.activity li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.activity li:last-child {
    border-bottom: none;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-top: 12px;
    font-weight: 600;
}

.danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.settings-view {
    display: grid;
    gap: 22px;
}

.settings-eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    margin-bottom: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.settings-search {
    min-width: min(320px, 100%);
    display: grid;
    gap: 8px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.settings-search input {
    padding: 14px 16px;
    border-radius: 16px;
}

.settings-layout {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.settings-sidebar {
    display: grid;
    gap: 10px;
    padding: 18px;
    border-radius: 22px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    position: sticky;
    top: 16px;
}

.settings-tab {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 14px 15px;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.settings-tab:hover,
.settings-tab.active {
    background: var(--accent-soft);
    border-color: var(--border-strong);
}

.settings-tab-title {
    color: var(--text-primary);
    font-weight: 700;
}

.settings-panels {
    display: grid;
}

.settings-panel {
    display: none;
    gap: 18px;
}

.settings-panel.active {
    display: grid;
}

.settings-section-card {
    padding: 22px;
}

.settings-profile-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.settings-profile-summary {
    display: flex;
    align-items: center;
    gap: 16px;
}

.settings-avatar {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: var(--bg-accent);
    background-size: cover;
    background-position: center;
    color: #fff;
    font-size: 1.3rem;
    font-weight: 800;
    box-shadow: var(--shadow-soft);
}

.settings-profile-summary h2 {
    font-size: 1.55rem;
    margin-bottom: 4px;
}

.settings-profile-summary p:last-child {
    color: var(--text-secondary);
}

.settings-profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.settings-badge {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.85rem;
}

.settings-badge-muted {
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.settings-card-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.settings-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.settings-info-item {
    display: grid;
    gap: 8px;
    padding: 16px;
    border-radius: 18px;
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
}

.settings-info-item strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.theme-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.theme-choice {
    display: grid;
    gap: 12px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--border-color);
    background: var(--bg-muted);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.theme-choice:hover,
.theme-choice.active {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    background: var(--accent-soft);
}

.theme-choice > span:last-child {
    color: var(--text-secondary);
    line-height: 1.6;
}

.theme-choice-preview {
    width: 100%;
    height: 110px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: block;
}

.theme-choice-preview-light {
    background:
        linear-gradient(180deg, #ffffff, #edf2ff),
        linear-gradient(135deg, #6c5ce7, #8b80f9);
}

.theme-choice-preview-dark {
    background:
        linear-gradient(180deg, #0c1528, #15223d),
        linear-gradient(135deg, #6f86ff, #4fbcff);
}

.settings-stack {
    display: grid;
    gap: 14px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-radius: 18px;
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
}

.setting-row p {
    margin-top: 6px;
    line-height: 1.6;
}

.toggle-switch-row {
    position: relative;
    width: 56px;
    height: 32px;
    flex: 0 0 auto;
}

.toggle-switch-row input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider-ui {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(152, 162, 179, 0.4);
    cursor: pointer;
    transition: background 0.2s ease;
}

.toggle-slider-ui::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    top: 4px;
    left: 4px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease;
}

.toggle-switch-row input:checked + .toggle-slider-ui {
    background: var(--accent);
}

.toggle-switch-row input:checked + .toggle-slider-ui::before {
    transform: translateX(24px);
}

.settings-select {
    min-width: 180px;
    padding: 12px 14px;
    border-radius: 14px;
}

.settings-action-row {
    margin-top: 18px;
}

.settings-inline-action,
.settings-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    text-decoration: none;
    font-weight: 700;
}

.settings-inline-action {
    padding: 11px 14px;
    background: var(--accent-soft);
    color: var(--accent);
}

.settings-action-button {
    min-width: 136px;
    padding: 12px 16px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

.settings-action-danger {
    background: #c0392b;
}

.danger-row {
    border-color: rgba(192, 57, 43, 0.18);
}

.settings-footer-note {
    font-size: 0.92rem;
}

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

    .settings-sidebar {
        position: static;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 960px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .main {
        padding: 22px 18px 28px;
    }

    .topbar,
    .page-header,
    .chart-box-header,
    .settings-page-header,
    .settings-profile-card,
    .setting-row {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar input,
    .settings-search,
    .settings-search input {
        width: 100%;
        min-width: 100%;
    }

    .charts,
    .theme-choice-grid,
    .settings-info-grid {
        grid-template-columns: 1fr;
    }

    .settings-profile-badges {
        justify-content: flex-start;
    }

    .settings-select,
    .settings-action-button {
        width: 100%;
    }
}
