:root {
  --accent: #16A34A;
  --accent-dark: #0F7C39;
  --bg: #faf6f2;
  --card: #ffffff;
  --border: #e6ded6;
  --text: #2b2320;
  --muted: #8a7d72;
  --success: #2e7d32;
  --danger: #c62828;
  --warn: #b8860b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--accent);
  color: #fff;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
}
.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #fff;
  color: var(--accent);
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 900;
  font-size: 19px;
  font-style: italic;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.brand-text {
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.3px;
}
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; flex-wrap: wrap; }

@media (max-width: 600px) {
  .topbar-inner { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .brand { gap: 6px; }
  .brand-icon { width: 24px; height: 24px; font-size: 13px; }
  .brand-text { font-size: 16px; }
  .topbar-user { gap: 4px; font-size: 11px; flex-wrap: wrap; row-gap: 4px; }
  .topbar-user span { font-size: 11px; }
  .topbar-user .btn.btn-sm { padding: 4px 7px; font-size: 11px; }
}
@media (max-width: 360px) {
  .topbar-user > span { flex-basis: 100%; }
}

.quick-menu {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.quick-menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.quick-menu-btn:hover { background: #E7F4EA; text-decoration: none; }
.quick-menu-btn:active { transform: scale(0.97); }
.quick-menu-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.quick-menu-icon { font-size: 28px; line-height: 1; }
.quick-menu-label { line-height: 1.2; }

@media (max-width: 480px) {
  .quick-menu { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 12px 0; }
  .quick-menu-btn { padding: 14px 4px; font-size: 13px; }
  .quick-menu-icon { font-size: 24px; }
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: #e8f5e9; color: var(--success); border: 1px solid #c8e6c9; }
.flash-error { background: #ffebee; color: var(--danger); border: 1px solid #ffcdd2; }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.form-row input[type=text],
.form-row input[type=number],
.form-row input[type=password],
.form-row input[type=date],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.form-help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-radio-group { display: flex; gap: 20px; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.15); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 16px 24px; font-size: 17px; font-weight: 700; border-radius: 8px; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8e1d1d; }
.btn-warn { background: var(--warn); }
.btn-secondary { background: #6b6b6b; }
.btn-active { background: var(--success) !important; }

.scan-status-centered { text-align: center; }
.balance-check-notice {
  text-align: center;
  color: var(--danger);
  font-weight: 800;
  font-size: 16px;
  margin: 8px 0 0;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
td.wrap-cell { white-space: normal; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table-scroll { overflow-x: auto; }
.table-scroll table { width: auto; min-width: 100%; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-active { background: #e8f5e9; color: var(--success); }
.badge-used { background: #e3e6f0; color: #3949ab; }
.badge-revoked { background: #ffebee; color: var(--danger); }
.badge-expired { background: #f5f0e6; color: var(--warn); }

.filters { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: end; }
.filters .form-row { margin-bottom: 0; min-width: 160px; }

.login-wrap {
  max-width: 380px;
  margin: 80px auto;
  padding: 32px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.login-wrap h1 { text-align: center; margin-bottom: 24px; }

.brand-on-light {
  display: flex;
  width: 100%;
  justify-content: center;
  margin-bottom: 28px;
}
.brand-on-light .brand-icon {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}
.brand-on-light .brand-text {
  color: var(--text);
}

.coupon-preview img { max-width: 320px; border: 1px solid var(--border); border-radius: 8px; }

.scan-box {
  max-width: 420px;
  margin: 0 auto;
}
.reader-wrapper {
  position: relative;
  max-width: 300px;
  margin: 0 auto;
}
#reader {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
.scan-mask {
  position: absolute;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  border: 2px solid #fff;
  border-radius: 8px;
  pointer-events: none;
  z-index: 5;
}

.result-box { padding: 16px; border-radius: 8px; margin-top: 16px; font-size: 15px; }
.result-ok { background: #e8f5e9; border: 1px solid #c8e6c9; }
.result-fail { background: #ffebee; border: 1px solid #ffcdd2; }

.balance-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.balance-controls .btn {
  flex: 0 0 auto;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
}
.balance-amount-input {
  flex: 1 1 100px;
  min-width: 90px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.scan-success-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(46, 125, 50, 0.92);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  padding: 18px 32px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.scan-success-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.scan-success-toast.hide {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}
.modal-box-sm { max-width: 380px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}
.modal-body { padding: 18px; }
.modal-footer {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.modal-footer .btn { flex: 1; text-align: center; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 20px; font-weight: 800; color: var(--text); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 16px;
  height: 200px;
  margin-top: 24px;
  padding-top: 8px;
}
.bar-chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  height: 100%;
}
.bar-chart-value { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.bar-chart-track {
  width: 100%;
  max-width: 56px;
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg);
  border-radius: 6px 6px 0 0;
  overflow: hidden;
}
.bar-chart-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  transition: height 0.3s ease;
}
.bar-chart-label { font-size: 13px; color: var(--muted); margin-top: 8px; text-align: center; }
