/* ==========================================================================
   SenseforgeAI Scraper — dashboard
   Tokens, buttons and base styles come from theme.css
   ========================================================================== */

body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Hide the app until auth has been checked (auth.js removes this) */
body.auth-pending .app-shell {
  visibility: hidden;
}

.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */

.app-header {
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.dedup-badge {
  cursor: pointer;
  transition: background-color 0.15s;
}

.dedup-badge:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.dedup-badge strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.dedup-badge:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #12B76A;
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.18);
  flex-shrink: 0;
}

.pulse.red {
  background: #F04438;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.18);
}

/* User menu */
.user-menu {
  position: relative;
}

.user-button {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 6px 0 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}

.user-button:hover {
  background: var(--surface-alt);
}

.user-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 240px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}

.user-info {
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.user-info strong {
  display: block;
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info span {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--surface-alt);
}

.menu-item .icon {
  color: var(--text-muted);
}

/* ---------- Layout ---------- */

.app-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: 0 10px 8px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.nav-item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.nav-text {
  flex: 1;
}

.badge-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  display: inline-grid;
  place-items: center;
}

.sidebar-footer {
  padding: 12px 10px 4px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
}

.tab-pane {
  display: none;
  max-width: 1280px;
  margin: 0 auto;
}

.tab-pane.active {
  display: block;
  animation: fade-in 0.15s ease-out;
}

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

.pane-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.pane-header h2 {
  font-size: 22px;
}

.pane-header p {
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.card-body {
  padding: 18px;
}

/* ---------- Scraper catalog ---------- */

.actors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.actor-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.actor-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.actor-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.actor-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--ink);
  display: grid;
  place-items: center;
}

.actor-category {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-sunken);
  padding: 2px 8px;
  border-radius: 999px;
}

.actor-card h3 {
  font-size: 15px;
}

.actor-desc {
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.55;
  flex: 1;
}

.actor-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.actor-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-subtle);
}

/* ---------- KPIs ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  padding: 16px 18px;
}

.kpi-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}

.kpi-value {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */

.runs-container {
  display: grid;
  gap: 20px;
}

.table-wrapper {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:not(.empty-row):hover td {
  background: var(--surface-alt);
}

.empty-row td {
  text-align: center;
  color: var(--text-subtle);
  padding: 40px 16px;
}

.run-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.run-actor {
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

.run-query {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

th.align-right {
  text-align: right;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-tag.READY { background: var(--surface-sunken); color: var(--text-muted); }
.status-tag.RUNNING { background: var(--info-soft); color: var(--info); }
.status-tag.SUCCEEDED { background: var(--success-soft); color: var(--success); }
.status-tag.FAILED { background: var(--danger-soft); color: var(--danger); }
.status-tag.ABORTED { background: var(--warning-soft); color: var(--warning); }

.status-tag.RUNNING::before {
  animation: dot-pulse 1.2s ease-in-out infinite;
}

@keyframes dot-pulse {
  50% { opacity: 0.3; }
}

/* ---------- Log console ---------- */

.terminal-card {
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--border);
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
}

.terminal-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-console {
  background: #0D1117;
  color: #C9D1D9;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  padding: 14px 18px;
  height: 320px;
  overflow: auto;
}

.log-entry {
  white-space: pre-wrap;
  word-break: break-word;
}

.log-entry.system { color: #8B949E; }
.log-entry.warn { color: #E3B341; }
.log-entry.error { color: #FF7B72; }

/* ---------- Datasets ---------- */

.datasets-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.datasets-list {
  list-style: none;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 70vh;
  overflow: auto;
}

.dataset-item-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.dataset-item-btn:hover {
  background: var(--surface-alt);
}

.dataset-item-btn.active {
  background: var(--brand-soft);
  border-color: rgba(15, 118, 110, 0.2);
}

.dataset-item-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.ds-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.empty-msg {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13px;
}

.dataset-inspector {
  min-width: 0;
  overflow: hidden;
}

.inspector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.inspector-header h3 {
  font-size: 15px;
}

.inspector-header p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.inspector-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.search-field {
  position: relative;
}

.search-field .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}

.table-search {
  height: 36px;
  width: 220px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.table-search:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.export-dropdown {
  position: relative;
}

.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}

.export-menu button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 13.5px;
  cursor: pointer;
}

.export-menu button span {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
}

.export-menu button:hover {
  background: var(--surface-alt);
}

.filter-chips-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.chip:hover {
  color: var(--text);
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}

.dataset-inspector .table-wrapper {
  max-height: 62vh;
}

#datasetTable th {
  position: sticky;
  top: 0;
  z-index: 1;
}

#datasetTable td {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 10px 16px;
}

#datasetTable td:first-child {
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.cell-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
}

.cell-link .icon {
  width: 14px;
  height: 14px;
  color: var(--text-subtle);
}

.cell-link:hover,
.cell-link:hover .icon {
  color: var(--brand);
}

/* ---------- API console ---------- */

.api-console-grid {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 8px;
  border-bottom: 1px solid var(--border);
}

.code-tabs {
  display: flex;
  gap: 2px;
}

.code-tab {
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.code-tab:hover {
  color: var(--text);
}

.code-tab.active {
  background: var(--surface-sunken);
  color: var(--ink);
}

.code-block {
  margin: 0;
  padding: 18px;
  background: #0D1117;
  color: #E6EDF3;
  font-size: 12.5px;
  line-height: 1.7;
  overflow: auto;
  min-height: 240px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.api-endpoints {
  margin-top: 20px;
  overflow: hidden;
}

.endpoint-path {
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
}

.endpoint-desc {
  color: var(--text-muted);
}

.method {
  display: inline-block;
  min-width: 52px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.method.get { background: var(--info-soft); color: var(--info); }
.method.post { background: var(--success-soft); color: var(--success); }
.method.delete { background: var(--danger-soft); color: var(--danger); }

/* ---------- Forms ---------- */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

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

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select {
  height: 38px;
}

.form-group textarea {
  resize: vertical;
  line-height: 1.5;
}

.form-group textarea.code-font {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.form-hint {
  font-size: 12px;
  color: var(--text-subtle);
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color 0.15s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}

.toggle-switch input:checked + .slider {
  background: var(--brand);
}

.toggle-switch input:checked + .slider::before {
  transform: translateX(16px);
}

.toggle-switch input:focus-visible + .slider {
  box-shadow: var(--focus-ring);
}

.toggle-label {
  font-size: 13.5px;
  color: var(--text);
}

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(11, 18, 32, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade-in 0.15s ease-out;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-card form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.modal-lg {
  max-width: 920px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
}

.modal-title-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.modal-title-wrapper p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.modal-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.close-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.close-btn:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.json-block {
  border-radius: var(--radius);
  max-height: 65vh;
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.25s, transform 0.25s;
}

.toast::before {
  content: '';
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: #84CAFF;
  flex-shrink: 0;
}

.toast.success::before { background: #32D583; }
.toast.error::before { background: #F97066; }

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .api-console-grid,
  .datasets-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .datasets-list {
    max-height: 220px;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 16px;
  }

  .wordmark-product,
  .status-label,
  .user-name {
    display: none;
  }

  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    position: sticky;
    top: 56px;
    z-index: 40;
    width: 100%;
    height: auto;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav-label,
  .sidebar-footer {
    display: none;
  }

  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-item {
    flex: 0 0 auto;
    height: 34px;
  }

  .main-content {
    padding: 20px 16px 40px;
  }

  .pane-header h2 {
    font-size: 19px;
  }

  .actors-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .kpi-grid {
    gap: 10px;
  }

  .kpi-value {
    font-size: 22px;
  }

  .search-field {
    flex: 1 1 100%;
  }

  .table-search {
    width: 100%;
  }

  .toast-stack {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

/* ---------- Queue, owners, roles ---------- */

.status-tag.QUEUED {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.status-tag.QUEUED::before {
  background: transparent;
  border: 1.5px solid currentColor;
  width: 5px;
  height: 5px;
}

.run-owner {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 2px;
}

.kpi-note {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-muted);
  min-height: 18px;
}

.role-badge {
  display: inline-block !important;
  margin-top: 6px;
  font-size: 11.5px !important;
  font-weight: 500;
  color: var(--brand-ink) !important;
  background: var(--brand-soft);
  padding: 1px 7px;
  border-radius: 999px;
}

.role-badge.hidden {
  display: none !important;
}

.intent-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.intent-tag.buyer { background: var(--success-soft); color: var(--success); }
.intent-tag.seller { background: var(--warning-soft); color: var(--warning); }

/* ---------- Settings: search keys ---------- */

.card-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 720px;
}

.key-form {
  display: grid;
  grid-template-columns: 180px minmax(140px, 200px) minmax(200px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.key-form .form-group {
  margin-bottom: 0;
}

.key-form .btn {
  height: 38px;
}

.order-buttons {
  display: flex;
  gap: 2px;
}

.key-detail {
  margin-top: 4px;
  max-width: 260px;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.card-footnote {
  padding: 12px 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.card-footnote:empty {
  display: none;
}

@media (max-width: 900px) {
  .key-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .key-input-group,
  .key-form .btn {
    grid-column: 1 / -1;
  }
}
