:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #666;
  --surface: #fff;
  --border: #e3e3e3;
  --hover: #f0f0f0;
  --accent: #1a1a1a;
  --accent-fg: #fff;
  --error-bg: #fde8e8;
  --error-fg: #6b1d1d;
  --error-border: #f5b5b5;
  --info-bg: #eef4ff;
  --info-fg: #1f3766;
  --info-border: #c5d3ee;
  --radius: 0.4rem;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

/* ---------- Auth pages keep their original centered layout ---------- */

main.auth {
  max-width: 28rem;
  margin: 4rem auto;
  padding: 0 1.5rem;
  text-align: left;
}

main.auth h1 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

/* ---------- App shell ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-brand {
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--fg);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-name {
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-logout {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
}

.topbar-logout:hover {
  background: var(--hover);
}

.topbar-logout:disabled {
  opacity: 0.5;
  cursor: progress;
}

.app-root {
  max-width: 60rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ---------- Views ---------- */

.view h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

.view-header {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.view-eyebrow {
  margin: 0;
  font-size: 0.85rem;
}

.view-eyebrow a {
  color: var(--muted);
  text-decoration: none;
}

.view-eyebrow a:hover {
  color: var(--fg);
}

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

.placeholder-card p {
  margin: 0 0 0.5rem;
}

.placeholder-card p:last-child {
  margin-bottom: 0;
}

/* ---------- Project picker ---------- */

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.1s ease;
}

.project-card:hover {
  box-shadow: var(--shadow-md);
}

.project-card-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
}

.project-card-name {
  font-weight: 500;
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Role badge ---------- */

.role-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: lowercase;
  background: var(--hover);
  color: var(--muted);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.role-badge-admin {
  background: var(--info-bg);
  color: var(--info-fg);
  border-color: var(--info-border);
}

/* ---------- Toast ---------- */

.toast-host {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 30;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 0.95rem;
  max-width: 22rem;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast-error {
  background: var(--error-bg);
  color: var(--error-fg);
  border-color: var(--error-border);
}

.toast-info {
  background: var(--info-bg);
  color: var(--info-fg);
  border-color: var(--info-border);
}

.toast-leaving {
  opacity: 0;
  transform: translateY(0.5rem);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 20;
}

.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  max-width: 28rem;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.modal-body {
  margin: 0 0 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-btn {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  cursor: pointer;
}

.modal-btn:hover {
  background: var(--hover);
}

.modal-btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.modal-btn-danger {
  background: var(--error-bg);
  color: var(--error-fg);
  border-color: var(--error-border);
}

/* ---------- Issue list ---------- */

.issue-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.filter-bar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.filter-bar-row-secondary {
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.filter-bar-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 9rem;
  flex: 1 1 9rem;
}

.filter-bar-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.filter-bar input[type='search'],
.filter-bar select {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
}

.filter-bar select[multiple] {
  padding: 0.25rem;
  min-height: 5rem;
}

.filter-bar-archived {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.filter-bar-spacer {
  flex: 1;
}

.filter-bar-link {
  background: transparent;
  border: none;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
}

.filter-bar-link:hover:not(:disabled) {
  background: var(--hover);
  border-radius: var(--radius);
}

.filter-bar-link:disabled {
  color: var(--muted);
  cursor: not-allowed;
  text-decoration: none;
  opacity: 0.7;
}

.issue-list-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.issue-list-loading,
.issue-list-error {
  margin: 0;
  padding: 1.5rem;
  text-align: center;
}

.issue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.issue-table th,
.issue-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.issue-table thead th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

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

.issue-table tbody tr:hover {
  background: var(--hover);
}

.issue-th.sortable {
  cursor: pointer;
  user-select: none;
}

.issue-th.sortable:hover {
  color: var(--fg);
}

.issue-th.sortable-active {
  color: var(--fg);
}

.issue-num {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.issue-num a,
.issue-name a {
  color: inherit;
  text-decoration: none;
}

.issue-name a:hover {
  text-decoration: underline;
}

.issue-status-closed {
  color: var(--muted);
}

.issue-time {
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.archived-row {
  opacity: 0.55;
}

.archived-row .issue-name a {
  text-decoration: line-through;
}

.issue-list-footer {
  padding: 0.85rem 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.issue-list-footer.pager {
  justify-content: space-between;
  flex-wrap: wrap;
}

.issue-list-footer.muted,
.issue-list-footer .muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.pager-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}

.pager-summary {
  white-space: nowrap;
}

.pager-btn,
.pager-page-btn {
  font: inherit;
  min-width: 2.25rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
}

.pager-btn:hover:not(:disabled),
.pager-page-btn:hover:not(:disabled) {
  background: var(--hover);
}

.pager-btn:disabled,
.pager-page-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pager-page-btn.is-current {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  opacity: 1;
}

.pager-gap {
  color: var(--muted);
  padding: 0 0.25rem;
}

.empty-state {
  padding: 2.5rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
}

.empty-state p {
  margin: 0;
}

/* ---------- Issue list toolbar ---------- */

.issue-list-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.issue-list-toolbar-spacer {
  flex: 1;
}

/* ---------- Issue detail ---------- */

.view-issue-detail .view-header {
  margin-bottom: 1rem;
}

.issue-detail-heading {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0;
  font-size: 1.5rem;
}

.issue-detail-number {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.issue-archived-badge {
  background: var(--error-bg);
  color: var(--error-fg);
  border-color: var(--error-border);
}

.issue-detail-loading,
.issue-detail-error {
  margin: 1.5rem 0;
}

.issue-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 1.5rem;
  align-items: start;
}

.issue-detail-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.issue-detail-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.issue-detail-sidebar > .field-cell {
  border-bottom: 1px solid var(--border);
}

.issue-detail-sidebar > .field-cell:last-child {
  border-bottom: none;
}

.issue-detail-meta {
  display: flex;
  flex-direction: column;
}

.issue-detail-danger {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.issue-detail-danger .modal-btn-danger {
  width: 100%;
}

.issue-detail-history {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.issue-detail-history h2,
.issue-detail-comment h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.issue-detail-comment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ---------- Field cells (inline editor) ---------- */

.field-cell {
  padding: 0.65rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-radius: var(--radius);
}

.field-cell.field-editable {
  cursor: text;
}

.field-cell.field-editable:hover {
  background: var(--hover);
}

.field-cell.field-dirty {
  outline: 2px solid var(--info-border);
  outline-offset: -2px;
  background: var(--info-bg);
}

.field-cell.field-dirty:hover {
  background: var(--info-bg);
}

.field-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.field-display {
  font-size: 0.95rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.field-name {
  font-weight: 500;
  font-size: 1.05rem;
}

.field-description {
  min-height: 2rem;
}

.field-editor {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-input {
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}

.field-textarea {
  resize: vertical;
  min-height: 5rem;
  font-family: inherit;
}

.field-hint {
  font-size: 0.8rem;
}

/* ---------- Save bar ---------- */

.save-bar {
  position: sticky;
  bottom: 0;
  margin-top: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 5;
}

.save-bar-summary {
  font-size: 0.95rem;
}

.save-bar-note {
  width: 100%;
}

.save-bar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ---------- Comment box ---------- */

.comment-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comment-box-input {
  resize: vertical;
  min-height: 4rem;
  font-family: inherit;
}

.comment-box-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.comment-box-hint {
  font-size: 0.8rem;
}

/* ---------- History timeline ---------- */

.history-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-event {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-event-creation {
  background: var(--info-bg);
  border-color: var(--info-border);
}

.history-event-comment {
  background: var(--surface);
}

.history-event-header {
  font-size: 0.9rem;
}

.history-author {
  font-weight: 500;
}

.history-time {
  font-size: 0.85rem;
}

.history-body {
  font-size: 0.95rem;
}

.history-comment,
.history-note {
  white-space: pre-wrap;
  word-break: break-word;
}

.history-change-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.history-change-row {
  font-size: 0.95rem;
  word-break: break-word;
}

.history-change-field {
  font-weight: 500;
}

.history-change-old {
  text-decoration: line-through;
  color: var(--muted);
}

.history-change-new {
  font-weight: 500;
}

.history-empty {
  margin: 0;
}

/* ---------- New issue modal form ---------- */

.new-issue-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-field-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.modal-error {
  margin: 0;
  color: var(--error-fg);
  min-height: 1.2rem;
  font-size: 0.9rem;
}

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  .topbar-inner {
    padding: 0.6rem 1rem;
  }

  .topbar-name {
    display: none;
  }

  .app-root {
    padding: 1.25rem 1rem 3rem;
  }

  .filter-bar-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .filter-bar-row-secondary {
    flex-direction: row;
  }

  .issue-table thead {
    display: none;
  }

  .issue-table,
  .issue-table tbody,
  .issue-table tr,
  .issue-table td {
    display: block;
    width: 100%;
  }

  .issue-table tr {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
  }

  .issue-table td {
    border: none;
    padding: 0.2rem 0.75rem;
  }

  .issue-list-footer.pager {
    align-items: stretch;
    flex-direction: column;
  }

  .pager-summary {
    white-space: normal;
  }

  .pager-controls {
    justify-content: flex-start;
  }

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

  .issue-detail-sidebar {
    order: -1;
  }
}

/* ---------- Stage 8: tabs ---------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.9rem;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0;
  margin-bottom: -1px;
}

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

.tab.is-active {
  color: var(--fg);
  border-bottom-color: var(--fg);
  font-weight: 500;
}

/* ---------- Stage 8: metadata list ---------- */

.metadata-list {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.metadata-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}

.metadata-row.is-dragging {
  opacity: 0.5;
}

.metadata-row.is-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.drag-handle {
  cursor: grab;
  color: var(--muted);
  user-select: none;
  padding: 0 0.25rem;
}

.metadata-row[draggable='true']:active .drag-handle {
  cursor: grabbing;
}

.metadata-name {
  min-width: 0;
}

.rename-field {
  display: inline-flex;
  align-items: center;
  width: 100%;
}

.rename-display {
  background: transparent;
  border: 1px dashed transparent;
  border-radius: var(--radius);
  padding: 0.2rem 0.4rem;
  font: inherit;
  color: inherit;
  cursor: text;
  text-align: left;
  width: 100%;
}

.rename-display:hover {
  border-color: var(--border);
  background: var(--hover);
}

.rename-input {
  width: 100%;
}

.metadata-badges {
  display: inline-flex;
  gap: 0.35rem;
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  font-size: 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--hover);
  text-transform: lowercase;
}

.badge-default {
  color: var(--info-fg);
  background: var(--info-bg);
  border-color: var(--info-border);
}

.badge-closed {
  color: var(--muted);
}

.metadata-actions {
  display: inline-flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
  background: var(--hover);
}

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

.icon-btn.is-active {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-fg);
}

.icon-btn-danger {
  color: var(--error-fg);
  border-color: var(--error-border);
}

.icon-btn-danger:hover:not(:disabled) {
  background: var(--error-bg);
}

.metadata-add {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding-top: 0.5rem;
}

.metadata-add .field-input {
  flex: 1;
}

/* ---------- Stage 8: danger zone ---------- */

.danger-zone {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  color: var(--error-fg);
  border-radius: var(--radius);
}

.danger-zone h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.danger-zone p {
  margin: 0 0 0.75rem;
}

/* ---------- Stage 8: user menu (TopBar dropdown) ---------- */

.user-menu {
  position: relative;
}

.user-menu-trigger {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded='true'] {
  background: var(--hover);
}

.user-menu-caret {
  font-size: 0.7rem;
  color: var(--muted);
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 12rem;
  padding: 0.25rem;
  display: grid;
  z-index: 20;
}

.user-menu-item {
  display: block;
  background: transparent;
  border: none;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  border-radius: calc(var(--radius) - 2px);
  text-decoration: none;
}

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

.user-menu-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

/* ---------- Stage 8: project header settings link ---------- */

.view-header-actions {
  display: inline-flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ---------- Stage 8: admin shell ---------- */

.admin-shell {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 1.5rem;
  align-items: start;
}

.admin-nav {
  display: grid;
  gap: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.admin-nav-item {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.95rem;
}

.admin-nav-item:hover {
  background: var(--hover);
  color: var(--fg);
}

.admin-nav-item.is-active {
  background: var(--info-bg);
  color: var(--info-fg);
  font-weight: 500;
}

.admin-content {
  min-width: 0;
}

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

/* ---------- Stage 8: admin tables ---------- */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.92rem;
}

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

.admin-table tbody tr:hover {
  background: var(--hover);
}

.admin-table-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.admin-toolbar .field-input {
  flex: 1;
  min-width: 12rem;
}

.admin-table-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}

.admin-error-stack {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78em;
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
  margin-top: 0.5rem;
  max-height: 24rem;
  overflow: auto;
}

/* ---------- Stage 8: profile / me ---------- */

.me-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.me-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.me-form {
  display: grid;
  gap: 0.5rem;
  max-width: 24rem;
}

.me-form label {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Stage 8: memberships modal ---------- */

.memberships-list {
  display: grid;
  gap: 0.4rem;
  max-height: 60vh;
  overflow-y: auto;
}

.membership-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.membership-row:last-child {
  border-bottom: none;
}

.membership-name {
  font-weight: 500;
}

.settings-note {
  margin-top: 0.75rem;
  color: var(--muted);
}

.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--fg);
}

/* ---------- Stage 9: attachments ---------- */
.attachments-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.attachments-empty {
  margin: 0;
  font-size: 0.9rem;
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.6rem;
}

.attachment-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.attachment-thumb-link,
.attachment-icon-link {
  display: block;
  border-radius: calc(var(--radius) - 0.1rem);
  overflow: hidden;
  background: var(--hover);
  text-decoration: none;
}

.attachment-thumb {
  display: block;
  width: 100%;
  height: 7rem;
  object-fit: cover;
}

.attachment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 5rem;
  font-size: 2rem;
}

.attachment-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.attachment-filename {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-filename:hover {
  text-decoration: underline;
}

.attachment-sub {
  font-size: 0.8rem;
}

.attachment-archive-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  cursor: pointer;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.1s ease-in-out;
}

.attachment-card:hover .attachment-archive-btn {
  opacity: 1;
}

.attachment-archive-btn:hover {
  color: var(--error-fg);
  border-color: var(--error-border);
  background: var(--error-bg);
}

.attachment-archived {
  opacity: 0.65;
}

.attachment-archived-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  background: var(--info-bg);
  color: var(--info-fg);
  border: 1px solid var(--info-border);
  border-radius: 0.3rem;
}

/* ---------- Stage 9: dropzone ---------- */
.dropzone {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dropzone-active {
  border-color: var(--accent);
  background: var(--hover);
}

.dropzone-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.dropzone-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  cursor: pointer;
  user-select: none;
}

.dropzone-cta {
  font-size: 0.9rem;
  color: var(--fg);
}

.dropzone-hint {
  font-size: 0.8rem;
}

.dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.dropzone-pending-list:empty {
  display: none;
}

.dropzone-pending-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.dropzone-pending-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: var(--hover);
  border-radius: calc(var(--radius) - 0.1rem);
  font-size: 0.85rem;
}

.dropzone-pending-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone-pending-size {
  font-size: 0.75rem;
}

.dropzone-pending-remove {
  background: transparent;
  border: 0;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0 0.3rem;
}

.dropzone-pending-remove:hover {
  color: var(--error-fg);
}

.dropzone-progress {
  font-size: 0.85rem;
  color: var(--muted);
}

.dropzone-error {
  font-size: 0.85rem;
  color: var(--error-fg);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: calc(var(--radius) - 0.1rem);
  padding: 0.3rem 0.5rem;
}

/* ---------- Stage 10: notification bell ---------- */

.notif-bell {
  position: relative;
}

.notif-bell-trigger {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.55rem;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  position: relative;
  line-height: 1;
}

.notif-bell-trigger:hover,
.notif-bell-trigger[aria-expanded='true'] {
  background: var(--hover);
}

.notif-bell-icon {
  font-size: 1rem;
}

.notif-bell-badge {
  position: absolute;
  top: -0.25rem;
  right: -0.3rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--danger, #c43d3d);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
}

.notif-bell-badge[hidden] {
  display: none;
}

.notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 22rem;
  max-width: 26rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.notif-header {
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.notif-list {
  max-height: 22rem;
  overflow-y: auto;
}

.notif-empty {
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.notif-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'kind  time'
    'issue time'
    'actor actor';
  gap: 0.1rem 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--fg);
  font-size: 0.9rem;
}

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

.notif-row-unread {
  background: var(--accent-bg, rgba(40, 90, 220, 0.06));
}

.notif-row-kind {
  grid-area: kind;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.notif-row-issue {
  grid-area: issue;
  font-weight: 500;
}

.notif-row-actor {
  grid-area: actor;
  color: var(--muted);
  font-size: 0.8rem;
}

.notif-row-time {
  grid-area: time;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.notif-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2, var(--surface));
}

.notif-mark-all,
.notif-settings-link {
  background: transparent;
  border: 0;
  color: var(--accent, var(--fg));
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  padding: 0.2rem 0.3rem;
  border-radius: calc(var(--radius) - 2px);
}

.notif-mark-all:hover,
.notif-settings-link:hover {
  background: var(--hover);
}

/* ---------- Stage 10: watch toggle ---------- */

.issue-detail-actions {
  display: inline-flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.watch-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
}

.watch-btn:hover {
  background: var(--hover);
}

.watch-btn-on {
  background: var(--accent-bg, rgba(40, 90, 220, 0.1));
  border-color: var(--accent, var(--border));
}

/* ---------- Stage 10: notification prefs ---------- */

.pref-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pref-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

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

.pref-checkbox {
  width: 1rem;
  height: 1rem;
}

.pref-row-label {
  font-size: 0.95rem;
}

/* ---------- Stage 10: mention popover ---------- */

.mention-popover {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  max-height: 14rem;
  overflow-y: auto;
}

.mention-item {
  background: transparent;
  border: 0;
  text-align: left;
  padding: 0.4rem 0.6rem;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

.mention-item.is-active,
.mention-item:hover {
  background: var(--hover);
}

.mention-item-handle {
  font-weight: 500;
}

.mention-item-name {
  font-size: 0.85rem;
}
