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

:root {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-soft: #e6f0ff;
    --text: #0f172a;
    --text-muted: #334155;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --accent: #3b82f6;
    --border: #cbd5e1;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --radius: 1rem;
    --radius-sm: 0.75rem;
    --transition: all 0.2s ease;
}

body.dark {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-soft: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --accent: #93c5fd;
    --border: #475569;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    line-height: 1.5;
    transition: background 0.3s, color 0.2s;
}

.app-container {
    max-width: 1280px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

header {
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.icon-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(255,255,255,0.3);
}

nav {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

nav button {
    padding: 0.6rem 1.2rem;
    background: transparent;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 2rem;
    transition: var(--transition);
}

nav button.active {
    background: var(--primary);
    color: white;
}

nav button:hover:not(.active) {
    background: var(--surface-soft);
    color: var(--text);
}

main {
    flex: 1;
    padding: 1.5rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.card h3 {
    margin-bottom: 1rem;
    font-weight: 600;
}

input, select, button:not(.icon-btn) {
    padding: 0.6rem 1rem;
    border-radius: 2rem;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

button.primary {
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

button.primary:hover {
    background: var(--primary-dark);
}

button.accent {
    background: var(--accent);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface-soft);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
}

.stat-card .value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
}

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

.total-price {
    font-size: 1.2rem;
    font-weight: 700;
    text-align: right;
    margin: 1rem 0;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-dark);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
}

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

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

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
    main {
        padding: 1rem;
    }
    nav button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}