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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

/* ---- Layout ---- */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.center-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

/* ---- Card ---- */
.card {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 400px;
}

/* ---- Typography ---- */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

.subtitle { color: #64748b; font-size: 0.95rem; margin-top: 4px; }
.muted { color: #94a3b8; font-size: 0.85rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); opacity: 0.9; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: #f1f5f9; color: #475569; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 8px; }
.btn-full { width: 100%; margin-top: 8px; padding: 14px; font-size: 1rem; }

/* ---- Inputs ---- */
.input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
  background: #fff;
}
.input:focus { border-color: #2563eb; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: #475569; margin-bottom: 5px; }

/* ---- PIN Screen ---- */
.pin-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 24px 0 28px;
}
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: transparent;
  transition: background .15s, border-color .15s;
}
.pin-dot.filled { background: #2563eb; border-color: #2563eb; }

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.pin-key {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 0;
  height: 64px;
  font-size: 1.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .1s, transform .1s;
  color: #1e293b;
}
.pin-key:active { background: #e0e7ff; transform: scale(0.95); }
.pin-key.del { font-size: 1.2rem; color: #64748b; }
.pin-key.empty { visibility: hidden; }

/* ---- Dashboard ---- */
.dash-header {
  background: #fff;
  padding: 20px 20px 0;
  border-bottom: 1px solid #e2e8f0;
}
.dash-header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 16px;
}
.dash-greeting { font-size: 1.3rem; font-weight: 700; }
.dash-balance { font-size: 0.9rem; color: #64748b; margin-top: 3px; }
.balance-amount { font-weight: 700; color: #dc2626; }
.balance-amount.zero { color: #16a34a; }

.dash-main { max-width: 900px; margin: 0 auto; padding: 24px 20px; }
.section-title { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #94a3b8; margin-bottom: 14px; }

.drink-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}
.drink-card {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.drink-card:hover { border-color: #93c5fd; box-shadow: 0 4px 16px rgba(37,99,235,0.1); }
.drink-card:active { transform: scale(0.95); background: #eff6ff; }
.drink-card.adding { border-color: #2563eb; background: #eff6ff; }
.drink-emoji { font-size: 2.4rem; line-height: 1; margin-bottom: 8px; }
.drink-name { font-size: 0.85rem; font-weight: 600; color: #334155; }
.drink-price { font-size: 0.8rem; color: #64748b; margin-top: 3px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform .3s ease;
  z-index: 100;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.history-section summary { cursor: pointer; padding: 8px 0; list-style: none; }
.history-section summary::-webkit-details-marker { display: none; }
.history-section summary::before { content: '▶ '; font-size: 0.7rem; }
details[open] summary::before { content: '▼ '; }
.history-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}
.history-item-emoji { font-size: 1.3rem; flex-shrink: 0; }
.history-item-info { flex: 1; min-width: 0; }
.history-item-name { font-size: 0.9rem; font-weight: 500; }
.history-item-time { font-size: 0.78rem; color: #94a3b8; margin-top: 1px; }
.history-item-price { font-size: 0.85rem; font-weight: 600; color: #475569; flex-shrink: 0; }

/* ---- Admin ---- */
.admin-page { min-height: 100vh; display: flex; flex-direction: column; }

.admin-header {
  background: #1e293b;
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-header h1 { font-size: 1.2rem; font-weight: 700; }

.admin-tabs {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-tab {
  flex-shrink: 0;
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  color: #64748b;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.admin-tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.admin-tab:hover { color: #334155; }

.admin-content { flex: 1; max-width: 900px; margin: 0 auto; width: 100%; padding: 24px 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }

.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid #e2e8f0; background: #fff; }
table { width: 100%; border-collapse: collapse; }
th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
}
td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: #64748b; }

.btn-row { display: flex; gap: 6px; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h2 { margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ---- Summary cards ---- */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.summary-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  border: 1.5px solid #e2e8f0;
}
.summary-card-name { font-weight: 600; font-size: 1rem; margin-bottom: 6px; }
.summary-card-balance { font-size: 1.4rem; font-weight: 700; color: #dc2626; }
.summary-card-balance.paid { color: #16a34a; }
.summary-card-detail { font-size: 0.78rem; color: #94a3b8; margin-top: 4px; }

/* ---- Utilities ---- */
.hidden { display: none !important; }
.error-msg { color: #dc2626; font-size: 0.85rem; margin-top: 8px; }
.success-msg { color: #16a34a; font-size: 0.85rem; margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }

@media (max-width: 480px) {
  .card { padding: 24px 20px; }
  .drink-grid { grid-template-columns: repeat(3, 1fr); }
  .drink-emoji { font-size: 2rem; }
}
