:root {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #172033;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #1e3a8a;
    --primary-dark: #172554;
    --danger: #dc2626;
    --warning: #b45309;
    --success: #15803d;
    --shadow: 0 16px 40px rgba(15, 23, 42, .08);
    --shadow-soft: 0 8px 22px rgba(15, 23, 42, .06);
    --control-height: 40px;
    --control-height-sm: 34px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 13px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a {
    color: inherit;
}

.icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

button,
input,
select,
textarea {
    max-width: 100%;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns .2s ease;
}

.app-shell.sidebar-expanded {
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 10px;
    background: linear-gradient(180deg, #0b1f44 0%, #0f2d5c 55%, #07152f 100%);
    color: #fff;
    overflow: hidden;
    transition: padding .2s ease;
}

.sidebar-backdrop {
    display: none;
}

.app-shell.sidebar-expanded .sidebar {
    padding: 24px 18px;
}

.brand {
    display: flex;
    justify-content: center;
    gap: 0;
    align-items: center;
    color: #fff;
    text-decoration: none;
    margin-bottom: 26px;
}

.app-shell.sidebar-expanded .brand {
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .95);
    color: #fff;
    box-shadow: 0 10px 24px rgba(30, 58, 138, .3);
}

.brand-mark img {
    display: block;
    width: 78%;
    height: 78%;
    object-fit: contain;
}

.brand-mark .icon {
    width: 22px;
    height: 22px;
}

.brand strong,
.brand small {
    display: block;
}

.brand-text,
.nav span {
    width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity .16s ease, width .2s ease;
}

.app-shell.sidebar-expanded .brand-text,
.app-shell.sidebar-expanded .nav span {
    width: auto;
    opacity: 1;
}

.brand small {
    margin-top: 2px;
    color: #cbd5e1;
    font-size: 12px;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    color: #dbe4f0;
    text-decoration: none;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px;
    transition: background .18s ease, color .18s ease;
}

.app-shell.sidebar-expanded .nav a {
    justify-content: flex-start;
    gap: 10px;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    box-shadow: inset 3px 0 0 #60a5fa;
}

.sidebar-profile {
    display: grid;
    grid-template-columns: 42px;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, .12);
}

.app-shell.sidebar-expanded .sidebar-profile {
    grid-template-columns: 42px minmax(0, 1fr) 38px;
    justify-content: stretch;
    align-items: center;
}

.profile-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: rgba(96, 165, 250, .18);
    color: #dbeafe;
    font-weight: 900;
}

.profile-meta {
    display: none;
    min-width: 0;
}

.app-shell.sidebar-expanded .profile-meta {
    display: block;
}

.profile-meta strong,
.profile-meta small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-meta small {
    color: #cbd5e1;
    font-size: 12px;
}

.profile-logout {
    display: grid;
    place-items: center;
    width: var(--control-height);
    height: var(--control-height);
    border-radius: 8px;
    color: #fecaca;
    text-decoration: none;
    transition: background .18s ease, color .18s ease;
}

.profile-logout:hover {
    background: rgba(220, 38, 38, .16);
    color: #fff;
}

.profile-logout span {
    display: none;
}

.main {
    padding: 28px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.topbar-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.sidebar-toggle {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
}

.sidebar-toggle:hover {
    background: #eef2f7;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 24px;
    line-height: 1.15;
}

h3 {
    margin-bottom: 16px;
}

.topbar-actions,
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.table-actions .inline-form,
.table-actions .inline-form button {
    width: auto;
}

.view-action-menu {
    position: relative;
}

.view-action-menu summary {
    list-style: none;
}

.view-action-menu summary::-webkit-details-marker {
    display: none;
}

.view-action-list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    min-width: 190px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow);
}

.view-action-list a,
.view-action-list span {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
}

@media (max-width: 768px) {
    .view-action-menu[open] .view-action-list {
        position: fixed;
        right: 14px;
        left: 14px;
        top: auto;
        bottom: 18px;
        z-index: 10000;
        min-width: 0;
        max-height: 55vh;
        overflow-y: auto;
        padding: 10px;
        border-radius: 16px;
    }

    .view-action-menu[open] .view-action-list a,
    .view-action-menu[open] .view-action-list span {
        padding: 12px 14px;
        font-size: 14px;
    }
}


.view-action-list a:hover {
    background: #f1f5f9;
}

.view-action-list span {
    color: var(--muted);
}

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--control-height);
    padding: 9px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

.btn:hover,
button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-muted {
    background: #eef2f7;
    color: #172033;
    border: 1px solid #d7dee8;
}

.btn-muted:hover {
    background: #cbd5e1;
}

.btn-danger {
    background: var(--danger);
}

.icon-btn {
    min-width: var(--control-height);
    width: var(--control-height);
    height: var(--control-height);
    min-height: var(--control-height);
    padding: 0;
}

.icon-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

.grid,
.grid2,
.summary {
    display: grid;
    gap: 14px;
}

.grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
}

.card,
.box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.card {
    padding: 22px;
    margin-bottom: 18px;
}

.box {
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.box-icon {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: #eff6ff;
    color: var(--primary);
}

.box h3 {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.box b {
    display: block;
    font-size: 22px;
    line-height: 1.2;
}

.box small {
    color: var(--muted);
}

.flow {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.flow span {
    padding: 14px;
    border-radius: 8px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    color: #334155;
    font-weight: 700;
    text-align: center;
}

.dashboard-insights,
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .9fr);
    gap: 18px;
    margin-bottom: 18px;
}

.insight-card,
.action-card {
    margin-bottom: 0;
}

.insight-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.insight-metrics div,
.action-list a,
.compact-list a {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.insight-metrics div {
    padding: 14px;
}

.insight-metrics span,
.action-list span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.insight-metrics strong {
    display: block;
    font-size: 17px;
    line-height: 1.25;
}

.action-list,
.compact-list {
    display: grid;
    gap: 10px;
}

.action-list a,
.compact-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: inherit;
    text-decoration: none;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.action-list a:hover,
.compact-list a:hover {
    border-color: rgba(30, 58, 138, .28);
    background: #eff6ff;
    transform: translateY(-1px);
}

.action-list strong,
.compact-list strong {
    min-width: max-content;
}

.compact-list span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-table {
    border: 0;
}

.mini-table table {
    min-width: 620px;
}

label {
    display: block;
    margin-bottom: 7px;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

.single-order-grid textarea {
    min-height: 44px;
    height: 44px;
    resize: vertical;
}

.single-items-table textarea {
    min-height: 38px;
    height: 38px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(30, 58, 138, .16);
    border-color: var(--primary);
}

button:focus-visible,
.btn:focus-visible,
.nav a:focus-visible {
    outline: 3px solid rgba(30, 58, 138, .22);
    outline-offset: 2px;
}

.form-section {
    margin-top: 18px;
}

.form-field-action {
    display: flex;
    align-items: end;
}

.form-field-action button {
    width: 100%;
    min-height: 42px;
}

.settings-form textarea.settings-address {
    min-height: 84px;
}

.pickup-date-action button {
    min-height: 48px;
    height: 48px;
}

.pickup-date-action {
    align-self: end;
    display: flex;
    align-items: center;
    margin-top: 0;
}

.pickup-filter-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}

.pickup-filter-form .pickup-print-options {
    grid-column: 1 / -1;
}

.pickup-print-options {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
}

.pickup-action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-left: auto;
}

.pickup-print-options button.icon-btn {
    width: var(--control-height);
    padding: 0;
}

.print-option {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    margin: 0;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    cursor: pointer;
}

.print-option input {
    flex: 0 0 auto;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.section-heading h3 {
    margin-bottom: 0;
}



.sale-price-warning {
    display: block;
    margin-top: 6px;
    color: #b45309;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}

.sale-price-warning[hidden] {
    display: none;
}

.input-warning {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .14) !important;
}

.stock-unit-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    min-width: 360px;
}

.stock-unit-select-all {
    display: inline-flex;
    grid-column: 1 / -1;
    align-items: center;
    gap: 8px;
    width: max-content;
    margin: 0 0 2px;
    padding: 7px 9px;
    border: 1px solid rgba(30, 58, 138, .22);
    border-radius: 8px;
    background: #eff6ff;
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

.stock-unit-option {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 9px;
    align-items: start;
    margin: 0;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    cursor: pointer;
}

.stock-unit-option:has(input:checked) {
    border-color: rgba(30, 58, 138, .55);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, .09);
}

.stock-unit-option:has(input:disabled) {
    opacity: .48;
    cursor: not-allowed;
}

.stock-unit-option input {
    margin-top: 2px;
}

.stock-unit-text {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.stock-unit-text strong,
.stock-unit-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stock-unit-text strong {
    font-size: 12px;
}

.stock-unit-text small,
.stock-unit-empty {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.stock-unit-empty {
    padding: 10px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.sale-items-table {
    table-layout: fixed;
    min-width: 820px;
}

.sale-items-table th:nth-child(1),
.sale-items-table td:nth-child(1) {
    width: 22%;
}

.sale-items-table th:nth-child(2),
.sale-items-table td:nth-child(2) {
    width: 52%;
}

.sale-items-table th:nth-child(3),
.sale-items-table td:nth-child(3) {
    width: 18%;
}

.sale-items-table th:nth-child(4),
.sale-items-table td:nth-child(4) {
    width: 8%;
}

.sale-items-table .stock-unit-picker {
    min-width: 0;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.sale-items-table .stock-unit-text strong,
.sale-items-table .stock-unit-text small {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
}

@media (max-width: 760px) {
    .sale-items-table {
        min-width: 720px;
    }

    .sale-items-table th:nth-child(1),
    .sale-items-table td:nth-child(1) {
        width: 20%;
    }

    .sale-items-table th:nth-child(2),
    .sale-items-table td:nth-child(2) {
        width: 56%;
    }

    .sale-items-table .stock-unit-picker {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
}

.purchase-bulk-actions {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.tabs {
    display: inline-flex;
    gap: 6px;
    padding: 5px;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.tab-button {
    min-height: var(--control-height);
    padding: 9px 14px;
    background: transparent;
    color: var(--muted);
}

.tab-button:hover,
.tab-button.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow-soft);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.purchase-mode-page {
    margin-bottom: 18px;
}

.single-purchase-form,
.batch-purchase-form {
    display: grid;
    gap: 18px;
}

.mode-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.single-hero {
    border-left: 4px solid var(--primary);
}

.batch-hero {
    border-left: 4px solid #2563eb;
}

.mode-kicker {
    display: block;
    margin-bottom: 5px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mode-hero h3 {
    margin-bottom: 6px;
    font-size: 18px;
}

.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: max-content;
    min-height: var(--control-height);
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: #334155;
    font-size: 12px;
    font-weight: 900;
}

.single-purchase-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

.single-order-pane,
.single-item-pane,
.batch-workspace {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.single-item-pane {
    position: static;
}

.compact-heading {
    margin-bottom: 14px;
}

.field-stack {
    display: grid;
    gap: 14px;
}

.single-order-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.sale-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.order-note-field {
    grid-column: auto;
}

.single-order-pane .grid2 {
    margin-bottom: 14px;
}

.featured-product-box {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 14px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f8fbff;
}

.product-glyph {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 8px;
    background: #eff6ff;
    color: var(--primary);
}

.product-glyph .icon {
    width: 25px;
    height: 25px;
}

.batch-workspace {
    display: grid;
    gap: 16px;
}

.batch-toolbar {
    display: grid;
    grid-template-columns: 220px 180px 180px minmax(260px, 1fr);
    gap: 12px;
    align-items: end;
    padding: 14px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f8fbff;
}

.batch-toolbar-actions {
    display: flex;
    justify-content: flex-end;
    align-items: end;
    gap: 10px;
    justify-self: end;
}

.batch-toolbar-actions .btn {
    white-space: nowrap;
}

.batch-table-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
}

.batch-table-head h3 {
    margin-bottom: 4px;
}

.batch-table-wrap table {
    min-width: 980px;
}

.single-items-table table {
    min-width: 820px;
}

.single-items-table td {
    padding: 8px;
    vertical-align: top;
}

.single-items-table input,
.single-items-table select,
.single-items-table textarea {
    min-height: 36px;
    padding: 8px 9px;
}

.batch-table-wrap td {
    padding: 8px;
}

.batch-table-wrap input,
.batch-table-wrap select {
    min-height: 36px;
    padding: 8px 9px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.section-subtitle {
    margin: 18px 0 10px;
    font-size: 15px;
    color: var(--text);
}

.table-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0 0 10px;
}

.table-filter-input {
    position: relative;
    width: min(100%, 360px);
}

.table-filter-input::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 14px;
    height: 14px;
    border: 2px solid var(--muted);
    border-radius: 999px;
    transform: translateY(-56%);
    opacity: .7;
}

.table-filter-input::after {
    content: "";
    position: absolute;
    left: 25px;
    top: 26px;
    width: 7px;
    height: 2px;
    border-radius: 999px;
    background: var(--muted);
    transform: rotate(45deg);
    opacity: .7;
}

.table-filter-input input {
    min-height: 38px;
    padding-left: 38px;
}

.filterable-head {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 28px;
}

.filterable-head::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid var(--muted);
    transform: translateY(-35%);
}

.filterable-head.is-filtered::after {
    border-top-color: var(--primary);
}

.column-filter-menu {
    position: absolute;
    z-index: 1300;
    width: min(280px, calc(100vw - 24px));
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(15, 23, 42, .18);
}

.column-filter-menu strong {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
}

.column-filter-list {
    display: grid;
    gap: 6px;
    max-height: 230px;
    overflow: auto;
    padding-right: 4px;
}

.column-filter-option {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text);
}

.column-filter-all {
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    font-weight: 800;
}

.column-filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.table-filter-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.table-filter-empty[hidden] {
    display: none;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}

.editable-cell {
    cursor: cell;
    position: relative;
}

.editable-cell:hover {
    background: #eff6ff;
}

.editable-cell.is-saving {
    opacity: .65;
}

.editable-cell.is-saved {
    background: #dcfce7;
}

.cell-editor {
    min-width: 140px;
    width: 100%;
    min-height: 36px;
    padding: 7px 8px;
}

.purchase-bulk-actions .bulk-stage-send {
    border-color: #f97316; background: #f97316; color: #fff;
}
.purchase-bulk-actions .bulk-stage-send:hover { background: #ea580c; }

.purchase-bulk-actions .bulk-stage-pre-stock {
    border-color: #ca8a04; background: #ca8a04; color: #fff;
}
.purchase-bulk-actions .bulk-stage-pre-stock:hover { background: #a16207; }

.purchase-bulk-actions .bulk-stage-arrived {
    border-color: #16a34a; background: #16a34a; color: #fff;
}
.purchase-bulk-actions .bulk-stage-arrived:hover { background: #15803d; }

.purchase-bulk-actions .bulk-stage-done {
    border-color: #2563eb; background: #2563eb; color: #fff;
}
.purchase-bulk-actions .bulk-stage-done:hover { background: #1d4ed8; }

.purchase-bulk-actions .bulk-stage-send svg,
.purchase-bulk-actions .bulk-stage-pre-stock svg,
.purchase-bulk-actions .bulk-stage-arrived svg,
.purchase-bulk-actions .bulk-stage-done svg { color: currentColor; }
.password-confirm-overlay {
    position: fixed; z-index: 1200; inset: 0; display: grid; place-items: center;
    padding: 16px; background: rgba(2, 6, 23, .72);
}
.password-confirm-panel {
    position: relative; width: min(420px, 100%); padding: 22px; border-radius: 14px; background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}
.password-confirm-panel h3 { margin-top: 0; }
.password-confirm-panel p { color: var(--muted); }
.password-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.password-confirm-actions button { width: 100%; }

.status-steps {
    display: inline-flex;
    gap: 6px;
    white-space: nowrap;
}

.status-step {
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    border-radius: 999px;
    font-size: 14px;
    line-height: 1;
}

.status-step.is-done {
    background: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .12);
}

.status-step.is-pending {
    background: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .11);
}

.status-step.is-saving {
    opacity: .55;
}

.status-step:disabled {
    opacity: .35;
    cursor: not-allowed;
    transform: none;
}

th {
    background: var(--panel-soft);
    color: #475569;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.sortable-head {
    position: relative;
    cursor: pointer;
    user-select: none;
    padding-right: 28px;
}

.sortable-head::after {
    content: "↕";
    position: absolute;
    right: 10px;
    top: 50%;
    color: #94a3b8;
    font-size: 11px;
    transform: translateY(-50%);
}

.sortable-head[data-sort-direction="asc"]::after {
    content: "↑";
    color: var(--primary);
}

.sortable-head[data-sort-direction="desc"]::after {
    content: "↓";
    color: var(--primary);
}

.sortable-head:focus-visible {
    outline: 3px solid rgba(30, 58, 138, .18);
    outline-offset: -3px;
}

tbody tr:hover td {
    background: #fbfdff;
}

tbody tr:has(input[type="checkbox"]:checked) td {
    background: #eff6ff;
}

tr:last-child td {
    border-bottom: 0;
}

.muted {
    color: var(--muted);
}

.table-description {
    display: block;
    max-width: 360px;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    white-space: normal;
}

.table-description-wide {
    max-width: none;
    margin-top: 0;
}

.table-detail-row td {
    padding-top: 0;
    background: #f8fafc;
    border-top: 0;
    vertical-align: middle;
}

.table-detail-row:hover td {
    background: #f8fafc;
}

.sale-product-row td:first-child {
    background: #fff;
}

.sale-product-row td:nth-child(2) {
    padding-left: 14px;
    vertical-align: middle;
}

.success {
    color: var(--success);
    font-weight: 800;
}

.warn {
    color: var(--warning);
    font-weight: 800;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 12px;
    font-weight: 900;
}

.badge-ready {
    background: #dcfce7;
    color: #166534;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-cancel {
    background: #fee2e2;
    color: #991b1b;
}

.alert {
    margin-bottom: 16px;
    padding: 13px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    font-weight: 700;
}

.alert-success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.alert-error,
.alert-danger {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.login-page {
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(30, 58, 138, .16), transparent 30%), var(--bg);
}

.login-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: min(100%, 420px);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.login-brand strong,
.login-brand span {
    display: block;
}

.login-brand span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.login-card h1 {
    margin-bottom: 8px;
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.login-form button {
    width: 100%;
}

.empty-state {
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

.invoice-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 16px;
}

.invoice-sheet {
    position: relative;
    overflow: hidden;
    max-width: 860px;
    margin: 0 auto 24px;
    padding: 42px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.invoice-sheet::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 216%;
    height: 216%;
    z-index: 0;
    background-image: url("../logo_invoice.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: .08;
    pointer-events: none;
    transform: translate(-50%, -50%) rotate(45deg);
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.invoice-sheet > * {
    position: relative;
    z-index: 1;
}

.invoice-sheet.invoice-pdf-render {
    width: 210mm;
    max-width: none;
    margin: 0;
    padding: 8mm;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.invoice-pdf-render .invoice-head {
    padding-bottom: 22px;
}

.invoice-pdf-render .invoice-grid {
    padding: 24px 0 22px;
}

.invoice-pdf-render .invoice-bank-bottom {
    margin-top: 22px;
}

.invoice-pdf-render.table-wrap {
    overflow: visible;
}

.invoice-pdf-stage {
    position: fixed;
    top: 0;
    left: -10000px;
    width: 210mm;
    overflow: visible;
    background: #fff;
    pointer-events: none;
}

.invoice-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 36px;
    padding-bottom: 28px;
    border-bottom: 2px solid #101828;
}

.pickup-date-head {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 2px solid #101828;
}

.pickup-date-head span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.pickup-date-head strong {
    display: block;
    font-size: 22px;
}

.invoice-brand {
    font-size: 24px;
    line-height: 1.1;
    font-weight: 900;
}

.invoice-address {
    max-width: 500px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
}

.invoice-phone {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.invoice-meta {
    min-width: 220px;
    text-align: right;
}

.invoice-meta span,
.invoice-label {
    display: block;
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.invoice-meta strong {
    display: block;
    font-size: 18px;
    line-height: 1.25;
}

.invoice-grid {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 40px;
    padding: 30px 0 26px;
}

.invoice-label-spaced {
    margin-top: 22px;
}

.invoice-grid strong {
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
}

.invoice-grid p {
    max-width: 560px;
    margin-bottom: 6px;
    line-height: 1.55;
}

.invoice-bank {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(248, 250, 252, .72);
    backdrop-filter: blur(1px);
}

.invoice-bank .invoice-label {
    margin-bottom: 8px;
}

.invoice-bank strong,
.invoice-bank span {
    display: block;
}

.invoice-bank .invoice-bank-account {
    margin-top: 3px;
    letter-spacing: .04em;
}
.invoice-bank span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.invoice-note-box {
    margin-bottom: 20px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.invoice-note-box p:last-child {
    margin-bottom: 0;
}

.invoice-table {
    margin-top: 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.invoice-table table {
    min-width: 620px;
    background: transparent;
}

.invoice-table th,
.invoice-table td {
    padding: 13px 14px;
    background: transparent;
}

.invoice-table th {
    border-top: 1px solid #101828;
    border-bottom: 1px solid #101828;
    color: #172033;
}

.invoice-table tbody tr:hover td {
    background: transparent;
}

.invoice-imei-line {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.invoice-table-total-row td {
    padding-top: 16px;
    padding-bottom: 16px;
    border-top: 2px solid #101828;
    background: transparent;
    font-weight: 900;
}

.invoice-table-total-row td:first-child {
    text-align: right;
    color: var(--muted);
    text-transform: uppercase;
}

.invoice-bank-bottom {
    margin-top: 24px;
}

.invoice-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 28px;
    font-size: 15px;
}

.invoice-total span {
    color: var(--muted);
    font-weight: 900;
    text-transform: uppercase;
}

.invoice-total strong {
    font-size: 22px;
}

.invoice-footer-note {
    margin-top: 38px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    text-align: center;
}

.invoice-footer-note p {
    margin-bottom: 0;
}

.balance-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 12px;
    margin: 18px 0;
}
.balance-metrics > div {
    padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft);
}
.balance-metrics span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
.balance-metrics strong { display: block; font-size: clamp(17px, 2vw, 24px); }
.balance-metrics .balance-main-metric {
    border-color: rgba(37, 99, 235, .24); background: linear-gradient(135deg, #eff6ff, #eef2ff);
}
.balance-metrics .balance-main-metric strong { color: #1d4ed8; }
.balance-metrics .danger, .report-balance-history .danger { color: #dc2626; }
.balance-form-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
}
.balance-form-panel {
    padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.balance-form-panel h4 { margin: 0 0 6px; }
.balance-form-panel button { margin-top: 4px; }
.report-balance-history {
    display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 16px; margin-bottom: 16px;
}
.report-balance-history .card { min-width: 0; margin-bottom: 0; }

@media (max-width: 980px) {
    .balance-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-balance-history { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .balance-metrics, .balance-form-grid { grid-template-columns: 1fr; }
    .balance-form-panel { padding: 14px; }
}

.report-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.report-chart-card {
    min-width: 0;
    overflow: hidden;
}

.report-visual-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(260px, .8fr) minmax(260px, .8fr);
    gap: 16px;
    margin-bottom: 18px;
}

.report-visual-card {
    min-width: 0;
    overflow: hidden;
}

.report-line-card {
    grid-row: span 1;
}

.chart-legend-inline,
.report-line-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 999px;
    vertical-align: -1px;
}

.legend-dot.blue { background: #2563eb; }
.legend-dot.green { background: #16a34a; }

.report-line-chart-wrap {
    overflow-x: auto;
    padding: 10px 0 2px;
}

.report-line-chart {
    display: block;
    width: 100%;
    min-width: 680px;
    height: auto;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(248, 250, 252, .95), rgba(255, 255, 255, .96));
}

.report-line-grid {
    stroke: #e2e8f0;
    stroke-width: 1;
}

.report-line-zero {
    stroke: #94a3b8;
    stroke-width: 1.5;
    stroke-dasharray: 6 8;
}

.report-line {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.report-line.sales { stroke: #2563eb; }
.report-line.profit { stroke: #16a34a; }

.report-line-area {
    stroke: none;
    opacity: .9;
}

.report-line-area.sales { fill: url(#salesLineFill); }
.report-line-area.profit { fill: url(#profitLineFill); }

.report-line-label {
    fill: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.report-line-summary {
    justify-content: space-between;
    padding-top: 8px;
}

.donut-layout {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
}

.donut-chart {
    position: relative;
    display: grid;
    width: 154px;
    height: 154px;
    place-items: center;
    border-radius: 50%;
    background: var(--donut, conic-gradient(#e5e7eb 0 360deg));
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .06), 0 16px 34px rgba(15, 23, 42, .08);
}

.donut-chart::after {
    position: absolute;
    inset: 28px;
    border-radius: 50%;
    background: #fff;
    content: '';
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .06);
}

.donut-chart strong,
.donut-chart span {
    position: relative;
    z-index: 1;
    display: block;
    text-align: center;
}

.donut-chart strong {
    color: #0f172a;
    font-size: 28px;
    line-height: 1;
}

.donut-chart span {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.donut-legend {
    display: grid;
    gap: 9px;
    min-width: 0;
}

.donut-legend span {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

.donut-legend i {
    display: inline-block;
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.donut-legend strong {
    margin-left: auto;
    color: #0f172a;
}

.donut-legend small {
    color: var(--muted);
    font-size: 11px;
}

.report-chart-scroll {
    overflow-x: auto;
    padding: 12px 4px 2px;
}

.report-bar-chart,
.report-profit-chart {
    display: grid;
    grid-template-columns: repeat(var(--chart-columns), minmax(48px, 1fr));
    align-items: end;
    min-width: max(100%, calc(var(--chart-columns) * 58px));
    height: 250px;
    padding-top: 24px;
}

.report-bar-column,
.report-profit-column {
    position: relative;
    display: flex;
    height: 100%;
    align-items: center;
    flex-direction: column;
    justify-content: flex-end;
    gap: 7px;
    padding: 0 5px;
}

.report-bar {
    width: min(30px, 72%);
    min-height: 0;
    border-radius: 7px 7px 2px 2px;
    transition: filter .18s ease, transform .18s ease;
}

.report-bar-column:hover .report-bar,
.report-profit-column:hover .report-bar {
    filter: brightness(.92);
    transform: scaleX(1.08);
}

.report-bar-sales {
    background: linear-gradient(180deg, #2563eb, #1e3a8a);
    box-shadow: 0 8px 18px rgba(30, 58, 138, .2);
}

.report-bar-value {
    max-width: 56px;
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-bar-column small,
.report-profit-column small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.report-profit-chart {
    position: relative;
    align-items: stretch;
    padding-top: 0;
}

.report-zero-line {
    position: absolute;
    top: calc(50% - 8px);
    right: 0;
    left: 0;
    height: 1px;
    background: var(--line);
}

.report-profit-column {
    display: grid;
    grid-template-rows: 1fr 1fr 16px;
    gap: 0;
}

.report-profit-half {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.report-profit-positive {
    justify-content: flex-end;
}

.report-profit-negative {
    justify-content: flex-start;
}

.report-bar-positive {
    min-height: 8px;
    background: linear-gradient(180deg, #22c55e, #15803d);
    box-shadow: 0 6px 14px rgba(21, 128, 61, .2);
}

.report-bar-negative {
    min-height: 8px;
    border-radius: 2px 2px 7px 7px;
    background: linear-gradient(180deg, #dc2626, #f87171);
    box-shadow: 0 6px 14px rgba(220, 38, 38, .18);
}

.barcode-scanner-overlay { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(2, 6, 23, .78); }
.barcode-scanner-panel { position: relative; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px; border-radius: 14px; background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, .35); }
.barcode-scanner-panel > .icon-btn { position: absolute; z-index: 2; top: 12px; right: 12px; }
.barcode-camera { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border-radius: 10px; background: #020617; }
.barcode-camera video,
.barcode-camera canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.barcode-camera canvas[hidden],
.barcode-camera video[hidden] { display: none; }
.product-photo-camera canvas { background: #020617; }
.product-photo-preview-label { position: absolute; left: 10px; bottom: 10px; padding: 5px 9px; border-radius: 999px; background: rgba(15, 23, 42, .82); color: #fff; font-size: 12px; font-weight: 800; }
.product-photo-preview-label[hidden] { display: none; }
.barcode-scan-line { position: absolute; top: 50%; right: 8%; left: 8%; height: 2px; background: #22c55e; box-shadow: 0 0 12px #22c55e; }
.barcode-scanner-status { margin: 12px 0 0; color: var(--muted); text-align: center; font-weight: 700; }
.barcode-imei-fields {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
    max-height: 220px; margin-top: 12px; overflow-y: auto;
}
.serial-ocr-hint { margin: -4px 0 12px; color: var(--muted); font-size: 13px; }
.serial-ocr-camera::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: rgba(2, 6, 23, .24);
}
.serial-ocr-frame {
    position: absolute; z-index: 2; top: 50%; left: 50%; width: 86%; height: 28%;
    transform: translate(-50%, -50%); border: 3px solid #22c55e; border-radius: 10px;
    box-shadow: 0 0 0 999px rgba(2, 6, 23, .38), 0 0 18px rgba(34, 197, 94, .9);
    pointer-events: none;
}
.serial-ocr-frame > span {
    position: absolute; bottom: -28px; left: 50%; transform: translateX(-50%);
    padding: 3px 8px; border-radius: 5px; background: #22c55e; color: #052e16;
    font-size: 10px; font-weight: 900; white-space: nowrap;
}
.serial-ocr-capture { width: 100%; margin-top: 12px; }
.serial-ocr-preview { display: block; width: 100%; max-height: 150px; margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; object-fit: contain; background: #0f172a; }
.serial-ocr-preview[hidden] { display: none; }
.serial-ocr-panel input { text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .08em; }
.barcode-imei-fields label { margin: 0; font-size: 12px; }
.barcode-imei-fields input { width: 100%; margin-top: 5px; }
.barcode-scanner-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.product-photo-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.product-photo-actions [disabled] { opacity: .55; cursor: not-allowed; }
.barcode-scanner-actions button { width: 100%; }
@media (max-width: 640px) { .barcode-imei-fields { grid-template-columns: 1fr; } }


@media (max-width: 980px) {
    .report-chart-grid,
    .report-visual-grid,
    .overview-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .overview-card-grid { grid-template-columns: 1fr; }
    .overview-card.wide { grid-column: auto; }

    .donut-layout {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: left;
    }

    .donut-legend {
        width: 100%;
    }

    .report-line-summary {
        justify-content: flex-start;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 64px minmax(0, 1fr);
    }

    .app-shell.sidebar-expanded {
        grid-template-columns: minmax(210px, 240px) minmax(0, 1fr);
    }

    .sidebar {
        position: sticky;
        height: 100vh;
        padding: 14px 8px;
    }

    .app-shell.sidebar-expanded .sidebar {
        padding: 18px 14px;
    }

    .nav {
        grid-template-columns: 1fr;
    }

    .grid,
    .grid2,
    .summary,
    .flow {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-insights,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .insight-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .single-purchase-layout {
        grid-template-columns: 1fr;
    }

    .single-order-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sale-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .order-note-field {
        grid-column: 1 / -1;
    }

    .single-item-pane {
        position: static;
    }

    .batch-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .batch-toolbar-actions {
        grid-column: 1 / -1;
        justify-self: end;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 14px;
        overflow-x: hidden;
    }

    body.mobile-menu-open {
        overflow: hidden;
    }

    .app-shell,
    .app-shell.sidebar-expanded {
        display: block;
        min-height: 100vh;
    }

    .sidebar,
    .app-shell.sidebar-expanded .sidebar {
        position: fixed;
        z-index: 50;
        inset: 0 auto 0 0;
        width: min(82vw, 292px);
        height: 100dvh;
        padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform .22s ease;
        box-shadow: 18px 0 45px rgba(2, 6, 23, .24);
    }

    .app-shell.sidebar-expanded .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 40;
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        min-height: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: rgba(15, 23, 42, .48);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .22s ease, visibility .22s ease;
    }

    .sidebar-backdrop:hover {
        background: rgba(15, 23, 42, .48);
        transform: none;
    }

    .app-shell.sidebar-expanded .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .brand,
    .app-shell.sidebar-expanded .brand {
        justify-content: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }

    .brand-text,
    .nav span,
    .app-shell.sidebar-expanded .brand-text,
    .app-shell.sidebar-expanded .nav span {
        width: auto;
        opacity: 1;
    }

    .brand-text {
        min-width: 0;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
    }

    .nav {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .nav a {
        justify-content: flex-start;
        gap: 10px;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 14px;
    }

    .app-shell.sidebar-expanded .nav a {
        justify-content: flex-start;
        gap: 10px;
    }

    .sidebar-profile,
    .app-shell.sidebar-expanded .sidebar-profile {
        grid-template-columns: 42px minmax(0, 1fr) 40px;
        justify-content: stretch;
        align-items: center;
    }

    .profile-meta,
    .app-shell.sidebar-expanded .profile-meta {
        display: block;
    }

    .main {
        width: 100%;
        min-width: 0;
        padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }

    .login-shell {
        min-height: 100dvh;
        padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    }

    .login-card {
        padding: 22px 18px;
    }

    .topbar {
        display: grid;
        gap: 12px;
        margin-bottom: 16px;
    }

    .topbar-title {
        align-items: center;
        min-width: 0;
    }

    .topbar-title > div {
        min-width: 0;
    }

    .sidebar-toggle {
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        min-height: 44px;
    }

    .topbar-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .topbar-actions .btn {
        width: 100%;
        min-width: 0;
    }

    button,
    .btn {
        min-height: 44px;
    }

    input,
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
    }

    .grid,
    .grid2,
    .single-order-grid,
    .sale-detail-grid,
    .summary,
    .flow,
    .insight-metrics {
        grid-template-columns: 1fr;
    }

    .mode-hero,
    .batch-table-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .mode-badge {
        min-width: 0;
    }

    .single-order-pane,
    .single-item-pane,
    .batch-workspace,
    .mode-hero {
        padding: 14px;
    }

    .featured-product-box {
        grid-template-columns: 1fr;
    }

    .product-glyph {
        width: 46px;
        height: 46px;
    }

    .batch-toolbar {
        grid-template-columns: 1fr;
    }

    .batch-toolbar-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-self: stretch;
    }

    .batch-toolbar-actions .btn { width: 100%; }

    .pickup-filter-form {
        grid-template-columns: 1fr;
    }

    .pickup-filter-form .pickup-print-options {
        grid-column: auto;
    }

    .pickup-print-options {
        align-items: stretch;
        flex-direction: column;
    }

    .pickup-action-buttons {
        width: 100%;
        flex-direction: column;
        margin-left: 0;
    }

    .pickup-print-options button {
        width: 100%;
    }

    .pickup-print-options button.icon-btn {
        width: 44px;
    }

    .summary {
        gap: 10px;
    }

    .card,
    .box {
        padding: 14px 12px;
        margin-bottom: 12px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, .07);
    }

    h1 {
        max-width: 100%;
        overflow-wrap: anywhere;
        font-size: 21px;
    }

    h3 {
        margin-bottom: 12px;
    }

    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .section-heading .btn,
    .section-heading button {
        width: 100%;
    }

    .actions {
        width: 100%;
    }

    .actions .btn,
    .actions button,
    .inline-form,
    .inline-form button {
        width: 100%;
    }

    .table-actions,
    .table-actions .inline-form,
    .table-actions .inline-form button {
        width: auto;
    }

    .purchase-bulk-actions {
        margin-bottom: 14px;
        padding-bottom: 14px;
    }

    .status-steps {
        gap: 4px;
    }

    .status-step {
        width: 28px;
        min-width: 28px;
        height: 28px;
        min-height: 28px;
    }

    .table-filter-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .table-filter-input {
        width: 100%;
    }

    .table-filter-count {
        white-space: normal;
    }

    .stock-unit-picker {
        grid-template-columns: 1fr;
        min-width: 220px;
    }

    .tabs {
        display: flex;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .tab-button {
        flex: 1 0 max-content;
        min-height: 44px;
    }

    .table-wrap {
        max-width: 100%;
        scrollbar-color: #94a3b8 #e2e8f0;
        scrollbar-width: thin;
    }

    .table-wrap::-webkit-scrollbar {
        height: 8px;
    }

    .table-wrap::-webkit-scrollbar-track {
        background: #e2e8f0;
    }

    .table-wrap::-webkit-scrollbar-thumb {
        border-radius: 8px;
        background: #94a3b8;
    }

    th,
    td {
        padding: 9px 10px;
        white-space: nowrap;
    }

    td {
        max-width: 220px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .table-actions {
        gap: 6px;
    }

    .table-actions .btn,
    .table-actions button,
    .status-step {
        min-height: 36px;
    }

    .status-step {
        width: 36px;
        min-width: 36px;
        height: 36px;
    }

    .editable-cell.is-editing {
        min-width: 180px;
    }

    .invoice-sheet {
        padding: 18px;
        width: 100%;
        margin-bottom: 12px;
    }

    .invoice-head,
    .invoice-grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .invoice-head {
        gap: 18px;
        padding-bottom: 20px;
    }

    .invoice-grid {
        gap: 18px;
        padding: 22px 0;
    }

    .invoice-meta {
        text-align: left;
        min-width: 0;
    }

    .invoice-total {
        justify-content: space-between;
        gap: 12px;
    }

}

@media (max-width: 420px) {
    .nav {
        grid-template-columns: 1fr;
    }

    .topbar-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar-actions .btn {
        padding-right: 10px;
        padding-left: 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    .box b,
    .invoice-total strong,
    .pickup-date-head strong {
        font-size: 19px;
    }

    table {
        min-width: 680px;
    }

    .invoice-table table {
        min-width: 560px;
    }
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .invoice-toolbar {
        display: none;
    }

    .app-shell {
        display: block;
        min-height: auto;
    }

    .main {
        padding: 0;
    }

    .invoice-sheet {
        max-width: none;
        margin: 0;
        padding: 8mm;
        border: 0;
        box-shadow: none;
    }

    .invoice-head {
        padding-bottom: 22px;
    }

    .invoice-grid {
        padding: 24px 0 22px;
    }

    .invoice-bank-bottom {
        margin-top: 22px;
    }

    .table-wrap {
        overflow: visible;
    }

    .btn,
    button {
        display: none;
    }
}


.owner-income-detail-toggle summary {
    cursor: pointer;
    color: var(--primary);
    list-style: none;
}

.owner-income-detail-toggle summary::-webkit-details-marker {
    display: none;
}

.owner-income-detail-toggle summary::after {
    content: "Lihat detail";
    display: inline-flex;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 11px;
    font-weight: 700;
}

.owner-income-detail-toggle[open] summary::after {
    content: "Tutup";
}

.owner-income-detail-panel {
    margin-top: 10px;
    min-width: 620px;
}



.owner-income-detail-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.owner-income-detail-actions .btn-small {
    padding: 7px 10px;
    font-size: 12px;
}

.owner-income-mini-table {
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: none;
}

.owner-income-mini-table table {
    min-width: 720px;
}

.owner-income-mini-table th,
.owner-income-mini-table td {
    padding: 8px 10px;
    font-size: 12px;
}

.purchase-row-sold > td {
    background: #dcfce7 !important;
}

.purchase-row-partial-sold > td {
    background: #fef3c7 !important;
}


.executive-dashboard {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.executive-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(37, 99, 235, .16);
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, .18), transparent 34%),
        linear-gradient(135deg, #ffffff 0%, #f8fbff 52%, #f4f7ff 100%);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: #2563eb;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.executive-kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.executive-kpis > div,
.executive-notes > div {
    position: relative;
    overflow: hidden;
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, .25);
    border-radius: 16px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}

.executive-kpis span,
.executive-notes span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.executive-kpis strong {
    display: block;
    font-size: clamp(18px, 2.2vw, 27px);
    line-height: 1.1;
}

.executive-kpis small,
.executive-notes small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.executive-notes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.executive-notes strong {
    display: block;
    font-size: 18px;
}

.overview-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.overview-card {
    position: relative;
    overflow: hidden;
    min-height: 132px;
    border: 1px solid rgba(37, 99, 235, .12);
    background: linear-gradient(180deg, #fff, #f8fbff);
}

.overview-card::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, #2563eb, #22c55e);
    content: '';
}

.overview-card span {
    display: block;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.overview-card strong {
    display: block;
    color: #0f172a;
    font-size: clamp(18px, 2vw, 25px);
    line-height: 1.1;
}

.overview-card small {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
}

.overview-card.wide {
    grid-column: span 2;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.analytics-card {
    min-width: 0;
}

.section-heading.compact {
    margin-bottom: 12px;
}

.rank-list {
    display: grid;
    gap: 11px;
}

.rank-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
}

.rank-item > b {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    color: #1d4ed8;
    background: #dbeafe;
    font-size: 13px;
}

.rank-item strong {
    display: block;
    line-height: 1.25;
}

.rank-item small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-weight: 700;
}

.rank-bar {
    display: block;
    height: 8px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.rank-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.rank-bar.blue i {
    background: linear-gradient(90deg, #38bdf8, #2563eb);
}

.rank-bar.violet i {
    background: linear-gradient(90deg, #a78bfa, #6366f1);
}

.rank-bar.amber i {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}



@media (max-width: 1100px) {
    .executive-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .analytics-grid,
    .executive-notes {
        grid-template-columns: 1fr;
    }

    .executive-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .executive-kpis {
        grid-template-columns: 1fr;
    }

    .rank-item {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .rank-item > b {
        width: 28px;
        height: 28px;
    }
}
.product-photo-ocr-panel { max-width: min(560px, calc(100vw - 24px)); }
.product-photo-ocr-fields { display: grid; gap: 10px; margin-top: 12px; }
.product-photo-ocr-fields[hidden] { display: none; }
.product-photo-ocr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.product-photo-ocr-row input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .06em; }
@media (max-width: 520px) {
    .product-photo-ocr-row { grid-template-columns: 1fr; }
}
.product-photo-camera { position: relative; }
.product-photo-ocr-frame {
    position: absolute;
    left: 4%;
    right: 4%;
    top: 24%;
    height: 52%;
    border: 2px solid #22c55e;
    border-radius: 14px;
    box-shadow: 0 0 0 999px rgba(15, 23, 42, .28);
    pointer-events: none;
    display: grid;
    place-items: start center;
    padding-top: 8px;
}
.product-photo-ocr-frame span {
    background: rgba(15, 23, 42, .78);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 4px 8px;
    border-radius: 999px;
}
.product-photo-camera canvas:not([hidden]) ~ .product-photo-ocr-frame,
.product-photo-camera video[hidden] ~ .product-photo-ocr-frame {
    display: none;
}
