:root {
    --bg-dark-teal: #0f3554;
    --bg-teal: #154a72;
    --bg-light: #f4f6fb;
    --text-light: #f8fbff;
    --text-dark: #0f1c2e;
    --accent-yellow: #f7b538;
    --accent-green: #2ecc71;
    --danger-red: #ff6b6b;
    --card-bg: #ffffff;
    --border-color: #dfe3ec;
}

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

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg-light);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    width: 95%;
    max-width: 1200px;
    margin: 0 auto;
}

body.home-page {
    background: linear-gradient(180deg, rgba(5,34,71,0.9), rgba(19,57,103,0.95)), url('/static/images/header-bg.jpg');
    background-repeat: no-repeat;
    background-size: cover;
    color: var(--text-light);
}

.header {
    background: linear-gradient(180deg, rgba(11,44,82,0.92), rgba(7,30,63,0.95));
    border-bottom: 4px solid var(--accent-yellow);
    color: var(--text-light);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.logo img { height: 34px; }
.main-nav {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}
.main-nav a { font-weight: 600; transition: opacity .2s; }
.main-nav a:hover { opacity: .75; }
.cart-icon {
    font-size: 24px;
    position: relative;
    cursor: pointer;
}
#cart-count {
    position: absolute;
    top: -8px;
    right: -12px;
    background: var(--danger-red);
    color: #fff;
    font-size: 11px;
    border-radius: 999px;
    padding: 2px 6px;
}

.btn {
    border: none;
    border-radius: 40px;
    padding: 12px 24px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,0.15); }
.btn-primary {
    background: var(--accent-yellow);
    color: var(--bg-dark-teal);
}
.btn-tertiary {
    background: rgba(255,255,255,0.2);
    color: inherit;
}
.ios-btn-primary {
    background: var(--accent-yellow);
    color: var(--bg-dark-teal);
    border-radius: 999px;
    padding: 12px 28px;
    font-weight: 600;
    border: none;
    box-shadow: 0 10px 20px rgba(247,181,56,0.35);
    cursor: pointer;
}
.ios-btn-secondary {
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    padding: 12px 26px;
    border-radius: 999px;
    background: transparent;
    font-weight: 600;
    cursor: pointer;
}

.hero { padding: 60px 0 50px; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.5rem); margin-bottom: 16px; }
.hero p { max-width: 600px; margin-bottom: 24px; opacity: .85; }

.home-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin: 30px 0;
}
.category-card {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 18px;
    text-align: center;
    border-radius: 12px;
    transition: transform .2s;
}
.category-card:hover { transform: translateY(-4px); }
.category-card .icon { font-size: 36px; margin-bottom: 6px; }

.products-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding: 10px 0;
}
.products-container .product-card {
    flex: 0 0 260px;
}

.catalog-layout {
    display: flex;
    gap: 24px;
    padding: 30px 0;
}
.catalog-main { flex: 1; }
.filters-sidebar {
    flex: 0 0 280px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 18px;
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.filter-group { border-bottom: 1px solid var(--border-color); }
.filter-group:last-child { border-bottom: none; }
.filter-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 12px 0;
    font-weight: 600;
}
.filter-group-header::after {
    content: 'v';
    font-size: 12px;
    transition: transform .2s;
}
.filter-group-header.active::after { transform: rotate(180deg); }
.filter-group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
}
.filter-group-content.active { max-height: 400px; padding-bottom: 12px; }
.price-filter {
    display: flex;
    gap: 10px;
}
.price-filter input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}
.filter-buttons {
    display: flex;
    gap: 12px;
    margin-top: 15px;
}

.catalog-header {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}
.catalog-header input[type="search"] {
    flex: 1 1 260px;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.catalog-header select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

#product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px,1fr));
    gap: 16px;
}
.product-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(15,53,84,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.product-card-link { display: flex; flex-direction: column; height: 100%; }
.product-image {
    background: #eef2f6;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.product-info { padding: 16px; flex: 1; }
.product-info h4 {
    font-size: 1rem;
    margin-bottom: 8px;
    min-height: 48px;
}
.product-price { font-size: 1.2rem; font-weight: 700; color: var(--bg-dark-teal); }
.cart-button-container { padding: 12px 16px 20px; }

.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 25px 0;
}
.page-btn {
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--border-color);
    cursor: pointer;
}
.page-btn.active { background: var(--bg-teal); color: #fff; }

.product-detail-layout {
    display: grid;
    grid-template-columns: minmax(280px, 400px) 1fr;
    gap: 24px;
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.product-detail-image {
    background: #f3f5f8;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.product-attributes table { width: 100%; border-collapse: collapse; }
.product-attributes td {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
}
.modal-overlay.show { display: flex; }
.modal-content {
    background: #fff;
    border-radius: 16px;
    width: min(480px, 90vw);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}
.cart-items {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
}
.cart-item-info h5 { font-size: 0.95rem; margin-bottom: 4px; }
.cart-item-price { color: #5c6a7a; font-size: 0.9rem; }
.cart-item-remove {
    border: none;
    background: none;
    color: var(--danger-red);
    font-size: 16px;
    cursor: pointer;
}
.cart-total { font-weight: 600; margin-top: 10px; }
.checkout-success-view {
    padding: 24px;
    text-align: center;
}
.checkout-success-view .icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(46, 204, 113, 0.15);
    color: var(--accent-green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-bottom: 12px;
}
.quantity-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.quantity-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--border-color);
    cursor: pointer;
}
.checkout-form input, .checkout-form select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
}

/* Admin quick helpers */
.admin-container { background: #fff; border-radius: 16px; box-shadow: 0 12px 30px rgba(7,30,63,0.1); padding: 30px; }
.admin-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; }
.tab-btn {
    background: none;
    border: none;
    padding: 10px 0;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}
.tab-btn.active { border-color: var(--accent-yellow); color: var(--bg-dark-teal); }
.product-table { width:100%; border-collapse: collapse; }
.product-table th, .product-table td { padding: 10px; border-bottom: 1px solid var(--border-color); text-align: left; }
.product-table th { background: #f8f9fb; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 15px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
#image-dropzone { border:1px dashed var(--border-color); padding: 15px; text-align:center; border-radius: 10px; background:#fafbff; cursor:pointer; }

@media (max-width: 992px) {
    .catalog-layout { flex-direction: column; }
    .filters-sidebar { position: static; max-height: none; width: 100%; }
}
@media (max-width: 768px) {
    .header .container { flex-direction: column; align-items: flex-start; }
    .header .container { gap: 10px; }
    .main-nav { gap: 12px; }
    .cart-icon { margin-left: 0; }
    .header .ios-btn-secondary { align-self: flex-start; }
    .catalog-header { flex-direction: column; align-items: stretch; }
    #product-grid { grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); }
    .product-detail-layout { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .home-category-grid { grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); }
    .filters-sidebar { padding: 12px; }
    .hero { padding: 40px 0; }
    .main-nav { width: 100%; }
    .main-nav a { font-size: 0.95rem; }
    .cart-icon { font-size: 22px; }
    .products-container { gap: 12px; }
    .product-image { height: 160px; }
    .product-info { padding: 12px; }
}
