:where(.app-shell, .app-topbar, .drawer-overlay, .modal-overlay)
  :is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* 桌面自适应全视口宽度，清爽留白，底部不再需要给悬浮条留巨大空白 */
.workspace {
  --ws-pad-x: clamp(14px, 1.8vw, 28px);
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0 var(--ws-pad-x) calc(28px + env(safe-area-inset-bottom, 0px));
  gap: 12px;
}

.app-topbar + .app-shell {
  --workspace-sticky-top: var(--section-nav-height);
}

/* 顶部自适应指标卡片区（随页面滚动，4~8 张卡等宽铺满） */
.queue-bar {
  padding-top: 14px;
}

.queue-bar .view-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  min-width: 0;
}

.queue-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  min-height: 70px;
  padding: 11px 14px 10px;
  text-align: left;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s, transform 0.14s;
}

.queue-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2.5px;
  background: transparent;
  transition: background-color 0.14s;
}

.queue-card-label {
  display: block;
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-count {
  display: block;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.queue-count.is-zero {
  color: #9ca3af;
  font-weight: 600;
}

.queue-soon {
  border-color: #fde68a;
  background: #fffdf7;
}

.queue-soon .queue-count {
  color: var(--warn-700);
}

.queue-late {
  border-color: #fecaca;
  background: #fffafa;
}

.queue-late .queue-count {
  color: var(--danger-700);
}

.queue-card:hover:not(.is-active) {
  border-color: var(--accent-border);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.queue-card.is-active {
  background: #f0f6ff;
  border-color: #93c5fd;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.queue-card.is-active::before {
  background: var(--accent);
}

.queue-card.is-active .queue-card-label {
  color: var(--accent-ink);
  font-weight: 600;
}

.queue-card.is-active .queue-count {
  color: var(--accent);
}

.queue-card.is-active .queue-count.is-zero {
  color: #60a5fa;
}

.queue-card.is-active.queue-soon {
  background: #fffbeb;
  border-color: var(--warn-border);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.12);
}

.queue-card.is-active.queue-soon::before {
  background: #d97706;
}

.queue-card.is-active.queue-soon .queue-card-label,
.queue-card.is-active.queue-soon .queue-count {
  color: var(--warn-700);
}

.queue-card.is-active.queue-late {
  background: #fef2f2;
  border-color: var(--danger-border);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.12);
}

.queue-card.is-active.queue-late::before {
  background: #dc2626;
}

.queue-card.is-active.queue-late .queue-card-label,
.queue-card.is-active.queue-late .queue-count {
  color: var(--danger-700);
}

/* 搜索与筛选工具栏（仅此条吸顶，滚动列表时保持清爽视野） */
.workspace-sticky-bar {
  position: sticky;
  top: var(--workspace-sticky-top, 0px);
  z-index: 30;
  margin-inline: calc(-1 * var(--ws-pad-x));
  padding: 10px var(--ws-pad-x);
  background: rgba(247, 248, 250, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
}

/* 顶部新建反馈主按钮 */
.btn-create-entry {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.18);
}

/* 筛选条：搜索框在最左侧，宽屏（>=1100px）直接全展示所有筛选项，窄屏/手机折叠到更多筛选 */
.workspace-sticky-bar .filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  gap: 8px;
}

.filter-bar .search-box {
  flex: 1 1 200px;
  max-width: 240px;
  min-width: 180px;
}

.filter-bar .filter-select {
  flex: 0 0 auto;
  width: auto;
  min-width: 98px;
}

.filter-bar .btn {
  flex: 0 0 auto;
}

.filter-bar :is(.search-input, .filter-select, .btn) {
  height: 36px;
  min-height: 36px;
  font-size: 13px;
  border-radius: 8px;
}

.filter-bar .filter-toggle {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.secondary-filters {
  display: contents;
}

@media (max-width: 1099px) {
  .filter-bar .filter-toggle {
    display: inline-flex;
  }

  .secondary-filters {
    flex: 1 0 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-light);
  }

  .filter-toggle[aria-expanded="false"] ~ .secondary-filters {
    display: none;
  }
}

/* 桌面端表格：清爽纯白卡片，细腻边框与柔和阴影 */
.table-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.ticket-table tbody tr:last-child td {
  border-bottom: 0;
}

.ticket-table tbody tr[data-ticket-id]:focus-within:not(.is-selected) {
  background: var(--bg-hover);
}

.ticket-table tbody .empty-cell {
  padding-block: 42px;
}

.empty-card {
  padding-block: 36px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

:is(.empty-cell, .empty-card) div:has(> [data-empty-reset]) {
  margin-top: 10px;
}

/* 桌面/手机共用列表底部分页条 */
.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  padding: 4px 2px 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.list-footer-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-export-csv {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.btn-export-csv:hover {
  color: var(--accent);
  border-color: var(--accent-border);
}

/* 订单号 / 手机号快捷复制（一键复制图标 + 双击文字复制，不误触弹抽屉） */
.copyable-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  cursor: default;
}

.copyable-text {
  user-select: text;
  cursor: text;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-inline-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.12s, background-color 0.12s, color 0.12s, border-color 0.12s;
}

.copyable-cell:hover .copy-inline-btn,
.copy-inline-btn:focus-visible {
  opacity: 1;
}

.copy-inline-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.copy-inline-btn.is-copied {
  opacity: 1;
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #059669;
}

.detail-copy-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 顶栏常驻「一键催办」按钮与轻量确认弹窗（不额外展开占行，零布局抖动） */
.btn-batch-remind-entry {
  height: 34px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 8px;
  gap: 5px;
  color: var(--text-secondary);
}

.btn-batch-remind-entry.has-selection {
  background: var(--accent-soft);
  border-color: #93c5fd;
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-batch-remind-entry:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.batch-remind-modal {
  max-width: 440px;
}

.batch-remind-summary {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.ticket-select-cell {
  text-align: center;
  width: 38px;
}

.ticket-select-cell input[type="checkbox"],
#ticket-select-all {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

.ticket-select-cell input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

/* 反钻空子异常微标签 */
.tag-revisit-after {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.tag-owner-inactive {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fda4af;
}

.tag-handoff-warn,
.tag-verify-warn {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.pagination {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-info {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 68px;
  text-align: center;
}

.toast-container {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
}

.ticket-card {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.ticket-card:focus-within {
  border-color: var(--accent-border);
}

.ticket-card-meta .mono-id {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   平板 & 手机响应式（保持清晰可点，不挤不遮挡）
   ========================================================================== */

@media (max-width: 900px) {
  .app-topbar {
    flex-wrap: wrap;
    padding-block: calc(8px + env(safe-area-inset-top, 0px)) 8px;
    gap: 8px;
  }

  .app-topbar-left {
    flex: 1 1 auto;
  }

  .app-topbar-right {
    flex: 1 1 auto;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .app-topbar {
    position: relative;
  }

  .app-topbar + .app-shell {
    --workspace-sticky-top: 0px;
  }

  .app-brand-name {
    font-size: 14px;
  }

  .topbar-actor-group {
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  .topbar-actor-select {
    max-width: min(46vw, 170px);
  }

  .queue-bar {
    padding-top: 8px;
  }

  .queue-bar .view-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 2px;
  }

  .queue-bar .view-tabs::-webkit-scrollbar {
    display: none;
  }

  .queue-card {
    flex: 0 0 auto;
    min-width: 106px;
    min-height: 58px;
    padding: 8px 11px;
    gap: 4px;
  }

  .queue-card-label {
    font-size: 12px;
  }

  .queue-count {
    font-size: 19px;
  }

  .workspace-sticky-bar {
    display: contents;
  }

  .workspace-sticky-bar .filter-bar {
    display: grid;
    position: sticky;
    top: 0;
    z-index: 30;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    max-height: 75dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-inline: calc(-1 * var(--ws-pad-x));
    padding: 8px var(--ws-pad-x);
    border-bottom: 1px solid var(--border-light);
    background: rgba(247, 248, 250, 0.96);
    backdrop-filter: blur(8px);
  }

  .filter-bar .search-box {
    grid-column: 1 / -1;
    max-width: none;
    min-width: 0;
  }

  .filter-bar .search-input {
    height: 40px;
    min-height: 40px;
    font-size: 14px;
  }

  .filter-bar > select.filter-select {
    min-width: 0;
    width: 100%;
    height: 40px;
    line-height: 38px;
  }

  .filter-bar .filter-toggle {
    justify-content: center;
    padding-inline: 8px;
    height: 40px;
  }

  .secondary-filters {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding-top: 6px;
  }

  #btn-reset-filters {
    grid-column: 1 / -1;
    justify-self: end;
  }
}

@media (max-width: 600px) {
  .workspace {
    --ws-pad-x: 12px;
    padding: 8px var(--ws-pad-x) calc(28px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .topbar-actor-label {
    display: none;
  }

  .btn-create-entry,
  .topbar-actor-pill {
    min-height: 38px;
  }

  .list-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 6px 2px 12px;
  }

  .list-count-text {
    text-align: center;
  }

  .pagination {
    width: 100%;
    justify-content: space-between;
  }

  .pagination .btn {
    min-height: 40px;
    min-width: 88px;
  }

  .ticket-card-summary {
    font-size: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .ticket-card-notes {
    font-size: 12.5px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .ticket-card-note-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
