:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --border: #d8dfeb;
    --text: #172033;
    --muted: #66728a;
    --primary: #1f6feb;
    --success: #188038;
    --danger: #c62828;
    --info: #0b7285;
    --secondary: #596579;
    --shadow: 0 18px 40px rgba(23, 32, 51, 0.08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

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

a {
    text-decoration: none;
}

.page-shell {
    min-height: 100vh;
    padding: 32px 20px;
}

.page-container {
    max-width: 1400px;
    margin: 0 auto;
}

.page-container-narrow {
    max-width: 980px;
}

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

.page-header-stacked {
    align-items: center;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--info);
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

h1,
h2 {
    margin: 0;
}

.subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.inventory-card {
    padding: 20px;
}

.error-card pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px;
    margin-top: 12px;
    color: var(--danger);
}

.auth-wrapper {
    display: flex;
    justify-content: center;
}

.auth-card {
    max-width: 460px;
    width: 100%;
}

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

.field-label {
    font-weight: bold;
    display: block;
    margin-bottom: 8px;
}

.text-input,
.text-area,
.filter-input,
.table-input,
.table-textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 12px;
    background: #fff;
    color: var(--text);
}

.text-input:focus,
.text-area:focus,
.filter-input:focus,
.table-input:focus,
.table-textarea:focus {
    outline: 2px solid rgba(31, 111, 235, 0.22);
    border-color: var(--primary);
}

.table-textarea,
.text-area {
    min-height: 78px;
    resize: vertical;
}

.helper-text {
    margin: 0;
    font-size: 0.95rem;
    color: var(--muted);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 11px 14px;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    min-height: 44px;
}

.btn:hover {
    transform: translateY(-1px);
    opacity: 0.96;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-block {
    width: 100%;
}

.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-info { background: var(--info); }
.btn-secondary { background: var(--secondary); }

.flash {
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-weight: bold;
}

.flash-success {
    background: rgba(24, 128, 56, 0.12);
    color: var(--success);
    border: 1px solid rgba(24, 128, 56, 0.2);
}

.flash-error {
    background: rgba(198, 40, 40, 0.1);
    color: var(--danger);
    border: 1px solid rgba(198, 40, 40, 0.2);
}

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

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

.inventory-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1100px;
}

.inventory-table th,
.inventory-table td {
    border-bottom: 1px solid var(--border);
    padding: 14px 12px;
    text-align: left;
    vertical-align: top;
    background: #fff;
}

.inventory-table thead th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

.filters-row th {
    padding-top: 10px;
    padding-bottom: 10px;
}

.inventory-row-new td {
    background: #f8fffb;
}

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

.actions-header,
.actions-cell {
    white-space: nowrap;
}

.actions-cell {
    min-width: 230px;
}

.cell-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.image-thumb {
    width: 78px;
    height: 78px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f1f5f9;
}

.js-preview-image {
    cursor: pointer;
}

.image-upload {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    cursor: pointer;
    background: #fcfdff;
    text-align: center;
    color: var(--muted);
    max-width: 150px;
}

.image-upload-new {
    min-width: 120px;
}

.image-upload-large {
    width: 100%;
    max-width: 280px;
}

.image-file-input {
    display: none;
}

.multiline-text {
    white-space: pre-wrap;
    line-height: 1.45;
}

.is-hidden {
    display: none !important;
}

.is-filter-hidden {
    display: none;
}

.hidden-form {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(23, 32, 51, 0.58);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
}

.modal.is-open {
    display: flex;
}

.modal-card {
    position: relative;
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow);
    width: min(100%, 640px);
    padding: 28px;
}

.modal-card-small {
    width: min(100%, 520px);
}

.modal-card-image {
    width: min(100%, 900px);
    padding: 22px;
}

.modal-preview-image {
    width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 14px;
    background: #f8fafc;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    background: #e5eaf4;
    color: var(--text);
    cursor: pointer;
    font-size: 1.4rem;
}

.modal-form {
    margin-top: 18px;
    display: grid;
    gap: 14px;
}

.modal-actions,
.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.detail-card {
    padding: 28px;
}

.detail-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 28px;
    align-items: start;
}

.detail-layout-edit {
    grid-template-columns: 320px 1fr;
}

.detail-photo-block {
    display: flex;
    justify-content: center;
}

.detail-image {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: #f1f5f9;
}

.detail-content h2 {
    margin-bottom: 18px;
}

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

.detail-grid dt {
    font-weight: bold;
    color: var(--muted);
    margin-bottom: 6px;
}

.detail-grid dd {
    margin: 0;
    line-height: 1.5;
}

.detail-grid-form {
    gap: 16px;
}

.detail-grid-full {
    grid-column: 1 / -1;
}

code {
    background: #eef2f7;
    padding: 2px 6px;
    border-radius: 8px;
}

@media (max-width: 960px) {
    .detail-layout,
    .detail-layout-edit {
        grid-template-columns: 1fr;
    }

    .page-header,
    .page-header-stacked,
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding: 18px 12px;
    }

    .card,
    .detail-card,
    .modal-card {
        padding: 18px;
    }

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

    .btn {
        width: 100%;
    }

    .actions-cell {
        min-width: 200px;
    }
}
