:root {
    --ink: #1d2939;
    --muted: #667085;
    --line: #d9e1ec;
    --panel: #ffffff;
    --page: #f4f7fb;
    --brand: #b9def6;
    --brand-dark: #5d8fb4;
    --accent: #f2b84b;
    --danger: #c33b3b;
    --ok: #5d8fb4;
    --low: #b7791f;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
    text-decoration: none;
}

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

input,
select,
textarea,
button {
    font: inherit;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px clamp(16px, 4vw, 42px);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
    color: var(--brand-dark);
}

.brand img {
    width: 132px;
    height: auto;
}

.brand span {
    border-left: 1px solid var(--line);
    padding-left: 10px;
}

.nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.nav a {
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--muted);
}

.nav a:hover {
    background: #edf7ff;
    color: var(--brand-dark);
}

.logout {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.shell {
    width: min(1180px, calc(100% - 28px));
    margin: 28px auto 56px;
}

.page-head,
.card-line,
.action-row,
.metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-head {
    margin-bottom: 18px;
}

h1,
h2 {
    margin: 0 0 8px;
    line-height: 1.12;
    font-weight: 600;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
}

h2 {
    font-size: 20px;
}

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

strong {
    font-weight: 600;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    padding: 10px 16px;
    background: var(--brand);
    color: #244963;
    font-weight: 600;
    cursor: pointer;
}

.button:hover {
    background: #a6d2ef;
}

.button--secondary {
    background: #e8f6ff;
    color: var(--brand-dark);
}

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

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

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

.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    background: #eef8ff;
    color: #4f7fa5;
    border: 1px solid #c9e8fb;
}

.alert--error {
    background: #fdecec;
    color: #9f1f1f;
    border-color: #f4b8b8;
}

.login-panel,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.login-panel {
    width: min(430px, 100%);
    margin: 60px auto;
}

.login-logo {
    width: 180px;
    margin-bottom: 18px;
}

.form-stack,
.form-grid,
.filters {
    display: grid;
    gap: 14px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-2 {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    background: white;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

.filters {
    grid-template-columns: minmax(220px, 1fr) 220px auto;
    margin-bottom: 18px;
}

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

.product-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.product-image {
    height: 190px;
    background: linear-gradient(135deg, #eef8ff, #fff6df);
    display: grid;
    place-items: center;
    color: var(--brand);
    font-size: 72px;
    font-weight: 650;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card__body {
    padding: 16px;
}

.product-card h2 {
    margin-top: 12px;
}

.product-list-panel {
    padding: 0;
    overflow: hidden;
}

.list-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.product-list {
    display: grid;
}

.product-row {
    display: grid;
    grid-template-columns: 96px minmax(240px, 1fr) minmax(180px, 240px) auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.product-row:last-child {
    border-bottom: 0;
}

.product-thumb {
    width: 96px;
    height: 72px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    overflow: hidden;
    background: linear-gradient(135deg, #eef8ff, #fff6df);
    color: var(--brand-dark);
    font-size: 32px;
    font-weight: 600;
}

.product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-row__main h2 {
    margin: 0;
    font-size: 18px;
}

.product-row__main p {
    margin: 7px 0 0;
}

.product-row__meta {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

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

.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.metric-row {
    align-items: flex-start;
    color: var(--muted);
    font-size: 14px;
    margin-top: 14px;
}

.tag,
.stock {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    background: #eef5ff;
    color: #24558f;
}

.stock {
    background: #eef8ff;
    color: var(--ok);
}

.stock--low {
    background: #fff4d8;
    color: var(--low);
}

.stock--empty {
    background: #fdecec;
    color: var(--danger);
}

.tag--return {
    background: #fff4d8;
    color: var(--low);
}

.product-detail {
    display: grid;
    grid-template-columns: minmax(260px, 420px) 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.gallery {
    display: grid;
    gap: 12px;
}

.gallery figure,
.gallery-empty {
    margin: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.gallery figure img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.gallery figure form {
    padding: 8px 10px;
}

.gallery-empty {
    min-height: 260px;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.product-main {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.info-grid div {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    display: grid;
    gap: 6px;
}

.info-grid strong {
    color: var(--muted);
    font-size: 13px;
}

.info-grid span {
    font-weight: 600;
}

.note {
    border-left: 4px solid var(--accent);
    background: #fff8e8;
    padding: 12px 14px;
    border-radius: 0 6px 6px 0;
    margin: 16px 0;
}

.two-columns {
    display: grid;
    grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
    gap: 18px;
    margin-bottom: 18px;
}

.variant-list,
.list {
    display: grid;
    gap: 10px;
}

.variant-item,
.list-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
}

.user-row {
    display: grid;
    grid-template-columns: minmax(150px, 0.8fr) minmax(280px, 1.4fr) auto;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
}

.user-row em {
    display: block;
    color: var(--muted);
    font-style: normal;
    font-size: 14px;
    margin-top: 3px;
}

.inline-password-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr)) auto;
    gap: 8px;
}

.variant-item span,
.list-row em {
    display: block;
    color: var(--muted);
    font-style: normal;
    font-size: 14px;
}

.variant-form {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.variant-form .button {
    grid-column: 1 / -1;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 940px;
}

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

th {
    color: var(--muted);
    font-size: 13px;
}

.link-danger,
.icon-danger {
    color: var(--danger);
    border: 0;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
}

.icon-danger {
    font-size: 22px;
    line-height: 1;
}

.empty {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    color: var(--muted);
}

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

@media (max-width: 860px) {
    .topbar,
    .logout,
    .page-head,
    .card-line,
    .action-row {
        align-items: flex-start;
    }

    .topbar {
        position: static;
        flex-direction: column;
    }

    .logout {
        margin-left: 0;
        flex-wrap: wrap;
    }

    .page-head,
    .product-detail,
    .two-columns,
    .filters,
    .form-grid,
    .info-grid,
    .product-row,
    .user-row,
    .inline-password-form {
        grid-template-columns: 1fr;
    }

    .product-thumb {
        width: 100%;
        height: 150px;
    }

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

    .page-head,
    .card-line,
    .action-row,
    .page-actions {
        flex-direction: column;
    }
}

@media (max-width: 700px) {
    .table-wrap {
        overflow-x: visible;
    }

    table {
        min-width: 0;
    }

    table,
    thead,
    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    thead {
        display: none;
    }

    tr {
        border: 1px solid var(--line);
        border-radius: 6px;
        margin-bottom: 12px;
        overflow: hidden;
        background: white;
    }

    td {
        display: grid;
        grid-template-columns: minmax(105px, 0.42fr) 1fr;
        gap: 10px;
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
        overflow-wrap: anywhere;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 13px;
        font-weight: 600;
    }
}

@media print {
    @page {
        margin: 12mm;
    }

    body {
        background: white;
        color: #111827;
    }

    .topbar,
    .filters,
    .pagination,
    .no-print,
    .print-button,
    .button,
    .link-danger,
    .icon-danger,
    .gallery figure form,
    .action-row form,
    .variant-form,
    .alert {
        display: none !important;
    }

    .shell {
        width: 100%;
        margin: 0;
    }

    .panel,
    .product-main,
    .gallery figure {
        border: 1px solid #d0d5dd;
        box-shadow: none;
        break-inside: avoid;
    }

    .page-head {
        display: block;
        margin-bottom: 14px;
    }

    .page-head h1,
    .product-main h1 {
        font-size: 24px;
    }

    .product-list-panel {
        border: 0;
        padding: 0;
    }

    .product-row {
        grid-template-columns: 74px 1fr 190px;
        padding: 10px 0;
        break-inside: avoid;
    }

    .product-row .button {
        display: none !important;
    }

    .product-thumb {
        width: 64px;
        height: 50px;
    }

    .product-detail {
        grid-template-columns: 220px 1fr;
    }

    .two-columns {
        display: block;
    }

    .print-variants {
        margin-top: 12px;
    }

    .gallery {
        display: block;
    }

    .gallery figure {
        margin-bottom: 8px;
    }

    .gallery figure:not(:first-child) {
        display: none;
    }

    .table-wrap {
        overflow: visible;
    }

    table {
        min-width: 0;
        font-size: 12px;
    }

    th,
    td {
        padding: 7px 6px;
    }
}
