:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --line: #d9e1ee;
    --ink: #18211f;
    --muted: #64706b;
    --brand: #0033A0;
    --brand-2: #0B5CAD;
    --danger: #b42318;
    --soft: #eef4ff;
}

html,
body {
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

a {
    color: var(--brand);
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 24px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.brand-logo {
    display: block;
    width: auto;
    height: 46px;
    max-width: 118px;
    object-fit: contain;
}

.login-logo {
    height: 58px;
    max-width: 140px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.main-nav a,
.user-block,
.topbar-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: .94rem;
}

.main-nav a.active {
    background: var(--soft);
    color: var(--brand);
    font-weight: 700;
}

.user-block {
    margin-left: auto;
    color: var(--ink);
}

.app-content {
    padding: 24px;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-heading h1 {
    margin: 0;
    font-size: 1.65rem;
    line-height: 1.2;
}

.page-heading p,
.login-heading p {
    margin: 4px 0 0;
    color: var(--muted);
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(280px, 36%) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.maintenance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.panel,
.login-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(24, 33, 31, .05);
}

.panel {
    padding: 16px;
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-title h2 {
    margin: 0;
    font-size: 1.08rem;
}

.panel-title span {
    color: var(--muted);
    font-size: .9rem;
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.toolbar .input-group {
    flex: 1 1 360px;
}

.toolbar .product-search-group {
    flex: 1 1 auto;
    min-width: 0;
}

.product-search-group .form-control {
    min-width: 220px;
}

.region-filter-select {
    flex: 0 0 260px;
    min-width: 220px;
    max-width: 320px;
}

.region-filter-label {
    color: var(--brand);
}

.btn {
    border-radius: 6px;
}

.btn-cle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 700;
}

.btn-cle:hover,
.btn-cle:focus {
    background: #002776;
    border-color: #002776;
    color: #fff;
}

.btn-outline-cle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-color: var(--brand);
    color: var(--brand);
    font-weight: 700;
}

.btn-outline-cle:hover {
    background: var(--brand);
    color: #fff;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--brand);
}

.icon-button:hover {
    background: var(--soft);
}

.icon-button.danger {
    color: var(--danger);
}

.form-control,
.form-select,
.input-group-text {
    border-color: var(--line);
    border-radius: 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-grid.compact {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2 {
    grid-column: span 2;
}

.switch-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0;
}

.switch-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcfa;
}

.compact-switches {
    grid-template-columns: minmax(0, 1fr);
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.product-list {
    display: grid;
    gap: 8px;
}

.product-row,
.result-row {
    width: 100%;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    text-align: left;
}

.product-row.active,
.result-row.active {
    border-color: var(--brand);
    background: #eef4ff;
}

.thumb {
    width: 72px;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 6px;
    background: var(--soft);
    color: var(--muted);
}

.thumb img,
.component-photo img,
.uploaded-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-row-body {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.product-row-body strong,
.product-row-body span,
.product-row-body small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-row-body span,
.product-row-body small {
    color: var(--muted);
}

.product-table {
    margin-bottom: 0;
}

.product-table th {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.product-table-row {
    cursor: pointer;
}

.product-table-row:hover {
    background: #f6f9ff;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .92rem;
}

.pagination-actions {
    display: flex;
    gap: 8px;
}

.table-product-cell {
    min-width: 240px;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.table-thumb {
    width: 52px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
}

.status-pill.on {
    color: #174b2f;
    background: #e2f2e8;
}

.status-pill.off {
    color: #5d6460;
    background: #ecefed;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.on {
    background: #257a4a;
}

.status-dot.off {
    background: #a8b0aa;
}

.components-panel {
    margin-top: 18px;
}

.preview-panel {
    margin-top: 18px;
}

.detail-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
    gap: 18px;
    align-items: stretch;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.detail-header h2 {
    margin: 4px 0;
    font-size: 1.75rem;
    line-height: 1.18;
}

.detail-header p {
    margin: 0;
    color: var(--muted);
    font-size: 1rem;
}

.detail-header img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    background: var(--soft);
}

.eyebrow {
    display: inline-flex;
    color: var(--brand-2);
    font-weight: 800;
    text-transform: uppercase;
    font-size: .78rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.info-grid div {
    min-height: 78px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}

.info-grid .wide {
    grid-column: span 2;
}

.info-grid span,
.component-copy span,
.component-copy small {
    display: block;
    color: var(--muted);
    font-size: .86rem;
}

.info-grid strong {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.feature-badge {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-weight: 700;
    font-size: .88rem;
}

.feature-badge.on {
    border-color: rgba(37, 122, 74, .35);
    background: #edf8f0;
    color: #257a4a;
}

.feature-badge.off {
    background: #f6f6f4;
    color: var(--muted);
}

.detail-section {
    margin-top: 22px;
}

.detail-section h3 {
    margin: 0 0 10px;
    font-size: 1.08rem;
}

.detail-section > p {
    margin: 0;
    padding: 12px;
    border-left: 4px solid var(--brand);
    background: #fbfcfa;
    border-radius: 6px;
}

.component-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.component-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.component-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--soft);
    color: var(--muted);
}

.component-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.component-copy {
    padding: 10px;
}

.component-copy strong {
    display: block;
    margin: 2px 0;
}

.component-copy p {
    margin: 8px 0 0;
    color: var(--ink);
}

.component-editor {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    margin-bottom: 16px;
}

.uploaded-preview {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.uploaded-preview img,
.uploaded-preview-image {
    width: 96px;
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    object-fit: contain;
    background: var(--soft);
}

.uploaded-preview-image {
    display: grid;
    place-items: center;
    overflow: hidden;
}

.uploaded-preview-image img {
    width: 100%;
    height: 100%;
}

.logo-upload-preview {
    grid-template-columns: 136px minmax(0, 1fr);
}

.uploaded-preview .brand-logo-preview {
    width: 136px;
    height: 102px;
    aspect-ratio: 4 / 3;
    box-sizing: border-box;
    padding: 6px;
    border-radius: 6px;
    background: #fff;
    object-fit: contain;
}

.component-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.component-item {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.component-photo {
    width: 96px;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 0;
    border-radius: 6px;
    background: var(--soft);
    color: var(--muted);
}

.component-body {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.component-body span,
.component-body small {
    color: var(--muted);
    font-size: .86rem;
}

.component-actions {
    display: grid;
    gap: 6px;
}

.empty-state {
    min-height: 120px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    text-align: center;
}

.empty-state.compact {
    min-height: 64px;
}

.box-maintenance {
    grid-column: 1 / -1;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}

.table-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.table-heading h3 {
    margin: 0;
    font-size: 1rem;
}

.maintenance-table {
    margin-bottom: 0;
}

.maintenance-table td:first-child {
    display: grid;
    gap: 2px;
}

.maintenance-table small {
    color: var(--muted);
}

.selected-card {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    min-height: 84px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.selected-card-media,
.picker-image {
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 0;
    border-radius: 6px;
    background: var(--soft);
    color: var(--muted);
}

.selected-card-media {
    width: 92px;
    aspect-ratio: 4 / 3;
}

.selected-card-media img,
.picker-image img,
.selected-material-chip img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.selected-card-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.selected-card-copy strong,
.selected-card-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-card-copy small,
.material-selector-head span,
.picker-header p,
.picker-copy span,
.picker-copy p {
    color: var(--muted);
}

.material-maintenance {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.material-selector-grid,
.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.assembly-sections {
    display: grid;
    gap: 16px;
}

.assembly-section {
    display: grid;
    gap: 10px;
}

.assembly-section h4 {
    margin: 0;
    color: var(--brand);
    font-size: .96rem;
    font-weight: 800;
}

.material-selector-grid.two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.material-selector-card,
.picker-card {
    display: grid;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.picker-card.selected {
    border-color: var(--brand);
    background: #f4f8ff;
}

.material-selector-head,
.picker-header,
.picker-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.material-selector-head strong,
.picker-copy strong {
    display: block;
}

.checkbox-card .material-selector-head {
    align-items: center;
}

.checkbox-card input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.material-selector-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcff;
}

.material-selector-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.material-selector-toggle strong,
.material-selector-toggle small {
    display: block;
}

.material-selector-toggle small {
    color: var(--muted);
}

.picker-option-toggle {
    margin-bottom: 12px;
}

.material-preview {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.selected-material-preview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
}

.material-preview-image,
.selected-material-preview-image,
.photo-upload-preview {
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 6px;
    background: var(--soft);
    color: var(--muted);
}

.material-preview-image,
.selected-material-preview-image {
    width: 76px;
    aspect-ratio: 4 / 3;
}

.material-preview-image img,
.selected-material-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.photo-upload-preview img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.material-preview strong,
.selected-material-preview strong,
.selected-material-preview small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.material-preview small,
.selected-material-preview small {
    color: var(--muted);
}

.selected-material-preview-grid {
    display: grid;
    gap: 8px;
}

.selected-material-preview {
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcff;
}

.selected-material-preview-image {
    grid-column: 1;
    grid-row: 1;
}

.selected-material-preview-copy {
    grid-column: 1 / -1;
    grid-row: 2;
}

.selected-material-preview button {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--danger);
}

.product-photos-panel {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.photo-upload-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(170px, auto);
    grid-template-areas:
        "cigar open open front"
        "cigar open open top"
        "bottom back left right";
    gap: 12px;
    align-items: stretch;
}

.photo-upload-card {
    display: grid;
    grid-template-rows: auto auto;
    gap: 8px;
    min-height: 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.photo-slot-cigar {
    grid-area: cigar;
    grid-template-rows: minmax(0, 1fr) auto;
}

.photo-slot-cigar .photo-upload-preview {
    width: auto;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    justify-self: center;
    align-self: center;
}

.photo-slot-front {
    grid-area: front;
}

.photo-slot-top {
    grid-area: top;
}

.photo-slot-bottom {
    grid-area: bottom;
}

.photo-slot-left {
    grid-area: left;
}

.photo-slot-right {
    grid-area: right;
}

.photo-slot-back {
    grid-area: back;
}

.photo-slot-open {
    grid-area: open;
    grid-template-rows: minmax(0, 1fr) auto;
}

.photo-slot-open .photo-upload-preview {
    width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    justify-self: stretch;
    align-self: stretch;
}

.photo-slot-cigar .photo-upload-preview img,
.photo-slot-open .photo-upload-preview img {
    width: auto;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
}

.photo-upload-preview {
    width: 100%;
    height: auto;
    max-height: none;
    min-height: 0;
    justify-self: stretch;
    align-self: center;
    aspect-ratio: 4 / 1;
    overflow: hidden;
}

.photo-upload-body {
    display: grid;
    gap: 6px;
}

.photo-upload-body small {
    color: var(--muted);
    font-size: .78rem;
}

.selected-material-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.selected-material-chip {
    display: inline-grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-height: 32px;
    padding: 2px 4px 2px 2px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    font-size: .84rem;
}

.selected-material-chip img {
    width: 28px;
    aspect-ratio: 1;
    border-radius: 4px;
}

.selected-material-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-material-chip button {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--danger);
}

.picker-header {
    margin-bottom: 12px;
}

.picker-header h3,
.picker-header p,
.picker-copy p {
    margin: 0;
}

.picker-image {
    width: 100%;
    aspect-ratio: 4 / 3;
}

.image-ratio-4x3 {
    aspect-ratio: 4 / 3;
}

.image-ratio-3x1 {
    aspect-ratio: 3 / 1;
}

.image-ratio-1x1 {
    aspect-ratio: 1 / 1;
}

.image-ratio-1x3 {
    aspect-ratio: 1 / 3;
}

.image-ratio-1x2 {
    aspect-ratio: 1 / 2;
}

.image-ratio-4x1 {
    aspect-ratio: 4 / 1;
}

.image-ratio-2x1 {
    aspect-ratio: 2 / 1;
}

.material-preview-image.image-ratio-3x1,
.selected-material-preview-image.image-ratio-3x1 {
    width: 150px;
}

.material-preview-image.image-ratio-4x1,
.selected-material-preview-image.image-ratio-4x1 {
    width: 170px;
}

.material-preview-image.image-ratio-2x1,
.selected-material-preview-image.image-ratio-2x1 {
    width: 130px;
}

.material-preview-image.image-ratio-1x1,
.selected-material-preview-image.image-ratio-1x1 {
    width: 82px;
}

.material-preview-image.image-ratio-1x3,
.selected-material-preview-image.image-ratio-1x3 {
    width: 64px;
}

.picker-copy {
    min-width: 0;
}

.picker-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.working-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--soft);
    color: var(--brand);
    font-weight: 700;
}

.modal-title {
    font-size: 1.15rem;
}

.modal-local-alert {
    margin-bottom: 14px;
}

.login-wrap {
    min-height: calc(100vh - 112px);
    display: grid;
    place-items: center;
}

.login-panel {
    width: min(420px, 100%);
    padding: 24px;
}

.login-heading {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.login-heading h1 {
    margin: 0;
    font-size: 1.4rem;
}

.setup-footer {
    margin-top: 14px;
    text-align: center;
}

.stack-form {
    display: grid;
    gap: 8px;
}

.inline-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.maintenance-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.maintenance-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.maintenance-row > button:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    text-align: left;
}

.maintenance-thumb {
    width: 42px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 4px;
    background: var(--soft);
}

.maintenance-thumb.brand-logo-thumb {
    width: 56px;
    height: 42px;
    aspect-ratio: 4 / 3;
    box-sizing: border-box;
    padding: 3px;
    object-fit: contain;
    background: #fff;
}

.share-layout {
    display: grid;
    grid-template-columns: minmax(340px, 42%) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.share-selection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 0 10px;
}

.share-selection-header strong,
.share-selection-header span {
    display: block;
}

.share-selection-header span {
    color: var(--muted);
    font-size: .9rem;
}

.share-product-list {
    display: grid;
    gap: 8px;
    max-height: 520px;
    overflow: auto;
    padding-right: 4px;
}

.share-product-row {
    display: grid;
    grid-template-columns: auto 52px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.share-product-row.selected {
    border-color: var(--brand);
    background: #f4f8ff;
}

.share-product-row .form-check-input {
    margin: 0;
}

.share-generate-button {
    width: 100%;
    margin-top: 14px;
}

.generated-link {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.table-actions {
    display: inline-flex;
    gap: 6px;
}

.table-actions .icon-button {
    text-decoration: none;
}

.share-public-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.share-public-header h1 {
    margin: 0;
    font-size: 1.65rem;
}

.share-public-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.share-public-panel {
    max-width: 920px;
    margin: 0 auto;
}

.share-public-list {
    position: sticky;
    top: 88px;
    display: grid;
    gap: 8px;
}

.share-public-detail {
    min-height: calc(100vh - 140px);
}

.compact-detail-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    margin-bottom: 18px;
}

.shared-photo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.shared-photo {
    aspect-ratio: 4 / 3;
}

.empty-detail {
    min-height: calc(100vh - 190px);
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    text-align: center;
    padding: 18px;
}

#blazor-error-ui {
    display: none;
}

@media (max-width: 1050px) {
    .workspace-grid,
    .maintenance-grid,
    .share-layout,
    .share-public-layout {
        grid-template-columns: 1fr;
    }

    .form-grid.compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .photo-upload-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: minmax(150px, auto);
        grid-template-areas:
            "cigar open"
            "cigar open"
            "front top"
            "bottom back"
            "left right";
    }

    .share-public-list {
        position: static;
    }
}

@media (max-width: 720px) {
    .toolbar {
        flex-wrap: wrap;
    }

    .toolbar .input-group {
        flex: 1 1 100%;
    }

    .product-search-group {
        flex-wrap: wrap;
    }

    .product-search-group .form-control,
    .product-search-group .region-filter-select {
        flex: 1 1 calc(100% - 42px);
        max-width: none;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    .main-nav {
        width: 100%;
        flex-wrap: wrap;
    }

    .user-block {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }

    .app-content {
        padding: 16px;
    }

    .page-heading {
        flex-direction: column;
    }

    .form-grid,
    .form-grid.compact,
    .switch-grid,
    .material-selector-grid.two-column,
    .detail-header,
    .info-grid,
    .shared-photo-grid,
    .compact-detail-header {
        grid-template-columns: 1fr;
    }

    .photo-upload-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        grid-template-areas:
            "cigar"
            "open"
            "front"
            "top"
            "bottom"
            "left"
            "right"
            "back";
    }

    .photo-upload-card {
        grid-template-rows: auto auto;
    }

    .photo-slot-cigar .photo-upload-preview,
    .photo-upload-preview {
        width: 100%;
        height: auto;
        max-height: none;
    }

    .span-2 {
        grid-column: span 1;
    }

    .info-grid .wide {
        grid-column: span 1;
    }

    .product-row {
        grid-template-columns: 64px minmax(0, 1fr) auto;
    }

    .thumb {
        width: 64px;
    }

    .component-item {
        grid-template-columns: 88px minmax(0, 1fr);
    }

    .selected-card {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .selected-card .btn,
    .selected-card .icon-button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .selected-card-media {
        width: 72px;
    }

    .component-actions {
        grid-column: 1 / -1;
        display: flex;
    }

    .pagination-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .pagination-actions {
        justify-content: space-between;
    }

    .share-selection-header,
    .share-public-header {
        align-items: stretch;
        flex-direction: column;
    }
}
