:root {
    --bg: #0f172a;
    --bg-soft: #111c33;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --accent: #06b6d4;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
    color: var(--text);
}

.app-body {
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 40%, #f1f5f9 100%);
    min-height: 100vh;
}

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 1rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1040;
}

.app-topbar-title strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.2;
}

.app-topbar-title small {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.app-topbar-spacer {
    flex: 1;
}

.app-topbar-role {
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--primary-soft);
    color: var(--primary-dark);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
}

.sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: 0.2s ease;
    z-index: 1045;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

body.sidebar-open {
    overflow: hidden;
}

body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
}

.sidebar-toggle {
    border: 0;
    background: #eef2ff;
    color: var(--primary);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar-toggle:hover {
    background: #e0e7ff;
}

.sidebar-toggle:active {
    transform: scale(0.96);
}

.sidebar-close {
    margin-inline-start: auto;
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.app-sidebar {
    background: linear-gradient(180deg, #111827 0%, #1e293b 100%);
    color: #fff;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    width: min(300px, 88vw);
    height: 100vh;
    z-index: 1050;
    transform: translateX(105%);
    transition: transform 0.25s ease;
    box-shadow: -8px 0 30px rgba(15, 23, 42, 0.18);
    overflow-y: auto;
    /* Keep drawer out of document flow so it never reserves vertical space. */
    margin: 0;
    pointer-events: none;
}

body.sidebar-open .app-sidebar {
    transform: translateX(0);
    pointer-events: auto;
}

.sidebar-brand {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    padding: 0.5rem 0.35rem 0.75rem;
    margin-bottom: 1.25rem;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #0A1424, #1B3B72);
    font-size: 1.3rem;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
    flex-shrink: 0;
}

.brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sidebar-brand strong {
    display: block;
    font-size: 1rem;
}

.sidebar-brand small {
    color: rgba(255, 255, 255, 0.65);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-inline-end: 0.15rem;
}

.sidebar-nav > .nav-item,
.sidebar-nav .sidebar-subnav > .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    margin: 0;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    line-height: 1.3;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.sidebar-nav > .nav-item:hover,
.sidebar-nav > .nav-item.active,
.sidebar-nav .sidebar-subnav > .nav-item:hover,
.sidebar-nav .sidebar-subnav > .nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-subnav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0.1rem 0 0.35rem;
    padding-inline-start: 0.65rem;
    border-inline-start: 2px solid rgba(255, 255, 255, 0.12);
}

.sidebar-nav .nav-item-sub {
    padding: 0.55rem 0.75rem;
    font-size: 0.92rem;
    border-radius: 10px;
}

.sidebar-nav .nav-item i {
    font-size: 1.05rem;
    width: 1.15rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-item span {
    min-width: 0;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-chip {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.85rem;
}

.user-chip .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.12);
    font-weight: 700;
}

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

.user-chip small {
    color: rgba(255, 255, 255, 0.6);
}

.btn-sidebar-logout {
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    background: transparent;
    border-radius: 12px;
    padding: 0.65rem 0.9rem;
}

.btn-sidebar-logout:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.app-main {
    min-width: 0;
    flex: 1 1 auto;
    width: 100%;
}

.app-content {
    padding: 1.5rem;
    max-width: 100%;
    overflow-x: hidden;
}

.hero-panel {
    background: linear-gradient(135deg, #312e81 0%, #4338ca 45%, #0ea5e9 100%);
    border-radius: calc(var(--radius) + 4px);
    color: #fff;
    padding: 1.6rem 1.8rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.hero-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.16), transparent 35%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.22), transparent 30%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.85rem;
    margin-bottom: 0.6rem;
}

.hero-badge.admin {
    background: rgba(255, 255, 255, 0.18);
}

.hero-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0;
}

.hero-subtitle {
    margin: 0.4rem 0 0;
    color: rgba(255, 255, 255, 0.82);
}

.hero-stats {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.stat-card {
    min-width: 110px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 0.85rem 1rem;
    backdrop-filter: blur(8px);
}

.stat-card small {
    display: block;
    margin-top: 0.15rem;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.75rem;
}

.stat-card.accent {
    background: rgba(255, 255, 255, 0.18);
}

.stat-label {
    display: block;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.75);
}

.stat-value {
    display: block;
    font-size: 1.35rem;
    line-height: 1.2;
}

.panel-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.filter-panel.panel-card,
.filter-panel-compact.panel-card {
    overflow: visible;
    position: relative;
    z-index: 1;
}

.inventory-panel {
    position: relative;
    z-index: 1;
    max-width: 100%;
    overflow: hidden;
}

.panel-card.border-primary {
    border: 2px solid #c7d2fe;
}

.panel-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.panel-card-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-card-subtitle {
    margin: 0.35rem 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.filter-panel .panel-card-header,
.inventory-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.hero-copy {
    max-width: 560px;
}

.panel-card-body {
    padding: 1.25rem;
}

.modern-input,
.form-select.modern-input {
    border-radius: 12px;
    border-color: var(--border);
    min-height: 44px;
}

.modern-input:focus,
.form-select.modern-input:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.12);
}

.btn-modern {
    border-radius: 12px;
    padding: 0.65rem 1.1rem;
    font-weight: 600;
}

.btn-soft {
    background: var(--primary-soft);
    color: var(--primary);
    border: 0;
    border-radius: 10px;
}

.btn-soft:hover {
    background: #e0e7ff;
    color: var(--primary-dark);
}

.btn-soft-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 0;
    border-radius: 10px;
}

.btn-soft-danger:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.app-alert {
    border: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modern-table-wrap {
    border-radius: 0 0 var(--radius) var(--radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    direction: rtl;
    box-sizing: border-box;
}

#inventoryTableWrap {
    width: 100%;
    max-width: 100%;
}

.modern-table-wrap.is-viewport-balanced {
    overflow-x: hidden;
}

.modern-table-wrap.is-viewport-balanced.table-responsive {
    overflow-x: hidden;
}

.inventory-table {
    width: 100%;
    min-width: 100%;
    font-size: var(--inventory-font-size, 0.82rem);
    table-layout: fixed;
    border-collapse: collapse;
    --bs-table-bg: transparent;
    --bs-table-accent-bg: transparent;
}

.inventory-font-sm {
    --inventory-font-size: 0.78rem;
    --inventory-th-font-size: 0.74rem;
}

.inventory-font-md {
    --inventory-font-size: 0.84rem;
    --inventory-th-font-size: 0.78rem;
}

.inventory-font-lg {
    --inventory-font-size: 0.94rem;
    --inventory-th-font-size: 0.86rem;
}

.inventory-font-xl {
    --inventory-font-size: 1.02rem;
    --inventory-th-font-size: 0.92rem;
}

.sortable-th {
    padding: 0 !important;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    padding: 0.42rem 0.5rem;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.sort-link:hover {
    color: var(--primary);
    background: #eef2ff;
}

.sortable-th.is-sorted .sort-link {
    color: var(--primary);
    font-weight: 700;
}

.sort-icon {
    font-size: 0.85em;
    opacity: 0.55;
}

.sortable-th.is-sorted .sort-icon {
    opacity: 1;
}

.inventory-table thead th,
.inventory-table tbody td {
    white-space: nowrap;
}

.inventory-table tbody td[data-column-key="MtName"],
.inventory-table tbody td[data-column-key="TsName"] {
    white-space: normal;
}

.table-scroll-hint {
    display: none;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.inventory-table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: var(--inventory-th-font-size, 0.74rem);
    font-weight: 600;
    letter-spacing: 0;
    color: #64748b;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 var(--border);
    padding: 0;
}

.inventory-table tbody tr.inventory-row {
    transition: background-color 0.12s ease;
    border-bottom: 1px solid #cbd5e1;
}

.inventory-table.table > tbody > tr.inventory-row:nth-child(odd) > td,
.inventory-table.table > tbody > tr.inventory-row:nth-child(odd) > th {
    background-color: #ffffff;
}

.inventory-table.table > tbody > tr.inventory-row:nth-child(even) > td,
.inventory-table.table > tbody > tr.inventory-row:nth-child(even) > th {
    background-color: #d9e2ec;
}

.inventory-table.table > tbody > tr.inventory-row:hover > td,
.inventory-table.table > tbody > tr.inventory-row:hover > th {
    background-color: #eef2ff;
}

.inventory-table.table > tbody > tr.inventory-row:nth-child(even):hover > td,
.inventory-table.table > tbody > tr.inventory-row:nth-child(even):hover > th {
    background-color: #c5d0dc;
}

.inventory-table tbody td {
    vertical-align: middle;
    padding: 0.32rem 0.45rem;
    line-height: 1.25;
}

.inventory-table [data-column-key="SalPric"],
.inventory-table [data-column-key="FixPric"],
.inventory-table [data-column-key="CstPric"],
.inventory-table [data-column-key="HlfPric"],
.inventory-table [data-column-key="TotalQuantity"] {
    text-align: end;
}

.modern-table-wrap.is-viewport-balanced .inventory-table {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed;
}

.modern-table-wrap.is-viewport-balanced .inventory-table [data-column-key] {
    min-width: 0 !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modern-table-wrap.is-viewport-balanced .inventory-table [data-column-key="MtName"],
.modern-table-wrap.is-viewport-balanced .inventory-table [data-column-key="Breakdown"] {
    overflow: visible;
    white-space: normal;
}

.modern-table-wrap.is-viewport-balanced .inventory-table [data-column-key="Image"] {
    width: auto !important;
    min-width: 0 !important;
    max-width: 5% !important;
    padding-inline: 0.1rem;
}

.inventory-table [data-column-key="Image"] {
    text-align: center;
    overflow: hidden;
    padding-inline: 0.15rem;
}

.inventory-table [data-column-key="PriceDatabase"] {
    text-align: center;
}

.cell-mt-no .cell-copy-text,
.cell-mono {
    font-variant-numeric: tabular-nums;
    font-family: "Cascadia Code", "Consolas", "Courier New", monospace;
    font-size: 0.9em;
    letter-spacing: 0.01em;
}

.cell-mt-name .cell-copy-text {
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.price-cell .price-main {
    display: inline-block;
    font-weight: 600;
    font-size: 0.95em;
    font-variant-numeric: tabular-nums;
    color: #047857;
    letter-spacing: 0;
}

.qty-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    border-radius: 6px;
    padding: 0.1rem 0.4rem;
    font-weight: 600;
    font-size: 0.92em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
}

.qty-badge-ok {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.qty-badge-low {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

.qty-badge-zero {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.dept-badge-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    padding: 0.08rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dept-badge-tone-0 { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.dept-badge-tone-1 { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.dept-badge-tone-2 { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.dept-badge-tone-3 { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.dept-badge-tone-4 { background: #fdf4ff; color: #a21caf; border-color: #f5d0fe; }
.dept-badge-tone-5 { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.dept-badge {
    background: #eef2ff !important;
    color: #4338ca !important;
    font-weight: 600;
}

.price-cell .price-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.breakdown-cell {
    background: transparent !important;
    padding: 0.32rem 0.45rem !important;
    min-width: 0;
    overflow: visible;
}

.breakdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border: 1px solid #dbeafe;
    background: #f8fafc;
    color: #4338ca;
    border-radius: 6px;
    padding: 0.12rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.breakdown-toggle:hover {
    background: #e0e7ff;
    border-color: #a5b4fc;
}

.breakdown-toggle-count {
    color: #6366f1;
}

.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.55rem;
    min-width: 220px;
}

.breakdown-list.breakdown-collapsed {
    display: none;
}

.breakdown-list.breakdown-expanded {
    display: flex;
}

.breakdown-item {
    display: grid;
    grid-template-columns: minmax(64px, 0.9fr) minmax(80px, 1.3fr) auto;
    gap: 0.45rem;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e8edf5;
    font-size: 0.82rem;
    min-width: 0;
}

.breakdown-item-total {
    background: #f8fafc;
    border-style: dashed;
    border-color: #cbd5e1;
}

.breakdown-item-total .breakdown-warehouse {
    color: var(--text-muted);
    font-weight: 700;
}

body.theme-dark .breakdown-item-total {
    background: rgba(15, 23, 42, 0.65);
    border-color: #334155;
}

.admin-breakdown-departments {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.35rem 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border, #e8edf5);
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.8);
    max-height: 220px;
    overflow: auto;
}

.breakdown-dept {
    color: #4338ca;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.breakdown-warehouse {
    color: var(--text);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.breakdown-qty {
    color: #0f766e;
    font-weight: 800;
    background: #ecfdf5;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    white-space: nowrap;
    justify-self: end;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
}

.empty-state-inventory {
    padding: 0.5rem 0.75rem 0.25rem;
}

.empty-state-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #f1f5f9;
    color: #64748b;
    margin-bottom: 0.15rem;
}

.empty-state i,
.empty-state-icon i {
    font-size: 1.55rem;
    color: #94a3b8;
}

.empty-state strong {
    color: var(--text);
    font-size: 1rem;
}

.btn-primary.btn-modern {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border: 0;
    box-shadow: 0 10px 24px rgba(79, 70, 229, 0.22);
}

.btn-primary.btn-modern:hover {
    background: linear-gradient(135deg, var(--primary-dark), #4f46e5);
}

.breakdown-panel {
    padding: 1rem 1.25rem;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.65rem;
}

.permission-chip {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    margin: 0;
}

.permission-chip input {
    accent-color: var(--primary);
}

.permission-chip span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.92rem;
}

.column-permissions.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

.role-admin {
    background: #eef2ff !important;
    color: #4338ca !important;
}

.role-user {
    background: #ecfeff !important;
    color: #0e7490 !important;
}

.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
    background:
        radial-gradient(circle at top right, rgba(79, 70, 229, 0.35), transparent 30%),
        radial-gradient(circle at bottom left, rgba(14, 165, 233, 0.28), transparent 28%),
        linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%);
}

.auth-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(79, 70, 229, 0.35), transparent 30%),
        radial-gradient(circle at bottom left, rgba(14, 165, 233, 0.28), transparent 28%),
        linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%);
}

.auth-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.auth-card {
    width: min(100%, 430px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.28);
    padding: 2rem;
}

.auth-card-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(10, 20, 36, 0.28);
}

.auth-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.auth-card-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.auth-card-header p {
    color: var(--text-muted);
    margin: 0;
}

.auth-submit {
    min-height: 48px;
}

.currency-toggle {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.35rem;
    border-radius: 14px;
    background: #f1f5f9;
    border: 1px solid var(--border);
}

.currency-btn {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    border-radius: 10px;
    padding: 0.55rem 0.95rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: 0.2s ease;
}

.currency-btn.active {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.25);
}

.currency-btn:hover:not(.active) {
    background: #e2e8f0;
    color: var(--text);
}

.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}

.pagination-bar:last-child {
    border-bottom: 0;
    border-top: 1px solid var(--border);
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.92rem;
}

.page-size-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
}

.page-size-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
    white-space: nowrap;
}

.page-size-select {
    width: auto;
    min-width: 90px;
}

.pagination-modern .page-link {
    border-radius: 10px;
    margin: 0 0.15rem;
    border: 0;
    color: var(--primary);
    background: #eef2ff;
}

.pagination-modern .page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
}

.pagination-modern .page-item.disabled .page-link {
    background: #f1f5f9;
    color: #94a3b8;
}

.excel-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

.excel-status-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.85rem 1rem;
}

.excel-status-item span {
    display: block;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 0.25rem;
}

.excel-status-item strong {
    display: block;
    font-size: 0.92rem;
    word-break: break-all;
}

@media (max-width: 1399px) {
    .hero-panel {
        padding: 1.25rem 1.35rem;
    }

    .hero-title {
        font-size: 1.55rem;
    }

    .app-content {
        padding: 1rem;
    }
}

@media (max-width: 1199px) {
    .app-topbar-role {
        display: none;
    }

    .app-main {
        min-height: calc(100vh - 58px);
    }

    .hero-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero-stats {
        width: 100%;
    }

    .stat-card {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 0;
    }

    .table-scroll-hint {
        display: block;
    }
}

@media (max-width: 992px) {
    .hero-title {
        font-size: 1.35rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .panel-card-header,
    .panel-card-body {
        padding: 0.9rem 1rem;
    }

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

    .excel-status-grid {
        grid-template-columns: 1fr;
    }

    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .page-size-form {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .app-content {
        padding: 0.75rem;
    }

    .hero-panel {
        padding: 1rem;
        border-radius: 16px;
    }

    .hero-badge {
        font-size: 0.78rem;
    }

    .hero-title {
        font-size: 1.2rem;
    }

    .stat-card {
        flex: 1 1 100%;
    }

    .stat-value {
        font-size: 1.15rem;
    }

    .modern-input,
    .form-select.modern-input {
        min-height: 40px;
        font-size: 0.92rem;
    }

    .btn-modern:not(.btn-sm):not(.btn-icon) {
        width: 100%;
    }

    .toolbar-actions .btn-modern,
    .filter-action-buttons .btn-modern,
    .btn-group .btn-modern,
    .hero-content .d-flex .btn-modern,
    .chat-composer .btn-modern,
    .pagination-bar .btn-modern,
    .chat-window-composer .btn-modern {
        width: auto;
    }

    .currency-toggle.w-100 {
        width: 100%;
        justify-content: center;
    }

    .inventory-mobile-cards {
        overflow-x: visible;
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .inventory-mobile-cards .table-scroll-hint {
        display: none;
    }

    .inventory-mobile-cards .inventory-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }

    .inventory-mobile-cards .inventory-table thead {
        display: none;
    }

    .inventory-mobile-cards .inventory-table tbody tr.inventory-row {
        display: block;
        margin: 0.65rem 0.75rem;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
        overflow: hidden;
    }

    .inventory-mobile-cards .inventory-table tbody tr.inventory-row:hover {
        box-shadow: 0 8px 22px rgba(79, 70, 229, 0.12);
    }

    .inventory-mobile-cards .inventory-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.5rem 0.85rem;
        border-bottom: 1px dashed #e8edf5;
        white-space: normal;
        position: static !important;
        box-shadow: none !important;
        background: transparent !important;
        min-width: 0 !important;
        max-width: none !important;
        width: auto !important;
    }

    .inventory-mobile-cards .inventory-table tbody td::before {
        content: attr(data-label);
        font-size: 0.76rem;
        font-weight: 700;
        color: var(--text-muted);
        flex-shrink: 0;
        max-width: 42%;
    }

    .inventory-mobile-cards .inventory-table tbody td[data-column-key="MtName"],
    .inventory-mobile-cards .inventory-table tbody td[data-column-key="Breakdown"] {
        flex-direction: column;
        align-items: stretch;
    }

    .inventory-mobile-cards .inventory-table tbody td[data-column-key="MtName"]::before,
    .inventory-mobile-cards .inventory-table tbody td[data-column-key="Breakdown"]::before {
        max-width: none;
    }

    .inventory-mobile-cards .inventory-table tbody td[data-column-key="MtName"] .cell-copy-wrap,
    .inventory-mobile-cards .inventory-table tbody td[data-column-key="Breakdown"] .breakdown-list {
        width: 100%;
    }

    .inventory-mobile-cards .inventory-table tbody td:last-child {
        border-bottom: 0;
    }

    .inventory-mobile-cards .inventory-table tbody td.is-column-hidden {
        display: none !important;
    }

    .inventory-mobile-cards .inventory-empty-row td {
        display: block;
        border: 0;
        padding: 1.5rem 0.85rem;
    }

    .inventory-mobile-cards .inventory-empty-row td::before {
        content: none;
    }

    body.theme-dark .inventory-mobile-cards .inventory-table tbody tr.inventory-row {
        background: #111827;
        border-color: var(--border);
    }

    .auth-card {
        padding: 1.25rem;
        border-radius: 18px;
    }
}

@media (max-width: 576px) {
    .sidebar-brand strong {
        font-size: 0.92rem;
    }

    .nav-item {
        padding: 0.7rem 0.85rem;
        font-size: 0.92rem;
    }

    .panel-card-header h2 {
        font-size: 0.95rem;
    }
}

@media (max-height: 700px) {
    .app-sidebar {
        overflow-y: auto;
    }

    .hero-panel {
        margin-bottom: 0.75rem !important;
    }

    .hero-stats {
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.6rem 0.75rem;
    }
}

.column-sortable-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.column-sortable-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: grab;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.column-sortable-item.is-dragging {
    opacity: 0.65;
    box-shadow: var(--shadow);
}

.column-drag-handle {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    user-select: none;
}

/* Admin settings layout */
.admin-settings-quick,
.admin-settings-main,
.admin-settings-log {
    position: relative;
    z-index: auto;
    width: 100%;
}

.admin-settings-card,
.admin-settings-main .panel-card,
.admin-settings-log {
    height: auto !important;
    min-height: 0;
    overflow: visible;
}

.admin-settings-main .row {
    align-items: flex-start;
}

.admin-settings-quick .column-sortable-list,
.admin-permissions-list {
    max-height: 220px;
    overflow-y: auto;
    padding-inline-end: 0.25rem;
}

.admin-permissions-list {
    max-height: 320px;
}

.admin-settings-main .panel-card-body {
    max-height: none;
}

.admin-settings-log {
    clear: both;
}

.admin-settings-log .modern-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.admin-activity-table {
    width: 100%;
    min-width: 720px;
    table-layout: auto;
}

.admin-activity-table th,
.admin-activity-table td {
    white-space: nowrap;
    vertical-align: middle;
}

.admin-activity-table .activity-col-time {
    width: 11rem;
}

.admin-activity-table .activity-col-user {
    width: 9rem;
}

.admin-activity-table .activity-col-action {
    width: 8rem;
}

.admin-activity-table .activity-col-subject {
    white-space: normal;
    min-width: 12rem;
}

.admin-activity-table code {
    white-space: nowrap;
}

/* === Inventory compact top === */
.inventory-top-compact {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: visible;
    position: relative;
    z-index: 200;
}

.inventory-top-compact.is-autocomplete-open {
    z-index: 5000;
}

.inventory-top-compact.is-sync-info-open {
    z-index: 5500;
}

.inventory-top-compact.is-sync-info-open .hero-panel-compact {
    z-index: 60;
}

.hero-panel-compact {
    padding: 0.45rem 0.85rem;
    margin-bottom: 0 !important;
    border-radius: 12px;
    overflow: visible;
    position: relative;
    z-index: 20;
}

.hero-content-compact {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hero-title-block {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    min-width: 0;
}

.hero-title-compact {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.sync-indicator-compact {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.78);
    white-space: nowrap;
}

.sync-info-dropdown {
    position: relative;
    z-index: 40;
}

.sync-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.sync-info-btn:hover,
.sync-info-btn:focus,
.sync-info-btn.show {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.55);
    color: #fff;
    transform: scale(1.04);
}

.sync-info-menu {
    min-width: 18rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
    z-index: 6100 !important;
    margin-top: 0.45rem !important;
}

.sync-info-section + .sync-info-section {
    margin-top: 0;
}

.sync-info-heading {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.45rem;
}

.sync-info-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.8rem;
    padding: 0.2rem 0;
}

.sync-info-label {
    color: var(--text-muted);
    white-space: nowrap;
}

.sync-info-note {
    margin-top: 0.35rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.sync-info-empty {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.sync-info-divider {
    height: 1px;
    background: var(--border);
    margin: 0.55rem 0;
}

.hero-stats-inline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
    line-height: 1.2;
}

.stat-pill.accent {
    background: rgba(255, 255, 255, 0.18);
}

.stat-pill-label {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.68rem;
}

.stat-pill strong {
    font-size: 0.82rem;
    font-weight: 800;
}

.inventory-quantity-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0 1rem 0.75rem;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.06), rgba(37, 99, 235, 0.02));
}

.inventory-quantity-total-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text);
}

.inventory-quantity-total-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.01em;
}

.filter-panel-compact {
    border-radius: 12px;
}

.filter-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.filter-toolbar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
}

.filter-toolbar-title h2 {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.filter-hint {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.filter-hint kbd {
    font-size: 0.68rem;
    padding: 0.05rem 0.3rem;
}

.panel-card-body-compact {
    padding: 0.55rem 0.75rem 0.65rem;
    overflow: visible;
}

.inventory-filter-form {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.filter-row {
    display: flex;
    align-items: flex-end;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.filter-row-options {
    align-items: center;
    gap: 0.55rem;
    padding-top: 0.1rem;
    border-top: 1px dashed var(--border);
}

.filter-field {
    flex: 1 1 120px;
    min-width: 0;
}
.filter-field-departments {
    min-width: 200px;
    position: relative;
    z-index: 40;
}
.department-multi {
    position: relative;
}
.department-multi-toggle {
    text-align: start;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.department-multi-toggle::after {
    content: "";
    width: 0.55rem;
    height: 0.55rem;
    border-inline-end: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-inline-start: 0.5rem;
    opacity: 0.55;
    flex-shrink: 0;
}
.department-multi-panel {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 4px);
    z-index: 50;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
    padding: 0.55rem;
    min-width: 220px;
}
.department-multi-list {
    max-height: 220px;
    overflow-y: auto;
    margin: 0.35rem 0;
}
.department-multi-option {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.4rem;
    border-radius: 8px;
    margin: 0;
    cursor: pointer;
    font-size: 0.88rem;
}
.department-multi-option:hover {
    background: var(--surface-muted);
}
.department-multi-option input {
    margin: 0;
}
.department-multi-all {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 0.2rem;
    font-weight: 600;
}
.department-multi-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
}
.cell-copy-btn.is-copied {
    color: #16a34a;
}

.filter-field-narrow {
    flex: 0 1 72px;
    max-width: 88px;
}

.filter-field-currency {
    flex: 0 1 96px;
    max-width: 110px;
}

.filter-field-grow {
    flex: 1 1 180px;
}

.filter-row-search {
    overflow: visible;
    position: relative;
    z-index: 6;
    display: grid !important;
    grid-template-columns: minmax(280px, 1.25fr) minmax(220px, 1fr);
    gap: 0.45rem;
    align-items: end;
    width: 100%;
}

.filter-search-primary {
    position: relative;
    z-index: 8;
    min-width: 0;
}

.filter-search-primary-row {
    display: flex !important;
    align-items: stretch;
    gap: 0.4rem;
    min-width: 0;
    width: 100%;
}

.filter-search-primary-row .search-quick-input-wrap {
    flex: 1 1 auto;
    min-width: 140px;
    display: block;
}

.filter-search-primary-row .form-control {
    width: 100%;
    min-width: 0;
}

.filter-search-primary-row .btn {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
    align-self: stretch;
}

.filter-search-primary .search-suggestions-panel {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 4px);
    z-index: 6000;
}

.filter-search-multi {
    min-width: 0;
}

.filter-search-multi .form-control {
    width: 100%;
}

.filter-field-actions {
    flex: 0 0 auto;
}

.filter-field .form-label {
    margin-bottom: 0.15rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}

.modern-input-sm,
.form-select.modern-input-sm {
    min-height: 32px;
    padding: 0.25rem 0.55rem;
    font-size: 0.82rem;
    border-radius: 8px;
}

.currency-toggle-sm {
    padding: 0.15rem;
    border-radius: 8px;
    gap: 0.15rem;
}

.currency-toggle-sm .currency-btn {
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
    border-radius: 6px;
    flex: 1;
    justify-content: center;
}

.filter-action-buttons {
    display: flex;
    gap: 0.35rem;
    flex-wrap: nowrap;
}

.filter-inline-check,
.filter-inline-switch {
    margin: 0;
    flex: 0 0 auto;
}

.filter-option-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto;
    margin: 0;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    white-space: nowrap;
}

.filter-option-pill .form-check-input {
    float: none;
    margin: 0;
    flex-shrink: 0;
}

.filter-option-pill .form-check-label {
    font-size: 0.78rem;
    margin: 0;
    cursor: pointer;
    user-select: none;
}

.filter-option-pill-switch .form-check-input {
    width: 2rem;
    height: 1rem;
}

.filter-option-pill.is-locked {
    opacity: 0.85;
    background: var(--surface-muted);
}

.filter-option-pill.is-locked .form-check-label {
    cursor: not-allowed;
}

.filter-inline-check .form-check-label,
.filter-inline-switch .form-check-label {
    font-size: 0.78rem;
}

.filter-inline-switch {
    padding-right: 0.5rem;
    border-right: 1px solid var(--border);
}

.filter-inline-switch .form-check-input {
    width: 2rem;
    height: 1rem;
    margin-top: 0.1rem;
}

.quick-filter-group-compact {
    flex: 1 1 auto;
    gap: 0.3rem;
    min-width: 0;
}

.quick-filter-btn-sm {
    padding: 0.2rem 0.55rem;
    font-size: 0.74rem;
    border-radius: 999px;
}

.btn-icon {
    padding: 0.25rem 0.45rem;
}

.inventory-panel .panel-card-header {
    padding: 0.65rem 0.85rem;
}

.inventory-panel-header .panel-card-subtitle {
    font-size: 0.78rem;
}

@media (max-width: 992px) {
    .filter-row-search {
        grid-template-columns: 1fr;
    }

    .filter-search-primary {
        z-index: 20;
    }

    .filter-search-primary .search-suggestions-panel {
        position: relative;
        top: auto;
        inset-inline: auto;
        margin-top: 0.35rem;
    }

    .filter-search-primary-row .btn {
        min-height: 32px;
        padding: 0.25rem 0.65rem;
    }

    .filter-row-options {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-inline-switch {
        border-right: 0;
        padding-right: 0;
    }
}

@media (max-width: 768px) {
    .hero-title-compact {
        font-size: 0.95rem;
    }

    .hero-stats-inline {
        width: 100%;
    }

    .filter-toolbar {
        padding: 0.4rem 0.55rem;
    }

    .panel-card-body-compact {
        padding: 0.45rem 0.55rem 0.55rem;
    }
}

/* === UX enhancements === */
.sync-indicator { color: var(--text-muted); font-size: 0.88rem; margin-top: 0.35rem; }
.toolbar-actions .btn { white-space: nowrap; }
.quick-filter-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.quick-filter-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.quick-filter-btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); font-weight: 700; }
.autocomplete-wrap { position: relative; z-index: 30; }
.autocomplete-list {
    position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 6000;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow-lg, var(--shadow)); max-height: min(520px, 60vh); overflow-y: auto;
    overscroll-behavior: contain;
}
.autocomplete-head {
    display: grid;
    grid-template-columns: 1fr 4.5rem;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: 12px 12px 0 0;
}
.autocomplete-head span:last-child {
    text-align: center;
}
.autocomplete-item {
    display: block;
    width: 100%;
    text-align: start;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    padding: 0;
    cursor: pointer;
    font-size: 0.84rem;
    line-height: 1.35;
}
.autocomplete-item:last-child {
    border-bottom: 0;
}
.autocomplete-item.has-qty {
    display: grid;
    grid-template-columns: 1fr 4.5rem;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.85rem;
}
.autocomplete-item:not(.has-qty) {
    padding: 0.5rem 0.85rem;
}
.autocomplete-item-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.autocomplete-item-qty {
    justify-self: center;
    min-width: 2.5rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
}
.autocomplete-item-qty.is-zero {
    color: var(--text-muted);
    background: #f1f5f9;
}
.autocomplete-item.is-active { background: var(--primary-soft); outline: 2px solid var(--primary); outline-offset: -2px; }
.autocomplete-item:hover { background: var(--primary-soft); }
.autocomplete-empty {
    padding: 0.65rem 0.85rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.inventory-row { cursor: pointer; }
.inventory-row:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
.inventory-view-comfortable .inventory-table tbody td { padding: 0.5rem 0.65rem; }
.inventory-view-compact .inventory-table thead th .sort-link,
.inventory-view-compact .inventory-table thead th .th-label { padding: 0.3rem 0.4rem; }
.inventory-view-compact .inventory-table tbody td { padding: 0.24rem 0.38rem; }
.inventory-view-compact .cell-image-thumb-btn { width: 1.75rem; height: 1.75rem; border-radius: 8px; }
.inventory-table .sticky-col {
    position: sticky;
    z-index: 2;
    box-shadow: -1px 0 0 var(--border);
}
.inventory-table thead .sticky-col { z-index: 5; background: #f8fafc; }
.inventory-table tbody tr.inventory-row:nth-child(odd) .sticky-col { background-color: #ffffff; }
.inventory-table tbody tr.inventory-row:nth-child(even) .sticky-col { background-color: #d9e2ec; }
.inventory-table tbody tr.inventory-row:hover .sticky-col { background-color: #eef2ff; }
.inventory-table tbody tr.inventory-row:nth-child(even):hover .sticky-col { background-color: #c5d0dc; }
.inventory-table thead th[data-column-key="MtNo"].sticky-col,
.inventory-table tbody td[data-column-key="MtNo"].sticky-col {
    min-width: 52px;
}

.inventory-table thead th[data-column-key="MtName"].sticky-col,
.inventory-table tbody td[data-column-key="MtName"].sticky-col {
    min-width: 0;
    white-space: normal;
}

.inventory-table thead th[data-column-key="MtNo"].sticky-col.has-custom-width,
.inventory-table tbody td[data-column-key="MtNo"].sticky-col.has-custom-width,
.inventory-table thead th[data-column-key="MtName"].sticky-col.has-custom-width,
.inventory-table tbody td[data-column-key="MtName"].sticky-col.has-custom-width {
    min-width: 0 !important;
    max-width: none !important;
}
#inventoryColgroup col.is-column-hidden {
    width: 0 !important;
}
#inventoryTableWrap.is-loading {
    opacity: 1;
    pointer-events: none;
    position: relative;
}

#inventoryTableWrap.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(248, 250, 252, 0.4) 25%, rgba(238, 242, 255, 0.85) 50%, rgba(248, 250, 252, 0.4) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s infinite;
    z-index: 3;
    pointer-events: none;
}

#inventoryTableWrap.is-loading .inventory-table {
    opacity: 0.55;
}

/* Column layout toolbar */
.column-layout-toolbar { position: relative; flex-shrink: 0; }
.column-layout-panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: 30;
    width: min(320px, 92vw);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    padding: 0.75rem;
}
.column-layout-panel-head {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-bottom: 0.65rem;
}
.column-layout-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow: auto;
}
.column-layout-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.35rem;
    border-radius: 8px;
    border: 1px solid transparent;
}
.column-layout-item.is-reorder-disabled .column-drag-handle,
.th-drag-handle[hidden] {
    display: none !important;
}
.column-layout-item.is-dragging { opacity: 0.55; }
.column-layout-item.is-drop-target { border-color: var(--primary); background: var(--primary-soft); }
.column-drag-handle,
.th-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    display: inline-flex;
    align-items: center;
    user-select: none;
    flex-shrink: 0;
    padding: 0.2rem 0.25rem;
    margin-inline-end: 0.1rem;
    border-radius: 4px;
    touch-action: none;
}
.column-drag-handle:hover,
.th-drag-handle:hover {
    background: rgba(100, 116, 139, 0.14);
    color: var(--primary);
}
.column-drag-handle:active,
.th-drag-handle:active { cursor: grabbing; }
.column-layout-label { flex: 1; font-size: 0.88rem; }
.column-visibility-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
}
.column-layout-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

/* Table header drag + resize */
.inventory-th {
    position: relative;
    overflow: visible;
}
.inventory-th .th-inner {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    min-width: 0;
    min-height: 0;
    padding: 0.1rem 0.15rem;
    position: relative;
    z-index: 1;
}

.inventory-th .th-label {
    display: inline-flex;
    align-items: center;
    padding: 0.42rem 0.5rem;
    font-size: inherit;
}
.th-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 18px;
    cursor: col-resize;
    z-index: 25;
    touch-action: none;
    pointer-events: auto;
}
.inventory-th.is-resize-hover {
    cursor: col-resize;
}
.th-resize-handle-start {
    inset-inline-start: 0;
}
.th-resize-handle-end {
    inset-inline-end: 0;
}
.th-resize-handle[hidden] {
    display: none !important;
}
.th-resize-handle::after {
    content: "";
    position: absolute;
    top: 15%;
    bottom: 15%;
    width: 3px;
    border-radius: 3px;
    background: rgba(100, 116, 139, 0.5);
}
.th-resize-handle-start::after {
    inset-inline-start: 4px;
}
.th-resize-handle-end::after {
    inset-inline-end: 4px;
}
.th-resize-handle:hover::after,
body.is-resizing-column .th-resize-handle.is-active::after {
    background: var(--primary);
    width: 4px;
}
body.is-resizing-column {
    cursor: col-resize !important;
    user-select: none !important;
}
body.is-resizing-column * {
    cursor: col-resize !important;
}
.inventory-table .has-custom-width,
.inventory-table [data-column-key="MtName"].has-custom-width,
.inventory-table [data-column-key="MtName"].sticky-col.has-custom-width {
    max-width: none !important;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.inventory-th.is-dragging { opacity: 0.55; }
.inventory-th.is-drop-target { box-shadow: inset 0 -2px 0 var(--primary); }
.inventory-th .sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}
.inventory-table [data-column-key].is-column-hidden {
    display: none !important;
}
.inventory-th:not(.is-resize-hover):not(.is-dragging) { cursor: default; }
body.is-dragging-column {
    cursor: grabbing !important;
    user-select: none !important;
}
body.is-dragging-column * {
    cursor: grabbing !important;
}
body.is-dragging-column .th-drag-handle {
    cursor: grabbing !important;
}
.column-layout-toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1080;
    background: #0f172a;
    color: #fff;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.column-layout-toast.is-visible { opacity: 1; }
.column-layout-toast.is-error { background: #b91c1c; }

/* Copyable material name */
.cell-copyable { user-select: text; }
.cell-copy-wrap {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
}
.cell-copy-text {
    flex: 1;
    min-width: 0;
    user-select: text;
    cursor: text;
    line-height: 1.35;
}
.cell-copy-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.1rem 0.25rem;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
}
.cell-copy-btn:hover {
    color: var(--primary);
    background: var(--primary-soft);
}
.cell-image-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.1rem 0.25rem;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    cursor: pointer;
}
.cell-image-btn:hover {
    color: var(--primary);
    background: var(--primary-soft);
}
.cell-image-thumb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #fff;
    transition: border-color 0.15s ease;
    flex-shrink: 0;
}
.cell-image-thumb-btn:hover {
    border-color: #c7d2fe;
}
.cell-image-thumb-btn.is-placeholder {
    background: #f8fafc;
    border-style: dashed;
}
.cell-image-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cell-image-thumb.is-fallback {
    object-fit: contain;
    padding: 0.25rem;
    opacity: 0.55;
}
.inventory-image-cell {
    padding-inline: 0.35rem;
    vertical-align: middle;
}
.inventory-image-cell .cell-image-btn:not(.cell-image-thumb-btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    min-height: 2rem;
    font-size: 1.05rem;
}
.inventory-table .inventory-th[data-column-key="Image"] .th-label,
.inventory-table .inventory-th[data-column-key="Image"] .th-inner {
    justify-content: center;
}
.item-image-modal-card .modal-body {
    padding: 1rem 1.25rem 1.25rem;
}
.item-image-modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.item-image-viewer {
    display: grid;
    gap: 0.85rem;
}
.item-image-main-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    max-height: min(62vh, 520px);
    background: var(--surface-muted, #f8fafc);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}
.item-image-main-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.35) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: item-hero-shimmer 1.2s ease-in-out infinite;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.item-image-main-wrap.is-loading::after {
    opacity: 1;
}
.item-image-main {
    max-width: 100%;
    max-height: min(62vh, 520px);
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 1;
}
.item-image-main.is-loading {
    opacity: 0.55;
}
.item-image-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}
.item-image-thumb {
    border: 2px solid transparent;
    background: var(--surface, #fff);
    border-radius: 10px;
    padding: 0.25rem;
    width: 72px;
    cursor: pointer;
}
.item-image-thumb img {
    width: 100%;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}
.item-image-thumb span {
    display: block;
    font-size: 0.72rem;
    text-align: center;
    margin-top: 0.15rem;
    color: var(--text-muted);
}
.item-image-thumb.is-active {
    border-color: var(--primary);
}
.item-image-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}
.item-image-empty {
    text-align: center;
    margin: 0;
}
.skeleton-block {
    height: 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s infinite;
}
.skeleton-block.short { width: 55%; }
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.item-detail-grid { display: grid; gap: 0.65rem; }
.item-detail-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px dashed var(--border); }
.item-price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.65rem; }
.item-price-card { background: var(--surface-muted); border: 1px solid var(--border); border-radius: 12px; padding: 0.65rem 0.8rem; }

/* === Item detail modal (aligned with portal navy/gold) === */
.item-modal-card {
    border: none;
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 28px 64px rgba(10, 20, 36, 0.22);
}

.item-modal-card .modal-header {
    border: none;
    padding: 0;
    background: linear-gradient(135deg, #0A1424 0%, #152238 48%, #1B3B72 100%);
    color: #fff;
    position: relative;
}

.item-modal-card .modal-header::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 0%, rgba(212, 180, 90, 0.22), transparent 42%),
        radial-gradient(circle at 92% 18%, rgba(23, 143, 124, 0.16), transparent 40%);
    pointer-events: none;
}

.item-modal-card .modal-header::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, #A48732, #D4B45A 45%, #F3E4B8 70%, transparent);
    opacity: 0.9;
}

.item-modal-header-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem 1rem;
    width: 100%;
    padding: 1rem 1.15rem 1.05rem;
}

.item-modal-heading {
    min-width: 0;
    flex: 1;
}

.item-modal-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    background: rgba(243, 228, 184, 0.14);
    border: 1px solid rgba(243, 228, 184, 0.28);
    color: #F3E4B8;
    font-size: 0.76rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
    letter-spacing: 0.01em;
}

.item-modal-title {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 800;
    line-height: 1.4;
    color: #fff;
}

.item-modal-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    color: rgba(233, 237, 245, 0.72);
}

.item-modal-qty {
    align-self: stretch;
    flex-shrink: 0;
    min-width: 4.35rem;
    text-align: center;
    padding: 0.55rem 0.7rem;
    border-radius: 0.95rem;
    background: linear-gradient(160deg, rgba(212, 180, 90, 0.28), rgba(255, 255, 255, 0.08));
    border: 1px solid rgba(243, 228, 184, 0.32);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.item-modal-qty[hidden] {
    display: none !important;
}

.item-modal-qty small {
    display: block;
    font-size: 0.66rem;
    color: rgba(243, 228, 184, 0.9);
    margin-bottom: 0.2rem;
    font-weight: 700;
}

.item-modal-qty strong {
    display: block;
    font-size: 1.4rem;
    font-weight: 900;
    line-height: 1;
    color: #fff;
}

.item-modal-card .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
    margin: 0.1rem 0 0;
    width: 0.85rem;
    height: 0.85rem;
    background-size: 0.75rem;
}

.item-modal-card .btn-close:hover {
    opacity: 1;
}

.item-modal-card .modal-body {
    padding: 0 0 0.35rem;
    background: linear-gradient(180deg, #F7F9FC 0%, #fff 38%);
}

.item-modal-hero {
    padding: 1rem 1.2rem 0.15rem;
}

.item-modal-hero-media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 168px;
    max-height: 240px;
    border-radius: 1.05rem;
    border: 1px solid rgba(217, 225, 236, 0.95);
    background:
        radial-gradient(circle at 50% 20%, rgba(27, 59, 114, 0.05), transparent 55%),
        #fff;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(10, 20, 36, 0.06);
    cursor: zoom-in;
}

.item-modal-hero-media.is-loading-skeleton {
    background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%);
    background-size: 200% 100%;
    animation: item-hero-shimmer 1.2s ease-in-out infinite;
}

.item-modal-hero-media.is-empty {
    background: var(--surface-muted, #f8fafc);
}

.item-modal-hero-img {
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    display: block;
    padding: 0.9rem 1rem;
    transition: opacity 0.2s ease, transform 0.25s ease;
}

.item-modal-hero-media:hover .item-modal-hero-img:not(.is-loading) {
    transform: scale(1.015);
}

.item-modal-hero-img.is-loading {
    opacity: 0.35;
}

.item-modal-hero-zoom {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    width: 2.2rem;
    height: 2.2rem;
    border: none;
    border-radius: 0.7rem;
    background: rgba(10, 20, 36, 0.78);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.item-modal-hero-media:hover .item-modal-hero-zoom,
.item-modal-hero-zoom:focus-visible {
    opacity: 1;
    transform: translateY(0);
}

.item-modal-hero-zoom:hover {
    background: #1B3B72;
}

.item-modal-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.item-modal-chips-only {
    padding: 1rem 1.2rem 0.2rem;
}

.item-modal-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.72rem;
    border-radius: 999px;
    border: 1px solid rgba(217, 225, 236, 0.95);
    background: rgba(230, 238, 249, 0.55);
    font-size: 0.76rem;
}

.item-modal-chip i {
    color: #1B3B72;
    font-size: 0.88rem;
}

.item-modal-chip span {
    color: var(--text-muted);
}

.item-modal-chip strong {
    color: var(--text);
    font-weight: 700;
}

.item-modal-section {
    padding: 0.95rem 1.2rem 0;
}

.item-modal-section + .item-modal-section {
    padding-top: 0.55rem;
}

@keyframes item-hero-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.item-modal-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.item-meta-tile {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 0.7rem 0.8rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.item-meta-tile span {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.item-meta-tile strong {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

.item-modal-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.7rem;
    font-size: 0.86rem;
    font-weight: 800;
    color: #0A1424;
}

.item-modal-section-title i {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 0.55rem;
    display: inline-grid;
    place-items: center;
    font-size: 0.85rem;
    color: #1B3B72;
    background: #E6EEF9;
}

.item-price-grid-premium {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.35rem;
}

.item-price-card-premium {
    position: relative;
    overflow: hidden;
    border-radius: 0.95rem;
    padding: 0.85rem 0.8rem 0.8rem;
    border: 1px solid rgba(217, 225, 236, 0.95);
    background: linear-gradient(180deg, #fff 0%, #F7F9FC 100%);
    box-shadow: 0 6px 18px rgba(10, 20, 36, 0.04);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.item-price-card-premium:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(10, 20, 36, 0.07);
}

.item-price-card-premium::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: var(--price-accent, #1B3B72);
}

.item-price-card-premium small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-weight: 700;
}

.item-price-card-premium strong {
    display: block;
    font-size: 1.02rem;
    font-weight: 900;
    color: #0A1424;
    letter-spacing: 0.01em;
}

.item-price-card-premium.price-wholesale {
    --price-accent: #1B3B72;
    background: linear-gradient(180deg, #fff 0%, #E6EEF9 140%);
}
.item-price-card-premium.price-retail {
    --price-accent: #178F7C;
    background: linear-gradient(180deg, #fff 0%, #D9F4EE 140%);
}
.item-price-card-premium.price-consumer {
    --price-accent: #4338CA;
    background: linear-gradient(180deg, #fff 0%, #EEF2FF 140%);
}
.item-price-card-premium.price-half {
    --price-accent: #D4B45A;
    background: linear-gradient(180deg, #fff 0%, #F8F1DC 140%);
}

.item-breakdown-panel {
    border: 1px solid rgba(217, 225, 236, 0.95);
    border-radius: 1rem;
    overflow: hidden;
    background: #fff;
    margin-bottom: 0.35rem;
    box-shadow: 0 6px 18px rgba(10, 20, 36, 0.04);
}

.item-breakdown-panel.item-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.7rem;
    overflow: visible;
}

.breakdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.8rem;
    border-radius: 0.8rem;
    background: #F7F9FC;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.breakdown-item:hover {
    background: #EEF2F7;
    border-color: rgba(217, 225, 236, 0.9);
}

.breakdown-item-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.breakdown-dept {
    font-size: 0.84rem;
    font-weight: 800;
    color: #0A1424;
}

.breakdown-warehouse {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.breakdown-item-total {
    background: rgba(27, 59, 114, 0.06);
    border-color: rgba(27, 59, 114, 0.1);
}

.breakdown-item .breakdown-qty {
    flex-shrink: 0;
    min-width: 2.35rem;
    justify-content: center;
    border-radius: 999px;
    font-weight: 800;
}

.item-breakdown-panel table {
    margin: 0;
}

.item-breakdown-panel thead th {
    background: var(--surface-muted);
    font-size: 0.78rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.item-modal-card .modal-footer {
    border-top: 1px solid rgba(217, 225, 236, 0.9);
    background: linear-gradient(180deg, #fff 0%, #F7F9FC 100%);
    padding: 0.85rem 1.2rem 1.05rem;
    justify-content: stretch;
}

.item-modal-card .modal-footer .btn {
    border-radius: 0.75rem;
    padding: 0.55rem 1.2rem;
    font-weight: 700;
    min-width: 7.5rem;
}

.item-modal-card .modal-footer .btn-outline-secondary {
    border-color: #D9E1EC;
    color: #243652;
    background: #fff;
}

.item-modal-card .modal-footer .btn-outline-secondary:hover {
    background: #EEF2F7;
    border-color: #C5D0E0;
    color: #0A1424;
}

@media (max-width: 575.98px) {
    .item-modal-header-inner {
        padding: 0.9rem 0.95rem 0.95rem;
        gap: 0.7rem;
    }

    .item-modal-title {
        font-size: 0.98rem;
    }

    .item-modal-qty {
        min-width: 3.9rem;
        padding: 0.45rem 0.55rem;
    }

    .item-modal-qty strong {
        font-size: 1.2rem;
    }

    .item-modal-hero-media {
        min-height: 148px;
        max-height: 200px;
    }

    .item-modal-hero-img {
        max-height: 200px;
        padding: 0.7rem;
    }

    .item-price-grid-premium {
        grid-template-columns: 1fr 1fr;
    }
}
body.theme-dark {
    --surface: #111827; --surface-muted: #0f172a; --text: #e5e7eb; --text-muted: #94a3b8; --border: #334155;
}
body.theme-dark .app-body { background: linear-gradient(180deg, #0b1220 0%, #111827 100%); }
body.theme-dark .app-topbar {
    background: rgba(17, 24, 39, 0.94);
    border-bottom-color: var(--border);
}
body.theme-dark .sidebar-toggle {
    background: rgba(79, 70, 229, 0.18);
    color: #c7d2fe;
}
body.theme-dark .app-topbar-role {
    background: rgba(79, 70, 229, 0.2);
    color: #c7d2fe;
}
body.theme-dark .panel-card,
body.theme-dark .hero-panel,
body.theme-dark .stat-card { background: #111827; color: var(--text); border-color: var(--border); }
body.theme-dark .stat-pill { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.1); }
body.theme-dark .modern-input,
body.theme-dark .form-select,
body.theme-dark .form-control { background: #0f172a; color: var(--text); border-color: var(--border); }
body.theme-dark .inventory-table thead th { background: #1e293b; color: #94a3b8; }
body.theme-dark .inventory-table.table > tbody > tr.inventory-row:nth-child(odd) > td,
body.theme-dark .inventory-table.table > tbody > tr.inventory-row:nth-child(odd) > th { background-color: #0f172a; }
body.theme-dark .inventory-table.table > tbody > tr.inventory-row:nth-child(even) > td,
body.theme-dark .inventory-table.table > tbody > tr.inventory-row:nth-child(even) > th { background-color: #334155; }
body.theme-dark .inventory-table.table > tbody > tr.inventory-row:hover > td,
body.theme-dark .inventory-table.table > tbody > tr.inventory-row:hover > th,
body.theme-dark .inventory-table.table > tbody > tr.inventory-row:nth-child(even):hover > td,
body.theme-dark .inventory-table.table > tbody > tr.inventory-row:nth-child(even):hover > th { background-color: #1e3a5f; }
body.theme-dark .inventory-table tbody tr.inventory-row:nth-child(odd) .sticky-col { background-color: #0f172a; }
body.theme-dark .inventory-table tbody tr.inventory-row:nth-child(even) .sticky-col { background-color: #334155; }
body.theme-dark .inventory-table tbody tr.inventory-row:hover .sticky-col { background-color: #1e3a5f; }
body.theme-dark .price-cell .price-main { color: #34d399; }
body.theme-dark .qty-badge-ok { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.35); }
body.theme-dark .qty-badge-low { background: rgba(249, 115, 22, 0.12); color: #fdba74; border-color: rgba(249, 115, 22, 0.35); }
body.theme-dark .qty-badge-zero { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }
body.theme-dark .cell-image-thumb-btn { background: #0f172a; border-color: var(--border); }
body.theme-dark .empty-state-icon { background: #0f172a; }
body.theme-dark .autocomplete-list { background: #111827; }
body.theme-dark .quick-filter-btn { background: #0f172a; color: var(--text); }
body.theme-dark .modal-content { background: #111827; color: var(--text); }
body.theme-dark .item-modal-card .modal-body { background: linear-gradient(180deg, #0f172a 0%, #111827 55%); }
body.theme-dark .item-modal-hero,
body.theme-dark .item-modal-chips-only { background: transparent; }
body.theme-dark .item-modal-hero-media,
body.theme-dark .item-modal-chip { background: #0f172a; border-color: var(--border); }
body.theme-dark .item-modal-chip { background: rgba(27, 59, 114, 0.25); }
body.theme-dark .item-modal-section-title { color: var(--text); }
body.theme-dark .item-modal-section-title i { background: rgba(79, 70, 229, 0.2); color: #c7d2fe; }
body.theme-dark .item-meta-tile,
body.theme-dark .item-price-card-premium,
body.theme-dark .item-breakdown-panel { background: #0f172a; border-color: var(--border); }
body.theme-dark .item-price-card-premium.price-wholesale,
body.theme-dark .item-price-card-premium.price-retail,
body.theme-dark .item-price-card-premium.price-consumer,
body.theme-dark .item-price-card-premium.price-half { background: #0f172a; }
body.theme-dark .item-price-card-premium strong { color: var(--text); }
body.theme-dark .breakdown-item { background: #111827; }
body.theme-dark .breakdown-item:hover { background: #172032; border-color: var(--border); }
body.theme-dark .breakdown-dept { color: var(--text); }
body.theme-dark .breakdown-item-total { background: rgba(79, 70, 229, 0.12); border-color: rgba(79, 70, 229, 0.2); }
body.theme-dark .item-modal-card .modal-footer { background: #111827; }
body.theme-dark .item-modal-card .modal-footer .btn-outline-secondary {
    background: #0f172a;
    color: var(--text);
    border-color: var(--border);
}
body.theme-dark .sync-info-menu { background: #111827; color: var(--text); border-color: var(--border); }

/* Quotes */
.quote-table th { white-space: nowrap; font-size: 0.85rem; }
.quote-table-wrap,
.quote-lines-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.quote-builder .quote-toggles { padding-top: 0.25rem; }
.quote-lines-table td, .quote-lines-table th { vertical-align: middle; }
.quote-lines-table .form-control-sm { min-width: 4.5rem; }
.quote-suggestions {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 4px);
    z-index: 30;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #dbe3f0);
    border-radius: 0.65rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    max-height: 260px;
    overflow: auto;
}
.quote-suggestion-item {
    display: block;
    width: 100%;
    text-align: right;
    border: 0;
    background: transparent;
    padding: 0.55rem 0.85rem;
    color: inherit;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}
.quote-suggestion-item:hover,
.quote-suggestion-item.active { background: rgba(37, 99, 235, 0.08); }
.quote-totals-bar { background: rgba(248, 250, 252, 0.9); }
.quote-item-search { position: relative; }
.quote-suggestion-zero { color: #b45309; }
.quote-line-stock-zero { background: rgba(254, 226, 226, 0.55) !important; }
.quote-line-stock-low { background: rgba(254, 243, 199, 0.55) !important; }
.quote-line-pending { background: rgba(254, 243, 199, 0.35) !important; }
.quote-pending-badge,
.quote-match-score { font-size: 0.7rem; vertical-align: middle; }
#quoteAiPanel .panel-card-header h2 { font-size: 1.05rem; }
.quote-image-paste-zone {
    position: relative;
    min-height: 6.5rem;
    border: 1.5px dashed var(--border, #cbd5e1);
    border-radius: 0.75rem;
    background: rgba(248, 250, 252, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.quote-image-paste-zone:hover,
.quote-image-paste-zone:focus,
.quote-image-paste-zone.is-dragover {
    border-color: #3b82f6;
    background: rgba(239, 246, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
    outline: none;
}
.quote-image-paste-zone.has-image {
    border-style: solid;
    min-height: 8rem;
}
.quote-image-paste-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    color: #64748b;
    font-size: 0.85rem;
    text-align: center;
    padding: 0.75rem;
}
.quote-image-paste-placeholder i { font-size: 1.4rem; color: #94a3b8; }
.quote-image-paste-zone.has-image .quote-image-paste-placeholder { display: none; }
#specsImagePreview {
    max-width: 100%;
    max-height: 10rem;
    object-fit: contain;
    display: block;
}
body.theme-dark .quote-image-paste-zone {
    background: rgba(15, 23, 42, 0.45);
    border-color: #334155;
}
body.theme-dark .quote-image-paste-zone:hover,
body.theme-dark .quote-image-paste-zone:focus,
body.theme-dark .quote-image-paste-zone.is-dragover {
    background: rgba(30, 58, 138, 0.25);
    border-color: #60a5fa;
}
#specsReviewTable .form-select-sm { min-width: 12rem; }
.quote-stock-cell { font-size: 0.85rem; color: #64748b; }
.quote-manual-price { font-size: 0.7rem; vertical-align: middle; }
.quote-sort-cell .btn { padding: 0.15rem 0.4rem; line-height: 1.1; }
.quote-builder { padding-bottom: 5.5rem; }
.quote-sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 40;
    margin-inline: -0.25rem;
    padding: 0.75rem 0.25rem 0.25rem;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0), rgba(248, 250, 252, 0.95) 28%, #f8fafc 100%);
}
.quote-sticky-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border, #dbe3f0);
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}
.quote-sticky-total { font-size: 1.05rem; }
.quote-sticky-total strong { font-size: 1.2rem; }

.quote-template-preview img {
    max-height: 140px;
    width: auto;
    max-width: 100%;
    background: #f8fafc;
}

/* Chat */
.sidebar-nav .nav-item {
    position: relative;
}
.nav-badge {
    margin-inline-start: auto;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-conversation-item.unread {
    background: rgba(37, 99, 235, 0.06);
}
.chat-room-card {
    display: flex;
    flex-direction: column;
    min-height: min(70vh, 720px);
}
.chat-room-body {
    flex: 1;
    overflow-y: auto;
    max-height: min(58vh, 560px);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 40%);
}
.chat-bubble {
    max-width: min(85%, 34rem);
    padding: 0.7rem 0.9rem;
    border-radius: 0.9rem;
    border: 1px solid var(--border, #e2e8f0);
    background: #fff;
}
.chat-bubble.mine {
    align-self: flex-start;
    background: #eff6ff;
    border-color: #bfdbfe;
}
.chat-bubble.theirs {
    align-self: flex-end;
    background: #fff;
}
.chat-bubble-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: #64748b;
    margin-bottom: 0.35rem;
}
.chat-bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-bubble-status,
.chat-msg-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
}
.chat-msg-status.is-pending,
.chat-msg-status.is-failed {
    color: #94a3b8;
}
.chat-msg-status.is-delivered {
    color: #64748b;
}
.chat-msg-status.is-read {
    color: #0ea5e9;
}
.chat-attachments {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.45rem;
}
.chat-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    text-decoration: none;
}
.chat-composer {
    background: #fff;
}

/* Floating multi-window chat */
.chat-widget-root {
    position: fixed;
    inset-inline-end: 1rem;
    bottom: 1rem;
    z-index: 1080;
    pointer-events: none;
}
.chat-widget-root > * {
    pointer-events: auto;
}
.chat-fab {
    position: relative;
    width: 3.4rem;
    height: 3.4rem;
    border: 0;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-inline-start: auto;
    float: inline-end;
}
.chat-fab:hover { filter: brightness(1.05); }
.chat-fab-badge,
.chat-window-badge {
    position: absolute;
    top: -0.25rem;
    inset-inline-start: -0.15rem;
    min-width: 1.2rem;
    height: 1.2rem;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.3rem;
}
.chat-window-badge {
    position: static;
    margin-inline-start: 0.35rem;
}
.chat-fab-pulse {
    animation: chatFabPulse 0.8s ease 2;
}
@keyframes chatFabPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); box-shadow: 0 0 0 10px rgba(37, 99, 235, 0.15); }
}
body.chat-alert-flash .app-topbar {
    animation: chatTopFlash 0.9s ease;
}
@keyframes chatTopFlash {
    0%, 100% { box-shadow: none; }
    40% { box-shadow: inset 0 -3px 0 #2563eb; }
}

.chat-launcher-panel {
    position: absolute;
    inset-inline-end: 0;
    bottom: 4.2rem;
    width: min(22rem, calc(100vw - 2rem));
    background: #fff;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 1rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}
.chat-launcher-header,
.chat-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.8rem;
    background: #0f172a;
    color: #fff;
}
.chat-launcher-body { padding: 0.85rem; max-height: 22rem; overflow: auto; }
.chat-win-btn {
    border: 0;
    background: rgba(255,255,255,0.12);
    color: #fff;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-recent-list { display: flex; flex-direction: column; gap: 0.35rem; }
.chat-recent-item {
    text-align: right;
    border: 1px solid var(--border, #e2e8f0);
    background: #f8fafc;
    border-radius: 0.65rem;
    padding: 0.55rem 0.7rem;
}
.chat-recent-item:hover { background: #eff6ff; }
.chat-recent-name { display: block; font-weight: 600; }
.chat-recent-preview {
    display: block;
    color: #64748b;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-widget-dock {
    position: absolute;
    inset-inline-end: 0;
    bottom: 4.2rem;
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-end;
    gap: 0.65rem;
    max-width: calc(100vw - 5.5rem);
    overflow-x: auto;
    padding-bottom: 0.15rem;
}
.chat-window {
    width: min(22rem, 86vw);
    background: #fff;
    border: 1px solid var(--border, #dbe3f0);
    border-radius: 0.9rem 0.9rem 0.55rem 0.55rem;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 0 auto;
}
.chat-window.is-minimized .chat-window-body,
.chat-window.is-minimized .chat-window-composer {
    display: none;
}
.chat-window.is-minimized {
    width: 12.5rem;
}
.chat-window-alert .chat-window-header {
    background: #b91c1c;
    animation: chatWinBlink 1s ease infinite;
}
@keyframes chatWinBlink {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.25); }
}
.chat-window-focus {
    outline: 2px solid #2563eb;
}
.chat-window-title {
    display: flex;
    align-items: center;
    min-width: 0;
    font-weight: 600;
}
.chat-window-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-window-actions { display: flex; gap: 0.25rem; }
.chat-window-body {
    height: 18rem;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    background: linear-gradient(180deg, #f8fafc, #fff 45%);
}
.chat-window-composer {
    border-top: 1px solid var(--border, #e2e8f0);
    padding: 0.55rem;
    background: #fff;
}
.chat-window-composer-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.4rem;
}
.chat-attach-label { cursor: pointer; }
.chat-attach-names {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-window .chat-bubble {
    max-width: 92%;
}
@media (max-width: 768px) {
    .chat-widget-dock {
        max-width: calc(100vw - 1rem);
        inset-inline-end: 0;
    }
    .chat-window {
        width: min(20rem, calc(100vw - 1.2rem));
    }
}

/* === Responsive / mobile web === */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.app-body {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-content {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
}

body.has-chat-widget .app-content {
    padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0));
}

/* Sidebar: off-canvas drawer on all screen sizes ? full width for content */

@media (max-width: 768px) {
    .hero-title-compact {
        white-space: normal;
        font-size: 0.92rem;
    }

    .hero-stats-inline {
        width: 100%;
        justify-content: flex-start;
    }

    .filter-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .filter-field-departments,
    .filter-field-grow:not(.filter-field-multi) {
        flex: 1 1 100%;
        min-width: 0;
        max-width: none;
    }

    .filter-field-narrow,
    .filter-field-currency {
        flex: 1 1 calc(50% - 0.25rem);
        max-width: none;
    }

    .inventory-quantity-total {
        margin: 0 0.55rem 0.65rem;
        padding: 0.55rem 0.7rem;
    }

    .hero-panel .hero-content.d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }

    .hero-panel .hero-content.d-flex > .d-flex {
        width: 100%;
    }

    .chat-room-card {
        min-height: calc(100dvh - 11rem);
    }

    .chat-room-body {
        max-height: none;
        min-height: 0;
    }

    .chat-bubble {
        max-width: 92%;
    }

    .chat-bubble-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }

    .item-modal-card {
        margin: 0.5rem;
        max-height: calc(100dvh - 1rem);
    }

    .item-modal-header-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .item-modal-qty {
        align-self: flex-start;
    }

    .quote-lines-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .quote-lines-table {
        min-width: 640px;
    }

    .quote-table-wrap .quote-table {
        min-width: 600px;
    }

    .admin-activity-table {
        min-width: 560px;
    }

    .column-layout-panel {
        width: min(320px, calc(100vw - 1.5rem));
        left: auto;
        inset-inline-end: 0;
    }

    .chat-widget-root {
        inset-inline-end: max(0.65rem, env(safe-area-inset-right, 0));
        bottom: max(0.65rem, env(safe-area-inset-bottom, 0));
    }

    .chat-fab {
        width: 3rem;
        height: 3rem;
        font-size: 1.2rem;
    }

    .chat-launcher-panel {
        width: min(22rem, calc(100vw - 1.3rem));
        bottom: 3.85rem;
    }

    .chat-window-body {
        height: min(18rem, 42dvh);
    }

    .sync-info-menu {
        min-width: 0;
        width: min(18rem, calc(100vw - 1.5rem));
    }

    .app-topbar {
        padding-inline: max(0.75rem, env(safe-area-inset-right, 0)) max(0.75rem, env(safe-area-inset-left, 0));
    }
}

@media (max-width: 576px) {
    .auth-container {
        padding: 1rem;
        padding-top: max(1rem, env(safe-area-inset-top, 0));
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 0));
    }

    .auth-card {
        padding: 1.35rem;
        border-radius: 18px;
    }

    .auth-card-header h1 {
        font-size: 1.25rem;
    }

    .app-topbar-title small {
        display: none;
    }

    .filter-hint {
        display: none;
    }

    .panel-card-header,
    .panel-card-body {
        padding: 0.75rem 0.85rem;
    }

    .pagination-bar {
        padding: 0.75rem 0.85rem;
        gap: 0.65rem;
    }

    .page-size-form {
        flex-wrap: wrap;
    }

    .department-multi-panel {
        max-height: min(52vh, 360px);
    }

    .autocomplete-list {
        max-height: min(360px, 50dvh);
    }

    .chat-window.is-minimized {
        width: min(12.5rem, calc(100vw - 1.5rem));
    }
}

/* Installation module */
.installation-dash-card .panel-card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.installation-mini-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.installation-mini-list li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.installation-mini-list li:last-child {
    border-bottom: 0;
}

.installation-empty-state {
    padding: 1.25rem 1rem;
    color: var(--portal-muted, #8b98ab);
    text-align: center;
}

.installation-status-badge {
    font-size: 0.75rem;
    font-weight: 600;
}

.installation-table th {
    white-space: nowrap;
    font-size: 0.85rem;
}

.installation-table td {
    vertical-align: middle;
}

.installation-team-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.installation-team-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.installation-team-list li:last-child {
    border-bottom: 0;
}

.installation-timeline {
    list-style: none;
    margin: 0;
    padding: 0.75rem 1rem;
}

.installation-timeline li {
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.installation-timeline li:last-child {
    border-bottom: 0;
}

.installation-stage-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: stage;
}

.installation-stage-item {
    counter-increment: stage;
    padding: 0.85rem 0.75rem 0.85rem 2.5rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0.5rem;
    margin-bottom: 0.6rem;
    position: relative;
    background: #fff;
}

.installation-stage-item::before {
    content: counter(stage);
    position: absolute;
    right: 0.65rem;
    top: 0.85rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: #eef1f4;
    color: #445;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.installation-stage-item.is-active {
    border-color: rgba(13, 110, 253, 0.35);
    box-shadow: 0 0 0 1px rgba(13, 110, 253, 0.08);
}

.installation-stage-actions {
    min-width: min(100%, 280px);
}


.installation-issue-card {
    padding: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.installation-issue-lines {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.installation-issue-lines li {
    padding: 0.2rem 0;
}

.installation-material-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

.installation-item-search {
    position: relative;
}

.installation-lines-table input.form-control-sm {
    min-width: 5rem;
}

.installation-form .form-label {
    font-weight: 600;
}

/* Customer portal (Phase 2) */
.customer-portal-body {
    background: linear-gradient(165deg, #0f172a 0%, #1e293b 45%, #334155 100%);
    min-height: 100vh;
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
}

.customer-portal-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.customer-portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    color: #fff;
}

.customer-portal-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.customer-portal-brand i {
    font-size: 1.5rem;
    color: #38bdf8;
}

.customer-portal-brand small {
    display: block;
    opacity: 0.75;
    font-size: 0.75rem;
}

.customer-portal-main {
    flex: 1;
    padding: 0 1rem 1.5rem;
}

.customer-portal-footer {
    text-align: center;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
}

.customer-portal-card {
    background: #fff;
    border-radius: 20px;
    padding: 1.35rem 1.25rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.customer-portal-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
}

.customer-portal-subtitle {
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.customer-portal-alert {
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.customer-portal-btn {
    border-radius: 12px;
    font-weight: 600;
}

.customer-portal-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #64748b;
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.customer-portal-status-banner {
    background: #eef2ff;
    color: #4338ca;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.customer-portal-info-block {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.customer-portal-info-block strong {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.customer-portal-prep {
    background: #fffbeb;
    border-radius: 12px;
    padding: 0.75rem;
    border: 1px solid #fde68a;
}

.customer-portal-section {
    margin-top: 1.25rem;
}

.customer-portal-section h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.customer-portal-slot-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.75rem;
    margin-bottom: 0.65rem;
}

.customer-portal-slot-time {
    font-weight: 600;
}

.customer-portal-project-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.customer-portal-project-item {
    display: block;
    padding: 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    margin-bottom: 0.65rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.customer-portal-project-item:hover {
    border-color: #4f46e5;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

.customer-portal-status {
    display: inline-block;
    font-size: 0.75rem;
    background: #eef2ff;
    color: #4338ca;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-left: 0.35rem;
}

.customer-portal-empty {
    text-align: center;
    color: #94a3b8;
    padding: 2rem 1rem;
}

.customer-portal-rating i {
    color: #f59e0b;
}

.customer-portal-link {
    font-size: 0.85rem;
}

.installation-appointment-form input[type="datetime-local"] {
    font-size: 0.85rem;
}

/* Pro Quote Builder - teal / slate accents */
.quote-confidence-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.65rem;
    padding: 0.55rem 0.85rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #0f172a 0%, #134e4a 55%, #0f766e 100%);
    color: #ecfdf5;
    font-size: 0.82rem;
}
.quote-conf-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(236, 253, 245, 0.14);
    border: 1px solid rgba(45, 212, 191, 0.35);
    color: #99f6e4;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.quote-conf-chip.is-high { border-color: rgba(16, 185, 129, 0.55); color: #a7f3d0; }
.quote-conf-chip.is-mid { border-color: rgba(251, 191, 36, 0.5); color: #fde68a; }
.quote-conf-chip.is-low { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.quote-line-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    flex-shrink: 0;
}
.quote-preflight {
    border: 1px solid #99f6e4;
    background: #f0fdfa;
    border-radius: 14px;
    padding: 0.85rem 1rem;
    color: #134e4a;
}
.quote-preflight.is-warn {
    border-color: #fcd34d;
    background: #fffbeb;
    color: #92400e;
}
.quote-builder-tools {
    border-color: #99f6e4 !important;
    box-shadow: 0 8px 24px rgba(15, 118, 110, 0.08);
}
.quote-kit-card td strong { color: #0f766e; }
.quote-public-body {
    margin: 0;
    min-height: 100vh;
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
    background: linear-gradient(165deg, #0f172a 0%, #1e293b 42%, #134e4a 100%);
    color: #0f172a;
}
.quote-public-shell {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 0 0 1.5rem;
}
.quote-public-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    color: #ecfdf5;
}
.quote-public-header strong { display: block; font-size: 1rem; }
.quote-public-header small { opacity: 0.75; font-size: 0.78rem; }
.quote-public-main { padding: 0 1rem 1rem; }
.quote-public-card {
    background: #fff;
    border-radius: 16px;
    padding: 1rem 1.1rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}
.quote-public-lines th {
    font-size: 0.78rem;
    background: #f0fdfa;
    color: #134e4a;
    white-space: nowrap;
}
.quote-public-lines td { font-size: 0.86rem; vertical-align: top; }
.quote-public-pdf-link {
    color: #99f6e4;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}
.quote-public-pdf-link:hover { color: #ccfbf1; }
body.theme-dark .quote-preflight { background: rgba(15, 118, 110, 0.18); border-color: #115e59; color: #99f6e4; }
body.theme-dark .quote-line-thumb { background: #1e293b; border-color: #334155; }

.btn-teal {
    --bs-btn-color: #fff;
    --bs-btn-bg: #0f766e;
    --bs-btn-border-color: #0f766e;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #0d9488;
    --bs-btn-hover-border-color: #0d9488;
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}
.btn-teal:hover { background: #0d9488; border-color: #0d9488; color: #fff; }
.quote-suggestion-item {
    display: block;
    width: 100%;
    text-align: right;
    border: 0;
    background: transparent;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.quote-suggestion-item:hover { background: rgba(15, 118, 110, 0.08); }
