:root {
    --bg: #0f0f14;
    --surface: #1c1c28;
    --surface2: #252535;
    --toolbar: #1a1a2e;
    --text: #EAEAEF;
    --text2: #8888a0;
    --text3: #555570;
    --border: #2a2a3c;
    --blue: #4d8df7;
    --green: #00d68f;
    --red: #ff3d71;
    --yellow: #ffcb2d;
    --orange: #ff9f43;
    --shopee: #EE4D2D;
    --tiktok: #FFFFFF;
    --lazada: #1A9CB7;
    --radius: 12px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: #16172b; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

/* ══ Layout ══ */
.header {
    background: linear-gradient(135deg, #16172b 0%, #1a2240 100%);
    padding: 10px 16px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(77,141,247,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}
.header h1 { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; background: linear-gradient(135deg, #4d8df7, #00d68f); -webkit-background-clip: text; -webkit-text-fill-color: transparent; user-select: none; }
.header-actions { display: flex; gap: 8px; align-items: center; user-select: none; }
.header * { cursor: default; }
.header a, .header button, .header svg, .header input { cursor: pointer; }

.container { padding: 12px; max-width: 800px; margin: 0 auto; }

/* ══ Bottom Tab Bar (mobile style) ══ */
.nav-bar {
    display: flex;
    background: linear-gradient(0deg, #0d0d18 0%, #141425 100%);
    border-top: 1px solid rgba(77,141,247,0.1);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    box-shadow: 0 -2px 16px rgba(0,0,0,0.4);
}
.nav-btn {
    flex: 1;
    padding: 10px 0 6px;
    text-align: center;
    color: var(--text3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}
.nav-svg {
    width: 22px; height: 22px; fill: currentColor;
    transition: transform 0.2s;
}
.nav-btn.active { color: var(--blue); }
.nav-btn.active .nav-svg { transform: scale(1.1); }

/* ══ Pull to Refresh ══ */
.ptr-indicator {
    text-align: center; padding: 0; overflow: hidden;
    height: 0; transition: height 0.2s;
    color: var(--text2); font-size: 12px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.ptr-indicator.pulling { height: 40px; }
.ptr-indicator.refreshing { height: 40px; }
.ptr-indicator .ptr-arrow {
    display: inline-block; transition: transform 0.2s;
    font-size: 16px;
}
.ptr-indicator.ready .ptr-arrow { transform: rotate(180deg); }
.ptr-indicator.refreshing .ptr-arrow { animation: spin 0.8s linear infinite; }

/* Space for bottom bar */
.container { padding-bottom: calc(80px + env(safe-area-inset-bottom, 16px)); }

/* ══ Filters ══ */
.filter-bar {
    display: flex;
    gap: 6px;
    padding: 10px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; }
.chip {
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 12px;
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text2);
    cursor: pointer;
    transition: all 0.25s;
    font-weight: 500;
}
.chip b {
    color: var(--yellow);
    font-size: 11px;
    margin-left: 3px;
}
.chip.active {
    background: linear-gradient(135deg, var(--blue), #3a6fd8);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(77,141,247,0.3);
}
.chip.active b { color: #fff; }

.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.search-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(77,141,247,0.15); }
.search-input::placeholder { color: var(--text3); }

/* Search with clear button */
.search-wrap { position: relative; flex: 1; }
.search-wrap .search-input { width: 100%; padding-right: 32px; }
.search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--text3); color: var(--bg); border: none;
    font-size: 11px; cursor: pointer; display: none;
    align-items: center; justify-content: center; line-height: 1;
}
.search-wrap .search-input:not(:placeholder-shown) + .search-clear { display: flex; }

select.filter-select {
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    outline: none;
    -webkit-appearance: none;
}

/* ══ Order Card ══ */
.order-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.order-card:active { border-color: var(--blue); transform: scale(0.99); }
.order-top {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
}
.order-img {
    width: 72px;
    height: 72px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg);
    flex-shrink: 0;
}
.order-info { flex: 1; min-width: 0; }
.order-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.order-code {
    font-weight: 600;
    font-size: 13px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.order-channel {
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 4px;
}
.order-note {
    font-size: 12px;
    color: #E0D8C8;
    line-height: 1.4;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.order-money {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text2);
}
.order-money b { color: var(--text); }

/* ══ Cards (generic) ══ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.card:active { border-color: var(--blue); transform: scale(0.99); }

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}
.status-dot.printed { background: var(--green); color: var(--green); }
.status-dot.pending { background: var(--yellow); color: var(--yellow); }
.status-dot.draft { background: var(--orange); color: var(--orange); }
.status-dot.refund { background: var(--red); color: var(--red); }

.card-code {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}
.card-source {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}
.source-shopee { background: #EE4D2D22; color: var(--shopee); border: 1px solid #EE4D2D33; }
.source-tiktok { background: #2a2a3c; color: #fff; border: 1px solid #444; }
.source-lazada { background: #1A9CB722; color: var(--lazada); border: 1px solid #1A9CB733; }
.source-tiki { background: #1A94FF22; color: #5BAAFF; border: 1px solid #1A94FF33; }
.source-other { background: #8BC34A22; color: #8BC34A; border: 1px solid #8BC34A33; }

.card-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text2);
    margin-top: 4px;
}
.card-row .value { color: var(--text); font-weight: 500; }
.card-products {
    font-size: 12px;
    color: var(--text2);
    margin-top: 6px;
    line-height: 1.5;
}

/* Profit colors */
.profit-high { color: #00d68f; }
.profit-mid { color: #ffcb2d; }
.profit-low { color: #ff9f43; }
.profit-loss { color: #ff3d71; }

/* ══ Product Card ══ */
.product-card {
    display: flex;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
}
.product-img {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg);
    flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.product-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.badge {
    font-size: 11px;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    font-weight: 600;
}
.badge-sku { background: #9B59B620; color: #CDA4F3; }
.badge-stock { background: #00d68f20; color: var(--green); }
.badge-sold { background: #4d8df720; color: #8AB8FF; }
.badge-price { background: #ffcb2d20; color: var(--yellow); }
.badge-warning { background: #ff3d7120; color: var(--red); }

/* ══ Detail Page ══ */
.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
    background: linear-gradient(135deg, #16172b 0%, #1a2240 100%);
    border-bottom: 1px solid rgba(77,141,247,0.15);
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}
.back-btn {
    font-size: 20px;
    color: var(--text);
    text-decoration: none;
    padding: 4px;
    cursor: pointer;
}
.detail-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    border-bottom: 1px solid #333;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text2); }
.detail-value { font-weight: 500; }

/* ══ Pagination ══ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
}
.page-btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}
.page-btn:disabled { opacity: 0.3; cursor: default; }
.page-info {
    font-size: 13px;
    color: var(--text2);
    padding: 8px 14px;
    background: var(--surface);
    border-radius: var(--radius);
}

/* ══ Login ══ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
}
.login-box {
    background: linear-gradient(145deg, var(--surface) 0%, #161630 100%);
    border: 1px solid rgba(77,141,247,0.2);
    border-radius: 20px;
    padding: 40px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.login-box h2 {
    text-align: center;
    margin-bottom: 28px;
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, #4d8df7, #00d68f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.form-group { margin-bottom: 16px; }
.form-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.form-input:focus { border-color: var(--blue); }
.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #4d8df7, #3a6fd8);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 4px 12px rgba(77,141,247,0.3);
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; box-shadow: none; }
.error-msg { color: var(--red); font-size: 13px; text-align: center; margin-top: 12px; }

/* ══ Loading ══ */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text2);
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ Skeleton Loading ══ */
.skeleton-wrap { padding: 8px 0; }
.skeleton-line {
    height: 14px; border-radius: 6px; margin-bottom: 10px;
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.skeleton-card {
    height: 70px; border-radius: var(--radius);
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ══ Stats bar ══ */
.stats-bar {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text2);
}
.stats-bar .stat { padding: 4px 10px; background: var(--surface); border-radius: var(--radius-sm); }
.stats-bar .stat b { color: var(--yellow); }

/* ══ Inventory ══ */
.inv-group { margin-bottom: 12px; }
.inv-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--toolbar);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 13px;
}
.inv-bill { font-weight: 600; color: var(--yellow); }
.inv-sum { color: var(--text2); font-size: 12px; }
.inv-item {
    border: 1px solid var(--border);
    border-top: none;
    background: var(--surface);
    padding: 10px 12px;
}
.inv-item:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.inv-item-top { display: flex; gap: 10px; }
.inv-img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg);
    flex-shrink: 0;
}
.inv-item-info { flex: 1; min-width: 0; }
.inv-item-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.inv-item-meta { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; align-items: center; }
.inv-item-prices {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 2px;
}
.inv-item-prices b { color: var(--text); }
.inv-item-total { font-size: 12px; color: var(--text2); }
.inv-item-total b { color: var(--yellow); }
.inv-item-note { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ══ Pricing Card ══ */
.price-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
}
.price-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.price-sku { font-size: 11px; color: var(--text2); margin-bottom: 8px; }
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.price-item { display: flex; justify-content: space-between; font-size: 12px; }
.price-label { color: var(--text2); }
.price-val { font-weight: 600; }

/* ══ Dashboard / Report ══ */
.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.15s;
}
.report-card:active { transform: scale(0.97); }
.report-card.dash-accent {
    border-color: rgba(77,141,247,0.2);
    background: linear-gradient(145deg, #161630, #1a2240);
    box-shadow: 0 2px 16px rgba(77,141,247,0.1);
}
.report-num { font-size: 17px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.5px; }
.report-label { font-size: 10px; color: var(--text2); font-weight: 500; }
.dash-title { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; margin-top: 16px; }
.dash-date-bar { display: flex; align-items: center; gap: 4px; margin: 12px 0; }

/* ══ Draft delete ══ */
.draft-action-btn {
    width: 24px; height: 24px; border-radius: 50%; border: none;
    background: #0078D422; color: var(--blue); font-size: 14px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.draft-action-btn.draft-del { background: #E74C3C22; color: #E74C3C; }
.btn-delete {
    padding: 10px 24px; border-radius: var(--radius); border: 1px solid #E74C3C33;
    background: #E74C3C1A; color: #E74C3C; font-size: 14px; cursor: pointer; font-weight: 500;
}

.header-text-btn {
    padding: 5px 10px; border-radius: 6px; border: 1px solid var(--blue);
    background: var(--blue); color: #fff; font-size: 10px; font-weight: 700;
    cursor: pointer; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.5px;
    display: inline-flex; align-items: center; gap: 4px;
}
.header-text-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* ══ Create Order Form ══ */
.header-add-btn {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--blue); color: #fff; border: none;
    font-size: 16px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.form-label { font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.form-textarea {
    width: 100%; padding: 10px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg); color: var(--text);
    font-size: 14px; outline: none; resize: vertical; font-family: inherit;
}
.form-textarea:focus { border-color: var(--blue); }

.autocomplete-wrap { position: relative; margin-bottom: 12px; }
.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 250px; overflow-y: auto;
    display: none;
}
.autocomplete-list:not(:empty) { display: block; }
.ac-item {
    padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #333;
    transition: background 0.1s;
}
.ac-item:active { background: #333; }
.ac-item:last-child { border-bottom: none; }
.ac-name { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.ac-meta { display: flex; gap: 4px; flex-wrap: wrap; }
.ac-empty { padding: 12px; color: var(--text2); font-size: 13px; text-align: center; }

.draft-item {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px; margin-bottom: 8px;
}
.draft-item-top { display: flex; justify-content: space-between; align-items: flex-start; }
.draft-item-info { flex: 1; }
.draft-item-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.draft-item-meta { display: flex; gap: 4px; }
.draft-remove {
    width: 28px; height: 28px; border-radius: 50%;
    background: #33E74C3C; border: none; color: var(--red);
    font-size: 14px; cursor: pointer; flex-shrink: 0;
}
.draft-item-bottom {
    display: flex; align-items: center; gap: 8px; margin-top: 8px;
    font-size: 13px;
}
.draft-qty { display: flex; align-items: center; gap: 4px; }
.draft-qty label { color: var(--text2); font-size: 12px; }
.draft-qty-input {
    width: 50px; padding: 4px 6px; border-radius: 4px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-size: 13px; text-align: center;
}
.draft-note-input {
    flex: 1; padding: 4px 6px; border-radius: 4px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-size: 12px;
}
.draft-subtotal { font-weight: 600; color: var(--yellow); white-space: nowrap; }
.draft-total { font-size: 14px; margin-top: 8px; text-align: right; }

/* ══ Inventory Modal ══ */
.inv-modal-overlay {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.inv-modal {
    background: var(--surface); border-radius: 12px; padding: 20px;
    width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.inv-status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.inv-status-btn {
    padding: 10px; border-radius: 6px; border: 2px solid var(--border);
    background: var(--bg); color: var(--text2); font-size: 13px;
    cursor: pointer; text-align: center; font-weight: 500;
    transition: all 0.2s;
}
.inv-status-btn.active {
    border-color: var(--sc); color: var(--sc);
    background: color-mix(in srgb, var(--sc) 15%, var(--bg));
    font-weight: 700;
}

/* ══ Quotation Table ══ */
.quote-table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; }
.qt-header, .qt-row { display: flex; align-items: center; padding: 6px 8px; font-size: 12px; border-bottom: 1px solid var(--border); }
.qt-header { background: var(--toolbar); font-weight: 600; color: var(--text2); font-size: 11px; }
.qt-row:last-child { border-bottom: none; }
.qt-num { width: 28px; text-align: center; flex-shrink: 0; }
.qt-name { flex: 2; min-width: 0; }
.qt-qty { width: 55px; flex-shrink: 0; }
.qt-unit { width: 50px; flex-shrink: 0; }
.qt-price { width: 75px; flex-shrink: 0; }
.qt-total { width: 80px; text-align: right; flex-shrink: 0; font-weight: 600; color: var(--yellow); }
.qt-del { width: 28px; flex-shrink: 0; text-align: center; }
.qt-input {
    width: 100%; padding: 4px 6px; border-radius: 3px;
    border: 1px solid transparent; background: transparent;
    color: var(--text); font-size: 12px; outline: none;
}
.qt-input:focus { border-color: var(--blue); background: var(--bg); }
.qt-input-name { font-weight: 500; }
.qt-input-num { text-align: center; width: 100%; }
.qt-input-sm { text-align: center; width: 100%; }

/* ══ Compact Date Picker ══ */
.date-compact {
    display: flex; align-items: center; gap: 2px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 2px;
}
.date-nav {
    width: 28px; height: 28px; border: none; background: transparent;
    color: var(--text2); font-size: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px; transition: background 0.15s;
}
.date-nav:active { background: var(--border); }
.date-label {
    position: relative; cursor: pointer;
    font-size: 13px; font-weight: 600; color: var(--text);
    padding: 4px 6px; min-width: 44px; text-align: center;
}
.date-hidden {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
    width: 100%; height: 100%;
}

/* ══ Header Icons ══ */
.header-icon {
    width: 28px; height: 28px; fill: #9E9E9E; cursor: pointer;
    transition: fill 0.2s;
    padding: 4px;
    min-width: 36px; min-height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    -webkit-tap-highlight-color: transparent;
}
.header-icon:active { background: rgba(255,255,255,0.1); }
.header-icon:hover { fill: var(--blue); }

/* ══ User Menu ══ */
.user-menu-wrap { position: relative; }
.user-menu {
    position: absolute; top: 32px; right: 0; z-index: 300;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; min-width: 160px; overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.user-menu-name { padding: 12px 14px 2px; font-size: 14px; font-weight: 600; }
.user-menu-role { padding: 0 14px 10px; font-size: 11px; color: var(--text2); border-bottom: 1px solid var(--border); }
.user-menu-item {
    padding: 10px 14px; font-size: 13px; cursor: pointer;
    transition: background 0.15s;
}
.user-menu-item:active { background: var(--border); }
.user-menu-logout { color: var(--red); border-top: 1px solid var(--border); }

/* ══ Global Search ══ */
.global-search-overlay {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,0.8);
    display: flex; flex-direction: column; padding: 16px;
    padding-top: env(safe-area-inset-top, 16px);
}
.global-search-box {
    display: flex; gap: 8px; align-items: center;
    background: var(--surface); border-radius: 12px;
    padding: 4px 8px; border: 1px solid var(--border);
}
.global-search-box .search-input { border: none; background: transparent; font-size: 16px; }
.global-search-results {
    flex: 1; overflow-y: auto; margin-top: 8px;
    background: var(--surface); border-radius: 12px;
    border: 1px solid var(--border);
    max-height: 60vh;
}
.gs-section-title {
    font-size: 11px; font-weight: 700; color: var(--text2);
    padding: 10px 14px 4px; text-transform: uppercase; letter-spacing: 1px;
}
.gs-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid #333;
    cursor: pointer; transition: background 0.15s;
}
.gs-item:active { background: #333; }
.gs-item:last-child { border-bottom: none; }

/* ══ Nav Badges ══ */
.nav-btn { position: relative; }
.nav-badge {
    position: absolute; top: 2px; right: 50%; transform: translateX(16px);
    min-width: 16px; height: 16px; border-radius: 8px;
    background: var(--red); color: #fff; font-size: 9px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 4px; line-height: 1;
}

/* ══ Dashboard Chart ══ */
.chart-container {
    display: flex; align-items: flex-end; gap: 4px;
    height: 140px; padding-top: 20px;
}
.chart-col {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; height: 100%;
}
.chart-val {
    font-size: 9px; color: var(--text2); margin-bottom: 4px;
    white-space: nowrap;
}
.chart-bar {
    width: 100%; border-radius: 4px 4px 0 0;
    overflow: hidden; min-height: 4px;
    margin-top: auto;
}
.chart-bar-fill {
    width: 100%; height: 100%;
    background: linear-gradient(180deg, var(--blue), var(--green));
    border-radius: 4px 4px 0 0;
}
.chart-bar-fill.profit-high { background: linear-gradient(180deg, #02CE76, #02a85f); }
.chart-bar-fill.profit-mid { background: linear-gradient(180deg, #FED843, #d4b435); }
.chart-bar-fill.profit-low { background: linear-gradient(180deg, #FF9800, #cc7a00); }
.chart-bar-fill.profit-loss { background: linear-gradient(180deg, #D00056, #a00044); }
.chart-label {
    font-size: 10px; color: var(--text2); margin-top: 4px;
    white-space: nowrap;
}

/* ══ Top Products ══ */
.top-product-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 0; border-bottom: 1px solid #333;
}
.top-product-item:last-child { border-bottom: none; }
.top-rank {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--border); display: flex; align-items: center;
    justify-content: center; font-size: 11px; font-weight: 700;
    color: var(--text2); flex-shrink: 0;
}
.top-product-item:nth-child(1) .top-rank { background: #FFD700; color: #222; }
.top-product-item:nth-child(2) .top-rank { background: #C0C0C0; color: #222; }
.top-product-item:nth-child(3) .top-rank { background: #CD7F32; color: #fff; }
.top-product-info { flex: 1; min-width: 0; }
.top-product-name {
    font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-bottom: 4px;
}
.top-product-bar-wrap {
    height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.top-product-bar {
    height: 100%; background: linear-gradient(90deg, var(--blue), var(--green));
    border-radius: 2px; transition: width 0.3s;
}
.top-product-stats { text-align: right; flex-shrink: 0; }
.top-sold { font-size: 14px; font-weight: 700; color: var(--yellow); display: block; }
.top-orders { font-size: 10px; color: var(--text2); }

/* ══ Low Stock ══ */
.low-stock-section { border-left: 3px solid var(--red); }
.low-stock-item {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 0; border-bottom: 1px solid #333;
}
.low-stock-item:last-child { border-bottom: none; }
.low-stock-info { flex: 1; min-width: 0; }
.low-stock-name {
    font-size: 13px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; margin-bottom: 4px;
}
.low-stock-bar-wrap {
    height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.low-stock-bar { height: 100%; border-radius: 2px; transition: width 0.3s; }
.low-stock-nums { text-align: right; flex-shrink: 0; white-space: nowrap; }

/* ══ Marketplace Loading Overlay ══ */
#mpLoadingOverlay {
    position: fixed; inset: 0; z-index: 500;
    background: rgba(32,32,32,0.95);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text);
}

/* ══ Action Buttons (order detail) ══ */
.action-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 14px 16px; border-radius: 10px; border: none;
    font-size: 12px; font-weight: 700; letter-spacing: 1px;
    cursor: pointer; text-decoration: none; text-align: center;
    transition: opacity 0.15s;
}
.action-btn:active { opacity: 0.7; }
.action-btn svg { flex-shrink: 0; }
.action-blue { background: #0078D433; color: var(--blue); }
.action-green { background: #02CE7633; color: var(--green); }

/* ══ Inventory Photo Upload ══ */
.inv-photo-area { margin-top: 6px; }
.inv-photo-add {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 6px; cursor: pointer;
    border: 1px dashed var(--border); background: var(--bg);
    color: var(--text2); font-size: 13px; transition: border-color 0.2s;
}
.inv-photo-add:active { border-color: var(--blue); }
.inv-photo-grid {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.inv-photo-thumb {
    position: relative; width: 64px; height: 64px;
    border-radius: 6px; overflow: hidden; border: 1px solid var(--border);
}
.inv-photo-thumb img {
    width: 100%; height: 100%; object-fit: cover;
}
.inv-photo-del {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(0,0,0,0.7); color: #fff; border: none;
    font-size: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* ══ Scanner capture button ══ */
.scan-capture-btn {
    position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(255,255,255,0.9); border: 4px solid var(--green);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5); z-index: 10;
    transition: transform 0.1s, opacity 0.15s;
    fill: var(--green);
}
.scan-capture-btn:active { transform: translateX(-50%) scale(0.9); }
.scan-capture-btn svg { fill: var(--green); }

/* ══ Scanner (html5-qrcode) dark theme ══ */
#scanner-cam {
    width: 100% !important;
    min-height: 280px;
    background: #000;
    position: relative;
}
#scanner-cam video {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    object-fit: cover;
}
#scanner-cam img { display: none !important; }
/* Scan region + qrbox border */
#scanner-cam__scan_region {
    min-height: 250px !important;
}
#scanner-cam__scan_region video {
    width: 100% !important;
    object-fit: cover !important;
}
#scanner-cam__dashboard_section { display: none !important; }
#scanner-cam__header_message { display: none !important; }
/* qrbox scanning area border */
#scanner-cam .qr-shaded-region { border-color: var(--green) !important; }

/* ══ Responsive ══ */
@media (min-width: 768px) {
    .container { padding: 16px 24px; }
    .card { padding: 16px; }
    .product-card { padding: 14px; }
    .product-img { width: 64px; height: 64px; }
    .chart-container { height: 180px; }
    .chart-val { font-size: 11px; }
    .chart-label { font-size: 11px; }
}
