:root {
  --orange: #f7941d;
  --orange-dark: #e0820d;
  --orange-light: #fef3e2;
  --bg: #f4f6f9;
  --bg-alt: #eef2f7;
  --white: #ffffff;
  --text: #111827;
  --text-mid: #374151;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --blue-soft: #eef2ff;
  --blue-text: #4f46e5;
  --green-soft: #ecfdf5;
  --green-text: #059669;
  --red-soft: #fef2f2;
  --red-text: #dc2626;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.07), 0 0 0 1px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

button,
input,
textarea,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
}

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1a1d2e 0%, #2d3250 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: 24px;
  padding: 48px 40px 40px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
}

.login-logo svg {
  width: 100%;
  height: 100%;
}

.login-title {
  margin: 0 0 6px;
  font-size: 1.6rem;
  font-weight: 700;
}

.login-sub {
  margin: 0 0 32px;
  color: var(--text-muted);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}

.header-brand,
.header-center,
.user-pill,
.stats-bar,
.toolbar,
.toolbar-right,
.person-row,
.skill-row,
.skill-row-actions,
.inline-form,
.view-tabs {
  display: flex;
  align-items: center;
}

.header-brand {
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-center {
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
}

.view-tabs {
  gap: 8px;
}

.view-tab {
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-mid);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.15s ease;
}

.view-tab.active {
  background: var(--orange-light);
  color: var(--orange-dark);
  border-color: #f7d2a1;
}

.stats-bar {
  justify-content: flex-end;
  gap: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-n {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.stat-l {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.user-pill {
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px 5px 6px;
}

.user-avatar,
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  background: var(--orange);
  color: white;
  font-size: 11px;
}

#user-name-display {
  font-size: 0.8rem;
  font-weight: 500;
}

.btn,
.btn-icon,
.btn-icon-sm,
.btn-ghost-sm {
  cursor: pointer;
  transition: 0.15s ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 9px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--orange);
  color: white;
  border-color: var(--orange);
}

.btn-primary:hover:not(:disabled) {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
}

.btn-outline {
  background: var(--white);
  color: var(--text-mid);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled),
.btn-ghost:hover:not(:disabled),
.btn-icon:hover,
.btn-icon-sm:hover {
  background: var(--bg-alt);
}

.btn-ghost {
  background: transparent;
  color: var(--text-mid);
  border-color: transparent;
}

.btn-danger {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-full {
  width: 100%;
}

.btn-icon,
.btn-icon-sm,
.btn-ghost-sm {
  border: none;
  background: transparent;
  color: var(--text-muted);
}

.btn-icon,
.btn-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  padding: 6px;
  border-radius: 8px;
}

.btn-icon-sm {
  padding: 4px;
  border-radius: 6px;
}

.btn-icon-sm.danger:hover {
  background: #fee2e2;
  color: #dc2626;
}

.btn-ghost-sm {
  border-radius: 6px;
  padding: 4px 6px;
}

.app-main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.view-section {
  display: block;
}

.toolbar {
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.toolbar h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mid);
}

.toolbar-sub {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.toolbar-right {
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.search-box:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(247, 148, 29, 0.12);
}

.search-box input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
}

.agents-grid,
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 20px;
}

.agent-card,
.user-card,
.skill-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.agent-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.user-card {
  display: flex;
  flex-direction: column;
}

.agent-card,
.user-card {
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.agent-card:hover,
.user-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10), 0 0 0 1px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.card-people,
.user-card-head,
.user-card-body,
.user-card-footer {
  padding: 18px 20px;
}

.card-top {
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  padding: 20px 20px 16px 17px;
}

.user-card-head {
  border-bottom: 1px solid var(--border);
  background: var(--orange-light);
}

.card-footer,
.user-card-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 14px 20px;
}

.card-title-row,
.user-card-head,
.user-meta-row,
.token-action-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.agent-name,
.user-name {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.agent-desc,
.user-email,
.role-summary {
  color: var(--text-muted);
}

.agent-desc {
  margin: 8px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
  min-height: calc(1.5em * 2);
}

.card-people {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.user-card-body {
  display: grid;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.person-row {
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  font-size: 11px;
}

.avatar-owner {
  background: var(--blue-soft);
  color: var(--blue-text);
}

.avatar-op {
  background: var(--green-soft);
  color: var(--green-text);
}

.avatar-admin {
  background: var(--orange-light);
  color: var(--orange-dark);
}

.person-info {
  min-width: 0;
  flex: 1;
}

.person-name {
  font-weight: 600;
}

.person-email {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ops-strip,
.badge-row,
.stack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ops-strip {
  max-height: 80px;
  overflow: hidden;
}

.ops-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ops-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 72px;
  overflow: hidden;
}

.token-section {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.op-chip,
.pill-chip,
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.75rem;
}

.op-chip,
.pill-chip {
  background: var(--bg);
  border: 1px solid var(--border);
}

.badge,
.role-chip {
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge {
  padding: 4px 8px;
}

.badge-owner,
.role-chip.owner {
  background: var(--blue-soft);
  color: var(--blue-text);
}

.badge-operator,
.role-chip.operator {
  background: var(--green-soft);
  color: var(--green-text);
}

.badge-admin {
  background: var(--orange-light);
  color: var(--orange-dark);
}

.no-ops,
.empty-note {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8rem;
  padding: 4px 0;
}


.user-meta {
  display: grid;
  gap: 10px;
}

.user-meta-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.user-meta-value {
  font-weight: 600;
}

.role-summary {
  font-size: 0.8rem;
}

.token-action-row {
  align-items: center;
}

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

.form-group {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

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

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-mid);
}

.req {
  color: var(--orange);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(247, 148, 29, 0.15);
}

textarea {
  resize: vertical;
}

.field-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.field-hint-inline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

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

.checkbox-row input {
  width: auto;
}

.picker {
  position: relative;
}

.picker input {
  padding-right: 36px;
}

.picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
}

.picker-option,
.picker-empty {
  padding: 10px 12px;
}

.picker-option {
  cursor: pointer;
}

.picker-option:hover,
.picker-option.active {
  background: var(--bg-alt);
}

.picker-title {
  font-weight: 600;
}

.picker-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.picker-empty {
  color: var(--text-muted);
}

.inline-form {
  gap: 10px;
  align-items: stretch;
}

.flex-fill {
  flex: 1;
}

.op-edit-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.section-divider {
  margin: 12px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.error-msg {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  border: 1px solid #fecaca;
  color: var(--red-text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(4px);
}

.modal {
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.modal-sm {
  max-width: 420px;
}

.modal-md {
  max-width: 580px;
}

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

.modal-header,
.modal-footer {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-sub {
  margin: 4px 0 0;
  color: var(--text-muted);
}

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

.scroll-body {
  max-height: 60vh;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.spacer {
  flex: 1;
}

.skill-item {
  margin-bottom: 10px;
  overflow: hidden;
}

.skill-row {
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
}

.skill-row:hover {
  background: var(--bg);
}

.skill-info {
  min-width: 0;
  flex: 1;
}

.skill-name {
  font-weight: 600;
}

.skill-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.skill-prompt {
  border-top: 1px solid var(--border);
  background: #f8f9fb;
}

.skill-prompt pre {
  margin: 0;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 0.8rem;
}

.skill-meta {
  padding: 8px 16px 14px;
  color: var(--text-muted);
  font-size: 0.74rem;
  border-top: 1px solid var(--border);
}

.token-box {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-family: "Consolas", "SFMono-Regular", monospace;
  word-break: break-all;
}

.confirm-message {
  margin: 0;
  color: var(--text-mid);
}

.loading-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 920px) {
  .app-header {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .header-center {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-bar {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-main {
    padding: 22px 16px 48px;
  }

  .toolbar,
  .toolbar-right,
  .header-center,
  .stats-bar,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 0;
  }

  .agents-grid,
  .users-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
  }

  .op-edit-row {
    grid-template-columns: auto 1fr auto;
  }

  .op-edit-row .btn-icon-sm {
    grid-column: 3;
  }
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.select-input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
}

.dash-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.dash-stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  text-align: center;
}

.dash-stat-clickable {
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.dash-stat-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dash-section-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.dash-section-row .dash-section-title {
  margin: 0;
}

.dash-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-filter-group .select-input {
  width: auto;
  min-width: 180px;
}

.dash-stat-n {
  font-size: 2rem;
  font-weight: 700;
  color: var(--orange);
  line-height: 1.1;
}

.dash-stat-l {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dash-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.dash-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-mid);
  margin: 0 0 16px;
}

.chart-wrapper {
  position: relative;
  height: 220px;
}

.dash-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.dash-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.dash-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--bg-alt);
  color: var(--text);
}

.dash-table tr:last-child td {
  border-bottom: none;
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: 0.875rem;
}

/* Feedback list */
.feedback-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.feedback-stars {
  color: var(--orange);
  font-size: 1rem;
  letter-spacing: 1px;
}

.feedback-agent {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

.feedback-user {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.feedback-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.feedback-comment {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-mid);
  font-style: italic;
}

/* ==========================================================================
   Version history modal
   ========================================================================== */

.version-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}

.version-item.version-current {
  border-color: var(--orange);
}

.version-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--white);
  user-select: none;
}

.version-header:hover {
  background: var(--bg-alt);
}

.version-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.version-num {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text);
  min-width: 28px;
}

.version-who {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.version-when {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.version-body {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.version-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.version-field {
  display: flex;
  gap: 12px;
  font-size: 0.875rem;
}

.version-field-label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 90px;
  flex-shrink: 0;
}

.version-prompt-row {
  flex-direction: column;
  gap: 4px;
}

.version-prompt {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin: 0;
}

.chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .dash-stats {
    grid-template-columns: 1fr 1fr;
  }

  .dash-tables {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Dashboard inner tabs
   ========================================================================== */

.dash-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.dash-tab {
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-mid);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: 0.15s ease;
}

.dash-tab.active {
  background: var(--orange-light);
  color: var(--orange-dark);
  border-color: #f7d2a1;
  font-weight: 600;
}

.dash-tab:hover:not(.active) {
  background: var(--bg-alt);
}

.dash-panel {
  display: none;
}

.dash-panel.active {
  display: block;
}

/* Stats grid for 5 cards */
.dash-stats {
  grid-template-columns: repeat(5, 1fr);
}

.chart-wrapper-sm {
  height: 160px;
}

/* 3-column dash-tables for platform tab */
#dash-platform .dash-tables {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ==========================================================================
   Drilldown panels
   ========================================================================== */

.drilldown-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-top: 16px;
  overflow: hidden;
}

.drilldown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.drilldown-header strong {
  flex: 1;
  font-size: 1rem;
}

.drilldown-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.drilldown-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.drilldown-section {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.drilldown-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.drilldown-section h4 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Clickable table rows */
.clickable-row {
  cursor: pointer;
  transition: background 0.1s ease;
}

.clickable-row:hover {
  background: var(--orange-light);
}

.dash-table-hover tbody tr {
  cursor: pointer;
}

.dash-table-hover tbody tr:hover {
  background: var(--orange-light);
}

.text-muted-sm {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Outcome badges
   ========================================================================== */

.outcome-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.outcome-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.outcome-completed {
  background: var(--green-soft);
  color: var(--green-text);
}

.outcome-partial {
  background: #fffbeb;
  color: #d97706;
}

.outcome-not_helpful {
  background: var(--red-soft);
  color: var(--red-text);
}

/* ==========================================================================
   Gap feed
   ========================================================================== */

.gap-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gap-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.875rem;
}

.gap-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 6px;
  background: var(--orange-light);
  color: var(--orange-dark);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ==========================================================================
   Activity heatmap
   ========================================================================== */

.activity-heatmap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.heatmap-row {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 3px;
}

.heatmap-cell {
  height: 22px;
  border-radius: 3px;
  background: var(--bg-alt);
  transition: background 0.1s;
}

.heatmap-cell.intensity-1 { background: rgba(247, 148, 29, 0.2); }
.heatmap-cell.intensity-2 { background: rgba(247, 148, 29, 0.4); }
.heatmap-cell.intensity-3 { background: rgba(247, 148, 29, 0.6); }
.heatmap-cell.intensity-4 { background: rgba(247, 148, 29, 0.8); }
.heatmap-cell.intensity-5 { background: var(--orange); }

.heatmap-labels {
  grid-template-columns: repeat(24, 1fr);
}

.heatmap-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   Version impact table rows
   ========================================================================== */

.version-impact-row.improved td {
  background: #f0fdf4;
}

.version-impact-row.regressed td {
  background: #fff5f5;
}

.version-impact-row.improved td:last-child {
  color: var(--green-text);
  font-weight: 600;
}

.version-impact-row.regressed td:last-child {
  color: var(--red-text);
  font-weight: 600;
}

/* ==========================================================================
   Signal badges + feedback extras
   ========================================================================== */

.signal-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red-text);
  font-size: 0.75rem;
  font-weight: 700;
}

.feedback-gap {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}

/* Inline clickable number/badge inside a table cell */
.cell-link {
  color: var(--orange-dark);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cell-link:hover {
  color: var(--orange);
}

/* Small count badge shown next to drilldown section headings */
.drilldown-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 1px 6px;
  margin-left: 6px;
  background: var(--bg-alt);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: 0;
}
