: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: 12px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-text-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-slogan {
  font-size: 0.74rem;
  font-weight: 800;
  color: #059669;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 3px;
}

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

.brand-logo-img {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.22), 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  flex-shrink: 0;
  display: block;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.brand:hover .brand-logo-img {
  transform: scale(1.05);
}

@media (max-width: 640px) {
  .brand-logo-img {
    width: 42px;
    height: 42px;
    border-radius: 11px;
  }
  .brand {
    gap: 9px;
  }
  .brand-title {
    font-size: 1.15rem;
  }
  .brand-slogan {
    font-size: 0.68rem;
  }
}

.app-header {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-header::-webkit-scrollbar {
  display: none;
  height: 0;
  width: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 rgba(241, 245, 249, 0.6);
  padding-bottom: 6px;
}

.nav-links::-webkit-scrollbar {
  height: 6px;
}

.nav-links::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.7);
  border-radius: 999px;
  margin: 0 4px;
}

.nav-links::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  transition: background 0.2s;
}

.nav-links::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.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 */
/* Apple Wallet / iOS Dynamic Island Ticket Card */
.ticket-card {
  text-align: center;
  padding: 26px 20px 28px;
  border-radius: 28px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 20px 45px -12px rgba(15, 23, 42, 0.1), 0 4px 16px -2px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: visible;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ticket-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 4px;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(90deg, #2563eb 0%, #38bdf8 50%, #6366f1 100%);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.ticket-card.called {
  border-color: #10b981;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
  animation: apple-call-glow 2.2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.ticket-card.called::before {
  background: linear-gradient(90deg, #059669, #10b981, #34d399);
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.5);
}

@keyframes apple-call-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45), 0 20px 45px -12px rgba(16, 185, 129, 0.2);
  }
  60% {
    box-shadow: 0 0 0 22px rgba(16, 185, 129, 0), 0 24px 50px -10px rgba(16, 185, 129, 0.25);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0), 0 20px 45px -12px rgba(16, 185, 129, 0.2);
  }
}

/* Apple Wallet Perforation Divider */
.ticket-wallet-divider {
  position: relative;
  margin: 20px -20px 18px;
  height: 1px;
  background: repeating-linear-gradient(90deg, #cbd5e1 0, #cbd5e1 6px, transparent 6px, transparent 12px);
}

.ticket-wallet-divider::before,
.ticket-wallet-divider::after {
  content: '';
  position: absolute;
  top: -9px;
  width: 18px;
  height: 18px;
  background: var(--bg);
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.ticket-wallet-divider::before {
  left: -9px;
}

.ticket-wallet-divider::after {
  right: -9px;
}

.ticket-number-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 800;
  color: #64748b;
  margin-bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ticket-number {
  font-size: 4.8rem;
  font-weight: 950;
  letter-spacing: -2.5px;
  line-height: 0.95;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #0f172a 30%, #1e293b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.ticket-card.called .ticket-number {
  background: linear-gradient(180deg, #065f46 20%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Dynamic Island Style Floating Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.25s ease;
}

.badge-waiting {
  background: #f8fafc;
  color: #1e293b;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  animation: apple-island-breath 3s infinite ease-in-out;
}

@keyframes apple-island-breath {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
  }
}

.badge-called {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
  font-size: 1.05rem;
  padding: 10px 24px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
  letter-spacing: 0.3px;
}

.badge-completed {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

/* iOS Widget Style Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0 10px;
}

.metric-box {
  background: #f8fafc;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 18px;
  padding: 14px 12px;
  text-align: center;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.metric-box:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
}

.metric-val {
  font-size: 1.75rem;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.05;
  letter-spacing: -0.5px;
}

.metric-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-top: 5px;
}

/* 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;
  }

  /* Printable Queue Report */
  .active-print-report,
  .active-print-report .printable-report,
  .printable-report,
  .printable-report * {
    visibility: visible !important;
  }
  .active-print-report {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    inset: auto !important;
    display: block !important;
    z-index: 999999 !important;
  }
  .printable-report {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 10px 15px !important;
    background: white !important;
    color: #0f172a !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
    max-height: none !important;
  }
  .no-print {
    display: none !important;
  }
}

/* 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);
}

/* iOS Modern Styling */
.ios-form-group {
  margin-bottom: 20px;
}
.ios-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.86rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 7px;
  letter-spacing: -0.01em;
}
.ios-input {
  width: 100%;
  padding: 13px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  outline: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.ios-input:focus {
  background: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12), 0 2px 4px rgba(0,0,0,0.04);
}
.ios-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}
.ios-hint {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.45;
}

/* Apple iOS 18 Segmented Navigation Bar */
.apple-segmented-bar {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 18px;
  margin: 16px 0 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 2px 6px rgba(0, 0, 0, 0.02);
  gap: 4px;
  position: sticky;
  top: 72px;
  z-index: 45;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.apple-segment-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 3px;
  background: transparent;
  border: none;
  border-radius: 14px;
  color: #64748b;
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  user-select: none;
  min-width: 0;
  line-height: 1.15;
}

.apple-segment-btn:hover {
  color: #1e293b;
  background: rgba(255, 255, 255, 0.4);
}

.apple-segment-btn .segment-icon {
  font-size: 1.25rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.apple-segment-btn .segment-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
  font-weight: 700;
}

.apple-segment-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.apple-segment-btn.active .segment-icon {
  transform: scale(1.1);
}

.apple-segment-btn .segment-badge {
  position: absolute;
  top: 2px;
  right: 6px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.64rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 10px;
  line-height: 1.2;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.apple-segment-btn .segment-sub-badge {
  font-size: 0.62rem;
  font-weight: 800;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 6px;
  margin-top: 1px;
  letter-spacing: -0.2px;
  line-height: 1;
}

.apple-segment-btn.active .segment-sub-badge {
  background: #fde68a;
  color: #92400e;
}

/* Apple Grouped Inset Box */
.apple-group-box {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.apple-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.apple-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.96rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.2px;
  margin: 0;
}

.apple-pill-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}

.apple-pill-status.active {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.apple-pill-status.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.client-tab-pane {
  animation: appleFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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