/* =========================================================================
   EIF Gear — design system
   - CSS variables with light/dark themes
   - Sidebar nav on desktop, hamburger drawer on mobile
   - Admin-set primary color is injected as --primary in the layout
   ========================================================================= */

:root {
    --primary: #1f6feb;
    --primary-fg: #ffffff;

    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f5;
    --surface-3: #e9ecef;
    --border: #e3e6eb;
    --border-strong: #d0d4da;
    --text: #1c1f24;
    --text-muted: #5b6470;
    --text-soft: #8a93a0;
    --link: var(--primary);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 8px rgba(15, 23, 42, 0.05), 0 2px 4px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08), 0 4px 10px rgba(15, 23, 42, 0.05);
    --success: #16a34a;
    --success-bg: #ecfdf3;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --warn: #d97706;
    --warn-bg: #fffbeb;

    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 20px;
    --fs-2xl: 24px;
    --fs-3xl: 32px;

    --topbar-h: 60px;
    --sidebar-w: 232px;
    --container: 1100px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0f1115;
        --surface: #181b21;
        --surface-2: #1f232a;
        --surface-3: #262b34;
        --border: #2a2f38;
        --border-strong: #3a414c;
        --text: #e8eaed;
        --text-muted: #b0b7c0;
        --text-soft: #808994;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.5);
        --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.5);
        --success-bg: rgba(22, 163, 74, 0.15);
        --error-bg: rgba(220, 38, 38, 0.15);
        --warn-bg: rgba(217, 119, 6, 0.15);
    }
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #1f232a;
    --surface-3: #262b34;
    --border: #2a2f38;
    --border-strong: #3a414c;
    --text: #e8eaed;
    --text-muted: #b0b7c0;
    --text-soft: #808994;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.5);
    --success-bg: rgba(22, 163, 74, 0.15);
    --error-bg: rgba(220, 38, 38, 0.15);
    --warn-bg: rgba(217, 119, 6, 0.15);
}

/* ----- Reset & base ------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* The HTML 'hidden' attribute must beat any display:flex / display:grid
   author rule we later put on the same element. Without this, the lightbox
   etc. ignore <div hidden> and show on page load. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--fs-md);
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3 { color: var(--text); margin: 0 0 var(--space-3); line-height: 1.25; font-weight: 600; }
h1 { font-size: var(--fs-2xl); margin-bottom: var(--space-4); }
h2 { font-size: var(--fs-xl); margin-top: var(--space-5); }
h3 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--space-3); }

::selection { background: color-mix(in srgb, var(--primary) 30%, transparent); }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* ----- Topbar ---------------------------------------------------------- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--topbar-h);
    padding: 0 var(--space-4);
    max-width: none;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    font-size: var(--fs-lg);
    color: var(--text);
    letter-spacing: -0.01em;
    flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    background: var(--brand-bg, var(--primary));
    color: var(--primary-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text {
    display: inline-block;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
    flex-shrink: 0;
}

.icon-btn {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms, color 120ms, border-color 120ms;
    position: relative;
    text-decoration: none;
    flex-shrink: 0;
}
.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
    text-decoration: none;
}
.icon-btn svg { width: 18px; height: 18px; }
.theme-form { display: inline-flex; }

.badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--primary);
    color: var(--primary-fg);
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
    line-height: 1;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background 120ms, color 120ms;
}
.user-chip:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
.user-avatar {
    width: 28px; height: 28px;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--primary) 15%, var(--surface-2));
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--fs-sm);
}
.user-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----- Layout (sidebar + main) ----------------------------------------- */

.layout {
    display: flex;
    min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: var(--space-4) var(--space-3);
    position: sticky;
    top: var(--topbar-h);
    align-self: flex-start;
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    transition: background 120ms, color 120ms;
}
.side-nav a:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}
.side-nav a.active {
    color: var(--text);
    background: color-mix(in srgb, var(--primary) 10%, var(--surface-2));
    box-shadow: inset 3px 0 0 var(--primary);
}
.side-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.side-section {
    margin: var(--space-4) var(--space-3) var(--space-1);
    color: var(--text-soft);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.main-inner {
    flex: 1;
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-5) var(--space-4) var(--space-7);
}

body.no-sidebar .main-inner { max-width: 720px; }

/* ----- Mobile drawer toggle ------------------------------------------- */

.nav-toggle { display: none; }
.nav-burger {
    display: none;
    width: 40px; height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
}
.nav-burger:hover { background: var(--surface-2); color: var(--text); }
.nav-burger svg { width: 22px; height: 22px; }
.nav-burger .icon-close { display: none; }

/* ----- Helpers --------------------------------------------------------- */

.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.right { text-align: right; }
.center { text-align: center; }
.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: var(--space-3); justify-content: space-between; align-items: center; flex-wrap: wrap; }

/* ----- Cards ----------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}
.card.compact { padding: var(--space-4); }

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}
.section-header h1, .section-header h2 { margin-bottom: 0; }

/* ----- Hero (rare) ----------------------------------------------------- */

.hero {
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 14%, var(--surface)), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-7) var(--space-5);
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.hero h1 { font-size: var(--fs-3xl); margin-bottom: var(--space-3); }
.hero p { color: var(--text-muted); font-size: var(--fs-lg); max-width: 480px; margin-left: auto; margin-right: auto; }
.hero .actions { margin-top: var(--space-5); display: inline-flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center; }

/* ----- Flash messages -------------------------------------------------- */

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}
.flash-error { background: var(--error-bg); color: var(--error); border-color: color-mix(in srgb, var(--error) 30%, transparent); }
.flash-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }

/* ----- Tables ---------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 calc(var(--space-5) * -1); padding: 0 var(--space-5); }

table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--surface-2);
}
tbody tr:hover td { background: var(--surface-2); }
tfoot td { font-weight: 600; }

.muted-row td { color: var(--text-muted); }

/* ----- Forms ----------------------------------------------------------- */

label {
    display: block;
    font-size: var(--fs-sm);
    color: var(--text);
    margin: var(--space-3) 0 var(--space-1);
    font-weight: 500;
}
label.inline-checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color 120ms, box-shadow 120ms;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
input[type="file"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
textarea { min-height: 100px; resize: vertical; }

.form-row { margin-bottom: var(--space-3); }
.form-row .help { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }
.form-actions {
    margin-top: var(--space-4);
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    align-items: center;
}

/* ----- Buttons --------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    transition: background 120ms, border-color 120ms, transform 80ms;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn-primary:hover {
    background: color-mix(in srgb, var(--primary) 88%, black);
    border-color: color-mix(in srgb, var(--primary) 88%, black);
    color: var(--primary-fg);
}
.btn-danger {
    background: transparent;
    border-color: color-mix(in srgb, var(--error) 50%, var(--border));
    color: var(--error);
}
.btn-danger:hover { background: var(--error-bg); }
.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: color-mix(in srgb, var(--success) 88%, black);
    border-color: color-mix(in srgb, var(--success) 88%, black);
    color: #fff;
}
.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn-lg { padding: 12px 20px; font-size: var(--fs-lg); }
.btn-block { width: 100%; }

.link-btn {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    color: var(--link);
    font: inherit;
}
.link-btn:hover { text-decoration: underline; }

/* Icon-only line actions (Edit / View / Delete / Settings...) */
.icon-link {
    display: inline-flex;
    width: 32px; height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 120ms, color 120ms;
    text-decoration: none;
    font: inherit;
    padding: 0;
}
.icon-link svg { width: 16px; height: 16px; }
.icon-link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
.icon-link.is-danger { color: var(--text-muted); }
.icon-link.is-danger:hover { background: var(--error-bg); color: var(--error); }
.icon-link.is-primary:hover { background: color-mix(in srgb, var(--primary) 12%, var(--surface-2)); color: var(--primary); }

/* Right-aligned action group in lists. When this class lands on a non-table
   element it stays a flex row; when it lands on a <td>/<th> the cell keeps
   its table-cell role and we right-align inline children instead -- mixing
   inline-flex with table-cell breaks the column widths of the whole row. */
.row-actions {
    display: inline-flex;
    gap: 2px;
    align-items: center;
    justify-content: flex-end;
}
td.row-actions,
th.row-actions {
    display: table-cell;
    text-align: right;
    white-space: nowrap;
    font-size: 0; /* collapse whitespace between icons */
    padding-top: 6px;
    padding-bottom: 6px;
}
td.row-actions > *,
th.row-actions > * {
    font-size: var(--fs-md);
    vertical-align: middle;
}
td.row-actions > * + *,
th.row-actions > * + * {
    margin-left: 2px;
}
td.row-actions form.inline,
th.row-actions form.inline {
    display: inline-block;
    margin: 0;
}

/* ----- Tags ------------------------------------------------------------ */

.tag {
    display: inline-flex;
    align-items: center;
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
    color: color-mix(in srgb, var(--primary) 80%, var(--text));
    border-radius: var(--radius-pill);
    padding: 2px 10px;
    font-size: var(--fs-xs);
    margin-right: 4px;
    font-weight: 500;
}
.tag-muted { background: var(--surface-2); color: var(--text-muted); }

.status { font-weight: 600; font-size: var(--fs-sm); }
.status-open { color: var(--success); }
.status-closed { color: var(--warn); }
.status-ordered { color: var(--primary); }
.status-received { color: var(--text-muted); }

/* ----- Grids ----------------------------------------------------------- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    color: inherit;
    transition: transform 120ms, box-shadow 120ms, border-color 120ms;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    overflow: hidden;
}
.product-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    transform: translateY(-1px);
}
.product-thumb {
    aspect-ratio: 1 / 1;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    margin-bottom: var(--space-2);
    padding: var(--space-2);
}
.product-thumb img { width: 100%; height: 100%; object-fit: contain; }
.product-thumb svg { width: 32px; height: 32px; opacity: 0.4; }
.product-card .name { font-weight: 600; color: var(--text); }
.product-card .desc { font-size: var(--fs-sm); color: var(--text-muted); flex: 1; }
.product-card .price { font-size: var(--fs-lg); font-weight: 600; color: var(--text); }

.product-gallery-stage { margin-bottom: var(--space-4); }

.product-hero {
    aspect-ratio: 16 / 10;
    max-height: 360px;
    background: var(--surface-2);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.product-hero img { width: 100%; height: 100%; object-fit: contain; }
.hero-img-button {
    width: 100%;
    height: 100%;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: zoom-in;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px; height: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 120ms, background 120ms;
}
.gallery-nav:hover { background: var(--surface-2); transform: translateY(-50%) scale(1.05); }
.gallery-nav svg { width: 18px; height: 18px; }
.gallery-prev { left: 8px; }
.gallery-next { right: 8px; }

.product-gallery {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.product-gallery-item {
    width: 84px;
    height: 84px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--border);
    background: var(--surface-2);
    padding: 0;
    cursor: pointer;
    transition: border-color 120ms, transform 120ms;
}
.product-gallery-item:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.product-gallery-item.is-active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.product-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 14, 0.92);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
}
body.lightbox-open { overflow: hidden; }
.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}
.lightbox-close,
.lightbox-nav {
    position: absolute;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: var(--radius-pill);
    width: 44px; height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 120ms;
    z-index: 1;
}
.lightbox-close { top: 16px; right: 16px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,0.2); }
.lightbox-close svg, .lightbox-nav svg { width: 22px; height: 22px; }
.lightbox-counter {
    position: absolute;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.85);
    background: rgba(0,0,0,0.4);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-sm);
}

/* Dropzone (photo upload) */
.dropzone {
    display: block;
    cursor: pointer;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: var(--space-6) var(--space-4);
    text-align: center;
    background: var(--surface-2);
    color: var(--text-muted);
    margin: var(--space-3) 0 0;
    transition: background 120ms, border-color 120ms, color 120ms;
}
.dropzone:hover { background: var(--surface-3); border-color: var(--primary); color: var(--text); }
.dropzone.is-dragging {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface-2));
    border-color: var(--primary);
    color: var(--text);
}
.dropzone-input {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
.dropzone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.dropzone-prompt strong { color: var(--text); font-size: var(--fs-lg); }
.dropzone-prompt .dropzone-hint { font-size: var(--fs-xs); }
.dropzone-prompt svg { color: var(--text-muted); margin-bottom: var(--space-2); }
.dropzone-files {
    list-style: none;
    margin: var(--space-3) 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dropzone-files li {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
}

.dropzone-preview {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-align: left;
}
.dropzone-preview img {
    max-height: 80px;
    max-width: 120px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.logo-current {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
}
.logo-current img {
    max-height: 64px;
    max-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
}

/* Kit-side image gallery editor */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.image-gallery-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}
.image-gallery-item.is-primary { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.image-gallery-item img {
    aspect-ratio: 4 / 3;
    width: 100%;
    height: auto;
    object-fit: cover;
    background: var(--surface-3);
}
.image-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--primary);
    color: var(--primary-fg);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.03em;
}
.image-actions {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-2);
    flex-wrap: wrap;
    justify-content: space-between;
}
.image-actions .btn { flex: 1; min-width: 0; }

/* ----- Definition list & attrs ----------------------------------------- */

dl.kv {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 6px var(--space-4);
    margin: 0;
}
dl.kv dt { color: var(--text-muted); font-size: var(--fs-sm); }
dl.kv dd { margin: 0; }

ul.attrs {
    margin: 0;
    padding-left: 16px;
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

/* ----- Auth ----------------------------------------------------------- */

.auth-shell {
    min-height: calc(100vh - var(--topbar-h) - 80px);
    display: grid;
    place-items: center;
    padding: var(--space-5) 0;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
}
.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    text-align: center;
}
.auth-logo img { max-height: 64px; max-width: 220px; }
.auth-logo .auth-brand { font-size: var(--fs-2xl); font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.auth-logo .auth-tagline { color: var(--text-muted); font-size: var(--fs-sm); }

/* ----- Empty state ---------------------------------------------------- */

.empty {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-7) var(--space-4);
}

/* ----- Footer --------------------------------------------------------- */

.footer {
    padding: var(--space-5) var(--space-4);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}
.footer-content { max-width: var(--container); margin: 0 auto; line-height: 1.6; }
.footer-content a { color: var(--text-muted); }
.footer-content a:hover { color: var(--text); }
.footer-content p { margin: 0 0 var(--space-2); }
.footer-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
}

/* ----- Catalog filters ------------------------------------------------ */

.catalog-filters {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--space-4);
}
.catalog-filters input[type="search"] { flex: 1 1 240px; min-width: 180px; }
.catalog-filters select { width: auto; flex: 0 1 200px; }
@media (max-width: 640px) {
    .catalog-filters input[type="search"],
    .catalog-filters select { flex: 1 1 100%; }
}

/* ----- Home instructions ---------------------------------------------- */

.instructions {
    font-size: var(--fs-md);
}
.instructions h2 { font-size: var(--fs-xl); margin-top: 0; }
.instructions h3 { font-size: var(--fs-lg); margin-top: var(--space-4); }
.instructions ol, .instructions ul { padding-left: 22px; margin: 0 0 var(--space-3); }
.instructions li { margin-bottom: 4px; }
.instructions p:last-child { margin-bottom: 0; }
.instructions code {
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 13px;
}

/* ----- Option allowlist (per-product attribute options) --------------- */

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

/* ----- Product meta editor rows --------------------------------------- */

.meta-rows { display: flex; flex-direction: column; gap: var(--space-2); }
.meta-row {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(180px, 2fr) auto;
    gap: var(--space-2);
    align-items: center;
}
.meta-row .btn { padding: 6px 10px; }
@media (max-width: 640px) {
    .meta-row {
        grid-template-columns: 1fr auto;
        grid-template-areas: "label remove" "value value";
    }
    .meta-row > input:first-child { grid-area: label; }
    .meta-row > input:nth-child(2) { grid-area: value; }
    .meta-row > .meta-remove { grid-area: remove; }
}

/* ----- Product properties (read-only display) ------------------------- */

.product-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px var(--space-4);
    margin: 0 0 var(--space-3);
    font-size: var(--fs-sm);
}
.product-meta dt { color: var(--text-muted); }
.product-meta dd { margin: 0; color: var(--text); }
@media (max-width: 480px) {
    .product-meta { grid-template-columns: 1fr; gap: 2px; }
    .product-meta dt { margin-top: 6px; }
}

/* ----- Responsive ---------------------------------------------------- */

@media (max-width: 900px) {
    :root { --topbar-h: 56px; }

    .nav-burger { display: inline-flex; }
    body.has-sidebar .layout { display: block; }
    body.has-sidebar .sidebar {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 200ms ease-out;
        box-shadow: var(--shadow-lg);
        height: calc(100vh - var(--topbar-h));
    }
    .nav-toggle:checked ~ .layout .sidebar { transform: translateX(0); }
    .nav-toggle:checked ~ .topbar .nav-burger .icon-open { display: none; }
    .nav-toggle:checked ~ .topbar .nav-burger .icon-close { display: block; }

    .user-name { display: none; }
}

@media (max-width: 640px) {
    .topbar-inner { padding: 0 var(--space-3); }
    .brand-text { display: none; }
    .main-inner { padding: var(--space-4) var(--space-3) var(--space-6); }

    .card { padding: var(--space-4); }
    .table-wrap { margin: 0 calc(var(--space-4) * -1); padding: 0 var(--space-4); }

    dl.kv { grid-template-columns: 1fr; gap: 2px; }
    dl.kv dt { margin-top: var(--space-2); }

    h1 { font-size: var(--fs-xl); }
    h2 { font-size: var(--fs-lg); }

    .topbar-right .btn { padding: 6px 10px; font-size: var(--fs-sm); }
    .user-chip .user-avatar { display: none; }
}

@media (max-width: 480px) {
    .auth-card { padding: var(--space-5) var(--space-4); }
    .form-actions .btn { flex: 1 1 auto; }
}
