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

:root {
    /* Dark Norse palette */
    --bg-deep: #0a0a0f;
    --bg-dark: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --bg-elevated: #252532;

    /* Accent colors - aurora borealis inspired */
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-tertiary: #06b6d4;
    --accent-gold: #f59e0b;
    --accent-ember: #ef4444;

    /* Gradients */
    --gradient-aurora: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
    --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-ember: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders & effects */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(99, 102, 241, 0.3);
    --glow-primary: 0 0 20px rgba(99, 102, 241, 0.3);
    --glow-gold: 0 0 20px rgba(245, 158, 11, 0.3);

    /* Priority colors */
    --priority-1: #22c55e;
    --priority-2: #06b6d4;
    --priority-3: #f59e0b;
    --priority-4: #f97316;
    --priority-5: #ef4444;

    /* Sidebar */
    --sidebar-width: 280px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   APP LAYOUT - Sidebar + Main
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow: hidden;
}

.sidebar-header {
    padding: 28px 24px;
    border-bottom: 1px solid var(--border-subtle);
    text-align: center;
}

.sidebar-header h1 {
    font-size: 2em;
    font-weight: 800;
    background: var(--gradient-aurora);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.sidebar-header h1 .runes {
    font-size: 0.5em;
    opacity: 0.6;
    margin-left: 8px;
    letter-spacing: 0.1em;
    -webkit-text-fill-color: var(--accent-gold);
}

.sidebar-header .subtitle {
    font-size: 0.85em;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.nav-section-title {
    padding: 0 24px 12px;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

.topic-list {
    list-style: none;
}

.topic-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    gap: 12px;
}

.topic-item:hover {
    background: var(--bg-card-hover);
    border-left-color: var(--accent-primary);
}

.topic-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-left-color: var(--accent-primary);
}

.topic-item.active .topic-name {
    color: var(--text-primary);
    font-weight: 600;
}

.topic-item.active .topic-icon {
    color: var(--accent-primary);
}

.topic-icon {
    font-size: 1.1em;
    color: var(--text-muted);
    transition: color 0.2s ease;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.topic-name {
    flex: 1;
    font-size: 0.95em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.topic-count {
    background: var(--bg-elevated);
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    min-width: 28px;
    text-align: center;
    transition: all 0.2s ease;
}

.topic-item:hover .topic-count {
    background: var(--accent-primary);
    color: white;
}

.topic-item.active .topic-count {
    background: var(--accent-primary);
    color: white;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

.sidebar-link.logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-ember);
}

.link-icon {
    font-size: 1em;
    width: 20px;
    text-align: center;
}

/* ============================================
   MAIN CONTENT WRAPPER
   ============================================ */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Content Header */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-title h2 {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-primary);
}

.header-count {
    font-size: 0.85em;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Content Main */
.content-main {
    flex: 1;
    padding: 24px 32px;
}

/* Content Footer */
.content-footer {
    padding: 20px 32px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.85em;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-card);
}

.live-indicator {
    width: 8px;
    height: 8px;
    background: var(--priority-1);
    border-radius: 50%;
    animation: pulse-live 2s ease-in-out infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-icon {
    padding: 10px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-primary {
    background: var(--gradient-aurora);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.btn-danger {
    background: var(--gradient-ember);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 6px 25px rgba(239, 68, 68, 0.4);
}

.btn-danger-outline {
    background: transparent;
    color: var(--accent-ember);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger-outline:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-ember);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.notifications {
    min-height: 200px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    color: var(--text-muted);
    font-size: 1.1em;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    padding: 40px;
}

.empty-state::before {
    content: '𐌾';
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state p {
    max-width: 300px;
}

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

/* ============================================
   NOTIFICATION CARDS
   ============================================ */
.notification-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    height: 180px;
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.notification-card:last-child {
    margin-bottom: 0;
}

/* Priority indicator stripe */
.notification-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--priority-3);
    transition: width 0.2s ease;
}

.notification-card[data-priority="1"]::before { background: var(--priority-1); }
.notification-card[data-priority="2"]::before { background: var(--priority-2); }
.notification-card[data-priority="3"]::before { background: var(--priority-3); }
.notification-card[data-priority="4"]::before { background: var(--priority-4); }
.notification-card[data-priority="5"]::before {
    background: var(--priority-5);
    animation: pulse-danger 2s ease-in-out infinite;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.notification-card:hover {
    border-color: var(--accent-primary);
    transform: translateX(4px);
    box-shadow: -4px 0 20px rgba(99, 102, 241, 0.1);
}

.notification-card:hover::before {
    width: 6px;
}

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

.notification-header h3 {
    flex: 1;
    font-size: 1.15em;
    font-weight: 600;
    margin: 0 0 8px 0;
    min-width: 0;
    word-break: break-word;
    width: 100%;
    color: var(--text-primary);
}

.badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.notification-header .priority {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.priority-1 { background: rgba(34, 197, 94, 0.2); color: var(--priority-1); }
.priority-2 { background: rgba(6, 182, 212, 0.2); color: var(--priority-2); }
.priority-3 { background: rgba(245, 158, 11, 0.2); color: var(--priority-3); }
.priority-4 { background: rgba(249, 115, 22, 0.2); color: var(--priority-4); }
.priority-5 { background: rgba(239, 68, 68, 0.2); color: var(--priority-5); }

.topic-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    white-space: nowrap;
}

.topic-badge::before {
    content: '#';
    opacity: 0.7;
}

.device-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-gold);
    white-space: nowrap;
}

.device-badge::before {
    content: '⚡';
    font-size: 0.9em;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid transparent;
    color: var(--accent-ember);
    font-size: 1.3em;
    cursor: pointer;
    padding: 6px 10px;
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
    border-radius: 8px;
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--accent-ember);
    transform: scale(1.1);
}

.notification-message {
    margin: 8px 0;
    color: var(--text-secondary);
    word-break: break-word;
    line-height: 1.6;
    font-size: 0.95em;
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.read-more {
    color: var(--accent-primary);
    font-size: 0.85em;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s ease;
    margin-top: auto;
}

.read-more:hover {
    color: var(--accent-secondary);
}

.notification-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
}

.notification-time {
    font-size: 0.85em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.notification-time::before {
    content: '';
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
    opacity: 0.7;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    margin: 10% auto;
    padding: 35px;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 1.5em;
    color: var(--text-primary);
}

.modal-content p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.modal-content input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    font-size: 1em;
    background: var(--bg-elevated);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-buttons .btn {
    flex: 1;
}

/* Notification Detail Modal */
.notification-modal .modal-content {
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.notification-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-subtle);
}

.notification-modal .modal-header h2 {
    margin: 0;
    font-size: 1.4em;
    color: var(--text-primary);
    flex: 1;
    padding-right: 15px;
}

.notification-modal .modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8em;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

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

.notification-modal .modal-badges {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.notification-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1em;
    white-space: pre-wrap;
    word-break: break-word;
}

.notification-modal .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-subtle);
}

.notification-modal .modal-time {
    color: var(--text-muted);
    font-size: 0.9em;
}

/* ============================================
   RESPONSIVE - Mobile
   ============================================ */
@media (max-width: 900px) {
    :root {
        --sidebar-width: 240px;
    }
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        width: 280px;
        transition: left 0.3s ease;
        z-index: 200;
    }

    .sidebar.open {
        left: 0;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .content-header {
        padding: 16px 20px;
    }

    .content-header::before {
        content: '☰';
        font-size: 1.5em;
        cursor: pointer;
        margin-right: 16px;
        color: var(--text-secondary);
    }

    .content-main {
        padding: 16px 20px;
    }

    .content-footer {
        padding: 16px 20px;
    }

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

    .notification-header h3 {
        width: 100%;
    }

    .badges {
        width: 100%;
    }

    .btn-delete {
        position: absolute;
        right: 15px;
        top: 15px;
    }

    .notification-card {
        position: relative;
        padding-right: 50px;
    }

    /* Mobile overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ============================================
   SELECTION STYLING
   ============================================ */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}
