:root {
  --primary: #0f766e;
  --primary-dark: #0d5f58;
  --accent: #f59e0b;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { text-decoration: none; color: inherit; }

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

.sidebar {
  width: 220px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 20px 0;
  flex-shrink: 0;
}
.sidebar h2 {
  padding: 0 20px 16px;
  font-size: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin: 0 0 12px;
}
.sidebar a {
  display: block;
  padding: 12px 20px;
  color: rgba(255,255,255,0.88);
  font-size: 14px;
}
.sidebar a:hover, .sidebar a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-left: 3px solid var(--accent);
}
.sidebar .user-box {
  padding: 12px 20px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  border-top: 1px solid rgba(255,255,255,0.15);
  margin-top: 12px;
}

.main { flex: 1; padding: 22px 28px; max-width: 100%; overflow-x: auto; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 22px; margin: 0; }

.cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  flex: 1;
  min-width: 180px;
}
.card .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.card .value { font-size: 24px; font-weight: 700; }
.card.warn .value { color: var(--danger); }
.card.good .value { color: var(--success); }

.panel {
  background: var(--card);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}
.panel h3 { margin-top: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover { background: #fafafa; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 6px;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e5e7eb; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.accent { background: var(--accent); color: #1f2937; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
}
label { font-size: 13px; color: var(--muted); margin-bottom: 4px; display: block; }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef9c3; color: #854d0e; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge.low { background: #fee2e2; color: #991b1b; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.pending { background: #fef9c3; color: #854d0e; }

.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.login-box {
  background: #fff; padding: 36px; border-radius: 12px; width: 340px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-box h2 { text-align: center; color: var(--primary); margin-top: 0; }

/* POS SCREEN */
.pos-layout { display: flex; gap: 18px; }
.pos-left { flex: 2; }
.pos-right { flex: 1; min-width: 320px; }
.scan-box input { font-size: 18px; padding: 14px; }
.scan-mode-toggle { display: flex; gap: 8px; }
.scan-mode-toggle .btn { white-space: nowrap; }
#reader video { border-radius: 8px; }
#reader__scan_region { border-radius: 8px; }
.cart-table td, .cart-table th { padding: 8px 6px; font-size: 13px; }
.cart-qty { width: 60px; }
.total-box { font-size: 26px; font-weight: 700; color: var(--primary); text-align: right; margin: 10px 0; }

.receipt {
  max-width: 340px; margin: 0 auto; font-family: 'Courier New', monospace;
  background: #fff; padding: 16px; border: 1px dashed #999;
}
.receipt h3 { text-align: center; margin: 4px 0; }
.receipt .center { text-align: center; }
.receipt table { font-size: 12px; }
.receipt hr { border: none; border-top: 1px dashed #999; }

.barcode-label {
  display: inline-block; border: 1px solid #ccc; padding: 6px; margin: 4px;
  text-align: center; width: 180px;
}
.barcode-label img { width: 100%; }

@media print {
  .no-print { display: none !important; }
  .sidebar { display: none; }
  .main { padding: 0; }
}

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; padding: 8px 0; }
  .sidebar h2 { display: none; }
  .sidebar a { padding: 10px 14px; white-space: nowrap; border-left: none !important; }
  .sidebar .user-box { display: none; }
  .pos-layout { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .cards { flex-direction: column; }
  .scan-box > div:first-child { flex-direction: column; align-items: stretch !important; gap: 8px; }
  .scan-mode-toggle { flex-direction: column; }
}
