:root {
    --bg: #f3f6f9;
    --card: #ffffff;
    --text: #1b2430;
    --accent: #0b7285;
    --accent-soft: #e3f4f7;
    --danger: #c92a2a;
    --success: #2b8a3e;
    --border: #d9e2ec;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #eef3f7 0%, #f8fbfd 100%);
    color: var(--text);
}

.container {
    width: min(960px, 100%);
    margin: 0 auto;
    padding: 16px;
}

.header {
    margin-bottom: 12px;
}

.header h1 {
    margin: 0 0 4px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

.menu {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.topnav {
    display: grid;
    gap: 10px;
}

.hamburger {
    width: auto;
    justify-self: start;
    padding: 8px 12px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--border);
}

.menu-links {
    display: none;
    gap: 8px;
    grid-template-columns: 1fr;
}

.menu-links.is-open {
    display: grid;
}

.menu a {
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.menu-links a {
    text-decoration: none;
    padding: 9px 11px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

form {
    display: grid;
    gap: 10px;
}

label {
    display: grid;
    gap: 6px;
    font-size: 14px;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.inline-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

input,
select,
textarea,
button {
    width: 100%;
    padding: 10px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

button {
    background: var(--accent);
    color: white;
    border: 0;
    font-weight: 700;
    cursor: pointer;
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.alert-error {
    background: #fff5f5;
    color: var(--danger);
    border: 1px solid #ffc9c9;
}

.alert-success {
    background: #ebfbee;
    color: var(--success);
    border: 1px solid #b2f2bb;
}

.hint {
    margin: 6px 0 0;
    color: #5c6b7a;
    font-size: 13px;
}

.list {
    margin: 0;
    padding-left: 18px;
}

.product {
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    margin-top: 10px;
}

.user-row {
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    margin-top: 10px;
}

.product:first-child {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}

.user-row:first-child {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}

.actions {
    display: flex;
    gap: 8px;
}

.right-actions {
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0;
}

.right-actions button {
    width: auto;
    min-width: 190px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

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

.btn-secondary {
    background: #495057;
}

.file-inline {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.btn-icon-camera {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px dashed var(--border);
}

.list-row:first-child {
    border-top: 0;
}

.row-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.photo-item {
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    margin-top: 10px;
}

.photo-item img {
    width: 100%;
    max-width: 260px;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
}

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

.photo-grid img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.gallery-shell {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

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

.thumb-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    padding: 6px;
    border-radius: 10px;
    text-align: left;
    font-weight: 600;
}

.thumb-btn img {
    width: 100%;
    height: 74px;
    object-fit: cover;
    border-radius: 7px;
    margin-bottom: 6px;
}

.thumb-btn span {
    font-size: 12px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumb-btn.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(11, 114, 133, 0.2);
}

.gallery-workbench {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    background: #fafcfd;
    display: grid;
    gap: 10px;
}

.card-sub {
    margin-top: 12px;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: #fbfdff;
}

.cat-box {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    display: grid;
    gap: 6px;
}

.cat-box legend {
    font-weight: 700;
    font-size: 14px;
    padding: 0 6px;
}

.cat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 6px 8px;
    padding-left: calc(8px + (var(--cat-depth, 0) * 22px));
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(11, 114, 133, calc(var(--cat-depth, 0) * 0.04)) 0%, rgba(11, 114, 133, 0.02) 100%);
    border-left: calc(var(--cat-depth, 0) * 2px) solid rgba(11, 114, 133, 0.25);
}

.cat-node {
    border-radius: 8px;
}

.cat-node summary {
    list-style: none;
    cursor: pointer;
}

.cat-node summary::-webkit-details-marker {
    display: none;
}

.cat-node .cat-item {
    margin-top: 4px;
}

.cat-leaf {
    margin-top: 4px;
}

.cat-children {
    display: grid;
    gap: 2px;
}

.cat-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

#selectedImagePreview {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.hidden {
    display: none !important;
}

.camera-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding: 12px;
    overflow-y: auto;
}

.camera-dialog {
    width: min(520px, 100%);
    background: #111;
    border-radius: 12px;
    padding: 10px;
    color: #fff;
    margin: auto 0;
    max-height: calc(100dvh - 24px);
    overflow: auto;
}

.camera-dialog video {
    width: 100%;
    border-radius: 10px;
    background: #000;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.camera-actions {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.crop-dialog {
    max-width: 520px;
}

#cropCanvas {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    display: block;
    border-radius: 10px;
    border: 1px solid #2b2b2b;
    touch-action: none;
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .right-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .right-actions button {
        width: 100%;
        min-width: 0;
    }

    .camera-modal {
        padding: 8px;
    }

    .camera-dialog {
        width: 100%;
        margin: 0;
        max-height: calc(100dvh - 16px);
    }

    #cropCanvas {
        max-width: 100%;
    }
}

@media (min-width: 900px) {
    .hamburger {
        display: none;
    }

    .menu-links {
        display: flex;
        flex-wrap: wrap;
    }
}
