/* =====================================================
   Durian Stand Management System — Global Styles
   ===================================================== */

:root {
    --primary: #1b4332;
    --primary-light: #2d6a4f;
    --primary-mid: #40916c;
    --primary-pale: #edf7f1;
    --accent: #f9c74f;
    --accent-dark: #e6a817;
    --danger: #dc3545;
    --success: #198754;
    --warning: #ffc107;
    --info: #0dcaf0;
    --bg: #f5f5f3;
    --card-bg: #ffffff;
    --text: #1e2d24;
    --text-muted: #7a8c80;
    --border: #e8ebe8;
    --sidebar-w: 240px;
    --topbar-h: 52px;
    --bottom-nav-h: 60px;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 3px rgba(0,0,0,.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.55;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.login-page {
    min-height: 100dvh;
    background: linear-gradient(160deg, var(--primary) 0%, var(--primary-mid) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.login-wrapper { width: 100%; max-width: 380px; }

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem 1.75rem;
    box-shadow: var(--shadow-md);
}

.login-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 2.5rem; margin-bottom: .4rem; }

.login-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.login-subtitle {
    font-size: .78rem;
    color: var(--text-muted);
    margin: .2rem 0 0;
}

.btn-login {
    background: var(--primary);
    border-color: var(--primary);
    padding: .6rem;
    font-size: .95rem;
    border-radius: var(--radius-sm);
}

.btn-login:hover, .btn-login:focus {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.login-version { font-size: .75rem; }

/* =====================================================
   LAYOUT: SIDEBAR + MAIN
   ===================================================== */
.app-page { overflow-x: hidden; }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100dvh;
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform .22s ease;
}

.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 999;
}

.sidebar-overlay.show { display: block; }

.sidebar-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}

.sidebar-logo { font-size: 1.3rem; }

.sidebar-title {
    font-size: .9rem;
    font-weight: 700;
    flex: 1;
}

.btn-close-sidebar {
    background: none;
    border: none;
    color: rgba(255,255,255,.6);
    font-size: 1rem;
    padding: .2rem;
    cursor: pointer;
    line-height: 1;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: .4rem 0;
    overflow-y: auto;
    flex: 1;
}

.sidebar-nav-item a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1.1rem;
    color: rgba(255,255,255,.7);
    font-size: .83rem;
    border-left: 2px solid transparent;
    transition: all .13s;
}

.sidebar-nav-item a i {
    font-size: 1rem;
    width: 1.1rem;
    text-align: center;
    opacity: .8;
}

.sidebar-nav-item a:hover,
.sidebar-nav-item.active a {
    color: #fff;
    background: rgba(255,255,255,.09);
    border-left-color: var(--accent);
}

.sidebar-nav-item.active a i { opacity: 1; }

.sidebar-nav-divider {
    height: 1px;
    background: rgba(255,255,255,.1);
    margin: .4rem 1.1rem;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .9rem 1.1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
    font-size: .8rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role { font-size: .7rem; color: rgba(255,255,255,.55); }

.btn-logout {
    color: rgba(255,255,255,.55);
    font-size: 1.1rem;
    padding: .2rem;
    transition: color .13s;
}

.btn-logout:hover { color: #fff; }

/* Main wrapper */
.main-wrapper {
    min-height: 100dvh;
    padding-top: var(--topbar-h);
    padding-bottom: calc(var(--bottom-nav-h) + .5rem);
}

@media (min-width: 992px) {
    .sidebar { transform: translateX(0); }
    .sidebar-overlay { display: none !important; }
    .btn-close-sidebar { display: none; }
    .main-wrapper { margin-left: var(--sidebar-w); }
}

/* Topbar */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 0 1rem;
    z-index: 900;
}

@media (min-width: 992px) { .topbar { left: var(--sidebar-w); } }

.btn-menu {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--primary);
    padding: .2rem;
    cursor: pointer;
    display: flex;
}

@media (min-width: 992px) { .btn-menu { display: none; } }

.topbar-title { flex: 1; }

.topbar-title h6 {
    font-size: .9rem;
    font-weight: 700;
    color: var(--primary);
}

/* Page Content */
.page-content {
    padding: 1.5rem 1.1rem;
    max-width: 700px;
    margin: 0 auto;
}

/* =====================================================
   SECTION
   ===================================================== */
.section-title {
    font-weight: 600;
    color: var(--text-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .65rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .65rem;
}

/* =====================================================
   KPI CARDS
   ===================================================== */
.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1rem;
    overflow: hidden;
}

.kpi-card::before { display: none; }

.kpi-icon {
    font-size: 1rem;
    margin-bottom: .2rem;
    opacity: .55;
}

.kpi-purchase .kpi-icon { color: #4361ee; }
.kpi-sale .kpi-icon     { color: #f72585; }
.kpi-expense .kpi-icon  { color: #ff9f1c; }
.kpi-profit .kpi-icon   { color: var(--success); }
.kpi-loss .kpi-icon     { color: var(--danger); }

.kpi-label {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.kpi-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    margin: .1rem 0;
}

.kpi-unit  { font-size: .72rem; color: var(--text-muted); }
.kpi-sub   { font-size: .72rem; color: var(--text-muted); margin-top: .2rem; }
.kpi-alert { font-size: .68rem; color: #b45309; font-weight: 600; margin-top: .2rem; }

.kpi-card.kpi-low { border-color: #ffc107; background: #fffdf5; }

/* Stock card */
.kpi-stock { text-align: center; padding: .8rem .5rem; }
.kpi-stock .kpi-label { font-size: .75rem; }
.kpi-stock .kpi-value { font-size: 1.3rem; }

/* =====================================================
   QUEUE LIST
   ===================================================== */
.queue-list { display: flex; flex-direction: column; gap: .4rem; }

.queue-item {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .7rem .9rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    border: 1px solid var(--border);
}

.queue-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-pale);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.queue-info { flex: 1; min-width: 0; }
.queue-name { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-meta { font-size: .74rem; color: var(--text-muted); }

/* =====================================================
   STAT MINI
   ===================================================== */
.stat-mini {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .8rem .9rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    border: 1px solid var(--border);
}

.stat-mini i { font-size: 1.2rem; opacity: .5; }
.stat-num { font-size: 1.3rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .72rem; color: var(--text-muted); }

/* =====================================================
   QUICK ACTIONS
   ===================================================== */
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .9rem .5rem;
    text-align: center;
    font-size: .75rem;
    font-weight: 500;
    color: var(--text);
    transition: background .13s;
}

.quick-action i { font-size: 1.2rem; color: var(--primary-mid); opacity: .75; }

.quick-action:hover, .quick-action:active {
    background: var(--primary-pale);
    border-color: var(--border);
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .3; }
.empty-state p { margin: 0; font-size: .85rem; }

/* =====================================================
   BOTTOM NAVIGATION
   ===================================================== */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    z-index: 900;
}

@media (min-width: 992px) { .bottom-nav { display: none; } }

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .1rem;
    font-size: .62rem;
    color: var(--text-muted);
    font-weight: 500;
    padding: .2rem 0;
    transition: color .13s;
}

.bottom-nav-item i { font-size: 1.2rem; }

.bottom-nav-item.active,
.bottom-nav-item:hover { color: var(--primary); }

/* =====================================================
   MORE MENU MODAL
   ===================================================== */
.more-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: .65rem .5rem;
    border-radius: var(--radius-sm);
    font-size: .75rem;
    font-weight: 500;
    color: var(--text);
    transition: background .13s;
}

.more-menu-item i { font-size: 1.4rem; color: var(--primary); opacity: .7; }
.more-menu-item.text-danger i { color: var(--danger); opacity: .8; }
.more-menu-item:hover { background: var(--bg); }

/* =====================================================
   FORMS
   ===================================================== */
.form-label { font-size: .82rem; font-weight: 500; color: var(--text); margin-bottom: .3rem; }

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: .875rem;
    padding: .45rem .7rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-mid);
    box-shadow: 0 0 0 .18rem rgba(64,145,108,.15);
}

.input-group-text {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text-muted);
    font-size: .9rem;
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-primary-custom { color: var(--primary) !important; }
.bg-primary-custom   { background: var(--primary) !important; }

@media (max-width: 360px) {
    .kpi-value { font-size: .95rem; }
    .page-content { padding: 1.25rem .75rem; }
}

/* =====================================================
   STOCK PAGE
   ===================================================== */
.stock-grade-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.1rem 1rem;
    margin-bottom: .6rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary-mid);
}

.stock-grade-card.stock-low { border-left-color: #ffc107; background: #fffdf5; }

.sgc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.sgc-grade { font-size: .95rem; font-weight: 700; color: var(--primary); }

.btn-adjust {
    background: none;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: .2rem .6rem;
    font-size: .72rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .13s;
}

.btn-adjust:hover { background: var(--bg); color: var(--primary); border-color: var(--primary-mid); }

.sgc-weight { font-size: 2.2rem; font-weight: 800; color: var(--primary); line-height: 1.1; }
.sgc-unit   { font-size: .75rem; color: var(--text-muted); }
.sgc-meta   { display: flex; gap: 1rem; font-size: .72rem; color: var(--text-muted); margin-top: .35rem; flex-wrap: wrap; }

/* Movement list */
.movement-row {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
}

.movement-row:last-child { border-bottom: none; }

.mv-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; margin-top: .1rem; opacity: .6; }
.mv-body { flex: 1; min-width: 0; }
.mv-top  { display: flex; align-items: center; gap: .35rem; }
.mv-type { font-weight: 600; font-size: .82rem; }
.mv-meta { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }
.mv-right { text-align: right; flex-shrink: 0; }
.mv-change { font-weight: 700; font-size: .9rem; }
.mv-in  { color: #198754; }
.mv-out { color: #dc3545; }
.mv-after { font-size: .7rem; color: var(--text-muted); }

/* =====================================================
   SALES PAGE
   ===================================================== */
.stock-avail-card {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .6rem .5rem;
    text-align: center;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: all .13s;
}

.stock-avail-card:hover, .stock-avail-card:active {
    border-color: var(--primary-mid);
    background: var(--primary-pale);
}

.sac-grade { font-size: .68rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.sac-kg    { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.sac-unit  { font-size: .62rem; color: var(--text-muted); }
.sac-cost  { font-size: .62rem; color: #6c757d; margin-top: .1rem; }

.stock-avail-info {
    background: var(--primary-pale);
    border-radius: var(--radius-sm);
    padding: .45rem .7rem;
    font-size: .8rem;
    color: var(--primary);
}

.sale-card {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    margin-bottom: .5rem;
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: opacity .1s;
}

.sale-card:active { opacity: .85; }

.sale-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .55rem .8rem .3rem;
    border-bottom: 1px solid var(--border);
}

.sale-buyer { font-size: .85rem; font-weight: 600; }

.sale-card-body { padding: .55rem .8rem; }

.sale-weights {
    display: flex;
    gap: .5rem;
    margin: .35rem 0;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: .35rem .55rem;
}

.sw-item { flex: 1; text-align: center; }
.sw-label { display: block; font-size: .62rem; color: var(--text-muted); }
.sw-value { display: block; font-size: .82rem; font-weight: 600; }
.sw-total .sw-value { color: var(--primary); }

.sale-profit     { font-size: .77rem; font-weight: 600; margin-top: .25rem; }
.profit-pos      { color: #198754; }
.profit-neg      { color: #dc3545; }
.sale-cost-note  { font-weight: 400; color: var(--text-muted); font-size: .7rem; }

.sale-card-footer {
    display: flex;
    justify-content: space-between;
    padding: .3rem .8rem .45rem;
    font-size: .7rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* =====================================================
   QUEUE PAGE
   ===================================================== */
.queue-stats {
    display: flex;
    gap: .4rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: .1rem;
}

.queue-stats::-webkit-scrollbar { display: none; }

.queue-stat {
    flex: 1;
    min-width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1.5px solid var(--border);
    padding: .6rem .3rem .5rem;
    cursor: pointer;
    transition: all .13s;
}

.queue-stat[data-filter="all"]      { border-color: var(--primary); }
.queue-stat[data-filter="waiting"]  { border-color: #f59e0b; }
.queue-stat[data-filter="called"]   { border-color: #0ea5e9; }
.queue-stat[data-filter="weighing"] { border-color: #6366f1; }
.queue-stat[data-filter="done"]     { border-color: #22c55e; }

.queue-stat.active { box-shadow: var(--shadow); }

.queue-stat[data-filter="all"].active      { background: var(--primary-pale); }
.queue-stat[data-filter="waiting"].active  { background: #fff8e1; }
.queue-stat[data-filter="called"].active   { background: #e0f4ff; }
.queue-stat[data-filter="weighing"].active { background: #eef2ff; }
.queue-stat[data-filter="done"].active     { background: #f0fdf4; }

.queue-stat:not(.active) { border-color: var(--border); opacity: .8; }

.stat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-bottom: .1rem;
}

.queue-stat[data-filter="all"] .stat-dot      { background: var(--primary); }
.queue-stat[data-filter="waiting"] .stat-dot  { background: #f59e0b; }
.queue-stat[data-filter="called"] .stat-dot   { background: #0ea5e9; }
.queue-stat[data-filter="weighing"] .stat-dot { background: #6366f1; }
.queue-stat[data-filter="done"] .stat-dot     { background: #22c55e; }

.stat-count { display: block; font-size: 1.3rem; font-weight: 700; line-height: 1; }

.queue-stat[data-filter="all"] .stat-count      { color: var(--primary); }
.queue-stat[data-filter="waiting"] .stat-count  { color: #d97706; }
.queue-stat[data-filter="called"] .stat-count   { color: #0284c7; }
.queue-stat[data-filter="weighing"] .stat-count { color: #4f46e5; }
.queue-stat[data-filter="done"] .stat-count     { color: #16a34a; }

.stat-name {
    display: block;
    font-size: .58rem;
    color: var(--text-muted);
    margin-top: .1rem;
    white-space: nowrap;
    font-weight: 500;
}

.queue-card {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .8rem;
    margin-bottom: .5rem;
    display: flex;
    align-items: center;
    gap: .7rem;
    border: 1px solid var(--border);
}

.queue-card-left { flex-shrink: 0; }

.queue-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-pale);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
}

.queue-card-body { flex: 1; min-width: 0; }
.queue-card-name { font-weight: 600; font-size: .9rem; }

.queue-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: .15rem;
}

.queue-card-meta span { display: flex; align-items: center; gap: .15rem; }
.queue-card-meta i    { font-size: .8rem; opacity: .7; }

.queue-card-notes { font-size: .74rem; color: var(--text-muted); margin-top: .25rem; }

.queue-card-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .35rem;
    flex-shrink: 0;
}

.queue-actions { display: flex; flex-direction: row; gap: .25rem; align-items: center; }

.btn-action {
    border: none;
    border-radius: 14px;
    padding: .25rem .6rem;
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity .13s;
}

.btn-action:hover { opacity: .8; }

.btn-call     { background: #cff4fc; color: #055160; }
.btn-weigh    { background: #cfe2ff; color: #084298; }
.btn-done     { background: #d1e7dd; color: #0a3622; }
.btn-cancel-q { background: #f8d7da; color: #842029; padding: .25rem .45rem; }

/* =====================================================
   PURCHASE PAGE
   ===================================================== */
.stat-mini-sm {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .6rem .7rem;
    text-align: center;
    border: 1px solid var(--border);
}

.smn { font-size: 1rem; font-weight: 700; }
.sml { font-size: .68rem; color: var(--text-muted); }

.lot-card {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    margin-bottom: .5rem;
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: opacity .1s;
}

.lot-card:active { opacity: .85; }

.lot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .6rem .8rem .35rem;
    border-bottom: 1px solid var(--border);
}

.lot-code  { font-weight: 700; font-size: .85rem; color: var(--primary); }
.lot-queue { font-size: .72rem; color: var(--text-muted); margin-left: .35rem; }

.lot-card-body { padding: .55rem .8rem; }

.lot-info-row { display: flex; align-items: center; gap: .45rem; margin-bottom: .4rem; }
.lot-seller   { font-size: .77rem; color: var(--text-muted); }

.lot-weights {
    display: flex;
    gap: .5rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: .35rem .55rem;
    margin-bottom: .4rem;
}

.lw-item  { flex: 1; text-align: center; }
.lw-label { display: block; font-size: .62rem; color: var(--text-muted); }
.lw-value { display: block; font-size: .82rem; font-weight: 600; }
.lw-net .lw-value { color: var(--primary); }

.lot-amount  { display: flex; justify-content: space-between; align-items: center; }
.lot-price   { font-size: .75rem; color: var(--text-muted); }
.lot-total   { font-size: .95rem; font-weight: 700; color: var(--primary); }

.lot-card-footer {
    display: flex;
    justify-content: space-between;
    padding: .35rem .8rem .45rem;
    font-size: .7rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* Calc box */
.calc-box {
    background: var(--primary-pale);
    border-radius: var(--radius-sm);
    padding: .7rem;
    border: 1px solid var(--border);
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .85rem;
    margin-bottom: .45rem;
}

.calc-total {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .45rem .7rem;
    text-align: center;
    border: 1px solid var(--border);
}

.calc-total-label { font-size: .68rem; color: var(--text-muted); }
.calc-total-value { font-size: 1.05rem; font-weight: 700; color: var(--primary); }

/* Detail grid */
.detail-grid { display: flex; flex-direction: column; gap: 0; }

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .45rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}

.detail-row:last-child { border-bottom: none; }
.detail-row > span:first-child { color: var(--text-muted); }

.detail-highlight {
    background: var(--primary-pale);
    margin: 0 -.5rem;
    padding: .5rem .5rem;
    border-radius: 4px;
}

/* =====================================================
   EXPENSES
   ===================================================== */
.cat-filter { display: flex; flex-wrap: wrap; gap: .35rem; }

.cat-chip {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: .25rem .8rem;
    font-size: .78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
}

.cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.expense-summary-box {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .8rem .9rem;
    margin-bottom: .5rem;
    border: 1px solid var(--border);
}

.esb-row { display: flex; align-items: center; gap: .55rem; margin-bottom: .45rem; }
.esb-row:last-child { margin-bottom: 0; }
.esb-cat   { font-size: .75rem; color: var(--text-muted); min-width: 75px; }
.esb-bar-wrap { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.esb-bar   { height: 100%; background: var(--primary-mid); border-radius: 3px; transition: width .4s; }
.esb-amount { font-size: .8rem; font-weight: 600; color: var(--primary); min-width: 65px; text-align: right; }

.expense-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .55rem .8rem;
    background: var(--primary-pale);
    border-radius: var(--radius-sm);
    margin-bottom: .65rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid var(--border);
}

.expense-row {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .75rem .8rem;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    margin-bottom: .45rem;
    border: 1px solid var(--border);
}

.exp-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-pale);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: .9rem;
    flex-shrink: 0;
    opacity: .8;
}

.exp-body  { flex: 1; min-width: 0; }
.exp-desc  { font-size: .87rem; font-weight: 600; color: var(--text); }

.exp-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .25rem;
    font-size: .72rem;
    color: var(--text-muted);
    align-items: center;
}

.exp-notes  { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

.exp-right  { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex-shrink: 0; }
.exp-amount { font-size: .95rem; font-weight: 700; color: var(--primary); }
.exp-actions { display: flex; gap: .2rem; }

.receipt-upload {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    position: relative;
}

.receipt-upload:hover { border-color: var(--primary-mid); background: var(--primary-pale); }
.receipt-preview { max-height: 180px; width: 100%; object-fit: contain; border-radius: var(--radius-sm); margin-top: .5rem; }

/* =====================================================
   ATTENDANCE / CHECK-IN
   ===================================================== */
.checkin-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius);
    padding: 1.4rem;
    color: #fff;
    text-align: center;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.checkin-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 80%, rgba(255,255,255,.06) 0%, transparent 60%);
    pointer-events: none;
}

.ci-user { display: flex; align-items: center; gap: .65rem; margin-bottom: 1rem; text-align: left; }

.ci-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

.ci-name { font-size: .95rem; font-weight: 700; }
.ci-role { font-size: .74rem; opacity: .72; }

.ci-clock {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-bottom: .2rem;
    color: var(--accent);
}

.ci-date { font-size: .82rem; opacity: .78; margin-bottom: .9rem; }

.ci-status-row { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: .9rem; flex-wrap: wrap; }

.ci-time-block { text-align: center; }
.ci-tl { display: block; font-size: .68rem; opacity: .65; text-transform: uppercase; letter-spacing: .5px; }
.ci-tv { display: block; font-size: 1.15rem; font-weight: 700; }
.ci-not-yet { font-size: .85rem; opacity: .65; padding: .4rem 0; }

.ci-gps {
    background: rgba(0,0,0,.18);
    border-radius: 14px;
    padding: .3rem .75rem;
    font-size: .74rem;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: 1rem;
    opacity: .85;
}

.ci-buttons { display: flex; gap: .65rem; justify-content: center; flex-wrap: wrap; }

.btn-checkin, .btn-checkout {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .65rem 1.75rem;
    border: none;
    border-radius: 30px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

.btn-checkin { background: var(--accent); color: var(--primary); }
.btn-checkin:hover:not(:disabled) { background: var(--accent-dark); }

.btn-checkout {
    background: rgba(255,255,255,.13);
    border: 1.5px solid rgba(255,255,255,.45);
    color: #fff;
}

.btn-checkout:hover:not(:disabled) { background: rgba(255,255,255,.22); }

.btn-checkin:disabled, .btn-checkout:disabled { opacity: .45; cursor: not-allowed; }

.ci-done { display: flex; align-items: center; gap: .45rem; font-size: .95rem; font-weight: 600; padding: .4rem 0; opacity: .88; }

.att-row {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .8rem;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    margin-bottom: .4rem;
    border: 1px solid var(--border);
}

.att-date   { font-size: .78rem; color: var(--text-muted); min-width: 48px; }
.att-times  { flex: 1; display: flex; align-items: center; gap: .45rem; font-size: .85rem; }
.att-sep    { color: var(--text-muted); font-size: .72rem; }
.att-right  { display: flex; align-items: center; gap: .35rem; flex-shrink: 0; }
.att-hours  { font-size: .77rem; font-weight: 600; color: var(--primary-light); }

/* Section header with flex layout */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .65rem; }

/* Generic btn-icon */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: .18rem .3rem;
    border-radius: 5px;
    transition: background .13s;
    line-height: 1;
}

.btn-icon:hover { background: var(--bg); }

/* =====================================================
   SUMMARY PAGE
   ===================================================== */
.sum-tabs {
    display: flex;
    gap: .3rem;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.sum-tabs::-webkit-scrollbar { display: none; }

.sum-tab {
    flex-shrink: 0;
    padding: .35rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: .8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.sum-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.sum-margin {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary-pale);
    border-radius: var(--radius-sm);
    padding: .55rem .9rem;
    border: 1px solid var(--border);
}

.sum-margin-label { font-size: .77rem; color: var(--text-muted); }
.sum-margin-val   { font-size: 1.2rem; font-weight: 700; color: var(--primary); }

.chart-wrap {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .7rem;
    border: 1px solid var(--border);
}

.grade-legend { display: flex; flex-direction: column; gap: .45rem; justify-content: center; height: 100%; }

.grade-leg-row   { display: flex; align-items: center; gap: .35rem; font-size: .77rem; }
.grade-leg-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.grade-dot       { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
.grade-leg-label { flex: 1; color: var(--text); }
.grade-leg-pct   { color: var(--text-muted); min-width: 28px; }
.grade-leg-val   { font-weight: 600; color: var(--primary); min-width: 52px; text-align: right; }

.sync-card { background: var(--card-bg); border-radius: var(--radius-sm); padding: .9rem; border: 1px solid var(--border); }
.sync-status { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }

.kpi-profit { border-left: 3px solid var(--success); }

/* =====================================================
   SETTINGS PAGE
   ===================================================== */
.user-row {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .75rem .8rem;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    margin-bottom: .4rem;
    border: 1px solid var(--border);
    position: relative;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-pale);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .87rem; font-weight: 600; color: var(--text); }
.user-meta { font-size: .74rem; color: var(--text-muted); }

.user-right { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }

.user-inactive-badge {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    color: var(--text-muted);
    pointer-events: none;
}

.geofence-preview {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: .55rem .8rem;
    font-size: .78rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .35rem;
}

.btn-xs { padding: .18rem .4rem; font-size: .72rem; }

/* =====================================================
   GRADE / VARIETY CHIPS
   ===================================================== */
.grade-chip-wrap { display: flex; flex-wrap: wrap; gap: .35rem; }

.grade-chip-wrap .btn {
    flex: 1 1 calc(33% - .35rem);
    min-width: 0;
    font-size: .78rem;
    padding: .32rem .35rem;
    white-space: nowrap;
}

.variety-chip-wrap { display: flex; flex-wrap: wrap; gap: .3rem; }

.variety-chip-wrap .btn {
    flex: 1 1 calc(33% - .3rem);
    min-width: 0;
    font-size: .75rem;
    padding: .28rem .3rem;
    white-space: nowrap;
    color: #0d9488;
    border-color: #0d9488;
}

.variety-chip-wrap .btn:hover,
.variety-chip-wrap .btn-check:checked + .btn {
    background: #0d9488;
    color: #fff;
    border-color: #0d9488;
}

.variety-badge { background: #0d9488; color: #fff; font-size: .7rem; }

.btn-outline-purple { color: #6f42c1; border-color: #6f42c1; }
.btn-outline-purple:hover,
.btn-check:checked + .btn-outline-purple { background: #6f42c1; color: #fff; border-color: #6f42c1; }

.btn-outline-pink { color: #d63384; border-color: #d63384; }
.btn-outline-pink:hover,
.btn-check:checked + .btn-outline-pink { background: #d63384; color: #fff; border-color: #d63384; }

/* =====================================================
   STOCK SCROLL ROW
   ===================================================== */
.stock-scroll-row {
    display: flex;
    overflow-x: auto;
    gap: .55rem;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.stock-scroll-row::-webkit-scrollbar { height: 3px; }
.stock-scroll-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.stock-mini-card {
    flex-shrink: 0;
    width: 84px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .55rem .45rem .45rem;
    text-align: center;
    border: 1px solid var(--border);
    border-top: 2px solid var(--gc, #1b4332);
    position: relative;
}

.stock-mini-low { background: #fff9f9; }

.smc-grade { font-size: .68rem; font-weight: 700; color: var(--gc, var(--primary)); margin-bottom: .15rem; }
.smc-val   { font-size: .95rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.smc-unit  { font-size: .62rem; color: var(--text-muted); }
.smc-alert { position: absolute; top: 2px; right: 3px; font-size: .6rem; color: #dc3545; }

.stock-avail-card { flex-shrink: 0; width: 94px; border-top: 2px solid var(--gc, #1b4332); }
.sac-grade { font-size: .68rem; font-weight: 600; color: var(--gc, var(--primary)); }

/* =====================================================
   SELLERS PAGE
   ===================================================== */
.seller-card {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: .8rem;
    margin-bottom: .45rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background .13s;
}

.seller-card:hover { background: var(--primary-pale); }
.seller-card:active { opacity: .85; }

.seller-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-pale);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.seller-info { flex: 1; min-width: 0; }

.seller-name {
    font-weight: 600;
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.seller-meta { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .72rem; color: var(--text-muted); margin-top: .12rem; }

.seller-stats { display: flex; gap: .65rem; flex-shrink: 0; }

.ss-item { text-align: center; }
.ss-val  { display: block; font-weight: 700; font-size: .85rem; color: var(--primary); }
.ss-label { font-size: .68rem; color: var(--text-muted); }

.section-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}

/* Seller autocomplete dropdown */
.seller-suggest {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;
}

.seller-suggest-item { padding: .45rem .7rem; cursor: pointer; font-size: .85rem; }

.seller-suggest-item:hover,
.seller-suggest-item.active { background: var(--primary-pale); }

.seller-suggest-item small { color: var(--text-muted); font-size: .72rem; }

/* =====================================================
   BADGES (legacy)
   ===================================================== */
.badge-grade-abc    { background: #1b4332; color: #fff; }
.badge-grade-d      { background: #40916c; color: #fff; }
.badge-grade-reject { background: #dc3545; color: #fff; }

/* =====================================================
   THEME SWATCHES (settings page)
   ===================================================== */
.theme-swatch-btn {
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: .4rem;
    cursor: pointer;
    position: relative;
    transition: border-color .2s, box-shadow .2s;
    text-align: left;
}
.theme-swatch-btn:hover { box-shadow: var(--shadow-md); }
.theme-swatch-btn.active { box-shadow: 0 0 0 3px rgba(0,0,0,.12); }
.theme-swatch-preview {
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-bottom: .35rem;
}
.theme-swatch-mid  { flex: 1; opacity: .65; }
.theme-swatch-pale { flex: 1; }
.theme-swatch-label { font-size: .76rem; font-weight: 600; color: var(--text); padding: 0 .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-swatch-check {
    position: absolute;
    top: .3rem;
    right: .35rem;
    font-size: .9rem;
    color: var(--primary);
}
.custom-color-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem;
    transition: border-color .2s;
}
.custom-color-card.active { border-color: var(--primary); }
.custom-color-picker-input {
    width: 44px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
}
.theme-custom-preview-bar {
    height: 36px;
    border-radius: 6px;
    background: linear-gradient(90deg, #1b4332, #40916c, #edf7f1);
    transition: background .25s;
}

/* =====================================================
   PRINT
   ===================================================== */
@media print {
    .sidebar, .topbar, .bottom-nav, .more-menu,
    .btn, button, .sum-tabs, #periodPicker { display: none !important; }
    .main-wrapper  { margin: 0 !important; padding: 0 !important; }
    .page-content  { padding: 0 !important; }
    .chart-wrap    { box-shadow: none; border: 1px solid #ccc; }
}
