:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d9e2ef;
    --primary: #356dff;
    --primary-dark: #214fd0;
    --danger: #d92d20;
    --warning: #fffaeb;
    --warning-line: #fedf89;
    --success-bg: #ecfdf3;
    --success-text: #027a48;
    --error-bg: #fef3f2;
    --error-text: #b42318;
    --info-bg: #eff8ff;
    --info-text: #175cd3;
    --radius: 16px;
    --shadow: 0 18px 55px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 260px;
    background: #101828;
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand strong { display: block; }
.brand small { color: #aeb8ca; display: block; margin-top: 2px; }
.brand-mark {
    width: 44px; height: 44px; border-radius: 12px;
    background: linear-gradient(135deg, #7ca5ff, #345dff);
    display: grid; place-items: center; font-weight: 800; color: #fff;
}
.nav { display: grid; gap: 6px; margin-top: 30px; }
.nav a {
    color: #d7deea; padding: 11px 12px; border-radius: 10px; display: block;
}
.nav a.active, .nav a:hover { background: #26344d; color: #fff; text-decoration: none; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #344054; padding-top: 18px; display: grid; gap: 5px; }
.sidebar-footer a { color: #b7cdfd; }
.sidebar-footer small { color: #98a2b3; }

.main { flex: 1; padding: 28px; min-width: 0; }
.main-centered { display: grid; place-items: center; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 28px; }
.pill, .tag {
    display: inline-flex; align-items: center; border: 1px solid var(--line);
    border-radius: 999px; padding: 4px 9px; background: #fff; color: #344054; font-size: 12px;
}

.cards { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: var(--text); }
.card:hover { text-decoration: none; transform: translateY(-1px); }
.card span { color: var(--muted); display: block; margin-bottom: 10px; }
.card strong { font-size: 34px; }
.card.warning { background: var(--warning); border-color: var(--warning-line); }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(320px, 0.75fr) minmax(460px, 1.25fr); }
.grid.two.uneven { grid-template-columns: minmax(340px, 0.8fr) minmax(600px, 1.4fr); }
.grid.two.uneven-left { grid-template-columns: minmax(320px, 0.65fr) minmax(620px, 1.35fr); }
.grid.three { grid-template-columns: minmax(260px, 0.7fr) minmax(270px, 0.8fr) minmax(420px, 1.2fr); }
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    min-width: 0;
}
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-header h2, h3 { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid.single { grid-template-columns: 1fr; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 6px; color: #344054; font-weight: 600; font-size: 14px; }
input, select, textarea {
    width: 100%; border: 1px solid #cfd8e7; border-radius: 10px; padding: 10px 11px;
    font: inherit; color: var(--text); background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(53, 109, 255, 0.18); border-color: var(--primary); }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 15px; }
.compact-form input, .compact-form select { max-width: 220px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { max-width: 310px; }

.btn {
    border: 1px solid var(--line); background: #fff; color: #344054; border-radius: 10px;
    padding: 10px 14px; cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { text-decoration: none; background: #f9fafb; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn.small { padding: 6px 9px; font-size: 12px; border-radius: 8px; }
.btn.full { width: 100%; }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-weight: 700; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.empty.large { padding: 80px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.table-wrap.tall { max-height: 620px; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #667085; }
tr:last-child td { border-bottom: 0; }
.row-warning td { background: var(--warning); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.list { display: grid; gap: 8px; }
.list-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--text); display: grid; gap: 3px; }
.list-item:hover, .list-item.active { text-decoration: none; border-color: var(--primary); background: #f5f8ff; }
.list-item span { color: var(--muted); }
.list-item em { color: #667085; font-style: normal; font-size: 12px; }

.login-body, .install-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #ecf3ff, #f8fafc); }
.login-card, .install-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 26px; box-shadow: var(--shadow); width: min(100%, 480px); }
.install-card { width: min(100%, 720px); }
.brand-login { margin-bottom: 20px; }
.install-card h1 { margin-bottom: 5px; }
.install-card h2 { grid-column: span 2; margin: 12px 0 0; }

.map-layout { grid-template-columns: 360px minmax(720px, 1fr); }
.map-panel { overflow: hidden; }
.store-map {
    position: relative;
    width: 100%;
    height: 600px;
    min-width: 700px;
    border: 2px solid #c8d5ea;
    border-radius: 18px;
    overflow: hidden;
    background-image: linear-gradient(#eef3fb 1px, transparent 1px), linear-gradient(90deg, #eef3fb 1px, transparent 1px);
    background-size: 24px 24px;
    margin-bottom: 16px;
}
.map-object {
    position: absolute;
    color: #fff;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.2);
    border: 2px solid rgba(255,255,255,.55);
    cursor: grab;
    display: grid;
    align-content: start;
    gap: 1px;
    user-select: none;
    overflow: hidden;
}
.map-object.dragging { cursor: grabbing; opacity: .88; }
.map-object strong { font-size: 13px; }
.map-object span, .map-object small { font-size: 11px; opacity: .92; }
.map-object a { color: #fff; font-size: 11px; text-decoration: underline; justify-self: start; }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; }

.shelf-grid {
    display: grid;
    grid-template-columns: 64px repeat(var(--bays), minmax(110px, 1fr));
    gap: 8px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafc;
    margin-bottom: 16px;
}
.level-label { display: grid; place-items: center; color: #667085; font-weight: 800; }
.shelf-slot {
    min-height: 108px;
    border: 1px dashed #b7c4d8;
    border-radius: 12px;
    background: #fff;
    padding: 10px;
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 4px;
    align-content: start;
    color: var(--text);
}
.shelf-slot:hover { border-color: var(--primary); background: #f5f8ff; }
.shelf-slot small { color: var(--muted); }
.shelf-slot span { font-size: 13px; }
.shelf-slot em { color: #667085; font-size: 12px; font-style: normal; }
.slot-form { margin-bottom: 16px; }
.delete-plan-form { margin-top: 12px; }

@media (max-width: 1100px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
    .grid.two, .grid.two.uneven, .grid.two.uneven-left, .grid.three, .map-layout { grid-template-columns: 1fr; }
    .sidebar { width: 220px; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; }
    .main { padding: 18px; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .cards { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
}

/* Full-screen shelf planner editor */
.planner-page {
    display: grid;
    gap: 14px;
}
.planner-titlebar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}
.planner-titlebar h2 {
    margin: 0;
    font-size: 28px;
}
.planner-titlebar p {
    margin: 4px 0 0;
    color: var(--muted);
}
.planner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.slim-panel {
    padding: 12px;
    box-shadow: none;
}
.plan-switcher {
    display: grid;
    grid-template-columns: minmax(260px, 420px) 1fr auto;
    gap: 12px;
    align-items: end;
}
.plan-meta-form {
    margin: 0;
}
.empty-planner-state {
    min-height: 420px;
    display: grid;
    place-items: center;
    text-align: center;
}
.planner-workspace {
    display: grid;
    grid-template-columns: 285px minmax(680px, 1fr) 300px;
    gap: 14px;
    min-height: calc(100vh - 185px);
    align-items: stretch;
}
.planner-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 16px;
    min-width: 0;
}
.product-library-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 190px);
    overflow: hidden;
}
.product-library-panel h3,
.product-library-panel h4,
.selected-product-panel h3 {
    margin: 0;
}
.small-text {
    font-size: 12px;
    margin: 0;
}
.category-chips {
    display: grid;
    gap: 6px;
    max-height: 180px;
    overflow: auto;
}
.category-chip {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
    color: #344054;
    font-weight: 700;
}
.category-chip:hover,
.category-chip.active {
    border-color: var(--primary);
    background: #f5f8ff;
    color: var(--primary);
}
.category-chip span {
    border-radius: 999px;
    background: #eef4ff;
    color: var(--primary);
    padding: 1px 7px;
}
.product-list {
    display: grid;
    gap: 8px;
    overflow: auto;
    padding-right: 3px;
}
.product-pick {
    display: grid;
    grid-template-columns: 42px 1fr 22px;
    gap: 10px;
    align-items: center;
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 8px;
    text-align: left;
    cursor: pointer;
    color: var(--text);
}
.product-pick:hover,
.product-pick.active {
    border-color: var(--primary);
    background: #f5f8ff;
}
.product-pick strong {
    display: block;
    font-size: 13px;
}
.product-pick small {
    color: var(--muted);
}
.product-pick em {
    color: var(--primary);
    font-style: normal;
    font-size: 20px;
    font-weight: 800;
}
.product-thumb,
.product-pack {
    width: 38px;
    height: 38px;
    border: 1px solid #dce6f5;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: #f8fafc;
    font-size: 22px;
}
.product-thumb.large {
    width: 64px;
    height: 64px;
    font-size: 34px;
}
.planner-canvas {
    overflow: auto;
    padding: 14px;
}
.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.visual-shelf-grid {
    display: grid;
    gap: 10px;
    min-width: 720px;
}
.visual-level-label {
    display: none;
}
.visual-slot-row {
    display: grid;
    grid-template-columns: 150px repeat(var(--bays), minmax(128px, 1fr));
    gap: 8px;
    min-height: 118px;
}
.visual-slot-row::before {
    content: attr(data-label);
}
.visual-shelf-grid .visual-level-label + .visual-slot-row {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    background: #fbfdff;
}
.visual-shelf-grid .visual-level-label + .visual-slot-row .visual-slot:first-child {
    margin-left: 0;
}
.visual-shelf-grid .visual-level-label {
    display: grid;
}
.visual-level-label {
    position: absolute;
}
.visual-shelf-grid {
    counter-reset: shelfrow;
}
.visual-level-label + .visual-slot-row {
    position: relative;
    padding-left: 160px !important;
}
.visual-level-label + .visual-slot-row::before {
    position: absolute;
    left: 10px;
    top: 10px;
    bottom: 10px;
    width: 135px;
    border-right: 1px solid var(--line);
    display: grid;
    place-content: center start;
    padding-left: 8px;
    font-weight: 800;
    color: var(--text);
    white-space: pre-line;
}
.visual-level-label:nth-of-type(1) + .visual-slot-row::before { content: '↑\A Top Shelf'; }
.visual-level-label:nth-of-type(2) + .visual-slot-row::before { content: '↕\A High-Mid Shelf'; }
.visual-level-label:nth-of-type(3) + .visual-slot-row::before { content: '–\A Middle Shelf'; }
.visual-level-label:nth-of-type(4) + .visual-slot-row::before { content: '↓\A Low-Mid Shelf'; }
.visual-level-label:nth-of-type(5) + .visual-slot-row::before { content: '⇣\A Bottom Shelf'; }
.visual-slot {
    min-height: 104px;
    border: 1px dashed #bac8db;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    padding: 9px;
    text-align: left;
    cursor: pointer;
    display: grid;
    align-content: start;
    justify-items: start;
    gap: 4px;
}
.visual-slot:hover,
.visual-slot.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(53, 109, 255, 0.14);
}
.visual-slot.filled {
    border-style: solid;
}
.visual-slot strong {
    font-size: 12px;
    line-height: 1.15;
}
.visual-slot small {
    color: var(--muted);
    font-size: 11px;
}
.empty-label {
    color: #52637c;
    font-weight: 700;
}
.planner-tip {
    margin-top: 12px;
    color: #52637c;
    font-size: 13px;
}
.selected-product-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: calc(100vh - 190px);
    overflow: auto;
}
.selected-preview {
    display: grid;
    grid-template-columns: 74px 1fr;
    gap: 12px;
    align-items: center;
}
.selected-preview strong,
.selected-preview small,
.selected-preview b {
    display: block;
}
.selected-preview small {
    color: var(--muted);
    margin: 4px 0 8px;
}
.selected-preview b {
    color: var(--primary);
    font-size: 20px;
}
.editor-form {
    gap: 11px;
}
.remove-slot-form {
    margin-top: auto;
}
.btn.outline.danger {
    background: #fff;
    color: var(--danger);
    border-color: #f3b3ad;
}
.btn.outline.danger:hover {
    background: #fff7f7;
}
.modal[hidden] {
    display: none;
}
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}
.modal-card {
    position: relative;
    width: min(720px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
}

@media (max-width: 1300px) {
    .planner-workspace {
        grid-template-columns: 250px minmax(560px, 1fr) 280px;
    }
    .visual-slot-row {
        grid-template-columns: 140px repeat(var(--bays), minmax(116px, 1fr));
    }
}

@media (max-width: 1050px) {
    .plan-switcher,
    .planner-workspace {
        grid-template-columns: 1fr;
    }
    .product-library-panel,
    .selected-product-panel {
        max-height: none;
    }
}

/* Corrections for dynamic shelf row labels in the full-screen editor. */
.visual-slot-row {
    grid-template-columns: repeat(var(--bays), minmax(128px, 1fr));
}
.visual-level-label + .visual-slot-row::before {
    content: attr(data-label);
}
.visual-level-label:nth-of-type(1) + .visual-slot-row::before,
.visual-level-label:nth-of-type(2) + .visual-slot-row::before,
.visual-level-label:nth-of-type(3) + .visual-slot-row::before,
.visual-level-label:nth-of-type(4) + .visual-slot-row::before,
.visual-level-label:nth-of-type(5) + .visual-slot-row::before {
    content: attr(data-label);
}
@media (max-width: 1300px) {
    .visual-slot-row {
        grid-template-columns: repeat(var(--bays), minmax(116px, 1fr));
    }
}

/* Bug fix: keep shelf row names in their own left rail and stop the hidden
   generated labels from overlapping the first shelf slot. */
.visual-shelf-grid > .visual-level-label {
    display: none !important;
    position: static !important;
}
.visual-shelf-grid > .visual-level-label + .visual-slot-row {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--bays), minmax(150px, 1fr)) !important;
    gap: 10px;
    min-height: 118px;
    padding: 10px 10px 10px 165px !important;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdff;
}
.visual-shelf-grid > .visual-level-label + .visual-slot-row::before {
    content: attr(data-label) !important;
    position: absolute;
    left: 12px;
    top: 10px;
    bottom: 10px;
    width: 135px;
    border-right: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 8px;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
    white-space: normal;
    pointer-events: none;
}
.visual-shelf-grid > .visual-level-label + .visual-slot-row .visual-slot {
    min-width: 0;
}
@media (max-width: 1300px) {
    .visual-shelf-grid > .visual-level-label + .visual-slot-row {
        grid-template-columns: repeat(var(--bays), minmax(132px, 1fr)) !important;
    }
}

/* Add-row/add-column controls in shelf planner toolbar. */
.toolbar-form {
    margin: 0;
    display: inline-flex;
}
.toolbar-form .btn {
    white-space: nowrap;
}

/* Right-click shelf planner context menu. */
.shelf-context-menu {
    position: fixed;
    z-index: 80;
    width: 210px;
    padding: 7px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .18);
}
.shelf-context-menu[hidden] {
    display: none;
}
.shelf-context-menu button {
    width: 100%;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    padding: 9px 10px;
    text-align: left;
    font-weight: 700;
    cursor: pointer;
}
.shelf-context-menu button:hover:not(:disabled) {
    background: #f5f8ff;
    color: var(--primary);
}
.shelf-context-menu button.danger {
    color: var(--danger);
}
.shelf-context-menu button.danger:hover:not(:disabled) {
    background: #fff7f7;
}
.shelf-context-menu button:disabled {
    color: #9aa7b8;
    cursor: not-allowed;
}
.shelf-context-menu hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 6px 4px;
}

/* Polished action feedback: toast notifications and confirmation modal. */
.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 120;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100vw - 36px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: grid;
    grid-template-columns: 38px 1fr 28px;
    gap: 10px;
    align-items: start;
    padding: 13px 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-left-width: 5px;
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
    animation: toastIn .22s ease-out both;
}
.toast-success { border-left-color: #12b76a; }
.toast-error { border-left-color: #f04438; }
.toast-info { border-left-color: var(--primary); }
.toast-icon {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-weight: 900;
    background: #eef4ff;
    color: var(--primary);
}
.toast-success .toast-icon { background: #ecfdf3; color: #027a48; }
.toast-error .toast-icon { background: #fff1f3; color: #b42318; }
.toast-body strong {
    display: block;
    font-size: 13px;
    margin-bottom: 2px;
    text-transform: capitalize;
}
.toast-body p {
    margin: 0;
    color: #475467;
    font-size: 13px;
    line-height: 1.35;
}
.toast-close {
    border: 0;
    background: transparent;
    color: #667085;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    border-radius: 8px;
}
.toast-close:hover { background: #f2f4f7; color: var(--text); }
.toast-leaving { animation: toastOut .2s ease-in both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px) scale(.98); } }

.confirm-modal[hidden] { display: none; }
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: grid;
    place-items: center;
    padding: 22px;
}
.confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .56);
    backdrop-filter: blur(2px);
}
.confirm-card {
    position: relative;
    width: min(460px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    padding: 22px;
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 14px;
    animation: confirmIn .18s ease-out both;
}
.confirm-icon {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #fff1f3;
    color: #b42318;
    font-weight: 900;
    font-size: 22px;
}
.confirm-copy h2 {
    margin: 0 0 6px;
    font-size: 20px;
}
.confirm-copy p {
    margin: 0;
    color: #475467;
    line-height: 1.45;
}
.confirm-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}
@keyframes confirmIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }


/* Drag-and-drop shelf planner interactions. */
.product-pick[draggable="true"],
.visual-slot.filled[draggable="true"] {
    cursor: grab;
}
.product-pick.dragging,
.visual-slot.dragging {
    opacity: .55;
    cursor: grabbing;
}
.visual-slot.drop-target {
    border-color: var(--primary) !important;
    background: #eef4ff;
    box-shadow: 0 0 0 4px rgba(53, 109, 255, 0.18);
}
.visual-slot.drop-target::after {
    content: 'Drop item here';
    align-self: end;
    justify-self: stretch;
    margin-top: 6px;
    padding: 5px 7px;
    border-radius: 8px;
    background: rgba(53, 109, 255, 0.10);
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}
.product-pick.dragging {
    border-color: var(--primary);
}

/* Profile + theme controls. */
.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.profile-summary {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(53, 109, 255, .04);
}
.profile-avatar {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    font-size: 22px;
}
.profile-summary strong,
.profile-summary span,
.profile-summary em {
    display: block;
}
.profile-summary span { color: var(--muted); margin-top: 3px; }
.profile-summary em { color: var(--muted); font-style: normal; font-size: 12px; margin-top: 5px; }
.theme-picker-form { display: grid; gap: 16px; }
.theme-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 12px;
}
.theme-option {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    cursor: pointer;
    background: var(--panel);
    color: var(--text);
}
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option:has(input:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(53, 109, 255, .12);
}
.theme-option strong,
.theme-option small { display: block; }
.theme-option small { color: var(--muted); margin-top: 4px; line-height: 1.35; }
.theme-preview {
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-rows: 22px 22px;
    gap: 6px;
    height: 72px;
    border-radius: 14px;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
}
.theme-preview i,
.theme-preview b,
.theme-preview em { border-radius: 8px; display: block; }
.theme-preview i { grid-row: 1 / 3; }
.theme-preview-light { background: #f8fafc; }
.theme-preview-light i { background: #101828; }
.theme-preview-light b,
.theme-preview-light em { background: #fff; border: 1px solid #d9e2ef; }
.theme-preview-dark { background: #0b1220; }
.theme-preview-dark i { background: #182235; }
.theme-preview-dark b,
.theme-preview-dark em { background: #111c2e; border: 1px solid #2d3b50; }
.theme-preview-system { background: linear-gradient(90deg, #f8fafc 0 50%, #0b1220 50% 100%); }
.theme-preview-system i { background: linear-gradient(90deg, #101828 0 50%, #182235 50% 100%); }
.theme-preview-system b,
.theme-preview-system em { background: linear-gradient(90deg, #fff 0 50%, #111c2e 50% 100%); border: 1px solid #8ea0b8; }

/* Dark theme. */
body.theme-dark {
    --bg: #0b1220;
    --panel: #111827;
    --text: #eef4ff;
    --muted: #9aa7bb;
    --line: #293548;
    --primary: #6ea0ff;
    --primary-dark: #4d7dff;
    --danger: #ff6b6b;
    --warning: #352a12;
    --warning-line: #7a5d1d;
    --success-bg: #073a25;
    --success-text: #8ff0bd;
    --error-bg: #3a1212;
    --error-text: #ffb4ad;
    --info-bg: #0f2748;
    --info-text: #a7c8ff;
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
}
body.theme-dark .sidebar { background: #080d18; }
body.theme-dark .nav a.active,
body.theme-dark .nav a:hover { background: #1b2a44; }
body.theme-dark .pill,
body.theme-dark .tag,
body.theme-dark .btn,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea,
body.theme-dark .panel,
body.theme-dark .card,
body.theme-dark .planner-card,
body.theme-dark .modal-card,
body.theme-dark .confirm-card,
body.theme-dark .toast,
body.theme-dark .shelf-context-menu,
body.theme-dark .list-item,
body.theme-dark .theme-option {
    background: var(--panel);
    color: var(--text);
    border-color: var(--line);
}
body.theme-dark label,
body.theme-dark .btn,
body.theme-dark .pill,
body.theme-dark .tag { color: var(--text); }
body.theme-dark .btn:hover { background: #182235; }
body.theme-dark .btn.primary { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
body.theme-dark .btn.danger { background: #e5484d; border-color: #e5484d; color: #fff; }
body.theme-dark th,
body.theme-dark .visual-slot-row,
body.theme-dark .visual-shelf-grid,
body.theme-dark .shelf-grid,
body.theme-dark .plan-switcher,
body.theme-dark .store-map,
body.theme-dark .product-library-panel,
body.theme-dark .selected-product-panel,
body.theme-dark .planner-canvas,
body.theme-dark .profile-summary {
    background: #0f1727;
    border-color: var(--line);
}
body.theme-dark .visual-slot,
body.theme-dark .shelf-slot,
body.theme-dark .product-pick,
body.theme-dark .list-item:hover,
body.theme-dark .list-item.active {
    background: #111c2e;
    color: var(--text);
    border-color: #2d3b50;
}
body.theme-dark .visual-slot:hover,
body.theme-dark .shelf-slot:hover,
body.theme-dark .product-pick:hover,
body.theme-dark .visual-slot.selected,
body.theme-dark .visual-slot.drop-target {
    background: #172945;
    border-color: var(--primary) !important;
}
body.theme-dark .visual-slot.drop-target::after { background: rgba(110, 160, 255, .16); color: var(--primary); }
body.theme-dark .toast-body p,
body.theme-dark .confirm-copy p { color: var(--muted); }
body.theme-dark .shelf-context-menu button { color: var(--text); }
body.theme-dark .shelf-context-menu button:hover:not(:disabled) { background: #172945; color: var(--primary); }
body.theme-dark .shelf-context-menu button.danger { color: #ff8a8a; }
body.theme-dark .shelf-context-menu button.danger:hover:not(:disabled) { background: #341b1f; }
body.theme-dark .modal-backdrop,
body.theme-dark .confirm-backdrop { background: rgba(0, 0, 0, .65); }

@media (prefers-color-scheme: dark) {
    body.theme-system {
        --bg: #0b1220;
        --panel: #111827;
        --text: #eef4ff;
        --muted: #9aa7bb;
        --line: #293548;
        --primary: #6ea0ff;
        --primary-dark: #4d7dff;
        --danger: #ff6b6b;
        --warning: #352a12;
        --warning-line: #7a5d1d;
        --success-bg: #073a25;
        --success-text: #8ff0bd;
        --error-bg: #3a1212;
        --error-text: #ffb4ad;
        --info-bg: #0f2748;
        --info-text: #a7c8ff;
        --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
    }
    body.theme-system .sidebar { background: #080d18; }
    body.theme-system .pill,
    body.theme-system .tag,
    body.theme-system .btn,
    body.theme-system input,
    body.theme-system select,
    body.theme-system textarea,
    body.theme-system .panel,
    body.theme-system .card,
    body.theme-system .planner-card,
    body.theme-system .modal-card,
    body.theme-system .confirm-card,
    body.theme-system .toast,
    body.theme-system .shelf-context-menu,
    body.theme-system .list-item,
    body.theme-system .theme-option { background: var(--panel); color: var(--text); border-color: var(--line); }
    body.theme-system label,
    body.theme-system .btn,
    body.theme-system .pill,
    body.theme-system .tag { color: var(--text); }
    body.theme-system .btn:hover { background: #182235; }
    body.theme-system .btn.primary { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
    body.theme-system th,
    body.theme-system .visual-slot-row,
    body.theme-system .visual-shelf-grid,
    body.theme-system .shelf-grid,
    body.theme-system .plan-switcher,
    body.theme-system .store-map,
    body.theme-system .product-library-panel,
    body.theme-system .selected-product-panel,
    body.theme-system .planner-canvas,
    body.theme-system .profile-summary { background: #0f1727; border-color: var(--line); }
    body.theme-system .visual-slot,
    body.theme-system .shelf-slot,
    body.theme-system .product-pick { background: #111c2e; color: var(--text); border-color: #2d3b50; }
    body.theme-system .visual-slot:hover,
    body.theme-system .shelf-slot:hover,
    body.theme-system .product-pick:hover,
    body.theme-system .visual-slot.selected,
    body.theme-system .visual-slot.drop-target { background: #172945; border-color: var(--primary) !important; }
    body.theme-system .toast-body p,
    body.theme-system .confirm-copy p { color: var(--muted); }
}

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

/* Collapsible left sidebar. */
.sidebar {
    width: 260px;
    transition: width .22s ease, padding .22s ease, transform .22s ease;
    overflow-x: hidden;
    z-index: 30;
}
.sidebar-toggle {
    position: absolute;
    top: 18px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 10px;
    background: rgba(255,255,255,.07);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    font-weight: 900;
}
.sidebar-toggle:hover {
    background: rgba(255,255,255,.13);
}
.brand {
    padding-right: 42px;
    min-height: 48px;
}
.brand-copy,
.nav a span,
.sidebar-footer small,
.sidebar-footer strong,
.sidebar-footer a {
    transition: opacity .14s ease, transform .14s ease;
}
.nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    white-space: nowrap;
}
.nav a::before {
    content: attr(data-short);
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    place-items: center;
    background: rgba(255,255,255,.07);
    color: #d7deea;
    font-size: 12px;
    font-weight: 900;
}
.nav a.active::before,
.nav a:hover::before {
    background: rgba(255,255,255,.13);
    color: #fff;
}
.topbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-sidebar-toggle {
    display: none;
}
body.sidebar-collapsed .sidebar {
    width: 82px;
    padding-left: 14px;
    padding-right: 14px;
}
body.sidebar-collapsed .sidebar-toggle {
    right: 14px;
}
body.sidebar-collapsed .brand {
    justify-content: center;
    padding-right: 0;
    margin-top: 42px;
}
body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav a span,
body.sidebar-collapsed .sidebar-footer small,
body.sidebar-collapsed .sidebar-footer strong,
body.sidebar-collapsed .sidebar-footer a {
    opacity: 0;
    transform: translateX(-8px);
    pointer-events: none;
    position: absolute;
}
body.sidebar-collapsed .nav {
    justify-items: center;
}
body.sidebar-collapsed .nav a {
    width: 46px;
    padding: 6px;
    justify-content: center;
}
body.sidebar-collapsed .nav a::before {
    display: grid;
}
body.sidebar-collapsed .sidebar-footer {
    min-height: 48px;
    border-top: 1px solid #344054;
}
body.sidebar-collapsed .topbar-sidebar-toggle {
    display: inline-flex;
}
body.sidebar-collapsed .planner-workspace {
    grid-template-columns: 285px minmax(760px, 1fr) 300px;
}

@media (max-width: 760px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 260px;
        max-width: calc(100vw - 54px);
        height: 100vh;
        transform: translateX(0);
        box-shadow: 18px 0 45px rgba(15, 23, 42, .22);
    }
    body.sidebar-collapsed .sidebar {
        width: 260px;
        padding: 24px 18px;
        transform: translateX(-100%);
    }
    body.sidebar-collapsed .brand {
        justify-content: flex-start;
        padding-right: 42px;
        margin-top: 0;
    }
    body.sidebar-collapsed .brand-copy,
    body.sidebar-collapsed .nav a span,
    body.sidebar-collapsed .sidebar-footer small,
    body.sidebar-collapsed .sidebar-footer strong,
    body.sidebar-collapsed .sidebar-footer a {
        opacity: 1;
        transform: none;
        pointer-events: auto;
        position: static;
    }
    body.sidebar-collapsed .nav {
        justify-items: stretch;
    }
    body.sidebar-collapsed .nav a {
        width: auto;
        padding: 11px 12px;
        justify-content: flex-start;
    }
    body.sidebar-collapsed .nav a::before {
        display: none;
    }
    .topbar-sidebar-toggle {
        display: inline-flex;
    }
    .main {
        padding-top: 18px;
    }
}

/* Dark theme polish pass: final high-specificity overrides so every page keeps
   proper contrast, including rules defined earlier with hard-coded light colors. */
body.theme-dark {
    color-scheme: dark;
}
body.theme-dark .main,
body.theme-dark .planner-page,
body.theme-dark .app-shell {
    background: var(--bg);
    color: var(--text);
}
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3,
body.theme-dark h4,
body.theme-dark strong,
body.theme-dark b {
    color: var(--text);
}
body.theme-dark a { color: #9dc0ff; }
body.theme-dark a:hover { color: #c5d9ff; }
body.theme-dark .topbar {
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
}
body.theme-dark .panel,
body.theme-dark .card,
body.theme-dark .planner-card,
body.theme-dark .login-card,
body.theme-dark .install-card,
body.theme-dark .modal-card,
body.theme-dark .confirm-card {
    background: #111827 !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}
body.theme-dark .card.warning,
body.theme-dark .row-warning td {
    background: #2a2112 !important;
    border-color: #7a5d1d !important;
}
body.theme-dark .panel-header,
body.theme-dark .canvas-toolbar,
body.theme-dark .planner-titlebar,
body.theme-dark .topbar,
body.theme-dark .actions,
body.theme-dark .toolbar,
body.theme-dark .inline-form {
    color: var(--text);
}
body.theme-dark label,
body.theme-dark .muted,
body.theme-dark .empty,
body.theme-dark .planner-titlebar p,
body.theme-dark .small-text,
body.theme-dark .planner-tip,
body.theme-dark .product-pick small,
body.theme-dark .visual-slot small,
body.theme-dark .visual-slot em,
body.theme-dark .shelf-slot small,
body.theme-dark .shelf-slot em,
body.theme-dark .profile-summary span,
body.theme-dark .profile-summary em,
body.theme-dark .selected-preview small,
body.theme-dark .list-item span,
body.theme-dark .list-item em {
    color: var(--muted) !important;
}
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
    background: #0f1727 !important;
    color: var(--text) !important;
    border-color: #334155 !important;
}
body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder { color: #72819a; }
body.theme-dark input:focus,
body.theme-dark select:focus,
body.theme-dark textarea:focus {
    border-color: var(--primary) !important;
    outline-color: rgba(110,160,255,.25) !important;
}
body.theme-dark .btn,
body.theme-dark .pill,
body.theme-dark .tag {
    background: #111827 !important;
    color: var(--text) !important;
    border-color: #334155 !important;
}
body.theme-dark .btn:hover {
    background: #1f2a3d !important;
    color: #fff !important;
}
body.theme-dark .btn.primary {
    background: #4d7dff !important;
    color: #fff !important;
    border-color: #4d7dff !important;
}
body.theme-dark .btn.primary:hover { background: #356dff !important; }
body.theme-dark .btn.danger,
body.theme-dark .btn.outline.danger {
    background: #3a1212 !important;
    color: #ffb4ad !important;
    border-color: #7f1d1d !important;
}
body.theme-dark .btn.danger:hover,
body.theme-dark .btn.outline.danger:hover {
    background: #4a1717 !important;
    color: #ffd0cc !important;
}
body.theme-dark .table-wrap {
    border-color: var(--line) !important;
    background: #0f1727 !important;
}
body.theme-dark table,
body.theme-dark tbody,
body.theme-dark tr,
body.theme-dark td {
    background: transparent !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}
body.theme-dark th {
    background: #182235 !important;
    color: #b6c3d6 !important;
    border-color: var(--line) !important;
}
body.theme-dark tr:hover td { background: rgba(110,160,255,.06) !important; }
body.theme-dark .list-item,
body.theme-dark .product-pick,
body.theme-dark .category-chip,
body.theme-dark .theme-option,
body.theme-dark .stat {
    background: #0f1727 !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}
body.theme-dark .list-item:hover,
body.theme-dark .list-item.active,
body.theme-dark .product-pick:hover,
body.theme-dark .product-pick.active,
body.theme-dark .category-chip:hover,
body.theme-dark .category-chip.active {
    background: #172945 !important;
    border-color: var(--primary) !important;
    color: #dce9ff !important;
}
body.theme-dark .category-chip span {
    background: rgba(110,160,255,.16) !important;
    color: #b8d0ff !important;
}
body.theme-dark .product-thumb,
body.theme-dark .product-pack,
body.theme-dark .profile-avatar {
    background: #172945 !important;
    color: #fff !important;
    border-color: #334155 !important;
}
body.theme-dark .stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 12px;
    margin: 14px 0;
}
body.theme-dark .stat {
    border-radius: 14px;
    padding: 14px;
}
body.theme-dark .stat span { display: block; color: var(--muted); margin-bottom: 6px; }
body.theme-dark .stat strong { font-size: 24px; }
body.theme-dark .alert-success { background: var(--success-bg) !important; color: var(--success-text) !important; border: 1px solid rgba(143,240,189,.22); }
body.theme-dark .alert-error { background: var(--error-bg) !important; color: var(--error-text) !important; border: 1px solid rgba(255,180,173,.22); }
body.theme-dark .alert-info { background: var(--info-bg) !important; color: var(--info-text) !important; border: 1px solid rgba(167,200,255,.22); }

/* Shelf planner dark mode */
body.theme-dark .planner-workspace,
body.theme-dark .planner-canvas,
body.theme-dark .product-library-panel,
body.theme-dark .selected-product-panel {
    background: #111827 !important;
    border-color: var(--line) !important;
}
body.theme-dark .visual-shelf-grid {
    background: #111827 !important;
}
body.theme-dark .visual-shelf-grid > .visual-level-label + .visual-slot-row {
    background: #0f1727 !important;
    border-color: #293548 !important;
}
body.theme-dark .visual-shelf-grid > .visual-level-label + .visual-slot-row::before {
    background: #111827 !important;
    color: #e5edff !important;
    border-right-color: #334155 !important;
}
body.theme-dark .visual-slot,
body.theme-dark .shelf-slot {
    background: #111c2e !important;
    color: var(--text) !important;
    border-color: #334155 !important;
}
body.theme-dark .visual-slot.empty-slot,
body.theme-dark .shelf-slot.empty-slot {
    background: #0f1727 !important;
    border-style: dashed !important;
    border-color: #435169 !important;
}
body.theme-dark .visual-slot.filled,
body.theme-dark .shelf-slot.filled {
    background: #13223a !important;
    border-color: #41506a !important;
}
body.theme-dark .visual-slot:hover,
body.theme-dark .visual-slot.selected,
body.theme-dark .shelf-slot:hover,
body.theme-dark .shelf-slot.selected,
body.theme-dark .visual-slot.drop-target {
    background: #193154 !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(110,160,255,.18) !important;
}
body.theme-dark .empty-label { color: #a9b7cc !important; }
body.theme-dark .selected-preview b { color: #9dc0ff !important; }

/* Store map dark mode */
body.theme-dark .store-map {
    border-color: #334155 !important;
    background-color: #0f1727 !important;
    background-image: linear-gradient(#1f2a3d 1px, transparent 1px), linear-gradient(90deg, #1f2a3d 1px, transparent 1px) !important;
}
body.theme-dark .map-object {
    border-color: rgba(255,255,255,.28) !important;
    box-shadow: 0 12px 28px rgba(0,0,0,.45) !important;
}
body.theme-dark .map-empty { color: var(--muted) !important; }

/* Toasts, confirmations, and right-click menus */
body.theme-dark .toast,
body.theme-dark .confirm-card,
body.theme-dark .shelf-context-menu {
    background: #111827 !important;
    color: var(--text) !important;
    border-color: #334155 !important;
}
body.theme-dark .toast-body p,
body.theme-dark .confirm-copy p { color: var(--muted) !important; }
body.theme-dark .toast-close { color: var(--muted) !important; }
body.theme-dark .toast-close:hover { background: #1f2a3d !important; color: #fff !important; }
body.theme-dark .toast-icon { background: #172945 !important; color: #9dc0ff !important; }
body.theme-dark .toast-success .toast-icon { background: #073a25 !important; color: #8ff0bd !important; }
body.theme-dark .toast-error .toast-icon { background: #3a1212 !important; color: #ffb4ad !important; }
body.theme-dark .confirm-icon { background: #3a1212 !important; color: #ffb4ad !important; }
body.theme-dark .shelf-context-menu button { color: var(--text) !important; }
body.theme-dark .shelf-context-menu button:hover:not(:disabled) { background: #172945 !important; color: #b8d0ff !important; }
body.theme-dark .shelf-context-menu button.danger { color: #ff9a92 !important; }
body.theme-dark .shelf-context-menu button.danger:hover:not(:disabled) { background: #3a1212 !important; }
body.theme-dark .modal-backdrop,
body.theme-dark .confirm-backdrop { background: rgba(0,0,0,.72) !important; }

/* Login/install pages respect dark mode when manually given theme-dark. */
body.theme-dark.login-body,
body.theme-dark.install-body {
    background: radial-gradient(circle at top left, #1b2a44, #0b1220 55%) !important;
}

@media (prefers-color-scheme: dark) {
    body.theme-system { color-scheme: dark; }
    body.theme-system .main,
    body.theme-system .planner-page,
    body.theme-system .app-shell { background: var(--bg); color: var(--text); }
    body.theme-system h1,
    body.theme-system h2,
    body.theme-system h3,
    body.theme-system h4,
    body.theme-system strong,
    body.theme-system b { color: var(--text); }
    body.theme-system a { color: #9dc0ff; }
    body.theme-system .topbar { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
    body.theme-system .panel,
    body.theme-system .card,
    body.theme-system .planner-card,
    body.theme-system .login-card,
    body.theme-system .install-card,
    body.theme-system .modal-card,
    body.theme-system .confirm-card { background: #111827 !important; color: var(--text) !important; border-color: var(--line) !important; }
    body.theme-system label,
    body.theme-system .muted,
    body.theme-system .empty,
    body.theme-system .planner-titlebar p,
    body.theme-system .small-text,
    body.theme-system .planner-tip,
    body.theme-system .product-pick small,
    body.theme-system .visual-slot small,
    body.theme-system .visual-slot em,
    body.theme-system .shelf-slot small,
    body.theme-system .shelf-slot em,
    body.theme-system .profile-summary span,
    body.theme-system .profile-summary em,
    body.theme-system .selected-preview small,
    body.theme-system .list-item span,
    body.theme-system .list-item em { color: var(--muted) !important; }
    body.theme-system input,
    body.theme-system select,
    body.theme-system textarea { background: #0f1727 !important; color: var(--text) !important; border-color: #334155 !important; }
    body.theme-system input::placeholder,
    body.theme-system textarea::placeholder { color: #72819a; }
    body.theme-system .btn,
    body.theme-system .pill,
    body.theme-system .tag { background: #111827 !important; color: var(--text) !important; border-color: #334155 !important; }
    body.theme-system .btn:hover { background: #1f2a3d !important; color: #fff !important; }
    body.theme-system .btn.primary { background: #4d7dff !important; color: #fff !important; border-color: #4d7dff !important; }
    body.theme-system .btn.danger,
    body.theme-system .btn.outline.danger { background: #3a1212 !important; color: #ffb4ad !important; border-color: #7f1d1d !important; }
    body.theme-system .table-wrap { border-color: var(--line) !important; background: #0f1727 !important; }
    body.theme-system table,
    body.theme-system tbody,
    body.theme-system tr,
    body.theme-system td { background: transparent !important; color: var(--text) !important; border-color: var(--line) !important; }
    body.theme-system th { background: #182235 !important; color: #b6c3d6 !important; border-color: var(--line) !important; }
    body.theme-system .list-item,
    body.theme-system .product-pick,
    body.theme-system .category-chip,
    body.theme-system .theme-option,
    body.theme-system .stat { background: #0f1727 !important; color: var(--text) !important; border-color: var(--line) !important; }
    body.theme-system .list-item:hover,
    body.theme-system .list-item.active,
    body.theme-system .product-pick:hover,
    body.theme-system .product-pick.active,
    body.theme-system .category-chip:hover,
    body.theme-system .category-chip.active { background: #172945 !important; border-color: var(--primary) !important; color: #dce9ff !important; }
    body.theme-system .category-chip span { background: rgba(110,160,255,.16) !important; color: #b8d0ff !important; }
    body.theme-system .product-thumb,
    body.theme-system .product-pack,
    body.theme-system .profile-avatar { background: #172945 !important; color: #fff !important; border-color: #334155 !important; }
    body.theme-system .card.warning,
    body.theme-system .row-warning td { background: #2a2112 !important; border-color: #7a5d1d !important; }
    body.theme-system .alert-success { background: var(--success-bg) !important; color: var(--success-text) !important; border: 1px solid rgba(143,240,189,.22); }
    body.theme-system .alert-error { background: var(--error-bg) !important; color: var(--error-text) !important; border: 1px solid rgba(255,180,173,.22); }
    body.theme-system .alert-info { background: var(--info-bg) !important; color: var(--info-text) !important; border: 1px solid rgba(167,200,255,.22); }
    body.theme-system .visual-shelf-grid,
    body.theme-system .planner-workspace,
    body.theme-system .planner-canvas,
    body.theme-system .product-library-panel,
    body.theme-system .selected-product-panel { background: #111827 !important; border-color: var(--line) !important; }
    body.theme-system .visual-shelf-grid > .visual-level-label + .visual-slot-row { background: #0f1727 !important; border-color: #293548 !important; }
    body.theme-system .visual-shelf-grid > .visual-level-label + .visual-slot-row::before { background: #111827 !important; color: #e5edff !important; border-right-color: #334155 !important; }
    body.theme-system .visual-slot,
    body.theme-system .shelf-slot { background: #111c2e !important; color: var(--text) !important; border-color: #334155 !important; }
    body.theme-system .visual-slot.empty-slot,
    body.theme-system .shelf-slot.empty-slot { background: #0f1727 !important; border-style: dashed !important; border-color: #435169 !important; }
    body.theme-system .visual-slot.filled,
    body.theme-system .shelf-slot.filled { background: #13223a !important; border-color: #41506a !important; }
    body.theme-system .visual-slot:hover,
    body.theme-system .visual-slot.selected,
    body.theme-system .shelf-slot:hover,
    body.theme-system .shelf-slot.selected,
    body.theme-system .visual-slot.drop-target { background: #193154 !important; border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(110,160,255,.18) !important; }
    body.theme-system .empty-label { color: #a9b7cc !important; }
    body.theme-system .selected-preview b { color: #9dc0ff !important; }
    body.theme-system .store-map { border-color: #334155 !important; background-color: #0f1727 !important; background-image: linear-gradient(#1f2a3d 1px, transparent 1px), linear-gradient(90deg, #1f2a3d 1px, transparent 1px) !important; }
    body.theme-system .toast,
    body.theme-system .confirm-card,
    body.theme-system .shelf-context-menu { background: #111827 !important; color: var(--text) !important; border-color: #334155 !important; }
    body.theme-system .toast-body p,
    body.theme-system .confirm-copy p { color: var(--muted) !important; }
    body.theme-system .shelf-context-menu button { color: var(--text) !important; }
    body.theme-system .modal-backdrop,
    body.theme-system .confirm-backdrop { background: rgba(0,0,0,.72) !important; }
}

/* Clickable profile shortcut in the sidebar footer. */
.sidebar-profile-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px;
    margin: 0 0 6px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 14px;
    background: rgba(255,255,255,.04);
    color: #fff;
    text-decoration: none;
    min-height: 58px;
}
.sidebar-profile-card:hover,
.sidebar-profile-card.active {
    background: rgba(53,109,255,.20);
    border-color: rgba(124,165,255,.45);
    text-decoration: none;
}
.sidebar-profile-avatar {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #7ca5ff, #345dff);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .02em;
    box-shadow: 0 10px 24px rgba(53,109,255,.22);
}
.sidebar-profile-copy {
    display: grid;
    gap: 1px;
    min-width: 0;
}
.sidebar-profile-copy small,
.sidebar-profile-copy strong,
.sidebar-profile-copy em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-profile-copy small { color: #aeb8ca; font-size: 12px; }
.sidebar-profile-copy strong { color: #fff; font-size: 14px; }
.sidebar-profile-copy em { color: #b7cdfd; font-size: 12px; font-style: normal; }
.sidebar-logout {
    display: inline-flex;
    align-items: center;
    color: #b7cdfd;
    padding: 4px 2px;
}
body.sidebar-collapsed .sidebar-footer {
    display: grid;
    justify-items: center;
}
body.sidebar-collapsed .sidebar-profile-card {
    width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 4px;
    justify-content: center;
    border-radius: 14px;
    margin-bottom: 0;
}
body.sidebar-collapsed .sidebar-profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 12px;
}
body.sidebar-collapsed .sidebar-profile-copy,
body.sidebar-collapsed .sidebar-logout {
    opacity: 0;
    transform: translateX(-8px);
    pointer-events: none;
    position: absolute;
}
@media (max-width: 760px) {
    body.sidebar-collapsed .sidebar-profile-card {
        width: auto;
        height: auto;
        min-height: 58px;
        padding: 10px;
        justify-content: flex-start;
    }
    body.sidebar-collapsed .sidebar-profile-avatar {
        width: 38px;
        height: 38px;
        border-radius: 12px;
        font-size: 13px;
    }
    body.sidebar-collapsed .sidebar-profile-copy,
    body.sidebar-collapsed .sidebar-logout {
        opacity: 1;
        transform: none;
        pointer-events: auto;
        position: static;
    }
}
