/* BTP-style shell: sidebar + main + top bar */
:root {
  --shell-bg: #0a0a0f;
  --shell-sidebar: #16161f;
  --shell-main: #0d0d12;
  --shell-blue: #2563eb;
  --shell-blue-hover: #1d4ed8;
  --shell-text: #e8e8f0;
  --shell-muted: #8b8b9e;
  --shell-border: rgba(255, 255, 255, 0.08);
}

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--shell-bg);
  color: var(--shell-text);
}

.shell-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--shell-sidebar);
  border-right: 1px solid var(--shell-border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: relative;
  transition: width 0.22s ease, padding 0.22s ease;
}

@media (prefers-reduced-motion: reduce) {
  .shell-sidebar {
    transition: none;
  }
}

.shell-sidebar-toggle {
  position: absolute;
  top: 14px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--shell-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--shell-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.shell-sidebar-toggle:hover {
  color: var(--shell-text);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.shell-sidebar-toggle-icon {
  font-size: 0.65rem;
  line-height: 1;
}

.shell-sidebar-toggle-icon-expand {
  display: none;
}

.app-shell.sidebar-collapsed .shell-sidebar-toggle-icon-collapse {
  display: none;
}

.app-shell.sidebar-collapsed .shell-sidebar-toggle-icon-expand {
  display: block;
}

.shell-nav-icon {
  display: none;
}

.app-shell.sidebar-collapsed .shell-nav a,
.app-shell.sidebar-collapsed .shell-sidebar-footer a,
.app-shell.sidebar-collapsed .shell-sidebar-footer button.shell-sidebar-admin {
  justify-content: center;
  padding-left: 8px;
  padding-right: 8px;
}

.app-shell.sidebar-collapsed .shell-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.app-shell.sidebar-collapsed .shell-nav-text {
  display: none;
}

.app-shell.sidebar-collapsed .shell-sidebar {
  width: 56px;
  padding-left: 0;
  padding-right: 0;
}

.app-shell.sidebar-collapsed .shell-brand {
  font-size: 0;
  color: transparent;
  padding-left: 8px;
  padding-right: 8px;
  padding-bottom: 20px;
  margin-bottom: 12px;
  text-align: center;
}

.app-shell.sidebar-collapsed .shell-brand::before {
  content: 'S';
  font-size: 1rem;
  font-weight: 700;
  color: var(--shell-text);
  letter-spacing: 0.05em;
}

.app-shell.sidebar-collapsed .shell-nav {
  padding-left: 6px;
  padding-right: 6px;
}

.app-shell.sidebar-collapsed .shell-sidebar-footer {
  padding-left: 6px;
  padding-right: 6px;
}

.shell-brand {
  padding: 0 44px 24px 20px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.05em;
  color: var(--shell-text);
  border-bottom: 1px solid var(--shell-border);
  margin-bottom: 16px;
}

.shell-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.shell-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: var(--shell-muted);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
}

.shell-nav a:hover {
  color: var(--shell-text);
  background: rgba(255, 255, 255, 0.05);
}

.shell-nav a.active {
  background: var(--shell-blue);
  color: #fff;
}

.shell-sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 0;
  border-top: 1px solid var(--shell-border);
}

.shell-sidebar-footer a {
  display: block;
  padding: 12px 14px;
  color: var(--shell-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.shell-sidebar-footer a:hover {
  color: var(--shell-text);
}

.hidden {
  display: none !important;
}

.shell-sidebar-footer button.shell-sidebar-admin {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  box-sizing: border-box;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--shell-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
}

.shell-sidebar-footer button.shell-sidebar-admin:hover {
  color: var(--shell-text);
}

.shell-sidebar-footer button.shell-sidebar-admin.shell-sidebar-admin--active {
  color: var(--shell-blue);
}

.shell-main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.shell-topbar {
  height: 52px;
  flex-shrink: 0;
  background: var(--shell-blue);
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  letter-spacing: 0.02em;
  gap: 12px;
}

.shell-topbar-user {
  margin-left: auto;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.9rem;
  color: #fff;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell-topbar-user.shown {
  display: inline-flex;
}

.shell-topbar-user::before {
  content: '◉';
  color: #6bff6b;
  font-size: 0.7rem;
  line-height: 1;
}

.shell-topbar-user-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
}

/* Log out button — hidden until an auth state with a signed-in user arrives. */
.shell-topbar-logout {
  display: none;
  align-items: center;
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.shell-topbar-logout.shown {
  display: inline-flex;
}

.shell-topbar-logout:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.6);
}

.shell-topbar-logout:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* The user pill's margin-left:auto already pushes this group right; on narrow
   screens drop the email and keep the button, which is the actionable part. */
@media (max-width: 700px) {
  .shell-topbar-user.shown {
    display: none;
  }
  /* With the pill hidden, its margin-left:auto no longer pushes the group right,
     so the button has to claim the free space itself. */
  .shell-topbar-logout.shown {
    margin-left: auto;
  }
}

.shell-content {
  flex: 1;
  padding: 24px;
  overflow: auto;
  background: var(--shell-main);
}

@media (max-width: 900px) {
  .shell-sidebar {
    width: 200px;
  }
  .shell-content {
    padding: 16px;
  }
}

@media (max-width: 700px) {
  .shell-sidebar-toggle {
    display: none;
  }

  .app-shell.sidebar-collapsed .shell-sidebar {
    width: 100%;
    padding: 12px;
  }

  .app-shell.sidebar-collapsed .shell-brand {
    font-size: 1rem;
    color: var(--shell-text);
    padding: 0 20px 12px;
    margin-bottom: 8px;
  }

  .app-shell.sidebar-collapsed .shell-brand::before {
    content: none;
  }

  .app-shell.sidebar-collapsed .shell-nav-icon {
    display: none;
  }

  .app-shell.sidebar-collapsed .shell-nav-text {
    display: inline;
  }

  .app-shell {
    flex-direction: column;
  }
  .shell-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid var(--shell-border);
  }
  .shell-brand {
    width: 100%;
    margin-bottom: 8px;
    padding-bottom: 12px;
    padding-right: 20px;
  }
  .shell-nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
  .shell-nav a {
    flex: 1;
    min-width: 100px;
    justify-content: center;
  }
  .shell-sidebar-footer button.shell-sidebar-admin {
    flex: 1;
    min-width: 100px;
    justify-content: center;
  }
  .shell-sidebar-footer {
    width: 100%;
    margin-top: 8px;
    padding-top: 12px;
  }
}

/* FAB stack bottom-right */
.fab-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  align-items: center;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--shell-blue);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}

.fab:hover {
  background: var(--shell-blue-hover);
  transform: scale(1.05);
}

.fab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Modal */
.shell-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.shell-modal-overlay.hidden {
  display: none;
}

.shell-modal {
  background: #1a1a22;
  border: 1px solid var(--shell-border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 440px;
  width: 100%;
}

.shell-modal h3 {
  font-size: 1.35rem;
  margin-bottom: 12px;
  color: #fff;
}

.shell-modal p {
  color: var(--shell-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

.shell-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
}

.shell-modal-actions button {
  background: none;
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  color: #fff;
}

.shell-modal-actions .btn-yes {
  color: #f97316;
}

/* QR scan modal */
.qr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.qr-modal-overlay.hidden {
  display: none;
}

.qr-modal-box {
  background: #1e1e28;
  border-radius: 12px;
  max-width: 420px;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--shell-border);
}

.qr-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--shell-border);
}

.qr-modal-head h4 {
  margin: 0;
  font-size: 1rem;
}

.qr-modal-close {
  background: none;
  border: none;
  color: var(--shell-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.qr-modal-body {
  padding: 16px;
}

.qr-modal-body video {
  width: 100%;
  border-radius: 8px;
}

.qr-modal-foot {
  padding: 10px 16px;
  background: var(--shell-blue);
  color: #fff;
  font-size: 0.85rem;
}
