:root {
  --op-bg: #f1f5f9;
  --op-header-bg: #0f172a;
  --op-panel-bg: #ffffff;
  --op-border: #e2e8f0;
  --op-text: #0f172a;
  --op-muted: #64748b;
  --op-primary: #2563eb;
  --op-primary-hover: #1d4ed8;
  --op-success: #16a34a;
  --op-warning: #d97706;
  --op-danger: #dc2626;
  --op-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 22px rgba(15, 23, 42, 0.05);
}

[hidden] {
  display: none !important;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--op-bg);
  color: var(--op-text);
  min-height: 100vh;
}

/* Loading screen shown while checkAuth() resolves */
.op-loading {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--op-muted);
  font-weight: 600;
}

.op-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--op-border);
  border-top-color: var(--op-primary);
  border-radius: 50%;
  animation: op-spin 0.8s linear infinite;
}

@keyframes op-spin {
  to { transform: rotate(360deg); }
}

.op-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.op-header {
  background: var(--op-header-bg);
  color: #ffffff;
  padding: 16px clamp(16px, 3vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.op-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.op-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--op-primary), #3b82f6);
  color: #ffffff;
  font-size: 1.5rem;
  font-weight: 800;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.op-brand-info h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.op-brand-info p {
  font-size: 0.82rem;
  color: #94a3b8;
}

.op-header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.op-clock {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #cbd5e1;
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  background-color: rgba(255, 255, 255, 0.05);
}

.conn-status .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.conn-status.online {
  color: #10b981;
}

.conn-status.offline {
  color: #ef4444;
  animation: conn-status-pulse 1.5s infinite;
}

@keyframes conn-status-pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Profile widget (own to this page, legible against the dark header) */
#userProfileInfo {
  position: relative;
  flex-shrink: 0;
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s ease;
}

.profile-trigger:hover {
  background: #273449;
}

.profile-trigger .profile-caret {
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

#userProfileInfo.open .profile-trigger .profile-caret {
  transform: rotate(180deg);
}

.profile-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid var(--op-border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  z-index: 20;
}

#userProfileInfo.open .profile-dropdown {
  display: block;
}

.profile-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--op-border);
}

.profile-dropdown-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--op-text);
}

.profile-dropdown-meta {
  font-size: 12px;
  color: var(--op-muted);
  margin-top: 2px;
}

.profile-dropdown-shift-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.profile-dropdown-shift-actions .btn {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.profile-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--op-text);
}

.profile-dropdown-item:hover {
  background: #f8fafc;
}

.profile-dropdown-item.logout {
  color: var(--op-danger);
}

/* Queue warning banner */
.op-banner {
  background: #fff7ed;
  border-bottom: 1px solid #fdba74;
  color: #9a3412;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  padding: 12px 20px;
}

/* Main layout */
.op-main {
  flex: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 18px;
  align-items: start;
}

.op-noshow-panel {
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  .op-main {
    grid-template-columns: 1fr;
  }
}

.op-panel {
  background: var(--op-panel-bg);
  border: 1px solid var(--op-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--op-shadow);
  display: grid;
  gap: 14px;
  align-content: start;
}

.op-panel h2 {
  font-size: 1.05rem;
  font-weight: 800;
}

.op-field {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--op-muted);
}

.op-field select {
  font: inherit;
  padding: 10px 11px;
  border: 1px solid var(--op-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--op-text);
}

.op-session-indicator {
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.95rem;
}

.op-session-indicator.closed {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
}

.op-session-indicator.open {
  background: #ecfdf5;
  border: 1px solid #86efac;
  color: #15803d;
}

.op-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.op-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.btn {
  font: inherit;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 750;
  font-size: 0.88rem;
  color: #ffffff;
  cursor: pointer;
  background: var(--op-primary);
  transition: background 0.2s ease, opacity 0.2s ease;
}

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

.btn.secondary {
  background: #334155;
}

.btn.secondary:hover {
  background: #1e293b;
}

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

.btn.success:hover {
  background: #15803d;
}

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

.btn.warning:hover {
  background: #b45309;
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.op-metric-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.op-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.op-metric {
  border: 1px solid var(--op-border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.op-metric span {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--op-muted);
}

.op-metric strong {
  display: block;
  margin-top: 4px;
  font-size: 1.4rem;
}

.op-muted {
  color: var(--op-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.op-active-ticket {
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  background: #f8fafc;
  border: 1px solid var(--op-border);
}

.op-active-ticket:not(.empty) {
  background: #ecfdf5;
  border-color: #86efac;
}

.op-ticket-number {
  font-size: clamp(32px, 6vw, 52px);
  font-weight: 850;
  line-height: 1;
  color: var(--op-text);
}

.op-active-ticket:not(.empty) .op-ticket-number {
  color: #15803d;
}

.op-ticket-details {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--op-muted);
}

.op-transfer {
  border: 1px solid var(--op-border);
  border-radius: 8px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.op-transfer summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
}

.op-transfer[open] summary {
  margin-bottom: 4px;
}

.op-status {
  min-height: 20px;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f8fafc;
  border: 1px solid var(--op-border);
  color: var(--op-muted);
}

.op-status.ok {
  background: #ecfdf5;
  border-color: #86efac;
  color: #15803d;
}

.op-status.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.op-table-wrap {
  overflow-x: auto;
}

.op-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.op-table th {
  background: #f1f5f9;
  padding: 10px;
  font-weight: 700;
  border-bottom: 1px solid var(--op-border);
}

.op-table td {
  padding: 10px;
  border-bottom: 1px solid var(--op-border);
}

.op-table .op-table-empty {
  text-align: center;
  color: var(--op-muted);
  padding: 16px;
}

.op-table button {
  font: inherit;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--op-border);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.op-table button:hover {
  background: #f8fafc;
}
