:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-light: #1e293b;
    --bg-lighter: #334155;
    --text: #f8fafc;
    --text-light: #cbd5e1;
    --border: #475569;
    --card-bg: rgba(30, 41, 59, 0.8);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 0.75rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-light);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 1.5rem 2rem;
    position: relative;
    overflow: hidden;
}

.header-content h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
}

.tagline {
    font-size: 1rem;
    opacity: 0.9;
}

.status-bar {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.status-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

/* Navigation */
.nav-tabs {
    display: flex;
    background: var(--bg-lighter);
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

.nav-tab {
    flex: 1;
    min-width: 120px;
    padding: 1rem 0.5rem;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-light);
}

/* Sections */
.tab-section {
    display: none;
    padding: 1.5rem;
}

.tab-section.active {
    display: block;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text);
    font-weight: 700;
}

/* Types Grid */
.types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.type-box {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.type-box:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.2);
}

.type-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
}

.type-box h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.type-pattern {
    color: var(--primary);
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
    font-weight: 500;
}

.type-examples {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.8rem;
    padding-left: 1rem;
}

.type-examples li {
    margin-bottom: 0.2rem;
}

.type-details {
    font-size: 0.8rem;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    padding-top: 0.8rem;
}

/* Table Section */
.table-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    align-items: center;
}

.filter-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-tag {
    padding: 0.5rem 1rem;
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    color: var(--text-light);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-tag:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-tag.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.search-box input {
    padding: 0.5rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    min-width: 200px;
    font-size: 0.9rem;
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table thead {
    background: var(--bg-lighter);
}

table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--primary);
}

table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-light);
}

table tbody tr:hover {
    background: rgba(99, 102, 241, 0.1);
}

.table-stats {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Calculator Section */
.calc-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

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

.calc-form {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
}

.input-group {
    margin-bottom: 1.2rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.9rem;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
}

.input-group input[type="range"] {
    margin-bottom: 0.5rem;
}

.calc-btn {
    width: 100%;
    padding: 0.8rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.calc-results {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
}

.results-placeholder {
    color: var(--text-light);
    font-style: italic;
    text-align: center;
    padding: 2rem 0;
}

.savings-chart {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
}

/* Demo Section */
.demo-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

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

.demo-header {
    margin-bottom: 1.2rem;
}

.sim-type-selector {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.sim-type-btn {
    flex: 1;
    min-width: 140px;
    padding: 0.6rem 0.8rem;
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    color: var(--text-light);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sim-type-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.sim-type-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.demo-description {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.5;
}

.canvas-wrapper {
    position: relative;
    background: var(--bg);
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border);
    margin-bottom: 1.2rem;
}

#simCanvas {
    width: 100%;
    height: 400px;
    display: block;
}

.canvas-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}

.demo-controls {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}

.demo-btn {
    flex: 1;
    max-width: 120px;
    padding: 0.8rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.demo-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

/* Demo Parameters */
.demo-params {
    background: var(--card-bg);
    padding: 1.2rem;
    border-radius: 12px;
    align-self: start;
}

.demo-params h3 {
    font-size: 1.2rem;
    margin-bottom: 1.2rem;
}

.param-group {
    margin-bottom: 1rem;
}

.param-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.param-group input[type="range"] {
    width: 100%;
    margin-bottom: 0.3rem;
}

.param-group span {
    display: inline-block;
    width: 40px;
    text-align: right;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.9rem;
}

.sim-info {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.sim-info h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.sim-info p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.3rem;
}

/* Footer */
footer {
    background: var(--bg-lighter);
    padding: 1.2rem 2rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }
    
    .container {
        border-radius: 12px;
    }
    
    header {
        padding: 1rem;
    }
    
    .header-content h1 {
        font-size: 1.5rem;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .tab-section {
        padding: 1rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tab {
        min-width: 90px;
        padding: 0.8rem 0.3rem;
        font-size: 0.8rem;
    }
    
    .types-grid {
        grid-template-columns: 1fr;
    }
    
    .table-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-controls {
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .search-box input {
        min-width: 100%;
    }
    
    .canvas-overlay {
        justify-content: center;
        padding: 0.6rem;
        gap: 0.8rem;
        font-size: 0.8rem;
    }
    
    .demo-controls {
        flex-wrap: wrap;
    }
    
    .demo-btn {
        min-width: 100px;
    }
    
    .sim-type-selector {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
    }
    
    .sim-type-btn {
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.3rem;
    }
    
    .tagline {
        font-size: 0.9rem;
    }
    
    .types-grid {
        gap: 0.8rem;
    }
    
    .type-box {
        padding: 1rem;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    table th,
    table td {
        padding: 0.6rem 0.5rem;
    }
    
    #simCanvas {
        height: 300px;
    }
}