:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --border: #475569;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --primary: #22c55e;
  --primary-hover: #16a34a;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app { min-height: 100vh; }

.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
  border-right: 1px solid #166534;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 110;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
}

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

.sidebar-logo {
  padding: 0 24px 24px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.sidebar-logo span { color: #bbf7d0; font-size: 14px; font-weight: 500; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.2); color: #fff; border-left-color: #fff; }

.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.main-content {
  flex: 1;
  margin-left: 230px;
  padding: 28px 32px;
  max-width: 100%;
}

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 700; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-label { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }
.stat-value.primary { color: var(--primary); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

.btn { padding: 9px 18px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 60px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-amber { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-blue { background: rgba(99,102,241,0.15); color: var(--primary); }

.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.pos-product-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: all 0.15s; text-align: center; }
.pos-product-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.pos-product-name { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.pos-product-price { font-size: 16px; font-weight: 700; color: var(--primary); }
.pos-product-stock { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.cart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: sticky; top: 20px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.cart-header { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.cart-items { flex: 1; overflow-y: auto; margin-bottom: 12px; }
.cart-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.cart-item-name { flex: 1; }
.cart-qty { display: flex; align-items: center; gap: 8px; }
.cart-qty-btn { width: 24px; height: 24px; border: 1px solid var(--border); background: var(--surface2); border-radius: 6px; cursor: pointer; color: var(--text); font-size: 14px; display: flex; align-items: center; justify-content: center; }
.cart-qty-btn:hover { background: var(--primary); }
.cart-summary { border-top: 1px solid var(--border); padding-top: 12px; }
.cart-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.cart-row.total { font-size: 18px; font-weight: 700; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

.search-bar { margin-bottom: 16px; position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar::before { content: '🔍'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; }

.empty-state { text-align: center; padding: 40px; color: var(--text-dim); }

.pos-product-card img.product-thumb { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; margin-bottom: 8px; }
.pos-product-card .product-no-img { width: 100%; height: 100px; background: var(--surface2); border-radius: 6px; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; font-size: 32px; }
.product-img-cell { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.product-no-img-cell { width: 44px; height: 44px; border-radius: 6px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.barcode-text { font-family: 'Courier New', monospace; font-size: 13px; color: var(--text-dim); letter-spacing: 1px; }

.dash-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .dash-two-col { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .pos-layout { grid-template-columns: 1fr; }
  .cart { position: relative; max-height: none; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; padding: 12px; padding-top: 52px; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .page-title { font-size: 20px; }
  .card { padding: 14px; }
  .modal { padding: 16px; max-width: 100%; max-height: 85vh; }
  .modal-overlay { padding: 10px; }
  .pos-products { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .pos-product-card { padding: 12px; }
  .pos-product-card img.product-thumb, .pos-product-card .product-no-img { height: 80px; }
  .form-input, .form-select, .form-textarea { font-size: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .pos-products { grid-template-columns: 1fr 1fr; gap: 8px; }
  .pos-product-card { padding: 10px; }
  .pos-product-card img.product-thumb, .pos-product-card .product-no-img { height: 70px; }
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.receipt { font-family: 'Courier New', monospace; background: #fff; color: #000; padding: 24px; border-radius: 8px; max-width: 380px; margin: 0 auto; }
.receipt h2 { text-align: center; font-size: 18px; margin-bottom: 4px; }
.receipt-meta { text-align: center; font-size: 12px; margin-bottom: 12px; }
.receipt hr { border: 1px dashed #ccc; margin: 8px 0; }
.receipt-item { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.receipt-total { font-weight: bold; font-size: 14px; margin-top: 8px; }
.receipt-footer { text-align: center; font-size: 12px; margin-top: 12px; }

.chart-container { margin-top: 16px; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 200px; padding-bottom: 24px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.chart-bar { flex: 1; min-width: 30px; background: var(--primary); border-radius: 4px 4px 0 0; position: relative; transition: opacity 0.15s; min-height: 2px; }
.chart-bar:hover { opacity: 0.8; }
.chart-bar-label { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.chart-bar-value { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-dim); white-space: nowrap; }

.w-full { width: 100%; }
.mt-16 { margin-top: 16px; }
.text-dim { color: var(--text-dim); }

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #14532d 100%); padding: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 36px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.auth-logo { font-size: 28px; font-weight: 800; text-align: center; margin-bottom: 28px; letter-spacing: 1px; }
.auth-logo span { color: var(--primary); font-size: 16px; font-weight: 500; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.auth-tab { flex: 1; padding: 12px; background: transparent; border: none; color: var(--text-dim); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-form .form-group { margin-bottom: 18px; }
.auth-btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 6px; }

.sidebar-user { margin-top: auto; padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: space-between; }
.sidebar-user-info { flex: 1; }
.sidebar-user-name { color: #fff; font-size: 14px; font-weight: 600; }
.sidebar-user-role { color: rgba(255,255,255,0.6); font-size: 12px; text-transform: capitalize; }
.sidebar-user .btn { color: rgba(255,255,255,0.8); border-color: rgba(255,255,255,0.2); }

.toast { position: fixed; top: 20px; right: 20px; padding: 14px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 9999; animation: slideIn 0.25s ease; }
.toast.success { background: var(--green); color: #fff; }
.toast.error { background: var(--red); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@media (max-width: 480px) { .auth-card { padding: 24px; } .auth-logo { font-size: 24px; } }
