/* ═══════════════════════════════════════════════════════════════════
   Unipin Redeemer — Design System (Airbnb-inspired Light)
   Font: Inter — Colors: Airbnb Rausch + neutrals
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ──────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand:       #FF385C;
  --brand-dark:  #E00B41;
  --brand-light: #FFF0F3;
  --brand-mid:   #FFD6DF;

  /* Neutrals */
  --gray-50:  #F7F7F7;
  --gray-100: #EBEBEB;
  --gray-200: #DDDDDD;
  --gray-300: #B0B0B0;
  --gray-400: #717171;
  --gray-500: #585858;
  --gray-600: #222222;
  --white:    #FFFFFF;

  /* Status */
  --success:     #008A05;
  --success-bg:  #EDFAF0;
  --warning:     #C47E00;
  --warning-bg:  #FFF8E0;
  --error:       #C13515;
  --error-bg:    #FFF0EC;
  --info:        #0066FF;
  --info-bg:     #EEF4FF;

  /* Layout */
  --sidebar-w:   240px;
  --header-h:    56px;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --shadow-xs:   0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:   0 1px 4px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10), 0 8px 32px rgba(0,0,0,.06);
  --transition:  0.18s ease;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--gray-600);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ── Typography ─────────────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
.text-sm  { font-size: .8rem; }
.text-xs  { font-size: .72rem; }
.text-muted { color: var(--gray-400); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ── App Shell ──────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.sidebar-brand svg { flex-shrink: 0; }

.sidebar-brand-text {
  line-height: 1.2;
}
.sidebar-brand-text .name {
  font-size: .95rem;
  font-weight: 800;
  color: var(--gray-600);
  letter-spacing: -.02em;
}
.sidebar-brand-text .sub {
  font-size: .68rem;
  color: var(--gray-400);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-label {
  font-size: .65rem;
  font-weight: 700;
  color: var(--gray-300);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
}
.nav-item svg { opacity: .7; flex-shrink: 0; }
.nav-item:hover {
  background: var(--gray-50);
  color: var(--gray-600);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--gray-100);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.user-card:hover { background: var(--gray-50); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, #f97316 100%);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info .user-name {
  font-size: .825rem;
  font-weight: 600;
  color: var(--gray-600);
}
.user-info .user-role {
  font-size: .68rem;
  color: var(--gray-400);
  text-transform: capitalize;
}

/* ── Main Content ────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-600);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content {
  padding: 28px;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-xs);
}

.card-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-body {
  padding: 20px 24px 24px;
}

.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--gray-600);
}

/* ── Stat Cards ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-100);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.04em;
  margin-bottom: 4px;
}

.stat-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.stat-card.total   .stat-icon { background: var(--gray-50); }
.stat-card.total   .stat-value { color: var(--gray-600); }
.stat-card.pending .stat-icon { background: var(--warning-bg); }
.stat-card.pending .stat-value { color: var(--warning); }
.stat-card.success .stat-icon { background: var(--success-bg); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.failed  .stat-icon { background: var(--error-bg); }
.stat-card.failed  .stat-value { color: var(--error); }
.stat-card.captcha .stat-icon { background: var(--info-bg); }
.stat-card.captcha .stat-value { color: var(--info); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn-primary:hover {
  background: var(--brand-dark);
  box-shadow: 0 2px 8px rgba(255,56,92,.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-600);
  border-color: var(--gray-200);
}
.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  background: #006b04;
  box-shadow: 0 2px 8px rgba(0,138,5,.3);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--error);
  color: white;
}
.btn-danger:hover {
  background: #a02a10;
  box-shadow: 0 2px 8px rgba(193,53,21,.3);
}

.btn-ghost {
  color: var(--gray-500);
  padding: 8px 12px;
}
.btn-ghost:hover {
  background: var(--gray-50);
  color: var(--gray-600);
}

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--gray-600);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255,56,92,.12);
}
.form-control::placeholder { color: var(--gray-300); }

textarea.form-control {
  resize: vertical;
  min-height: 100px;
  font-family: 'Courier New', monospace;
  font-size: .8rem;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Session indicator ───────────────────────────────────────────── */
.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(0,138,5,.18);
}
.session-pill.offline {
  background: var(--error-bg);
  color: var(--error);
  border-color: rgba(193,53,21,.18);
}
.session-pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}

/* ── Status Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-pending  { background: var(--warning-bg);  color: var(--warning); }
.badge-running  { background: var(--info-bg);     color: var(--info); }
.badge-success  { background: var(--success-bg);  color: var(--success); }
.badge-failed   { background: var(--error-bg);    color: var(--error); }
.badge-captcha  { background: #F0E6FF;            color: #7B2FBE; }

/* ── Table ───────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-100);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

thead th {
  background: var(--gray-50);
  font-weight: 700;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

td {
  padding: 11px 14px;
  color: var(--gray-600);
  vertical-align: middle;
}

.code-cell {
  font-family: 'Courier New', monospace;
  font-size: .78rem;
  color: var(--gray-500);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Log Output ──────────────────────────────────────────────────── */
.log-box {
  background: #1a1a2e;
  border-radius: var(--radius-md);
  padding: 16px;
  height: 280px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: .78rem;
  line-height: 1.7;
  color: #a9b7c6;
}

.log-box .log-line { display: block; }
.log-box .log-line.success { color: #6BCB77; }
.log-box .log-line.error   { color: #FF6B6B; }
.log-box .log-line.warning { color: #FFD166; }
.log-box .log-line.info    { color: #74C0FC; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(0,138,5,.2); }
.alert-error   { background: var(--error-bg);   color: var(--error);   border: 1px solid rgba(193,53,21,.2); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(0,102,255,.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(196,126,0,.2); }

/* ── Toast ───────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--gray-600);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: .85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp .25s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }
.toast.warning { background: var(--warning); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 480px;
  padding: 28px;
  animation: scaleIn .2s ease;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

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

.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-400);
  transition: background var(--transition);
  cursor: pointer;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-600); }

/* ── Divider ─────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--gray-100);
  margin: 20px 0;
}

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state svg { opacity: .3; margin-bottom: 12px; }
.empty-state h3 { font-size: .95rem; color: var(--gray-400); margin-bottom: 6px; }
.empty-state p  { font-size: .82rem; }

/* ── Running indicator ───────────────────────────────────────────── */
.running-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--brand) 0%, #f97316 50%, var(--brand) 100%);
  background-size: 200% 100%;
  border-radius: 999px;
  animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Login Page ──────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff5f7 0%, #fff0ec 50%, #f0f4ff 100%);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  padding: 40px;
  animation: scaleIn .3s ease;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
  gap: 8px;
}
.login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--brand) 0%, #f97316 100%);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(255,56,92,.3);
}
.login-logo h1 {
  font-size: 1.25rem;
  color: var(--gray-600);
}
.login-logo p {
  font-size: .78rem;
  color: var(--gray-400);
}

/* ── Page Sections (tabs) ────────────────────────────────────────── */
.page-section { display: none; }
.page-section.active { display: block; }

/* ── Grid layouts ────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Action bar ──────────────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Progress bar ────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray-100);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, #f97316 100%);
  border-radius: 999px;
  transition: width .4s ease;
}

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ── Denomination & Channel chips ──────────────────────────────────── */
.denom-chip, .channel-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  white-space: nowrap;
}
.denom-chip:hover, .channel-chip:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}
.denom-chip.selected, .channel-chip.selected {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255,56,92,.10);
}

/* ── Queue Filter Chip ──────────────────────────────────────────── */
.q-chip {
  padding: 5px 12px;
  font-size: .78rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--gray-400);
  cursor: pointer;
  transition: all .18s ease;
  line-height: 1.4;
  white-space: nowrap;
}
.q-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg, rgba(255,56,92,.08));
}
.q-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Queue table cell fixes ─────────────────────────────────────── */
#voucher-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
#voucher-table td.msg-cell {
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
  font-size: .78rem;
  max-height: 60px;
  overflow: hidden;
}
#voucher-table .code-cell {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
