/* Northern Platform — Design System & Global Styles */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

/* Custom Properties */
:root {
    --color-accent: #4f8cff;
    --color-accent-hover: #3a7bff;
    --color-accent-muted: rgba(79, 140, 255, 0.15);
    --color-surface: #0a0a0a;
    --color-surface-raised: #111111;
    --color-surface-overlay: #1a1a1a;
    --color-border: rgba(255, 255, 255, 0.08);
    --color-border-strong: rgba(255, 255, 255, 0.15);
    --color-text-primary: #ffffff;
    --color-text-secondary: #a0a0a0;
    --color-text-muted: #666666;
    --color-success: #22c55e;
    --color-success-muted: rgba(34, 197, 94, 0.15);
    --color-warning: #f59e0b;
    --color-warning-muted: rgba(245, 158, 11, 0.15);
    --color-danger: #ef4444;
    --color-danger-muted: rgba(239, 68, 68, 0.15);

    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-display: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;

    --sidebar-width: 260px;
    --topbar-height: 60px;
    --transition: 150ms ease;
}

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

html {
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-primary);
    background: var(--color-surface);
    height: 100%;
    overflow: hidden;
}

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

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

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
}

img, svg {
    display: block;
    max-width: 100%;
}

/* ============================================
   APP SHELL
   ============================================ */

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-surface-raised);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition);
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.sidebar-brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--color-text-primary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 8px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

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

.nav-link.active {
    color: var(--color-accent);
    background: var(--color-accent-muted);
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-link.active svg {
    opacity: 1;
}

.nav-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    background: var(--color-accent-muted);
    color: var(--color-accent);
}

/* Context sidebar back link */
.context-back {
    color: var(--color-text-muted) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 6px 12px !important;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--color-border);
}
.context-back:hover {
    color: var(--color-text-primary) !important;
    background: none !important;
}
.context-back svg {
    width: 14px !important;
    height: 14px !important;
}

#contextNav .nav-section-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Workspace switcher */
.workspace-switcher {
    padding: 12px;
    border-top: 1px solid var(--color-border);
}

.workspace-current {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--color-surface-overlay);
    cursor: pointer;
    transition: background var(--transition);
}

.workspace-current:hover {
    background: var(--color-border-strong);
}

.workspace-avatar {
    width: 28px;
    height: 28px;
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.workspace-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.workspace-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 12px;
    right: 12px;
    background: var(--color-surface-overlay);
    border: 1px solid var(--color-border);
    margin-bottom: 4px;
    z-index: 200;
    max-height: 240px;
    overflow-y: auto;
}

.workspace-dropdown.open {
    display: block;
}

.workspace-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background var(--transition);
}

.workspace-item:hover {
    background: var(--color-surface-raised);
}

/* Main area */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Topbar */
#topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.topbar-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    padding: 4px;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

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

.topbar-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition);
}

.topbar-search input::placeholder {
    color: var(--color-text-muted);
}

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

.topbar-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 8px;
    transition: color var(--transition);
}

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

.topbar-btn svg {
    width: 20px;
    height: 20px;
}

.topbar-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--color-danger);
}

.user-menu {
    position: relative;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    transition: background var(--transition);
}

.user-trigger:hover {
    background: var(--color-surface-raised);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--color-accent);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent);
    object-fit: cover;
}

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

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: var(--color-surface-overlay);
    border: 1px solid var(--color-border);
    margin-top: 4px;
    z-index: 200;
}

.user-dropdown.open {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--color-text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.dropdown-item:hover {
    color: var(--color-text-primary);
    background: var(--color-surface-raised);
}

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

.dropdown-divider {
    border-top: 1px solid var(--color-border);
    margin: 4px 0;
}

.dropdown-item.danger {
    color: var(--color-danger);
}

/* Content area */
#content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    transition: opacity 0.15s ease;
}

/* ============================================
   AUTH LAYOUTS
   ============================================ */

.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-surface);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-logo svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.auth-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

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

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition);
}

.form-input:focus {
    border-color: var(--color-accent);
}

.form-input.error {
    border-color: var(--color-danger);
}

.form-error {
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 4px;
}

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

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-sans);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

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

.btn-secondary {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    color: var(--color-text-primary);
    border-color: var(--color-border-strong);
    background: var(--color-surface-overlay);
}

.btn-secondary.active {
    color: var(--color-text-primary);
    border-color: var(--color-accent);
    background: var(--color-surface-overlay);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    padding: 8px 12px;
}

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

.btn-outline {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.btn-outline:hover {
    border-color: var(--color-border-strong);
    color: var(--color-text-primary);
}

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

.btn-lg {
    padding: 12px 28px;
    font-size: 15px;
}

.btn-block {
    width: 100%;
}

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

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    padding: 24px;
}

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

.card-header[data-collapse] {
    cursor: pointer;
    user-select: none;
}

.card-header[data-collapse] .collapse-icon {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.card-header[data-collapse].collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapse-chevron.rotated {
    transform: rotate(180deg);
}

.card-header[data-collapse].collapsed + .card-body,
.card-header[data-collapse].collapsed + .table-wrap,
.card-header[data-collapse].collapsed ~ *:not(.card-header) {
    display: none;
}

.card-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}

/* ============================================
   PAGE LAYOUTS
   ============================================ */

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* Stats bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.accent {
    background: var(--color-accent-muted);
    color: var(--color-accent);
}

.stat-icon.success {
    background: var(--color-success-muted);
    color: var(--color-success);
}

.stat-icon.warning {
    background: var(--color-warning-muted);
    color: var(--color-warning);
}

.stat-icon.danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--color-danger);
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
}

.stat-label {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Product cards grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.product-card {
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: border-color var(--transition);
}

.product-card:hover {
    border-color: var(--color-border-strong);
}

.product-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.product-icon {
    width: 44px;
    height: 44px;
    background: var(--color-accent-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
}

.product-icon svg {
    width: 22px;
    height: 22px;
}

.product-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.product-badge.active {
    background: var(--color-success-muted);
    color: var(--color-success);
}

.product-badge.free {
    background: var(--color-surface-overlay);
    color: var(--color-text-muted);
}

.product-badge.coming-soon {
    background: var(--color-warning-muted);
    color: var(--color-warning);
}

.product-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}

.product-desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 20px;
    flex: 1;
}

.product-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   SETTINGS LAYOUT
   ============================================ */

.settings-layout {
    display: flex;
    gap: 32px;
    max-width: 960px;
}

.settings-nav {
    width: 200px;
    flex-shrink: 0;
}

.settings-nav-link {
    display: block;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all var(--transition);
    margin-bottom: 2px;
}

.settings-nav-link:hover {
    color: var(--color-text-primary);
    background: var(--color-surface-overlay);
}

.settings-nav-link.active {
    color: var(--color-accent);
    background: var(--color-accent-muted);
}

.settings-content {
    flex: 1;
    min-width: 0;
}

/* Avatar upload */
.avatar-upload-area {
    display: flex;
    align-items: center;
    gap: 20px;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-surface-overlay);
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initials {
    font-size: 28px;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-family: var(--font-display);
}

.avatar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.avatar-actions .form-hint {
    width: 100%;
    margin-top: 0;
}

/* Connected accounts */
.connected-accounts {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.connected-account {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.connected-account:last-child {
    border-bottom: none;
}

.connected-account-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.connected-account-icon {
    flex-shrink: 0;
}

.connected-account-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.connected-account-status {
    font-size: 12px;
    color: var(--color-text-muted);
}

.connected-account-status.connected {
    color: var(--color-success);
}

/* Toggle switches */
.toggle-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    gap: 16px;
}

.toggle-item:last-child {
    border-bottom: none;
}

.toggle-info {
    flex: 1;
}

.toggle-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.toggle-desc {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.toggle-item input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 40px;
    height: 22px;
    background: var(--color-surface-overlay);
    border: 1px solid var(--color-border);
    border-radius: 11px;
    position: relative;
    transition: all var(--transition);
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    width: 16px;
    height: 16px;
    background: var(--color-text-muted);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all var(--transition);
}

.toggle-item input:checked + .toggle-switch {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.toggle-item input:checked + .toggle-switch::after {
    background: #fff;
    left: 20px;
}

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

/* Sessions */
.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.session-item:last-child {
    border-bottom: none;
}

.session-device {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.session-meta {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.session-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-success);
    border: 1px solid var(--color-success);
    padding: 3px 8px;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Danger card */
.card-danger {
    border-color: rgba(239, 68, 68, 0.2);
}

.card-danger .card-title {
    color: var(--color-danger);
}

/* Modal (old – used only by privacy delete modal) */
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ============================================
   TABLES
   ============================================ */

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

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

th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
}

td {
    padding: 12px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

tr:hover td {
    background: var(--color-surface-overlay);
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: var(--color-success-muted);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-muted);
    color: var(--color-warning);
}

.badge-danger {
    background: var(--color-danger-muted);
    color: var(--color-danger);
}

.badge-neutral {
    background: var(--color-surface-overlay);
    color: var(--color-text-muted);
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

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

.modal {
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition);
}

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

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
}

/* Pricing tiers */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.pricing-tier {
    border: 1px solid var(--color-border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: border-color var(--transition);
}

.pricing-tier:hover {
    border-color: var(--color-border-strong);
}

.pricing-tier.recommended {
    border-color: var(--color-accent);
}

.pricing-tier-name {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.pricing-price {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 4px;
}

.pricing-price span {
    font-size: 14px;
    font-weight: 400;
    color: var(--color-text-secondary);
}

.pricing-period {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

.pricing-features {
    list-style: none;
    margin-bottom: 24px;
    flex: 1;
}

.pricing-features li {
    font-size: 13px;
    color: var(--color-text-secondary);
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pricing-features li svg {
    width: 14px;
    height: 14px;
    color: var(--color-success);
    flex-shrink: 0;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 12px 16px;
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.alert-success {
    background: var(--color-success-muted);
    color: var(--color-success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-danger {
    background: var(--color-danger-muted);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: var(--color-warning-muted);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */

.notification-list {
    display: flex;
    flex-direction: column;
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition);
}

.notification-item:hover {
    background: var(--color-surface-overlay);
}

.notification-item.unread {
    background: var(--color-accent-muted);
}

.notification-dot {
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    flex-shrink: 0;
    margin-top: 6px;
}

.notification-item:not(.unread) .notification-dot {
    background: transparent;
}

.notification-body {
    flex: 1;
}

.notification-text {
    font-size: 13px;
    color: var(--color-text-primary);
    margin-bottom: 4px;
}

.notification-time {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* ============================================
   LOADING
   ============================================ */

.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    animation: spin 0.6s linear infinite;
}

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

@keyframes globalTimerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.spin {
    animation: spin 1s linear infinite;
}

.page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 600;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--color-surface-overlay);
    border: 1px solid var(--color-border);
    padding: 12px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 200ms ease;
    min-width: 280px;
}

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

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

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.empty-state > svg {
    width: 48px;
    height: 48px;
    color: var(--color-danger);
    margin: 0 auto 16px;
}

.empty-state-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

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

    .mobile-menu-btn {
        display: block;
    }

    #content {
        padding: 20px;
    }

    .settings-layout {
        flex-direction: column;
    }

    .settings-nav {
        width: 100%;
    }

    .pricing-grid {
        grid-template-columns: 1fr;
    }

    .product-grid {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 28px 20px;
    }

    #content {
        padding: 16px;
    }

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

/* ============================================
   TEAM — PRODUCT ACCESS
   ============================================ */

.team-member-row {
    border-bottom: 1px solid var(--color-border);
    padding: 14px 0;
}

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

.team-member-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.team-member-products {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.product-access-section {
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
}

.product-access-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-access-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
}

.product-access-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.product-access-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
    cursor: pointer;
}

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

.form-input-sm {
    padding: 6px 10px;
    font-size: 12px;
    height: 32px;
}

.badge-subtle {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(79, 140, 255, 0.1);
    color: var(--color-accent);
    white-space: nowrap;
}

.badge-accent {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(79, 140, 255, 0.15);
    color: var(--color-accent);
}

.toggle-products-btn {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .team-member-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .product-access-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}
