* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.2s, border-color 0.3s;
}

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --border-color: #e2e8f0;
    --header-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --section-header: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    --code-bg: #1e293b;
    --code-text: #fbbf24;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
}

body.dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --header-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --section-header: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
    --code-bg: #0f0f23;
    --code-text: #facc15;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 32px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(circle at 20% 40%, rgba(59,130,246,0.05) 0%, transparent 50%);
}
body.dark .animated-bg {
    background: radial-gradient(circle at 20% 40%, rgba(59,130,246,0.1) 0%, transparent 50%);
}

.theme-toggle {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 60px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
}

.header {
    background: var(--header-gradient);
    color: white;
    padding: 50px 40px;
    text-align: center;
    position: relative;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    background: var(--card-bg);
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 20px;
}

.stat {
    text-align: center;
    flex: 1;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #3b82f6;
}

.search-container {
    padding: 20px 40px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

#searchInput {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 50px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.filter-btn {
    padding: 6px 14px;
    border-radius: 30px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
}

.filter-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Table of Contents */
.toc {
    background: var(--card-bg);
    margin: 20px 40px;
    padding: 20px 30px;
    border-radius: 24px;
    box-shadow: var(--shadow);
}
.toc h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}
.toc ul {
    columns: 2;
    column-gap: 40px;
    list-style: none;
}
.toc li {
    margin: 8px 0;
}
.toc a {
    color: var(--text-secondary);
    text-decoration: none;
}
.toc a:hover {
    color: #3b82f6;
    text-decoration: underline;
}

.category-section {
    margin: 30px 40px;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.category-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--hover-shadow);
}

.category-header {
    background: var(--section-header);
    padding: 18px 24px;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
}

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

.commands-table th {
    text-align: left;
    padding: 12px 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.commands-table td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.commands-table tr:hover td {
    background: var(--bg-primary);
}

.num-col {
    width: 60px;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
}

code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 8px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
}

.badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}
.badge-common { background: #10b981; color: white; }
.badge-careful { background: #ef4444; color: white; }
.badge-advanced { background: #8b5cf6; color: white; }

.footer {
    text-align: center;
    padding: 30px;
    background: var(--header-gradient);
    color: white;
    margin-top: 40px;
}

@media (max-width: 768px) {
    .category-section, .toc { margin: 20px; }
    .filter-buttons { justify-content: center; }
    .theme-toggle { top: 20px; right: 20px; }
    .toc ul { columns: 1; }
    
    /* Card format for tables on mobile */
    .commands-table, .commands-table tbody, .commands-table tr, .commands-table td {
        display: block;
        width: 100%;
    }
    .commands-table thead {
        display: none;
    }
    .commands-table tr {
        margin-bottom: 15px;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        background: var(--bg-secondary);
        padding: 10px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }
    .commands-table td {
        display: flex;
        flex-direction: column;
        text-align: left;
        padding: 12px 10px;
        border-bottom: 1px dashed var(--border-color);
        gap: 6px;
    }
    .commands-table td:last-child {
        border-bottom: none;
    }
    .commands-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    .num-col {
        width: 100%;
        text-align: left;
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center;
        background: var(--bg-primary);
        border-radius: 8px 8px 0 0;
        margin: -10px -10px 0 -10px;
        padding: 10px 15px !important;
        border-bottom: 1px solid var(--border-color) !important;
    }
    .num-col::before {
        font-size: 0.9rem !important;
        color: var(--text-primary) !important;
    }
}

@media print {
    .theme-toggle, .search-container, .filter-buttons, .animated-bg { display: none; }
    .category-section, .toc { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
