/* Professional modern ERP theme — Dynamics / Business Central inspired */
:root {
    --erp-primary: #0f6cbd;
    --erp-primary-hover: #115ea3;
    --erp-primary-soft: #ebf3fc;
    --erp-sidebar-bg: #edf3f9;
    --erp-sidebar-hover: #e3ecf6;
    --erp-sidebar-active: #dceaf8;
    --erp-sidebar-text: #1e3a5f;
    --erp-sidebar-muted: #5b7190;
    --erp-rail-width: 48px;
    --erp-rail-expanded: 228px;
    --erp-canvas: #f4f6f8;
    --erp-surface: #ffffff;
    --erp-border: #e5e7eb;
    --erp-border-strong: #d1d5db;
    --erp-text: #111827;
    --erp-text-secondary: #4b5563;
    --erp-text-muted: #6b7280;
    --erp-success: #0e7a3e;
    --erp-success-bg: #e8f5ee;
    --erp-warning: #9a6700;
    --erp-warning-bg: #fff8e6;
    --erp-danger: #c50f1f;
    --erp-danger-bg: #fde7e9;
    --erp-info: #0f6cbd;
    --erp-info-bg: #ebf3fc;
    --erp-shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
    --erp-shadow-md: 0 4px 12px rgba(17, 24, 39, 0.08);
    --erp-radius: 6px;
    --erp-font: "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, sans-serif;
    --fluent-brand: var(--erp-primary);
    --fluent-brand-hover: var(--erp-primary-hover);
    --fluent-brand-light: var(--erp-primary-soft);
    --fluent-bg: var(--erp-canvas);
    --fluent-surface: var(--erp-surface);
    --fluent-border: var(--erp-border);
    --erp-blue: var(--erp-primary);
    --erp-blue-dark: var(--erp-primary-hover);
    --katana-green: var(--erp-primary);
    --katana-canvas: var(--erp-canvas);
}

body.erp-theme {
    font-family: var(--erp-font);
    font-size: 13px;
    color: var(--erp-text);
}

body.erp-theme:not(.login-page) {
    background: var(--erp-canvas);
}

/* Shell */
body.erp-theme .global-bar {
    height: 48px;
    background: var(--erp-surface);
    border-bottom: 1px solid var(--erp-border);
    box-shadow: var(--erp-shadow-sm);
}

body.erp-theme .global-brand {
    width: auto;
    min-width: 0;
    padding: 0 14px;
    gap: 10px;
    color: var(--erp-text);
    background: transparent;
    border-right: none;
}

body.erp-theme .brand-glyph {
    width: 26px;
    height: 26px;
    background: var(--erp-primary);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
}

body.erp-theme .global-brand strong {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

body.erp-theme .global-brand::after {
    content: "Factory ERP";
    margin-left: 6px;
    padding-left: 8px;
    border-left: 1px solid var(--erp-border);
    color: var(--erp-text-muted);
    font-size: 11px;
    font-weight: 400;
}

body.erp-theme .global-search {
    height: 32px;
    background: #f9fafb;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
}

body.erp-theme .global-search:focus-within {
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.15);
    background: #fff;
}

body.erp-theme .global-search input {
    font-size: 13px;
}

body.erp-theme .company-context strong {
    font-size: 12px;
    font-weight: 600;
}

body.erp-theme .global-user .avatar {
    background: var(--erp-primary);
    font-size: 12px;
}

/* Collapsible icon rail */
body.icon-rail-shell.erp-theme .icon-rail {
    top: 48px;
    width: var(--erp-rail-width);
    padding: 6px 0 34px;
    display: flex;
    flex-direction: column;
    color: var(--erp-sidebar-text);
    background: var(--erp-sidebar-bg);
    border-right: 1px solid #d4e2f0;
    box-shadow: none;
    overflow: hidden;
    transition: width 0.2s ease, box-shadow 0.2s ease;
    z-index: 35;
}

body.icon-rail-shell.erp-theme .icon-rail:hover,
body.icon-rail-shell.erp-theme .icon-rail.is-pinned,
body.icon-rail-shell.erp-theme .icon-rail.is-open {
    width: var(--erp-rail-expanded);
    box-shadow: var(--erp-shadow-md);
}

body.icon-rail-shell.erp-theme .icon-rail-head {
    min-height: 36px;
    padding: 4px 8px 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #d4e2f0;
}

body.icon-rail-shell.erp-theme .icon-rail-pin {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--erp-sidebar-muted);
    background: #fff;
    border: 1px solid #d4e2f0;
    border-radius: var(--erp-radius);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

body.icon-rail-shell.erp-theme .icon-rail-pin:hover,
body.icon-rail-shell.erp-theme .icon-rail-pin[aria-pressed="true"] {
    color: var(--erp-primary);
    background: var(--erp-primary-soft);
    border-color: rgba(15, 108, 189, 0.35);
}

body.icon-rail-shell.erp-theme .icon-rail-pin-icon {
    display: inline-block;
    font-size: 14px;
    line-height: 1;
    transition: transform 0.2s ease;
}

body.icon-rail-shell.erp-theme .icon-rail.is-pinned .icon-rail-pin-icon,
body.icon-rail-shell.erp-theme .icon-rail-pin[aria-pressed="true"] .icon-rail-pin-icon {
    transform: rotate(180deg);
}

body.icon-rail-shell.erp-theme .icon-rail-head-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    color: var(--erp-sidebar-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

body.icon-rail-shell.erp-theme .icon-rail:hover .icon-rail-head-label,
body.icon-rail-shell.erp-theme .icon-rail.is-pinned .icon-rail-head-label,
body.icon-rail-shell.erp-theme .icon-rail.is-open .icon-rail-head-label {
    opacity: 1;
    width: auto;
}

body.icon-rail-shell.erp-theme .icon-rail-nav {
    flex: 1;
    padding: 6px 6px 0;
    overflow-x: hidden;
    overflow-y: auto;
}

body.icon-rail-shell.erp-theme .icon-rail-link {
    min-height: 40px;
    margin: 2px 0;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--erp-sidebar-text);
    text-decoration: none;
    border-radius: var(--erp-radius);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

body.icon-rail-shell.erp-theme .icon-rail-link:hover {
    color: var(--erp-primary);
    background: var(--erp-sidebar-hover);
}

body.icon-rail-shell.erp-theme .icon-rail-link.active {
    color: var(--erp-primary);
    background: var(--erp-sidebar-active);
    box-shadow: inset 3px 0 0 var(--erp-primary);
}

body.icon-rail-shell.erp-theme .icon-rail-link-muted {
    color: var(--erp-sidebar-muted);
}

body.icon-rail-shell.erp-theme .icon-rail-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--erp-primary);
    background: #fff;
    border: 1px solid #d4e2f0;
    border-radius: 6px;
    font-size: 14px;
    box-shadow: var(--erp-shadow-sm);
}

body.icon-rail-shell.erp-theme .icon-rail-link.active .icon-rail-icon {
    color: #fff;
    background: var(--erp-primary);
    border-color: var(--erp-primary);
}

body.icon-rail-shell.erp-theme .icon-rail-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

body.icon-rail-shell.erp-theme .icon-rail:hover .icon-rail-text,
body.icon-rail-shell.erp-theme .icon-rail.is-pinned .icon-rail-text,
body.icon-rail-shell.erp-theme .icon-rail.is-open .icon-rail-text {
    opacity: 1;
    width: auto;
}

body.icon-rail-shell.erp-theme .icon-rail-utils {
    padding: 6px 6px 0;
    border-top: 1px solid #d4e2f0;
}

body.icon-rail-shell.erp-theme .icon-rail-status {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 28px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--erp-primary);
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid #d4e2f0;
    backdrop-filter: blur(4px);
}

body.icon-rail-shell.erp-theme .icon-rail-status-dot {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    background: var(--erp-primary);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
}

body.icon-rail-shell.erp-theme .icon-rail-status-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

body.icon-rail-shell.erp-theme .icon-rail:hover .icon-rail-status-label,
body.icon-rail-shell.erp-theme .icon-rail.is-pinned .icon-rail-status-label,
body.icon-rail-shell.erp-theme .icon-rail.is-open .icon-rail-status-label {
    opacity: 1;
    width: auto;
}

body.icon-rail-shell.erp-theme .main-shell {
    width: calc(100% - var(--erp-rail-width));
    margin-left: var(--erp-rail-width);
    min-height: calc(100vh - 48px);
    transition: margin-left 0.2s ease, width 0.2s ease;
}

body.icon-rail-shell.rail-pinned.erp-theme .main-shell {
    width: calc(100% - var(--erp-rail-expanded));
    margin-left: var(--erp-rail-expanded);
}

body.icon-rail-shell.erp-theme .content,
body.icon-rail-shell.erp-theme .content-gi {
    padding-bottom: 44px;
}

/* Legacy full sidebar (fallback) */
body.erp-theme:not(.icon-rail-shell) .sidebar {
    width: 240px;
    padding: 10px 8px 56px;
    background: var(--erp-sidebar-bg);
    border-right: 1px solid #d4e2f0;
    box-shadow: none;
}

body.erp-theme:not(.icon-rail-shell) .main-shell {
    width: calc(100% - 240px);
    margin-left: 240px;
}

body.erp-theme .nav-label {
    padding: 10px 12px 6px;
    color: var(--erp-sidebar-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

body.erp-theme:not(.icon-rail-shell) .nav a,
body.erp-theme:not(.icon-rail-shell) .sidebar-footer a {
    min-height: 38px;
    margin: 1px 0;
    padding: 0 12px;
    color: var(--erp-sidebar-text);
    border-radius: var(--erp-radius);
    font-size: 13px;
    font-weight: 400;
}

body.erp-theme:not(.icon-rail-shell) .nav a:hover,
body.erp-theme:not(.icon-rail-shell) .sidebar-footer a:hover {
    color: var(--erp-primary);
    background: var(--erp-sidebar-hover);
}

body.erp-theme:not(.icon-rail-shell) .nav a.active {
    color: var(--erp-primary);
    background: var(--erp-sidebar-active);
    box-shadow: inset 3px 0 0 var(--erp-primary);
}

body.erp-theme:not(.icon-rail-shell) .nav-icon {
    width: 18px;
    color: var(--erp-sidebar-muted);
    font-size: 14px;
    opacity: 0.9;
}

body.erp-theme:not(.icon-rail-shell) .nav a.active .nav-icon {
    color: var(--erp-primary);
}

body.erp-theme:not(.icon-rail-shell) .sidebar-footer {
    background: transparent;
    border-top: 1px solid #d4e2f0;
}

/* Page chrome */
body.erp-theme .topbar {
    min-height: 52px;
    padding: 10px 24px;
    background: var(--erp-surface);
    border-bottom: 1px solid var(--erp-border);
}

body.erp-theme .topbar h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--erp-text);
}

body.erp-theme .breadcrumb {
    font-size: 11px;
    color: var(--erp-text-muted);
    letter-spacing: 0.01em;
}

body.erp-theme .content,
body.erp-theme .content-gi {
    padding: 16px 24px 36px;
}

body.erp-theme .footer,
body.erp-theme .status-footer {
    position: fixed;
    z-index: 60;
    inset: auto 0 0 0;
    height: 24px;
    padding: 0 14px 0 calc(var(--erp-rail-width) + 12px);
    display: flex;
    align-items: center;
    gap: 14px;
    color: #3d5a80;
    background: linear-gradient(180deg, #eef5fc 0%, #e3eef9 100%);
    border-top: 1px solid #c5daf0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
    font-size: 10px;
    line-height: 1;
}

body.erp-theme .status-footer::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--erp-primary) 18%, #5eb3ff 50%, var(--erp-primary) 82%, transparent 100%);
    opacity: 0.55;
}

body.icon-rail-shell.rail-pinned.erp-theme .status-footer,
body.icon-rail-shell.rail-pinned.erp-theme .footer {
    padding-left: calc(var(--erp-rail-expanded) + 12px);
}

body.erp-theme .status-footer-active {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--erp-text-secondary);
}

body.erp-theme .status-footer-active strong {
    overflow: hidden;
    color: var(--erp-text);
    font-size: 10px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.erp-theme .status-dot {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    background: var(--erp-primary);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.18);
}

body.erp-theme .status-footer-center {
    margin: 0 auto;
    overflow: hidden;
    color: #4a6585;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.erp-theme .status-footer-credit {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    color: #2f557d;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(15, 108, 189, 0.14);
    border-radius: 999px;
    font-size: 9px;
    letter-spacing: 0.02em;
}

body.erp-theme .status-footer-credit strong {
    color: var(--erp-primary);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

body.erp-theme .status-footer-role {
    flex-shrink: 0;
    color: #2f557d;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Workspace headers */
body.erp-theme .workspace-title,
body.erp-theme .module-heading {
    margin-bottom: 14px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--erp-border);
}

body.erp-theme .workspace-title h2 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
    color: var(--erp-text);
}

body.erp-theme .workspace-title p,
body.erp-theme .module-heading p {
    margin: 0;
    font-size: 12px;
    color: var(--erp-text-muted);
}

body.erp-theme .section-caption {
    height: auto;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--erp-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

body.erp-theme .section-caption div {
    background: var(--erp-border);
}

body.erp-theme .section-caption a {
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
}

/* Exception / alert tiles — corporate, not rainbow */
body.erp-theme .exception-grid {
    gap: 10px;
}

body.erp-theme .exception-tile {
    min-height: 76px;
    padding: 12px 14px 12px 16px;
    color: var(--erp-text);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    position: relative;
    overflow: hidden;
}

body.erp-theme .exception-tile::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--erp-primary);
}

body.erp-theme .exception-tile.tile-amber::before { background: #d97706; }
body.erp-theme .exception-tile.tile-green::before { background: var(--erp-success); }
body.erp-theme .exception-tile.tile-red::before { background: var(--erp-danger); }
body.erp-theme .exception-tile.tile-blue::before { background: var(--erp-primary); }
body.erp-theme .exception-tile.tile-purple::before { background: #6b4c9a; }

body.erp-theme .exception-tile .tile-icon {
    display: none;
}

body.erp-theme .exception-tile strong {
    justify-self: start;
    font-size: 22px;
    font-weight: 600;
    color: var(--erp-text);
    line-height: 1.1;
}

body.erp-theme .exception-tile small {
    grid-column: 1;
    justify-self: start;
    margin-top: 4px;
    color: var(--erp-text-muted);
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

body.erp-theme .exception-tile:hover {
    border-color: var(--erp-border-strong);
    box-shadow: var(--erp-shadow-md);
}

/* Analytics widgets */
body.erp-theme .analytics-grid,
body.erp-theme .bottom-workspace {
    gap: 12px;
}

body.erp-theme .erp-widget,
body.erp-theme .erp-grid-panel,
body.erp-theme .panel,
body.erp-theme .data-panel {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
}

body.erp-theme .widget-title {
    min-height: 40px;
    padding: 10px 14px;
    color: var(--erp-text);
    background: #f9fafb;
    border-bottom: 1px solid var(--erp-border);
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
}

body.erp-theme .widget-title a {
    font-size: 12px;
    font-weight: 500;
}

body.erp-theme .big-number {
    padding: 16px 14px;
    background: #f9fafb;
    border-bottom: 1px solid var(--erp-border);
}

body.erp-theme .big-number strong {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

body.erp-theme .big-number span {
    font-size: 11px;
    text-transform: none;
    color: var(--erp-text-muted);
}

body.erp-theme .donut {
    background: conic-gradient(
        var(--erp-primary) 0 var(--a),
        #10b981 var(--a) var(--b),
        #d1d5db var(--b) 100%
    );
}

body.erp-theme .hbar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

body.erp-theme .hbar span {
    background: var(--erp-primary);
    border-radius: 4px;
}

body.erp-theme .horizontal-bars > div:nth-child(2) .hbar span {
    background: #10b981;
}

body.erp-theme .horizontal-bars > div:nth-child(3) .hbar span {
    background: #f59e0b;
}

body.erp-theme .spark-bars span {
    background: var(--erp-primary);
    border-radius: 2px 2px 0 0;
    opacity: 0.85;
}

body.erp-theme .legend-blue { background: var(--erp-primary); }
body.erp-theme .legend-green { background: #10b981; }
body.erp-theme .legend-amber { background: #f59e0b; }

/* KPI / overview blocks — flat enterprise metrics */
body.erp-theme .inventory-hero-card,
body.erp-theme .sales-hero-card,
body.erp-theme .customer-hero-card,
body.erp-theme .product-hero-card,
body.erp-theme .payment-kpi-primary {
    color: var(--erp-text);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-left: 4px solid var(--erp-primary);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
}

body.erp-theme .inventory-hero-glyph,
body.erp-theme .sales-hero-glyph,
body.erp-theme .customer-hero-glyph,
body.erp-theme .product-hero-glyph {
    display: none;
}

body.erp-theme .inventory-card-label,
body.erp-theme .sales-card-label,
body.erp-theme .customer-card-label,
body.erp-theme .product-card-label {
    color: var(--erp-text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
}

body.erp-theme .inventory-hero-card strong,
body.erp-theme .sales-hero-card strong,
body.erp-theme .customer-hero-card strong,
body.erp-theme .product-hero-card strong {
    font-size: 20px;
    font-weight: 600;
    color: var(--erp-text);
}

body.erp-theme .inventory-hero-card p,
body.erp-theme .sales-hero-card p,
body.erp-theme .customer-hero-card p,
body.erp-theme .product-hero-card p {
    color: var(--erp-text-muted);
    font-size: 12px;
    line-height: 1.45;
}

body.erp-theme .inventory-stat-card,
body.erp-theme .sales-stat-card,
body.erp-theme .customer-stat-card,
body.erp-theme .product-stat-card,
body.erp-theme .payment-kpi,
body.erp-theme .reject-kpi,
body.erp-theme .production-kpis article {
    border: 1px solid var(--erp-border);
    border-top: 3px solid var(--erp-primary);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
}

body.erp-theme .inventory-stat-card span,
body.erp-theme .sales-stat-card span,
body.erp-theme .payment-kpi span,
body.erp-theme .production-kpis span {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--erp-text-muted);
}

body.erp-theme .inventory-stat-card strong,
body.erp-theme .sales-stat-card strong,
body.erp-theme .payment-kpi strong,
body.erp-theme .production-kpis strong {
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

body.erp-theme .payment-kpi-primary {
    background: var(--erp-surface);
    border-top-color: var(--erp-primary);
}

body.erp-theme .payment-kpi-primary strong,
body.erp-theme .payment-kpi-primary span,
body.erp-theme .payment-kpi-primary small {
    color: inherit;
}

body.erp-theme .inventory-insight-bar,
body.erp-theme .sales-insight-bar,
body.erp-theme .payments-callout,
body.erp-theme .customer-recent-panel,
body.erp-theme .forecast-panel {
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    background: var(--erp-surface);
}

body.erp-theme .payments-callout {
    border-left: 4px solid var(--erp-primary);
}

body.erp-theme .cashier-close {
    background: var(--erp-surface);
    border-color: var(--erp-border);
    border-radius: 0.25rem;
    box-shadow: var(--erp-shadow-sm);
}

body.erp-theme .cashier-close-summary article {
    background: #f9fbfd;
    border-color: var(--erp-border);
}

body.erp-theme .cashier-close-table thead th,
body.erp-theme .cashier-close-receipts-table th {
    background: #f1f5f9;
    border-color: var(--erp-border);
    color: var(--erp-text-muted);
}

body.erp-theme .cashier-close-variance-ok {
    color: var(--erp-success) !important;
}

body.erp-theme .cashier-close-variance-warn {
    color: var(--erp-warning) !important;
}

/* Production stepper */
body.erp-theme .production-flow-strip {
    padding: 10px 14px;
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
}

body.erp-theme .production-flow-strip div {
    font-size: 10px;
    color: var(--erp-text-muted);
}

body.erp-theme .production-flow-strip b {
    width: 22px;
    height: 22px;
    background: #e5e7eb;
    color: var(--erp-text-secondary);
    font-size: 10px;
    font-weight: 600;
}

body.erp-theme .production-flow-strip div:last-child b,
body.erp-theme .production-flow-strip div:nth-child(4) b {
    background: var(--erp-primary);
    color: #fff;
}

/* Data tables */
body.erp-theme .data-panel table th,
body.erp-theme .erp-grid-panel table th {
    height: 34px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--erp-text-secondary);
    background: #f3f4f6;
    border-bottom: 1px solid var(--erp-border-strong);
    white-space: nowrap;
}

body.erp-theme .data-panel table td,
body.erp-theme .erp-grid-panel table td {
    height: 38px;
    padding: 6px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--erp-border);
    vertical-align: middle;
}

body.erp-theme .data-panel table td:nth-child(n+4),
body.erp-theme .erp-grid-panel table td:nth-child(n+5) {
    font-variant-numeric: tabular-nums;
}

body.erp-theme .data-panel tbody tr:hover {
    background: #f9fafb;
}

body.erp-theme .grid-progress {
    width: 72px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    vertical-align: middle;
}

body.erp-theme .grid-progress span {
    background: var(--erp-primary);
    border-radius: 3px;
}

body.erp-theme .grid-link,
body.erp-theme .table-action {
    color: var(--erp-primary);
    font-weight: 500;
    text-decoration: none;
}

body.erp-theme .grid-link:hover,
body.erp-theme .table-action:hover {
    text-decoration: underline;
}

/* Command bar & tabs */
body.erp-theme .record-command-bar {
    padding: 8px 12px;
    background: #f9fafb;
    border-bottom: 1px solid var(--erp-border);
}

body.erp-theme .view-selector a {
    height: 34px;
    font-size: 13px;
    color: var(--erp-text-secondary);
}

body.erp-theme .view-selector a.active {
    color: var(--erp-primary);
    font-weight: 600;
}

body.erp-theme .table-toolbar {
    padding-bottom: 0;
    border-bottom: 1px solid var(--erp-border);
    background: var(--erp-surface);
}

body.erp-theme .toolbar-report-link {
    font-size: 12px;
    border-color: var(--erp-border);
}

body.erp-theme .module-view-tabs a {
    font-size: 13px;
    font-weight: 500;
}

/* Buttons */
body.erp-theme .button,
body.erp-theme .command-primary,
body.erp-theme .quick-action-button {
    min-height: 32px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--erp-radius);
}

body.erp-theme .button-primary,
body.erp-theme .command-primary {
    background: var(--erp-primary);
    border-color: var(--erp-primary);
}

body.erp-theme .button-primary:hover,
body.erp-theme .command-primary:hover {
    background: var(--erp-primary-hover);
    border-color: var(--erp-primary-hover);
}

/* Badges */
body.erp-theme .badge {
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
}

body.erp-theme .badge-success {
    color: var(--erp-success);
    background: var(--erp-success-bg);
}

body.erp-theme .badge-warning {
    color: var(--erp-warning);
    background: var(--erp-warning-bg);
}

body.erp-theme .badge-danger,
body.erp-theme .badge-error {
    color: var(--erp-danger);
    background: var(--erp-danger-bg);
}

body.erp-theme .badge-info,
body.erp-theme .badge-primary {
    color: var(--erp-info);
    background: var(--erp-info-bg);
}

/* Quick actions */
body.erp-theme .quick-grid a {
    min-height: 64px;
    padding: 12px 14px;
    color: var(--erp-text);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--erp-shadow-sm);
}

body.erp-theme .quick-grid a:hover {
    color: var(--erp-primary);
    background: var(--erp-primary-soft);
    border-color: #bfdbfe;
    transform: none;
}

body.erp-theme .quick-grid span {
    width: 28px;
    height: 28px;
    color: var(--erp-primary);
    background: var(--erp-primary-soft);
    border-radius: 6px;
    box-shadow: none;
    font-size: 13px;
}

body.erp-theme .transaction-grid {
    padding: 12px;
    gap: 10px;
}

body.erp-theme .transaction-grid a {
    min-height: 56px;
    padding: 10px 12px;
    color: var(--erp-text);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--erp-shadow-sm);
}

body.erp-theme .transaction-grid a:hover {
    color: var(--erp-primary);
    background: var(--erp-primary-soft);
    border-color: #bfdbfe;
}

body.erp-theme .transaction-grid b {
    width: 28px;
    height: 28px;
    color: #fff;
    background: var(--erp-primary);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

/* Compact lists */
body.erp-theme .compact-list > div {
    border-bottom: 1px solid var(--erp-border);
    font-size: 13px;
}

/* Modals */
body.erp-theme .modal-card,
body.erp-theme .product-detail-card {
    border-radius: 8px;
    box-shadow: var(--erp-shadow-md);
}

body.erp-theme .entry-command-bar {
    background: #f9fafb;
    border-bottom: 1px solid var(--erp-border);
}

body.erp-theme .modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

body.erp-theme .form-grid input,
body.erp-theme .form-grid select,
body.erp-theme .form-grid textarea {
    border-radius: var(--erp-radius);
    border-color: var(--erp-border-strong);
    font-size: 13px;
}

/* Login */
body.erp-theme.login-page .login-story {
    background: linear-gradient(165deg, #111827 0%, #1f2937 40%, #0f6cbd 100%);
}

body.erp-theme .login-card h2 {
    font-size: 22px;
    font-weight: 600;
}

body.erp-theme .login-card .subtle {
    color: var(--erp-text-muted);
}

@media (max-width: 900px) {
    body.icon-rail-shell.erp-theme .icon-rail {
        transform: translateX(-100%);
        width: var(--erp-rail-expanded);
        transition: transform 0.25s ease, box-shadow 0.25s ease;
    }

    body.icon-rail-shell.erp-theme .icon-rail.is-open {
        transform: translateX(0);
        box-shadow: var(--erp-shadow-md);
    }

    body.icon-rail-shell.erp-theme .icon-rail .icon-rail-text,
    body.icon-rail-shell.erp-theme .icon-rail .icon-rail-head-label,
    body.icon-rail-shell.erp-theme .icon-rail .icon-rail-status-label {
        opacity: 1;
        width: auto;
    }

    body.icon-rail-shell.erp-theme .main-shell,
    body.icon-rail-shell.rail-pinned.erp-theme .main-shell {
        width: 100%;
        margin-left: 0;
    }

    body.icon-rail-shell.erp-theme .status-footer,
    body.icon-rail-shell.rail-pinned.erp-theme .status-footer {
        padding-left: 12px;
        gap: 8px;
    }

    body.erp-theme .status-footer-credit {
        display: none;
    }

    body.erp-theme .menu-toggle {
        width: 40px;
        height: 40px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--erp-text);
        background: transparent;
        border: 0;
        border-right: 1px solid var(--erp-border);
        cursor: pointer;
    }

    body.erp-theme .menu-toggle span {
        width: 16px;
        height: 2px;
        background: currentColor;
    }

    body.erp-theme .global-brand::after {
        display: none;
    }
}

/* Beat legacy app.css sidebar/katana overrides */
body.icon-rail-shell.erp-theme aside.icon-rail {
    position: fixed;
    inset: 48px auto 0 0;
    width: var(--erp-rail-width);
    padding: 6px 0 34px;
    color: var(--erp-sidebar-text);
    background: var(--erp-sidebar-bg);
    border-right: 1px solid #d4e2f0;
    box-shadow: none;
}

body.icon-rail-shell.erp-theme aside.icon-rail:hover,
body.icon-rail-shell.erp-theme aside.icon-rail.is-pinned,
body.icon-rail-shell.erp-theme aside.icon-rail.is-open {
    width: var(--erp-rail-expanded);
    box-shadow: var(--erp-shadow-md);
}

/* Reports: department workspace uses single-column body (no inquiry tree) */
body.erp-theme .gi-body.gi-body-single {
    grid-template-columns: minmax(0, 1fr);
}

body.erp-theme .gi-body.gi-body-single .gi-main {
    width: 100%;
    min-width: 0;
}

body.erp-theme .gi-report-tabs-toolbar {
    border-bottom-color: var(--erp-border);
}

body.erp-theme .gi-report-tab {
    color: var(--erp-text-secondary);
    background: var(--erp-surface);
    border-color: var(--erp-border);
    border-radius: var(--erp-radius);
    font-size: 12px;
}

body.erp-theme .gi-report-tab:hover {
    color: var(--erp-primary);
    background: var(--erp-primary-soft);
    border-color: rgba(15, 108, 189, 0.35);
}

body.erp-theme .gi-report-tab.is-active {
    color: #fff;
    background: var(--erp-primary);
    border-color: var(--erp-primary);
}

body.erp-theme .gi-report-tab:not(.is-active) .gi-report-tab-count {
    color: var(--erp-text-muted);
    background: #eef2f7;
}

body.erp-theme .gi-report-tab-filter input {
    border-color: var(--erp-border);
    border-radius: var(--erp-radius);
    font-size: 12px;
}

body.erp-theme .gi-report-tab-panel .gi-grid-wrap {
    max-height: min(58vh, 680px);
}

/* Shared workspace polish */
body.erp-theme .topbar {
    min-height: 64px;
    padding-block: 10px;
    background: #fff;
    border-bottom: 1px solid var(--erp-border);
}

body.erp-theme .topbar h1 {
    margin-top: 2px;
    font-size: 20px;
    line-height: 1.2;
    letter-spacing: 0;
}

body.erp-theme .breadcrumb {
    color: var(--erp-text-muted);
    font-size: 10px;
    letter-spacing: 0;
}

body.erp-theme .record-command-bar,
body.erp-theme .table-toolbar {
    min-height: 48px;
    padding: 7px 12px;
    gap: 8px;
    background: #fff;
}

body.erp-theme .toolbar-right {
    min-width: 0;
    gap: 6px;
}

body.erp-theme .search-box {
    min-width: 210px;
    height: 34px;
    border: 1px solid var(--erp-border-strong);
    border-radius: 5px;
    background: #fff;
}

body.erp-theme .search-box:focus-within {
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.12);
}

body.erp-theme .data-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

body.erp-theme .data-tool-menu {
    position: relative;
}

body.erp-theme .data-tool-menu > summary {
    list-style: none;
}

body.erp-theme .data-tool-menu > summary::-webkit-details-marker {
    display: none;
}

body.erp-theme .data-tool-button {
    height: 34px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--erp-text-secondary);
    background: #fff;
    border: 1px solid var(--erp-border-strong);
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

body.erp-theme .data-tool-button:hover,
body.erp-theme .data-tool-menu[open] .data-tool-button {
    color: var(--erp-primary);
    background: var(--erp-primary-soft);
    border-color: rgba(15, 108, 189, 0.4);
}

body.erp-theme .data-tool-button span:first-child {
    width: 15px;
    text-align: center;
    font-size: 14px;
}

body.erp-theme .data-tool-popover {
    position: absolute;
    z-index: 80;
    top: calc(100% + 7px);
    right: 0;
    width: 250px;
    padding: 14px;
    display: grid;
    gap: 9px;
    color: var(--erp-text);
    background: #fff;
    border: 1px solid var(--erp-border);
    border-radius: 6px;
    box-shadow: 0 14px 35px rgba(16, 36, 63, 0.16);
}

body.erp-theme .data-tool-popover > strong {
    font-size: 12px;
}

body.erp-theme .data-tool-help,
body.erp-theme .saved-view-empty {
    color: var(--erp-text-muted);
    font-size: 10px;
    line-height: 1.4;
}

body.erp-theme .saved-view-create {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
}

body.erp-theme .saved-view-create input {
    min-width: 0;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--erp-border-strong);
    border-radius: 4px;
    font-size: 11px;
}

body.erp-theme .saved-view-create button,
body.erp-theme .data-tool-popover > button,
body.erp-theme .bulk-action-bar button,
body.erp-theme .polished-empty-state button {
    min-height: 32px;
    padding: 0 10px;
    color: var(--erp-primary);
    background: #fff;
    border: 1px solid rgba(15, 108, 189, 0.35);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
}

body.erp-theme .saved-view-create button:hover,
body.erp-theme .data-tool-popover > button:hover,
body.erp-theme .bulk-action-bar button:hover,
body.erp-theme .polished-empty-state button:hover {
    background: var(--erp-primary-soft);
}

body.erp-theme .saved-view-list {
    display: grid;
    gap: 4px;
}

body.erp-theme .saved-view-list > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px;
    border: 1px solid var(--erp-border);
    border-radius: 4px;
    overflow: hidden;
}

body.erp-theme .saved-view-list button {
    min-height: 32px;
    padding: 0 9px;
    color: var(--erp-text-secondary);
    background: #fff;
    border: 0;
    text-align: left;
    font-size: 10px;
    cursor: pointer;
}

body.erp-theme .saved-view-list .saved-view-remove {
    padding: 0;
    color: #9b3f3f;
    border-left: 1px solid var(--erp-border);
    text-align: center;
    font-size: 16px;
}

body.erp-theme .column-choice-list {
    max-height: 280px;
    display: grid;
    overflow: auto;
}

body.erp-theme .column-choice-list label {
    min-height: 32px;
    padding: 5px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--erp-text-secondary);
    border-bottom: 1px solid #eef2f5;
    font-size: 10px;
    cursor: pointer;
}

body.erp-theme .column-choice-list input,
body.erp-theme .bulk-select-cell input {
    width: 15px;
    height: 15px;
    accent-color: var(--erp-primary);
}

body.erp-theme .bulk-select-cell {
    width: 38px;
    min-width: 38px;
    padding-inline: 10px !important;
    text-align: center;
}

body.erp-theme .bulk-action-bar {
    min-height: 43px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 7px;
    color: #17466b;
    background: #edf6fc;
    border-bottom: 1px solid #c7dfef;
}

body.erp-theme .bulk-action-bar[hidden] {
    display: none;
}

body.erp-theme .bulk-action-bar strong {
    margin-right: auto;
    font-size: 11px;
}

body.erp-theme .column-hidden {
    display: none !important;
}

body.erp-theme .polished-empty-state {
    padding: 48px 20px !important;
    background: #fbfcfd;
}

body.erp-theme .polished-empty-state strong,
body.erp-theme .polished-empty-state span {
    display: block;
}

body.erp-theme .polished-empty-state strong {
    margin-bottom: 5px;
    color: var(--erp-text);
    font-size: 13px;
}

body.erp-theme .polished-empty-state span {
    margin-bottom: 13px;
    color: var(--erp-text-muted);
    font-size: 10px;
}

body.erp-theme .badge {
    gap: 5px;
    border: 1px solid transparent;
    letter-spacing: 0;
}

body.erp-theme .badge::before {
    width: 5px;
    height: 5px;
    flex: 0 0 5px;
    background: currentColor;
    border-radius: 50%;
    content: "";
    opacity: 0.75;
}

body.erp-theme button:disabled,
body.erp-theme .button:disabled,
body.erp-theme [aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.55;
}

body.erp-theme button.is-loading {
    position: relative;
    pointer-events: none;
}

body.erp-theme button.is-loading::before {
    width: 12px;
    height: 12px;
    margin-right: 7px;
    display: inline-block;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -2px;
    content: "";
    animation: erp-spin 0.7s linear infinite;
}

.page-progress {
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: #0f6cbd;
    opacity: 0;
    pointer-events: none;
}

body.is-page-loading .page-progress {
    width: 72%;
    opacity: 1;
    transition: width 7s cubic-bezier(.1,.7,.1,1), opacity .15s ease;
}

@keyframes erp-spin {
    to { transform: rotate(360deg); }
}

/* Entry workflows use a focused drawer while retaining existing step tabs. */
body.erp-theme [data-entry-modal] {
    padding: 0;
    align-items: stretch;
    justify-content: flex-end;
}

body.erp-theme [data-entry-modal] .modal-card {
    width: min(760px, calc(100vw - 72px));
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    border: 0;
    border-left: 1px solid var(--erp-border);
    border-radius: 0;
    box-shadow: -16px 0 45px rgba(16, 36, 63, 0.18);
    overflow: hidden;
    transform: translateX(24px);
    transition: transform 0.2s ease;
}

body.erp-theme [data-entry-modal].is-open .modal-card {
    transform: translateX(0);
}

body.erp-theme [data-entry-modal] #entry-form {
    min-height: 0;
    overflow: auto;
}

body.erp-theme [data-entry-modal] .dialog-footer {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    background: #fff;
    border-top: 1px solid var(--erp-border);
    box-shadow: 0 -8px 22px rgba(16, 36, 63, 0.06);
}

@media (max-width: 760px) {
    body.erp-theme .topbar {
        min-height: 58px;
    }

    body.erp-theme .topbar h1 {
        font-size: 18px;
    }

    body.erp-theme .record-command-bar,
    body.erp-theme .table-toolbar,
    body.erp-theme .toolbar-right {
        height: auto;
        align-items: stretch;
        flex-wrap: wrap;
    }

    body.erp-theme .toolbar-right {
        width: 100%;
        margin-left: 0;
    }

    body.erp-theme .search-box {
        min-width: 0;
        flex: 1 1 180px;
    }

    body.erp-theme .data-tools {
        flex: 0 0 auto;
    }

    body.erp-theme .data-tool-button {
        width: 34px;
        padding: 0;
        justify-content: center;
    }

    body.erp-theme .data-tool-button span:last-child {
        display: none;
    }

    body.erp-theme .data-tool-popover {
        position: fixed;
        z-index: 140;
        top: 96px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100dvh - 130px);
        overflow: auto;
    }

    body.erp-theme .table-wrap {
        overflow: visible;
        background: #f4f7f9;
    }

    /* .sales-line-table is rendered by JS and has no data-label markup,
       so it never converts to the card layout below — keep it a real
       scrollable table instead of losing overflow handling entirely. */
    body.erp-theme .sales-line-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        background: #fff;
    }

    body.erp-theme .sales-line-table {
        min-width: 560px;
    }

    body.erp-theme .sales-line-table th,
    body.erp-theme .sales-line-table td {
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    body.erp-theme .sales-line-table td small {
        white-space: normal;
    }

    body.erp-theme table[data-table],
    body.erp-theme table[data-table] tbody {
        width: 100%;
        display: block;
    }

    body.erp-theme table[data-table] thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    body.erp-theme table[data-table] tbody tr {
        margin: 8px;
        padding: 6px 12px;
        display: block;
        background: #fff;
        border: 1px solid var(--erp-border);
        border-radius: 6px;
        box-shadow: 0 1px 2px rgba(16, 36, 63, 0.04);
    }

    body.erp-theme table[data-table] tbody tr[hidden] {
        display: none !important;
    }

    body.erp-theme table[data-table] tbody td {
        min-height: 35px;
        padding: 8px 0 !important;
        display: grid;
        grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        border: 0;
        border-bottom: 1px solid #edf1f4;
        text-align: left;
        white-space: normal;
    }

    body.erp-theme table[data-table] tbody td:last-child {
        border-bottom: 0;
    }

    body.erp-theme table[data-table] tbody td::before {
        color: var(--erp-text-muted);
        content: attr(data-label);
        font-size: 9px;
        font-weight: 700;
        line-height: 1.4;
        text-transform: uppercase;
        letter-spacing: 0;
        grid-column: 1;
        grid-row: 1 / -1;
        align-self: start;
    }

    body.erp-theme table[data-table] tbody td > * {
        grid-column: 2;
    }

    body.erp-theme table[data-table] tbody td.bulk-select-cell {
        width: auto;
        min-width: 0;
        display: block;
        border-bottom: 0;
        text-align: right;
    }

    body.erp-theme table[data-table] tbody td.bulk-select-cell::before {
        display: none;
    }

    body.erp-theme table[data-table] .cell-sub {
        white-space: normal;
    }

    body.erp-theme .bulk-action-bar {
        position: sticky;
        z-index: 20;
        top: 48px;
        flex-wrap: wrap;
    }

    body.erp-theme [data-entry-modal] .modal-card {
        width: 100vw;
        border-left: 0;
    }

    body.erp-theme [data-entry-modal] .modal-header-meta,
    body.erp-theme [data-entry-modal] .entry-shortcut-hint {
        display: none;
    }
}

/* ============================================================
   Native-app polish for mobile [data-table] cards (≤760px).
   Purely additive on top of the label/grid fix above — turns the
   generic key-value stack into something closer to a Material
   list-item / card component: elevation, status accent, chips,
   a Material-style linear progress bar, and tonal action buttons.
   ============================================================ */
@media (max-width: 760px) {

    /* Card shell: soft elevation + rounded shape instead of a flat border */
    body.erp-theme table[data-table] tbody tr {
        margin: 10px 12px;
        padding: 14px 16px 14px 20px;
        border: 0;
        border-radius: 16px;
        box-shadow: var(--erp-shadow-sm);
        position: relative;
        overflow: hidden;
        transition: box-shadow 0.15s ease, transform 0.1s ease;
        -webkit-tap-highlight-color: transparent;
    }

    /* Status accent stripe, colour-matched to whichever badge the card contains */
    body.erp-theme table[data-table] tbody tr::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 4px;
        background: var(--erp-border-strong);
    }
    body.erp-theme table[data-table] tbody tr:has(.badge-success)::after { background: var(--erp-success); }
    body.erp-theme table[data-table] tbody tr:has(.badge-warning)::after { background: var(--erp-warning); }
    body.erp-theme table[data-table] tbody tr:has(.badge-danger)::after,
    body.erp-theme table[data-table] tbody tr:has(.badge-error)::after { background: var(--erp-danger); }
    body.erp-theme table[data-table] tbody tr:has(.badge-info)::after,
    body.erp-theme table[data-table] tbody tr:has(.badge-primary)::after { background: var(--erp-blue); }

    /* Tap feedback stands in for a real ripple */
    body.erp-theme table[data-table] tbody tr:active {
        box-shadow: none;
        transform: scale(0.99);
    }

    /* Title cell = the identity/name column. Normally that's the literal
       first <td> — but the bulk-select checkbox (added client-side; see
       .bulk-select-cell above) becomes the *actual* first child on tables
       that support row selection, pushing the real title cell to second
       position. Both cases are covered here so the label-drop and title
       typography always land on the right cell. */
    body.erp-theme table[data-table] tbody td:first-child:not(.bulk-select-cell),
    body.erp-theme table[data-table] tbody td.bulk-select-cell + td {
        padding-top: 0;
        border-bottom: 0;
        margin-bottom: 2px;
    }
    body.erp-theme table[data-table] tbody td:first-child:not(.bulk-select-cell)::before,
    body.erp-theme table[data-table] tbody td.bulk-select-cell + td::before {
        display: none;
    }
    body.erp-theme table[data-table] tbody td:first-child:not(.bulk-select-cell) strong,
    body.erp-theme table[data-table] tbody td.bulk-select-cell + td strong {
        font-size: 15px;
        font-weight: 700;
        color: var(--erp-text);
    }
    body.erp-theme table[data-table] tbody td:first-child:not(.bulk-select-cell) .cell-sub,
    body.erp-theme table[data-table] tbody td.bulk-select-cell + td .cell-sub {
        font-size: 11px;
        color: var(--erp-text-muted);
    }

    /* Action cells — only ones that actually contain a link/button/form —
       drop their label, gain a divider, and read as a tonal action row.
       Scoped with :has() so text-only last columns (e.g. Maintenance's
       "Status", Quality's "Checked") are left with their normal label. */
    body.erp-theme table[data-table] tbody td:last-child:has(a, button, form) {
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid var(--erp-border);
        display: block;
    }
    body.erp-theme table[data-table] tbody td:last-child:has(a, button, form)::before {
        display: none;
    }

    /* Chip-style badges with a status dot — Android "assist chip" language */
    body.erp-theme table[data-table] .badge {
        padding: 4px 10px 4px 8px;
        border-radius: 999px;
        font-size: 10px;
        display: inline-flex;
        align-items: center;
        gap: 5px;
    }
    body.erp-theme table[data-table] .badge::before {
        content: "";
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: currentColor;
        flex: 0 0 auto;
    }

    /* Order-type pill matched to the same chip language */
    body.erp-theme table[data-table] .order-type-pill {
        display: inline-flex;
        padding: 4px 10px;
        border-radius: 999px;
        font-size: 10px;
        font-weight: 700;
        background: var(--erp-canvas);
        color: var(--erp-text-secondary);
    }

    /* Linear progress, Material-style: thin, rounded, coloured by status */
    body.erp-theme table[data-table] .sales-progress {
        height: 4px;
        border-radius: 4px;
        background: var(--erp-border);
        overflow: hidden;
        margin-bottom: 4px;
    }
    body.erp-theme table[data-table] .sales-progress span {
        display: block;
        height: 100%;
        border-radius: 4px;
        background: var(--erp-blue);
    }
    body.erp-theme table[data-table] tbody tr:has(.badge-success) .sales-progress span { background: var(--erp-success); }
    body.erp-theme table[data-table] tbody tr:has(.badge-warning) .sales-progress span { background: var(--erp-warning); }
    body.erp-theme table[data-table] tbody tr:has(.badge-danger) .sales-progress span,
    body.erp-theme table[data-table] tbody tr:has(.badge-error) .sales-progress span { background: var(--erp-danger); }

    /* Action links / quick-action buttons become full-width tonal pill buttons */
    body.erp-theme table[data-table] .workflow-link,
    body.erp-theme table[data-table] .quick-action-button,
    body.erp-theme table[data-table] .table-action {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 38px;
        padding: 0 16px;
        border-radius: 10px;
        font-size: 12px;
        font-weight: 700;
        text-align: center;
        box-sizing: border-box;
    }
    body.erp-theme table[data-table] .workflow-link,
    body.erp-theme table[data-table] .table-action {
        color: var(--erp-blue);
        background: var(--erp-primary-soft);
    }
    body.erp-theme table[data-table] .quick-action-button {
        color: #fff;
        background: var(--erp-blue);
        border: 0;
    }
    body.erp-theme table[data-table] .product-row-actions,
    body.erp-theme table[data-table] .action-links,
    body.erp-theme table[data-table] .payment-row-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    body.erp-theme table[data-table] .product-row-open {
        display: none;
    }

    /* Android-style search bar: pill shape, no hard outline */
    body.erp-theme .search-box {
        border-radius: 24px;
        border-color: transparent;
        background: var(--erp-canvas);
    }
    body.erp-theme .search-box:focus-within {
        background: #fff;
        box-shadow: 0 0 0 2px var(--erp-primary-soft), 0 0 0 3px var(--erp-blue);
    }

    /* Icon buttons as circular tap targets */
    body.erp-theme .data-tool-button {
        border-radius: 50%;
    }

    /* Segmented tabs: pill-active indicator instead of an underline */
    body.erp-theme .view-selector {
        gap: 4px;
        padding: 3px;
        background: var(--erp-canvas);
        border-radius: 12px;
    }
    body.erp-theme .view-selector a {
        border-bottom: 0;
        border-radius: 9px;
        font-weight: 600;
    }
    body.erp-theme .view-selector a.active {
        background: #fff;
        color: var(--erp-blue);
        box-shadow: var(--erp-shadow-sm);
    }
}

/* RMS-inspired secure workstation sign-in */
body.rms-login-page {
    min-height: 100vh;
    margin: 0;
    color: #172638;
    background: #dfe5eb;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

body.rms-login-page .rms-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: 58px minmax(0, 1fr) 28px;
}

body.rms-login-page .rms-titlebar {
    padding: 0 22px;
    display: flex;
    align-items: center;
    color: #fff;
    background: #123f6d;
    border-bottom: 1px solid #082b4d;
    box-shadow: 0 1px 4px rgba(8, 29, 49, 0.25);
}

body.rms-login-page .rms-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #fff;
    text-decoration: none;
}

body.rms-login-page .rms-brand-mark,
body.rms-login-page .rms-window-icon {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    color: #123f6d;
    background: #fff;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 700;
}

body.rms-login-page .rms-brand span:last-child,
body.rms-login-page .rms-window-header div > span:last-child {
    display: grid;
}

body.rms-login-page .rms-brand strong {
    font-size: 17px;
    line-height: 1.1;
}

body.rms-login-page .rms-brand small,
body.rms-login-page .rms-window-header small {
    color: #c7daeb;
    font-size: 10px;
}

body.rms-login-page .rms-title-context {
    margin-left: auto;
    display: grid;
    text-align: right;
}

body.rms-login-page .rms-title-context strong {
    font-size: 12px;
}

body.rms-login-page .rms-title-context span {
    color: #c7daeb;
    font-size: 10px;
}

body.rms-login-page .rms-login-main {
    min-height: 0;
    padding: 34px 20px;
    display: grid;
    place-items: center;
    background: #e8edf2;
}

body.rms-login-page .rms-login-window {
    width: min(820px, 100%);
    background: #fff;
    border: 1px solid #9baaba;
    border-radius: 4px;
    box-shadow: 0 16px 45px rgba(25, 48, 72, 0.2);
    overflow: hidden;
}

body.rms-login-page .rms-window-header {
    min-height: 64px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    color: #fff;
    background: #1e5b91;
    border-bottom: 1px solid #174a77;
}

body.rms-login-page .rms-window-header > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

body.rms-login-page .rms-window-header strong {
    font-size: 15px;
}

body.rms-login-page .rms-window-icon {
    color: #1e5b91;
}

body.rms-login-page .rms-secure-state {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #e4eff8;
    font-size: 10px;
}

body.rms-login-page .rms-secure-state i,
body.rms-login-page .rms-online i,
body.rms-login-page .rms-statusbar i {
    width: 7px;
    height: 7px;
    display: inline-block;
    background: #53bd7d;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 50%;
}

body.rms-login-page .rms-window-body {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
}

body.rms-login-page .rms-site-panel {
    padding: 28px 26px;
    color: #24394d;
    background: #edf3f8;
    border-right: 1px solid #cbd6df;
}

body.rms-login-page .rms-site-label,
body.rms-login-page .rms-login-heading > span {
    display: block;
    color: #567087;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

body.rms-login-page .rms-site-panel h1 {
    margin: 8px 0 24px;
    color: #153c61;
    font-size: 20px;
    line-height: 1.3;
    letter-spacing: 0;
}

body.rms-login-page .rms-site-panel dl {
    margin: 0;
    border-top: 1px solid #c8d5df;
}

body.rms-login-page .rms-site-panel dl div {
    min-height: 45px;
    padding: 7px 0;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: center;
    border-bottom: 1px solid #d2dce4;
}

body.rms-login-page .rms-site-panel dt {
    color: #667b8c;
    font-size: 10px;
}

body.rms-login-page .rms-site-panel dd {
    margin: 0;
    color: #20384c;
    font-size: 11px;
    font-weight: 600;
}

body.rms-login-page .rms-online {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #197443 !important;
}

body.rms-login-page .rms-site-panel p {
    margin: 22px 0 0;
    color: #667b8c;
    font-size: 10px;
    line-height: 1.55;
}

body.rms-login-page .rms-credential-panel {
    min-width: 0;
    padding: 30px 34px 32px;
}

body.rms-login-page .rms-login-heading h2 {
    margin: 5px 0 4px;
    color: #172638;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: 0;
}

body.rms-login-page .rms-login-heading p {
    margin: 0 0 22px;
    color: #687888;
    font-size: 11px;
}

body.rms-login-page .rms-login-form {
    display: grid;
    gap: 16px;
}

body.rms-login-page .rms-login-form > label {
    display: grid;
    gap: 6px;
    color: #2a4053;
    font-size: 11px;
    font-weight: 600;
}

body.rms-login-page .rms-login-form input[type="email"],
body.rms-login-page .rms-login-form input[type="password"] {
    width: 100%;
    height: 39px;
    padding: 0 11px;
    color: #172638;
    background: #fff;
    border: 1px solid #9eacb9;
    border-radius: 2px;
    outline: 0;
    font: 12px "Segoe UI", Tahoma, Arial, sans-serif;
}

body.rms-login-page .rms-login-form input:focus {
    border-color: #1e5b91;
    box-shadow: 0 0 0 2px rgba(30, 91, 145, 0.15);
}

body.rms-login-page .rms-login-options {
    display: grid;
    gap: 8px;
    color: #6a7987;
    font-size: 10px;
}

body.rms-login-page .rms-login-options label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #354c60;
}

body.rms-login-page .rms-login-options input {
    width: 14px;
    height: 14px;
    accent-color: #1e5b91;
}

body.rms-login-page .rms-signin-button {
    height: 41px;
    padding: 0 0 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    background: #1e5b91;
    border: 1px solid #174a77;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

body.rms-login-page .rms-signin-button:hover {
    background: #174f80;
}

body.rms-login-page .rms-signin-button b {
    width: 42px;
    height: 39px;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.12);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 16px;
}

body.rms-login-page .alert {
    margin: 0 0 16px;
    padding: 10px 12px;
    border-radius: 2px;
    font-size: 10px;
}

body.rms-login-page .rms-window-footer,
body.rms-login-page .rms-statusbar {
    min-height: 28px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 22px;
    color: #5b6d7e;
    background: #f2f4f6;
    border-top: 1px solid #cbd4dc;
    font-size: 9px;
}

body.rms-login-page .rms-window-footer span:last-child,
body.rms-login-page .rms-statusbar span:last-child {
    margin-left: auto;
}

body.rms-login-page .rms-statusbar {
    color: #d3e1ed;
    background: #123f6d;
    border-color: #082b4d;
}

body.rms-login-page .rms-statusbar span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

body.rms-login-page .password-change-window {
    width: min(520px, 100%);
}

body.rms-login-page .password-change-window .rms-credential-panel {
    padding: 30px 34px 34px;
}

body.rms-login-page .password-change-window .rms-login-heading h1 {
    margin: 5px 0 4px;
    color: #172638;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: 0;
}

.gate-verify-status.is-hold {
    background: #a56800;
}

@media (max-width: 700px) {
    body.rms-login-page .rms-shell {
        grid-template-rows: 52px minmax(0, 1fr) 26px;
    }

    body.rms-login-page .rms-titlebar {
        padding: 0 13px;
    }

    body.rms-login-page .rms-title-context,
    body.rms-login-page .rms-window-footer span:nth-child(2),
    body.rms-login-page .rms-statusbar span:nth-child(2) {
        display: none;
    }

    body.rms-login-page .rms-login-main {
        padding: 14px 10px;
        align-items: start;
    }

    body.rms-login-page .rms-window-body {
        grid-template-columns: 1fr;
    }

    body.rms-login-page .rms-site-panel {
        padding: 16px 18px;
        border-right: 0;
        border-bottom: 1px solid #cbd6df;
    }

    body.rms-login-page .rms-site-panel h1 {
        margin: 5px 0 0;
        font-size: 16px;
    }

    body.rms-login-page .rms-site-panel dl,
    body.rms-login-page .rms-site-panel p {
        display: none;
    }

    body.rms-login-page .rms-credential-panel {
        padding: 23px 18px 25px;
    }

    body.rms-login-page .rms-secure-state {
        font-size: 0;
    }

    body.rms-login-page .rms-window-footer,
    body.rms-login-page .rms-statusbar {
        padding-inline: 10px;
        gap: 10px;
    }
}
/* All entry modals — centered by default */
[data-entry-modal] {
    padding: 24px;
    align-items: center;
    justify-content: center;
}

[data-entry-modal] .modal-card {
    width: min(1040px, calc(100vw - 48px));
    height: auto;
    min-height: 540px;
    max-height: calc(100vh - 88px);
    margin: 0;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(16, 36, 63, 0.22);
    transform: none;
    transition: none;
}

/* Sales entry only — right drawer */
.sales-entry-modal {
    padding: 0;
    align-items: stretch;
    justify-content: flex-end;
}

.sales-entry-modal .modal-card {
    width: min(880px, calc(100vw - 48px));
    height: 100dvh;
    max-height: none;
    min-height: 0;
    margin: 0;
    border-radius: 0;
    border: 0;
    border-left: 1px solid #e5e7eb;
    box-shadow: -16px 0 45px rgba(16, 36, 63, 0.18);
    transform: none;
    transition: none;
}

/* ============================================================
   Mobile FAB: the single "+ New …" action per view becomes a
   floating action button instead of an inline bar button — the
   record-command-bar always renders exactly one command-primary
   child per view (see module.php), so this scopes safely.
   Excludes the inventory "Receive selected" bulk-action button,
   which isn't a create-record action and stays a normal bar.
   ============================================================ */
@media (max-width: 760px) {

    body.erp-theme .record-command-bar {
        height: 0;
        min-height: 0;
        padding: 0;
        margin: 0;
        border: 0;
        background: none;
        overflow: visible;
    }

    body.erp-theme .record-command-bar:not(:has([data-stores-receive-selected])) .command-primary {
        position: fixed;
        right: 20px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        z-index: 60;
        width: 56px;
        height: 56px;
        min-height: 0;
        padding: 0;
        border-radius: 50%;
        font-size: 0;
        color: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: var(--erp-shadow-md), 0 6px 16px rgba(15, 108, 189, 0.32);
        transition: box-shadow 0.15s ease, transform 0.1s ease;
    }

    body.erp-theme .record-command-bar:not(:has([data-stores-receive-selected])) .command-primary::before {
        content: "+";
        font-size: 28px;
        font-weight: 400;
        line-height: 1;
        color: #fff;
    }

    body.erp-theme .record-command-bar:not(:has([data-stores-receive-selected])) .command-primary:active {
        transform: scale(0.94);
        box-shadow: var(--erp-shadow-sm);
    }

    /* Stores bulk-receive stays a normal sticky bottom bar, not a FAB —
       it processes a selection rather than creating a new record */
    body.erp-theme .record-command-bar:has([data-stores-receive-selected]) {
        height: auto;
        min-height: 0;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid var(--erp-border);
        position: sticky;
        bottom: 0;
        z-index: 20;
    }

    body.erp-theme .record-command-bar:has([data-stores-receive-selected]) .command-primary {
        width: 100%;
        height: 44px;
        border-radius: var(--erp-radius);
        font-size: 13px;
        color: #fff;
    }
}