:root {
    --orange: #f97316;
    --orange-dark: #ea580c;
    --orange-soft: #fff7ed;
    --orange-border: #fed7aa;
    --ink: #172033;
    --text: #475569;
    --muted: #94a3b8;
    --line: #e8edf3;
    --panel: #ffffff;
    --background: #f8fafc;
    --success: #15803d;
    --danger: #b91c1c;
    --shadow: 0 12px 35px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--background);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

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

button, input, select { font: inherit; }

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    background: #fff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.brand {
    height: 92px;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 13px;
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(135deg, #fb923c, #ea580c);
    color: white;
    display: grid;
    place-items: center;
    font-size: 21px;
    font-weight: 800;
    box-shadow: 0 9px 22px rgba(249,115,22,.28);
}

.brand-mark.large { width: 58px; height: 58px; border-radius: 18px; font-size: 28px; }

.brand strong { display: block; font-size: 15px; letter-spacing: .09em; }
.brand span { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }

.nav-menu { padding: 18px 14px; flex: 1; overflow-y: auto; }

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 45px;
    padding: 0 13px;
    margin: 3px 0;
    border-radius: 11px;
    color: #5a6577;
    font-size: 14px;
    font-weight: 600;
    transition: .18s ease;
}

.nav-menu a:hover { background: #f8fafc; color: var(--ink); }

.nav-menu a.active {
    background: var(--orange-soft);
    color: var(--orange-dark);
}

.nav-icon {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    font-size: 16px;
}

.sidebar-footer { border-top: 1px solid var(--line); padding: 17px 18px 20px; }

.user-mini { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--orange-soft);
    color: var(--orange-dark);
    display: grid;
    place-items: center;
    font-weight: 800;
}

.user-mini strong, .user-mini span {
    display: block;
    max-width: 145px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-mini strong { font-size: 13px; }
.user-mini span { color: var(--muted); font-size: 11px; margin-top: 2px; text-transform: capitalize; }
.logout-link { font-size: 12px; color: #64748b; }
.logout-link:hover { color: var(--orange-dark); }

.main { width: calc(100% - 260px); margin-left: 260px; min-width: 0; }

.topbar {
    height: 92px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--line);
    padding: 0 30px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
}

.topbar h1 { margin: 0; font-size: 20px; font-weight: 750; }
.topbar p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

.topbar-badge {
    margin-left: auto;
    font-size: 10px;
    letter-spacing: .08em;
    font-weight: 800;
    background: var(--orange-soft);
    border: 1px solid var(--orange-border);
    color: var(--orange-dark);
    padding: 7px 10px;
    border-radius: 999px;
}

.menu-toggle { display: none; border: 0; background: transparent; font-size: 22px; cursor: pointer; }

.content { padding: 28px 30px 48px; max-width: 1800px; margin: 0 auto; }

.page-actions {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.page-actions h2 { margin: 0; font-size: 22px; }
.page-actions p { margin: 5px 0 0; color: var(--text); font-size: 13px; }

.store-filter { display: grid; gap: 5px; min-width: 280px; }
.store-filter label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.store-filter select {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}
.store-filter select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,.12); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    min-height: 108px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 42px; height: 42px; flex: 0 0 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--orange-soft);
    color: var(--orange-dark);
    font-weight: 800;
}

.stat-card span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .055em; font-weight: 700; }
.stat-card strong { display: block; margin-top: 4px; font-size: 26px; letter-spacing: -.03em; }
.stat-card.success .stat-icon { background: #f0fdf4; color: var(--success); }
.stat-card.warning .stat-icon { background: #fff7ed; color: #c2410c; }
.stat-card.danger .stat-icon { background: #fef2f2; color: var(--danger); }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(330px, .8fr);
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: var(--shadow);
    padding: 20px;
    min-width: 0;
}

.panel-heading { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 16px; }
.panel-heading h3 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.text-link { color: var(--orange-dark); font-size: 12px; font-weight: 700; white-space: nowrap; }

.chart-wrap { height: 310px; position: relative; }
.chart-wrap.donut { height: 310px; }

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

.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
    padding: 10px 9px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
    letter-spacing: .05em;
    text-transform: uppercase;
    text-align: left;
}
.data-table td { padding: 12px 9px; border-bottom: 1px solid #f1f5f9; color: #536074; vertical-align: middle; }
.data-table td strong { color: var(--ink); display: block; font-size: 12px; }
.data-table td small { color: var(--muted); display: block; margin-top: 2px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.positive { color: var(--success) !important; font-weight: 700; }
.negative { color: var(--danger) !important; font-weight: 700; }
.pill { display: inline-block; padding: 5px 8px; border-radius: 999px; background: #f8fafc; border: 1px solid var(--line); font-size: 9px; font-weight: 800; color: #64748b; }

.low-stock-list { display: grid; gap: 8px; }
.stock-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 12px;
    border: 1px solid #f0f2f5;
    border-radius: 11px;
}
.stock-item strong { display: block; font-size: 11px; }
.stock-item span, .stock-item small { display: block; color: var(--muted); margin-top: 2px; font-size: 10px; }
.stock-item b {
    min-width: 34px; height: 34px; padding: 0 8px;
    border-radius: 10px; background: var(--orange-soft); color: var(--orange-dark);
    display: grid; place-items: center;
}

.empty, .empty-card { color: var(--muted); text-align: center; padding: 25px !important; }

.alert { border-radius: 11px; padding: 12px 14px; margin: 0 0 18px; font-size: 13px; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.module-placeholder {
    max-width: 620px;
    margin: 80px auto;
    text-align: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 52px 35px;
    box-shadow: var(--shadow);
}
.placeholder-icon { font-size: 32px; color: var(--orange); }
.module-placeholder h2 { margin: 12px 0 8px; }
.module-placeholder p { color: var(--text); line-height: 1.7; margin: 0 auto 24px; max-width: 460px; }

.btn-primary {
    border: 0;
    background: linear-gradient(135deg, #fb923c, #ea580c);
    color: white;
    border-radius: 10px;
    padding: 11px 17px;
    font-weight: 750;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 18px rgba(249,115,22,.22);
}
.btn-primary:hover { filter: brightness(.98); }
.btn-block { width: 100%; }

/* Login */
.login-page { background: white; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }

.login-brand {
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
    padding: 60px;
    background:
        radial-gradient(circle at 15% 15%, rgba(255,255,255,.18), transparent 24%),
        radial-gradient(circle at 85% 80%, rgba(255,255,255,.12), transparent 26%),
        linear-gradient(145deg, #f97316, #ea580c 65%, #c2410c);
    color: white;
}

.login-brand::after {
    content: "";
    position: absolute;
    width: 420px; height: 420px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 50%;
    right: -180px; bottom: -190px;
}

.login-brand-inner { max-width: 520px; position: relative; z-index: 1; }
.login-brand .brand-mark { background: white; color: var(--orange-dark); box-shadow: 0 15px 35px rgba(124,45,18,.18); margin-bottom: 28px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-weight: 800; font-size: 10px; }
.login-brand h1 { margin: 13px 0; font-size: clamp(38px, 5vw, 68px); line-height: .98; letter-spacing: -.055em; }
.login-brand p { max-width: 480px; font-size: 15px; line-height: 1.75; color: rgba(255,255,255,.82); }
.feature-row { display: flex; flex-wrap: wrap; gap: 17px; margin-top: 28px; font-size: 11px; font-weight: 750; }

.login-form-panel { display: grid; place-items: center; padding: 50px 28px; }

.login-form { width: min(420px, 100%); }
.login-form > .eyebrow { color: var(--orange-dark); }
.login-form h2 { margin: 8px 0 4px; font-size: 30px; letter-spacing: -.03em; }
.login-form > p { margin: 0 0 28px; color: var(--text); font-size: 13px; }

.login-form label { display: grid; gap: 7px; margin-bottom: 16px; }
.login-form label > span { color: #4b5563; font-size: 12px; font-weight: 700; }
.login-form input,
.login-form select {
    width: 100%;
    height: 46px;
    border: 1px solid #dce2e9;
    border-radius: 10px;
    padding: 0 12px;
    outline: none;
    color: var(--ink);
    background: #fff;
}
.login-form input:focus, .login-form select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,.12); }

.password-field { position: relative; }
.password-field input { padding-right: 60px; }
.password-field button {
    position: absolute;
    right: 7px; top: 7px; bottom: 7px;
    border: 0; background: transparent;
    color: var(--orange-dark); font-weight: 700; font-size: 11px; cursor: pointer;
}
.form-note { display: block; margin-top: 14px; color: var(--muted); font-size: 10px; line-height: 1.6; }

@media (max-width: 1250px) {
    .stat-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 1050px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .chart-wrap.donut { height: 340px; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 20px 0 40px rgba(15,23,42,.12); }
    .sidebar.open { transform: translateX(0); }
    .main { width: 100%; margin-left: 0; }
    .menu-toggle { display: block; }
    .content { padding: 22px 18px 40px; }
    .topbar { padding: 0 18px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { min-height: 380px; padding: 45px 30px; }
}

@media (max-width: 720px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .page-actions { align-items: stretch; flex-direction: column; }
    .store-filter { min-width: 0; width: 100%; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .topbar-badge { display: none; }
}


/* Phase 2: Products + Inventory */
.filter-panel { margin-bottom: 18px; padding: 16px 18px; }

.filter-grid {
    display: grid;
    gap: 13px;
    align-items: end;
}

.product-filter-grid { grid-template-columns: minmax(280px, 1.7fr) minmax(140px, .55fr) minmax(190px, .9fr) 100px; }
.inventory-filter-grid { grid-template-columns: minmax(220px, .9fr) minmax(300px, 1.3fr) minmax(180px, .7fr) 100px; }

.filter-grid label, .barcode-box { display: grid; gap: 6px; }
.filter-grid label > span, .barcode-box > label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.filter-grid input,
.filter-grid select,
.barcode-box input {
    width: 100%;
    height: 42px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

.filter-grid input:focus,
.filter-grid select:focus,
.barcode-box input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.10);
}

.products-actions { align-items: end; }

.barcode-box { width: min(420px, 100%); }
.search-inline { display: flex; gap: 8px; }
.search-inline input { min-width: 0; flex: 1; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .table-scroll { padding: 0 18px; }

.table-toolbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
}

.table-toolbar h3 { margin: 0; font-size: 15px; }
.table-toolbar p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.pagination-bar {
    min-height: 66px;
    padding: 12px 18px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.pagination-bar span { min-width: 100px; text-align: center; color: var(--text); font-size: 11px; font-weight: 700; }

.btn-secondary {
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid #dce3eb;
    border-radius: 9px;
    background: #fff;
    color: #526073;
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
}
.btn-secondary:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; color: var(--ink); }
.btn-secondary:disabled { opacity: .45; cursor: default; }

.btn-table, .table-link {
    border: 0;
    background: transparent;
    color: var(--orange-dark);
    font-weight: 750;
    cursor: pointer;
    padding: 0;
}
.btn-table {
    padding: 6px 9px;
    border: 1px solid var(--orange-border);
    background: var(--orange-soft);
    border-radius: 8px;
    font-size: 10px;
}
.table-link:hover { text-decoration: underline; }

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 23px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.status-badge.active { color: #166534; background: #f0fdf4; border: 1px solid #bbf7d0; }
.status-badge.inactive { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }

.stock-number {
    display: inline-flex;
    justify-content: flex-end;
    min-width: 32px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.stock-number.low { color: var(--orange-dark); }
.muted-number { color: var(--muted) !important; }

.inventory-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.modal-open { overflow: hidden; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }

.modal-card {
    width: min(680px, 100%);
    max-height: min(88vh, 900px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 17px;
    box-shadow: 0 30px 80px rgba(15,23,42,.25);
}
.modal-card.modal-large { width: min(980px, 100%); }

.modal-header, .modal-footer {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 17px 20px;
}
.modal-header { justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-header h3 { margin: 3px 0 0; font-size: 18px; }

.modal-close {
    width: 36px; height: 36px;
    border: 0;
    border-radius: 10px;
    background: #f8fafc;
    color: #64748b;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.modal-body { padding: 20px; overflow-y: auto; }

.loading-block {
    min-height: 180px;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.orange-text { color: var(--orange-dark); }

.product-detail-hero {
    display: flex;
    align-items: center;
    gap: 17px;
    padding: 16px;
    border: 1px solid var(--orange-border);
    border-radius: 14px;
    background: var(--orange-soft);
}
.product-code-box {
    min-width: 125px;
    padding: 13px 12px;
    border-radius: 10px;
    background: #fff;
    color: var(--orange-dark);
    font-weight: 850;
    letter-spacing: .06em;
    text-align: center;
    border: 1px solid #ffedd5;
}
.product-detail-hero h4 { margin: 7px 0 3px; font-size: 17px; }
.product-detail-hero p { margin: 0; color: var(--text); font-size: 11px; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 10px;
    margin-top: 15px;
}
.detail-grid > div {
    min-height: 68px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
}
.detail-grid span {
    display: block;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: 9px;
    font-weight: 750;
}
.detail-grid strong { display: block; margin-top: 5px; font-size: 12px; word-break: break-word; }

.modal-section { margin-top: 22px; }
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.section-title h4 { margin: 0; font-size: 13px; }
.section-title span { color: var(--muted); font-size: 10px; }

.detail-strip {
    padding: 11px 13px;
    margin-bottom: 14px;
    border-radius: 10px;
    background: var(--orange-soft);
    color: var(--orange-dark);
    font-size: 12px;
}

.danger-outline { color: #b91c1c; border-color: #fecaca; }
.success-outline { color: #15803d; border-color: #bbf7d0; }

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1200;
    max-width: min(380px, calc(100vw - 44px));
    padding: 12px 15px;
    border-radius: 11px;
    background: #172033;
    color: #fff;
    font-size: 12px;
    font-weight: 650;
    box-shadow: 0 15px 35px rgba(15,23,42,.25);
    opacity: 0;
    transform: translateY(14px);
    pointer-events: none;
    transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }

@media (max-width: 1180px) {
    .product-filter-grid,
    .inventory-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .inventory-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 650px) {
    .product-filter-grid,
    .inventory-filter-grid { grid-template-columns: 1fr; }
    .products-actions { align-items: stretch; }
    .barcode-box { width: 100%; }
    .search-inline { flex-direction: column; }
    .pagination-bar { justify-content: space-between; }
    .detail-grid { grid-template-columns: 1fr; }
    .product-detail-hero { align-items: flex-start; flex-direction: column; }
    .modal-backdrop { padding: 8px; align-items: flex-end; }
    .modal-card { max-height: 94vh; border-radius: 16px 16px 0 0; }
}


/* Barcode scanner hotfix */
.barcode-actions { align-items: stretch; }
.scanner-hint {
    display: block;
    max-width: 640px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.55;
}

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

.camera-scan-shell {
    position: relative;
    width: 100%;
    min-height: 320px;
    overflow: hidden;
    border-radius: 14px;
    background: #111827;
}

#barcodeCameraVideo {
    display: block;
    width: 100%;
    min-height: 320px;
    max-height: 60vh;
    object-fit: cover;
}

.camera-scan-frame {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.camera-scan-frame::before {
    content: "";
    width: min(72%, 460px);
    height: 145px;
    border: 2px solid rgba(255,255,255,.94);
    border-radius: 14px;
    box-shadow: 0 0 0 9999px rgba(15,23,42,.34);
}

.camera-scan-frame span {
    position: absolute;
    width: min(66%, 420px);
    height: 2px;
    background: var(--orange);
    box-shadow: 0 0 14px rgba(249,115,22,.9);
    animation: barcodeScanLine 1.8s ease-in-out infinite alternate;
}

.camera-status {
    margin: 12px 0 0;
    color: var(--text);
    font-size: 12px;
    text-align: center;
}

@keyframes barcodeScanLine {
    from { transform: translateY(-52px); }
    to { transform: translateY(52px); }
}

@media (max-width: 720px) {
    .barcode-actions { flex-wrap: wrap; }
    .barcode-actions input { flex: 1 1 100%; }
    .barcode-actions button { flex: 1 1 auto; }
    .camera-scan-shell,
    #barcodeCameraVideo { min-height: 260px; }
}


/* Barcode input / product search interaction hotfix */
#barcodeLookup,
#productSearch {
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

#barcodeLookup:focus,
#productSearch:focus {
    background: #ffffff;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .12);
}

#barcodeLookup::selection,
#productSearch::selection {
    background: rgba(249, 115, 22, .22);
}


/* Phase 3: Stock Receiving */
.receiving-filter-grid {
    grid-template-columns: minmax(320px, 1.5fr) minmax(160px, .55fr) 100px;
}

.receiving-stats {
    margin-bottom: 18px;
}

.status-badge.pending {
    color: #9a3412;
    background: #fff7ed;
    border: 1px solid #fed7aa;
}

.status-badge.completed {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.status-badge.cancelled {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.modal-xl {
    width: min(1180px, 100%);
}

.modal-subtitle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.receiving-editor-body {
    background: #fbfcfe;
}

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

.form-grid label {
    display: grid;
    gap: 6px;
}

.form-grid label > span,
.receiving-add-grid label > span,
.cancel-area label > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.form-grid input,
.form-grid select,
.receiving-add-grid input,
.cancel-area textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

.form-grid input:focus,
.form-grid select:focus,
.receiving-add-grid input:focus,
.cancel-area textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.10);
}

.form-grid input:disabled,
.form-grid select:disabled {
    background: #f8fafc;
    color: #64748b;
}

.form-span-2 {
    grid-column: span 2;
}

.receiving-header-grid {
    padding: 17px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.receiving-entry-card {
    margin-top: 17px;
    padding: 17px;
    background: #fff;
    border: 1px solid var(--orange-border);
    border-radius: 14px;
}

.receiving-entry-card .section-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.receiving-add-grid {
    display: grid;
    grid-template-columns: minmax(350px, 1fr) minmax(300px, 1fr);
    gap: 14px;
}

.receiving-add-grid label {
    display: grid;
    gap: 6px;
    position: relative;
}

.receiving-add-grid small {
    color: var(--muted);
    font-size: 9px;
}

.product-search-wrap {
    position: relative;
}

.product-search-results {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    z-index: 1100;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 11px;
    box-shadow: 0 18px 40px rgba(15,23,42,.14);
}

.product-search-option {
    width: 100%;
    min-height: 58px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    text-align: left;
    cursor: pointer;
}

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

.product-search-option:hover {
    background: var(--orange-soft);
}

.product-search-option strong,
.product-search-option small {
    display: block;
}

.product-search-option strong {
    font-size: 11px;
    color: var(--ink);
}

.product-search-option small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

.product-search-option b {
    color: var(--orange-dark);
    font-size: 10px;
    white-space: nowrap;
}

.product-search-empty {
    padding: 18px;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

.table-input {
    width: 88px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    text-align: right;
    outline: none;
}

.table-input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 2px rgba(249,115,22,.10);
}

.table-action-group {
    display: inline-flex;
    gap: 5px;
}

.danger-table {
    color: #991b1b;
    border-color: #fecaca;
    background: #fef2f2;
}

.cancel-area {
    margin-top: 17px;
    padding: 15px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    border-radius: 12px;
}

.cancel-area label {
    display: grid;
    gap: 6px;
}

.cancel-area textarea {
    resize: vertical;
}

.receiving-editor-footer {
    justify-content: space-between;
}

.footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.receiving-meta {
    color: var(--muted);
    font-size: 9px;
}

.receiving-final-note {
    margin-top: 13px;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

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

    .receiving-filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .receiving-editor-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .footer-actions {
        width: 100%;
        flex-wrap: wrap;
    }
}

@media (max-width: 650px) {
    .receiving-filter-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-span-2 {
        grid-column: auto;
    }

    .footer-actions button {
        flex: 1 1 auto;
    }

    .receiving-add-grid .search-inline {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .receiving-add-grid .search-inline input {
        grid-column: 1 / -1;
    }
}


/* Global textbox/input interaction fix */
input:not([disabled]),
textarea:not([disabled]),
select:not([disabled]),
[contenteditable="true"] {
    pointer-events: auto !important;
    user-select: text;
    -webkit-user-select: text;
    touch-action: manipulation;
    position: relative;
}

input:not([disabled]),
textarea:not([disabled]) {
    cursor: text;
}

select:not([disabled]) {
    cursor: pointer;
}

input:not([disabled]):focus,
textarea:not([disabled]):focus,
select:not([disabled]):focus {
    outline: none;
    border-color: var(--orange) !important;
    box-shadow: 0 0 0 3px rgba(249,115,22,.12) !important;
}

.modal-card input:not([disabled]),
.modal-card textarea:not([disabled]),
.modal-card select:not([disabled]) {
    z-index: 2;
}

/*
 * Hidden modal layers must never intercept clicks/focus.
 * When open, pointer events are restored.
 */
.modal-backdrop:not(.open) {
    pointer-events: none !important;
}

.modal-backdrop.open {
    pointer-events: auto !important;
}

.modal-card {
    pointer-events: auto;
}


/* Global searchable dropdowns - Select2 */
.select2-container {
    width: 100% !important;
    font-size: 12px;
}

.select2-container .select2-selection--single {
    height: 42px;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    outline: none;
    display: flex;
    align-items: center;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    width: 100%;
    padding-left: 11px;
    padding-right: 35px;
    line-height: 40px;
    color: var(--ink);
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--muted);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
    right: 7px;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}

.select2-container--default.select2-container--disabled .select2-selection--single {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
}

.select2-dropdown {
    border: 1px solid #dce3eb;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(15,23,42,.12);
    overflow: hidden;
    z-index: 1400;
}

.select2-container--open {
    z-index: 1400;
}

.select2-search--dropdown {
    display: block !important;
    padding: 8px;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    display: block !important;
    width: 100% !important;
    height: 38px;
    padding: 0 10px;
    border: 1px solid #dce3eb;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
    pointer-events: auto !important;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.10);
}

.select2-results__options {
    max-height: 290px !important;
}

.select2-container--default .select2-results__option {
    min-height: 36px;
    padding: 9px 11px;
    color: #475569;
    font-size: 11px;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: var(--orange);
    color: #fff;
}

.select2-container--default .select2-results__option--selected {
    background: var(--orange-soft);
    color: var(--orange-dark);
    font-weight: 700;
}

/* Keep Select2 correctly positioned inside application modals. */
.modal-card .select2-container {
    z-index: 3;
}

.modal-card .select2-dropdown {
    z-index: 1500;
}

/* Select2 multi-select support for future modules. */
.select2-container--default .select2-selection--multiple {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 3px 7px;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--orange-soft);
    border: 1px solid var(--orange-border);
    color: var(--orange-dark);
    border-radius: 7px;
    padding: 3px 7px 3px 23px;
}

/*
 * Native selects stay in the DOM for accessibility and form behavior,
 * but Select2 handles the visible UI.
 */
select.select2-hidden-accessible {
    pointer-events: none !important;
}


/* ============================================================
   Mobile modal layout fix
   ============================================================
   On phones, every modal becomes a true full-screen app sheet:
   - header stays visible
   - content scrolls independently
   - footer stays visible
   - no content is hidden behind browser UI/footer
   - safe-area insets are respected
*/
@media (max-width: 650px) {
    .modal-backdrop {
        padding: 0 !important;
        align-items: stretch !important;
        justify-content: stretch !important;
        background: rgba(15, 23, 42, .50);
    }

    .modal-card,
    .modal-card.modal-large,
    .modal-card.modal-xl,
    .camera-modal-card {
        width: 100vw !important;
        max-width: 100vw !important;

        /* fallback first, then modern mobile viewport unit */
        height: 100vh;
        max-height: 100vh;
        height: 100dvh;
        max-height: 100dvh;

        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: hidden !important;

        display: flex !important;
        flex-direction: column !important;
    }

    .modal-header {
        flex: 0 0 auto;
        min-height: 68px;
        padding:
            calc(12px + env(safe-area-inset-top, 0px))
            16px
            12px !important;
        background: #fff;
        z-index: 20;
    }

    .modal-header > div {
        min-width: 0;
    }

    .modal-header h3 {
        margin-top: 2px;
        font-size: 18px;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .modal-subtitle {
        flex-wrap: wrap;
        gap: 5px 8px;
    }

    .modal-close {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
        align-self: flex-start;
    }

    .modal-body {
        flex: 1 1 auto;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 14px !important;
        background: #fff;
    }

    .receiving-editor-body {
        background: #fbfcfe;
    }

    .modal-footer {
        flex: 0 0 auto;
        min-height: 64px;
        padding:
            10px
            14px
            calc(10px + env(safe-area-inset-bottom, 0px)) !important;
        background: #fff;
        z-index: 20;
        box-shadow: 0 -5px 18px rgba(15,23,42,.05);
    }

    .modal-footer .btn-primary,
    .modal-footer .btn-secondary {
        min-height: 42px;
    }

    /*
     * Product details:
     * Keep the mobile page compact instead of making each detail card
     * a full-width tall block.
     */
    .product-detail-hero {
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 12px !important;
        border-radius: 12px;
    }

    .product-code-box {
        min-width: 108px;
        max-width: 42%;
        padding: 11px 9px;
        font-size: 15px;
    }

    .product-detail-hero > div:last-child {
        min-width: 0;
        flex: 1;
    }

    .product-detail-hero h4 {
        margin: 6px 0 2px;
        font-size: 14px;
        line-height: 1.3;
        overflow-wrap: anywhere;
    }

    .product-detail-hero p {
        overflow-wrap: anywhere;
    }

    .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        margin-top: 10px !important;
    }

    .detail-grid > div {
        min-height: 58px !important;
        padding: 10px !important;
        border-radius: 10px !important;
    }

    .detail-grid span {
        font-size: 8px;
    }

    .detail-grid strong {
        margin-top: 4px;
        font-size: 11px;
        line-height: 1.25;
    }

    .modal-section {
        margin-top: 16px !important;
    }

    .section-title {
        align-items: flex-start;
    }

    /*
     * Horizontal data tables stay usable on narrow screens.
     * The body scrolls vertically and table wrapper scrolls horizontally.
     */
    .modal-body .table-scroll {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-body .data-table {
        min-width: 620px;
    }

    /*
     * Receiving editor action footer:
     * Keep buttons visible and wrap cleanly instead of stretching the modal.
     */
    .receiving-editor-footer {
        gap: 8px;
    }

    .receiving-editor-footer #receivingFooterLeft {
        display: none;
    }

    .receiving-editor-footer .footer-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .receiving-editor-footer .footer-actions > button {
        width: 100%;
        margin: 0;
    }

    .receiving-editor-footer .footer-actions > .btn-primary:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    /*
     * New receiving and other forms: one clean column on phone.
     */
    .form-grid,
    .receiving-filter-grid,
    .receiving-add-grid {
        grid-template-columns: 1fr !important;
    }

    .form-span-2 {
        grid-column: auto !important;
    }

    /*
     * Camera modal: maximize useful preview area but keep controls visible.
     */
    .camera-scan-shell,
    #barcodeCameraVideo,
    #receivingCameraVideo {
        min-height: 280px;
        max-height: calc(100dvh - 190px);
    }

    /*
     * Select2 dropdowns inside full-screen modals.
     */
    .modal-card .select2-dropdown {
        max-width: calc(100vw - 28px);
    }
}

/* Very narrow phones */
@media (max-width: 390px) {
    .detail-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .product-detail-hero {
        align-items: flex-start !important;
    }

    .product-code-box {
        min-width: 96px;
        font-size: 13px;
    }

    .modal-header {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .modal-body {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .modal-footer {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}


/* Phase 4: Inventory Adjustments */
.adjustment-filter-grid {
    grid-template-columns: minmax(320px, 1.5fr) minmax(160px, .55fr) 100px;
}

.adjustment-stats {
    margin-bottom: 18px;
}

.adjustment-editor-body {
    background: #fbfcfe;
}

.adjustment-header-grid {
    padding: 17px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.adjustment-entry-card {
    margin-top: 17px;
    padding: 17px;
    border: 1px solid var(--orange-border);
    border-radius: 14px;
    background: #fff;
}

.adjustment-entry-card .section-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.adjustment-product-grid {
    display: grid;
    grid-template-columns: minmax(330px, 1fr) minmax(300px, 1fr);
    gap: 14px;
}

.adjustment-product-grid label,
.adjustment-value-area label {
    display: grid;
    gap: 6px;
    position: relative;
}

.adjustment-product-grid label > span,
.adjustment-value-area label > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.adjustment-product-grid input,
.adjustment-value-area input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

.adjustment-product-grid input:focus,
.adjustment-value-area input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.10);
}

.selected-adjustment-product {
    margin-top: 13px;
    padding: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid #dce3eb;
    border-radius: 11px;
    background: #f8fafc;
}

.selected-adjustment-product strong,
.selected-adjustment-product small {
    display: block;
}

.selected-adjustment-product strong {
    margin-top: 4px;
    font-size: 12px;
}

.selected-adjustment-product small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

.adjustment-stock-box {
    flex: 0 0 auto;
    min-width: 105px;
    padding: 9px 12px;
    text-align: right;
    border-radius: 9px;
    background: var(--orange-soft);
    color: var(--orange-dark);
}

.adjustment-stock-box span,
.adjustment-stock-box strong {
    display: block;
}

.adjustment-stock-box span {
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.adjustment-stock-box strong {
    margin-top: 3px;
    font-size: 18px;
}

.adjustment-value-area {
    display: grid;
    grid-template-columns: minmax(150px, .55fr) minmax(180px, .6fr) minmax(280px, 1.2fr) auto;
    gap: 12px;
    align-items: end;
    margin-top: 13px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
}

.adjustment-add-button {
    min-height: 42px;
    white-space: nowrap;
}

.adjustment-editor-footer {
    justify-content: space-between;
}

.adjustment-final-note {
    margin-top: 13px;
}

@media (max-width: 950px) {
    .adjustment-product-grid,
    .adjustment-value-area {
        grid-template-columns: 1fr 1fr;
    }

    .adjustment-add-button {
        width: 100%;
    }
}

@media (max-width: 650px) {
    .adjustment-filter-grid,
    .adjustment-product-grid,
    .adjustment-value-area {
        grid-template-columns: 1fr !important;
    }

    .selected-adjustment-product {
        align-items: stretch;
        flex-direction: column;
    }

    .adjustment-stock-box {
        width: 100%;
        text-align: left;
    }

    .adjustment-editor-footer {
        gap: 8px;
    }

    .adjustment-editor-footer #adjustmentFooterLeft {
        display: none;
    }

    .adjustment-editor-footer .footer-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .adjustment-editor-footer .footer-actions > button {
        width: 100%;
    }

    .adjustment-editor-footer .footer-actions > .btn-primary:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}


/* Phase 5: Stores Management */
.nav-section-label {
    padding: 15px 16px 6px;
    color: rgba(255,255,255,.45);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.store-filter-grid {
    grid-template-columns: minmax(360px, 1.5fr) minmax(160px, .55fr) 100px;
}

.store-address-cell {
    min-width: 220px;
    max-width: 380px;
    white-space: normal;
    line-height: 1.45;
}

.store-form-grid textarea {
    width: 100%;
    resize: vertical;
    min-height: 84px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    background: #fff;
    outline: none;
    font: inherit;
}

.store-form-grid textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.10);
}

.store-metrics-area {
    margin-top: 16px;
}

.store-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.store-metric-card {
    min-height: 78px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafc;
}

.store-metric-card span,
.store-metric-card small,
.store-metric-card strong {
    display: block;
}

.store-metric-card span {
    color: var(--muted);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.store-metric-card strong {
    margin-top: 6px;
    font-size: 18px;
    color: var(--ink);
}

.store-metric-card small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

.store-user-list {
    display: grid;
    gap: 8px;
}

.store-user-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
}

.store-user-row .avatar {
    width: 34px;
    height: 34px;
}

.store-user-row strong,
.store-user-row span {
    display: block;
}

.store-user-row strong {
    font-size: 11px;
}

.store-user-row div > span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 9px;
}

.store-users-empty {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 11px;
}

.store-modal-footer {
    justify-content: space-between;
}

@media (max-width: 850px) {
    .store-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 650px) {
    .store-filter-grid,
    .store-metrics-grid {
        grid-template-columns: 1fr !important;
    }

    .store-modal-footer {
        gap: 8px;
    }

    .store-modal-footer #storeStatusActions,
    .store-modal-footer .footer-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .store-modal-footer #storeStatusActions:empty {
        display: none;
    }

    .store-modal-footer #storeStatusActions button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .store-modal-footer .footer-actions > button {
        width: 100%;
    }
}


/* Phase 6: Store Users / Access Management */
.user-filter-grid {
    grid-template-columns: minmax(330px, 1.45fr) minmax(150px, .55fr) minmax(150px, .55fr) 100px;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    min-height: 23px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.user-store-summary {
    min-width: 210px;
    max-width: 350px;
    white-space: normal;
}

.user-store-summary strong,
.user-store-summary small {
    display: block;
}

.user-store-summary small {
    margin-top: 3px;
    color: var(--muted);
    line-height: 1.35;
}

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

.user-password-area {
    margin-top: 16px;
    padding: 15px;
    border: 1px solid var(--orange-border);
    border-radius: 13px;
    background: #fffaf5;
}

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

.user-store-access-label {
    display: grid;
    gap: 7px;
}

.user-store-access-label > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.user-store-access-label .select2-container {
    width: 100% !important;
}

.user-store-access-label .select2-selection--multiple {
    min-height: 44px !important;
}

.user-activity-list {
    display: grid;
    gap: 7px;
}

.user-activity-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.user-activity-row strong,
.user-activity-row span {
    display: block;
}

.user-activity-row strong {
    font-size: 10px;
}

.user-activity-row span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.4;
}

.user-activity-row time {
    color: var(--muted);
    font-size: 8px;
    white-space: nowrap;
}

.user-activity-empty {
    padding: 16px;
    border: 1px dashed var(--line);
    border-radius: 10px;
}

.user-modal-footer {
    justify-content: space-between;
}

.store-users-manage-link {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.store-users-manage-link .btn-secondary {
    text-decoration: none;
}

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

@media (max-width: 650px) {
    .user-filter-grid,
    .user-profile-grid,
    .user-password-grid {
        grid-template-columns: 1fr !important;
    }

    .user-activity-row {
        grid-template-columns: 1fr;
    }

    .user-activity-row time {
        white-space: normal;
    }

    .user-modal-footer {
        gap: 8px;
    }

    .user-modal-footer #userStatusActions,
    .user-modal-footer .footer-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .user-modal-footer #userStatusActions:empty {
        display: none;
    }

    .user-modal-footer #userStatusActions button,
    .user-modal-footer #userStatusActions .receiving-meta {
        grid-column: 1 / -1;
        width: 100%;
    }

    .user-modal-footer .footer-actions > button {
        width: 100%;
    }
}


/* Sortable main tables */
.data-table th.sortable-column {
    position: relative;
    padding-right: 22px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease;
}

.data-table th.sortable-column::after {
    content: '↕';
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 10px;
    font-weight: 900;
    opacity: .72;
}

.data-table th.sortable-column:hover,
.data-table th.sortable-column:focus-visible {
    background: #fff7ed;
    color: #9a3412;
    outline: none;
}

.data-table th.sortable-column.sort-active {
    color: #c2410c;
    background: #fff7ed;
}

.data-table th.sortable-column.sort-asc::after {
    content: '▲';
    color: #f97316;
    opacity: 1;
}

.data-table th.sortable-column.sort-desc::after {
    content: '▼';
    color: #f97316;
    opacity: 1;
}


/* Phase 7: Stock Transfers */
.transfer-filter-grid {
    grid-template-columns: minmax(330px, 1.5fr) minmax(170px, .55fr) 100px;
}

.transfer-stats {
    margin-bottom: 18px;
}

.status-badge.in_transit {
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.transfer-workflow-note {
    line-height: 1.55;
}

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

.transfer-new-hint {
    margin-top: 16px;
}

.transfer-barcode-grid {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    gap: 14px;
}

.transfer-barcode-grid > label {
    min-width: 0;
}

.transfer-barcode-grid > label > span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.transfer-final-note {
    margin-top: 14px;
}

.transfer-editor-footer {
    justify-content: space-between;
}

.transfer-footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

#transferCameraVideo {
    display: block;
    width: 100%;
    min-height: 320px;
    max-height: 60vh;
    object-fit: cover;
}

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

@media (max-width: 650px) {
    .transfer-filter-grid,
    .transfer-new-grid,
    .transfer-header-grid {
        grid-template-columns: 1fr !important;
    }

    .transfer-editor-footer {
        gap: 8px;
    }

    .transfer-editor-footer #transferFooterLeft,
    .transfer-editor-footer .transfer-footer-actions {
        width: 100%;
    }

    .transfer-footer-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .transfer-footer-actions > button {
        width: 100%;
    }

    #dispatchTransferBtn,
    #completeTransferBtn {
        grid-column: 1 / -1;
    }

    #transferCameraVideo {
        min-height: 260px;
    }
}


/* Phase 7 UI hotfix: complete Stock Transfer control styling */

/*
 * All form controls inside transfer modals get the same visual system as
 * Receiving / Adjustments. This intentionally covers text, search, number,
 * select and textarea controls so future transfer fields do not appear as
 * raw browser-default controls.
 */
#newTransferModal input:not([type="hidden"]),
#newTransferModal select,
#newTransferModal textarea,
#transferEditorModal input:not([type="hidden"]),
#transferEditorModal select,
#transferEditorModal textarea {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    line-height: 1.35;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

#newTransferModal input::placeholder,
#newTransferModal textarea::placeholder,
#transferEditorModal input::placeholder,
#transferEditorModal textarea::placeholder {
    color: #94a3b8;
    opacity: 1;
}

#newTransferModal input:not([disabled]):hover,
#newTransferModal select:not([disabled]):hover,
#newTransferModal textarea:not([disabled]):hover,
#transferEditorModal input:not([disabled]):hover,
#transferEditorModal select:not([disabled]):hover,
#transferEditorModal textarea:not([disabled]):hover {
    border-color: #cbd5e1;
}

#newTransferModal input:focus,
#newTransferModal select:focus,
#newTransferModal textarea:focus,
#transferEditorModal input:focus,
#transferEditorModal select:focus,
#transferEditorModal textarea:focus {
    border-color: var(--orange) !important;
    box-shadow: 0 0 0 3px rgba(249,115,22,.12) !important;
    background: #fff;
}

#newTransferModal input:disabled,
#newTransferModal select:disabled,
#newTransferModal textarea:disabled,
#transferEditorModal input:disabled,
#transferEditorModal select:disabled,
#transferEditorModal textarea:disabled {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
}

/* Keep transfer textareas comfortably usable. */
#transferCancelReason {
    min-height: 92px;
    resize: vertical;
}

/* Source/destination panels now visually match the other transaction modules. */
.transfer-header-grid {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

#transferItemEntry {
    padding: 16px;
    border: 1px solid var(--orange-border);
    border-radius: 14px;
    background: #fffaf5;
}

#transferItemEntry .section-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 10px;
}

/* Barcode / product-search inputs */
.transfer-barcode-grid > label {
    position: relative;
    display: grid;
    gap: 6px;
}

.transfer-barcode-actions,
.transfer-barcode-grid .barcode-actions {
    display: flex;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
}

.transfer-barcode-actions input,
.transfer-barcode-grid .barcode-actions input {
    flex: 1 1 auto;
    min-width: 0;
}

.transfer-barcode-actions .btn-secondary,
.transfer-barcode-grid .barcode-actions .btn-secondary {
    min-height: 42px;
    flex: 0 0 auto;
}

/*
 * Product results are anchored to the product-search label rather than the
 * modal/page, preventing the dropdown from floating in the wrong position.
 */
.transfer-barcode-grid .product-search-results {
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1250;
}

/* Quantity input in the transfer item table. */
#transferItemRows .table-input {
    width: 92px;
    min-width: 82px;
    min-height: 36px;
    padding: 6px 8px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Table secondary text / store labels. */
#transferRows td small,
#transferItemRows td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.35;
}

#transferRows td strong,
#transferItemRows td strong {
    color: var(--ink);
}

/* Select2 inside both transfer modals must fill the field width. */
#newTransferModal .select2-container,
#transferEditorModal .select2-container {
    width: 100% !important;
}

/* Consistent Select2 height with the native 42px transfer controls. */
#newTransferModal .select2-container .select2-selection--single,
#transferEditorModal .select2-container .select2-selection--single {
    min-height: 42px;
}

#newTransferModal .select2-container--default .select2-selection--single .select2-selection__rendered,
#transferEditorModal .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 40px;
}

#newTransferModal .select2-container--default .select2-selection--single .select2-selection__arrow,
#transferEditorModal .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
}

/* Prevent action buttons from looking detached from their text fields. */
.transfer-barcode-grid .btn-secondary {
    border-radius: 10px;
}

/* Better spacing for the transfer document editor. */
#transferHeaderArea + #transferItemEntry {
    margin-top: 16px;
}

#transferEditorModal .modal-section {
    scroll-margin-top: 12px;
}

@media (max-width: 720px) {
    .transfer-barcode-actions,
    .transfer-barcode-grid .barcode-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .transfer-barcode-actions input,
    .transfer-barcode-grid .barcode-actions input {
        grid-column: 1 / -1;
        width: 100%;
    }

    .transfer-barcode-actions button,
    .transfer-barcode-grid .barcode-actions button {
        width: 100%;
    }

    #transferItemRows .table-input {
        width: 78px;
        min-width: 72px;
    }
}


/* Phase 7 partial transfer receiving */
[hidden] {
    display: none !important;
}

.transfer-receipt-history {
    display: grid;
    gap: 9px;
}

.transfer-receipt-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
}

.transfer-receipt-card strong,
.transfer-receipt-card span,
.transfer-receipt-card small {
    display: block;
}

.transfer-receipt-card span,
.transfer-receipt-card small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.4;
}

.transfer-receipt-meta {
    text-align: right;
}

.transfer-receive-table .transfer-receive-qty {
    width: 92px;
    min-width: 82px;
    min-height: 36px;
    padding: 6px 8px;
    text-align: right;
}

.transfer-receipt-remarks {
    display: grid;
    gap: 7px;
    margin-top: 16px;
}

.transfer-receipt-remarks > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

#transferReceiveModal textarea,
#transferReceiveModal input:not([type="hidden"]) {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

#transferReceiveModal input:focus,
#transferReceiveModal textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}

#transferShortageReason {
    min-height: 92px;
    resize: vertical;
}

@media (max-width: 650px) {
    .transfer-receipt-card {
        grid-template-columns: 1fr;
    }

    .transfer-receipt-meta {
        text-align: left;
    }

    .transfer-receive-table .transfer-receive-qty {
        width: 76px;
        min-width: 70px;
    }
}


/* Keyboard / Select2 interaction hotfix */
input:not([disabled]),
textarea:not([disabled]),
[contenteditable="true"],
.select2-search__field {
    user-select: text !important;
    -webkit-user-select: text !important;
}

.select2-search__field {
    pointer-events: auto !important;
    touch-action: auto !important;
    cursor: text !important;
    caret-color: auto;
}

/*
 * Select2 filters must remain interactive above surrounding filter panels
 * and modal content. Search fields are intentionally normal text inputs so
 * Ctrl/Cmd+C/V/X/A/Z and browser-native editing shortcuts remain untouched.
 */
.select2-container,
.select2-container--open,
.select2-dropdown,
.select2-search,
.select2-search__field {
    pointer-events: auto;
}

.inventory-filter-grid .select2-container {
    width: 100% !important;
}

.inventory-filter-grid .select2-dropdown {
    z-index: 1500;
}


/* Phase 8: Sales / POS */
.sales-filter-grid {
    grid-template-columns: minmax(300px, 1.4fr) minmax(180px, .7fr) minmax(150px, .55fr) 100px;
}

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

#newSaleModal input:not([type="hidden"]),
#newSaleModal select,
#saleEditorModal input:not([type="hidden"]),
#saleEditorModal select,
#saleEditorModal textarea {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

#newSaleModal input:focus,
#newSaleModal select:focus,
#saleEditorModal input:focus,
#saleEditorModal select:focus,
#saleEditorModal textarea:focus {
    border-color: var(--orange) !important;
    box-shadow: 0 0 0 3px rgba(249,115,22,.12) !important;
}

.sales-header-grid {
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

#saleItemEntry {
    padding: 16px;
    border: 1px solid var(--orange-border);
    border-radius: 14px;
    background: #fffaf5;
}

.sales-barcode-grid {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    gap: 14px;
}

.sales-barcode-grid > label {
    position: relative;
    display: grid;
    gap: 6px;
    min-width: 0;
}

.sales-barcode-grid > label > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.sales-barcode-actions {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.sales-barcode-actions input {
    flex: 1 1 auto;
}

.sales-barcode-actions button {
    flex: 0 0 auto;
    min-height: 42px;
}

.sales-barcode-grid .product-search-results {
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1450;
}

#saleItemRows .table-input {
    width: 84px;
    min-width: 76px;
    min-height: 36px;
    padding: 6px 8px;
    text-align: right;
}

#salesRows td small,
#saleItemRows td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.35;
}

.sales-totals {
    width: min(100%, 430px);
    margin: 16px 0 0 auto;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.sales-total-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 7px 0;
    color: var(--muted);
}

.sales-total-row strong {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.sales-total-row.grand {
    margin-top: 5px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    font-size: 14px;
    font-weight: 900;
}

.sales-total-row.grand strong {
    color: var(--orange-dark);
    font-size: 20px;
}

.sales-final-note {
    margin-top: 14px;
}

.sales-editor-footer {
    justify-content: space-between;
}

.sales-footer-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

#saleCameraVideo {
    display: block;
    width: 100%;
    min-height: 320px;
    max-height: 60vh;
    object-fit: cover;
}

#newSaleModal .select2-container,
#saleEditorModal .select2-container {
    width: 100% !important;
}

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

    .sales-barcode-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 650px) {
    .sales-filter-grid,
    .sales-new-grid,
    .sales-header-grid {
        grid-template-columns: 1fr !important;
    }

    .sales-barcode-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .sales-barcode-actions input {
        grid-column: 1 / -1;
    }

    .sales-barcode-actions button {
        width: 100%;
    }

    .sales-totals {
        width: 100%;
    }

    .sales-editor-footer,
    .sales-footer-actions {
        width: 100%;
    }

    .sales-footer-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .sales-footer-actions > button {
        width: 100%;
    }

    #completeSaleBtn {
        grid-column: 1 / -1;
    }

    #saleCameraVideo {
        min-height: 260px;
    }
}


/* Phase 9: Reports */
.reports-page-actions {
    align-items: flex-start;
}

.reports-export-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.reports-filter-grid {
    grid-template-columns: 150px 150px minmax(220px, .9fr) minmax(330px, 1.2fr);
    align-items: end;
}

.reports-range-presets {
    display: grid;
    gap: 7px;
}

.reports-range-presets > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.reports-preset-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.reports-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    margin-bottom: 18px;
}

.reports-chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.report-chart-panel {
    min-width: 0;
}

.report-chart-wrap {
    position: relative;
    min-height: 320px;
    padding: 8px 4px 2px;
}

.report-section {
    margin-top: 18px;
}

#reportProductRows td small,
#reportSalesRows td small,
#reportInventoryRows td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.35;
}

.reports-inventory-toolbar {
    align-items: end;
    gap: 12px;
}

.reports-inventory-filters {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(180px, .7fr);
    gap: 8px;
    width: min(100%, 620px);
}

.reports-inventory-filters input,
.reports-inventory-filters select {
    width: 100%;
}

.report-inventory-summary {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin: 10px 0 16px;
}

.reports-filter-panel input[type="date"],
.reports-inventory-filters input {
    min-height: 42px;
}

@media (max-width: 1050px) {
    .reports-filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .reports-chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .reports-page-actions,
    .reports-export-group {
        width: 100%;
    }

    .reports-export-group {
        display: grid;
        grid-template-columns: 1fr;
    }

    .reports-export-group > button {
        width: 100%;
    }

    .reports-filter-grid {
        grid-template-columns: 1fr !important;
    }

    .reports-preset-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .reports-preset-buttons > button {
        width: 100%;
    }

    .reports-inventory-toolbar {
        align-items: stretch;
    }

    .reports-inventory-filters {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .report-chart-wrap {
        min-height: 260px;
    }
}


/* Phase 10: Sale Returns */
.returns-filter-grid {
    grid-template-columns:
        minmax(320px, 1.35fr)
        minmax(190px, .7fr)
        minmax(150px, .55fr)
        100px;
}

.return-create-grid {
    grid-template-columns: 1fr;
}

.return-sale-select-label {
    min-width: 0;
}

#newReturnModal textarea,
#returnEditorModal textarea,
#returnEditorModal input:not([type="hidden"]) {
    width: 100%;
    min-width: 0;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

#newReturnModal textarea:focus,
#returnEditorModal textarea:focus,
#returnEditorModal input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}

#newReturnModal .select2-container {
    width: 100% !important;
}

#newReturnModal .select2-container .select2-selection--single {
    min-height: 42px;
}

.return-header-card {
    display: grid;
    gap: 14px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.return-header-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.return-header-meta > div {
    min-width: 0;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
}

.return-header-meta span,
.return-reason-field > span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.return-header-meta strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.return-reason-field {
    display: grid;
    gap: 6px;
}

.return-final-note {
    margin-top: 14px;
}

#returnSourceRows td small,
#returnItemRows td small,
#returnRows td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.35;
}

#returnSourceRows .table-input {
    width: 84px;
    min-width: 76px;
    min-height: 36px;
    padding: 6px 8px;
    text-align: right;
}

.return-totals {
    width: min(100%, 420px);
    margin: 16px 0 0 auto;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.return-total-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 7px 0;
    color: var(--muted);
}

.return-total-row strong {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.return-total-row.grand {
    margin-top: 5px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    font-weight: 900;
}

.return-total-row.grand strong {
    color: var(--orange-dark);
    font-size: 19px;
}

.return-editor-footer {
    justify-content: space-between;
}

.return-footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 950px) {
    .returns-filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .return-header-meta {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 650px) {
    .returns-filter-grid,
    .return-header-meta {
        grid-template-columns: 1fr !important;
    }

    .return-editor-footer,
    .return-footer-actions {
        width: 100%;
    }

    .return-footer-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .return-footer-actions > button {
        width: 100%;
    }

    #completeReturnBtn {
        grid-column: 1 / -1;
    }
}


/* Phase 11: Promotions + POS automatic discounts */
.promotion-filter-grid {
    grid-template-columns: minmax(360px, 1.4fr) minmax(170px, .55fr) 100px;
}

.promotion-form-grid {
    grid-template-columns: 1.4fr .55fr 1fr 1fr;
}

.promotion-scope-grid {
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.35fr);
    margin-top: 15px;
}

.promotion-scope-grid label {
    min-width: 0;
}

.promotion-scope-grid small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.promotion-toggle-row {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafc;
}

.toggle-check {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-check input {
    width: 18px !important;
    min-height: 18px !important;
    height: 18px;
    margin: 0;
    accent-color: var(--orange);
}

.toggle-check > span {
    margin: 0 !important;
    color: var(--ink) !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

#promotionModal input:not([type="hidden"]),
#promotionModal select,
#promotionModal textarea {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

#promotionModal input:focus,
#promotionModal select:focus,
#promotionModal textarea:focus {
    border-color: var(--orange) !important;
    box-shadow: 0 0 0 3px rgba(249,115,22,.12) !important;
}

#promotionModal .select2-container {
    width: 100% !important;
}

#promotionModal .select2-container--default .select2-selection--multiple {
    min-height: 42px;
    padding: 3px 5px;
}

.promotion-modal-footer {
    justify-content: space-between;
}

.status-badge.scheduled {
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.status-badge.expired {
    color: #854d0e;
    background: #fefce8;
    border: 1px solid #fde68a;
}

.promotion-discount {
    color: #15803d;
    font-weight: 800;
    white-space: nowrap;
}

.promotion-live-price {
    color: #15803d;
    font-weight: 800;
}

.promotion-live-price s {
    margin-right: 4px;
    color: var(--muted);
    font-weight: 600;
}

@media (max-width: 1100px) {
    .promotion-form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 850px) {
    .promotion-scope-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 650px) {
    .promotion-filter-grid,
    .promotion-form-grid {
        grid-template-columns: 1fr !important;
    }

    .promotion-toggle-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .promotion-modal-footer {
        gap: 8px;
    }

    .promotion-modal-footer > div,
    .promotion-modal-footer .footer-actions {
        width: 100%;
    }
}


/* Phase 12: Audit / Activity & Exception Monitoring */
.audit-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 5px;
    width: fit-content;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.audit-tab {
    min-height: 40px;
    padding: 8px 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.audit-tab.active {
    background: var(--orange);
    color: #fff;
}

.audit-tab-panel[hidden] {
    display: none !important;
}

.audit-exception-stats,
.audit-activity-stats {
    margin-bottom: 18px;
}

.audit-exception-filters {
    grid-template-columns:
        minmax(320px, 1.3fr)
        minmax(190px, .65fr)
        minmax(150px, .5fr)
        minmax(220px, .7fr);
}

.audit-activity-filters {
    grid-template-columns:
        minmax(300px, 1.2fr)
        minmax(210px, .75fr)
        minmax(150px, .45fr)
        minmax(200px, .7fr)
        145px
        145px
        100px;
}

.exception-badge,
.operation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.exception-badge.critical {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.exception-badge.warning {
    color: #9a3412;
    background: #fff7ed;
    border-color: #fed7aa;
}

.exception-badge.info {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.operation-badge.create {
    color: #166534;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.operation-badge.update {
    color: #9a3412;
    background: #fff7ed;
    border-color: #fed7aa;
}

.operation-badge.delete {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.operation-badge.select {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.exception-row td {
    vertical-align: top;
}

.exception-row.critical {
    background: #fffafa;
}

.exception-row.warning {
    background: #fffdf8;
}

#exceptionRows td small,
#activityRows td small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.45;
    white-space: normal;
}

.activity-description {
    min-width: 280px;
    max-width: 520px;
    white-space: normal;
    word-break: break-word;
}

@media (max-width: 1200px) {
    .audit-activity-filters {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .audit-exception-filters {
        grid-template-columns: 1fr 1fr;
    }

    .audit-activity-filters {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 650px) {
    .audit-tabs {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .audit-tab {
        width: 100%;
    }

    .audit-exception-filters,
    .audit-activity-filters {
        grid-template-columns: 1fr !important;
    }

    .activity-description {
        min-width: 220px;
    }
}


/* ============================================================
   Global modal overflow / large-data resilience hotfix
   ============================================================
   Some create/edit modals wrap .modal-body + .modal-footer inside a <form>.
   Without a constrained flex form, a long body can grow past the card while
   .modal-card overflow:hidden clips the data/footer.  Apply the same layout
   contract to both direct-body and form-wrapped modals.
*/

/* Every modal is a bounded flex column. */
.modal-card {
    min-width: 0;
    min-height: 0;
}

/*
 * Forms that directly wrap modal body/footer must become the modal's
 * scroll-layout container. This fixes:
 * Stores, Users, Receiving create, Adjustments create, Transfers create,
 * Sales create, Sale Returns create, and Promotions.
 */
.modal-card > form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

/* Header/footer never get pushed outside the visible modal. */
.modal-card > .modal-header,
.modal-card > .modal-footer,
.modal-card > form > .modal-footer {
    flex: 0 0 auto;
    min-width: 0;
}

/* The data area is the only vertical scrolling region. */
.modal-card > .modal-body,
.modal-card > form > .modal-body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

/*
 * Long tables remain inside the body. Horizontal overflow belongs to the
 * table wrapper instead of expanding/clipping the entire modal.
 */
.modal-body .table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.modal-body .data-table {
    width: max-content;
    min-width: 100%;
    max-width: none;
}

/* Allow long text values to wrap instead of forcing modal width. */
.modal-body .data-table td,
.modal-body .data-table th {
    overflow-wrap: anywhere;
}

.modal-body .data-table td > strong,
.modal-body .data-table td > small,
.modal-body .data-table td > span,
.modal-body .data-table td > a,
.modal-body .data-table td > button {
    max-width: 100%;
}

/*
 * Keep ordinary detail/form grids from overflowing because of a long code,
 * customer name, address, reason, username, description, etc.
 */
.modal-body .form-grid,
.modal-body .detail-grid,
.modal-body .modal-section,
.modal-body .section-title,
.modal-body [class$="-grid"],
.modal-body [class$="-card"],
.modal-body label,
.modal-body label > *,
.modal-body .select2-container {
    min-width: 0;
    max-width: 100%;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
    max-width: 100%;
}

.modal-body textarea {
    resize: vertical;
}

/* Header/subtitle text may wrap while the close button stays reachable. */
.modal-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.modal-header h3,
.modal-header .modal-subtitle,
.modal-header p {
    max-width: 100%;
    overflow-wrap: anywhere;
}

/*
 * Large multi-selects (notably Promotions) may contain many selected values.
 * Keep their selection area bounded and internally scrollable.
 */
.modal-card .select2-container--default
.select2-selection--multiple {
    max-height: 130px;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-card .select2-container--default
.select2-selection--multiple
.select2-selection__rendered {
    display: flex;
    flex-wrap: wrap;
    max-width: 100%;
    padding-bottom: 3px;
}

.modal-card .select2-selection__choice {
    max-width: calc(100% - 8px);
}

.modal-card .select2-selection__choice__display {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

/*
 * Select2 result lists with large datasets get their own predictable scroll
 * area rather than extending beyond the viewport.
 */
.modal-card .select2-results__options {
    max-height: min(42vh, 360px) !important;
    overflow-y: auto !important;
}

/*
 * Desktop/tablet: use more of the viewport while still preserving breathing
 * room. This helps high-data editor modals without making small forms huge.
 */
@media (min-width: 651px) {
    .modal-card {
        max-height: min(92vh, 960px);
    }

    .modal-card.modal-large,
    .modal-card.modal-xl {
        max-height: min(94vh, 1000px);
    }

    .modal-body {
        scrollbar-gutter: stable both-edges;
    }
}

/*
 * Mobile already uses full-screen modal sheets. Explicitly keep form-wrapped
 * modals at full available height and make only their body scroll.
 */
@media (max-width: 650px) {
    .modal-card > form {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: 100% !important;
        overflow: hidden !important;
    }

    .modal-card > form > .modal-body {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-card > form > .modal-footer {
        flex: 0 0 auto !important;
    }

    .modal-body .data-table {
        width: max-content;
        min-width: 620px;
    }

    .modal-card .select2-container--default
    .select2-selection--multiple {
        max-height: 105px;
    }

    .modal-card .select2-results__options {
        max-height: min(38vh, 300px) !important;
    }
}


/* Phase 13: Advanced operational dashboard */
.dashboard-page-actions {
    align-items: flex-start;
}

.dashboard-section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: 24px 0 12px;
}

.dashboard-section-heading h3 {
    margin: 3px 0 0;
    font-size: 18px;
}

.executive-kpis .stat-card,
.inventory-health-kpis .stat-card {
    min-height: 108px;
}

.executive-kpis .stat-card small,
.inventory-health-kpis .stat-card small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 1.4;
}

.dashboard-kpi-charts {
    margin-top: 18px;
}

.dashboard-sales-chart {
    min-height: 320px;
}

.pending-operation-list {
    display: grid;
    gap: 8px;
}

.pending-operation-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    transition:
        border-color .18s ease,
        background .18s ease,
        transform .18s ease;
}

.pending-operation-list a:hover {
    border-color: rgba(249,115,22,.45);
    background: #fffaf5;
    transform: translateY(-1px);
}

.pending-operation-list span {
    font-size: 11px;
    font-weight: 750;
}

.pending-operation-list strong {
    min-width: 30px;
    color: var(--orange);
    font-size: 18px;
    text-align: right;
}

.dashboard-top-products td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

@media (max-width: 750px) {
    .dashboard-section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-sales-chart {
        min-height: 280px;
    }
}


/* Phase 14: Procurement / Suppliers / Replenishment */
.procurement-tabs {
    display:flex;
    gap:8px;
    width:fit-content;
    max-width:100%;
    margin:0 0 16px;
    padding:5px;
    border:1px solid var(--line);
    border-radius:12px;
    background:#fff;
}
.procurement-tab {
    min-height:40px;
    padding:8px 14px;
    border:0;
    border-radius:9px;
    background:transparent;
    color:var(--muted);
    font:inherit;
    font-weight:800;
    cursor:pointer;
}
.procurement-tab.active {
    background:var(--orange);
    color:#fff;
}
#procOrdersPanel[hidden],
#procReplenishmentPanel[hidden] {
    display:none !important;
}
.procurement-item-entry {
    grid-template-columns:minmax(260px,2fr) 100px 140px auto;
    align-items:end;
}
.inline-editor-panel {
    margin:14px 0;
    padding:14px;
    border:1px solid var(--line);
    border-radius:12px;
    background:#fffaf5;
}
.inline-editor-panel[hidden] {
    display:none !important;
}
.inline-actions {
    display:flex;
    justify-content:flex-end;
    gap:8px;
    margin-top:12px;
}
.workflow-actions {
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-right:auto;
}
.linked-doc-list {
    display:grid;
    gap:8px;
}
.linked-doc-row {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:10px 12px;
    border:1px solid var(--line);
    border-radius:9px;
    color:var(--ink);
    text-decoration:none;
    background:#fff;
}
.linked-doc-row:hover {
    border-color:rgba(249,115,22,.45);
    background:#fffaf5;
}
.linked-doc-row span {
    color:var(--muted);
    font-size:10px;
}
.table-input {
    width:90px;
    min-width:80px;
    padding:6px 7px;
}
.status-badge.draft {
    background:#f8fafc;
    color:#475569;
    border-color:#cbd5e1;
}
.status-badge.approved {
    background:#fff7ed;
    color:#9a3412;
    border-color:#fed7aa;
}
.status-badge.partially_received {
    background:#fffbeb;
    color:#92400e;
    border-color:#fde68a;
}
@media (max-width:900px) {
    .procurement-item-entry {
        grid-template-columns:1fr 1fr;
    }
    .procurement-item-entry .span-2 {
        grid-column:1 / -1;
    }
}
@media (max-width:650px) {
    .procurement-tabs {
        display:grid;
        width:100%;
        grid-template-columns:1fr;
    }
    .procurement-tab {
        width:100%;
    }
    .procurement-item-entry {
        grid-template-columns:1fr;
    }
    .procurement-item-entry .span-2 {
        grid-column:auto;
    }
    .linked-doc-row {
        align-items:flex-start;
        flex-direction:column;
    }
}


/* Phase 14 R2: procurement setup / New PO robustness */
#procurementSetupAlert[hidden] {
    display: none !important;
}

#procurementSetupAlert a {
    font-weight: 850;
}

#poCreateModal .modal-footer .text-link {
    margin-right: auto;
}

#newPurchaseOrder:disabled {
    cursor: wait;
    opacity: .65;
}

@media (max-width: 650px) {
    #poCreateModal .modal-footer .text-link {
        width: 100%;
        margin: 0 0 6px;
        text-align: center;
    }
}


/* Phase 14 R5: modal visibility compatibility.
   Standard behavior uses .open; hidden=false is also supported as a fallback. */


/* ================================================================
   Phase 14 R6 — Complete UI style normalization
   Applies a consistent COLEROSH visual contract to old and new UI.
   ================================================================ */

/* ---------- Global interactive-element normalization ---------- */
button,
input,
select,
textarea {
    font: inherit;
}

button {
    -webkit-appearance: none;
    appearance: none;
}

input,
select,
textarea {
    accent-color: var(--orange);
}

textarea {
    line-height: 1.5;
    resize: vertical;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(249, 115, 22, .18);
    outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
}

/* ---------- Complete button family ---------- */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-table {
    transition:
        border-color .16s ease,
        background-color .16s ease,
        color .16s ease,
        box-shadow .16s ease,
        transform .16s ease,
        opacity .16s ease;
}

.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled),
.btn-danger:hover:not(:disabled),
.btn-table:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled),
.btn-danger:active:not(:disabled),
.btn-table:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-danger {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid #fecaca;
    border-radius: 9px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.btn-danger:hover:not(:disabled) {
    border-color: #fca5a5;
    background: #fee2e2;
    color: #991b1b;
}

.btn-danger:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-table.danger,
.btn-table.danger-table {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.btn-table.danger:hover,
.btn-table.danger-table:hover {
    border-color: #fca5a5;
    background: #fee2e2;
    color: #991b1b;
}

/* ---------- Generic modal form styling ----------
   Handles fields placed outside .form-grid as well as future fields. */
.modal-body form {
    min-width: 0;
}

.modal-body form > label:not(.check-field),
.inline-editor-panel > label:not(.check-field),
.modal-section > label:not(.check-field) {
    display: grid;
    gap: 6px;
    margin-top: 13px;
    min-width: 0;
}

.modal-body form > label:not(.check-field) > span,
.inline-editor-panel > label:not(.check-field) > span,
.modal-section > label:not(.check-field) > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.modal-body form > label:not(.check-field) > input,
.modal-body form > label:not(.check-field) > select,
.modal-body form > label:not(.check-field) > textarea,
.inline-editor-panel > label:not(.check-field) > input,
.inline-editor-panel > label:not(.check-field) > select,
.inline-editor-panel > label:not(.check-field) > textarea,
.modal-section > label:not(.check-field) > input,
.modal-section > label:not(.check-field) > select,
.modal-section > label:not(.check-field) > textarea {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

.modal-body form > label:not(.check-field) > textarea,
.inline-editor-panel > label:not(.check-field) > textarea,
.modal-section > label:not(.check-field) > textarea {
    min-height: 78px;
}

.modal-body form > label:not(.check-field) > input:focus,
.modal-body form > label:not(.check-field) > select:focus,
.modal-body form > label:not(.check-field) > textarea:focus,
.inline-editor-panel > label:not(.check-field) > input:focus,
.inline-editor-panel > label:not(.check-field) > select:focus,
.inline-editor-panel > label:not(.check-field) > textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.10);
}

/* ---------- Form-grid utility coverage ---------- */
.form-grid.two-col,
.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .span-2,
.form-grid > .span-2 {
    grid-column: span 2;
}

/* Checkbox/radio fields must not inherit full-size text-input rules. */
.check-field,
.form-grid .check-field {
    display: flex !important;
    align-items: center;
    align-self: end;
    gap: 9px;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

.check-field:hover {
    border-color: var(--orange-border);
    background: var(--orange-soft);
}

.check-field input[type="checkbox"],
.check-field input[type="radio"],
.form-grid .check-field input[type="checkbox"],
.form-grid .check-field input[type="radio"] {
    flex: 0 0 auto;
    width: 17px !important;
    height: 17px !important;
    min-width: 17px !important;
    min-height: 17px !important;
    margin: 0;
    padding: 0;
    box-shadow: none !important;
}

.check-field > span,
.form-grid .check-field > span {
    display: inline !important;
    margin: 0 !important;
    color: var(--ink) !important;
    font-size: 11px !important;
    font-weight: 750 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

/* ---------- Modal size utilities ---------- */
.modal-card.modal-small,
.modal-small {
    width: min(500px, 100%);
}

.modal-card.modal-large,
.modal-card.modal-xl,
.modal-card.modal-small {
    min-width: 0;
}

/* ---------- Panel / dashboard utility coverage ---------- */
.panel-wide {
    min-width: 0;
    overflow: hidden;
}

.dashboard-grid.second-row {
    align-items: start;
}

.second-row > * {
    min-width: 0;
}

/* ---------- Table utility coverage ---------- */
.product-table,
.inventory-table {
    width: 100%;
    table-layout: auto;
}

.product-table td,
.inventory-table td {
    min-width: 0;
}

.data-table tbody tr {
    transition: background-color .14s ease;
}

.data-table tbody tr:hover {
    background: #fcfdff;
}

.data-table td,
.data-table th {
    max-width: 420px;
}

.data-table td {
    overflow-wrap: anywhere;
}

.data-table .num {
    white-space: nowrap;
}

.table-input,
.reorder-input {
    max-width: 110px;
}

/* ---------- Report preset coverage ---------- */
.report-preset {
    white-space: nowrap;
}

.report-preset:hover {
    border-color: var(--orange-border);
    color: var(--orange-dark);
    background: var(--orange-soft);
}

/* ---------- Phase 14 list/filter layouts ---------- */
.supplier-filter-grid,
.procurement-filter-grid {
    grid-template-columns:
        minmax(300px, 1.7fr)
        minmax(170px, .55fr)
        100px;
}

.replenishment-filter-grid {
    grid-template-columns:
        minmax(220px, .65fr)
        minmax(320px, 1.35fr);
}

.procurement-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ---------- Supplier module polish ---------- */
#supplierForm {
    min-width: 0;
}

#supplierForm .form-grid {
    margin-bottom: 0;
}

#supplierForm > label:first-of-type {
    margin-top: 13px;
}

#supplierProductsPanel {
    padding-top: 4px;
}

#supplierProductsPanel > h4,
#poAddItemPanel > h4,
.modal-section > h4 {
    margin: 0 0 10px;
    color: var(--ink);
    font-size: 13px;
}

#supplierProductRows .btn-table,
#poItemRows .btn-table {
    white-space: nowrap;
}

#supplierSetupAlert {
    box-shadow: 0 7px 20px rgba(146, 64, 14, .05);
}

/* ---------- Procurement module polish ---------- */
#procurementSetupAlert {
    box-shadow: 0 7px 20px rgba(146, 64, 14, .05);
}

#poSummary {
    color: var(--text);
    font-size: 10px;
    font-weight: 700;
}

.procurement-item-entry > .btn-secondary,
.procurement-item-entry > .btn-primary {
    min-height: 42px;
    align-self: end;
}

.inline-editor-panel {
    box-shadow: inset 0 0 0 1px rgba(249,115,22,.02);
}

.linked-doc-row strong {
    color: var(--ink);
    font-size: 11px;
}

.workflow-actions .btn-primary,
.workflow-actions .btn-secondary,
.workflow-actions .btn-danger {
    min-height: 36px;
}

/* ---------- Select2 fallback/consistency inside forms ---------- */
.form-grid .select2-container,
.filter-grid .select2-container,
.modal-body .select2-container {
    width: 100% !important;
    min-width: 0;
}

.check-field + .select2-container {
    min-width: 0;
}

/* ---------- Empty and message states ---------- */
.empty-card {
    min-height: 68px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--line);
    border-radius: 10px;
    background: #fbfcfe;
}

.alert strong {
    font-weight: 850;
}

/* ---------- Responsive normalization ---------- */
@media (max-width: 1050px) {
    .supplier-filter-grid,
    .procurement-filter-grid {
        grid-template-columns: minmax(240px, 1fr) minmax(150px, .55fr) 100px;
    }

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

@media (max-width: 760px) {
    .supplier-filter-grid,
    .procurement-filter-grid,
    .replenishment-filter-grid,
    .form-grid.two-col,
    .two-col {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2,
    .form-grid > .span-2 {
        grid-column: auto;
    }

    .check-field,
    .form-grid .check-field {
        align-self: stretch;
    }
}

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

    .modal-footer {
        flex-wrap: wrap;
    }

    .modal-footer > .btn-primary,
    .modal-footer > .btn-secondary,
    .modal-footer > .btn-danger {
        min-height: 40px;
    }

    .workflow-actions {
        width: 100%;
        margin-right: 0;
    }
}


/* ================================================================
   Phase 14 R7 — Strict modal visibility contract
   ================================================================
   Existing COLEROSH modals are present in page markup but must remain
   invisible until their module JavaScript adds the .open class.
*/
.modal-backdrop {
    display: none;
    pointer-events: none;
}

.modal-backdrop[hidden] {
    display: none !important;
    pointer-events: none !important;
}

.modal-backdrop.open {
    display: flex;
    pointer-events: auto;
}


/* ================================================================
   Phase 14 R8 — Semantic form/control styling audit
   ================================================================
   A modal label is a visual field regardless of whether the form is:
     .modal-body > form > label
   or:
     form > .modal-body > label
   or:
     .modal-body > label

   This prevents browser-default controls when markup hierarchy changes.
*/

/* ----- Universal labelled modal field ----- */
.modal-card label:not(.check-field):not(.toggle-check) {
    min-width: 0;
}

.modal-card label:not(.check-field):not(.toggle-check) > span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.modal-card label:not(.check-field):not(.toggle-check) >
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
.modal-card label:not(.check-field):not(.toggle-check) > select,
.modal-card label:not(.check-field):not(.toggle-check) > textarea {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 42px;
    margin: 0;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    line-height: 1.35;
    outline: none;
    box-shadow: none;
}

.modal-card label:not(.check-field):not(.toggle-check) > textarea {
    min-height: 86px;
    padding-top: 10px;
    padding-bottom: 10px;
    resize: vertical;
}

.modal-card label:not(.check-field):not(.toggle-check) >
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):hover:not(:disabled),
.modal-card label:not(.check-field):not(.toggle-check) > select:hover:not(:disabled),
.modal-card label:not(.check-field):not(.toggle-check) > textarea:hover:not(:disabled) {
    border-color: #cbd5e1;
}

.modal-card label:not(.check-field):not(.toggle-check) >
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):focus,
.modal-card label:not(.check-field):not(.toggle-check) > select:focus,
.modal-card label:not(.check-field):not(.toggle-check) > textarea:focus {
    border-color: var(--orange) !important;
    box-shadow: 0 0 0 3px rgba(249,115,22,.10) !important;
}

.modal-card label:not(.check-field):not(.toggle-check) >
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):disabled,
.modal-card label:not(.check-field):not(.toggle-check) > select:disabled,
.modal-card label:not(.check-field):not(.toggle-check) > textarea:disabled {
    border-color: var(--line);
    background: #f8fafc;
    color: #64748b;
}

/*
 * Standalone fields must stack label over control.
 * This directly fixes PO Remarks and Cancel Reason from the screenshots.
 */
.modal-field-full,
.modal-card > form > .modal-body > label:not(.check-field):not(.toggle-check),
.modal-card > .modal-body > label:not(.check-field):not(.toggle-check),
.modal-body > form > label:not(.check-field):not(.toggle-check),
.inline-editor-panel > label:not(.check-field):not(.toggle-check) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    width: 100%;
    max-width: 100%;
}

.modal-field-full,
.modal-card > form > .modal-body > label:not(.check-field):not(.toggle-check),
.modal-body > form > label:not(.check-field):not(.toggle-check),
.inline-editor-panel > label:not(.check-field):not(.toggle-check) {
    margin-top: 14px;
}

/* Fields inside a grid do not need added vertical margins. */
.form-grid > label {
    margin-top: 0 !important;
}

/* ----- Complete form-grid control contract, including textarea ----- */
.form-grid textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 86px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    line-height: 1.4;
    outline: none;
    resize: vertical;
}

.form-grid textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249,115,22,.10);
}

.form-grid textarea:disabled {
    background: #f8fafc;
    color: #64748b;
}

/* ----- Screenshot-specific procurement polish ----- */
#poCreateModal .modal-body,
#poCancelModal .modal-body {
    background: #fff;
}

#poCreateModal .modal-field-full textarea {
    min-height: 92px;
}

#poCancelModal .modal-field-full {
    margin-top: 0;
}

#poCancelModal .modal-field-full textarea {
    min-height: 120px;
}

#poCreateModal .modal-footer,
#poCancelModal .modal-footer {
    align-items: center;
}

#poCreateModal .modal-footer .btn-primary,
#poCreateModal .modal-footer .btn-secondary,
#poCancelModal .modal-footer .btn-danger,
#poCancelModal .modal-footer .btn-secondary {
    min-height: 42px;
    padding-left: 16px;
    padding-right: 16px;
}

#poCreateModal .modal-footer .text-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 7px;
    border-radius: 8px;
    text-decoration: none;
}

#poCreateModal .modal-footer .text-link:hover {
    background: var(--orange-soft);
    color: var(--orange-dark);
}

/* ----- Supplier standalone fields ----- */
#supplierForm > .modal-field-full textarea {
    min-height: 82px;
}

/* ----- Consistent required-field / helper appearance ----- */
.modal-card label > small,
.modal-card .field-help {
    color: var(--muted);
    font-size: 9px;
    line-height: 1.45;
}

/* ----- Footer action consistency across every modal ----- */
.modal-footer .btn-primary,
.modal-footer .btn-secondary,
.modal-footer .btn-danger {
    min-height: 40px;
}

.modal-footer .text-link {
    line-height: 1.25;
}

/* ----- Native date/select visual consistency ----- */
.modal-card input[type="date"],
.modal-card input[type="datetime-local"],
.modal-card select {
    color-scheme: light;
}

/* ----- Mobile field behavior ----- */
@media (max-width: 650px) {
    .modal-field-full,
    .modal-card > form > .modal-body > label:not(.check-field):not(.toggle-check),
    .modal-card > .modal-body > label:not(.check-field):not(.toggle-check),
    .modal-body > form > label:not(.check-field):not(.toggle-check),
    .inline-editor-panel > label:not(.check-field):not(.toggle-check) {
        width: 100%;
    }

    #poCreateModal .modal-footer .text-link {
        width: 100%;
        justify-content: center;
        margin: 0 0 4px;
    }

    #poCancelModal .modal-field-full textarea {
        min-height: 110px;
    }
}


/* ================================================================
   Phase 15 R2 — Cross-device responsive navigation
   ================================================================ */
.sidebar-overlay {
    display: none;
    visibility: hidden;
    position: fixed;
    inset: 0;
    z-index: 40;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, .44);
    opacity: 0;
    pointer-events: none;
    cursor: default;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .18s ease, visibility .18s ease;
}

body.sidebar-open {
    /* Keep layout viewport stable while drawer is open. */
    overscroll-behavior: contain;
}

@media (max-width: 1366px),
       (max-width: 1600px) and (hover: none) and (pointer: coarse) {
    .sidebar {
        transform: translate3d(-102%, 0, 0);
        transition: transform .22s ease;
        box-shadow: 20px 0 40px rgba(15,23,42,.16);
        z-index: 42;
        will-change: transform;
        backface-visibility: hidden;
    }

    .sidebar.open {
        transform: translate3d(0, 0, 0);
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-overlay.show {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
    }

    .main {
        width: 100%;
        margin-left: 0;
    }

    .topbar {
        z-index: 41;
        padding-left: 18px;
        padding-right: 18px;
    }

    .menu-toggle {
        display: inline-grid !important;
        place-items: center;
        position: relative;
        z-index: 43;
        flex: 0 0 auto;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        border: 1px solid var(--line);
        border-radius: 11px;
        background: #fff;
        color: var(--ink);
        font-size: 23px;
        line-height: 1;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }

    .menu-toggle:hover {
        border-color: var(--orange-border);
        background: var(--orange-soft);
        color: var(--orange-dark);
    }

    .menu-toggle:active { transform: scale(.97); }
    .menu-toggle:focus-visible {
        outline: 3px solid rgba(249,115,22,.18);
        outline-offset: 2px;
    }

    .content { padding: 22px 18px 40px; }
}

@media (max-width: 700px) {
    .sidebar { width: min(86vw, 320px); }
    .topbar { height: 78px; }
    .brand {
        height: 78px;
        padding-top: 16px;
        padding-bottom: 16px;
    }
    .menu-toggle {
        width: 42px;
        height: 42px;
        min-width: 42px;
        min-height: 42px;
    }
}

@media (max-width: 420px) {
    .sidebar { width: min(90vw, 305px); }
    .topbar h1 { font-size: 17px; }
    .topbar p { font-size: 10px; }
}


/* Phase 15: Procurement Reports */
.procurement-report-filter-grid {
    grid-template-columns:
        minmax(210px, .7fr)
        minmax(250px, .9fr)
        150px
        150px
        auto;
}

.procurement-report-filter-grid > .btn-primary {
    min-height: 42px;
    align-self: end;
}

.procurement-report-kpis {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.procurement-report-kpis .stat-card small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
}

.procurement-report-charts {
    margin-top: 18px;
}

#procCostRows td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

@media (max-width: 1250px) {
    .procurement-report-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .procurement-report-filter-grid > .btn-primary {
        width: fit-content;
    }
}

@media (max-width: 720px) {
    .procurement-report-kpis,
    .procurement-report-filter-grid {
        grid-template-columns: 1fr;
    }

    .procurement-report-filter-grid > .btn-primary {
        width: 100%;
    }
}


/* ================================================================
   Phase 15 R3 — deterministic hamburger safety layer
   ================================================================ */
@media (max-width: 1366px),
       (max-width: 1600px) and (hover: none) and (pointer: coarse) {
    #menuToggle.menu-toggle {
        display: inline-grid !important;
        pointer-events: auto !important;
        touch-action: manipulation;
    }

    #sidebar.sidebar {
        transform: translate3d(-102%, 0, 0) !important;
    }

    #sidebar.sidebar.open {
        transform: translate3d(0, 0, 0) !important;
    }

    #sidebarOverlay.sidebar-overlay {
        visibility: hidden;
        opacity: 0;
        pointer-events: none !important;
    }

    #sidebarOverlay.sidebar-overlay.show {
        visibility: visible;
        opacity: 1;
        pointer-events: auto !important;
    }
}

/* Phase 16 Inventory Intelligence */
.intelligence-filters{grid-template-columns:minmax(220px,.8fr) 160px minmax(260px,1fr) auto}
.intelligence-filters>.btn-primary{align-self:end;min-height:42px}
.intelligence-kpis{grid-template-columns:repeat(5,minmax(0,1fr))}
.intelligence-kpis small,.data-table td small{display:block;margin-top:4px;color:var(--muted);font-size:9px}
.intelligence-po-builder{margin:18px 0}
.intelligence-po-builder .inline-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.intelligence-po-builder .select2-container{min-width:280px}
#intelRows .table-input{width:82px;min-width:72px;text-align:right}
#intelRows input[type=checkbox],#intelSelectAll{width:18px;height:18px;accent-color:var(--orange)}
@media(max-width:1000px){.intelligence-kpis{grid-template-columns:repeat(3,minmax(0,1fr))}.intelligence-filters{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:650px){.intelligence-kpis,.intelligence-filters{grid-template-columns:1fr}.intelligence-filters>.btn-primary{width:100%}.intelligence-po-builder .select2-container{min-width:100%!important;width:100%!important}}


/* ================================================================
   Phase 16 R2 — Utility Tools / Default Reorder Settings
   ================================================================ */
.utility-tool-card,
.utility-help-card {
    margin-bottom: 18px;
}

.utility-tool-body {
    padding-top: 4px;
}

.utility-reorder-grid {
    grid-template-columns:
        minmax(220px, 1.15fr)
        minmax(260px, 1.35fr)
        minmax(170px, .8fr)
        minmax(170px, .8fr);
}

.utility-mode-note {
    margin-top: 14px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.utility-mode-note.danger-note {
    border-color: #fecaca;
    background: #fff7f7;
    color: #991b1b;
}

.utility-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.utility-preview-area {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.utility-preview-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.utility-preview-summary {
    margin-top: 14px;
    padding: 14px 15px;
    border: 1px solid var(--orange-border);
    border-radius: 12px;
    background: var(--orange-soft);
}

.utility-preview-summary strong {
    display: block;
    margin-bottom: 5px;
    color: var(--ink);
}

.utility-preview-summary p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.utility-confirm {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.utility-confirm input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin-top: 1px;
    accent-color: var(--orange);
}

.utility-confirm span {
    color: var(--ink);
    font-size: 12px;
    line-height: 1.5;
}

.utility-help-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.utility-help-grid > div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.utility-help-grid strong {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
}

.utility-help-grid p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.utility-help-grid code {
    font-size: 11px;
    word-break: break-word;
}

@media (max-width: 1100px) {
    .utility-reorder-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .utility-preview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .utility-reorder-grid,
    .utility-preview-grid,
    .utility-help-grid {
        grid-template-columns: 1fr;
    }

    .utility-actions .btn-primary,
    .utility-actions .btn-secondary {
        width: 100%;
    }
}


/* ================================================================
   Phase 16 R4 — Descriptive product search results
   ================================================================ */
.product-search-option-rich {
    min-height: 84px;
    align-items: flex-start;
    padding-top: 11px;
    padding-bottom: 11px;
}

.product-search-identity {
    min-width: 0;
    flex: 1 1 auto;
}

.product-search-option-rich strong {
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.product-search-option-rich small {
    line-height: 1.42;
    overflow-wrap: anywhere;
}

.product-search-option-rich .product-search-variant {
    color: #475569;
    font-weight: 600;
}

.product-search-option-rich > b {
    flex: 0 0 auto;
    max-width: 38%;
    padding-top: 1px;
    text-align: right;
    line-height: 1.45;
}

.product-select2-result {
    display: grid;
    gap: 2px;
    padding: 3px 1px;
    line-height: 1.35;
}

.product-select2-title {
    display: block;
    color: var(--ink);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.product-select2-line {
    display: block;
    color: var(--muted);
    font-size: 10px;
    overflow-wrap: anywhere;
}

.product-select2-variant {
    color: #475569;
    font-weight: 600;
}

.select2-results__option--highlighted .product-select2-title,
.select2-results__option--highlighted .product-select2-line {
    color: inherit;
}

.modal-card .select2-results__option:has(.product-select2-result) {
    padding-top: 8px;
    padding-bottom: 8px;
}

@media (max-width: 700px) {
    .product-search-option-rich {
        min-height: 96px;
        gap: 8px;
    }

    .product-search-option-rich > b {
        max-width: 42%;
        white-space: normal;
    }
}


/* ================================================================
   Phase 16 R5 — Mobile responsive audit + spacing/button polish
   ================================================================ */

/* ---------- Prevent page-level horizontal overflow ----------
   Tables may scroll internally on tablet, but the entire application page
   must never need a rightward page scroll. */
html,
body,
.app-shell,
.main,
.content {
    max-width: 100%;
}

html,
body {
    overflow-x: hidden;
}

.content,
.content > *,
.page-actions > *,
.panel,
.panel-heading > *,
.table-toolbar > *,
.filter-grid > *,
.form-grid > *,
.inline-actions > * {
    min-width: 0;
}

/* ---------- Consistent vertical rhythm between top-level sections ---------- */
.content > .panel,
.content > .stat-grid,
.content > .dashboard-grid,
.content > .reports-chart-grid,
.content > .procurement-report-chart-grid {
    margin-bottom: 18px;
}

.content > .page-actions {
    margin-bottom: 22px;
}

.content > .table-panel:last-child,
.content > .panel:last-child {
    margin-bottom: 0;
}

/* Consecutive table/report blocks must never visually touch. */
.content > .table-panel + .table-panel,
.content > .report-section + .report-section,
.content > .panel + .table-panel,
.content > .table-panel + .panel {
    margin-top: 18px;
}

/* ---------- Button text normalization ----------
   Anchor-buttons and long labels such as "Purchase Orders" now share the
   same centering, line-height and wrapping behavior as <button>. */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-table {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: 100%;
    text-align: center;
    text-decoration: none;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
    vertical-align: middle;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    min-height: 40px;
}

.page-actions > .btn-primary,
.page-actions > .btn-secondary,
.page-actions > .btn-danger,
.page-actions > .page-action-button {
    flex: 0 1 auto;
    min-width: max-content;
    padding-top: 8px;
    padding-bottom: 8px;
}

/* ---------- Table breathing room ----------
   Keep content away from panel edges and make internal scrolling obvious. */
.table-panel .table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.table-panel .data-table {
    margin: 0;
}

.table-panel .pagination-bar {
    margin-top: 0;
}

/* ---------- Page/header actions ---------- */
.page-actions {
    flex-wrap: wrap;
}

.page-actions > :first-child {
    flex: 1 1 auto;
}

.page-actions > :not(:first-child) {
    flex-shrink: 0;
}

/* Product barcode controls should never disappear off the right side. */
.products-actions .barcode-box {
    flex: 1 1 480px;
    width: min(560px, 100%);
    max-width: 100%;
}

.product-barcode-actions {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto auto;
    width: 100%;
    max-width: 100%;
}

.product-barcode-actions > input,
.product-barcode-actions > button {
    min-width: 0;
}

/* ---------- Generic compact tablet refinements ---------- */
@media (max-width: 1100px) {
    .content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .page-actions {
        align-items: stretch;
    }

    .products-actions {
        flex-direction: column;
    }

    .products-actions .barcode-box {
        width: 100%;
    }

    .product-barcode-actions {
        grid-template-columns: minmax(0, 1fr) auto auto;
    }

    .panel-heading,
    .table-toolbar {
        flex-wrap: wrap;
    }

    .table-toolbar > :first-child,
    .panel-heading > :first-child {
        flex: 1 1 240px;
    }

    .table-toolbar > .btn-primary,
    .table-toolbar > .btn-secondary,
    .panel-heading > .btn-primary,
    .panel-heading > .btn-secondary {
        flex: 0 1 auto;
    }

    .workflow-actions,
    .inline-actions,
    .footer-actions {
        max-width: 100%;
    }
}

/* ---------- Phone layout ----------
   Main-page data tables become readable cards. This avoids the common
   "scroll the entire page to the right to reach actions/details" problem. */
@media (max-width: 700px) {
    .content {
        padding: 16px 12px 32px;
    }

    .page-actions {
        gap: 14px;
        margin-bottom: 16px;
    }

    .page-actions h2 {
        font-size: 20px;
        line-height: 1.2;
    }

    .page-actions p {
        font-size: 12px;
        line-height: 1.55;
    }

    .page-actions > .btn-primary,
    .page-actions > .btn-secondary,
    .page-actions > .btn-danger,
    .page-actions > .page-action-button {
        width: 100%;
        min-width: 0;
        flex: 1 1 100%;
    }

    .product-barcode-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .product-barcode-actions > input {
        grid-column: 1 / -1;
        width: 100%;
    }

    .product-barcode-actions > .btn-primary,
    .product-barcode-actions > .btn-secondary {
        width: 100%;
    }

    .scanner-hint {
        line-height: 1.6;
    }

    .filter-panel {
        padding: 14px 12px;
    }

    .panel {
        border-radius: 13px;
    }

    .panel-heading,
    .table-toolbar {
        padding-left: 14px;
        padding-right: 14px;
    }

    .panel-heading > .btn-primary,
    .panel-heading > .btn-secondary,
    .table-toolbar > .btn-primary,
    .table-toolbar > .btn-secondary {
        width: 100%;
        flex: 1 1 100%;
    }

    .pagination-bar {
        padding: 12px;
        gap: 8px;
    }

    .pagination-bar .btn-primary,
    .pagination-bar .btn-secondary {
        flex: 1 1 0;
        min-width: 0;
        padding-left: 8px;
        padding-right: 8px;
    }

    .pagination-bar span {
        min-width: 72px;
        font-size: 10px;
    }

    /* Select2 / form controls can otherwise preserve a desktop min width. */
    .content .select2-container {
        max-width: 100% !important;
    }

    .content .inline-actions {
        width: 100%;
    }

    .content .inline-actions > .btn-primary,
    .content .inline-actions > .btn-secondary,
    .content .inline-actions > .btn-danger {
        flex: 1 1 150px;
    }

    /* Inventory Intelligence: supplier + Purchase Orders/draft actions */
    .intelligence-po-builder .inline-actions {
        align-items: stretch;
    }

    .intelligence-po-builder .inline-actions > * {
        max-width: 100%;
    }
}

@media (max-width: 420px) {
    .content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .product-barcode-actions {
        grid-template-columns: 1fr;
    }

    .product-barcode-actions > input {
        grid-column: auto;
    }

    .pagination-bar {
        flex-wrap: wrap;
    }

    .pagination-bar span {
        order: -1;
        width: 100%;
        min-width: 100%;
    }

    .content > .table-panel .data-table tbody td {
        grid-template-columns: minmax(72px, .32fr) minmax(0, 1fr);
        gap: 8px;
        padding-left: 9px;
        padding-right: 9px;
    }
}


/* ================================================================
   Phase 16 R6 — Mobile spacing correction + classic table restore
   ================================================================ */

/*
 * IMPORTANT:
 * Do not use a fixed flex-basis on .page-actions children.
 * On column layouts flex-basis becomes vertical height and creates the
 * large blank spaces seen on Dashboard and Product Catalog.
 */
.page-actions > :first-child {
    flex-basis: auto;
    min-height: 0;
}

.page-actions > :not(:first-child) {
    min-height: 0;
}

/* Keep normal table presentation on every viewport. */
.content .table-panel .data-table {
    display: table;
    width: 100%;
}

.content .table-panel .data-table thead {
    display: table-header-group;
}

.content .table-panel .data-table tbody {
    display: table-row-group;
}

.content .table-panel .data-table tr {
    display: table-row;
}

.content .table-panel .data-table th,
.content .table-panel .data-table td {
    display: table-cell;
}

/*
 * Wide tables scroll INSIDE their panel.
 * The page itself should not need horizontal scrolling.
 */
.content .table-panel .table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.content .table-panel .data-table {
    min-width: 760px;
}

/* Narrower/simple tables are allowed to naturally fit when possible. */
.content .table-panel .data-table.compact-table {
    min-width: 620px;
}

/* Product Catalog barcode controls remain visible without creating tall gaps. */
.products-actions {
    row-gap: 16px;
}

.products-actions > :first-child,
.products-actions .barcode-box {
    min-height: 0;
}

@media (max-width: 1100px) {
    .products-actions {
        gap: 16px;
    }

    .products-actions > :first-child {
        flex: 0 0 auto;
        width: 100%;
    }

    .products-actions .barcode-box {
        flex: 0 0 auto;
        width: 100%;
    }

    .product-barcode-actions {
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: stretch;
    }

    .product-barcode-actions > button {
        min-height: 42px;
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (max-width: 720px) {
    /*
     * Existing base CSS switches page-actions to column here.
     * Explicitly reset flex sizing so headings/forms remain content-height.
     */
    .page-actions {
        gap: 14px;
    }

    .page-actions > :first-child,
    .page-actions > :not(:first-child) {
        flex: 0 0 auto;
        width: 100%;
        min-height: 0;
    }

    .store-filter {
        margin-top: 0;
    }

    .content > .page-actions {
        margin-bottom: 18px;
    }

    .product-barcode-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .product-barcode-actions > input {
        grid-column: 1 / -1;
        min-height: 44px;
    }

    .product-barcode-actions > button {
        width: 100%;
        min-height: 44px;
    }

    /*
     * Reverted table behavior:
     * retain standard rows/columns; user scrolls only the table container
     * when a table is wider than the phone.
     */
    .content .table-panel .table-scroll {
        overflow-x: auto;
        padding-left: 12px;
        padding-right: 12px;
    }

    .content .table-panel .data-table {
        min-width: 760px !important;
    }

    .content .table-panel .data-table th,
    .content .table-panel .data-table td {
        white-space: nowrap;
    }

    /*
     * Product/description cells may wrap slightly so tables do not become
     * unnecessarily wider, while preserving the original row/table view.
     */
    .content .table-panel .data-table td:nth-child(2) {
        white-space: normal;
        min-width: 180px;
    }

    /* Long page action buttons such as Purchase Orders stay readable. */
    .page-actions > .btn-primary,
    .page-actions > .btn-secondary,
    .page-actions > .btn-danger,
    .page-actions > .page-action-button {
        width: 100%;
        min-height: 42px;
        white-space: normal;
        line-height: 1.25;
    }
}

@media (max-width: 420px) {
    .product-barcode-actions {
        grid-template-columns: 1fr;
    }

    .product-barcode-actions > input {
        grid-column: auto;
    }

    .content .table-panel .table-scroll {
        padding-left: 10px;
        padding-right: 10px;
    }
}


/* ================================================================
   Phase 16 R7 — Product Catalog heading alignment
   ================================================================ */

/*
 * Product Catalog has a tall barcode utility on the right.
 * Do not bottom-align the page title against that utility.
 * The heading must begin at the same top content position as other pages
 * such as Inventory Browser.
 */
.products-actions {
    align-items: flex-start;
}

.products-actions > :first-child,
.products-actions .barcode-box {
    align-self: flex-start;
}

/*
 * Preserve the existing responsive behavior. The title remains content-height
 * and the barcode controls stay visible without creating vertical gaps.
 */
@media (max-width: 1100px) {
    .products-actions {
        align-items: stretch;
    }

    .products-actions > :first-child,
    .products-actions .barcode-box {
        align-self: auto;
    }
}


/* ================================================================
   Phase 17 — Stock Counts / Cycle Counting
   ================================================================ */
.stock-count-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stock-count-filter-grid {
    grid-template-columns: minmax(200px, .9fr) minmax(170px, .65fr) minmax(280px, 1.4fr) 110px;
}

.stock-count-editor {
    width: min(1180px, calc(100vw - 34px));
}

.stock-count-new-modal {
    width: min(720px, calc(100vw - 34px));
}

.stock-count-document-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.stock-count-document-meta > div {
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.stock-count-document-meta span,
.stock-count-progress span,
.selected-product-stock span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
}

.stock-count-document-meta strong,
.stock-count-progress strong,
.selected-product-stock strong {
    color: var(--ink);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.stock-count-meta-wide {
    grid-column: 1 / -1;
}

.stock-count-entry {
    margin: 16px 0;
    padding: 15px;
    border: 1px solid var(--orange-border);
    border-radius: 13px;
    background: var(--orange-soft);
}

.stock-count-entry .panel-heading {
    padding: 0 0 12px;
}

.stock-count-scan-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    gap: 8px;
}

.stock-count-scan-row input {
    min-width: 0;
}

.stock-count-search-wrap {
    margin-top: 10px;
}

.stock-count-value-grid {
    grid-template-columns: minmax(180px, .55fr) minmax(280px, 1.45fr) auto;
    align-items: end;
    margin-top: 10px;
}

.stock-count-value-grid > .btn-primary {
    min-height: 42px;
}

.stock-count-progress {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.stock-count-progress > div {
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.stock-count-items-scroll {
    max-height: 50vh;
    overflow: auto;
}

.stock-count-items-scroll .data-table {
    min-width: 980px;
}

.stock-count-footer {
    align-items: center;
}

.stock-count-footer .footer-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 1000px) {
    .stock-count-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .stock-count-document-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stock-count-progress {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stock-count-value-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stock-count-value-grid > .btn-primary {
        grid-column: 1 / -1;
        width: 100%;
    }
}

@media (max-width: 700px) {
    .stock-count-filter-grid,
    .stock-count-document-meta,
    .stock-count-progress,
    .stock-count-value-grid {
        grid-template-columns: 1fr;
    }

    .stock-count-meta-wide,
    .stock-count-value-grid > .btn-primary {
        grid-column: auto;
    }

    .stock-count-scan-row {
        grid-template-columns: 1fr 1fr;
    }

    .stock-count-scan-row input {
        grid-column: 1 / -1;
        min-height: 44px;
    }

    .stock-count-scan-row .btn-primary,
    .stock-count-scan-row .btn-secondary {
        width: 100%;
        min-height: 44px;
    }

    .stock-count-editor,
    .stock-count-new-modal {
        width: 100%;
    }

    .stock-count-footer {
        align-items: stretch;
    }

    .stock-count-footer .footer-actions {
        width: 100%;
    }

    .stock-count-footer .footer-actions > button {
        flex: 1 1 180px;
    }

    .stock-count-items-scroll {
        max-height: 45vh;
    }
}

@media (max-width: 420px) {
    .stock-count-scan-row {
        grid-template-columns: 1fr;
    }

    .stock-count-scan-row input {
        grid-column: auto;
    }

    .stock-count-footer .footer-actions > button {
        flex-basis: 100%;
        width: 100%;
    }
}


/* ================================================================
   Phase 17 R2 — Global control styling + responsive totals/cards
   ================================================================ */

/* ---------- Universal application control baseline ----------
   Low-specificity rules deliberately fill styling gaps without replacing
   module-specific filter/modal styling. */
.content :where(
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="tel"],
    input[type="url"],
    select
) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    line-height: 1.25;
    outline: none;
    box-shadow: none;
    transition:
        border-color .16s ease,
        box-shadow .16s ease,
        background-color .16s ease;
}

.content :where(textarea) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 82px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    line-height: 1.5;
    outline: none;
    resize: vertical;
    box-shadow: none;
    transition:
        border-color .16s ease,
        box-shadow .16s ease,
        background-color .16s ease;
}

.content :where(
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="tel"],
    input[type="url"],
    select,
    textarea
):focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .10);
}

.content :where(
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="tel"],
    input[type="url"],
    select,
    textarea
):disabled {
    cursor: not-allowed;
    background: #f8fafc;
    color: #94a3b8;
}

.content :where(input)::placeholder,
.content :where(textarea)::placeholder {
    color: #94a3b8;
    opacity: 1;
}

/* Search inputs should look identical to normal application text fields. */
.content :where(input[type="search"]) {
    -webkit-appearance: none;
    appearance: none;
}

.content :where(input[type="search"])::-webkit-search-cancel-button {
    cursor: pointer;
}

/* Standalone selects/searches inside action bars and report toolbars. */
.content :where(
    .inline-actions,
    .table-toolbar,
    .panel-heading,
    .reports-inventory-filters,
    .reports-export-group
) :where(input, select, textarea) {
    max-width: 100%;
}

/* ---------- Report inventory snapshot controls ----------
   These controls previously only had width/min-height, leaving the browser
   native border/appearance visible. */
.reports-inventory-filters input,
.reports-inventory-filters select {
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

.reports-inventory-filters input:focus,
.reports-inventory-filters select:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .10);
}

/* ---------- Responsive total / KPI cards ----------
   Let the grid decide the number of columns from available width rather
   than forcing cards narrow enough for monetary values to overlap. */
.content .stat-grid {
    grid-template-columns:
        repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    align-items: stretch;
}

.content .stat-card {
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.content .stat-card > :not(.stat-icon) {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.content .stat-card strong {
    max-width: 100%;
    font-size: clamp(17px, 1.35vw, 26px);
    line-height: 1.08;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.025em;
    white-space: nowrap;
}

/* Inventory summary has currency totals; keep each card comfortably wide. */
.report-inventory-summary {
    grid-template-columns:
        repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

/* Reports top-level money cards get the same safe width contract. */
.reports-summary-grid {
    grid-template-columns:
        repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

/* Avoid a toolbar title competing with filters for the same narrow row. */
.reports-inventory-toolbar > :first-child {
    flex: 1 1 320px;
    min-width: 0;
}

.reports-inventory-filters {
    flex: 1 1 520px;
    min-width: min(100%, 360px);
    max-width: 620px;
}

/* ---------- Tablet ----------
   Amount cards become 2–3 columns naturally depending on actual content
   width; filters stop compressing each other. */
@media (max-width: 1100px) {
    .content .stat-grid,
    .reports-summary-grid,
    .report-inventory-summary {
        grid-template-columns:
            repeat(auto-fit, minmax(min(100%, 210px), 1fr));
    }

    .reports-inventory-toolbar {
        align-items: stretch;
    }

    .reports-inventory-toolbar > :first-child,
    .reports-inventory-filters {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
    }

    .reports-inventory-filters {
        grid-template-columns: minmax(0, 1.3fr) minmax(180px, .7fr);
    }
}

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
    .content .stat-grid,
    .reports-summary-grid,
    .report-inventory-summary {
        grid-template-columns:
            repeat(auto-fit, minmax(min(100%, 180px), 1fr));
        gap: 10px;
    }

    .content .stat-card {
        min-height: 92px;
        padding: 14px;
        gap: 11px;
    }

    .content .stat-icon {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
        border-radius: 10px;
    }

    .content .stat-card strong {
        font-size: clamp(18px, 5vw, 24px);
    }

    .reports-inventory-filters {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 460px) {
    .content .stat-grid,
    .reports-summary-grid,
    .report-inventory-summary {
        grid-template-columns: 1fr;
    }

    .content .stat-card strong {
        font-size: clamp(20px, 7vw, 27px);
    }
}


/* ================================================================
   Phase 18 — Notifications & Alerts
   ================================================================ */
.nav-menu a { position: relative; }

.nav-alert-badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    margin-left: auto;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    line-height: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.topbar-alert-wrap { position: relative; }

.topbar-alert-button {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, background .16s ease;
}

.topbar-alert-button:hover,
.topbar-alert-button.has-alerts {
    border-color: var(--orange-border);
    background: var(--orange-soft);
    color: var(--orange-dark);
}

.topbar-alert-icon { font-size: 14px; line-height: 1; }

.topbar-alert-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 8px;
    font-weight: 900;
    line-height: 1;
}

.alert-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 70;
    width: min(390px, calc(100vw - 24px));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 55px rgba(15, 23, 42, .18);
}

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

.alert-dropdown-header strong,
.alert-dropdown-header span { display: block; }

.alert-dropdown-header strong { color: var(--ink); font-size: 12px; }
.alert-dropdown-header span { margin-top: 2px; color: var(--muted); font-size: 9px; }

.alert-dropdown-header button {
    flex: 0 0 auto;
    padding: 5px 7px;
    border: 0;
    background: transparent;
    color: var(--orange-dark);
    font-size: 9px;
    font-weight: 800;
    cursor: pointer;
}

.alert-dropdown-list {
    max-height: min(420px, 58vh);
    overflow-y: auto;
}

.alert-preview-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    padding: 11px 13px;
    border-bottom: 1px solid #f1f5f9;
    color: inherit;
    text-decoration: none;
}

.alert-preview-item:hover { background: #fffaf5; }

.alert-preview-icon {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 12px;
    font-weight: 900;
}

.alert-preview-icon.warning { background: #fff7ed; color: #ea580c; }
.alert-preview-icon.critical { background: #fef2f2; color: #dc2626; }

.alert-preview-item strong,
.alert-preview-item small,
.alert-preview-item em {
    display: block;
    min-width: 0;
}

.alert-preview-item strong { color: var(--ink); font-size: 10px; line-height: 1.35; }
.alert-preview-item small { margin-top: 2px; color: var(--orange-dark); font-size: 8px; font-weight: 700; }
.alert-preview-item em { margin-top: 3px; color: var(--muted); font-size: 9px; font-style: normal; line-height: 1.42; }

.alert-dropdown-empty {
    padding: 24px 14px;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
}

.alert-dropdown-footer {
    display: block;
    padding: 10px 14px;
    background: #f8fafc;
    color: var(--orange-dark);
    font-size: 10px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.dashboard-alert-summary {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    background: #fff7ed;
    color: inherit;
    text-decoration: none;
}

.dashboard-alert-summary.critical {
    border-color: #fecaca;
    background: #fff5f5;
}

.dashboard-alert-summary-icon {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #ffedd5;
    color: #ea580c;
    font-weight: 900;
}

.dashboard-alert-summary.critical .dashboard-alert-summary-icon {
    background: #fee2e2;
    color: #dc2626;
}

.dashboard-alert-summary strong,
.dashboard-alert-summary small { display: block; }

.dashboard-alert-summary strong { color: var(--ink); font-size: 11px; }
.dashboard-alert-summary small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.dashboard-alert-summary em { color: var(--orange-dark); font-size: 10px; font-style: normal; font-weight: 800; }

.alert-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.alert-filter-grid {
    grid-template-columns:
        minmax(190px, .95fr)
        minmax(150px, .65fr)
        minmax(180px, .8fr)
        minmax(150px, .65fr)
        minmax(260px, 1.35fr)
        100px;
}

.alerts-table { min-width: 1120px; }
.alert-row-unread td { background: #fffdf9; }
.alert-row-unread td:nth-child(2) > strong { color: #0f172a; }
.alert-row-read { opacity: .78; }

.alert-severity {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    padding: 4px 7px;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 9px;
    font-weight: 800;
    white-space: nowrap;
}

.alert-severity b {
    display: inline-grid;
    place-items: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
}

.alert-severity.warning { background: #fff7ed; color: #c2410c; }
.alert-severity.critical { background: #fef2f2; color: #b91c1c; }
.alert-table-actions { flex-wrap: nowrap; }

@media (max-width: 1100px) {
    .alert-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .alert-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .topbar-actions { gap: 7px; }
    .topbar-alert-button { width: 40px; height: 40px; }

    .alert-dropdown {
        position: fixed;
        top: 70px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: calc(100vh - 85px);
    }

    .dashboard-alert-summary { grid-template-columns: 38px minmax(0, 1fr); }
    .dashboard-alert-summary em { grid-column: 2; }
    .alert-summary-grid,
    .alert-filter-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .topbar-badge { display: none; }
    .alert-dropdown { top: 66px; right: 8px; left: 8px; }
}


/* ================================================================
   Phase 19 — System Health / Production Readiness
   ================================================================ */
.system-health-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.system-health-overall {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 13px;
    margin-bottom: 18px;
    padding: 14px 15px;
    border: 1px solid #fed7aa;
    border-radius: 13px;
    background: #fff7ed;
}

.system-health-overall.pass {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.system-health-overall.fail {
    border-color: #fecaca;
    background: #fef2f2;
}

.system-health-overall-icon {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: #ffedd5;
    color: #ea580c;
    font-size: 18px;
    font-weight: 900;
}

.system-health-overall.pass .system-health-overall-icon {
    background: #dcfce7;
    color: #15803d;
}

.system-health-overall.fail .system-health-overall-icon {
    background: #fee2e2;
    color: #b91c1c;
}

.system-health-overall strong {
    display: block;
    color: var(--ink);
    font-size: 12px;
}

.system-health-overall p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.system-health-environment {
    margin-bottom: 18px;
}

.system-health-env-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.system-health-env-grid > div {
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.system-health-env-grid span,
.system-health-env-grid strong {
    display: block;
}

.system-health-env-grid span {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
}

.system-health-env-grid strong {
    color: var(--ink);
    font-size: 10px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.system-health-filter-grid {
    grid-template-columns: minmax(190px, .7fr) minmax(170px, .6fr) minmax(300px, 1.7fr);
}

.system-health-table {
    min-width: 1000px;
}

.health-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
}

.health-status-badge.pass {
    background: #dcfce7;
    color: #166534;
}

.health-status-badge.warning {
    background: #ffedd5;
    color: #c2410c;
}

.health-status-badge.fail {
    background: #fee2e2;
    color: #b91c1c;
}

.system-health-notes {
    margin-top: 18px;
}

.system-health-launch-card {
    border-color: var(--orange-border);
}

@media (max-width: 1100px) {
    .system-health-summary,
    .system-health-env-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .system-health-summary,
    .system-health-env-grid,
    .system-health-filter-grid {
        grid-template-columns: 1fr;
    }

    .system-health-overall {
        grid-template-columns: 38px minmax(0, 1fr);
    }
}


/* ================================================================
   Phase 20 — Superadmin / Database Backup & Restore / Launch Gate
   ================================================================ */
.superadmin-nav-label {
    color: #fb923c;
}

.database-backup-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.database-critical-warning code,
.database-backup-table code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.database-upload-panel {
    margin-bottom: 18px;
}

.database-upload-form {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.database-upload-form label {
    min-width: 0;
}

.database-backup-table {
    min-width: 1180px;
}

.database-backup-table td:nth-child(2) strong,
.database-backup-table td:nth-child(2) small,
.database-backup-table td:nth-child(4) strong,
.database-backup-table td:nth-child(4) small {
    display: block;
}

.database-backup-table td:nth-child(2) small,
.database-backup-table td:nth-child(4) small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

.backup-hash {
    font-size: 9px;
    white-space: nowrap;
}

.danger-button {
    background: #b91c1c;
    border-color: #b91c1c;
}

.danger-button:hover {
    background: #991b1b;
    border-color: #991b1b;
}

.deployment-checklist-table {
    min-width: 850px;
}

.user-protected-row {
    opacity: .82;
}

@media (max-width: 900px) {
    .database-backup-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 520px) {
    .database-backup-summary {
        grid-template-columns: 1fr;
    }
}


/* ================================================================
   Phase 20 R1 — Database backup creation/cPanel compatibility
   ================================================================ */
.database-backup-preflight {
    margin-bottom: 18px;
}

.database-preflight-summary {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 10px;
    font-weight: 800;
}

.database-preflight-summary.pass {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.database-preflight-summary.fail {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.database-preflight-table {
    min-width: 720px;
}


/* ================================================================
   Phase 20 R2 — Full / Segregated database backup modes
   ================================================================ */
.database-backup-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.database-backup-mode-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.database-backup-mode-card.recommended {
    border-color: var(--orange-border);
    background: linear-gradient(180deg, #fff 0%, #fffaf5 100%);
}

.database-backup-mode-card h3 {
    margin: 4px 0 6px;
    color: var(--ink);
    font-size: 15px;
}

.database-backup-mode-card p,
.database-backup-mode-card li {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.55;
}

.database-backup-mode-card ul {
    margin: 10px 0 14px;
    padding-left: 18px;
}

.database-backup-mode-card button {
    width: 100%;
}

.database-backup-table {
    min-width: 1320px;
}

@media (max-width: 820px) {
    .database-backup-mode-grid {
        grid-template-columns: 1fr;
    }
}


/* ================================================================
   Phase 20 R3 — Restore privilege preflight / recovery safety
   ================================================================ */
.restore-preflight-box {
    margin: 0 16px 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafc;
}

.restore-preflight-table {
    min-width: 680px;
}

#confirmDatabaseRestore:disabled {
    opacity: .62;
    cursor: not-allowed;
}


/* ================================================================
   Phase 20 R5 — Live restore progress + maintenance lock
   ================================================================ */
.restore-live-progress {
    margin: 0 16px 14px;
    padding: 14px;
    border: 1px solid #fed7aa;
    border-radius: 13px;
    background: #fffaf5;
}

.restore-progress-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.restore-progress-heading > div {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.restore-progress-heading strong {
    color: var(--ink);
    font-size: 12px;
}

.restore-progress-heading b {
    flex: 0 0 auto;
    color: var(--orange-dark);
    font-size: 12px;
}

.restore-progress-pulse {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 0 0 0 rgba(249, 115, 22, .36);
    animation: restoreProgressPulse 1.5s infinite;
}

@keyframes restoreProgressPulse {
    70% { box-shadow: 0 0 0 9px rgba(249, 115, 22, 0); }
    100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}

.restore-progress-bar {
    height: 11px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.restore-progress-bar > i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--orange);
    transition: width .35s ease;
}

.restore-live-progress > p {
    margin: 9px 0 0;
    color: #475569;
    font-size: 10px;
    line-height: 1.55;
}

.restore-progress-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.restore-progress-stats > div {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.restore-progress-stats span,
.restore-progress-stats strong {
    display: block;
}

.restore-progress-stats span {
    color: var(--muted);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.restore-progress-stats strong {
    margin-top: 4px;
    color: var(--ink);
    font-size: 10px;
    overflow-wrap: anywhere;
}

.restore-progress-detail {
    margin-top: 10px;
    padding: 10px 11px;
    border-radius: 10px;
    background: #f8fafc;
    color: #475569;
    font-size: 9px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.restore-progress-warning {
    margin: 10px 0 0;
    font-size: 9px;
    line-height: 1.55;
}

#databaseRestoreModal button:disabled {
    cursor: not-allowed;
}

@media (max-width: 700px) {
    .restore-progress-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* ================================================================
   Phase 20 R6 — Optional segregated MAIN/CORE-only restore
   ================================================================ */
.restore-strategy-box {
    margin: 0 16px 14px;
    padding: 13px;
    border: 1px solid var(--orange-border);
    border-radius: 12px;
    background: #fffaf5;
}

.restore-strategy-box h4 {
    margin: 4px 0 10px;
    color: var(--ink);
    font-size: 12px;
}

.restore-strategy-option {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    margin: 8px 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

.restore-strategy-option input {
    margin: 3px 0 0;
}

.restore-strategy-option strong,
.restore-strategy-option small {
    display: block;
}

.restore-strategy-option strong {
    color: var(--ink);
    font-size: 10px;
}

.restore-strategy-option small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.5;
}

.restore-strategy-option.danger-option {
    border-color: #fed7aa;
}

.restore-strategy-option.disabled {
    opacity: .58;
    cursor: not-allowed;
    background: #f8fafc;
}

#restoreCoreOnlyWarning {
    margin-top: 10px;
}


/* ================================================================
   Phase 20 R7 — Restore modal scroll / visibility repair
   ================================================================
   One bounded modal, one vertical scroll region:
   header (fixed)
   -> form
      -> .database-restore-body (ALL variable details; scrollable)
      -> footer (fixed)
   ================================================================ */

.database-restore-card {
    width: min(1040px, 100%);
    height: min(92vh, 940px);
    max-height: min(92vh, 940px);
    overflow: hidden;
}

.database-restore-card > .database-restore-header {
    flex: 0 0 auto;
    position: relative;
    z-index: 3;
    background: #fff;
}

.database-restore-card > .database-restore-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.database-restore-card
> .database-restore-form
> .database-restore-body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 16px 18px 22px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    background: #f8fafc;
}

/*
 * R6 placed these as direct modal-card children. Their old margins assumed
 * that position. Inside the unified scroll body they must be normal flowing
 * sections so nothing is pushed/clipped outside the modal.
 */
.database-restore-body > .restore-strategy-box,
.database-restore-body > .restore-preflight-box,
.database-restore-body > .restore-live-progress {
    width: 100%;
    max-width: 100%;
    margin: 0 0 14px;
}

.database-restore-section {
    min-width: 0;
}

.database-restore-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 9px;
}

.database-restore-section-heading strong,
.database-restore-section-heading small {
    display: block;
}

.database-restore-section-heading strong {
    color: var(--ink);
    font-size: 10px;
}

.database-restore-section-heading small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.45;
}

/*
 * Horizontal movement stays inside the preflight table. Vertical movement
 * belongs exclusively to .database-restore-body.
 */
.database-restore-body .restore-preflight-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
}

.database-restore-body .restore-preflight-table {
    width: 100%;
    min-width: 760px;
    margin: 0;
}

.database-restore-body .restore-preflight-table th,
.database-restore-body .restore-preflight-table td {
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
}

.database-restore-body .restore-preflight-table th:first-child,
.database-restore-body .restore-preflight-table td:first-child {
    width: 90px;
}

.database-restore-confirmation {
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.database-restore-confirmation > .alert {
    margin: 0 0 12px;
}

.database-restore-confirmation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.database-restore-footer {
    flex: 0 0 auto;
    position: relative;
    z-index: 3;
    min-width: 0;
    background: #fff;
}

.database-restore-footer-note {
    margin-right: auto;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.35;
}

.database-restore-scroll-end {
    padding: 4px 0 0;
    color: #94a3b8;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .04em;
    text-align: center;
    text-transform: uppercase;
}

/* Give the visible scroll area a clear top/bottom edge. */
.database-restore-body {
    border-top: 0;
    border-bottom: 0;
}

/*
 * Restore progress can grow as server details change. Never constrain or clip
 * it to a fixed height.
 */
.database-restore-body .restore-live-progress,
.database-restore-body .restore-progress-detail,
.database-restore-body .restore-progress-warning {
    max-height: none;
    overflow: visible;
}

/* The modal itself must never become the browser-page scroll container. */
#databaseRestoreModal.open {
    overflow: hidden;
}

@media (max-width: 820px) {
    .database-restore-card {
        width: 100%;
        height: min(96dvh, 960px);
        max-height: 96dvh;
    }

    .database-restore-card
    > .database-restore-form
    > .database-restore-body {
        padding: 13px 12px 18px;
    }

    .database-restore-confirmation-grid {
        grid-template-columns: 1fr;
    }

    .database-restore-footer {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }

    .database-restore-footer-note {
        flex: 1 0 100%;
        order: -1;
        width: 100%;
    }

    .database-restore-footer .btn-secondary,
    .database-restore-footer .btn-primary {
        flex: 1 1 150px;
    }
}

@media (max-width: 520px) {
    #databaseRestoreModal.modal-backdrop {
        padding: 0;
        align-items: stretch;
    }

    .database-restore-card,
    .database-restore-card.modal-large {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .database-restore-card > .database-restore-header {
        padding: 12px 14px;
    }

    .database-restore-card
    > .database-restore-form
    > .database-restore-body {
        padding: 12px 10px 18px;
    }

    .database-restore-body .restore-preflight-table {
        min-width: 640px;
    }
}


/* ================================================================
   Phase 21 — Disaster Recovery SQL backup
   ================================================================ */
.database-backup-mode-grid {
    grid-template-columns: repeat(
        auto-fit,
        minmax(min(100%, 280px), 1fr)
    );
}

.disaster-recovery-card {
    border-color: #fdba74;
    background:
        linear-gradient(
            180deg,
            #fff7ed 0%,
            #ffffff 44%
        );
}

.disaster-recovery-card code,
.disaster-cli-note code {
    font-size: .9em;
    overflow-wrap: anywhere;
}

.disaster-recovery-preflight {
    border-color: #fed7aa;
}

.disaster-cli-note {
    margin: 12px 0 0;
    line-height: 1.55;
}

.database-backup-table td small {
    display: block;
    margin-top: 3px;
}


/* ================================================================
   Phase 21 R3 — Application-level isolated staging restore
   ================================================================ */
.staging-database-panel {
    border-color: #fdba74;
    background: linear-gradient(180deg, #fffaf5 0%, #fff 46%);
}

.staging-target-grid {
    display: grid;
    grid-template-columns: minmax(180px, .8fr) repeat(2, minmax(220px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    margin: 12px 0;
}

.staging-target-fact,
.staging-target-field {
    min-width: 0;
}

.staging-target-fact {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.staging-target-fact span,
.staging-target-fact strong,
.staging-target-fact small,
.staging-target-field > span,
.staging-target-field > small {
    display: block;
}

.staging-target-fact span,
.staging-target-field > span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.staging-target-fact strong {
    margin-top: 4px;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.staging-target-fact small,
.staging-target-field > small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.4;
}

.staging-target-action {
    align-self: center;
}

.staging-production-note {
    margin: 12px 0 0;
}

.staging-restore-card {
    width: min(1080px, 100%);
    height: min(92vh, 940px);
    max-height: min(92vh, 940px);
    overflow: hidden;
}

.staging-restore-card > .staging-restore-header {
    flex: 0 0 auto;
    background: #fff;
}

.staging-restore-card > .staging-restore-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.staging-restore-card
> .staging-restore-form
> .staging-restore-body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 16px 18px 22px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    background: #f8fafc;
}

.staging-restore-target-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.staging-restore-target-summary > div {
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.staging-restore-target-summary span,
.staging-restore-target-summary strong,
.staging-restore-target-summary small {
    display: block;
}

.staging-restore-target-summary span {
    color: var(--muted);
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
}

.staging-restore-target-summary strong {
    margin-top: 4px;
    color: var(--ink);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.staging-restore-target-summary small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

.staging-preflight-box,
.staging-live-progress,
.staging-restore-confirmation {
    width: 100%;
    max-width: 100%;
    margin: 0 0 14px;
}

.staging-restore-footer {
    flex: 0 0 auto;
    background: #fff;
}

#stagingRestoreModal.open {
    overflow: hidden;
}

@media (max-width: 1100px) {
    .staging-target-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .staging-target-action {
        align-self: end;
    }
}

@media (max-width: 720px) {
    .staging-target-grid,
    .staging-restore-target-summary {
        grid-template-columns: 1fr;
    }

    .staging-restore-card {
        width: 100%;
        height: 96dvh;
        max-height: 96dvh;
    }

    .staging-restore-card
    > .staging-restore-form
    > .staging-restore-body {
        padding: 12px 10px 18px;
    }
}

@media (max-width: 520px) {
    #stagingRestoreModal.modal-backdrop {
        padding: 0;
        align-items: stretch;
    }

    .staging-restore-card,
    .staging-restore-card.modal-large {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
}

/* ================================================================
   Phase 22 R3 — Web Department Database Setup
   ================================================================ */
.status-badge.success {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.status-badge.warning {
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
}

.status-badge.danger {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.department-db-top-actions {
    margin-top: 0;
    margin-bottom: 14px;
}

.department-db-table-wrap,
.setup-status-table-wrap {
    margin-top: 8px;
}

.department-db-action-grid {
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(260px, 1.2fr);
    margin-top: 16px;
}

.setup-console-page {
    min-height: 100vh;
    background: #f6f8fb;
    color: var(--ink);
}

.setup-console-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 48px;
}

.setup-console-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.setup-console-topbar h1 {
    margin: 5px 0 8px;
    font-size: clamp(26px, 4vw, 38px);
    letter-spacing: -.03em;
}

.setup-console-topbar p {
    margin: 0;
    color: var(--muted);
}

.setup-console-login-card {
    max-width: 640px;
    margin: 20px auto 0;
}

.setup-console-form {
    display: grid;
    gap: 14px;
    padding-top: 4px;
}

.setup-console-form label {
    display: grid;
    gap: 7px;
}

.setup-console-form label > span {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink);
}

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

.setup-action-card {
    margin: 0;
}

.setup-demo-note {
    margin-top: 18px;
}

.setup-status-table small,
.department-db-table-wrap small {
    color: var(--muted);
}

@media (max-width: 900px) {
    .department-db-action-grid,
    .setup-console-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .setup-console-shell {
        width: min(100% - 20px, 1180px);
        padding-top: 18px;
    }

    .setup-console-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .setup-console-topbar .btn-secondary {
        width: 100%;
        text-align: center;
    }
}

/* Phase 22 R4: HFSQL Windows Migration API */
.migration-token-grid {
    grid-template-columns: minmax(220px, 1fr) minmax(160px, .6fr) minmax(240px, 1fr);
    margin-top: 14px;
}

.copy-field-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin: 10px 0 6px;
}

.copy-field-row input {
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

#migrationTokenTable td:last-child {
    white-space: nowrap;
}

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

@media (max-width: 620px) {
    .copy-field-row {
        grid-template-columns: 1fr;
    }
    .copy-field-row .btn-secondary {
        width: 100%;
    }
}


/* Phase 22 R10: optimized legacy product photos */
.product-list-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.product-list-info > div { min-width: 0; }
.product-list-thumb {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
}
.product-detail-image {
    width: 96px;
    height: 96px;
    flex: 0 0 96px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid #ffedd5;
    background: #fff;
}
@media (max-width: 720px) {
    .product-detail-image {
        width: 72px;
        height: 72px;
        flex-basis: 72px;
    }
    .product-list-thumb {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }
}


/* ==========================================================================
   Phase 22 R10.3 - Product Photo Lightbox
   ========================================================================== */

.product-photo-link {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    cursor: zoom-in;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.product-photo-link:focus-visible {
    outline: 3px solid rgba(210, 91, 35, .35);
    outline-offset: 3px;
}

.product-list-photo-button {
    flex: 0 0 auto;
}

.product-list-photo-button:hover .product-list-thumb,
.inventory-photo-button:hover .inventory-product-thumb,
.product-detail-photo-button:hover .product-detail-image {
    transform: scale(1.03);
}

.product-list-thumb,
.inventory-product-thumb,
.product-detail-image {
    transition: transform .18s ease, box-shadow .18s ease;
}

.inventory-product-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    display: block;
    border-radius: 9px;
    background: #f3f4f6;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .10);
}

.product-photo-cell {
    width: 66px;
    min-width: 66px;
    text-align: center;
}

.product-photo-empty {
    color: #a0a5ad;
}

.product-detail-photo-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.product-detail-photo-button {
    position: relative;
    overflow: hidden;
}

.product-photo-expand {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .78);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.product-detail-photo-button:hover .product-photo-expand,
.product-detail-photo-button:focus-visible .product-photo-expand {
    opacity: 1;
    transform: translateY(0);
}

.product-photo-original-link {
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    padding: 22px;
    background: rgba(5, 10, 20, .88);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.photo-lightbox.open {
    display: flex;
}

.photo-lightbox-dialog {
    width: min(1180px, 100%);
    max-height: calc(100vh - 44px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 30px 100px rgba(0, 0, 0, .42);
}

.photo-lightbox-header,
.photo-lightbox-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 18px;
}

.photo-lightbox-header {
    border-bottom: 1px solid #e8ebef;
}

.photo-lightbox-header h3 {
    margin: 2px 0 0;
}

.photo-lightbox-header p {
    margin: 3px 0 0;
    color: #69717c;
    font-size: 13px;
}

.photo-lightbox-close {
    appearance: none;
    border: 0;
    background: transparent;
    color: #20242a;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 10px;
}

.photo-lightbox-close:hover {
    background: #f1f3f5;
}

.photo-lightbox-stage {
    min-height: 260px;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background:
        linear-gradient(45deg, #e7e9ec 25%, transparent 25%),
        linear-gradient(-45deg, #e7e9ec 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e7e9ec 75%),
        linear-gradient(-45deg, transparent 75%, #e7e9ec 75%),
        #f3f4f6;
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.photo-lightbox-stage img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 190px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 35px rgba(0, 0, 0, .20);
    cursor: zoom-in;
}

.photo-lightbox-stage img:active {
    cursor: zoom-out;
}

.photo-lightbox-footer {
    border-top: 1px solid #e8ebef;
    color: #69717c;
    font-size: 12px;
}

.photo-lightbox-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

@media (max-width: 720px) {
    .photo-lightbox {
        padding: 0;
        align-items: stretch;
    }

    .photo-lightbox-dialog {
        max-height: 100vh;
        width: 100%;
        border-radius: 0;
    }

    .photo-lightbox-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .photo-lightbox-actions {
        width: 100%;
    }

    .photo-lightbox-actions > * {
        flex: 1;
        text-align: center;
    }

    .photo-lightbox-stage img {
        max-height: calc(100vh - 230px);
    }

    .product-photo-expand {
        opacity: 1;
        transform: none;
    }
}


/* ==========================================================================
   Phase 23 R1 - BHPC PROGRAM 2026 Required Reports
   ========================================================================== */
.bhpc-page-actions { align-items: flex-start; }
.bhpc-action-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.bhpc-tabs-panel { padding: 0; overflow: hidden; }
.bhpc-tabs { display: flex; gap: 0; border-bottom: 1px solid #e7e9ed; background: #fafbfc; }
.bhpc-tab {
    appearance: none; border: 0; border-right: 1px solid #e7e9ed;
    background: transparent; padding: 14px 18px; font-weight: 800;
    cursor: pointer; color: #555d68;
}
.bhpc-tab.active { background: #fff; color: #c45124; box-shadow: inset 0 -3px 0 #d9632c; }
.bhpc-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 14px; padding: 18px;
}
.bhpc-filter-grid label, .bhpc-filter-action { display: flex; flex-direction: column; gap: 6px; }
.bhpc-filter-action { justify-content: flex-end; }
.bhpc-summary-grid { margin-top: 16px; }
.bhpc-report-sheet { margin-top: 16px; }
.bhpc-sheet-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 20px; padding: 18px 20px; border-bottom: 1px solid #e6e8ec;
}
.bhpc-sheet-header h2 { margin: 0 0 8px; letter-spacing: .04em; }
.bhpc-sheet-meta { display: flex; gap: 18px; flex-wrap: wrap; font-weight: 700; font-size: 13px; }
.bhpc-template-note { margin: 14px 18px 0; padding: 10px 12px; background: #fff8e9; border: 1px solid #f2d49b; border-radius: 9px; font-size: 12px; line-height: 1.55; }
.bhpc-data-table th { white-space: nowrap; vertical-align: middle; }
.bhpc-data-table td { vertical-align: middle; }
.bhpc-data-table thead tr:first-child th { background: #2e3136; color: #fff; }
.bhpc-data-table thead tr:nth-child(2) th { background: #f0f2f4; }
.bhpc-data-table tfoot th { background: #f8f1e8; border-top: 2px solid #c45124; }
.bhpc-sold-row { background: #fffaf4; }
.bhpc-remarks-guide {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
    padding: 14px 18px 18px; font-size: 12px;
}
.bhpc-remarks-guide span { padding: 5px 8px; border: 1px solid #ddd; border-radius: 999px; background: #fff; }
.bhpc-remarks-guide small { width: 100%; color: #6f7780; }
@media (max-width: 900px) {
    .bhpc-filter-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
@media (max-width: 620px) {
    .bhpc-filter-grid { grid-template-columns: 1fr; }
    .bhpc-sheet-header { flex-direction: column; }
}
@media print {
    body * { visibility: hidden !important; }
    #bhpcReportSheet, #bhpcReportSheet * { visibility: visible !important; }
    #bhpcReportSheet {
        position: absolute; left: 0; top: 0; width: 100%;
        box-shadow: none !important; border: 0 !important;
    }
    .sidebar, .topbar, .bhpc-page-actions, .bhpc-tabs-panel, .bhpc-summary-grid, .alert { display: none !important; }
    .bhpc-table-scroll { overflow: visible !important; }
    .bhpc-data-table { font-size: 8.5pt; width: 100%; }
    @page { size: landscape; margin: 8mm; }
}

/* Phase 23 R1.1 BHPC report correction */
.bhpc-filter-grid textarea {
    width: 100%;
    min-height: 70px;
    resize: vertical;
    font: inherit;
    border: 1px solid #d6dae0;
    border-radius: 8px;
    padding: 9px 10px;
    background: #fff;
}
.bhpc-sheet-meta #bhpcBasisLabel:not(:empty) { color: #c45124; }


/* Phase 23 R1.1.2 - BHPC selector population reliability */
.bhpc-population-status {
    margin: 12px 0;
    padding: 10px 13px;
    border: 1px solid #dfe3e8;
    border-radius: 9px;
    background: #f8fafb;
    color: #56606b;
    font-size: 12px;
}
.bhpc-field-help {
    color: #737b85;
    font-size: 11px;
    line-height: 1.35;
}
#bhpcProductCodesWrap .select2-container {
    width: 100% !important;
}
#bhpcProductCodesWrap .select2-selection--multiple {
    min-height: 42px;
    border: 1px solid #d6dae0;
    border-radius: 8px;
    padding: 3px 5px;
}
#bhpcProductCodesWrap .select2-search__field {
    min-width: 220px !important;
}


/* Phase 23 R1.1.3 - BHPC reactive dependent selectors */
.bhpc-filter-grid .bhpc-field-hidden {
    display: none !important;
}
.bhpc-population-status strong {
    color: var(--ink);
}


/* ==========================================================================
   Phase 23 R2 - Demo Data Reset & Generator
   ========================================================================== */
.demo-seed-panel { padding: 20px; }
.demo-seed-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.demo-seed-grid article {
    padding: 16px;
    border: 1px solid #e6e8ec;
    border-radius: 12px;
    background: #fafbfc;
}
.demo-seed-grid article strong {
    display: block;
    margin-top: 5px;
    font-size: 20px;
}
.demo-seed-options,
.demo-seed-confirm {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 16px;
    margin: 18px 0;
}
.demo-seed-options label,
.demo-seed-confirm label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.demo-seed-options small,
.demo-seed-confirm small {
    color: #707984;
    line-height: 1.45;
}
.demo-seed-plan {
    margin: 22px 0;
    padding: 16px;
    border: 1px solid #e6e8ec;
    border-radius: 12px;
}
.demo-seed-plan h3 { margin-top: 0; }
.demo-seed-plan-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
}
.demo-seed-plan-grid div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 11px 12px;
    border-radius: 9px;
    background: #f8fafb;
}
.demo-seed-plan-grid span {
    color: #69727d;
    font-size: 12px;
}
.demo-seed-estimate {
    padding: 12px 14px;
    border-radius: 9px;
    background: #fff8e9;
    border: 1px solid #f0d5a0;
}
.demo-seed-run {
    min-height: 46px;
    padding-left: 22px;
    padding-right: 22px;
}
.demo-seed-progress {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-top: 18px;
    padding: 14px;
    border: 1px solid #e6e8ec;
    border-radius: 10px;
    background: #fafbfc;
}
.demo-seed-progress p { margin: 4px 0 0; color: #6d7580; }
.demo-seed-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #eceff2;
    border-top-color: #e86522;
    border-radius: 50%;
    animation: demoSeedSpin .8s linear infinite;
    flex: 0 0 auto;
}
@keyframes demoSeedSpin { to { transform: rotate(360deg); } }
.demo-seed-result { margin-top: 18px; padding: 20px; }
.demo-seed-result pre {
    overflow: auto;
    padding: 15px;
    border-radius: 10px;
    background: #111827;
    color: #e5e7eb;
    line-height: 1.55;
}
.demo-seed-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
@media (max-width: 900px) {
    .demo-seed-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
    .demo-seed-grid,
    .demo-seed-options,
    .demo-seed-confirm,
    .demo-seed-plan-grid {
        grid-template-columns: 1fr;
    }
}
