:root {
    --ems-sidebar: #102a3a;
    --ems-sidebar-deep: #0c2230;
    --ems-primary: #365e91;
    --ems-primary-dark: #294b76;
    --ems-bg: #f4f6f8;
    --ems-card: #ffffff;
    --ems-text: #243444;
    --ems-muted: #677685;
    --ems-border: #cdd6e2;
    --ems-success: #167553;
    --ems-warning: #a86514;
    --ems-danger: #b54141;
    --ems-purple: #655b8f;
    --ems-cyan: #39798a;
    --ems-table-head: #e8edf4;
    --ems-selected: #e8f0fa;
    --ems-page-bg: var(--ems-bg);
    --ems-action: var(--ems-primary);
    --ems-radius-sm: 8px;
    --ems-radius: 10px;
    --ems-radius-lg: 12px;
    --ems-shadow: 0 1px 3px rgba(28, 47, 65, .06);
    --ems-sidebar-width: 256px;
    --ems-topbar-height: 72px;
    --surface: var(--ems-card);
    --surface-subtle: var(--ems-bg);
    --text: var(--ems-text);
    --text-muted: var(--ems-muted);
    --border: var(--ems-border);
    --primary: var(--ems-primary);
    --primary-soft: var(--ems-selected);
    --success: var(--ems-success);
    --radius-md: var(--ems-radius);
    --radius-lg: var(--ems-radius-lg);
    --shadow-sm: var(--ems-shadow);
    --shadow-md: var(--ems-shadow);
    --shadow-lg: 0 8px 24px rgba(28,47,65,.16);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; max-width:100%; overflow-x:hidden; background: var(--ems-bg); }
body {
    margin: 0;
    max-width:100%;
    overflow-x:hidden;
    background: var(--ems-bg);
    color: var(--ems-text);
    font-family: Inter, "Noto Sans Myanmar", "Myanmar Text", "Noto Sans SC", "Microsoft YaHei", "Microsoft JhengHei", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(25, 137, 232, .28); outline-offset: 2px; }

.app-shell { min-height: 100vh; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--ems-sidebar-width);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    color: #dfeafa;
    background: var(--ems-sidebar);
    box-shadow: 2px 0 10px rgba(5, 26, 46, .12);
    transition: width .2s ease, transform .22s ease;
}
.brand-row { height: var(--ems-topbar-height); display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand { flex: 1; display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; background: #365e91; font-size: 19px; }
.tenant-logo { position: relative; display: inline-grid; flex: 0 0 auto; place-items: center; overflow: hidden; color: #fff; background: #365e91; }
.tenant-logo > i { position: relative; z-index: 0; }
.tenant-logo > img { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tenant-menu-logo { width: 40px; height: 40px; border-radius: 8px; font-size: 19px; }
.tenant-header-logo { width: 40px; height: 40px; border: 1px solid var(--ems-border); border-radius: 8px; font-size: 17px; }
.tenant-print-header { display: none; }
.tenant-receipt-logo,.tenant-document-logo { width: 64px; height: 64px; margin: 0 auto 10px; border: 1px solid var(--ems-border); border-radius: 10px; font-size: 25px; }
.tenant-document-logo { display: block; }
.brand strong { display: block; font-size: 21px; line-height: 1.1; }
.brand small { display: block; margin-top: 3px; font-size: 10px; color: #a9bdd4; }
.side-nav { flex: 1; overflow-y: auto; padding: 14px 10px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.side-nav a, .nav-group-toggle {
    width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 8px;
    padding: 9px 12px; color: #c7d7e8; background: transparent; text-align: left; text-decoration: none; cursor: pointer;
}
.side-nav a > i:first-child, .nav-group-toggle > i:first-child { width: 20px; color: #a8c1d8; text-align: center; }
.side-nav a:hover, .nav-group-toggle:hover { color: #fff; background: rgba(255,255,255,.08); }
.side-nav .nav-dashboard.active { color: #fff; background: #365e91; box-shadow: none; }
.side-nav .nav-dashboard.active i { color: #fff; }
.nav-group { margin-top: 3px; }
.nav-group-toggle span:nth-child(2) { flex: 1; }
.nav-chevron { margin-left: auto; font-size: 10px; transition: transform .2s ease; }
.nav-group.expanded .nav-chevron { transform: rotate(180deg); }
.nav-children { margin: 3px 0 8px 18px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.12); }
.nav-children a { min-height: 38px; padding-block: 7px; font-size: 13px; }
.nav-children a.active { color: #fff; background: rgba(119,157,197,.26); }
.nav-children a.active i { color: #a9c4df; }
.nav-badge { min-width: 20px; height: 20px; display: grid; place-items: center; margin-left: auto; padding: 0 6px; border-radius: 999px; color: #fff; background: var(--ems-danger); font-size: 10px; font-weight: 800; }
.profile-shortcut { min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 12px 22px; color: #d7e4f2; border-top: 1px solid rgba(255,255,255,.1); text-decoration: none; }
.profile-shortcut:hover { color: #fff; background: rgba(255,255,255,.06); }

.app-stage { min-height: 100vh; margin-left: var(--ems-sidebar-width); transition: margin-left .2s ease; }
.app-shell.nav-collapsed .app-sidebar { width: 76px; }
.app-shell.nav-collapsed .app-stage { margin-left: 76px; }
.app-shell.nav-collapsed .brand-row { justify-content: center; padding-inline: 10px; }
.app-shell.nav-collapsed .brand { display: none; }
.app-shell.nav-collapsed .side-nav { padding-inline: 8px; }
.app-shell.nav-collapsed .side-nav a,
.app-shell.nav-collapsed .nav-group-toggle { justify-content: center; gap: 0; padding-inline: 8px; }
.app-shell.nav-collapsed .side-nav a > span,
.app-shell.nav-collapsed .nav-group-toggle > span,
.app-shell.nav-collapsed .nav-chevron,
.app-shell.nav-collapsed .nav-badge,
.app-shell.nav-collapsed .nav-children { display: none; }
.app-shell.nav-collapsed .side-nav a > i:first-child,
.app-shell.nav-collapsed .nav-group-toggle > i:first-child { width: 24px; font-size: 16px; }
.top-bar { position: sticky; top: 0; z-index: 1050; height: var(--ems-topbar-height); display: flex; align-items: center; gap: 14px; padding: 0 22px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--ems-border); backdrop-filter: blur(14px); }
.mobile-nav-toggle{display:none}
.desktop-nav-toggle{display:inline-grid;flex:0 0 44px}
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; border-radius: 9px; color: var(--ems-muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--ems-primary); background: #edf6ff; }
.top-page-context { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.top-page-context strong { overflow: hidden; color: var(--ems-text); font-size: 18px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.top-page-context small { max-width: min(620px, 52vw); margin-top: 2px; overflow: hidden; color: var(--ems-muted); font-size: 11px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { position: relative; margin-left: auto; display: flex; align-items: center; gap: 9px; }
.top-select, .user-menu { height: 44px; display: flex; align-items: center; gap: 9px; padding: 0 12px; color: var(--ems-text); border: 1px solid var(--ems-border); border-radius: 9px; background: #fff; cursor: pointer; }
.top-select i:last-child { margin-left: 12px; font-size: 9px; color: var(--ems-muted); }
.notification-button { position: relative; }
.notification-button span { position: absolute; top: 1px; right: 1px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; color: white; background: var(--ems-danger); border: 2px solid white; border-radius: 999px; font-size: 9px; font-weight: 800; }
.user-menu { border-color: transparent; padding: 0 4px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #6f7881; font-size: 11px; font-weight: 800; }
.user-copy { min-width: 112px; text-align: left; }
.user-copy strong, .user-copy small { display: block; }
.user-copy small { color: var(--ems-muted); font-size: 10px; }
.user-menu > i { color: var(--ems-muted); font-size: 9px; }
.profile-menu-panel {
    width: 210px;
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    overflow: hidden;
    padding: 6px;
    border: 1px solid var(--ems-border);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(28,47,65,.14);
}
.profile-menu-panel a,
.profile-menu-panel button {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border: 0;
    border-radius: 7px;
    color: var(--ems-text);
    background: transparent;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.profile-menu-panel a:hover,
.profile-menu-panel button:hover { color: var(--ems-primary); background: var(--ems-selected); }
.profile-menu-panel form { margin: 0; border-top: 1px solid var(--ems-border); padding-top: 4px; }
.profile-menu-panel form button { color: var(--ems-danger); }
.nav-scrim { display: none; }

.app-main { min-height: calc(100vh - var(--ems-topbar-height)); padding: 18px 20px 28px; outline: none; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-heading h1 { margin: 0; font-size: clamp(22px, 2.4vw, 28px); letter-spacing: -.02em; }
.page-heading p { margin: 4px 0 0; color: var(--ems-muted); }
.eyebrow { margin-bottom: 3px; color: var(--ems-primary); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.page-actions-only { justify-content: flex-end; margin-bottom: 12px; }
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border: 1px solid transparent; border-radius: 8px; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn-primary { color: white; background: var(--ems-primary); border-color: var(--ems-primary); box-shadow: none; }
.btn-primary:hover { background: var(--ems-primary-dark); }
.btn-outline { color: var(--ems-text); background: white; border-color: var(--ems-border); }
.btn-outline:hover { color: var(--ems-primary); border-color: #9ed1f8; background: #f5fbff; }
.btn-success { color: white; background: var(--ems-success); }
.btn-danger { color: white; background: var(--ems-danger); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi-card { min-height: 132px; display: flex; align-items: flex-start; gap: 12px; position: relative; overflow: hidden; padding: 18px; border: 1px solid var(--ems-border); border-radius: var(--ems-radius); background: var(--ems-card); box-shadow: var(--ems-shadow); }
.kpi-icon { width: 48px; height: 48px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 11px; font-size: 20px; }
.kpi-card.blue .kpi-icon { color: var(--ems-primary); background: #e4f3ff; }
.kpi-card.green .kpi-icon { color: var(--ems-success); background: #dff9ef; }
.kpi-card.orange .kpi-icon { color: #e98421; background: #fff0df; }
.kpi-card.purple .kpi-icon { color: var(--ems-purple); background: #ece8ff; }
.kpi-copy { min-width: 0; }
.kpi-copy > span { display: block; color: var(--ems-muted); font-size: 12px; }
.kpi-copy > strong { display: block; margin-top: 5px; font-size: 20px; white-space: nowrap; }
.kpi-copy small { display: block; margin-top: 10px; font-weight: 800; }
.kpi-copy small.positive { color: var(--ems-success); }
.kpi-copy small.negative { color: var(--ems-danger); }
.kpi-copy small em { display: block; margin-top: 1px; color: var(--ems-muted); font-size: 10px; font-style: normal; font-weight: 500; }
.spark-bars { align-self: flex-end; margin-left: auto; display: flex; align-items: end; gap: 3px; height: 45px; opacity: .55; }
.spark-bars i { width: 5px; border-radius: 3px 3px 0 0; background: currentColor; }
.kpi-card.blue .spark-bars { color: var(--ems-primary); }
.kpi-card.green .spark-bars { color: var(--ems-success); }
.kpi-card.orange .spark-bars { color: var(--ems-warning); }
.kpi-card.purple .spark-bars { color: var(--ems-purple); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .8fr) minmax(280px, .9fr); gap: 14px; margin-top: 14px; }
.dashboard-grid.secondary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { border: 1px solid var(--ems-border); border-radius: var(--ems-radius); background: var(--ems-card); box-shadow: var(--ems-shadow); }
.card-header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid #edf2f7; }
.card-header h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; }
.card-header h2 i { color: var(--ems-primary); }
.card-body { padding: 16px; }
.card-link { color: var(--ems-primary); font-size: 11px; font-weight: 800; text-decoration: none; }
.mini-select { min-height: 34px; padding: 4px 9px; border: 1px solid var(--ems-border); border-radius: 7px; color: var(--ems-text); background: #fff; font-size: 11px; }

.trend-chart { height: 210px; display: flex; align-items: end; gap: clamp(8px, 2vw, 20px); padding: 18px 6px 0; border-bottom: 1px solid var(--ems-border); background: repeating-linear-gradient(to bottom, transparent 0, transparent 49px, #edf2f7 50px); }
.chart-canvas-wrap { height: 230px; }
.trend-month { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; }
.trend-bars { height: 160px; display: flex; align-items: end; gap: 3px; }
.trend-bars i { width: clamp(5px, .7vw, 9px); min-height: 5px; border-radius: 3px 3px 0 0; }
.trend-bars .sales { background: var(--ems-primary); }
.trend-bars .purchase { background: var(--ems-success); }
.trend-month span { color: var(--ems-muted); font-size: 9px; }
.chart-legend { display: flex; justify-content: center; gap: 20px; margin-top: 12px; color: var(--ems-muted); font-size: 11px; }
.chart-legend i { width: 9px; height: 9px; display: inline-block; margin-right: 5px; border-radius: 2px; }
.inventory-chart { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 18px; }
.donut { width: 140px; aspect-ratio: 1; display: grid; place-items: center; position: relative; border-radius: 50%; background: conic-gradient(var(--ems-primary) 0 45%, var(--ems-success) 45% 65%, var(--ems-warning) 65% 93%, var(--ems-purple) 93% 100%); }
.donut::after { content: ""; width: 82px; aspect-ratio: 1; position: absolute; border-radius: 50%; background: white; }
.donut strong { position: relative; z-index: 1; text-align: center; font-size: 15px; }
.donut strong small { display: block; color: var(--ems-muted); font-size: 9px; }
.legend-list { display: grid; gap: 10px; }
.legend-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 7px; font-size: 11px; }
.legend-item i { width: 10px; height: 10px; margin-top: 3px; border-radius: 3px; }
.legend-item span small { display: block; color: var(--ems-muted); }
.progress-list { display: grid; gap: 14px; }
.progress-row { display: grid; grid-template-columns: 90px 48px 1fr 38px; align-items: center; gap: 7px; font-size: 10px; }
.progress-track { height: 10px; overflow: hidden; border-radius: 999px; background: #edf2f6; }
.progress-track i { display: block; height: 100%; border-radius: inherit; }
.progress-track .blue { background: var(--ems-primary); }
.progress-track .green { background: var(--ems-success); }
.progress-track .orange { background: var(--ems-warning); }
.progress-track .red { background: var(--ems-danger); }

.metric-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric-box { padding: 12px; border-radius: 8px; background: #f7fafc; }
.metric-box i { width: 30px; height: 30px; display: grid; place-items: center; margin-bottom: 8px; border-radius: 8px; }
.metric-box.success i { color: var(--ems-success); background: #dcf8ec; }
.metric-box.danger i { color: var(--ems-danger); background: #ffe5e8; }
.metric-box span, .balance-list span { color: var(--ems-muted); font-size: 10px; }
.metric-box strong { display: block; margin-top: 3px; font-size: 14px; }
.balance-total { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.balance-total i { width: 40px; height: 40px; display: grid; place-items: center; color: var(--ems-success); background: #dff8ef; border-radius: 10px; }
.balance-total strong { font-size: 16px; }
.balance-list { display: grid; gap: 8px; }
.balance-list div { display: flex; justify-content: space-between; padding-top: 8px; border-top: 1px solid #edf2f7; }
.alert-list, .activity-list { display: grid; }
.alert-row, .activity-row { display: grid; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid #edf2f7; font-size: 10px; }
.alert-row { grid-template-columns: 14px 1fr auto; }
.alert-row i { color: var(--ems-warning); }
.activity-row { grid-template-columns: 28px 1fr auto; }
.activity-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; }
.activity-icon.blue { color: var(--ems-primary); background: #e5f3ff; }
.activity-icon.purple { color: var(--ems-purple); background: #eeeaff; }
.activity-icon.green { color: var(--ems-success); background: #e1f8ef; }
.activity-icon.orange { color: var(--ems-warning); background: #fff0df; }
.activity-row small { display: block; color: var(--ems-muted); }

.filter-card { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-bottom: 12px; padding: 10px; border: 1px solid var(--ems-border); border-radius: 6px; background: #fff; box-shadow: none; }
.form-field { display: grid; gap: 5px; min-width: 0; }
.form-field.grow { flex: 1; }
.form-field label { color: #4d5d73; font-size: 11px; font-weight: 800; }
.form-control, .form-select { width: 100%; min-height: 44px; padding: 8px 10px; color: var(--ems-text); border: 1px solid var(--ems-border); border-radius: 6px; background: #fff; outline: 0; }
.form-control:focus, .form-select:focus { border-color: var(--ems-primary); box-shadow: 0 0 0 3px rgba(25,137,232,.12); }
.search-control { position: relative; }
.search-control i { position: absolute; top: 50%; left: 13px; color: var(--ems-muted); transform: translateY(-50%); }
.search-control input { padding-left: 38px; }

.data-card { overflow: hidden; border: 1px solid var(--ems-border); border-radius: 6px; background: #fff; box-shadow: none; }
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.data-table th { height: 40px; padding: 8px 10px; color: #4f6072; background: var(--ems-table-head); border-right: 1px solid var(--ems-border); border-bottom: 1px solid var(--ems-border); font-size: 10px; letter-spacing: .025em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { height: 44px; padding: 7px 10px; border-right: 1px solid #dce3eb; border-bottom: 1px solid #dce3eb; vertical-align: middle; }
.data-table th:last-child,.data-table td:last-child { border-right: 0; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:nth-child(even) { background: #fafbfd; }
.data-table tbody tr:hover { background: var(--ems-selected); }
.data-table .number { font-variant-numeric: tabular-nums; text-align: right; }
.statement-amount { font-weight: 800; white-space: nowrap; }
.statement-amount.debit { color: var(--ems-success); }
.statement-amount.credit { color: var(--ems-danger); }
.data-table .strong { color: var(--ems-primary); font-weight: 800; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-actions button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--ems-border); border-radius: 7px; color: var(--ems-muted); background: #fff; cursor: pointer; }
.row-actions button:hover { color: var(--ems-primary); border-color: #a5d6fa; }
.record-actions { position: relative; display: flex; justify-content: flex-end; }
.record-actions-desktop { display: flex; gap: 6px; }
.record-actions-desktop .btn { min-height: 40px; padding: 7px 10px; }
.record-actions-mobile { display: none; width: 100%; gap: 8px; }
.record-actions-mobile .btn { flex: 1 1 120px; min-height: 44px; white-space: nowrap; }
.confirm-action-copy { display: flex; align-items: flex-start; gap: 14px; padding: 8px 0 18px; }
.confirm-action-copy h3 { margin: 2px 0 6px; font-size: 17px; }
.confirm-action-copy p { margin: 0; color: var(--ems-muted); }
.confirm-action-icon { display: grid; flex: 0 0 44px; height: 44px; place-items: center; border-radius: 12px; color: var(--ems-primary); background: #e8f5ff; }
.confirm-action-icon.danger { color: var(--ems-danger); background: #ffe8eb; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); overflow: hidden; border: 1px solid var(--ems-border); border-radius: 10px; background: var(--ems-card); }
.detail-field { display: grid; grid-template-columns: minmax(104px,.72fr) minmax(0,1.28fr); align-items: center; gap: 10px; min-width: 0; min-height: 46px; padding: 9px 12px; border-right: 1px solid var(--ems-border); border-bottom: 1px solid var(--ems-border); background: var(--ems-card); }
.detail-field:nth-child(2n) { border-right: 0; }
.detail-field span { display: block; margin: 0; color: var(--ems-muted); font-size: 11px; font-weight: 750; letter-spacing: .02em; text-transform: uppercase; }
.detail-field strong { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.detail-field > .status-badge { justify-self: start; }
.detail-header-table { margin-bottom: 12px; overflow: hidden; border: 1px solid var(--ems-border); border-radius: 10px; }
.detail-header-table .data-table { min-width: 620px; border: 0; }
.detail-header-table th { width: 145px; color: var(--ems-muted); background: #f6f8fb; font-size: 11px; letter-spacing: .02em; text-transform: uppercase; }
.compact-detail-table { margin: 0; }
.compact-detail-table th, .compact-detail-table td { padding: 9px 11px; }
.compact-detail-table tfoot th { border-top: 2px solid var(--ems-border); background: #f6f8fb; }
.detail-money-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); overflow: hidden; margin-bottom: 12px; border: 1px solid var(--ems-border); border-radius: 10px; background: var(--ems-card); }
.detail-money-summary > div { min-width: 0; padding: 12px 14px; border-right: 1px solid var(--ems-border); }
.detail-money-summary > div:last-child { border-right: 0; }
.detail-money-summary span { display: block; color: var(--ems-muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.detail-money-summary strong { display: block; margin-top: 4px; font-size: 16px; font-variant-numeric: tabular-nums; }
.detail-money-summary .emphasized { background: var(--ems-selected); }
.detail-money-summary .emphasized strong { color: var(--ems-primary); }
.invoice-detail-sections summary small { color: var(--ems-muted); font-size: 11px; font-weight: 650; }
.mobile-records { display: none; }
.record-card { margin-bottom: 10px; padding: 14px; border: 1px solid var(--ems-border); border-radius: var(--ems-radius); background: #fff; box-shadow: var(--ems-shadow); }
.record-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.record-card-header a { color: var(--ems-primary); font-weight: 800; text-decoration: none; }
.record-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 13px; }
.record-card-grid span { display: block; color: var(--ems-muted); font-size: 10px; }
.record-card-grid strong { display: block; margin-top: 2px; font-size: 13px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status-badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.success { color: #087a4b; background: #dcf7eb; }
.status-badge.warning { color: #a75b0d; background: #fff0da; }
.status-badge.info { color: #0a6db5; background: #dff1ff; }
.status-badge.danger { color: #b8293a; background: #ffe3e7; }
.status-badge.neutral { color: #5d6b7d; background: #edf1f5; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.form-section { margin-bottom: 14px; padding: 18px; border: 1px solid var(--ems-border); border-radius: var(--ems-radius); background: #fff; box-shadow: var(--ems-shadow); }
.form-section-title { margin: 0 0 15px; font-size: 15px; }
.logo-upload-preview { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; color: var(--ems-muted); font-size: 13px; }
.logo-upload-preview img { width: 72px; height: 72px; border: 1px solid var(--ems-border); border-radius: 14px; background: #fff; object-fit: cover; }
.logo-upload-preview strong { color: var(--ems-text); overflow-wrap: anywhere; }
.ems-modal-backdrop { position: fixed; inset: 0; z-index: 1080; display: grid; place-items: center; padding: 20px; background: rgba(11, 44, 74, .48); }
.ems-modal { width: min(760px, 100%); max-height: min(760px, calc(100dvh - 40px)); overflow: hidden auto; border: 0; border-radius: 12px; background: var(--ems-card); box-shadow: 0 24px 56px rgba(11, 44, 74, .28); }
.ems-modal-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 12px 16px; border-bottom: 1px solid var(--ems-border); background: var(--ems-card); }
.ems-modal-header h2 { margin: 0; font-size: 18px; color: var(--ems-text); }
.ems-modal-body { padding: 16px; }
.ems-modal-body .form-section { margin: 0; padding: 0; border: 0; box-shadow: none; }
.btn-icon { display: inline-grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--ems-muted); }
.btn-icon:hover { background: var(--ems-page-bg); color: var(--ems-text); }
.line-editor { margin-top: 16px; }
.sticky-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 0; }
.settings-tabs { display: flex; overflow-x: auto; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--ems-border); }
.settings-tabs button { min-height: 44px; padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; color: var(--ems-muted); background: transparent; font-weight: 700; white-space: nowrap; }
.settings-tabs button.active { color: var(--ems-primary); border-color: var(--ems-primary); }
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .35fr); gap: 14px; }
.hint-panel { padding: 16px; border: 1px solid #cfe7fb; border-radius: var(--ems-radius); background: #eff8ff; }
.hint-panel h3 { margin-top: 0; color: #116cab; font-size: 14px; }
.hint-panel p { color: #52718a; font-size: 12px; }
.report-table td:first-child { font-weight: 600; }
.report-table tr.emphasized td { font-size: 14px; font-weight: 850; background: #f6f9fc; }
.report-table tr.negative td:last-child { color: var(--ems-danger); }
.accounting-filter .filter-primary { flex: 1 1 260px; }
.accounting-filter .filter-normal { flex: 0 1 210px; }
.accounting-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); margin-bottom: 12px; overflow: hidden; border: 1px solid var(--ems-border); border-radius: 6px; background: #fff; }
.accounting-summary > div { min-width: 0; padding: 12px 14px; border-right: 1px solid var(--ems-border); }
.accounting-summary > div:last-child { border-right: 0; }
.accounting-summary span,.accounting-summary small { display: block; color: var(--ems-muted); font-size: 10px; font-weight: 700; }
.accounting-summary strong { display: block; margin-top: 4px; font-size: 16px; font-variant-numeric: tabular-nums; }
.accounting-summary-primary { background: #eef4fb; }
.accounting-summary-primary strong { color: var(--ems-primary); }
.accounting-summary-success { box-shadow: inset 3px 0 0 var(--ems-success); }
.accounting-summary-success strong { color: var(--ems-success); }
.accounting-summary-danger { box-shadow: inset 3px 0 0 var(--ems-danger); }
.accounting-summary-danger strong,.accounting-grid .negative { color: var(--ems-danger); }
.ledger-report-period { margin: 0 0 12px; color: var(--ems-muted); font-size: 12px; font-weight: 700; }
.ledger-report-section { margin-bottom: 14px; overflow: hidden; }
.ledger-report-section-header { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 24px; padding: 14px 16px; border-bottom: 1px solid var(--ems-border); background: #f8fafc; }
.ledger-report-section-header > div:first-child { min-width: 220px; margin-right: auto; }
.ledger-report-section-header span { display: block; color: var(--ems-muted); font-size: 11px; }
.ledger-report-section-header strong { font-variant-numeric: tabular-nums; }
.ledger-report-section-footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px 24px; padding: 12px 16px; border-top: 1px solid var(--ems-border); background: #f8fafc; font-size: 12px; }
.ledger-report-section-footer strong { margin-left: 5px; font-variant-numeric: tabular-nums; }
.ledger-report-empty { padding: 18px 16px; color: var(--ems-muted); }
.pagination-bar { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0; }
.pagination-bar > span { color: var(--ems-muted); font-size: 12px; }
.accounting-grid .btn-compact { min-height: 34px; padding: 5px 9px; font-size: 11px; white-space: nowrap; }
.balance-sheet-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.balance-sheet-section { align-self: start; }
.accounting-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 12px; border-bottom: 1px solid var(--ems-border); background: #f8fafc; }
.accounting-section-heading h3 { margin: 0; font-size: 14px; }
.accounting-section-heading strong { color: var(--ems-primary); font-size: 14px; font-variant-numeric: tabular-nums; }
.period-close-form { grid-template-columns: 1fr 1fr; }
.period-close-form .form-field:first-child { grid-column: 1/-1; }
.period-close-warning { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 12px; color: #7a4a0b; border: 1px solid #f0cf9f; border-radius: 6px; background: #fff8eb; font-size: 12px; }
.period-close-warning i { margin-top: 2px; }

.skeleton-stack { display: grid; gap: 10px; }
.skeleton-line { height: 42px; border-radius: 8px; background: linear-gradient(90deg, #edf2f6 25%, #f8fafc 50%, #edf2f6 75%); background-size: 200% 100%; animation: skeleton 1.2s infinite; }
@keyframes skeleton { to { background-position: -200% 0; } }
.empty-state { max-width: 420px; margin: 50px auto; padding: 32px; text-align: center; }
.empty-state > span { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 18px; color: var(--ems-primary); background: #e8f5ff; font-size: 24px; }
.empty-state h2 { margin: 0; font-size: 18px; }
.empty-state p { color: var(--ems-muted); }
.mobile-only { display: none; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(1px,1px,1px,1px) !important; white-space: nowrap !important; }

@media (max-width: 1199px) {
    .app-sidebar,
    .app-shell.nav-collapsed .app-sidebar { inset:var(--ems-topbar-height) auto 0 0;width: var(--ems-sidebar-width); height:calc(100dvh - var(--ems-topbar-height)); transform: translateX(-105%); }
    .app-shell.nav-open .app-sidebar { transform: translateX(0); }
    .app-stage,
    .app-shell.nav-collapsed .app-stage { margin-left: 0; }
    .mobile-nav-toggle{display:inline-grid;flex:0 0 44px}
    .desktop-nav-toggle{display:none}
    .app-shell.nav-collapsed .brand-row { justify-content: initial; padding: 0 16px; }
    .app-shell.nav-collapsed .brand { display: flex; }
    .app-shell.nav-collapsed .side-nav { padding: 14px 10px; }
    .app-shell.nav-collapsed .side-nav a,
    .app-shell.nav-collapsed .nav-group-toggle { justify-content: initial; gap: 12px; padding: 9px 12px; }
    .app-shell.nav-collapsed .side-nav a > span,
    .app-shell.nav-collapsed .nav-group-toggle > span,
    .app-shell.nav-collapsed .nav-chevron,
    .app-shell.nav-collapsed .nav-badge { display: initial; }
    .app-shell.nav-collapsed .nav-children { display: block; }
    .nav-scrim { position: fixed; inset: var(--ems-topbar-height) 0 0; z-index: 1030; border: 0; background: rgba(5,25,42,.48); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    .app-shell.nav-open .nav-scrim { display: block; opacity: 1; pointer-events: auto; }
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid > :first-child { grid-column: 1 / -1; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .date-selector { display: none; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid.secondary { grid-template-columns: 1fr 1fr; }
    .dashboard-grid.secondary > :last-child { grid-column: 1 / -1; }
    .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
    :root { --ems-topbar-height: 62px; }
    .top-bar { padding: 0 10px; gap: 6px; }
    .tenant-header-logo { width: 36px; height: 36px; }
    .top-page-context { flex: 1; }
    .top-page-context strong { font-size: 16px; }
    .top-page-context small, .top-select, .user-copy, .user-menu > i { display: none; }
    .user-menu { min-width: 44px; padding: 0 3px; }
    .app-main { padding: 16px 12px 88px; }
    .app-shell,.app-stage,.app-main{width:100%;max-width:100%;min-width:0;overflow-x:clip}
    .page-heading { align-items: flex-start; margin-bottom: 16px; }
    .page-heading h1 { font-size: 24px; }
    .page-heading p { font-size: 12px; }
    .page-actions .btn span { display: inline; }
    .kpi-grid, .dashboard-grid, .dashboard-grid.secondary { grid-template-columns: 1fr; }
    .dashboard-grid > *, .dashboard-grid.secondary > :last-child { grid-column: auto; }
    .kpi-card { min-height: 118px; }
    .inventory-chart { grid-template-columns: 112px 1fr; }
    .donut { width: 112px; }
    .donut::after { width: 66px; }
    .progress-row { grid-template-columns: 76px 42px 1fr 34px; }
    .filter-card { align-items: stretch; flex-direction: column; }
    .filter-card > .btn { width: 100%; }
    .accounting-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .accounting-summary > div { border-bottom: 1px solid var(--ems-border); }
    .accounting-summary > div:nth-child(2n) { border-right: 0; }
    .accounting-summary > div:nth-last-child(-n+2) { border-bottom: 0; }
    .ledger-report-section-header { align-items: stretch; gap: 10px; }
    .ledger-report-section-header > div { flex: 1 1 calc(50% - 10px); }
    .ledger-report-section-header > div:first-child { flex-basis: 100%; min-width: 0; }
    .ledger-report-section-footer { justify-content: space-between; }
    .balance-sheet-grid { grid-template-columns: 1fr; }
    .period-close-form { grid-template-columns: 1fr; }
    .period-close-form .form-field:first-child { grid-column: auto; }
    .desktop-table { display: none; }
    .mobile-records { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .table-responsive:has(.responsive-virtual-table){overflow-x:visible}
    .responsive-virtual-table{width:100%;max-width:100%}
    .responsive-virtual-table tr:not(.virtualize-placeholder){width:100%;max-width:100%;margin:8px 0!important}
    input[type="date"]{min-width:0;width:100%}
    .form-section { padding: 14px; }
    .ems-modal-backdrop { align-items: end; padding: 0; }
    .ems-modal { width: 100%; max-height: 94dvh; border-radius: 12px 12px 0 0; }
    .ems-modal-body { padding: 16px 14px max(16px, env(safe-area-inset-bottom)); }
    .sticky-actions { position: fixed; inset: auto 0 0 0; z-index: 1010; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--ems-border); box-shadow: 0 -8px 24px rgba(23,49,74,.08); backdrop-filter: blur(12px); }
    .sticky-actions .btn { flex: 1; }
    .mobile-only { display: initial; }
}

@media (max-width: 430px) {
    .app-sidebar { width: min(88vw, 330px); }
    .notification-button { display: none; }
    .metric-pair { grid-template-columns: 1fr; }
    .inventory-chart { grid-template-columns: 1fr; justify-items: center; }
    .legend-list { width: 100%; }
    .record-card-grid { grid-template-columns: 1fr 1fr; }
}

/* Shared entry layouts: size to the containing dialog, not the desktop viewport. */
.app-stage, .app-main, .card, .card-body, .page-heading > *, .record-card-grid > * { min-width: 0; }
.page-heading, .record-card-header, .card-header { flex-wrap: wrap; }
.btn { max-width: 100%; white-space: normal; }
.btn:disabled { opacity: .6; cursor: wait; }
.filter-card > .form-field { flex: 1 1 180px; }
.filter-modal-launcher{display:flex;justify-content:flex-end;margin:0 0 10px}.filter-modal-trigger{width:42px;height:42px;border:1px solid var(--border);background:var(--surface);color:var(--primary);box-shadow:var(--shadow-sm)}.filter-modal-trigger:hover{border-color:var(--primary);background:var(--primary-soft)}.filter-modal-content.filter-card{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;grid-template-areas:none!important;gap:14px!important;margin:0!important;padding:0!important;border:0!important;box-shadow:none!important;background:transparent!important}.filter-modal-content.filter-card>*{grid-area:auto!important;min-width:0!important;width:auto!important}.filter-modal .ems-modal-footer .btn{min-width:110px}.filter-modal-content .grow{grid-column:1/-1}
@media(max-width:640px){.filter-modal-content.filter-card{grid-template-columns:1fr!important}.filter-modal-content .grow{grid-column:auto}.filter-modal-trigger{width:44px;height:44px}}
.form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.form-control, .form-select { min-width: 0; max-width: 100%; }
.form-check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.form-check input { flex-shrink: 0; width: 20px; height: 20px; }
.row-actions button, .nav-children a { min-width: 44px; min-height: 44px; }
.entry-launch { margin: 16px 0; }
.entry-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.ems-modal { display: flex; flex-direction: column; width: min(960px, 100%); overflow: hidden; }
.ems-modal.modal-compact { width: min(640px, 100%); }
.ems-modal.modal-medium { width: min(780px, 100%); }
.ems-modal.modal-wide { width: min(960px, 100%); }
.ems-modal-header, .ems-modal-footer { flex-shrink: 0; }
.modal-busy-indicator{height:3px;overflow:hidden;background:#e4ebf3}.modal-busy-indicator>span:first-child{display:block;width:38%;height:100%;background:var(--ems-primary);animation:modal-busy-slide 1s ease-in-out infinite}@keyframes modal-busy-slide{0%{transform:translateX(-110%)}100%{transform:translateX(365%)}}
.ems-modal-body { overflow: auto; overscroll-behavior: contain; min-height: 0; }
.ems-modal-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--ems-border); background: var(--ems-card); }
.ems-modal-footer .btn{min-height:44px;white-space:nowrap}
.ems-modal-footer-split { justify-content: flex-start; }
.modal-footer-spacer { flex: 1 1 auto; }
.ems-modal .filter-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); padding: 0; border: 0; box-shadow: none; }
.ems-modal .form-grid, .ems-modal .filter-card { margin-bottom: 18px; }
.ems-modal .sticky-actions { position: static; box-shadow: none; }
.ems-modal .form-section-title { display: none; }
.lookup-combobox{position:relative;min-width:0}
.lookup-combobox-control{position:relative}
.lookup-combobox-control .form-control{padding-right:76px}
.lookup-clear,.lookup-toggle{position:absolute;top:50%;z-index:2;transform:translateY(-50%)}
.lookup-clear{right:38px}
.lookup-toggle{right:4px}
.lookup-toggle i{font-size:.75rem;transition:transform .15s ease}
.lookup-combobox:has([aria-expanded="true"]) .lookup-toggle i{transform:rotate(180deg)}
.lookup-options{position:absolute;z-index:1200;top:calc(100% + 4px);left:0;right:0;max-height:260px;overflow:auto;padding:6px;border:1px solid var(--ems-border);border-radius:10px;background:var(--ems-card);box-shadow:0 14px 32px rgba(11,44,74,.18)}
.lookup-option{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:8px;width:100%;min-height:44px;align-items:center;padding:9px 10px;border:0;border-radius:7px;background:transparent;color:var(--ems-text);text-align:left;cursor:pointer}
.lookup-option span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lookup-option.active,.lookup-option:hover,.lookup-option:focus-visible{background:var(--ems-selected,#e8f0fa);outline:2px solid var(--ems-primary);outline-offset:-2px}
.lookup-option small,.lookup-empty{color:var(--ems-muted)}
.lookup-empty{padding:12px}
.entry-lines{border:1px solid var(--ems-border);border-radius:10px;overflow:hidden}.entry-lines table{margin:0}.entry-summary{display:flex;justify-content:flex-end;gap:24px;align-items:center;padding:14px 0;font-size:1.05rem}.entry-summary strong{font-size:1.2rem}.modal-sections{display:grid;gap:10px}.modal-section{border:1px solid var(--ems-border);border-radius:10px;background:var(--ems-card)}.modal-section>summary{cursor:pointer;display:flex;justify-content:space-between;align-items:center;min-height:48px;padding:10px 14px;font-weight:700}.modal-section-body{padding:0 14px 14px}.compact-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px}.compact-metric{padding:12px;border:1px solid var(--ems-border);border-radius:9px}.compact-metric span{display:block;color:var(--ems-muted);font-size:.8rem}.compact-metric strong{display:block;margin-top:4px}.table-action-group{display:flex;justify-content:flex-end;gap:6px}.payment-mode{display:flex;flex-wrap:wrap;gap:8px}.payment-mode label{display:flex;align-items:center;gap:8px;min-height:44px;padding:8px 12px;border:1px solid var(--ems-border);border-radius:8px}
.production-cost-summary .cost-total,.fg-cost-overview .cost-total{border-color:#b9ddfb;background:#eef7ff}.production-cost-summary .cost-unit{border-color:#bcebd7;background:#effbf6}.production-cost-summary .cost-total strong,.production-cost-summary .cost-unit strong,.fg-cost-overview .cost-total strong{font-size:1.08rem}.fg-cost-overview{margin:0 0 14px}.fg-cost-table .btn{white-space:nowrap}
.table-secondary{display:block;margin-top:3px;color:var(--ems-muted)}.detail-list-row{display:grid;grid-template-columns:minmax(120px,1fr) minmax(180px,2fr) auto;gap:12px;align-items:center;min-height:48px;padding:9px 0;border-bottom:1px solid var(--ems-border)}.detail-list-row:last-child{border-bottom:0}.detail-list-row span,.detail-list-row small{color:var(--ems-muted)}.production-timeline{display:grid;gap:8px}.timeline-row{display:grid;grid-template-columns:32px 1fr auto;gap:10px;align-items:center;padding:8px 0;border-bottom:1px solid var(--ems-border)}.timeline-index{display:grid;place-items:center;width:30px;height:30px;border-radius:50%;color:var(--ems-primary);background:#e4f3ff;font-weight:800}.timeline-row small{display:block;margin-top:3px;color:var(--ems-muted)}.statement-summary{margin-bottom:16px}.purchase-line-entry{align-items:end}.purchase-line-entry>.btn{margin-bottom:0}
@media(max-width:767px){.detail-list-row{grid-template-columns:1fr auto}.detail-list-row span,.detail-list-row small{grid-column:1/-1}.entry-summary{justify-content:space-between}.payment-mode label{flex:1 1 140px}.purchase-line-entry>.btn{width:100%}}
.modal-simple-grid { grid-template-columns: repeat(2,minmax(0,1fr)); margin: 0 !important; }
.production-filter { margin-bottom: 10px; }
.production-filter > .production-search-field { flex: 0 1 420px; width: min(100%,420px); }
.production-secondary-filters { margin-bottom: 14px; }
.production-secondary-filters .filter-card { margin-bottom: 0; }
.date-range-filter > .production-status-filter { flex: 0 0 190px; width: 190px; }
.production-orders-filter > .production-orders-search { flex: 1 1 260px; }
@media (min-width:900px) {
    .production-orders-filter { flex-wrap: nowrap; }
    .production-orders-filter > .production-status-filter { flex: 0 0 145px; width: 145px; }
    .production-orders-filter > .date-filter-field { flex: 0 0 155px; }
    .production-orders-filter > .filter-actions { flex: 0 0 auto; }
    .production-orders-filter > .filter-actions .btn { white-space: nowrap; }
}
.production-search-field{position:relative;min-width:min(100%,320px)}
.production-search-control{position:relative;display:flex;align-items:center}
.production-search-control>.fa-magnifying-glass{position:absolute;left:14px;color:var(--ems-muted);pointer-events:none;z-index:1}
.production-search-control>.form-control{padding-left:40px;padding-right:44px}
.production-search-clear{position:absolute;right:5px;top:50%;transform:translateY(-50%)}
.production-search-options{position:absolute;z-index:1200;top:calc(100% + 6px);left:0;right:0;max-height:320px;overflow:auto;border:1px solid var(--ems-border);border-radius:10px;background:var(--ems-card);box-shadow:0 16px 36px rgba(11,44,74,.18);padding:6px}
.production-search-option{width:100%;min-height:52px;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 10px;border:0;border-radius:8px;background:transparent;color:var(--ems-text);text-align:left;cursor:pointer}
.production-search-option:hover,.production-search-option:focus-visible{background:#edf6ff;outline:2px solid var(--ems-action);outline-offset:-2px}
.production-search-option span:first-child{display:grid;gap:2px;min-width:0}
.production-search-option small{color:var(--ems-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.production-search-state{padding:14px;color:var(--ems-muted);text-align:center}
.production-order-table td { vertical-align: middle; }
.production-order-action { width: 1%; white-space: nowrap; text-align: right; }
.production-order-action .btn { min-height: 38px; padding: 7px 10px; font-size: 12px; line-height: 1.2; white-space: nowrap; }
.production-order-card > p { margin: 9px 0 0; color: var(--ems-text); }
.production-order-card > .btn { width: 100%; margin-top: 13px; }
.production-stage-list { display: grid; gap: 10px; }
.production-stage-row { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--ems-border); border-radius: 9px; }
.production-stage-number { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; color: var(--ems-primary); background: #e8f5ff; font-weight: 850; }
.production-stage-row strong, .production-stage-row span { display: block; }
.production-stage-row div > span { margin-top: 3px; color: var(--ems-muted); font-size: 11px; }
.production-detail-grid { margin: 0; }
.production-cost-hero { display: grid; grid-template-columns: minmax(210px,1.2fr) minmax(220px,.8fr); gap: 16px 24px; padding: 18px; border: 1px solid #aebfd3; border-radius: 10px; background: #f7f9fc; }
.production-cost-identity { min-width: 0; display: flex; flex-wrap: wrap; align-content: start; align-items: center; gap: 7px 10px; }
.production-cost-identity > span { flex-basis: 100%; color: var(--ems-muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.production-cost-identity > strong { min-width: 0; overflow-wrap: anywhere; font-size: 17px; }
.production-cost-primary { padding-left: 22px; border-left: 1px solid var(--ems-border); text-align: right; }
.production-cost-primary span,.production-cost-primary small { display: block; color: var(--ems-muted); }
.production-cost-primary span { font-size: 12px; font-weight: 800; text-transform: uppercase; }
.production-cost-primary strong { display: block; margin: 4px 0 2px; color: var(--ems-primary-dark); font-size: clamp(24px,3vw,32px); line-height: 1.15; font-variant-numeric: tabular-nums; }
.production-cost-facts { grid-column: 1/-1; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); border-top: 1px solid var(--ems-border); border-bottom: 1px solid var(--ems-border); }
.production-cost-facts > div { min-width: 0; padding: 11px 14px; border-right: 1px solid var(--ems-border); }
.production-cost-facts > div:last-child { border-right: 0; }
.production-cost-facts span,.production-cost-facts strong { display: block; }
.production-cost-facts span { color: var(--ems-muted); font-size: 11px; }
.production-cost-facts strong { margin-top: 3px; font-size: 14px; font-variant-numeric: tabular-nums; }
.production-cost-hero > p { grid-column: 1/-1; display: flex; align-items: flex-start; gap: 8px; margin: -4px 0 0; color: var(--ems-muted); font-size: 11px; }
.production-cost-breakdown { overflow: hidden; }
.production-cost-section-title { min-height: 48px; display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--ems-border); font-weight: 800; }
.production-detail-table { min-width: 620px; }
.production-detail-table th { color: #4d5d73; font-size: 11px; white-space: nowrap; }
.production-detail-table td { vertical-align: middle; }
.production-detail-table tbody th { width: 14%; background: var(--ems-table-head); text-align: left; }
.production-cost-table { min-width: 420px; }
.production-cost-table .emphasized td { border-top: 2px solid var(--ems-primary); background: var(--ems-selected); font-weight: 800; }
.production-cost-table .unit-cost-row td { color: var(--ems-success); background: #eef8f4; font-weight: 800; }
.ems-modal.production-detail-full{width:calc(100vw - 24px);height:calc(100dvh - 24px);max-height:calc(100dvh - 24px);border-radius:10px}
.ems-modal-backdrop:has(.production-operation-modal){z-index:1100}
.production-detail-workspace{display:grid;gap:14px;min-width:0}
.production-detail-full .production-cost-facts{grid-template-columns:repeat(auto-fit,minmax(135px,1fr))}
.production-stage-progress{padding:14px 16px;border:1px solid var(--ems-border);border-radius:10px;background:var(--ems-card)}
.production-stage-progress-title{margin-bottom:12px;font-size:13px;font-weight:850}
.production-stage-progress ol{display:flex;margin:0;padding:0;list-style:none}
.production-stage-progress li{position:relative;display:grid;flex:1;grid-template-columns:40px minmax(0,1fr);gap:9px;align-items:center;min-width:0;padding-right:18px}
.production-stage-progress li:not(:last-child)::after{content:"";position:absolute;z-index:0;top:19px;left:40px;right:0;height:3px;background:#d9e1ea}
.production-stage-progress li.completed:not(:last-child)::after{background:var(--ems-success)}
.production-stage-dot{position:relative;z-index:1;display:grid;width:40px;height:40px;place-items:center;border:3px solid #d9e1ea;border-radius:50%;color:var(--ems-muted);background:var(--ems-card)}
.production-stage-progress li.completed .production-stage-dot{border-color:var(--ems-success);color:#fff;background:var(--ems-success)}
.production-stage-progress li.current .production-stage-dot{border-color:var(--ems-primary);color:var(--ems-primary);background:#edf7ff}
.production-stage-progress li>div{display:grid;justify-items:start;gap:5px;min-width:0}
.production-stage-progress li strong{overflow-wrap:anywhere;font-size:12px}
.production-stage-progress .status-badge{font-size:9px}
.production-detail-tabs{position:sticky;z-index:3;top:-16px;display:flex;overflow-x:auto;gap:4px;padding:8px 0 0;border-bottom:1px solid var(--ems-border);background:var(--ems-card);scrollbar-width:thin}
.production-detail-tab{display:inline-flex;flex:0 0 auto;align-items:center;gap:7px;min-height:46px;padding:8px 12px;border:0;border-bottom:3px solid transparent;color:var(--ems-muted);background:transparent;font-weight:750;white-space:nowrap;cursor:pointer}
.production-detail-tab:hover,.production-detail-tab:focus-visible{color:var(--ems-primary);background:var(--ems-primary-soft)}
.production-detail-tab.active{color:var(--ems-primary);border-bottom-color:var(--ems-primary)}
.production-detail-panel{min-height:260px;padding:2px 0 8px;outline:none}
.production-tab-toolbar{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:12px}
.production-tab-toolbar h3{margin:0;font-size:15px}.production-tab-toolbar span{display:block;margin-top:3px;color:var(--ems-muted);font-size:11px}
.production-output-metrics{margin-top:14px}
.production-cost-breakdown-inline{margin-bottom:16px;border:1px solid var(--ems-border);border-radius:9px}
.input-invalid{border-color:var(--ems-danger)!important;color:var(--ems-danger)}
.production-detail-navigation-layout{display:grid;grid-template-columns:190px minmax(0,1fr);gap:16px;align-items:start;min-width:0}
.production-detail-side-menu{position:sticky;top:0;display:grid;gap:6px;padding:8px;border:1px solid var(--ems-border);border-radius:10px;background:var(--ems-card)}
.production-detail-side-menu button{display:flex;align-items:center;gap:10px;min-height:48px;padding:10px 12px;border:0;border-radius:8px;color:var(--ems-muted);background:transparent;font-weight:750;text-align:left;cursor:pointer}
.production-detail-side-menu button i{width:20px;color:var(--ems-primary);text-align:center}
.production-detail-side-menu button:hover,.production-detail-side-menu button:focus-visible{color:var(--ems-primary);background:var(--ems-primary-soft)}
.production-detail-side-menu button.active{color:#fff;background:var(--ems-primary)}
.production-detail-side-menu button.active i{color:#fff}
.production-detail-content{display:grid;gap:14px;min-width:0}
.production-detail-section{overflow:hidden;border:1px solid var(--ems-border);border-radius:10px;background:var(--ems-card)}
.production-detail-section>header{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:52px;margin:0;padding:10px 14px;border-bottom:1px solid var(--ems-border)}
.production-detail-section>header h3{margin:0;font-size:15px}
.production-detail-section>header>span,.production-detail-section>header>div>span{color:var(--ems-muted);font-size:11px}
.production-detail-section-body{padding:14px}
.production-detail-section-body.table-responsive{padding:0}
.production-detail-section-body.table-responsive>.data-table{margin:0}
.manufacturing-report-filter-layout{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr) minmax(0,1.1fr) 150px 150px 190px;grid-template-areas:"search search search search search search" "primary secondary tertiary from to actions";gap:10px 12px}.manufacturing-report-filter-layout>.filter-search{grid-area:search;width:min(100%,440px);justify-self:start}.manufacturing-report-filter-layout>.filter-primary{grid-area:primary}.manufacturing-report-filter-layout>.filter-secondary{grid-area:secondary}.manufacturing-report-filter-layout>.filter-tertiary{grid-area:tertiary}.manufacturing-report-filter-layout>.date-filter-from{grid-area:from}.manufacturing-report-filter-layout>.date-filter-to{grid-area:to}.manufacturing-report-filter-layout>.filter-actions{grid-area:actions}.manufacturing-report-filter-layout>.filter-actions .btn{flex:1;white-space:nowrap}
@media(max-width:1100px) and (min-width:768px){.manufacturing-report-filter-layout{grid-template-columns:repeat(3,minmax(0,1fr));grid-template-areas:"search search search" "primary secondary tertiary" "from to actions"}.manufacturing-report-filter-layout>.filter-search{width:min(100%,420px)}}
@media(max-width:767px){.production-cost-hero{grid-template-columns:1fr;padding:14px;gap:14px}.production-cost-primary{padding:12px 0 0;border-top:1px solid var(--ems-border);border-left:0;text-align:left}.production-cost-facts{grid-template-columns:1fr 1fr}.production-cost-facts>div:nth-child(2){border-right:0}.production-cost-facts>div:nth-child(-n+2){border-bottom:1px solid var(--ems-border)}.production-cost-primary strong{font-size:24px}}
@media(max-width:767px){.ems-modal.production-detail-full{width:100dvw;height:100dvh;max-height:100dvh;border-radius:0}.production-detail-full .ems-modal-header{padding-top:max(12px,env(safe-area-inset-top))}.production-stage-progress ol{display:grid;gap:8px}.production-stage-progress li{grid-template-columns:36px 1fr;padding:0 0 10px}.production-stage-progress li:not(:last-child)::after{top:35px;bottom:-8px;left:17px;right:auto;width:3px;height:auto}.production-stage-dot{width:36px;height:36px}.production-detail-tab{min-height:48px;padding:8px 10px;font-size:11px}.production-tab-toolbar{align-items:stretch;flex-direction:column}.production-tab-toolbar .btn{width:100%}.production-operation-modal{width:100%;max-height:92dvh}.production-output-metrics{grid-template-columns:1fr 1fr}.production-detail-navigation-layout{display:block}.production-detail-side-menu{position:sticky;z-index:3;top:-16px;display:grid;grid-template-columns:1fr 1fr;margin-bottom:12px;border-radius:0 0 10px 10px}.production-detail-side-menu button{justify-content:center;text-align:center}.production-detail-section-body{padding:10px}.production-detail-content{gap:12px}}
.return-simple-grid { grid-template-columns: repeat(2,minmax(0,1fr)); margin: 0 !important; }
.return-simple-wide { grid-column: 1 / -1; }
.return-simple-wide textarea { min-height: 88px; resize: vertical; }
.return-submit { flex: 0 0 auto; min-width: 148px; }
.cost-line-editor { display: grid; grid-template-columns: minmax(130px,.7fr) minmax(220px,2fr) minmax(150px,1fr) auto; gap: 12px; align-items: end; }
.cost-add-line { min-width: 126px; }
.cost-draft-list { overflow: hidden; margin-top: 16px; border: 1px solid var(--ems-border); border-radius: 10px; }
.cost-draft-row { display: grid; grid-template-columns: 86px minmax(160px,1fr) minmax(130px,auto) 92px; gap: 12px; align-items: center; min-height: 58px; padding: 8px 12px; border-bottom: 1px solid var(--ems-border); }
.cost-draft-row strong { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.cost-type-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.cost-type-badge.labour { color: #087a4b; background: #dcf7eb; }
.cost-type-badge.expense { color: #a75b0d; background: #fff0da; }
.cost-draft-actions { display: flex; justify-content: flex-end; gap: 2px; }
.cost-draft-actions .danger { color: var(--ems-danger); }
.cost-draft-totals { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 18px; padding: 12px; background: var(--ems-page-bg); color: var(--ems-muted); font-size: 11px; }
.cost-draft-totals strong { margin-left: 5px; color: var(--ems-text); font-size: 12px; }
.cost-history{margin-top:20px;padding-top:16px;border-top:1px solid var(--ems-border)}
.cost-history-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px}
.cost-history-heading h3{margin:0;font-size:15px}
.cost-history-heading span{color:var(--ems-muted);font-size:12px}
.cost-posted-list{overflow:hidden;border:1px solid var(--ems-border);border-radius:10px}
.cost-posted-row{display:grid;grid-template-columns:86px minmax(160px,1fr) minmax(130px,auto);align-items:center;gap:12px;min-height:58px;padding:9px 12px;border-bottom:1px solid var(--ems-border)}
.cost-posted-row:last-child{border-bottom:0}
.cost-posted-description{display:grid;gap:3px;min-width:0}
.cost-posted-description strong{overflow-wrap:anywhere;font-size:13px}
.cost-posted-description small{color:var(--ems-muted)}
.posted-cost-totals{border:1px solid var(--ems-border);border-top:0;border-radius:0 0 10px 10px}
.btn-icon:hover { background: var(--ems-bg); }
.entry-line { display: grid; grid-template-columns: minmax(0, 2fr) minmax(160px, 1fr) minmax(120px, 1fr) auto; gap: 12px; align-items: end; padding: 16px 0; border-bottom: 1px solid var(--ems-border); }
.entry-total { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 16px; background: var(--ems-bg); border-radius: 8px; font-size: 18px; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 8px; margin: 12px 0; }
.pos-products .btn { justify-content: flex-start; flex-wrap: wrap; text-align: left; }
.section-tabs { display: flex; gap: 2px; max-width: 100%; margin: 0 0 12px; padding: 0 4px; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; border: 0; border-bottom: 1px solid var(--ems-border); border-radius: 0; background: transparent; box-shadow: none; }
.section-tab { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 13px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--ems-muted); font-weight: 700; text-decoration: none; white-space: nowrap; }
.section-tab:hover { color: var(--ems-primary); background: var(--ems-bg); }
.section-tab.active { color: var(--ems-primary); border-bottom-color: var(--ems-primary); background: var(--ems-selected); box-shadow: none; }
.section-tab:focus-visible { outline: 3px solid rgba(25,137,232,.28); outline-offset: 1px; }
.section-tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--ems-bg); color: var(--ems-muted); font-size: 12px; }
.section-tab.active .section-tab-count { background: var(--ems-primary); color: #fff; }
.section-tab-panel { min-width: 0; outline: none; }
.workspace-content { min-width: 0; }
.workspace-content > .page-heading { display: none; }
.workspace-content > .section-tabs { margin-top: 0; }
.section-tab-panel:focus-visible { outline: 3px solid rgba(25,137,232,.2); outline-offset: 4px; border-radius: var(--ems-radius); }
.permission-selection-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; padding: 12px 14px; border: 1px solid var(--ems-border); border-radius: 10px; background: var(--ems-bg); color: var(--ems-muted); }
.permission-selection-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.permission-selection-actions .btn { min-height: 44px; }
.quantity-control { display: grid; grid-template-columns: 44px minmax(60px, 1fr) 44px; gap: 4px; }
.quantity-control input { text-align: center; padding-inline: 4px; }
.table-responsive { max-width: 100%; }
.data-table th { position: sticky; top: 0; z-index: 1; }
@media(max-width:767px) {
    .form-control, .form-select { font-size: 16px; }
    .page-heading { gap: 12px; }
    .page-heading .page-actions { width: 100%; }
    .filter-card > .form-field { flex-basis: auto; }
    .ems-modal-backdrop { padding: 0; }
    .ems-modal { height: 100dvh; max-height: 100dvh; border-radius: 0; }
    .ems-modal.modal-compact, .ems-modal.modal-medium, .ems-modal.modal-wide { width: 100%; }
    .ems-modal-body { padding: 16px; }
    .ems-modal-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .ems-modal-footer>.btn{flex:1 1 130px}
    .entry-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .entry-line > :first-child { grid-column: 1 / -1; }
    .record-card strong, .kpi-copy > strong { overflow-wrap: anywhere; white-space: normal; }
    .sticky-actions { position: sticky; bottom: 0; }
    .section-tabs { margin-inline: -2px; padding: 4px; scroll-snap-type: x proximity; }
    .section-tab { scroll-snap-align: start; }
    .permission-selection-toolbar, .permission-selection-actions { align-items: stretch; }
    .permission-selection-actions { width: 100%; }
    .permission-selection-actions .btn { flex: 1 1 130px; }
    .record-actions-desktop { display: none; }
    .record-actions { width: 100%; }
    .record-actions-mobile { display: flex; flex-wrap: wrap; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-field { grid-template-columns: minmax(96px,.7fr) minmax(0,1.3fr); border-right: 0; }
    .detail-money-summary { grid-template-columns: 1fr; }
    .detail-money-summary > div { border-right: 0; border-bottom: 1px solid var(--ems-border); }
    .detail-money-summary > div:last-child { border-bottom: 0; }
    .modal-simple-grid { grid-template-columns: 1fr; }
    .production-stage-row { grid-template-columns: 34px minmax(0,1fr); }
    .production-stage-row > .status-badge { grid-column: 2; justify-self: start; }
    .return-simple-grid { grid-template-columns: 1fr; }
    .return-simple-wide { grid-column: auto; }
    .return-submit { flex: 1 1 160px; min-height: 48px; }
    .cost-line-editor { grid-template-columns: 1fr; }
    .cost-add-line { width: 100%; }
    .cost-draft-row { grid-template-columns: auto 1fr auto; gap: 8px; padding: 11px; }
    .cost-draft-row > .number { grid-column: 2; text-align: left; }
    .cost-draft-actions { grid-column: 3; grid-row: 1 / span 2; }
    .cost-draft-totals { align-items: stretch; flex-direction: column; gap: 7px; }
    .cost-draft-totals span { display: flex; justify-content: space-between; gap: 12px; }
    .cost-posted-row{grid-template-columns:auto 1fr;padding:11px}
    .cost-posted-row>.number{grid-column:2;text-align:left}
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 2000; padding: 16px; background: #fff3cd; color: #664d03; }
@media print {
    .tenant-print-header { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 0 0 10px; border-bottom: 1px solid #bbb; color: #111; }
    .tenant-print-header .tenant-print-logo { width: 52px; height: 52px; border: 1px solid #bbb; border-radius: 8px; }
    .tenant-print-header strong,.tenant-print-header small { display: block; }
    .tenant-print-header small { margin-top: 2px; font-size: 10px; color: #555; }
    .tenant-receipt-logo,.tenant-document-logo { border-color: #bbb; }
    body:has(.ems-modal-backdrop) * { visibility: hidden !important; }
    body:has(.ems-modal-backdrop) .ems-modal-backdrop,
    body:has(.ems-modal-backdrop) .ems-modal-backdrop * { visibility: visible !important; }
    body:has(.ems-modal-backdrop) .ems-modal-backdrop { position: absolute; inset: 0; display: block; padding: 0; background: #fff; }
    body:has(.ems-modal-backdrop) .ems-modal { width: 100%; max-height: none; overflow: visible; border-radius: 0; box-shadow: none; }
    body:has(.ems-modal-backdrop) .ems-modal-header .btn-icon,
    body:has(.ems-modal-backdrop) .ems-modal-footer { display: none !important; }
    body:has(.ems-modal-backdrop) .ems-modal-body { overflow: visible; padding: 12px 0; }
    body:has(.ems-modal-backdrop) .modal-section > :not(summary) { display: block !important; }
}
.costing-page { max-width:1100px; display:grid; gap:24px; }
.costing-current { display:flex; align-items:center; gap:20px; padding:24px; border:1px solid #c8def3; border-radius:14px; background:linear-gradient(120deg,#eef6ff,#fff); }
.costing-symbol { display:grid; place-items:center; flex-shrink:0; width:56px; height:56px; border-radius:14px; background:#dcebfa; color:#145c98; font-size:24px; }
.costing-eyebrow { color:#52677e; font-size:11px; font-weight:700; letter-spacing:.08em; }
.costing-current h2 { margin:6px 0; font-size:25px; }
.costing-current p, .costing-lock p, .costing-items p { margin:0; color:#52677e; }
.costing-currency { margin-left:auto; padding:6px 12px; border-radius:20px; background:white; color:#52677e; font-weight:700; }
.costing-lock { display:flex; gap:12px; padding:16px 20px; border:1px solid var(--ems-border); border-radius:10px; background:#fff; }
.costing-lock > i { margin-top:4px; color:#52677e; }
.costing-lock p { margin-top:4px; }
.costing-choices > h2, .costing-items h2 { font-size:18px; margin:0 0 8px; }
.costing-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; margin-top:20px; }
.costing-option { padding:20px; border:1px solid var(--ems-border); border-radius:12px; background:white; min-width:0; }
.costing-option.is-selected { border-color:#1989e8; box-shadow:0 0 0 1px #1989e8; }
.costing-option-title { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.costing-option h3 { font-size:17px; margin:0; }
.costing-tag { padding:3px 8px; border-radius:20px; font-size:11px; color:#145c98; background:#eaf4ff; font-weight:700; }
.costing-option p { color:#52677e; margin:14px 0; }
.costing-radio { display:flex; align-items:center; gap:10px; min-height:44px; cursor:pointer; font-weight:600; }
.costing-radio input { width:20px; height:20px; accent-color:#1989e8; }
.costing-example { margin-top:20px; padding:0 16px; border:1px solid var(--ems-border); border-radius:10px; background:white; }
.costing-example summary { padding:14px 0; min-height:48px; cursor:pointer; font-weight:600; }
.costing-example-values { display:flex; flex-wrap:wrap; gap:24px; padding-bottom:20px; }
.costing-example-values strong { display:block; margin-top:4px; }
.costing-save { display:flex; flex-wrap:wrap; gap:12px; align-items:center; margin-top:20px; padding:16px; background:white; border:1px solid var(--ems-border); border-radius:10px; }
.costing-save > span { flex:1; }
.costing-items { display:flex; align-items:center; gap:24px; justify-content:space-between; padding:24px; background:white; border:1px solid var(--ems-border); border-radius:12px; }
.costing-items .btn { flex-shrink:0; }
@media(max-width:900px) { .costing-grid { grid-template-columns:1fr; } .costing-items { align-items:stretch; flex-direction:column; gap:16px; } }
@media(max-width:767px) { .costing-page { gap:16px; } .costing-current { padding:16px; gap:12px; flex-wrap:wrap; } .costing-current h2 { font-size:22px; } .costing-symbol { width:44px; height:44px; } .costing-currency { margin-left:56px; } .costing-save > span { flex-basis:100%; } .costing-save .btn { flex:1; } .costing-items { padding:18px; } }
.preferences-layout { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); gap:24px; max-width:1100px; align-items:start; }
.preferences-card { margin:0; min-width:0; }
.preferences-card h2 { display:flex; align-items:center; gap:10px; font-size:18px; margin:0 0 24px; }
.preferences-card h2 i { color:var(--ems-primary); }
.preferences-secondary { display:grid; gap:24px; min-width:0; }
.preferences-card .muted { margin:10px 0 16px; }
.preferences-note { display:flex; gap:8px; align-items:center; padding:12px; border-radius:8px; background:var(--ems-bg); }
.preferences-example { border-top:1px solid var(--ems-border); padding-top:12px; }
.preferences-example summary { min-height:44px; cursor:pointer; padding:10px 0; }
.preferences-example dl, .preferences-facts { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.5fr); gap:16px; margin:0; }
.preferences-card dd { margin:0; overflow-wrap:anywhere; }
.preferences-card dt { color:var(--ems-muted); font-weight:500; }
.preferences-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:12px; margin-top:28px; }
.preferences-link { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:48px; padding:12px 0; border-top:1px solid var(--ems-border); }
@media(max-width:767px) { .preferences-layout { grid-template-columns:minmax(0,1fr); gap:16px; } .preferences-secondary { gap:16px; } .preferences-actions .btn { flex:1; } }
.security-assignment-grid{margin-top:20px;align-items:start}
.multi-select-field{position:relative;min-width:0}
.multi-select-control{position:relative;border:1px solid var(--ems-border);border-radius:8px;background:var(--ems-card);transition:border-color .15s ease,box-shadow .15s ease}
.multi-select-control:focus-within,.multi-select-control.is-open{border-color:var(--ems-primary);box-shadow:0 0 0 3px rgba(25,137,232,.12)}
.multi-select-search{display:flex;align-items:center;gap:8px;padding:2px 6px 2px 12px;min-height:46px}
.multi-select-search>i{color:var(--ems-muted)}
.multi-select-search .form-control{border:0;box-shadow:none;padding-left:0;min-width:0;background:transparent}
.multi-select-search .btn-icon{flex:0 0 40px}
.multi-select-chips{display:flex;flex-wrap:wrap;gap:6px;padding:10px 10px 0}
.multi-select-chip{display:inline-flex;align-items:center;gap:6px;max-width:100%;padding:5px 7px 5px 10px;border-radius:999px;background:#eaf4ff;color:#125c9b;font-size:.85rem;font-weight:650}
.multi-select-chip button{display:grid;place-items:center;width:24px;height:24px;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer}
.multi-select-chip button:hover{background:rgba(25,137,232,.14)}
.multi-select-options{position:absolute;z-index:1100;top:calc(100% + 6px);left:-1px;right:-1px;max-height:300px;overflow:auto;border:1px solid var(--ems-border);border-radius:10px;background:var(--ems-card);box-shadow:0 16px 36px rgba(11,44,74,.18);padding:6px}
.multi-select-summary{display:flex;justify-content:space-between;align-items:center;padding:7px 9px;border-bottom:1px solid var(--ems-border);color:var(--ems-muted);font-size:.82rem}
.multi-select-summary button{border:0;background:transparent;color:var(--ems-primary);font-weight:700;cursor:pointer}
.multi-select-option{display:grid;grid-template-columns:22px minmax(0,1fr) 20px;gap:9px;align-items:center;min-height:48px;padding:8px 10px;border-radius:7px;cursor:pointer}
.multi-select-option:hover,.multi-select-option[aria-selected="true"]{background:#f0f7ff}
.multi-select-option input{width:18px;height:18px;accent-color:var(--ems-primary)}
.multi-select-option span{display:flex;flex-direction:column;min-width:0}
.multi-select-option strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.multi-select-option small{color:var(--ems-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.multi-select-option>i{color:var(--ems-success)}
.multi-select-empty{padding:18px;text-align:center;color:var(--ems-muted)}
@media(max-width:767px){.security-assignment-grid{grid-template-columns:1fr}.multi-select-options{position:relative;top:auto;margin-top:4px;max-height:240px;box-shadow:none;border-left:0;border-right:0;border-bottom:0}.multi-select-chip{font-size:.8rem}}
@media(max-width:767px){.production-search-options{position:fixed;left:12px;right:12px;top:auto;max-height:45vh}.production-filter>.production-search-field{width:100%;flex:1 1 100%}.production-filter>.btn{width:100%}.date-range-filter>.production-status-filter{width:auto;flex-basis:auto;grid-column:1/-1}.manufacturing-report-filter-layout{grid-template-columns:1fr 1fr;grid-template-areas:"search search" "primary primary" "secondary tertiary" "from to" "actions actions"}.manufacturing-report-filter-layout>.filter-search{width:100%}}
.date-range-filter{align-items:end}.date-range-filter .filter-actions{display:flex;gap:8px;align-items:center}.date-range-filter .date-filter-field{flex:0 0 170px}.transaction-date-search-layout{display:grid;grid-template-columns:minmax(0,1.05fr) minmax(0,.9fr) minmax(0,1.15fr) minmax(145px,.75fr) minmax(190px,.9fr);grid-template-areas:"primary secondary tertiary from to" "search search search status actions";gap:10px 12px}.transaction-date-search-layout>.form-field{width:auto}.transaction-date-search-layout>.filter-primary{grid-area:primary}.transaction-date-search-layout>.filter-secondary{grid-area:secondary}.transaction-date-search-layout>.filter-tertiary{grid-area:tertiary}.transaction-date-search-layout>.date-filter-from{grid-area:from}.transaction-date-search-layout>.date-filter-to{grid-area:to}.transaction-date-search-layout>.filter-search{grid-area:search}.transaction-date-search-layout>.filter-status{grid-area:status}.transaction-date-search-layout>.filter-actions{grid-area:actions;justify-content:stretch}.transaction-date-search-layout>.filter-actions .btn{flex:1;white-space:nowrap}.field-error{color:var(--danger,#ef5261);font-size:.875rem;margin:-8px 0 14px}.virtual-list-status{padding:12px;text-align:center;color:var(--muted-text,#6c7a90)}
.sale-orders-filter-layout{display:grid;grid-template-columns:minmax(150px,.8fr) minmax(150px,.8fr) minmax(180px,1fr) minmax(160px,.9fr) minmax(180px,1fr);grid-template-areas:"from to customer branch warehouse" "search search search status actions";gap:10px 12px}.sale-orders-filter-layout>.form-field{width:auto;min-width:0}.sale-orders-filter-layout>.date-filter-from{grid-area:from}.sale-orders-filter-layout>.date-filter-to{grid-area:to}.sale-orders-filter-layout>.filter-customer{grid-area:customer}.sale-orders-filter-layout>.filter-branch{grid-area:branch}.sale-orders-filter-layout>.filter-warehouse{grid-area:warehouse}.sale-orders-filter-layout>.filter-search{grid-area:search}.sale-orders-filter-layout>.filter-status{grid-area:status}.sale-orders-filter-layout>.filter-actions{grid-area:actions;justify-content:stretch}.sale-orders-filter-layout>.filter-actions .btn{flex:1;white-space:nowrap}
@media(max-width:1023px){.sale-orders-filter-layout{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-areas:"from to" "customer branch" "warehouse status" "search search" "actions actions"}}
@media(max-width:767px){.date-range-filter{display:grid;grid-template-columns:1fr 1fr;gap:12px}.transaction-date-search-layout{grid-template-areas:"from to" "primary primary" "secondary tertiary" "search search" "status status" "actions actions"}.sale-orders-filter-layout{grid-template-areas:"from to" "customer customer" "branch warehouse" "search search" "status status" "actions actions"}.date-range-filter .grow,.date-range-filter .filter-actions{grid-column:1/-1}.date-range-filter .filter-actions .btn{flex:1}.date-range-filter .form-control,.date-range-filter .form-select{min-width:0}}
@media(max-width:767px){.responsive-virtual-table thead{display:none}.responsive-virtual-table,.responsive-virtual-table tbody{display:block}.responsive-virtual-table tr:not(.virtualize-placeholder){display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:12px;padding:14px;border:1px solid var(--border,#dde7f0);border-radius:10px;background:#fff}.responsive-virtual-table td{display:flex!important;flex-direction:column;padding:0!important;border:0!important;text-align:left!important}.responsive-virtual-table td:before{content:attr(data-label);font-size:.75rem;color:var(--muted-text,#6c7a90)}.responsive-virtual-table td:has(>.record-actions){grid-column:1/-1;margin-top:4px}.responsive-virtual-table td:has(>.record-actions):before{display:none}.responsive-virtual-table .production-order-action{grid-column:1/-1}.responsive-virtual-table .production-order-action .btn{width:100%}}
.controlled-document-list {
    margin: 12px 0 16px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.section-heading h3 {
    margin: 0;
    color: var(--ems-text);
    font-size: .95rem;
}

.actions-cell,
.detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Sales invoice entry: compact spreadsheet-style editing on desktop/tablet. */
.invoice-source-strip { display:flex; flex-wrap:wrap; align-items:center; gap:8px 14px; margin-bottom:16px; padding:10px 12px; border:1px solid var(--ems-border); border-radius:8px; background:var(--ems-bg); }
.invoice-source-strip > span:not(.status-badge) { color:var(--ems-muted); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; }
.invoice-section-heading { display:flex; align-items:center; justify-content:space-between; margin:18px 0 8px; }
.invoice-section-heading h3 { margin:0; font-size:15px; }
.sale-entry-lines { margin-top:12px; }
.sale-entry-lines .form-control { min-width:110px; }
.sale-entry-lines .qty-expression { width:145px; }
.sale-entry-lines .number-input { width:135px; margin-left:auto; text-align:right; }
.charge-entry { grid-template-columns:minmax(180px,1.2fr) minmax(240px,1.6fr) minmax(140px,.7fr) auto; align-items:end; gap:10px; }
.charge-entry > .btn { min-width:92px; white-space:nowrap; }
.invoice-totals { display:grid; grid-template-columns:repeat(4,minmax(130px,1fr)); margin-top:18px; border:1px solid var(--ems-border); border-radius:9px; overflow:hidden; background:#fff; }
.invoice-totals > div { display:grid; gap:5px; padding:12px 14px; border-right:1px solid var(--ems-border); }
.invoice-totals > div:last-child { border-right:0; }
.invoice-totals span { color:var(--ems-muted); font-size:11px; font-weight:700; text-transform:uppercase; }
.invoice-totals strong { font-variant-numeric:tabular-nums; }
.invoice-totals .invoice-grand-total { background:var(--ems-selected); }
.invoice-totals .invoice-grand-total strong { color:var(--ems-primary); font-size:18px; }
.table-action-group { display:flex; align-items:center; justify-content:flex-end; gap:6px; white-space:nowrap; }
.table-action-group .btn { white-space:nowrap; }
@media(max-width:900px) and (min-width:768px){.charge-entry{grid-template-columns:1fr 1fr}.charge-entry>.btn{justify-self:start}.invoice-totals{grid-template-columns:1fr 1fr}.invoice-totals>div:nth-child(2){border-right:0}.invoice-totals>div:nth-child(-n+2){border-bottom:1px solid var(--ems-border)}}
@media(max-width:767px){.invoice-source-strip{align-items:flex-start}.sale-entry-lines{overflow-x:auto}.sale-entry-lines table{min-width:850px}.charge-entry{grid-template-columns:1fr}.charge-entry>.btn{width:100%}.invoice-totals{grid-template-columns:1fr 1fr}.invoice-totals>div{border-bottom:1px solid var(--ems-border)}.invoice-totals>div:nth-child(2n){border-right:0}.invoice-totals>div:nth-last-child(-n+2){border-bottom:0}.table-action-group{align-items:stretch;flex-direction:column}.table-action-group .btn{width:100%}}

/* Shared sales entry dialogs. */
.sales-context-grid { grid-template-columns:repeat(3,minmax(0,1fr)); align-items:start; }
.receipt-context-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
.dialog-section-title { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; margin-top:16px; padding:8px 0; border-bottom:1px solid var(--ems-border); }
.dialog-section-title h3 { margin:0; font-size:14px; }
.dialog-section-title > span { color:var(--ems-muted); font-size:12px; }
.section-toolbar { display:flex; align-items:center; gap:8px; }
.sales-line-editor { min-width:0; }
.sales-line-add { display:grid; grid-template-columns:minmax(220px,1.6fr) minmax(130px,.8fr) minmax(125px,.7fr) minmax(135px,.8fr) auto; gap:10px; align-items:end; padding:12px 0; }
.sales-line-add:has(.readonly-field:nth-child(3)) { grid-template-columns:minmax(210px,1.5fr) minmax(145px,.9fr) minmax(115px,.65fr) minmax(125px,.7fr) minmax(135px,.8fr) auto; }
.sales-line-add-button { min-width:88px; white-space:nowrap; }
.readonly-field output { display:flex; align-items:center; min-height:44px; padding:9px 11px; border:1px solid var(--ems-border); border-radius:8px; background:var(--ems-bg); font-variant-numeric:tabular-nums; }
.sales-line-table { margin-top:2px; }
.sales-line-table .form-control { min-width:110px; min-height:38px; height:38px; padding:6px 8px; }
.sales-line-table td { vertical-align:middle; }
.sales-line-cards { display:none; }
.sales-line-card { border:1px solid var(--ems-border); border-radius:10px; background:#fff; overflow:hidden; }
.sales-line-card > header { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:12px; border-bottom:1px solid var(--ems-border); background:var(--ems-bg); }
.sales-line-card > header span,.sales-line-card > header small { display:block; }
.sales-line-card > header small { margin-top:3px; color:var(--ems-muted); }
.sales-line-card .form-grid { grid-template-columns:1fr 1fr; margin:0; padding:12px; }
.sales-line-card-facts { display:grid; grid-template-columns:repeat(3,1fr); border-bottom:1px solid var(--ems-border); }
.sales-line-card-facts span { display:grid; gap:3px; padding:10px; border-right:1px solid var(--ems-border); color:var(--ems-muted); font-size:11px; }
.sales-line-card-facts span:last-child { border-right:0; }
.sales-line-card-facts strong { color:var(--ems-text); font-size:12px; font-variant-numeric:tabular-nums; }
.transaction-totals { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); margin-top:16px; border:1px solid var(--ems-border); border-radius:8px; overflow:hidden; background:#fff; }
.transaction-totals > div { display:grid; gap:4px; min-width:0; padding:12px 14px; border-right:1px solid var(--ems-border); }
.transaction-totals > div:last-child { border-right:0; }
.transaction-totals span { color:var(--ems-muted); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.03em; }
.transaction-totals strong { overflow-wrap:anywhere; font-size:14px; font-variant-numeric:tabular-nums; }
.transaction-totals .is-emphasized { background:var(--ems-selected); }
.transaction-totals .is-emphasized strong { color:var(--ems-primary); font-size:17px; }
.sales-payment-mode { margin-top:10px; }
.sales-payment-mode label { cursor:pointer; }
.sales-payment-mode label.selected { color:var(--ems-primary); border-color:var(--ems-primary); background:var(--ems-selected); }
.sales-payment-mode input { accent-color:var(--ems-primary); }
.payment-account-field { max-width:420px; margin-top:12px; }
.default-transaction-context { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0; margin-bottom:12px; border:1px solid var(--ems-border); border-radius:8px; overflow:hidden; background:var(--ems-bg); }
.default-transaction-context > div { display:grid; gap:4px; min-width:0; padding:10px 14px; }
.default-transaction-context > div + div { border-left:1px solid var(--ems-border); }
.default-transaction-context span { color:var(--ems-muted); font-size:11px; font-weight:700; letter-spacing:.03em; text-transform:uppercase; }
.default-transaction-context strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.transaction-context-bar{display:flex;align-items:center;gap:0;margin:0 0 12px;border:1px solid var(--ems-border);border-radius:9px;background:var(--ems-bg);overflow:hidden}
.transaction-context-bar>div{display:grid;gap:3px;min-width:0;flex:1 1 180px;padding:10px 14px}
.transaction-context-bar>div+div{border-left:1px solid var(--ems-border)}
.transaction-context-bar span{color:var(--ems-muted);font-size:11px;font-weight:750;text-transform:uppercase;letter-spacing:.03em}
.transaction-context-bar strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.transaction-context-change{align-self:stretch;min-width:88px;padding:8px 13px;border:0;border-left:1px solid var(--ems-border);background:transparent;color:var(--ems-primary);font-weight:750;cursor:pointer}
.transaction-context-change:hover,.transaction-context-change:focus-visible{background:var(--ems-selected)}
.transaction-context-editor{margin:-2px 0 14px;padding:12px;border:1px solid var(--ems-border);border-radius:9px;background:var(--ems-card)}
.transaction-location-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr)) auto;gap:10px;align-items:end;margin:0!important}
.transaction-location-grid>.btn{min-height:44px}
.inline-confirm{display:flex;align-items:center;gap:8px;margin:0 0 14px;padding:10px 12px;border:1px solid #e7c987;border-radius:8px;background:#fff8e5;color:#6e4b0a}
.inline-confirm>span{flex:1 1 auto}
.progressive-entry-section{display:grid;gap:10px;margin-top:16px;padding-top:15px;border-top:1px solid var(--ems-border)}
.progressive-entry-section>header{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:28px}
.progressive-entry-section>header h3{margin:0;font-size:15px}
.progressive-entry-section>header span{color:var(--ems-muted);font-size:12px}
.progressive-entry-body{min-width:0}
.adaptive-entry-lines-cards{display:none}
.progressive-return-entry>.lookup-combobox{max-width:560px}
.sales-customer-field { max-width:520px; margin-bottom:4px; }
.charge-entry-simple { grid-template-columns:minmax(220px,1.4fr) minmax(160px,.65fr) auto; }
.sale-invoice-entry-modal .progressive-entry-section{margin-top:12px;padding-top:12px}
.sale-invoice-entry-modal .sales-line-table-compact table{min-width:660px}
.sale-invoice-entry-modal .sales-line-table-compact th,.sale-invoice-entry-modal .sales-line-table-compact td{padding-block:9px}
.invoice-optional-action,.invoice-cost-toggle{display:inline-flex;align-items:center;gap:7px;min-height:44px;margin-top:8px;padding:7px 2px;border:0;background:transparent;color:var(--ems-primary);font-weight:750;cursor:pointer}
.invoice-optional-action:hover,.invoice-cost-toggle:hover{text-decoration:underline}
.invoice-settlement-panel{display:grid;grid-template-columns:1fr;gap:14px;margin-top:14px;padding-top:14px;border-top:1px solid var(--ems-border)}
.invoice-payment-panel{display:grid;grid-template-columns:minmax(280px,auto) minmax(260px,430px);align-items:end;gap:10px 14px;min-width:0}
.invoice-payment-panel h3{grid-column:1/-1;margin:0;font-size:15px}
.invoice-payment-panel .sales-payment-mode{margin:0}
.invoice-payment-panel .payment-entry-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;width:100%;margin:0}
.invoice-compact-totals{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));align-content:start;gap:0;width:100%;overflow:hidden;border:1px solid var(--ems-border);border-radius:8px;background:#fff}
.invoice-compact-totals>div{display:grid;gap:4px;min-height:58px;padding:9px 12px;border-right:1px solid var(--ems-border)}
.invoice-compact-totals>div:last-child{border-right:0}
.invoice-compact-totals span{color:var(--ems-muted);font-size:12px}
.invoice-compact-totals strong{font-variant-numeric:tabular-nums;font-size:13px}
.invoice-compact-totals .invoice-total-final{color:var(--ems-primary);background:var(--ems-selected)}
.invoice-compact-totals .invoice-total-final span{color:var(--ems-text);font-weight:800}
.invoice-compact-totals .invoice-total-final strong{font-size:17px}
.invoice-cost-toggle{display:flex;margin:0 0 0 auto;min-height:38px;font-size:12px}
.invoice-cost-summary{display:flex;justify-content:flex-end;gap:22px;margin-left:auto;width:min(100%,440px);padding:9px 0;border-top:1px dashed var(--ems-border);color:var(--ems-muted);font-size:12px}
.invoice-cost-summary strong{margin-left:5px;color:var(--ems-text)}
.payment-entry-grid { grid-template-columns:repeat(2,minmax(0,320px)); align-items:end; margin-top:12px; }
.charge-table { margin-top:10px; }
.charge-table td { vertical-align:middle; }
.allocation-heading { align-items:flex-end; }
.allocation-input { min-width:125px; text-align:right; }
.selected-row td { background:var(--ems-selected); }
.btn-icon.danger { color:var(--ems-danger); }
@media(max-width:1050px) and (min-width:768px){.receipt-context-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.sales-line-add,.sales-line-add:has(.readonly-field:nth-child(3)){grid-template-columns:repeat(3,minmax(0,1fr))}.sales-line-add-button{justify-self:start}.transaction-totals{grid-template-columns:repeat(2,minmax(0,1fr))}.transaction-totals>div:nth-child(2n){border-right:0}.transaction-totals>div:nth-child(n+3){border-top:1px solid var(--ems-border)}}
@media(max-width:767px){.sales-context-grid,.receipt-context-grid,.sales-line-add,.sales-line-add:has(.readonly-field:nth-child(3)),.charge-entry-simple,.payment-entry-grid{grid-template-columns:1fr}.default-transaction-context{grid-template-columns:1fr}.default-transaction-context>div+div{border-top:1px solid var(--ems-border);border-left:0}.transaction-context-bar{flex-wrap:wrap}.transaction-context-bar>div{flex-basis:50%}.transaction-context-change{width:100%;min-height:44px;border-top:1px solid var(--ems-border);border-left:0}.transaction-location-grid{grid-template-columns:1fr}.inline-confirm{align-items:stretch;flex-direction:column}.inline-confirm .btn{width:100%}.adaptive-entry-lines-table{display:none}.adaptive-entry-lines-cards{display:grid;gap:10px}.progressive-entry-section{margin-top:12px;padding-top:12px}.sales-customer-field{max-width:none}.sales-line-add-button{width:100%}.sales-line-table{display:none}.sales-line-cards{display:grid;gap:10px}.sales-line-card .form-grid{grid-template-columns:1fr 1fr}.invoice-settlement-panel{grid-template-columns:1fr;gap:14px}.invoice-compact-totals{width:100%}.invoice-cost-summary{width:100%;justify-content:space-between;gap:10px}.transaction-totals{grid-template-columns:1fr 1fr}.transaction-totals>div{border-bottom:1px solid var(--ems-border)}.transaction-totals>div:nth-child(2n){border-right:0}.transaction-totals>div:nth-last-child(-n+2){border-bottom:0}.allocation-heading{align-items:stretch;flex-direction:column}.section-toolbar{width:100%}.section-toolbar .btn{flex:1}.allocation-input{width:100%;min-height:44px}.payment-account-field{max-width:none}}
@media(max-width:430px){.sales-line-card .form-grid,.transaction-totals{grid-template-columns:1fr}.sales-line-card-facts{grid-template-columns:1fr 1fr}.sales-line-card-facts span:nth-child(2){border-right:0}.sales-line-card-facts span:last-child{grid-column:1/-1;border-top:1px solid var(--ems-border)}.transaction-totals>div{border-right:0!important}.transaction-totals>div:nth-last-child(2){border-bottom:1px solid var(--ems-border)}}

/* Compact transaction entry dialogs: one clear path, no decorative space. */
.sales-entry-modal.modal-wide{width:min(900px,100%)}
.sales-entry-modal .ems-modal-body{padding:14px 16px}
.sales-entry-modal .alert{margin:0 0 12px}
.sales-entry-modal .transaction-context-bar{margin-bottom:10px}
.sales-entry-modal .sales-customer-field{margin-bottom:0}
.sales-entry-modal .progressive-entry-section{gap:8px;margin-top:12px;padding-top:12px}
.sales-entry-modal .progressive-entry-section>header{min-height:24px}
.sales-entry-modal .progressive-entry-section>header h3{font-size:14px}
.sales-entry-modal .sales-line-add{padding:8px 0 10px}
.sales-entry-modal .transaction-totals{margin-top:10px}
.sales-entry-modal .transaction-totals>div{padding:9px 11px}
.sales-entry-modal .dialog-section-title{min-height:38px;margin-top:10px;padding:5px 0}
.sales-entry-modal .entry-lines{margin-top:8px}
.sales-entry-modal .transaction-summary-note{margin:8px 0;padding:9px 11px}
.sales-entry-modal .invoice-source-strip{margin-bottom:10px;padding:8px 10px}
.sales-entry-modal .form-grid{margin-bottom:0}
.settlement-entry-modal>.ems-modal-body .lookup-combobox:first-child{max-width:520px}
.return-entry-modal .progressive-return-entry>.lookup-combobox{max-width:520px}

@media(max-width:767px){
    .sales-entry-modal .ems-modal-body{padding:12px 12px max(12px,env(safe-area-inset-bottom))}
    .sales-entry-modal .sales-line-add,.sales-entry-modal .sales-line-add:has(.readonly-field:nth-child(3)){grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
    .sales-entry-modal .sales-line-add>.lookup-combobox,.sales-entry-modal .sales-line-add>.sales-line-add-button{grid-column:1/-1}
    .sales-entry-modal .sales-line-add-button{width:100%}
    .invoice-payment-panel{grid-template-columns:1fr}
    .invoice-payment-panel h3{grid-column:auto}
    .invoice-payment-panel .payment-entry-grid{grid-template-columns:1fr}
    .invoice-compact-totals{grid-template-columns:1fr 1fr}
    .invoice-compact-totals>div{border-bottom:1px solid var(--ems-border)}
    .invoice-compact-totals>div:nth-child(2n){border-right:0}
    .invoice-compact-totals>div:last-child{border-bottom:0}
    .sales-entry-modal .transaction-totals{grid-template-columns:1fr 1fr}
}
@media(max-width:390px){
    .sales-entry-modal .sales-line-add,.sales-entry-modal .sales-line-add:has(.readonly-field:nth-child(3)){grid-template-columns:1fr}
    .sales-entry-modal .sales-line-add>.lookup-combobox,.sales-entry-modal .sales-line-add>.sales-line-add-button{grid-column:auto}
    .invoice-compact-totals,.sales-entry-modal .transaction-totals{grid-template-columns:1fr}
    .invoice-compact-totals>div{border-right:0}
}

.detail-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--ems-border);
}
.sales-context-grid>.form-field,.sales-context-grid>div,.modal-simple-grid>.form-field,.modal-simple-grid>div{align-self:start}.quick-party-create{margin-top:.55rem;padding-left:2px}.quick-party-toggle{min-height:32px;padding:.2rem .15rem;color:var(--ems-primary);font-weight:700;white-space:nowrap}.quick-party-dialog-backdrop{position:fixed;inset:0;z-index:1140;display:grid;place-items:center;padding:20px;background:rgba(11,44,74,.56)}.quick-party-dialog{width:min(620px,calc(100vw - 32px));max-height:calc(100dvh - 40px);overflow:auto;border:1px solid var(--ems-border);border-radius:12px;background:var(--ems-card);box-shadow:0 24px 70px rgba(11,44,74,.28)}.quick-party-dialog>header,.quick-party-dialog>footer{display:flex;align-items:center;padding:14px 16px;background:var(--ems-card)}.quick-party-dialog>header{position:sticky;top:0;z-index:1;justify-content:space-between;border-bottom:1px solid var(--ems-border)}.quick-party-dialog>header h3{margin:0;font-size:1.08rem}.quick-party-dialog-body{display:grid;gap:14px;padding:18px 16px}.quick-party-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.quick-party-address{grid-column:1/-1}.quick-party-dialog>footer{position:sticky;bottom:0;justify-content:flex-end;gap:10px;border-top:1px solid var(--ems-border)}
.transaction-summary-note{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin:.75rem 0 0;padding:.75rem 1rem;border:1px solid #c9d8e8;border-radius:8px;background:#f2f6fb;color:var(--ems-text);font-size:.92rem}.transaction-summary-note strong{white-space:nowrap;font-size:1.05rem}.settlement-outstanding-summary{margin-bottom:.85rem}
@media(max-width:767px){.quick-party-dialog-backdrop{align-items:end;padding:0}.quick-party-dialog{width:100%;max-width:none;max-height:88dvh;border-width:1px 0 0;border-radius:14px 14px 0 0}.quick-party-form-grid{grid-template-columns:1fr}.quick-party-address{grid-column:auto}.transaction-summary-note{align-items:flex-start;flex-direction:column;gap:.25rem}}
/* Sale invoice POS */
.sale-pos-panel-context{display:grid;gap:9px;padding:12px 14px;border-bottom:1px solid var(--border);background:var(--surface-subtle)}
.sale-pos-location-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.sale-pos-location-grid label,.sale-pos-context-customer{display:flex;min-width:0;flex-direction:column;gap:4px}.sale-pos-location-grid label>span,.sale-pos-context-customer>span{font-size:.75rem;color:var(--text-muted)}
.sale-pos-context-customer{min-height:60px;padding:8px 12px;text-align:left;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);color:var(--text);cursor:pointer}.sale-pos-context-customer small{color:var(--text-muted)}
.sale-pos-layout{display:grid;grid-template-columns:minmax(0,1.65fr) minmax(360px,.85fr);gap:18px;align-items:start}.sale-pos-catalog{min-width:0}.sale-pos-catalog-toolbar{display:grid;gap:10px;margin-bottom:14px}.sale-pos-search-input{display:flex;align-items:center;gap:10px}.sale-pos-search-input>i{width:18px;flex:0 0 18px;text-align:center;color:var(--text-muted)}.sale-pos-search-input>.form-control{min-width:0;flex:1}.sale-pos-category-chips{display:flex;gap:8px;overflow-x:auto;padding:2px}.sale-pos-category-chips .chip{min-height:38px;padding:7px 14px;border:1px solid var(--border);border-radius:999px;background:var(--surface);white-space:nowrap;cursor:pointer}.sale-pos-category-chips .chip.selected{border-color:var(--primary);background:var(--primary-soft);color:var(--primary)}
.sale-pos-product-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.sale-pos-product-card{display:flex;min-width:0;min-height:190px;padding:14px;flex-direction:column;align-items:flex-start;gap:7px;text-align:left;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-sm);cursor:pointer;transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease}.sale-pos-product-card:hover:not(:disabled){transform:translateY(-2px);border-color:var(--primary);box-shadow:var(--shadow-md)}.sale-pos-product-card:disabled{opacity:.55;cursor:not-allowed}.sale-pos-product-card strong{display:-webkit-box;overflow:hidden;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.35}.sale-pos-product-card small{color:var(--text-muted);font-size:.75rem}.sale-pos-product-card b{margin-top:auto;color:var(--primary)}
.sale-pos-product-icon{display:grid;width:44px;height:44px;place-items:center;border-radius:12px;background:hsl(var(--category-hue) 68% 92%);color:hsl(var(--category-hue) 55% 38%);font-size:1.1rem}.sale-pos-product-code{font-size:.7rem;font-weight:700;letter-spacing:.06em;color:var(--text-muted)}.sale-pos-load-more{display:flex;margin:18px auto}
.sale-pos-checkout{position:sticky;top:16px;max-height:calc(100vh - 32px);display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--surface);box-shadow:var(--shadow-md)}.sale-pos-checkout-toolbar{display:none}.sale-pos-lines{max-height:290px;overflow:auto;padding:10px 14px}.sale-pos-line{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:10px;align-items:center;padding:10px 0;border-bottom:1px solid var(--border)}.sale-pos-line>div:first-child{display:flex;min-width:0;flex-direction:column}.sale-pos-line small{color:var(--text-muted)}
.sale-pos-charges,.sale-pos-payment{padding:12px 14px;border-top:1px solid var(--border)}.sale-pos-charges h3,.sale-pos-payment h3{margin:0;font-size:.88rem}.sale-pos-section-heading{display:flex;min-height:36px;align-items:center;justify-content:space-between;gap:10px}.sale-pos-section-heading .btn-icon{border:1px solid var(--border);background:var(--surface)}.sale-pos-charge-entry{display:grid;grid-template-columns:minmax(0,1fr) 110px 36px;gap:6px;align-items:center;margin-top:7px}.sale-pos-payment .payment-mode{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin:10px 0}.sale-pos-payment .payment-mode label{min-height:42px;display:flex;align-items:center;justify-content:center;gap:5px;border:1px solid var(--border);border-radius:var(--radius-md);cursor:pointer}.sale-pos-payment .payment-mode label.selected{border-color:var(--primary);background:var(--primary-soft);color:var(--primary)}
.sale-pos-payment-accounts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:5px}.sale-pos-payment-accounts label{display:flex;min-width:0;min-height:46px;align-items:center;gap:8px;padding:7px 9px;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);cursor:pointer}.sale-pos-payment-accounts label.selected{border-color:var(--primary);background:var(--primary-soft);color:var(--primary)}.sale-pos-payment-accounts input{position:absolute;opacity:0;pointer-events:none}.sale-pos-payment-accounts i{width:20px;text-align:center}.sale-pos-payment-accounts label>span{display:flex;min-width:0;flex-direction:column}.sale-pos-payment-accounts strong,.sale-pos-payment-accounts small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sale-pos-payment-accounts small{color:var(--text-muted);font-size:.68rem}
.sale-pos-review-payment{margin-top:14px;padding:14px 0 0;border-top:1px solid var(--border)}.sale-pos-review-payment .payment-mode{max-width:460px}.sale-pos-review-payment .sale-pos-payment-accounts{grid-template-columns:repeat(auto-fit,minmax(160px,1fr))}.sale-pos-partial-received{max-width:320px;margin-top:10px}
.sale-pos-summary{display:grid;gap:6px;padding:14px;border-top:1px solid var(--border);background:var(--surface-subtle)}.sale-pos-summary>div{display:flex;justify-content:space-between;gap:12px}.sale-pos-grand-total{margin-top:4px;padding-top:10px;border-top:1px solid var(--border);font-size:1.08rem}.sale-pos-review{min-height:52px;margin:0 14px 14px;justify-content:center}.sale-pos-mobile-invoice,.sale-pos-mobile-back{display:none}
.sale-pos-customer-search{margin-bottom:12px}.sale-pos-customer-list{display:grid;gap:7px;max-height:55vh;overflow:auto}.sale-pos-customer-row{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(120px,.65fr) minmax(120px,.65fr);gap:12px;padding:12px;text-align:left;color:var(--text);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);cursor:pointer}.sale-pos-customer-row.selected{border-color:var(--primary);background:var(--primary-soft)}.sale-pos-customer-row>span{display:flex;flex-direction:column;gap:3px}.sale-pos-customer-row small{color:var(--text-muted)}
.sale-pos-item-heading{display:flex;align-items:center;gap:12px;margin-bottom:16px}.sale-pos-item-heading>div{display:flex;flex-direction:column}.sale-pos-item-heading small{color:var(--text-muted)}.output-control{display:flex;align-items:center;background:var(--surface-subtle)}.sale-pos-review-context{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:14px}.sale-pos-review-context>div{display:flex;flex-direction:column;padding:10px;border-radius:var(--radius-md);background:var(--surface-subtle)}.sale-pos-review-context span{font-size:.75rem;color:var(--text-muted)}.sale-pos-review-totals{margin-top:12px;border-radius:var(--radius-md)}
.sale-pos-receipt{max-width:900px;margin:3vh auto;padding:32px;border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--surface);box-shadow:var(--shadow-md)}.sale-pos-receipt-header{text-align:center}.sale-pos-receipt-icon{font-size:3rem;color:var(--success)}.sale-pos-receipt h1{margin:8px}.sale-pos-receipt-customer{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:24px 0;padding:14px;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface-subtle)}.sale-pos-receipt-customer>div{display:flex;min-width:0;flex-direction:column;gap:2px}.sale-pos-receipt-customer span{font-size:.72rem;color:var(--text-muted)}.sale-pos-receipt-lines{margin-top:16px}.sale-pos-receipt-lines tfoot th{font-size:1rem}.sale-pos-receipt-charge td{background:var(--surface-subtle)}.sale-pos-receipt-totals{display:grid;gap:8px;margin:18px 0;padding:16px;border-radius:var(--radius-md);background:var(--surface-subtle)}.sale-pos-receipt-totals>div{display:flex;justify-content:space-between}.sale-pos-receipt .page-actions{justify-content:center}
.sale-invoice-detail-print{display:none}
@media (max-width:1023px) and (min-width:768px){.sale-pos-product-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.sale-pos-layout{grid-template-columns:minmax(0,1.4fr) minmax(330px,.9fr)}}
@media (max-width:767px){.sale-pos-panel-context{padding:10px 12px}.sale-pos-layout{display:block}.sale-pos-product-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.sale-pos-product-card{min-height:142px;padding:8px;gap:4px;border-radius:10px}.sale-pos-product-icon{width:34px;height:34px;border-radius:9px}.sale-pos-product-card strong{font-size:.78rem}.sale-pos-product-card small{font-size:.64rem}.sale-pos-product-card b{font-size:.72rem}.sale-pos-checkout{display:none;position:fixed;inset:0;z-index:1050;max-height:none;border:0;border-radius:0}.sale-pos-layout.show-checkout .sale-pos-catalog{visibility:hidden}.sale-pos-layout.show-checkout .sale-pos-checkout{display:flex}.sale-pos-mobile-invoice{display:inline-flex;position:fixed;right:16px;bottom:max(18px,env(safe-area-inset-bottom));z-index:900;min-height:48px;align-items:center;box-shadow:var(--shadow-lg)}.sale-pos-mobile-invoice span{display:grid;min-width:22px;height:22px;place-items:center;margin-left:5px;border-radius:999px;background:#fff;color:var(--primary);font-size:.72rem}.sale-pos-checkout-toolbar{display:flex;align-items:center;justify-content:space-between;min-height:48px;padding:max(8px,env(safe-area-inset-top)) 12px 8px;border-bottom:1px solid var(--border)}.sale-pos-mobile-back{display:inline-grid}.sale-pos-lines{max-height:none;flex:1}.sale-pos-review{min-height:52px;margin-bottom:max(14px,env(safe-area-inset-bottom))}.sale-pos-customer-row{grid-template-columns:1fr 1fr}.sale-pos-customer-row>span:first-child{grid-column:1/-1}.sale-pos-review-context{grid-template-columns:1fr}.sale-pos-item-modal{position:fixed!important;left:0!important;right:0!important;bottom:0!important;top:auto!important;max-height:88vh!important;border-radius:18px 18px 0 0!important}.sale-pos-item-modal .ems-modal-footer{padding-bottom:max(12px,env(safe-area-inset-bottom))}}
@media (prefers-reduced-motion:reduce){.sale-pos-product-card{transition:none}}
.sale-pos-product-card:focus-visible,.sale-pos-category-chips .chip:focus-visible,.sale-pos-context-customer:focus-visible{outline:3px solid color-mix(in srgb,var(--primary) 35%,transparent);outline-offset:2px}
@media (max-width:767px){.sale-pos-layout.show-checkout+.sale-pos-mobile-invoice{display:none}}
@media (max-width:767px){.sale-pos-receipt{margin:0;padding:18px 12px;border:0;box-shadow:none}.sale-pos-receipt-customer{grid-template-columns:repeat(2,minmax(0,1fr));padding:10px}.sale-pos-receipt-lines .data-table{min-width:680px}}
@media print{
    .sale-invoice-detail-print{display:block!important}
    body:has(.sale-pos-receipt) *{visibility:hidden!important}
    body:has(.sale-pos-receipt) .sale-pos-receipt,body:has(.sale-pos-receipt) .sale-pos-receipt *{visibility:visible!important}
    body:has(.sale-pos-receipt) .sale-pos-receipt{position:absolute;inset:0 auto auto 0;width:100%;max-width:none;margin:0;padding:10mm;border:0;border-radius:0;box-shadow:none;color:#111;background:#fff}
    body:has(.sale-pos-receipt) .sale-pos-receipt .no-print{display:none!important}
    body:has(.sale-pos-receipt) .sale-pos-receipt-customer{break-inside:avoid;background:#fff}
    body:has(.sale-pos-receipt) .sale-pos-receipt-lines{overflow:visible}
    body:has(.sale-pos-receipt) .sale-pos-receipt-lines table{width:100%;min-width:0}
    body:has(.sale-pos-receipt) .sale-pos-receipt-lines tr{break-inside:avoid}
    body:has(.sale-pos-receipt) .sale-pos-receipt-totals{break-inside:avoid;background:#fff;border:1px solid #ccc}
}
