:root {
    --bg-start: #0f1a12;
    --bg-end:   #0a0f0a;
    --card-bg:  #0c120d;
    --input-bg: #0a0e0b;
    --border:   #c026d3;
    --accent:   #d946ef;
    --accent-dark: #b91cf5;
    --text:     #ffffff;
    --text-dim: #d1a8ff;
    --glow:     rgba(192, 38, 211, 0.25);
    --glow-strong: rgba(217, 70, 239, 0.4);
    
    /* Mobile optimizations */
    --touch-target: 44px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: radial-gradient(ellipse at bottom, var(--bg-start) 0%, var(--bg-end) 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 2rem;
    padding-top: 4rem;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 50, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    z-index: 10000;
    font-weight: 500;
    transition: opacity 0.4s ease;
    max-width: 90%;
    text-align: center;
    backdrop-filter: blur(8px);
    pointer-events: none;
}

.notification.hidden {
    opacity: 0;
    pointer-events: none;
}

.notification.success {
    background: rgba(0, 120, 60, 0.95);
}

.notification.error {
    background: rgba(180, 40, 40, 0.95);
}

/* Announcement Bar */
.announcement-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(44, 1, 44, 0.85);
    color: #ffffff;
    text-align: center;
    padding: 0.75rem;
    z-index: 1000;
    font-size: 1rem;
    border-bottom: 1px solid rgba(192, 38, 211, 0.3);
    backdrop-filter: blur(8px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stars Background - Optimized */
.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
}

.star {
    position: absolute;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0.75;
    animation: twinkle 4.5s infinite alternate;
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.5);
    will-change: transform, opacity;
}

@keyframes twinkle {
    0%   { opacity: 0.45; transform: scale(0.85); }
    100% { opacity: 0.95; transform: scale(1.15); }
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Header Titles */
.header-titles {
    text-align: center;
    margin-bottom: 2.5rem;
}

.header-titles h1 {
    font-size: 2.8rem;
    margin: 0;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent), #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Navbar + Menu Toggle */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0.5rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
}

.menu-toggle {
    padding: 0.6rem 0.9rem;
    border-radius: 0.5rem;
    color: #ffffff;
    cursor: pointer;
    border: none;
    font-size: 1.6rem;
    background: transparent;
    transition: all 0.25s ease;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-toggle:active {
    transform: scale(0.95);
}

.menu-toggle:hover {
    color: var(--accent);
    text-shadow: 0 0 12px var(--glow);
    transform: scale(1.1);
}

/* Sidebar - Optimized */
.sidebar {
    position: fixed;
    top: 3rem;
    left: -280px;
    width: 280px;
    height: calc(100% - 3rem);
    background: rgba(12, 18, 13, 0.98);
    backdrop-filter: blur(20px);
    padding: 1rem 0;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    border-right: 1px solid rgba(192, 38, 211, 0.3);
    box-shadow: 0 0 25px rgba(192, 38, 211, 0.12);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar.open {
    left: 0;
}

.sidebar a {
    color: rgba(255,255,255,0.94);
    padding: 0.9rem 1.2rem;
    text-decoration: none;
    display: block;
    transition: all 0.2s;
    background: rgba(192, 38, 211, 0.02);
    margin: 0 0.6rem 0.2rem;
    border-radius: 8px;
    min-height: var(--touch-target);
}

.sidebar a:active {
    background: rgba(192, 38, 211, 0.2);
    transform: scale(0.98);
}

/* Sidebar Header */
.sidebar-header {
    position: relative;
    padding: 0.8rem 1rem;
    font-weight: bold;
    color: var(--accent);
    border-bottom: 1px solid rgba(192,38,211,0.3);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-header span {
    flex: 1;
    font-size: 1.1rem;
}

/* Close Button - Optimized */
.sidebar-close {
    background: rgba(192, 38, 211, 0.2);
    border: 1px solid rgba(192, 38, 211, 0.5);
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    min-width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
}

.sidebar-close:active {
    transform: scale(0.95);
    background: rgba(192, 38, 211, 0.4);
}

.sidebar-close:hover {
    background: rgba(192, 38, 211, 0.4);
    color: var(--accent);
    transform: scale(1.05);
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

/* Buttons - Touch Optimized */
button {
    padding: 0.8rem 1.8rem;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 180px;
    min-height: var(--touch-target);
    position: relative;
    overflow: hidden;
}

button:active {
    transform: scale(0.97);
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

button:active::after {
    width: 100%;
    height: 100%;
}

/* Button Colors */
.bg-blue-600 { background: #2563eb; }
.bg-blue-600:hover { background: #1d4ed8; }
.bg-blue-600:active { background: #1e40af; }

.bg-purple-600 { background: #7c3aed; }
.bg-purple-600:hover { background: #6d28d9; }
.bg-purple-600:active { background: #5b21b6; }

.bg-red-600 { background: #dc2626; }
.bg-red-600:hover { background: #b91c1c; }
.bg-red-600:active { background: #991b1b; }

/* Table Card */
.table-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    box-shadow: 0 8px 25px rgba(0,0,0,0.5), 0 0 20px var(--glow);
    backdrop-filter: blur(6px);
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th, td {
    padding: 1.1rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(192, 38, 211, 0.15);
}

th {
    background: rgba(17, 24, 39, 0.7);
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    font-size: 0.9rem;
}

td {
    color: var(--text-dim);
}

.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 1.8rem;
}

/* ============================================ */
/* MOBILE OPTIMIZATIONS */
/* ============================================ */

/* Tablet and Mobile */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
        left: -260px;
    }
    
    .sidebar-close {
        font-size: 1.8rem;
        padding: 0.4rem 0.8rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
        padding-top: 3.5rem;
    }
    
    .announcement-bar {
        font-size: 0.85rem;
        padding: 0.6rem;
        white-space: normal;
        word-break: break-word;
    }
    
    .header-titles h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }
    
    button {
        width: 100%;
        max-width: 280px;
        min-width: 200px;
        padding: 0.7rem 1.2rem;
        font-size: 0.95rem;
    }
    
    .table-card {
        padding: 1rem;
        overflow-x: auto;
    }
    
    table {
        font-size: 0.85rem;
        min-width: 500px;
    }
    
    th, td {
        padding: 0.8rem 0.6rem;
    }
    
    .navbar {
        margin-bottom: 1.5rem;
        flex-direction: column;
    }
    
    .nav-left, .nav-right {
        width: 100%;
        justify-content: center;
    }
    
    .sidebar {
        width: 260px;
        left: -260px;
        top: 2.8rem;
        height: calc(100% - 2.8rem);
    }
    
    .sidebar a {
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
    }
    
    .sidebar-header span {
        font-size: 1rem;
    }
    
    .sidebar-close {
        font-size: 1.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    body {
        padding: 0.75rem;
        padding-top: 3rem;
    }
    
    .announcement-bar {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
    
    .header-titles {
        margin-bottom: 1.5rem;
    }
    
    .header-titles h1 {
        font-size: 1.6rem;
    }
    
    button {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        min-width: 180px;
        max-width: 240px;
    }
    
    .table-card {
        padding: 0.75rem;
        border-radius: 0.5rem;
    }
    
    table {
        font-size: 0.75rem;
        min-width: 400px;
    }
    
    th, td {
        padding: 0.6rem 0.4rem;
    }
    
    th {
        font-size: 0.75rem;
    }
    
    .sidebar {
        width: 240px;
        left: -240px;
    }
    
    .sidebar a {
        padding: 0.7rem 0.9rem;
        font-size: 0.9rem;
    }
    
    .sidebar-header {
        padding: 0.6rem 0.8rem;
    }
    
    .sidebar-header span {
        font-size: 0.9rem;
    }
    
    .sidebar-close {
        font-size: 1.6rem;
        padding: 0.3rem 0.7rem;
    }
    
    .notification {
        font-size: 0.85rem;
        padding: 8px 16px;
        top: 60px;
    }
}

/* Landscape Mode */
@media (max-width: 896px) and (orientation: landscape) {
    body {
        padding: 0.5rem;
        padding-top: 3rem;
    }
    
    .header-titles h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .controls {
        margin-bottom: 1rem;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    button {
        width: auto;
        min-width: 140px;
        padding: 0.5rem 1rem;
    }
    
    .table-card {
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .sidebar {
        top: 2.5rem;
        height: calc(100% - 2.5rem);
    }
}

/* Large Tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .header-titles h1 {
        font-size: 2.4rem;
    }
    
    button {
        min-width: 160px;
        padding: 0.7rem 1.5rem;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.9rem 0.8rem;
    }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .star {
        box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.5);
    }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .star {
        animation: none;
        opacity: 0.5;
    }
    
    button:active {
        transform: none;
    }
    
    .sidebar {
        transition: none;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    button:hover {
        transform: none;
    }
    
    .menu-toggle:hover {
        transform: none;
    }
    
    .sidebar a:hover {
        background: rgba(192, 38, 211, 0.08);
    }
    
    .sidebar-close:hover {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .announcement-bar,
    .sidebar,
    .menu-toggle,
    .controls,
    .stars,
    .notification {
        display: none !important;
    }
    
    body {
        padding: 0;
        background: white;
        color: black;
    }
    
    .table-card {
        box-shadow: none;
        border: 1px solid #ccc;
        background: white;
    }
    
    th, td {
        color: black;
        border-color: #ccc;
    }
    
    th {
        background: #f0f0f0;
    }
}