* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
:root {
  --primary: #4f46e5; --primary-light: #eef2ff; --primary-dark: #4338ca;
  --success: #10b981; --success-light: #ecfdf5;
  --danger: #ef4444; --danger-light: #fef2f2;
  --warning: #f59e0b; --warning-light: #fffbeb;
  --bg: #f3f4f6; --card: #fff;
  --text: #111827; --text2: #6b7280; --text3: #9ca3af;
  --border: #e5e7eb; --radius: 12px; --shadow: 0 1px 3px rgba(0,0,0,.08);
  --safe-bottom: env(safe-area-inset-bottom,0px);
}
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
#app { display: flex; flex-direction: column; height: 100%; max-width: 480px; margin: 0 auto; }

/* Header */
header { background: var(--primary); color: #fff; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; min-height: 48px; }
header h1 { font-size: 17px; font-weight: 600; }
.header-btn { background: none; border: none; color: #fff; font-size: 14px; padding: 4px 8px; cursor: pointer; border-radius: 6px; }
.header-btn:active { background: rgba(255,255,255,.15); }

/* Main */
main { flex: 1; overflow-y: auto; padding: 12px 12px 8px; -webkit-overflow-scrolling: touch; }

/* Bottom Nav */
#bottomNav { display: flex; background: var(--card); border-top: 1px solid var(--border); flex-shrink: 0; padding-bottom: var(--safe-bottom); }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 0 4px; border: none; background: none; color: var(--text3); font-size: 10px; cursor: pointer; transition: color .15s; }
.nav-item svg { width: 22px; height: 22px; margin-bottom: 1px; }
.nav-item.active { color: var(--primary); }
.nav-item:active { opacity: .6; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.card-title { font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.card-value { font-size: 24px; font-weight: 700; color: var(--primary); }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); text-align: center; }
.stat-card .num { font-size: 22px; font-weight: 700; margin: 4px 0 2px; }
.stat-card .label { font-size: 12px; color: var(--text2); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 10px 20px; border: none; border-radius: 8px; font-size: 15px; font-weight: 500; cursor: pointer; transition: opacity .15s; }
.btn:active { opacity: .7; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: none; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; }

/* Form */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 4px; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; color: var(--text); background: #fff; outline: none; transition: border-color .15s; }
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text3); }
select.form-control { appearance: auto; }

/* Lists */
.list-item { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.list-item:last-child { border-bottom: none; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 500; font-size: 15px; }
.item-sub { font-size: 12px; color: var(--text2); margin-top: 1px; }
.item-right { text-align: right; flex-shrink: 0; }
.item-price { font-size: 13px; color: var(--text2); }
.item-qty { font-weight: 600; font-size: 15px; }
.qty-in { color: var(--success); }
.qty-out { color: var(--danger); }
.item-action { color: var(--text3); padding: 4px; cursor: pointer; border: none; background: none; font-size: 18px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; z-index: 1000; }
.modal-content { background: #fff; border-radius: 16px 16px 0 0; width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; padding: 20px; animation: slideUp .25s ease; }
@keyframes slideUp { from { transform: translateY(100%) } to { transform: translateY(0) } }
.modal-content h3 { font-size: 17px; margin-bottom: 16px; }
.modal-close { float: right; background: none; border: none; font-size: 22px; color: var(--text2); cursor: pointer; }

/* Toast */
.toast { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; z-index: 2000; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text3); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }

/* Tabs */
.tab-bar { display: flex; background: var(--card); border-radius: var(--radius); padding: 3px; margin-bottom: 12px; box-shadow: var(--shadow); }
.tab-item { flex: 1; text-align: center; padding: 8px 0; border-radius: 10px; font-size: 13px; color: var(--text2); cursor: pointer; border: none; background: none; font-weight: 500; transition: all .2s; }
.tab-item.active { background: var(--primary); color: #fff; }

/* Filter bar */
.filter-bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-bar .form-control { flex: 1; min-width: 100px; padding: 8px 10px; font-size: 13px; }

/* Charts */
.chart-container { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.chart-container h4 { font-size: 14px; color: var(--text2); margin-bottom: 10px; font-weight: 500; }

/* Inline badge */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-in { background: var(--success-light); color: var(--success); }
.badge-out { background: var(--danger-light); color: var(--danger); }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.quick-btn { padding: 16px; border-radius: var(--radius); border: none; font-size: 15px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.quick-btn:active { opacity: .7; }
.quick-btn svg { width: 28px; height: 28px; }
.quick-in { background: var(--success-light); color: var(--success); }
.quick-out { background: var(--danger-light); color: var(--danger); }

/* Product item in transaction form */
.product-select-list { max-height: 250px; overflow-y: auto; margin-bottom: 12px; }
.product-select-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; cursor: pointer; transition: all .15s; }
.product-select-item:active, .product-select-item.selected { border-color: var(--primary); background: var(--primary-light); }

/* Search */
.search-box { position: relative; margin-bottom: 12px; }
.search-box input { padding-left: 34px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text3); }
