:root {
    color-scheme: light;
    --bg: #f7f2ea;
    --panel: #ffffff;
    --ink: #2a2a2a;
    --muted: #6d6d6d;
    --accent: #b08b5c;
    --accent-dark: #8a6a43;
    --border: #e2d9cc;
    --danger: #b64b4b;
}

* {
    box-sizing: border-box;
    font-family: "Lato", "Segoe UI", sans-serif;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

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

.topbar h1 {
    margin: 0 0 6px;
    font-size: 2rem;
}

.topbar p {
    margin: 0;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    gap: 10px;
}

button {
    border: none;
    border-radius: 4px;
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
}

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

button.ghost {
    background: transparent;
    color: var(--accent-dark);
    border: 1px solid var(--accent-dark);
}

button.ghost:hover {
    background: rgba(176, 139, 92, 0.1);
}

button.primary {
    padding: 10px 18px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.hidden {
    display: none;
}

label {
    display: block;
    margin: 12px 0 6px;
    font-weight: 600;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 0.95rem;
}

.error {
    color: var(--danger);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    gap: 12px;
    align-items: center;
}

#search {
    min-width: 260px;
}

.section {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 18px;
    background: #fff;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.section-header h3 {
    margin: 0 0 6px;
}

.section-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.section-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.section-actions button {
    padding: 8px 12px;
    font-size: 0.8rem;
}

.upload-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
}

.upload-row input[type=file] {
    padding: 6px;
    background: #fbf9f6;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.table th,
.table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

.table .title-col,
.table .title-cell {
    width: 240px;
}

.table .title-cell input {
    min-width: 220px;
}

.table th {
    color: var(--muted);
    font-weight: 600;
}

.thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid #eee;
}

.thumb-wrap {
    position: relative;
    width: 56px;
    height: 56px;
}

.thumb-icons {
    position: absolute;
    bottom: -6px;
    right: -6px;
    display: flex;
    gap: 4px;
}

.icon-badge {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e7ddcf;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(176, 139, 92, 0.2);
    color: var(--accent-dark);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.sold {
    background: rgba(182, 75, 75, 0.2);
    color: var(--danger);
}

.inline-btn {
    background: transparent;
    color: var(--accent-dark);
    border: 1px solid var(--accent-dark);
    padding: 4px 8px;
    border-radius: 4px;
}

.icon-btn {
    background: transparent;
    border: 1px solid #d8cbbb;
    color: #5a4b39;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1;
}

.icon-btn:hover {
    background: rgba(176, 139, 92, 0.08);
}

.icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: transparent;
}

.icon-btn.drag-handle {
    cursor: grab;
}

tr.dragging {
    opacity: 0.5;
}

tr.drag-over-top td {
    border-top: 2px solid var(--accent-color);
}

tr.drag-over-bottom td {
    border-bottom: 2px solid var(--accent-color);
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #e5ddd1;
    border-radius: 999px;
    transition: background 0.2s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.toggle input:checked + .toggle-slider {
    background: #c4a078;
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.inline-btn:hover {
    background: rgba(176, 139, 92, 0.1);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 9999;
}

.modal.hidden {
    display: none;
}

.modal-card {
    background: #fff;
    border-radius: 10px;
    max-width: 900px;
    width: 100%;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    padding: 20px;
    position: relative;
}

.modal-card img {
    width: 100%;
    height: 100%;
    max-height: 70vh;
    object-fit: contain;
    background: #f7f2ea;
    border-radius: 6px;
}

.modal-body {
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 900px) {
    .modal-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar-left {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    #search {
        width: 100%;
    }
}
