:root {
  --brown: #1a0a00;
  --brown-mid: #3d1f00;
  --brown-light: #7a4520;
  --amber: #c8860a;
  --amber-light: #f0a830;
  --cream: #f5e6d3;
  --cream-light: #fdf6ee;
  --white: #ffffff;
  --gray: #6b6b6b;
  --gray-light: #e8e8e8;
  --success: #2e7d32;
  --danger: #c62828;
  --shadow: 0 2px 12px rgba(26,10,0,0.12);
  --radius: 14px;
  --radius-sm: 8px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #fdf6ee; color: #1a0a00; min-height: 100vh; }
a { color: #c8860a; text-decoration: none; }

/* BUTTONS */
button, .btn { cursor: pointer; border: none; font-family: inherit; font-size: 1rem; border-radius: 8px; padding: 0.65rem 1.2rem; transition: all 0.18s; font-weight: 500; display: inline-block; }
.btn-primary { background: #c8860a; color: #fff; }
.btn-primary:hover { background: #f0a830; }
.btn-secondary { background: #f5e6d3; color: #1a0a00; border: 1.5px solid #7a4520; }
.btn-secondary:hover { background: #fdf6ee; }
.btn-danger { background: #c62828; color: #fff; }
.btn-success { background: #2e7d32; color: #fff; }
.btn-lg { padding: 0.85rem 1.8rem; font-size: 1.05rem; border-radius: 14px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* INPUTS */
input, select, textarea {
  width: 100%; padding: 0.65rem 0.9rem;
  border: 1.5px solid #e8e8e8; border-radius: 8px;
  font-family: inherit; font-size: 0.95rem; color: #1a0a00;
  background: #fff; transition: border 0.18s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #c8860a; }

/* UTILS */
.card { background: #fff; border-radius: 14px; box-shadow: 0 2px 12px rgba(26,10,0,0.12); padding: 1.4rem; }
.badge { display: inline-block; padding: 0.2rem 0.65rem; border-radius: 20px; font-size: 0.78rem; font-weight: 600; }
.badge-amber { background: #fff3cd; color: #856404; }
.badge-green { background: #d4edda; color: #155724; }
.badge-red { background: #f8d7da; color: #721c24; }
.badge-gray { background: #e8e8e8; color: #6b6b6b; }
.hidden { display: none !important; }

/* TOPBAR */
.topbar { background: #1a0a00; color: #fff; padding: 0.9rem 1.4rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; min-height: 56px; }
.topbar .logo { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.topbar .logo span { color: #c8860a; }
.topbar .user-pill { background: rgba(255,255,255,0.1); color: #f5e6d3; padding: 0.35rem 0.8rem; border-radius: 20px; font-size: 0.85rem; display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }

/* SIDEBAR */
.sidebar { width: 220px; background: #1a0a00; min-height: calc(100vh - 56px); padding: 1rem 0; position: fixed; left: 0; top: 56px; z-index: 50; }
.sidebar a { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1.2rem; color: rgba(255,255,255,0.7); font-size: 0.92rem; text-decoration: none; transition: all 0.15s; }
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar .sec-label { padding: 0.9rem 1.2rem 0.3rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.35); }

/* MAIN CONTENT */
.main-content { margin-left: 220px; padding: 1.5rem 1.8rem; }

/* SECTIONS - nav-controlled visibility */
.nav-section { display: none; }
.nav-section.active { display: block; }

/* STAT GRID */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border-radius: 14px; padding: 1.2rem; box-shadow: 0 2px 12px rgba(26,10,0,0.12); }
.stat-card .s-label { font-size: 0.8rem; color: #6b6b6b; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem; }
.stat-card .s-value { font-size: 2rem; font-weight: 700; color: #1a0a00; line-height: 1.1; }
.stat-card .s-sub { font-size: 0.82rem; color: #6b6b6b; margin-top: 0.2rem; }

/* TABLES */
.table-wrap { overflow-x: auto; border-radius: 14px; box-shadow: 0 2px 12px rgba(26,10,0,0.12); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th { background: #1a0a00; color: #f5e6d3; padding: 0.75rem 1rem; text-align: left; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; white-space: nowrap; }
td { padding: 0.75rem 1rem; border-bottom: 1px solid #e8e8e8; font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fdf6ee; }

/* MODALS */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: #fff; border-radius: 14px; padding: 1.6rem; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 1.15rem; margin-bottom: 1.2rem; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; color: #3d1f00; }

/* ALERTS */
.alert { padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #1a0a00 0%, #3d1f00 100%); padding: 1.5rem; }
.login-box { background: #fff; border-radius: 14px; padding: 2.2rem; width: 100%; max-width: 380px; box-shadow: 0 8px 40px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 1.8rem; }
.login-logo .bc-icon { font-size: 2.5rem; }
.login-logo h1 { font-size: 1.3rem; color: #1a0a00; margin-top: 0.4rem; }
.login-logo p { font-size: 0.85rem; color: #6b6b6b; }

/* STAMP CARD VISUAL (cashier) */
.stamp-card-visual { background: linear-gradient(135deg, #1a0a00 0%, #3d1f00 100%); border-radius: 14px; padding: 1.4rem; color: #fff; margin-bottom: 1.2rem; }
.stamp-card-visual .cafe-name { font-size: 0.85rem; opacity: 0.7; margin-bottom: 0.2rem; }
.stamp-card-visual .customer-name { font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; }
.stamps-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; }
.stamp-dot { width: 100%; aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; transition: all 0.25s; }
.stamp-dot.filled { background: #c8860a; border-color: #c8860a; }
.stamp-count-text { margin-top: 0.9rem; font-size: 0.85rem; opacity: 0.8; }

/* ADMIN-SPECIFIC */
.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.2rem; display: flex; align-items: center; gap: 0.5rem; }
.toolbar { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input { max-width: 280px; }
.customer-avatar { width: 36px; height: 36px; border-radius: 50%; background: #c8860a; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.reward-card { background: #fff; border-radius: 14px; padding: 1rem 1.2rem; box-shadow: 0 2px 12px rgba(26,10,0,0.12); display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.reward-card .rname { font-weight: 700; }
.reward-card .rsub { font-size: 0.82rem; color: #6b6b6b; }
.user-row { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: #fff; border-radius: 8px; box-shadow: 0 2px 12px rgba(26,10,0,0.12); margin-bottom: 0.6rem; }
.user-row .uinfo { flex: 1; }
.user-row .uname { font-weight: 600; }
.user-row .usub { font-size: 0.82rem; color: #6b6b6b; }
.tx-stamp { color: #c8860a; font-weight: 600; }
.tx-redeem { color: #2e7d32; font-weight: 600; }
.tx-signup { color: #7a4520; font-weight: 600; }

/* QR */
.qr-display { text-align: center; padding: 1.2rem; }
.qr-display img { max-width: 180px; border-radius: 8px; }

/* CASHIER */
.action-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1rem; }
.action-btns button { padding: 0.8rem; font-size: 0.95rem; border-radius: 8px; font-weight: 600; }
.customer-found { animation: slideIn 0.25s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* RESPONSIVE */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
