:root {
    --shell-bg: #05080f;
    --shell-bg-2: #0b0f1a;
    --shell-bg-3: #11172a;
    --shell-border: rgba(255, 255, 255, 0.09);
    --shell-text: #f8fafc;
    --shell-muted: #94a3b8;

    --bg: #f1f4f9;
    --card-bg: #ffffff;
    --text: #1f2933;
    --muted: #64748b;

    --accent: #006fff;
    --accent-dark: #0058cc;
    --accent-light: #2483ff;
    --accent-gradient: linear-gradient(135deg, var(--accent-dark), var(--accent-light));
    --accent-soft: rgba(0, 111, 255, 0.1);
    --accent-soft-border: rgba(0, 111, 255, 0.3);

    --border: #e2e8f0;
    --danger: #e4483f;
    --ok: #1a8f5e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; }

header {
    background: var(--shell-bg);
    background-image: radial-gradient(circle at 15% 0%, rgba(0, 111, 255, 0.22), transparent 55%),
                       radial-gradient(circle at 85% 100%, rgba(36, 131, 255, 0.12), transparent 50%);
    color: var(--shell-text);
    padding: 22px 24px;
    border-bottom: 1px solid var(--shell-border);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
    font-size: 23px;
    letter-spacing: -0.01em;
}

header h1 .accent-word {
    background: linear-gradient(135deg, var(--accent-light), #7db4ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

header p {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--shell-muted);
}

.powered-by {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 11px;
    color: var(--shell-muted);
    text-decoration: none;
    border: 1px solid var(--shell-border);
    background: rgba(255, 255, 255, 0.03);
    padding: 5px 10px 5px 8px;
    border-radius: 999px;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.powered-by:hover {
    border-color: var(--accent-soft-border);
    color: var(--shell-text);
}

.powered-by .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-gradient);
    flex-shrink: 0;
}

.header-links {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-links a {
    color: var(--shell-muted);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.15s ease;
}

.header-links a:hover {
    color: var(--shell-text);
}

.header-links .admin-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-gradient);
    color: #fff;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12.5px;
}

.header-links .admin-link:hover {
    opacity: 0.92;
    color: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--card-bg);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    margin-bottom: 18px;
}

.controls input[type="text"] {
    flex: 1 1 260px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.controls select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.controls input[type="text"]:focus,
.controls select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.controls + .controls {
    margin-top: -10px;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -6px 0 14px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 6px 5px 12px;
    border-radius: 999px;
}

.filter-chip button {
    border: none;
    background: rgba(0, 111, 255, 0.16);
    color: var(--accent-dark);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-chip button:hover {
    background: rgba(0, 111, 255, 0.3);
}

.clear-all {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.clear-all:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.status-line {
    margin: 4px 0 16px;
    font-size: 13px;
    color: var(--muted);
}

.layout {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    padding: 12px;
    position: sticky;
    top: 14px;
    max-height: calc(100vh - 28px);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.sidebar-clear {
    border: none;
    background: none;
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
}

.sidebar-clear:hover {
    text-decoration: underline;
}

.sidebar-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 12.5px;
    margin-bottom: 8px;
}

.sidebar-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.brand-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brand-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
}

.brand-item:hover {
    background: var(--accent-soft);
}

.brand-item input {
    flex-shrink: 0;
    accent-color: var(--accent);
}

.brand-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.brand-item-count {
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
}

.brand-empty {
    font-size: 12px;
    color: var(--muted);
    padding: 8px 4px;
}

.main-col {
    flex: 1;
    min-width: 0;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 12px;
}

.card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 111, 255, 0.14);
    border-color: var(--accent-soft-border);
}

.card .thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 9px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.card-body h3 {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-body .generic {
    font-size: 10.5px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-body .brand {
    font-size: 10.5px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-body .meta {
    font-size: 10.5px;
    color: var(--muted);
    margin-top: 1px;
}

.price-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
}

.price {
    font-weight: 700;
    color: var(--accent-dark);
    font-size: 14px;
}

.pack-size {
    font-size: 10px;
    color: var(--muted);
    margin-top: 1px;
}

.card-footer-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.category-tag {
    font-size: 9px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alt-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 4px 8px;
    border: 1px solid var(--accent);
    background: #fff;
    color: var(--accent);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.alt-btn:hover {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 15, 0.65);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--accent-soft), transparent);
}

.modal-header h2 {
    margin: 0;
    font-size: 16px;
    color: var(--text);
}

.modal-header button {
    border: none;
    background: none;
    font-size: 24px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
}

.modal-header button:hover {
    color: var(--danger);
}

.modal-body {
    padding: 12px 20px 20px;
    overflow-y: auto;
}

.alt-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.alt-card:last-child {
    border-bottom: none;
}

.alt-thumb {
    width: 56px;
    height: 56px;
    object-fit: contain;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.alt-info {
    flex: 1;
    min-width: 0;
}

.alt-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.alt-brand, .alt-meta {
    font-size: 12px;
    color: var(--muted);
}

.alt-price {
    font-weight: 700;
    color: var(--accent-dark);
    font-size: 15px;
    white-space: nowrap;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 26px;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    transition: border-color 0.15s ease, color 0.15s ease;
}

.pagination button:not(:disabled):hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination span {
    font-size: 13px;
    color: var(--muted);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

footer.site-footer {
    background: var(--shell-bg);
    border-top: 1px solid var(--shell-border);
    color: var(--shell-muted);
    padding: 22px 24px;
    text-align: center;
    font-size: 12.5px;
}

footer.site-footer a {
    color: var(--accent-light);
    text-decoration: none;
    font-weight: 600;
}

footer.site-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 820px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        max-height: 260px;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}
