.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--content-bg);
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  transition: var(--transition-base);
  z-index: 100;
  overflow: hidden;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  background: var(--sidebar-logo-bg);
  color: var(--sidebar-text-active);
  flex-shrink: 0;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-primary);
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  height: 36px;
  color: var(--sidebar-text);
  text-decoration: none;
  position: relative;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  border-radius: var(--radius-base);
  font-size: 13.5px;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}

.nav-item.is-active {
  background: var(--sidebar-bg-dk);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

.nav-item.is-active::before {
  content: none;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-width: 1.75;
  opacity: 0.85;
}

.nav-item.is-active .nav-icon {
  opacity: 1;
}

.nav-text {
  font-size: inherit;
  flex: 1;
  opacity: 1;
  transition: opacity 0.2s;
}

.nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 10px 8px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-placeholder);
  padding: 14px 14px 4px;
  white-space: nowrap;
}
.nav-section-label:first-child {
  padding-top: 8px;
}
.app-shell.is-collapsed .nav-section-label {
  opacity: 0;
  height: 8px;
  padding: 0;
  overflow: hidden;
}

.nav-item-external {
  color: var(--sidebar-text);
  opacity: 0.7;
}

.nav-external {
  width: 12px;
  height: 12px;
  opacity: 0.6;
  flex-shrink: 0;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  box-shadow: var(--topbar-shadow);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-toggle {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-regular);
  cursor: pointer;
  border-radius: var(--radius-base);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.topbar-toggle:hover {
  background: var(--color-bg-subtle);
  color: var(--text-primary);
}

.topbar-toggle svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.breadcrumb-item.is-current {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-sep {
  color: var(--text-placeholder);
}

.topbar-spacer {
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-regular);
  padding: 6px 10px;
  border-radius: var(--radius-base);
  background: var(--color-bg-subtle);
}

/* Quick-add dropdown — topbar shortcut for creating new booth/template/QR */
.quick-add {
  position: relative;
  margin-right: 8px;
}
.quick-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px 0 10px;
  background: var(--ea-primary);
  color: #fff;
  border: 1px solid var(--ea-primary);
  border-radius: var(--radius-base);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.08);
  transition: background 0.15s, border-color 0.15s;
}
.quick-add-btn:hover { background: var(--ea-primary-hover); border-color: var(--ea-primary-hover); }
.quick-add-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.quick-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.18);
  padding: 6px;
  z-index: 60;
  animation: quick-add-in 0.12s ease;
}
.quick-add-menu[hidden] { display: none; }
.quick-add-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-base) - 2px);
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.quick-add-item:hover { background: var(--color-bg-subtle); }
.quick-add-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-secondary); }
@keyframes quick-add-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.topbar-user-email {
  font-weight: 500;
  color: var(--text-primary);
}

.content {
  flex: 1;
  padding: 24px;
  background: var(--content-bg);
}

.content-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.app-shell.is-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

.app-shell.is-collapsed .sidebar-logo-text,
.app-shell.is-collapsed .nav-text,
.app-shell.is-collapsed .nav-external {
  opacity: 0;
  pointer-events: none;
}

.app-shell.is-collapsed .nav-item {
  padding: 0;
  justify-content: center;
}

.app-shell.is-collapsed .sidebar-logo {
  padding: 0;
  justify-content: center;
}

.app-shell.is-collapsed .main {
  margin-left: var(--sidebar-width-collapsed);
}

@media (max-width: 992px) {
  .sidebar {
    width: var(--sidebar-width-collapsed);
  }
  .sidebar-logo-text,
  .nav-text,
  .nav-external {
    opacity: 0;
    pointer-events: none;
  }
  .nav-item {
    padding: 0;
    justify-content: center;
  }
  .sidebar-logo {
    padding: 0;
    justify-content: center;
  }
  .main {
    margin-left: var(--sidebar-width-collapsed);
  }
}

@media (max-width: 600px) {
  .content {
    padding: 16px;
  }
  .breadcrumb-item:not(.is-current) {
    display: none;
  }
  .breadcrumb-sep {
    display: none;
  }
}

/* ── Phone + tablet (≤991px): off-canvas sidebar + full-width content ──
   Covers the old tablet dead-zone (769–991px) that was stuck in icon-only
   collapse — now everything below the desktop breakpoint uses the hamburger
   drawer. The !important rules here override the ≤992px icon-collapse block
   above for this range. */
@media (max-width: 991px) {
  /* Sidebar slides in over the content from the left; hidden by default.
     Tapping the toggle adds .is-mobile-open (see app.js bindSidebarToggle). */
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1000;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.15);
  }
  /* Show full labels in the mobile drawer (cancel the ≤992 icon-collapse). */
  .sidebar-logo-text, .nav-text, .nav-external { opacity: 1 !important; pointer-events: auto !important; }
  .nav-item { padding: 0 16px !important; justify-content: flex-start !important; }
  .sidebar-logo { padding: 0 16px !important; justify-content: flex-start !important; }
  .app-shell.is-mobile-open .sidebar { transform: translateX(0); }

  /* Content takes the full width — ignore desktop collapse margins. */
  .main, .app-shell.is-collapsed .main { margin-left: 0 !important; }
  .content { padding: 14px; }

  /* Backdrop behind the open sidebar (toggled with .is-mobile-open). */
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 999; }

  /* Topbar fits a phone. */
  .topbar { padding: 0 12px; gap: 8px; }
  .quick-add-btn span { display: none; }
  .topbar-user-email { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Page chrome stacks instead of crowding. */
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .stat-grid { grid-template-columns: 1fr !important; }
  .filter-bar { flex-direction: column; align-items: stretch; gap: 10px; }

  /* Wide tables scroll horizontally instead of breaking the layout. */
  .el-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  /* Drawers / modals go full-width. */
  .drawer { max-width: 100% !important; width: 100% !important; }
}
