:root {
    --bg: #0f1114;
    --card: #1a1d23;
    --border: #2a2f38;
    --text: #e8eaef;
    --muted: #9aa3b2;
    --accent: #7c6cf0;
    --accent2: #5dd4c4;
    --danger: #e85d6a;
    --ok: #4ade80;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, "Cairo", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

.live-data-banner {
    margin: 0;
    padding: 10px 20px;
    background: rgba(232, 93, 106, 0.12);
    border-bottom: 1px solid rgba(232, 93, 106, 0.35);
    color: #f0d4d7;
    font-size: 0.88rem;
    line-height: 1.5;
}

.live-data-banner strong {
    color: #ffb4bc;
}

.live-data-banner a {
    color: var(--accent2);
    font-weight: 600;
}

.global-stats-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 6px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.28);
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--muted);
}
.global-stats-bar a {
    color: var(--muted);
    text-decoration: none;
}
.global-stats-bar a:hover {
    color: var(--accent2);
    text-decoration: none;
}
.global-stats-bar a.is-warn,
.global-stats-bar a.is-warn strong {
    color: #ffb4bc;
}
.global-stats-bar strong {
    color: var(--text);
    font-weight: 700;
}
.global-stats-bar__sep {
    opacity: 0.45;
}

.page-stats {
    margin: 0 0 14px;
}
.page-stats__count {
    margin: 0 0 8px;
    font-size: 0.92rem;
    color: var(--text);
}
.page-stats__of,
.page-stats__label {
    color: var(--muted);
    font-weight: 400;
}
a.page-stats__total-link {
    color: var(--accent2);
    text-decoration: none;
    border-bottom: 1px dashed rgba(93, 212, 196, 0.45);
}
a.page-stats__total-link:hover {
    color: var(--text);
    border-bottom-color: var(--accent2);
}
a.page-stats__total-link strong {
    font-weight: 700;
}
.page-stats__filtered {
    display: inline-block;
    margin-inline-start: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    background: rgba(93, 212, 196, 0.12);
    color: var(--accent2);
    vertical-align: middle;
}
.page-stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.page-stats-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.3;
    text-decoration: none;
}
a.page-stats-chip:hover {
    border-color: rgba(93, 212, 196, 0.35);
    color: var(--accent2);
    text-decoration: none;
}
.page-stats-chip__value {
    color: var(--text);
    font-weight: 700;
}
.page-stats-chip.is-warn,
.page-stats-chip.is-warn .page-stats-chip__value {
    color: #ffb4bc;
    border-color: rgba(232, 93, 106, 0.35);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.35);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar .brand {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
    flex-shrink: 0;
}

.topbar-home:hover {
    color: var(--accent2);
    border-color: rgba(93, 212, 196, 0.45);
    text-decoration: none;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar nav a { color: var(--text); opacity: 0.9; }
.topbar nav a:hover { opacity: 1; color: var(--accent2); }

.who { color: var(--muted); font-size: 0.9rem; }

.topbar-notif {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.topbar-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
}

.topbar-bell:hover,
.topbar-notif.is-open .topbar-bell {
    color: var(--accent2);
    border-color: rgba(93, 212, 196, 0.45);
}

.topbar-bell__icon {
    display: block;
    transform-origin: top center;
}

.topbar-bell.has-alerts .topbar-bell__icon {
    animation: topbar-bell-ring 1.5s ease-in-out infinite;
}

@keyframes topbar-bell-ring {
    0%, 100% { transform: rotate(0deg); }
    8% { transform: rotate(14deg); }
    16% { transform: rotate(-12deg); }
    24% { transform: rotate(10deg); }
    32% { transform: rotate(-8deg); }
    40% { transform: rotate(4deg); }
    48%, 100% { transform: rotate(0deg); }
}

.topbar-bell__badge {
    position: absolute;
    top: -5px;
    inset-inline-end: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e85d6a;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px rgba(10, 12, 16, 0.9);
}

.topbar-notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    width: min(360px, calc(100vw - 24px));
    max-height: min(420px, 70vh);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #14181f;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    z-index: 40;
}

.topbar-notif-panel__head {
    padding: 12px 14px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.topbar-notif-empty {
    margin: 0;
    padding: 16px 14px;
    color: var(--muted);
    font-size: 0.9rem;
}

.topbar-notif-list {
    list-style: none;
    margin: 0;
    padding: 6px;
}

.topbar-notif-line {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    border: 1px solid transparent;
    font-size: 0.9rem;
    line-height: 1.35;
}

.topbar-notif-line:hover {
    background: rgba(93, 212, 196, 0.1);
    border-color: rgba(93, 212, 196, 0.28);
    color: var(--accent2);
    text-decoration: none;
}

.shell { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; box-sizing: border-box; }
.shell.shell-wide {
    max-width: none;
    width: 100%;
    padding-inline: 16px;
    box-sizing: border-box;
}

/* Horizontal scroll for wide admin tables (items, categories, backups, …) */
.table-scroll,
.data-wide-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin-bottom: 4px;
}

.table-scroll > table.data,
.data-wide-wrap > table.data {
    margin-bottom: 0;
}

@media (max-width: 900px) {
    html, body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .shell,
    .shell.shell-wide {
        max-width: 100%;
        width: 100%;
        padding: 16px 12px 40px;
    }

    .topbar {
        gap: 10px;
        padding: 10px 12px;
        flex-wrap: nowrap;
    }

    .topbar .brand {
        font-size: 0.95rem;
        white-space: nowrap;
    }

    .topbar nav {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        gap: 12px;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        padding-bottom: 2px;
    }

    .topbar nav > a,
    .topbar nav > .who,
    .topbar nav > .btn,
    .topbar nav > .topbar-notif {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .global-stats-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        padding: 8px 12px;
        scrollbar-width: thin;
    }

    .global-stats-bar a,
    .global-stats-bar__sep {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .toolbar {
        gap: 8px 10px;
    }

    table.data {
        min-width: 720px;
    }

    table.data.data-wide {
        min-width: 960px;
    }

    .insights-charts {
        grid-template-columns: 1fr;
    }

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

    .item-edit-lang-row {
        grid-template-columns: 1fr;
    }

    .branch-price-grid,
    .branch-item-images-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .dash-kpi-grid {
        grid-template-columns: 1fr;
    }

    .topbar-start .brand {
        max-width: 7.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

h1 { font-size: 1.55rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }

.muted { color: var(--muted); margin: 0 0 16px; }

.error { color: #ffb4bc; background: rgba(232,93,106,0.12); padding: 10px 12px; border-radius: 8px; }
.success { color: #bbf7d0; background: rgba(74,222,128,0.12); padding: 10px 12px; border-radius: 8px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
}

.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5a4fd4); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 0.85rem; }
.btn.danger { border-color: var(--danger); color: #ffb4bc; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 20px; }

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

table.data th, table.data td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.data th { background: rgba(0,0,0,0.25); color: var(--muted); font-weight: 600; font-size: 0.85rem; }
table.data tr:last-child td { border-bottom: 0; }

.row-actions-inner {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex-wrap: nowrap;
}
.row-actions-reorder,
.row-actions-side {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.row-actions-reorder form,
.row-actions-side form {
    display: block;
    margin: 0;
}
.row-actions-reorder .btn,
.row-actions-side .btn {
    display: block;
    width: 100%;
    min-width: 5.4rem;
    white-space: nowrap;
}

.item-sort-form {
    margin: 0;
}

.item-sort-field {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    cursor: text;
}

.item-sort-hash {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.item-sort-input {
    width: 2.8rem;
    min-width: 2.8rem;
    margin: 0;
    padding: 4px 2px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    text-align: center;
    font-weight: 700;
    -moz-appearance: textfield;
}

.item-sort-input::-webkit-outer-spin-button,
.item-sort-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ampm-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ampm-field-label {
    color: var(--muted);
}

.ampm-trigger {
    min-width: 7.5rem;
    justify-content: center;
}

.ampm-popover {
    position: absolute;
    z-index: 80;
}

.ampm-popover-card {
    min-width: 260px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #161a24;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
}

.ampm-popover-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ampm-popover-row label {
    margin: 0;
    flex: 1;
    min-width: 70px;
    font-size: 0.82rem;
}

.ampm-popover-row select {
    width: 100%;
    margin-top: 4px;
}

.ampm-popover-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.cat-meta-status.error {
    color: #ff8f9a;
}

.categories-page {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.cat-schedule-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 0 0 14px;
    width: 100%;
    box-sizing: border-box;
}

.cat-schedule-box legend {
    padding: 0 8px;
    font-weight: 700;
}

.cat-schedule-help {
    margin: 0 0 12px;
}

.cat-schedule-row {
    display: grid;
    grid-template-columns: 72px minmax(150px, 1.2fr) minmax(150px, 1.2fr) minmax(100px, 0.8fr);
    gap: 10px 14px;
    align-items: end;
    width: 100%;
    padding: 12px 14px;
    margin: 0 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    box-sizing: border-box;
}

.cat-schedule-slot-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent2, #7dd3c7);
    padding-bottom: 10px;
    letter-spacing: 0.02em;
}

.cat-schedule-order {
    margin: 0;
    font-size: 0.85rem;
}

.cat-schedule-order input {
    width: 100%;
    max-width: none;
    margin-top: 4px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #12151a;
    color: var(--text);
    box-sizing: border-box;
}

.cat-schedule-cell {
    min-width: 520px;
    width: 48%;
    vertical-align: top;
}

.cat-meta-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    width: 100%;
}

.cat-meta-status {
    font-size: 0.78rem;
    min-height: 1.1em;
}

.data-wide {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
}

.ampm-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ampm-field-label {
    color: var(--muted);
    font-size: 0.8rem;
}

.ampm-trigger {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
}

@media (max-width: 1100px) {
    .cat-schedule-cell {
        min-width: 440px;
        width: auto;
    }
}

@media (max-width: 900px) {
    .cat-schedule-row {
        grid-template-columns: 1fr 1fr;
    }
    .cat-schedule-slot-label {
        grid-column: 1 / -1;
        padding-bottom: 0;
    }
}

.stack label { display: block; margin-bottom: 14px; }
.stack input, .stack select, .stack textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #12151a;
    color: var(--text);
}

.stack textarea { min-height: 100px; resize: vertical; }

.stack fieldset input[type="checkbox"] {
    width: auto;
    margin-top: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.check-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}
.check-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #12151a;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.card-link {
    display: block;
    padding: 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    text-decoration: none;
    transition: transform 0.15s ease, border-color 0.15s;
}
.card-link:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.card-link h2 { margin: 0 0 8px; font-size: 1.1rem; }
.card-link p { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* ── Dashboard ── */
.dash { width: 100%; max-width: 100%; }

.dash-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 18px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    width: fit-content;
    max-width: 100%;
}

.dash-tab {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
}

.dash-tab:hover {
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
}

.dash-tab.is-active {
    color: var(--text);
    background: rgba(126, 200, 192, 0.18);
    border: 1px solid rgba(126, 200, 192, 0.35);
}

.insights-alerts {
    display: grid;
    gap: 8px;
    margin: 0 0 14px;
}

.insights-alert {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.9rem;
}

.insights-alert--warn {
    border-color: rgba(232, 180, 120, 0.55);
    background: rgba(232, 180, 120, 0.12);
}

.insights-alert--info {
    border-color: rgba(143, 184, 232, 0.45);
    background: rgba(143, 184, 232, 0.1);
}

.insights-compare {
    margin: 0 0 12px;
    font-size: 0.86rem;
}

.insights-focus-bar {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(126, 200, 192, 0.45);
    background: rgba(126, 200, 192, 0.12);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.insights-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.insights-chart-hint {
    margin: 8px 0 0;
    font-size: 0.8rem;
}

.insights-link {
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(126, 200, 192, 0.5);
}

.insights-link:hover {
    color: var(--accent2, #7ec8c0);
}

tr.is-insights-active,
tr.is-insights-active td {
    background: rgba(126, 200, 192, 0.14) !important;
}

.insights.is-loading {
    opacity: 0.72;
    pointer-events: none;
}

.insights-status {
    min-height: 1em;
}

.insights-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-end;
    margin: 0 0 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
}

.insights-filter {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.insights-filter select {
    min-width: 12rem;
}

.insights-branches {
    border: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
}

.insights-branches legend {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0;
    margin: 0 8px 0 0;
}

.insights-branches label {
    margin: 0;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    font-size: 0.88rem;
}

.insights-range-meta {
    font-size: 0.82rem;
}

.insights-method {
    margin: 0 0 16px;
    max-width: 52rem;
}

.insights-th-label {
    margin-inline-end: 4px;
}

.insights-help {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-inline-start: 2px;
    cursor: help;
    outline: none;
}

.insights-help__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid rgba(154, 163, 178, 0.65);
    color: #9aa3b2;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    background: rgba(255, 255, 255, 0.04);
}

.insights-help:hover .insights-help__mark,
.insights-help:focus .insights-help__mark,
.insights-help:focus-within .insights-help__mark {
    border-color: rgba(126, 200, 192, 0.85);
    color: #cfe9e5;
}

.insights-help__tip {
    display: none;
    position: absolute;
    z-index: 60;
    top: calc(100% + 8px);
    inset-inline-start: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(280px, 70vw);
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(45, 53, 64, 0.95);
    background: #151820;
    color: #e8eaef;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.45;
    text-align: start;
    white-space: normal;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

body.admin-ui-arabic .insights-help__tip {
    font-family: "Almarai", system-ui, sans-serif;
}

.insights-help:hover .insights-help__tip,
.insights-help:focus .insights-help__tip,
.insights-help:focus-within .insights-help__tip {
    display: block;
}

.insights-filter > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

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

.insights-chart-card {
    margin: 0;
    min-width: 0;
}

.insights-chart-card canvas {
    max-width: 100%;
}

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

.dash-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 18px;
}
.dash-intro { margin: 4px 0 0; max-width: 52rem; }
.dash-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.dash-customize {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    padding: 14px 16px;
    margin-bottom: 18px;
}
.dash-customize__head { font-weight: 700; margin-bottom: 10px; }
.dash-customize__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px 14px;
}
.dash-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    margin: 0;
    cursor: pointer;
}
.dash-customize__note { margin: 12px 0 0; font-size: 0.82rem; }

.dash-panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    padding: 16px 18px 18px;
    margin-bottom: 16px;
}
.dash-panel[hidden],
.dash-panel.is-hidden-panel { display: none !important; }
.dash-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.dash-panel__head h2 {
    margin: 0;
    font-size: 1.05rem;
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.dash-drag {
    width: 32px;
    height: 32px;
    padding: 0;
    cursor: grab;
    opacity: 0.75;
    flex-shrink: 0;
}
.dash-drag:active {
    cursor: grabbing;
}
.dash-drag:hover {
    opacity: 1;
}
.dash-panel.is-dragging {
    opacity: 0.55;
    border-color: rgba(93, 212, 196, 0.55);
}
.dash-panel.is-drop-target {
    border-color: rgba(93, 212, 196, 0.7);
    box-shadow: 0 0 0 1px rgba(93, 212, 196, 0.35);
}
.dash-panels {
    display: flex;
    flex-direction: column;
}
.dash-hide {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.7;
}
.dash-hide:hover { opacity: 1; }

.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.dash-kpi {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.18);
    color: inherit;
    text-decoration: none;
    min-height: 88px;
}
a.dash-kpi:hover {
    border-color: rgba(93, 212, 196, 0.4);
    text-decoration: none;
    color: inherit;
}
.dash-kpi--warn {
    border-color: rgba(232, 93, 106, 0.35);
    background: rgba(232, 93, 106, 0.08);
}
.dash-kpi__label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.82rem;
}
.dash-kpi__value {
    font-size: 1.75rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.dash-coverage {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr auto;
    gap: 18px;
    align-items: center;
}
@media (max-width: 900px) {
    .dash-coverage { grid-template-columns: 1fr; }
}
.dash-meter__top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.dash-meter__track {
    height: 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
}
.dash-meter__track > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #3aa89a, var(--accent2));
}
a.dash-meter__track--link {
    display: block;
    text-decoration: none;
}
a.dash-meter__track--link:hover {
    filter: brightness(1.1);
}
.dash-donut-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.dash-donut { width: 96px; height: 96px; }

.dash-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
@media (max-width: 720px) {
    .dash-split { grid-template-columns: 1fr; }
}
.dash-sub {
    margin: 0 0 10px;
    font-size: 0.92rem;
    color: var(--muted);
}
.dash-report {
    list-style: none;
    margin: 0;
    padding: 0;
}
.dash-report li + li { margin-top: 6px; }
.dash-report a {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
    text-decoration: none;
    background: rgba(0,0,0,0.15);
}
.dash-report a:hover {
    border-color: rgba(93, 212, 196, 0.35);
    color: var(--accent2);
}
.dash-ok { margin: 0; }

.dash-bars { display: flex; flex-direction: column; gap: 14px; }
.dash-bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr;
    gap: 12px 16px;
    align-items: center;
}
@media (max-width: 640px) {
    .dash-bar-row { grid-template-columns: 1fr; }
}
.dash-bar-row__label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.9rem;
}
.dash-bar-row__tracks { display: flex; flex-direction: column; gap: 6px; }
.dash-bar {
    position: relative;
    height: 28px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    overflow: hidden;
}
.dash-bar__fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    min-width: 0;
}
.dash-bar__fill--items { background: rgba(93, 212, 196, 0.55); }
.dash-bar__fill--cats { background: rgba(124, 108, 240, 0.5); }
.dash-bar em {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-style: normal;
    font-size: 0.78rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.45);
}

.dash-table td, .dash-table th { white-space: nowrap; }
.dash-mini-cov {
    width: 72px;
    height: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-inline-end: 6px;
}
.dash-mini-cov > span {
    display: block;
    height: 100%;
    background: var(--accent2);
}

.dash-flag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
}
.dash-flag {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.16);
}
.dash-flag span { color: var(--muted); font-size: 0.82rem; }
.dash-flag strong { font-size: 1.25rem; }

.badge-soft {
    display: inline-block;
    margin-inline-start: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    background: rgba(232, 93, 106, 0.15);
    color: #ffb4bc;
    vertical-align: middle;
}

.dash-backup-list {
    margin: 12px 0 0;
    padding-inline-start: 18px;
    font-size: 0.85rem;
}

.dash-num {
    color: var(--accent2);
    font-weight: 700;
    text-decoration: none;
}
.dash-num:hover { text-decoration: underline; }
.dash-num--warn { color: #ffb4bc; }

.dash-meter--link,
.dash-donut-wrap--link,
.dash-bar--link,
.dash-flag,
.dash-cov-link {
    color: inherit;
    text-decoration: none;
}
.dash-meter--link:hover,
.dash-donut-wrap--link:hover,
.dash-flag:hover {
    border-color: rgba(93, 212, 196, 0.4);
    text-decoration: none;
    color: inherit;
}
a.dash-flag {
    border: 1px solid rgba(255,255,255,0.08);
}
.dash-bar--link { display: block; }
.dash-bar--link:hover { filter: brightness(1.08); }
.dash-cov-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.dash-cov-link:hover { text-decoration: none; }

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 28px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--card);
}

.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: #222; }
.thumb-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #1a1d23;
    border: 1px dashed var(--border);
    color: var(--muted);
    font-size: 0.85rem;
}
.item-thumb-cell { vertical-align: middle; width: 56px; }
.item-thumb-edit {
    display: inline-block;
    cursor: pointer;
    position: relative;
    margin: 0;
}
.item-thumb-edit .thumb {
    display: block;
    transition: opacity 0.15s ease, outline-color 0.15s ease;
}
.item-thumb-edit:hover .thumb,
.item-thumb-edit .thumb.is-saving {
    outline: 2px solid var(--accent, #5dd4c4);
    outline-offset: 2px;
}
.item-thumb-edit .thumb.is-saving {
    opacity: 0.55;
}
.item-active-col {
    width: 2.5rem;
    text-align: center;
    vertical-align: middle;
}
.item-active-toggle {
    margin: 0;
    display: inline-flex;
    cursor: pointer;
}
.item-row-hidden {
    opacity: 0.62;
}
tr.item-inline-ok {
    outline: 1px solid rgba(93, 212, 196, 0.55);
}
tr.item-inline-err {
    outline: 1px solid rgba(220, 80, 80, 0.55);
}
.item-inline-price {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    cursor: text;
}
.item-inline-price-prefix {
    color: var(--muted);
    font-size: 0.88rem;
}
.item-inline-price-input {
    width: 5.75rem;
    margin: 0;
    padding: 2px 6px;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.88rem;
    border-radius: 6px;
    -moz-appearance: textfield;
    appearance: textfield;
}
.item-inline-price-input::-webkit-outer-spin-button,
.item-inline-price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.item-inline-price-input:hover,
.item-inline-price-input:focus {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.04);
    outline: none;
}
.item-inline-price-input.is-saving {
    opacity: 0.6;
}
.item-current-image {
    max-width: 280px;
    max-height: 280px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #12151a;
}

code { background: #12151a; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

.card {
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    margin: 16px 0;
}

.import-summary-stats {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
}

.import-summary-stats li {
    font-size: 0.95rem;
}

.linkish {
    background: none;
    border: none;
    color: var(--accent2);
    cursor: pointer;
    text-decoration: underline;
    font: inherit;
    padding: 0 4px;
}

.import-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.import-modal[hidden] {
    display: none;
}

.import-modal-card {
    width: min(920px, 100%);
    max-height: min(80vh, 720px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.import-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.import-modal-head h3 {
    margin: 0;
    font-size: 1rem;
}

.import-modal-body {
    overflow: auto;
    padding: 12px 18px 18px;
}

.import-wizard-card {
    width: min(960px, 100%);
    max-height: min(88vh, 820px);
}

.import-steps {
    display: flex;
    gap: 8px;
    padding: 0 18px 12px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.import-step {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
}

.import-step.active {
    color: var(--text);
    background: rgba(124, 108, 240, 0.25);
    font-weight: 600;
}

.import-step.done {
    color: var(--accent2);
}

.import-step-panel {
    padding-top: 4px;
}

.import-wizard-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
    flex-wrap: wrap;
}

.import-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    margin-inline-end: 6px;
}

.import-badge.ok {
    background: rgba(74, 222, 128, 0.15);
    color: #86efac;
}

.import-badge.skip {
    background: rgba(154, 163, 178, 0.15);
    color: var(--muted);
}

/* Bulk edit */
body.bulk-modal-open {
    overflow: hidden;
}

.bulk-check-col {
    width: 36px;
    text-align: center;
    vertical-align: middle;
}

.bulk-check-col input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

#bulk-edit-open:disabled,
#bulk-edit-open.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.bulk-edit-card {
    width: min(560px, 100%);
    max-height: min(88vh, 760px);
}

.bulk-edit-body {
    overflow: auto;
}

.bulk-section {
    margin: 0 0 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.bulk-section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    cursor: pointer;
}

.bulk-section-title {
    display: block;
    margin: 0 0 10px;
}

.bulk-radio-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bulk-radio-stack label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    cursor: pointer;
    line-height: 1.35;
}

.bulk-radio-stack input {
    margin-top: 3px;
    width: auto;
}

.bulk-branch-grid {
    margin-top: 12px;
}

.bulk-price-value-wrap {
    display: block;
    margin-top: 12px;
}

.bulk-price-value-wrap input {
    margin-top: 6px;
    max-width: 180px;
}

#bulk-edit-status {
    margin: 0 0 8px;
}

#bulk_category_id {
    width: 100%;
}

.branch-multiselect {
    min-width: 180px;
    min-height: 88px;
}

.ms-filter {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 200px;
}

.ms-filter-label {
    font-size: 0.9rem;
    color: var(--muted);
}

.ms-filter-box {
    position: relative;
}

.ms-filter-trigger {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    cursor: pointer;
    text-align: start;
}

.ms-filter-trigger:hover,
.ms-filter.is-open .ms-filter-trigger {
    border-color: rgba(93, 212, 196, 0.55);
}

.ms-filter-chips-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.ms-filter-chips {
    display: contents;
}

.ms-filter-placeholder {
    color: var(--muted);
    font-size: 0.92rem;
    padding: 4px 2px;
}

.ms-filter-placeholder[hidden] {
    display: none;
}

.ms-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 3px 8px 3px 4px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.92);
    color: #1a1f2e;
    font-size: 0.82rem;
    line-height: 1.2;
}

.ms-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ms-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #5a6478;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.ms-chip-remove:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #1a1f2e;
}

.ms-filter-caret {
    width: 0;
    height: 0;
    margin-top: 10px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    opacity: 0.7;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.ms-filter.is-open .ms-filter-caret {
    transform: rotate(180deg);
}

.ms-filter-panel {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-start: 0;
    z-index: 50;
    min-width: 100%;
    max-height: 220px;
    overflow: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: #1a1f2e;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    display: none;
    flex-direction: column;
}

.ms-filter.is-open .ms-filter-panel {
    display: flex;
}

.ms-filter-panel[hidden] {
    display: none !important;
}

.ms-filter-panel-head {
    padding: 10px 12px 6px;
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.ms-filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.ms-filter-option:last-child {
    border-bottom: none;
}

.ms-filter-option:hover {
    background: rgba(93, 212, 196, 0.12);
}

.ms-filter-option.is-selected {
    background: #2f6fed;
    color: #fff;
}

.ms-filter-option.is-selected:hover {
    background: #255fd4;
}

.ms-filter-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    pointer-events: none;
}

.ms-filter-option span {
    line-height: 1.25;
    flex: 1;
}

.branch-price-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 720px) {
    .branch-price-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.branch-price-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    opacity: 0.72;
}

.branch-price-row.is-on {
    opacity: 1;
    border-color: rgba(93, 212, 196, 0.45);
    box-shadow: 0 0 0 1px rgba(93, 212, 196, 0.12);
}

.branch-price-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
}

.branch-price-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.branch-price-input input {
    width: 110px;
    margin: 0;
}

.size-price-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}

@media (min-width: 700px) {
    .size-price-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.size-price-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    min-width: 0;
}

.size-price-field span {
    font-weight: 600;
    font-size: 0.92rem;
}

.size-price-field input {
    width: 100%;
    margin: 0;
}

/* Item edit: pack compact frames into two columns on wide screens */
.item-edit-lang-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 0 0 14px;
}

@media (min-width: 900px) {
    .item-edit-lang-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

.item-edit-panel {
    min-width: 0;
}

.branch-item-images-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 720px) {
    .branch-item-images-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.branch-item-images {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
}

.branch-price-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.branch-price-list li {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.25;
}

.branch-price-list li span {
    color: var(--muted);
    font-size: 0.88rem;
}

/* Items list: horizontal branch chips (do not reuse item_edit .branch-price-row) */
.item-branch-chips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-width: none;
    overflow: visible;
}

.item-branch-chip {
    display: flex !important;
    flex-direction: column !important;
    flex: unset;
    gap: 4px;
    min-width: 0;
    max-width: none;
    width: auto;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    box-sizing: border-box;
    line-height: 1.25;
}

.item-branch-chip.has-branch-accent,
.cat-branch-opt.has-branch-accent,
.has-branch-accent {
    border-width: 1px;
    border-style: solid;
}

.branch-accent-picker {
    width: 2.25rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.item-branch-chip.is-off {
    opacity: 0.45;
}

.item-branch-check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    cursor: pointer;
    white-space: nowrap;
}

.item-branch-check input {
    margin: 0;
    flex: 0 0 auto;
}

.item-branch-check strong {
    font-size: 0.85rem;
}

.branches-prices-cell {
    min-width: 16rem;
    width: 36%;
}

.item-branch-chip .item-inline-price {
    width: 100%;
}

.item-branch-chip .item-inline-price-input {
    width: 100%;
    max-width: none;
}

#bulk-price-extras {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
