:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #162026;
    --muted: #63727d;
    --line: #dbe3e8;
    --accent: #126d5b;
    --accent-dark: #0d5748;
    --danger: #b42318;
    --danger-dark: #8f1c13;
    --warning: #996a13;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 12px clamp(16px, 4vw, 40px);
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand {
    font-weight: 700;
    text-decoration: none;
}

.page {
    width: min(1320px, calc(100% - 32px));
    margin: 32px auto;
}

.auth-panel,
.empty,
.product-form,
.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.auth-panel {
    width: min(420px, 100%);
    margin: 72px auto;
    padding: 28px;
}

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 6px;
    font-size: 28px;
    line-height: 1.2;
}

h2 {
    margin-bottom: 8px;
    font-size: 20px;
}

p {
    color: var(--muted);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
}

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

.button-secondary {
    background: #e9eef1;
    color: var(--text);
}

.button-secondary:hover {
    background: #d9e2e7;
}

.button-danger {
    background: var(--danger);
}

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

.form {
    display: grid;
    gap: 18px;
}

.product-form {
    padding: 24px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

label,
.field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 650;
}

.field-label {
    display: block;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    color: var(--text);
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.check input {
    width: 18px;
    height: 18px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.alert,
.notice {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 6px;
}

.alert {
    border: 1px solid #ffd6a8;
    background: #fff8eb;
    color: var(--warning);
}

.notice {
    border: 1px solid #b7ebc9;
    background: #ecfff2;
    color: #11683d;
}

.upload-progress {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafb;
    color: var(--muted);
}

.empty {
    padding: 36px;
    text-align: center;
}

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

.bulk-save-bar {
    position: sticky;
    bottom: 16px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 32px rgba(22, 32, 38, 0.14);
    backdrop-filter: blur(10px);
}

.bulk-save-bar strong {
    display: block;
    margin-bottom: 3px;
}

.bulk-save-bar span {
    color: var(--muted);
    font-size: 14px;
}

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

th,
td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.description {
    min-width: 320px;
    max-width: 520px;
}

.thumb,
.preview {
    display: block;
    width: 106px;
    height: 106px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
    background: #eef2f4;
}

.preview {
    width: 224px;
    height: 168px;
}

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

.gallery-item {
    display: grid;
    gap: 8px;
}

.gallery-delete {
    font-size: 14px;
}

.image-count {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.photo-upload {
    display: grid;
    gap: 6px;
    width: 148px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.photo-upload input {
    padding: 6px;
    font-size: 12px;
}

.table-input {
    min-width: 0;
    padding: 9px 10px;
    font-size: 15px;
}

.name-input {
    width: 220px;
    font-weight: 650;
}

.category-input {
    width: 220px;
}

.table-textarea {
    min-height: 96px;
    line-height: 1.35;
}

.price-input {
    width: 118px;
}

.quantity-input {
    width: 96px;
}

.availability-cell {
    min-width: 132px;
}

.switch {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.switch input {
    width: 18px;
    height: 18px;
}

.thumb-empty {
    background: linear-gradient(135deg, #eef2f4, #dfe7ec);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
}

.status-on {
    background: #e7f7ef;
    color: #11683d;
}

.status-off {
    background: #f2f4f7;
    color: #667085;
}

.actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .section-header,
    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .header-actions {
        justify-content: stretch;
    }

    .bulk-save-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .page {
        margin-top: 20px;
    }

    .thumb {
        width: 96px;
        height: 96px;
    }
}
