/*
 * Shared component styles — agent baseball-card drawer, compliance chip,
 * and other cross-page surfaces introduced by the dashboard upgrade.
 * Depends on tokens.css for CSS custom properties.
 */

/* ── Baseball-card drawer ─────────────────────────────────────────────── */

.drawer-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  animation: drawer-fade var(--duration-base) var(--ease-standard);
}

.drawer-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(480px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border-bright);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-drawer);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: drawer-slide-in var(--duration-slow) var(--ease-emphasized);
}

@keyframes drawer-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes drawer-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.drawer-content {
  height: 100%;
  overflow-y: auto;
  padding: 0;
}

.drawer-header {
  position: sticky; top: 0;
  display: flex; align-items: flex-start; gap: var(--space-4);
  padding: var(--space-6) var(--space-6) var(--space-4);
  background: linear-gradient(180deg, var(--surface2), var(--surface));
  border-bottom: 1px solid var(--border);
}

.drawer-avatar {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 16px; font-weight: 600;
  flex-shrink: 0;
}

.drawer-ident { flex: 1; min-width: 0; }

.drawer-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-1);
  word-break: break-word;
}

.drawer-agency {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: var(--space-2);
  word-break: break-word;
}

.drawer-meta {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  align-items: center;
  font-size: 11px; color: var(--muted);
}

.drawer-chip {
  background: var(--surface3);
  border: 1px solid var(--border-bright);
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.drawer-chip--tenure {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
  color: var(--purple);
}

.drawer-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  width: 28px; height: 28px;
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-standard);
  flex-shrink: 0;
}

.drawer-close:hover,
.drawer-close:focus-visible {
  color: var(--text);
  border-color: var(--border-bright);
  background: var(--surface3);
  outline: none;
}

.drawer-body {
  padding: var(--space-5) var(--space-6) var(--space-8);
  display: flex; flex-direction: column; gap: var(--space-6);
}

.drawer-section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--space-3);
}

.drawer-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.drawer-hint {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.drawer-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.drawer-stat-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drawer-score-row {
  display: flex; align-items: center; gap: var(--space-2);
}

.drawer-score-track {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.drawer-score-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease-emphasized);
}

.drawer-score-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  min-width: 26px;
  text-align: right;
}

.drawer-kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: var(--space-3);
  column-gap: var(--space-4);
  align-items: center;
}

.drawer-kv-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drawer-kv-value {
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.drawer-kv-value.mono,
.drawer-kv-value .mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.drawer-muted { color: var(--muted); font-style: italic; }

.drawer-validity {
  display: inline-flex; align-items: center;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
}

.drawer-validity--ok {
  color: var(--green);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.drawer-validity--bad {
  color: var(--red);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.drawer-copy {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
}

.drawer-copy:hover { color: var(--text); border-color: var(--border-bright); }

.drawer-address {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}

.drawer-similar {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.drawer-similar-strip {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-top: var(--space-2);
  scrollbar-width: thin;
}
.drawer-similar-card {
  flex: 0 0 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard),
              transform var(--duration-fast) var(--ease-standard);
  color: inherit;
  font: inherit;
}
.drawer-similar-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-1px);
}
.drawer-similar-avatar {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}
.drawer-similar-body {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.drawer-similar-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-similar-sub {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-similar-meta {
  display: flex;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
}
.drawer-similar-reason { color: var(--purple); }
.drawer-similar-score { color: var(--green); }

.drawer-pipeline {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.drawer-pipeline-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-2);
}
.drawer-pipeline-stage {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  flex: 1;
}
.drawer-pipeline-stage:focus { outline: none; border-color: var(--purple); }
.drawer-pipeline-add {
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: filter var(--duration-fast) var(--ease-standard);
}
.drawer-pipeline-add:hover { filter: brightness(1.1); }
.drawer-pipeline-add:disabled { opacity: 0.5; cursor: not-allowed; }
.drawer-pipeline-status {
  margin-top: var(--space-2);
  font-size: 11px;
  color: var(--text-dim);
  min-height: 14px;
}

.drawer-compliance {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-dim);
}

.drawer-compliance strong { color: var(--text); font-weight: 600; }
.drawer-compliance a { color: var(--blue); text-decoration: none; margin-left: var(--space-1); }
.drawer-compliance a:hover { text-decoration: underline; }

.drawer-empty {
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--muted);
}

.drawer-empty-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin-bottom: var(--space-2); color: var(--text); }
.drawer-empty-sub { font-size: 12px; }

/* Row click hint — only applies to dashboards that opt in via class */
.row-clickable { cursor: pointer; }
.row-clickable:hover td { background: rgba(255, 255, 255, 0.03); }
.row-clickable:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

body.drawer-open { overflow: hidden; }

/* ── Compliance chrome badge (header-friendly) ────────────────────────── */

.compliance-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-standard);
}

.compliance-chip:hover,
.compliance-chip:focus-visible {
  color: var(--text);
  border-color: var(--border-bright);
  outline: none;
}

.compliance-chip::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14);
  flex-shrink: 0;
}

/* ── Hot Right Now ribbon ────────────────────────────────────────────── */

.hot-ribbon {
  padding: var(--space-4) var(--space-6) var(--space-3);
  /* Subtle amber overlay; .glass--soft underneath supplies the base. */
  background-image: linear-gradient(180deg, rgba(245, 158, 11, 0.05) 0%, transparent 100%), var(--glass-sheen);
  border-bottom: 1px solid var(--border);
}

.hot-ribbon-head {
  display: flex; align-items: baseline; gap: var(--space-4);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.hot-ribbon-title {
  display: flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.hot-ribbon-flame { font-size: 16px; filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.35)); }

.hot-ribbon-label { letter-spacing: 0.02em; }

.hot-ribbon-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.hot-ribbon-scroll {
  display: flex; gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scroll-snap-type: x proximity;
}

.hot-ribbon-scroll::-webkit-scrollbar { height: 4px; }
.hot-ribbon-scroll::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: var(--radius-pill); }

.hot-card {
  flex: 0 0 auto;
  width: 240px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  scroll-snap-align: start;
  transition: all var(--duration-fast) var(--ease-standard);
  display: flex; flex-direction: column; gap: var(--space-2);
}

.hot-card:hover,
.hot-card:focus-visible {
  border-color: rgba(245, 158, 11, 0.35);
  background: var(--surface3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  outline: none;
}

.hot-card-top {
  display: flex; align-items: center; gap: var(--space-3);
}

.hot-card-avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.hot-card-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hot-card-agency {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hot-card-meta {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.hot-card-pill {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--amber);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hot-card-pill--green {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--green);
}

/* ── Command palette (⌘K) ────────────────────────────────────────────── */

.palette-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  z-index: var(--z-palette);
  animation: drawer-fade var(--duration-base) var(--ease-standard);
}

.palette-panel {
  position: fixed;
  top: 14vh; left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100% - var(--space-8)));
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  z-index: calc(var(--z-palette) + 1);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: palette-pop var(--duration-base) var(--ease-emphasized);
}

@keyframes palette-pop {
  from { opacity: 0; transform: translate(-50%, -8px) scale(0.98); }
  to   { opacity: 1; transform: translate(-50%, 0)    scale(1); }
}

.palette-search-wrap {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.palette-search-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  flex-shrink: 0;
}

.palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  padding: var(--space-2) 0;
}

.palette-input::placeholder { color: var(--muted); }

.palette-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
}
.palette-close:hover { color: var(--text); border-color: var(--border-bright); }

.palette-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--space-2) 0 var(--space-3);
}

.palette-group + .palette-group { border-top: 1px solid var(--border); }

.palette-group-title {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: var(--space-3) var(--space-5) var(--space-1);
}

.palette-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}

.palette-item:hover,
.palette-item.is-active {
  background: rgba(59, 130, 246, 0.08);
}

.palette-item.is-active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.palette-item-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.palette-item-label mark {
  background: transparent;
  color: var(--blue);
  font-weight: 700;
}

.palette-item-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.palette-empty {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--muted);
}

.palette-empty-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: var(--space-1); }
.palette-empty-sub   { font-size: 12px; }

.palette-footer {
  display: flex; gap: var(--space-4);
  padding: var(--space-2) var(--space-5);
  background: var(--surface2);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
}

.palette-footer kbd {
  font-family: var(--font-mono);
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 1px 4px;
  margin-right: var(--space-1);
  color: var(--text-dim);
}

/* ── Pipeline kanban ─────────────────────────────────────────────────── */

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: var(--space-4);
  padding: var(--space-6);
  overflow-x: auto;
  align-items: start;
}
@media (max-width: 1280px) {
  .pipeline-board { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
}
@media (max-width: 720px) {
  .pipeline-board { grid-template-columns: 1fr; }
}

.pipeline-column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-height: 240px;
}
.pipeline-col-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.pipeline-col-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.pipeline-col-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}
.pipeline-col-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface2);
  border-radius: var(--radius-pill, 999px);
  padding: 2px 8px;
  flex-shrink: 0;
}
.pipeline-col-body {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 160px;
  transition: background var(--duration-fast) var(--ease-standard);
}
.pipeline-col-body.is-drop-target {
  background: color-mix(in srgb, var(--purple) 8%, transparent);
  outline: 1px dashed var(--purple);
  outline-offset: -6px;
}
.pipeline-empty-col {
  font-size: 12px;
  color: var(--muted);
  padding: var(--space-3);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  line-height: 1.5;
}

.pipeline-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  cursor: grab;
  transition: border-color var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-fast) var(--ease-standard),
              transform var(--duration-fast) var(--ease-standard);
}
.pipeline-card:hover {
  border-color: var(--border-bright);
  box-shadow: var(--shadow-sm);
}
.pipeline-card.is-dragging {
  opacity: 0.6;
  cursor: grabbing;
  transform: rotate(-1deg);
}
.pipeline-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.pipeline-card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
  word-break: break-word;
}
.pipeline-card-business {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.pipeline-card-remove {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}
.pipeline-card-remove:hover { color: var(--red); background: var(--surface3); }
.pipeline-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  gap: var(--space-2);
}
.pipeline-card-updated { font-family: var(--font-mono); }
.pipeline-card-stats {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.pipeline-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--surface3);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.pipeline-chip.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, var(--border)); }
.pipeline-chip.bad { color: var(--muted); }
.pipeline-chip.green { color: var(--green); }
.pipeline-chip.amber { color: var(--amber); }

.pipeline-empty {
  grid-column: 1 / -1;
}

/* ── PAGE SHELL ────────────────────────────────────────────────────────── */
/*
 * The dashboard layout primitive. Replaces the previous body-level flat
 * stacking + position:fixed AI panel + padding-right hack.
 *
 * Five grid areas: topbar | tabs | main | aside | footer. The aside
 * (AI panel) is a real grid column when docked; floating-mode is
 * handled in ai-chat.css with .ai-aside--floating overriding.
 *
 * Responsive tiers (see spec §4.3):
 *   ultrawide ≥1600  — 380px aside, content max 1440px
 *   wide      1280-  — min(360px, 28vw) aside
 *   regular   900-   — single column, aside as sticky bottom sheet
 *   compact   <900   — single column, aside as 56px bottom pill
 */

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(360px, 28vw);
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "topbar topbar"
    "tabs   tabs"
    "main   aside"
    "footer footer";
  min-height: 100vh;
}

.page-shell > .topbar         { grid-area: topbar; container-type: inline-size; container-name: topbar; }
.page-shell > .tabs           { grid-area: tabs; }
.page-shell > .dashboard-main { grid-area: main; min-width: 0; container-type: inline-size; container-name: main; display: flex; flex-direction: column; }
.page-shell > .ai-aside       { grid-area: aside; min-width: 0; min-height: 0; }
.page-shell > .site-footer    { grid-area: footer; }

/* When the aside is in floating mode (.ai-floating body class set by
 * applyState in ai-chat.js), the panel is position:fixed and out of
 * flow — release the grid's aside column so .dashboard-main reclaims
 * the freed space. Without this, undocking the panel leaves a 360px
 * dead zone where the docked column was. */
body.ai-floating .page-shell {
  grid-template-columns: minmax(0, 1fr) 0;
}

/* The stats section auto-fits its 4 cards against its container width
 * (which is .dashboard-main, not the viewport) — so cards reflow when
 * the aside opens/closes without a viewport resize. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

/* Ultrawide — give the content a max width and use the full 380px aside. */
@media (min-width: 1600px) {
  .page-shell {
    grid-template-columns: minmax(0, 1fr) 380px;
    max-width: 1820px;
    margin: 0 auto;
  }
  .page-shell > .dashboard-main {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
  }
}

/* Regular — collapse to single column; aside becomes a sticky bottom sheet
 * embedded in the main flow (still inside the grid via a re-mapped area). */
@media (max-width: 1279px) {
  .page-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas:
      "topbar"
      "tabs"
      "main"
      "aside"
      "footer";
  }
  .page-shell > .ai-aside {
    position: sticky;
    bottom: 0;
    max-height: 360px;
    border-top: 1px solid var(--glass-border-hi);
    z-index: var(--z-drawer);
  }
  .page-shell > .ai-aside.expanded { max-height: 75vh; }
}

/* Compact — aside becomes a 56px pill that expands to a near-full-screen
 * sheet on tap. */
@media (max-width: 899px) {
  .page-shell > .ai-aside { max-height: 56px; }
  .page-shell > .ai-aside.expanded { max-height: 90vh; }
}

/* Default display for the wrapper groups + the More buttons that the
 * container queries below toggle. These must come BEFORE the container
 * queries so that the queries can override at narrow widths (CSS author
 * rules at equal specificity: later wins). */
.topbar-nav        { display: flex; gap: 8px; align-items: center; }
.toolbar-secondary { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-more-btn,
.toolbar-more-filters { display: none; }

/* Header container query — collapse nav into a More menu when the
 * topbar itself is narrow. Header isn't a descendant of .dashboard-main
 * so this query keys off the topbar's own container. */
@container topbar (max-width: 900px) {
  .topbar-nav      { display: none; }
  .topbar-more-btn { display: inline-flex; }
}

/* Main container query — collapse secondary toolbar controls when the
 * data area is narrow (triggered when the aside opens or viewport shrinks). */
@container main (max-width: 760px) {
  .toolbar-secondary    { display: none; }
  .toolbar-more-filters { display: inline-flex; }
}

/* ── POPOVERS (topbar More / toolbar Filters) ─────────────────────────── */
/* (.topbar-more-btn / .toolbar-more-filters default display: none lives
 *  in the PAGE SHELL section above so the container queries can override.) */

.popover {
  position: absolute;
  background: var(--glass-surface);
  background-image: var(--glass-sheen);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--glass-border-hi);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-overlay);
  display: none;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 200px;
}

.popover.is-open { display: flex; }

.popover button,
.popover a,
.popover select {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
  text-decoration: none;
}

.popover button:hover,
.popover a:hover,
.popover button:focus-visible,
.popover a:focus-visible {
  background: var(--surface3);
  outline: none;
}

@media (prefers-reduced-transparency: reduce) {
  .popover { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* (.topbar-nav / .toolbar-secondary defaults are declared BEFORE the
 *  container queries in the PAGE SHELL section above, so the queries
 *  can override at narrow widths.) */

/* ── DATA TABLE — sticky header, min-widths, glass-hover ──────────────── */

.data {
  /* The data section owns its own horizontal scroll context so narrow
   * viewports get a scrollable table without breaking the rest of the
   * layout. */
  overflow-x: auto;
  position: relative;
}

.data > .table-wrap {
  overflow: visible;  /* the .data wrapper handles scroll now */
}

.data table {
  width: 100%;
  min-width: 1100px;  /* keeps columns readable; below this the .data
                         section overflows and the user scrolls */
  border-collapse: collapse;
  table-layout: fixed;
}

.data thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.data thead th {
  position: sticky;
  top: 0;
  background: var(--glass-surface);
  background-image: var(--glass-sheen);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border-bottom: 1px solid var(--glass-border);
}

/* Column min-widths — keeps the 12-column layout readable even when the
 * aside opens and the data section narrows. */
.data thead th:nth-child(1)  { min-width: 180px; } /* Agent */
.data thead th:nth-child(2)  { min-width: 140px; } /* Address */
.data thead th:nth-child(3)  { min-width: 72px;  } /* Zip */
.data thead th:nth-child(4)  { min-width: 100px; } /* County */
.data thead th:nth-child(5)  { min-width: 100px; } /* City */
.data thead th:nth-child(6)  { min-width: 80px;  } /* NPN */
.data thead th:nth-child(7)  { min-width: 90px;  } /* License # */
.data thead th:nth-child(8)  { min-width: 70px;  } /* Type */
.data thead th:nth-child(9)  { min-width: 90px;  } /* Licensed */
.data thead th:nth-child(10) { min-width: 110px; } /* Phone */
.data thead th:nth-child(11) { min-width: 160px; } /* Email */
.data thead th:nth-child(12) { min-width: 90px;  } /* Score */

.data tbody tr:hover td {
  background: color-mix(in oklab, var(--blue) 6%, transparent);
}

/* Reduced-transparency: solid sticky header. */
@media (prefers-reduced-transparency: reduce) {
  .data thead th { background: var(--surface2); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ── FOCUS VISIBLE AUDIT (a11y) ───────────────────────────────────────── */
/*
 * Every interactive surface in the dashboard gets a consistent
 * keyboard-focus indicator. Mouse-only focus (after click) is suppressed
 * by :focus-visible. Existing per-component rules in this file (drawer,
 * compliance-chip, popover, hot-card, row-clickable) are preserved;
 * this block covers the surfaces those rules missed. */

.btn-sm:focus-visible,
.filter-btn:focus-visible,
.feed-bell:focus-visible,
.col-filter:focus-visible,
.sort-select:focus-visible,
.page-btn:focus-visible,
.topbar-more-btn:focus-visible,
.toolbar-more-filters:focus-visible,
.popover select:focus-visible,
.ai-empty-prompt:focus-visible,
.ai-header-btn:focus-visible,
.ai-send:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Table rows already have an inset outline (see .row-clickable above). */
.data tbody tr:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

/* ── HIDDEN ATTRIBUTE RESPECT ─────────────────────────────────────────── */
/* CSS specificity gotcha: .drawer-panel / .drawer-overlay declare
 * `display: flex` / `position: fixed` which override the UA stylesheet's
 * `[hidden] { display: none }` rule. The panels then render and intercept
 * pointer events even when carrying the `hidden` attribute, breaking
 * clicks on whatever sits behind them.
 *
 * Bumping these rules to attr-selector specificity (0,2,0) restores
 * the expected "hidden means hidden" semantics. Pre-existing bug that
 * the .page-shell rebuild surfaced via Playwright clicks on #ai-toggle-*. */
.drawer-overlay[hidden],
.drawer-panel[hidden],
.feed-tray[hidden],
.palette-overlay[hidden],
.palette-panel[hidden] {
  display: none;
}
