:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 30px -10px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  width: 100%;
}

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

/* Header */
header.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
  text-decoration: none;
}

.brand-icon {
  font-size: 1.4rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.nav-links button,
.nav-links .btn,
.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s;
  width: auto !important;
  white-space: nowrap !important;
  flex-shrink: 0;
}

.nav-links a:hover, .nav-links a.active,
.nav-links button:hover {
  color: var(--primary);
  background: var(--primary-light);
}
  background: var(--primary-light);
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* Ticket Hero Card */
.ticket-card {
  text-align: center;
  padding: 32px 20px;
  border-radius: 24px;
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.ticket-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
}

.ticket-card.called {
  border-color: var(--success);
  animation: pulse-glow 2s infinite;
}

.ticket-card.called::before {
  background: var(--success);
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 18px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ticket-number-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.ticket-number {
  font-size: 4.2rem;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--text-main);
  line-height: 1;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

.badge-waiting {
  background: var(--warning-light);
  color: #b45309;
}

.badge-called {
  background: var(--success-light);
  color: #065f46;
  font-size: 1.05rem;
  padding: 8px 20px;
}

.badge-completed {
  background: #f1f5f9;
  color: var(--text-muted);
}

/* Status Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.metric-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
}

.metric-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* Call Alert Banner */
.call-banner {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border-radius: 18px;
  padding: 24px 16px;
  text-align: center;
  margin: 20px 0;
  animation: bounce 0.6s ease;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.call-banner h2 {
  font-size: 1.7rem;
  margin-bottom: 6px;
  font-weight: 800;
}

.call-banner p {
  font-size: 1.1rem;
  opacity: 0.95;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  width: 100%;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f1f5f9;
}

.btn-karma {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

/* Audio / notification status pill */
.notice-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e2e8f0;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 8px 14px;
  border-radius: 999px;
  margin: 12px auto 0;
  width: fit-content;
  cursor: pointer;
}

.notice-pill.enabled {
  background: var(--success-light);
  color: #065f46;
}

/* Admin Grid */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 800px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.operator-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

/* Queue List */
.ticket-list {
  list-style: none;
  margin-top: 14px;
}

.ticket-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.ticket-item:last-child {
  border-bottom: none;
}

.ticket-item-num {
  font-weight: 700;
  font-size: 1.1rem;
}

.ticket-item-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Display (Hall Screen) */
body.display-mode {
  background: #090d16;
  color: #ffffff;
  overflow: hidden;
}

.display-header {
  padding: 24px 40px;
  background: #0f172a;
  border-bottom: 2px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.display-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #38bdf8;
}

.display-clock {
  font-size: 1.6rem;
  font-weight: 600;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.display-content {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  height: calc(100vh - 100px);
  padding: 30px 40px;
  gap: 30px;
}

.display-active-card {
  background: #131d33;
  border: 3px solid #2563eb;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  box-shadow: 0 0 60px rgba(37, 99, 235, 0.25);
}

.display-active-card.calling {
  border-color: #10b981;
  box-shadow: 0 0 80px rgba(16, 185, 129, 0.4);
  animation: display-pulse 1s infinite alternate;
}

@keyframes display-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.02); }
}

.display-huge-number {
  font-size: 8rem;
  font-weight: 900;
  color: #38bdf8;
  line-height: 1;
  margin: 16px 0;
}

.display-active-card.calling .display-huge-number {
  color: #34d399;
}

.display-huge-counter {
  font-size: 2.8rem;
  font-weight: 700;
  color: #f8fafc;
}

.display-queue-list {
  background: #131d33;
  border: 1px solid #1e293b;
  border-radius: 28px;
  padding: 30px;
}

.display-queue-item {
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #1e293b;
  font-size: 1.8rem;
  font-weight: 700;
}

/* Modal for QR printing and dialogs */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: 20px;
  max-width: 480px;
  width: 100%;
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  margin: auto;
}

.qr-image-wrapper {
  margin: 20px auto;
  padding: 16px;
  background: #ffffff;
  border: 2px dashed var(--border);
  border-radius: 16px;
  display: inline-block;
}

.qr-image-wrapper img {
  display: block;
  max-width: 260px;
  height: auto;
  border-radius: 8px;
}

@media print {
  body * {
    visibility: hidden;
  }
  .printable-poster, .printable-poster * {
    visibility: visible;
  }
  .printable-poster {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 40px;
  }
}

/* UI Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: 0.25s ease;
  border-radius: 26px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s ease;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
input:checked + .switch-slider {
  background-color: var(--primary);
}
input:checked + .switch-slider:before {
  transform: translateX(20px);
}
