:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --card-bg: #121212;
  --card-header: #121212;
  --border: #262626;
  --border-light: #2b2b2b;
  --text-main: #f2f2f2;
  --text-muted: #9e9e9e;
  --text-dim: #737373;
  --accent: #007bff;
  --accent-hover: #006be6;
  --accent-red: #d40000;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;

  /* Read-only status label and dot colors */
  --status-label-fg: #b0b0b0;
  --status-saved-dot: #c7c7c7;

  --status-applying-dot: #f8d7a2;

  --status-applied-dot: #a8cdfa;

  --status-interview-dot: #d0b4f3;

  --status-offer-dot: #b3edcf;

  --status-rejected-dot: #f8a9a9;

  --status-archived-dot: #b3b3b3;

  /* Surfaces & Controls */
  --input-bg: #121212;
  --input-border: #2b2b2b;
  /* Filled controls used only by the in-row editor. */
  --editor-field-bg: #222222;
  --editor-field-hover-bg: #303030;
  --dialog-bg: #121212;
  --btn-secondary-bg: #1f1f1f;
  --btn-secondary-hover: #292929;
  --dropdown-bg: #121212;
  --dropdown-header: #191919;
  --dropdown-hover: #292929;
  --action-hover-bg: rgba(255, 255, 255, 0.08);
}

:root.light,
html.light {
  color-scheme: light;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --card-header: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-red: #d40000;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --danger-hover: #b91c1c;

  /* Surfaces & Controls */
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --editor-field-bg: #eef2f7;
  --editor-field-hover-bg: #e2e8f0;
  --dialog-bg: #ffffff;
  --btn-secondary-bg: #f1f5f9;
  --btn-secondary-hover: #e2e8f0;
  --dropdown-bg: #ffffff;
  --dropdown-header: #f8fafc;
  --dropdown-hover: #f1f5f9;
  --action-hover-bg: rgba(0, 0, 0, 0.06);

  /* Maintain label contrast against light row-hover backgrounds. */
  --status-label-fg: #475569;
  --status-saved-dot: #475569;

  --status-applying-dot: #b45309;

  --status-applied-dot: #0369a1;

  --status-interview-dot: #7e22ce;

  --status-offer-dot: #047857;

  --status-rejected-dot: #b91c1c;

  --status-archived-dot: #475569;
}

/* Keep the centered layout fixed when filters make the page shorter than the viewport. */
html {
  scrollbar-gutter: stable;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.title-group {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.app-logo {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: block;
  flex-shrink: 0;
}

.logo-badge {
  width: 36px;
  height: 36px;
  background: var(--accent-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.25rem;
  border-radius: 6px;
  user-select: none;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  background-color: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Controls Bar */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.search-box {
  flex: 1;
  min-width: 250px;
  max-width: 400px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 0.375rem;
  color: var(--text-main);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent);
}

/* Filter buttons */
.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

.filter-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  background: var(--card-bg);
  color: var(--text-main);
  border-color: var(--border-light);
}

.filter-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.375rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease-in-out;
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--text-main);
  border: 0;
}
.btn-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}

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

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Stats Summary */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Table */
.table-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow-x: auto;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

th {
  padding: 0.75rem 1rem;
  background: var(--card-header);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

th.sortable {
  cursor: pointer;
}

th.sortable:hover {
  color: var(--text-main);
}

.sort-arrow {
  margin-left: 0.25rem;
  font-size: 0.75rem;
  color: var(--accent);
}

td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tr:hover td {
  background: rgba(30, 41, 59, 0.5);
}

.company-name {
  font-weight: 600;
  color: var(--text-main);
}

.position-title {
  font-weight: 500;
  color: var(--text-main);
}

.position-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

/* Compact read-only workflow state: no pill within a row or card.
   Meaning is always in the visible text; the dot is a secondary scan cue. */
.record-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--status-label-fg);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}

.record-status::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--record-status-dot, var(--text-muted));
}

.record-status-saved { --record-status-dot: var(--status-saved-dot); }
.record-status-applying { --record-status-dot: var(--status-applying-dot); }
.record-status-applied { --record-status-dot: var(--status-applied-dot); }
.record-status-interview { --record-status-dot: var(--status-interview-dot); }
.record-status-offer { --record-status-dot: var(--status-offer-dot); }
.record-status-rejected { --record-status-dot: var(--status-rejected-dot); }
.record-status-archived { --record-status-dot: var(--status-archived-dot); }

/* Action table buttons */
.row-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.action-icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.45rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s ease;
}

.action-icon-btn:hover {
  background: var(--border);
  color: var(--text-main);
}

.action-icon-btn.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* Empty / Loading States */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.empty-desc {
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.notice-banner {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notice-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: #f87171;
}

.notice-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--warning);
  color: #fbbf24;
}

@keyframes dialog-attention {
  0% { transform: scale(1); }
  50% { transform: scale(1.015); border-color: var(--warning); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4); }
  100% { transform: scale(1); }
}

.modal-dialog.dialog-attention {
  animation: dialog-attention 0.25s ease-in-out;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.40);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-dialog {
  background: var(--dialog-bg);
  border: 1px solid var(--border-light);
  border-radius: 0.5rem;
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  color: var(--text-main);
}

html.light .modal-dialog {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-full {
  grid-column: 1 / -1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
  color: var(--text-main);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-error {
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Inspect Details */
.detail-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: 0.9rem;
  color: var(--text-main);
}

.detail-link-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: 100%;
}

.detail-job-link {
  color: var(--accent);
  word-break: break-all;
}

.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border-light);
  border-radius: 0.25rem;
  padding: 0.175rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.copy-link-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.copy-link-btn:hover {
  background: var(--btn-secondary-hover);
  color: var(--text-main);
  border-color: var(--accent);
}

.copy-link-btn.copied {
  color: var(--success);
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.12);
}

/* CV Commit Selector */
.cv-select-container {
  position: relative;
  width: 100%;
}

.cv-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 2.25rem;
  padding: 0.375rem 0.625rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  color: var(--text-main);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}

.cv-select-trigger:hover {
  border-color: var(--accent);
}

.cv-select-trigger:focus-visible {
  outline: 2px solid var(--accent);
}

.cv-badge-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.cv-commit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.45rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.cv-commit-badge:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--accent);
}

/* Unboxed, single-line links; the column header supplies the CV context. */
.cv-version-link {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.cv-version-link:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Cards do not have a CV column heading. */
@media (max-width: 1279px) {
  .mobile-card .cv-version-link::before {
    content: "CV ";
    color: var(--text-dim);
  }
}

.cv-plain-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.cv-dropdown-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  width: 100%;
  min-width: 0;
  max-height: 20rem;
  background: var(--dropdown-bg);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-main);
}

html.light .cv-dropdown-menu {
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

.cv-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: var(--dropdown-header);
}

.cv-search-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.cv-dropdown-search {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
  min-width: 0;
}

.cv-dropdown-search::placeholder {
  color: var(--text-muted);
}

.cv-search-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0.1rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 3px;
}

.cv-search-clear-btn svg {
  width: 14px;
  height: 14px;
}

.cv-search-clear-btn:hover {
  color: var(--text-main);
}

.cv-trigger-placeholder {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.cv-trigger-selected {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
  min-width: 0;
}

/* Keep the revision identifiable without the pill used by the old selector. */
.cv-trigger-sha {
  flex: 0 0 auto;
  color: var(--text-muted);
  font: 500 0.75rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cv-trigger-msg {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-trigger-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
  padding-left: 0.25rem;
}

.cv-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.15rem;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.cv-clear-btn svg {
  width: 14px;
  height: 14px;
}

.cv-clear-btn:hover {
  color: var(--text-main);
  background: var(--action-hover-bg);
}

.cv-chevron {
  transition: transform 0.15s ease;
}

.cv-chevron.open {
  transform: rotate(180deg);
}

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

.cv-refresh-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.cv-spinner {
  width: 12px;
  height: 12px;
  color: var(--accent);
  animation: cv-spin 0.9s linear infinite;
  flex-shrink: 0;
}

.cv-refresh-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.65rem;
  border-bottom: 1px solid rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.1);
  font-size: 0.7rem;
  color: var(--danger);
}

.cv-refresh-error-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-retry-btn {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 0.7rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.cv-empty-state {
  padding: 0.85rem 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.cv-use-custom-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.cv-use-custom-btn:hover {
  opacity: 0.85;
}

.cv-commit-list {
  overflow-y: auto;
  max-height: 14rem;
  padding: 0.25rem;
}

.cv-commit-option {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.cv-commit-option:hover {
  background: var(--dropdown-hover);
}

.cv-commit-option.selected {
  background: rgba(56, 189, 248, 0.18);
}

html.light .cv-commit-option.selected {
  background: rgba(2, 132, 199, 0.15);
}

.cv-branch-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-dim);
  font-size: 0.68rem;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Company Autocomplete Dropdown */
.company-autocomplete-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  width: 100%;
  max-height: 12rem;
  background: var(--dropdown-bg);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  z-index: 90;
  overflow-y: auto;
  padding: 0.25rem;
  color: var(--text-main);
}

html.light .company-autocomplete-dropdown {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-main);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--dropdown-hover);
}

.autocomplete-icon {
  font-size: 0.8rem;
  opacity: 0.7;
}

.overdue-tag {
  color: #f59e0b;
  font-weight: 600;
}

.due-soon-tag {
  color: #ef4444;
  font-weight: 600;
}

/* Theme toggle button */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.theme-toggle-btn:hover {
  border-color: var(--border-light);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

html.light .theme-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Responsive Table & Mobile Cards */
.mobile-cards {
  display: none;
}

@media (max-width: 1024px) {
  .desktop-table {
    display: none !important;
  }
  .mobile-cards {
    display: flex !important;
    flex-direction: column;
    gap: 0.75rem;
  }
}

@media (min-width: 1025px) {
  .desktop-table {
    display: block;
  }
  .mobile-cards {
    display: none;
  }
}

.mobile-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.15s;
}

.mobile-card:hover {
  border-color: var(--border-light);
}

.mobile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.mobile-card-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.mobile-card-company {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.mobile-card-position {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.mobile-card-subinfo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.mobile-card-action {
  font-size: 0.8rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  border-left: 2px solid var(--accent);
}

html.light .mobile-card-action {
  background: rgba(0, 0, 0, 0.03);
}

.mobile-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

.mobile-card-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-family: monospace;
}

.mobile-card-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}



/* Visual parity with the original Next.js tracker (dark, compact, borderless).
 * Deliberately scoped to the main list view; modal mechanics and CRUD remain unchanged.
 * CSS tokens above remain the only theme sources, including light mode. */
body {
  font-family: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
.container { max-width: 1280px; padding: 24px 32px; }
.header {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  gap: 12px;
}
.title-group { gap: 10px; }
.app-logo { width: 24px; height: 24px; border-radius: 4px; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -.025em; }
.header .btn-primary {
  height: 36px; padding: 0 12px;
  background: var(--text-main);
  color: var(--bg);
  font-size: 14px; border-radius: 6px;
}
.header .btn-primary:hover { filter: brightness(.85); }
.header .btn-primary svg { width: 16px; height: 16px; }
.theme-toggle-btn {
  width: 32px; height: 32px; padding: 6px;
  border: 0; border-radius: 6px;
}
.theme-toggle-btn svg { width: 16px; height: 16px; }
.theme-toggle-btn:hover { border: 0; background: var(--action-hover-bg); }

.controls-bar {
  flex-wrap: nowrap; gap: 10px;
  justify-content: stretch;
  margin-bottom: 16px;
}
.search-box { flex: 1 1 0; max-width: none; min-width: 0; }
.search-icon {
  position: absolute; width: 16px; height: 16px;
  top: 50%; left: 12px; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.search-input {
  height: 36px; padding: 0 32px 0 36px;
  background: var(--editor-field-bg);
  border: 0;
  font-size: 14px; border-radius: 6px; box-shadow: none;
  transition: background-color 130ms ease;
}
.search-input:hover:not(:disabled), .search-input:focus {
  background: var(--editor-field-hover-bg);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus-visible, .filter-select:focus-visible, .clear-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.filter-group { flex: 0 0 auto; flex-wrap: nowrap; gap: 8px; }
.filter-select-wrap { position: relative; min-width: 176px; }
.filter-icon {
  position: absolute; z-index: 1;
  top: 50%; left: 12px; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-muted);
  pointer-events: none;
}
.filter-select {
  appearance: auto; width: 100%; height: 36px;
  padding: 0 12px 0 32px;
  background: var(--card-bg); border: 1px solid var(--border-light);
  border-radius: 6px; color: var(--text-main);
  font-size: 12px; font-weight: 500; cursor: pointer;
}
.clear-btn { height: 36px; padding: 0 10px; border-radius: 6px; color: var(--text-muted); }
.clear-btn svg { width: 16px; height: 16px; }
.clear-btn:hover:not(:disabled) { background: var(--action-hover-bg); color: var(--text-main); }
.clear-btn:disabled { opacity: .4; cursor: not-allowed; }
.stats-bar { display: none; }

.table-container {
  background: transparent;
  border: 0; border-radius: 0;
  box-shadow: none; overflow-x: auto;
}
.desktop-table table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.desktop-table thead { border-bottom: 1px solid var(--border); }
.desktop-table th {
  height: 36px; padding: 0 12px;
  background: transparent; border-bottom: 0;
  font-size: 12px; line-height: 1;
  font-weight: 500; letter-spacing: normal; text-transform: none;
}
.desktop-table th.sortable { transition: color .15s; }
.desktop-table th.sortable:hover { color: var(--text-main); }
.desktop-table td {
  height: 48px; padding: 6px 12px;
  border-bottom: 0;
  font-size: 14px;
}
.desktop-table tr:hover td { background: var(--action-hover-bg); }
.desktop-table .company-name, .desktop-table .position-title {
  font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.desktop-table .position-sub {
  margin-top: 2px; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 12px;
}
.desktop-table td.link-cell { text-align: center; }
.job-external-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 4px;
  color: var(--text-muted); text-decoration: none;
}
.job-external-link svg { width: 14px; height: 14px; }
.job-external-link:hover { background: var(--action-hover-bg); color: var(--text-main); }
.desktop-table .row-actions { gap: 2px; justify-content: flex-end; }
.desktop-table .action-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border: 0;
  background: transparent; border-radius: 4px;
  color: var(--text-muted); font-size: 16px;
}
.desktop-table .action-icon-btn svg { width: 14px; height: 14px; }
.desktop-table .action-icon-btn:hover { background: var(--action-hover-bg); color: var(--text-main); }
.desktop-table .action-icon-btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.desktop-table .cv-commit-badge {
  border-radius: 4px; padding: 2px 5px;
  font-weight: 500; font-size: 11px;
}
.desktop-table .cv-badge-group { gap: 1px; }
.desktop-table .cv-external-icon { padding: 2px; }

@media (max-width: 1279px) {
  .desktop-table { display: none !important; }
  .mobile-cards { display: flex !important; flex-direction: column; gap: 10px; }
}
@media (min-width: 1280px) {
  .desktop-table { display: block !important; }
  .mobile-cards { display: none !important; }
}
@media (max-width: 639px) {
  .container { padding: 24px 16px; }
  .header { flex-wrap: wrap; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .search-box { flex: 1 1 auto; width: 100%; }
  .filter-group { width: 100%; justify-content: space-between; }
  .filter-select-wrap { flex: 1 1 auto; }
  .mobile-card { border-radius: 6px; }
}


/* Narrow layouts keep compact rows, with spacing and hover feedback rather than dividers. */
@media (max-width: 1279px) {
  .mobile-cards { gap: 0 !important; }
  .mobile-card {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 14px 8px;
    gap: 8px;
    transition: background-color 0.15s ease;
  }
  .mobile-card:hover { background: var(--action-hover-bg); }
  .mobile-card-title {
    flex-direction: row; flex-wrap: wrap;
    align-items: baseline; gap: 2px 8px;
    min-width: 0;
  }
  .mobile-card-company { font-size: 14px; font-weight: 600; }
  .mobile-card-position { font-size: 14px; }
  .mobile-card-subinfo {
    flex-basis: 100%; display: block;
    font-size: 12px; color: var(--text-muted);
  }
  .mobile-card-action {
    padding: 0; border: 0; border-radius: 0;
    background: transparent; color: var(--text-main);
    font-size: 12px; font-weight: 500;
  }
  .mobile-card-meta {
    border: 0; margin: 0; padding: 0;
    align-items: center; gap: 8px;
  }
  .mobile-card-dates {
    flex: 1 1 180px;
    gap: 6px 10px; font-size: 11px;
  }
  .mobile-card-actions { margin-left: auto; gap: 2px; flex-shrink: 0; }
  .mobile-card-actions .action-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0;
    background: transparent; border: 0; border-radius: 4px;
    color: var(--text-muted); font-size: 15px;
  }
  .mobile-card-actions .action-icon-btn svg { width: 16px; height: 16px; }
  .mobile-card-actions .action-icon-btn:hover {
    background: var(--action-hover-bg); color: var(--text-main);
  }
  .mobile-card-actions .action-icon-btn.danger:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger);
  }
}
.clear-btn, .clear-btn:disabled { background: transparent; border: 0; }


/* Interactive select parity: the original app used custom popovers, not native selects. */
.custom-select-wrap {
  position: relative;
  min-width: 0;
  width: 100%;
}
.custom-select-wrap.compact { width: 176px; flex: 0 0 176px; }
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  height: 36px;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  color: var(--text-main);
  background: var(--dropdown-bg);
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 14px;
}
.custom-select-wrap.compact .custom-select-trigger { font-size: 12px; }
/* Only the list's status filter gets the frameless filled treatment; the
   create dialog's other selectors keep their existing design. */
.controls-bar .custom-select-wrap.compact .custom-select-trigger {
  border: 0;
  background: var(--editor-field-bg);
  transition: background-color 130ms ease;
}
.controls-bar .custom-select-wrap.compact .custom-select-trigger:is(:hover, :focus) {
  background: var(--editor-field-hover-bg);
}
.custom-select-trigger:hover { border-color: var(--border-light); }
.custom-select-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.custom-select-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  min-width: 0;
}
.custom-select-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.select-chevron { width: 14px; height: 14px; flex: none; color: var(--text-muted); }
.select-dot, .select-dot-placeholder {
  width: 8px; height: 8px; flex: none; border-radius: 50%;
}
.dot-saved { background: #a1a1aa; }
.dot-applying { background: #fbbf24; }
.dot-applied { background: #38bdf8; }
.dot-interview { background: #c084fc; }
.dot-offer { background: #34d399; }
.dot-rejected { background: #f87171; }
.dot-archived { background: #71717a; }
.custom-select-menu {
  position: absolute;
  z-index: 500;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: 176px;
  max-height: min(380px, 80vh);
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--dropdown-bg);
  box-shadow: 0 12px 28px rgba(0,0,0,.32);
}
.custom-select-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 9px;
  gap: 9px;
  border: 0;
  border-radius: 4px;
  color: var(--text-main);
  background: transparent;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.custom-select-option:hover, .custom-select-option.active { background: var(--dropdown-hover); }
.custom-select-option[aria-selected="true"] { font-weight: 600; background: var(--action-hover-bg); }
.select-check { color: var(--accent); margin-left: auto; }
.custom-select-option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 639px) {
  .custom-select-wrap.compact { flex: 1 1 auto; width: auto; }
}


/* Record details are opened from the row itself. Links/actions retain own behavior. */
.clickable-record { cursor: pointer; }
.desktop-table .clickable-record:focus-visible td,
.mobile-card.clickable-record:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.desktop-table .clickable-record:focus-visible td {
  background: var(--action-hover-bg);
}
.mobile-card.clickable-record:focus-visible {
  background: var(--action-hover-bg);
}
.cv-version-link {
  white-space: nowrap;
}
.cv-version-link:focus-visible,
.action-icon-btn:focus-visible,
.job-external-link:focus-visible,
.copy-link-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Visually hidden but announced by assistive technology. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Passive success snackbar: bottom-left avoids obscuring right-side details.
   Single message, auto expires; it never takes focus or intercepts input. */
.toast-viewport {
  position: fixed;
  left: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 900;
  display: flex;
  justify-content: flex-start;
  max-width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0.5rem 0.875rem;
  background: var(--dialog-bg);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.4;
  animation: toast-in 150ms ease-out;
}
.toast-message {
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
@media (max-width: 639px) {
  .toast-viewport { left: 0.75rem; right: 0.75rem; max-width: none; }
  .toast { flex: 1 1 auto; }
}

/* List-first application management: the table never shrinks for a drawer. */
.row-management { width: 44px; text-align: right; white-space: nowrap; }
.row-management-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0;
  transition: opacity 120ms ease;
}
.desktop-table tr:hover .row-management-actions,
.desktop-table tr:focus-within .row-management-actions,
.desktop-table tr.inspector-selected .row-management-actions {
  opacity: 1;
}
.row-delete-action {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  border-radius: 7px;
}
.row-delete-action svg {
  display: block;
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.row-delete-action:hover, .row-delete-action:focus-visible {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}
.row-delete-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.note-preview-wrapper { position: relative; min-width: 0; }
.note-preview-trigger {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border: 0;
  border-radius: 4px;
  padding: 2px 0;
  cursor: help;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  text-align: left;
}
.note-preview-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.note-preview-popover {
  position: absolute;
  z-index: 400;
  top: calc(100% + 5px);
  left: 0;
  width: min(420px, calc(100vw - 36px));
  max-height: min(330px, 45vh);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--dialog-bg);
  color: var(--text-main);
  border: 1px solid var(--border-light);
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
  border-radius: 8px;
  padding: 14px;
  line-height: 1.55;
  font-size: 13px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease, visibility 120ms ease;
}
.note-preview-wrapper:hover .note-preview-popover,
.note-preview-wrapper:focus-within .note-preview-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
/* Compact edit-in-place: the selected row is replaced, never duplicated. */
.desktop-table tr.clickable-record.inspector-selected td {
  background: var(--action-hover-bg);
}
.mobile-card.inspector-selected { background: var(--action-hover-bg); }
.inline-editor-row > td { padding: 0 !important; background: var(--bg); }
.inline-editor-overlay.modal-overlay {
  position: static;
  inset: auto;
  display: block;
  width: 100%;
  padding: 4px 0 8px;
  background: transparent;
  border: 0;
  backdrop-filter: none;
  pointer-events: auto;
  z-index: auto;
}
.inline-editor-dialog.modal-dialog {
  position: relative;
  inset: auto;
  transform: none;
  width: 100%;
  max-width: none;
  height: auto;
  max-height: none;
  margin: 0;
  overflow: visible;
  background: var(--card-bg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
html.light .inline-editor-dialog.modal-dialog { box-shadow: none; }
.mobile-inline-editor { border: 0; margin: 0; }
.mobile-card { position: relative; touch-action: pan-y; }
.mobile-record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.mobile-card.swipe-revealed .mobile-record-actions {
  background: color-mix(in srgb, var(--danger) 5%, transparent);
  padding: 9px;
  border-radius: 6px;
}
.mobile-record-actions .row-delete-action { color: var(--danger); }
.toast:has(.toast-undo) { pointer-events: auto; }
.toast-undo {
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  padding: 6px 9px;
  font-weight: 650;
  cursor: pointer;
}
.toast-undo:hover, .toast-undo:focus-visible { background: var(--action-hover-bg); }
@media (max-width: 1024px) {
  .inline-editor-dialog .form-grid { grid-template-columns: minmax(0, 1fr); }
  .inline-editor-dialog .modal-header { padding: 12px 14px; }
  .inline-editor-dialog .modal-body { padding: 14px; }
  .inline-editor-dialog .modal-footer { padding: 12px 14px; }
  .note-preview-popover { left: auto; right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .row-management-actions, .note-preview-popover { transition: none; }
}

/* Keep the hover/focus note preview outside the scroll clipping context on
   desktop. Mobile uses cards and does not depend on hover. */
@media (min-width: 1025px) { .table-container { overflow: visible; } }


/* The quick editor is one line of inputs plus a small action bar. */
.inline-editor-dialog .modal-header {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.inline-editor-dialog .modal-header .close-btn { display: none; }
.inline-editor-dialog .modal-body {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 10px 14px 6px;
  overflow: visible;
}
.inline-editor-dialog .form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.45fr) minmax(125px, .85fr) minmax(0, 1.4fr);
  gap: 8px 12px;
}
.inline-editor-dialog .form-group { min-width: 0; gap: 3px; }
/* CV selection should occupy one normal grid column, not stretch across the
   entire row. The create form uses its standard two-column grid. */
.cv-version-field { min-width: 0; }
.cv-version-field .cv-select-trigger { min-width: 0; }
.inline-editor-dialog .form-label {
  font-size: 11px;
  font-weight: 550;
  line-height: 1.4;
}
.inline-editor-dialog .form-input,
.inline-editor-dialog .form-select,
.inline-editor-dialog .form-textarea {
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 5px;
  font-size: 12px;
}
.inline-editor-dialog .custom-select-trigger,
.inline-editor-dialog .cv-select-trigger {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
}

/* Filled, borderless editor controls. Scope these rules so create-dialog
   fields, table filters and dropdown menus keep their existing semantics. */
.inline-editor-dialog :is(
  .form-input, .form-select, .form-textarea,
  .custom-select-trigger, .cv-select-trigger
) {
  background-color: var(--editor-field-bg);
  border: 0;
  box-shadow: none;
  color: var(--text-main);
  transition: background-color 130ms ease;
}
.inline-editor-dialog :is(.form-input, .form-textarea)::placeholder {
  color: var(--text-muted);
  opacity: 1;
}
.inline-editor-dialog :is(
  .form-input, .form-select, .form-textarea,
  .custom-select-trigger, .cv-select-trigger
):hover:not(:disabled) {
  background-color: var(--editor-field-hover-bg);
}
.inline-editor-dialog :is(
  .form-input, .form-select, .form-textarea,
  .custom-select-trigger, .cv-select-trigger
):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background-color: var(--editor-field-hover-bg);
}
.inline-editor-dialog :is(
  .form-input, .form-select, .form-textarea,
  .custom-select-trigger, .cv-select-trigger
):focus:not(:focus-visible) {
  outline: none;
  background-color: var(--editor-field-hover-bg);
}
.inline-editor-dialog :is(
  .form-input, .form-select, .form-textarea,
  .custom-select-trigger, .cv-select-trigger
):disabled {
  opacity: .55;
  cursor: not-allowed;
}
/* Invalid values retain a text error, not color-only feedback. */
.inline-editor-dialog :is(.form-input, .form-select, .form-textarea)[aria-invalid="true"],
.inline-editor-dialog :is(.form-input, .form-select, .form-textarea):user-invalid {
  outline: 2px solid var(--danger);
  outline-offset: 1px;
}
.inline-editor-dialog .form-group:focus-within > .form-label {
  color: var(--text-main);
}
/* A fixed 34px textarea clipped multiline notes into an unusable single
   line. Grow with the content until six-to-eight lines are visible; only
   longer notes scroll. Short notes keep the compact 34px row. */
.inline-editor-dialog .form-textarea {
  field-sizing: content;
  box-sizing: border-box;
  height: auto;
  min-height: 34px;
  max-height: 176px;
  overflow-y: auto;
  resize: none;
  line-height: 1.5;
}
/* Browsers without field-sizing still get a readable multi-line textarea. */
@supports not (field-sizing: content) {
  .inline-editor-dialog .form-textarea {
    min-height: 96px;
  }
}
.inline-editor-dialog.compact-expanded .expanded-notes {
  grid-column: 1 / -1;
}
.inline-editor-dialog.compact-expanded .expanded-notes .form-textarea {
  min-height: 128px;
  max-height: min(60vh, 480px);
  resize: vertical;
}
.inline-editor-dialog .inline-advanced-toggle {
  order: 2;
  padding: 0 210px 0 0;
  margin: 0;
  border: 0;
}
.inline-editor-dialog .compact-secondary-field { order: 3; }
.inline-editor-dialog .inline-advanced-field { order: 4; }
.inline-editor-dialog .inline-advanced-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 3px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.inline-editor-dialog .inline-advanced-button:hover { color: var(--text-main); }
.inline-editor-dialog .inline-advanced-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.inline-editor-dialog .inline-advanced-button svg {
  width: 15px;
  height: 15px;
  transform: rotate(-90deg);
  transition: transform 140ms ease;
}
.inline-editor-dialog .inline-advanced-button[aria-expanded="true"] svg { transform: rotate(0); }
.inline-editor-dialog .inline-advanced-summary { display: none; }
.inline-editor-dialog .advanced-hidden { display: none; }
.inline-editor-dialog .modal-footer {
  position: absolute;
  z-index: 6;
  right: 14px;
  bottom: 7px;
  padding: 0;
  gap: 8px;
  border: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.inline-editor-dialog .modal-footer .btn {
  padding: 6px 12px;
  min-height: 32px;
  font-size: 12px;
}
.inline-editor-dialog.compact-expanded .modal-body { padding-bottom: 50px; }
.mobile-record-actions .row-delete-action { width: 36px; height: 36px; }
.mobile-record-actions .row-delete-action svg { width: 18px; height: 18px; }
@media (max-width: 1024px) {
  .inline-editor-dialog .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .inline-editor-dialog .modal-body { padding: 10px 12px 6px; }
  .inline-editor-dialog .modal-footer { right: 12px; }
}
@media (max-width: 550px) {
  .inline-editor-overlay.modal-overlay { padding: 0 0 8px; }
  .inline-editor-dialog .form-grid { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .inline-editor-dialog .modal-body { padding: 10px 12px 6px; }
  .inline-editor-dialog .inline-advanced-toggle { padding-right: 165px; }
  .inline-editor-dialog .modal-footer { gap: 5px; }
  .inline-editor-dialog .modal-footer .btn { padding: 6px 8px; font-size: 11px; }
  .inline-editor-dialog .inline-advanced-button { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .inline-editor-dialog .inline-advanced-button svg,
  .inline-editor-dialog :is(
    .form-input, .form-select, .form-textarea,
    .custom-select-trigger, .cv-select-trigger
  ),
  .search-input,
  .controls-bar .custom-select-wrap.compact .custom-select-trigger {
    transition: none;
  }
}

/* A read-first expansion follows the summary row; the list keeps its width. */
.desktop-table .record-details-row > td { padding: 0; white-space: normal; }
.record-details { border-left: 2px solid var(--accent); padding: 0 20px 20px; background: var(--card-bg); color: var(--text-main); }
.record-disclosure { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: inherit; font: inherit; font-weight: inherit; text-align: left; padding: 0; cursor: pointer; }
.record-disclosure:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.details-header { display: flex; align-items: center; gap: 12px; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 8px 0; margin-bottom: 20px; }
.details-tabs { display: flex; gap: 12px; }
.details-tabs [aria-current="page"] { color: var(--text-main); box-shadow: inset 0 -2px var(--accent); border-radius: 0; }
.draft-indicator { font-size: .75rem; color: var(--warning); }
.details-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 32px; }
.details-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; align-content: start; }
.notes-reading { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: .875rem; padding: 8px 0; }
.notes-actions { display: flex; justify-content: flex-end; gap: 8px; }

.history-layout { display: grid; grid-template-columns: minmax(160px, 230px) minmax(0, 1fr); gap: 24px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-entry { text-align: left; background: transparent; color: var(--text-main); border: 1px solid var(--border); border-radius: 6px; padding: 10px; cursor: pointer; overflow-wrap: anywhere; }
.history-entry[aria-pressed="true"] { border-color: var(--accent); background: var(--action-hover-bg); }
.history-entry strong, .history-entry time { display: block; font-size: .8rem; }
.history-entry time { font-size: .7rem; color: var(--text-muted); margin-top: 4px; }
.history-coverage { color: var(--text-muted); font-size: .8rem; }
.history-comparison > p { font-size: .8rem; margin: 0 0 12px; }
.history-all { display: flex; align-items: center; gap: 8px; font-size: .8rem; min-height: 40px; }
.history-field { padding: 14px 0; border-bottom: 1px solid var(--border); }
.history-field h3 { margin: 0 0 8px; font-size: .8rem; }
.history-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.history-pair > div { padding: 10px; background: var(--action-hover-bg); border-radius: 6px; min-width: 0; }
.history-pair span { display: block; font-size: .7rem; color: var(--text-muted); margin-bottom: 6px; }
.history-pair p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; }
.history-pair a { overflow-wrap: anywhere; }
.history-changed .history-pair > div { border-top: 2px solid var(--border-light); }
.history-changed .history-pair > div:last-child { border-top-color: var(--accent); }
@media (max-width: 1279px) { .mobile-record-details { margin-top: -8px; margin-bottom: 16px; } }
@media (max-width: 700px) {
  .record-details { padding: 0 12px 16px; }
  .details-header { flex-wrap: wrap; gap: 4px; }
  .details-header .btn { min-height: 44px; }
  .details-grid, .history-layout, .history-pair { grid-template-columns: minmax(0, 1fr); }
  .details-grid { gap: 20px; }
  .history-list { flex-direction: row; overflow-x: auto; padding: 4px; }
  .history-entry { flex: 0 0 180px; }

}
.detail-item { margin-bottom: 12px; min-width: 0; }
.detail-item-heading { margin-bottom: 4px; }
.detail-item-label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
}
.detail-readonly {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: space-between;
  text-align: left;
  width: 100%;
  min-height: 34px;
  border: 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: .875rem;
}
.detail-readonly:hover { background: var(--action-hover-bg); }
.detail-readonly > span:first-child { min-width: 0; }
.detail-empty { color: var(--text-dim); }
.detail-edit-icon {
  font-size: .6875rem;
  color: var(--text-muted);
  opacity: .8;
  flex-shrink: 0;
}
.detail-readonly:hover .detail-edit-icon,
.detail-readonly:focus-visible .detail-edit-icon { opacity: 1; }
.detail-input, .detail-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--editor-field-bg);
  color: var(--text-main);
  font: inherit;
}
.detail-textarea {
  min-height: 190px;
  height: min(38vh, 310px);
  resize: vertical;
  line-height: 1.55;
}
.detail-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.details-error {
  border-radius: 7px;
  padding: 10px;
  margin-bottom: 12px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  font-size: .8rem;
}
@media (hover: none) {
  .detail-edit-icon { opacity: .75; }
}

.record-details .btn-ghost { background: transparent; color: var(--text-muted); }
.record-details .btn-ghost:hover { background: var(--action-hover-bg); color: var(--text-main); }
.record-details .btn:focus-visible, .history-entry:focus-visible, .details-secondary summary:focus-visible,
.detail-input:focus-visible, .detail-textarea:focus-visible, .detail-readonly:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.clickable-record.inspector-selected .note-preview-popover { display: none; }
.detail-reference { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; }
.detail-reference .btn { padding: 4px 8px; font-size: .6875rem; }
.details-secondary { grid-column: 1 / -1; }
.details-secondary summary { cursor: pointer; color: var(--text-muted); font-size: .8rem; padding: 8px 0; }
.details-secondary > .details-facts { margin-top: 12px; }

/* Empty notes are a compact action; metadata uses the available row width. */
.detail-notes:has(.notes-empty) { display: flex; flex-direction: row; align-items: center; gap: 12px; margin: 0; }
.detail-notes:has(.notes-empty) .detail-item-heading { margin: 0; }
.notes-empty .btn { padding: 6px 10px; }
.details-grid:has(.notes-empty) { grid-template-columns: minmax(0, 1fr); gap: 16px; }
.details-grid:has(.notes-empty) > .details-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-status-dropdown .custom-select-wrap.compact { width: 100%; flex: 0 0 auto; min-width: 0; }
.row-status-dropdown .custom-select-trigger { padding: 4px 6px; min-height: 32px; background: transparent; border: 0; }
.row-status-dropdown .select-chevron { display: none; }
.row-status-dropdown .custom-select-trigger:is(:hover, :focus-visible, [aria-expanded="true"]) {
  background: var(--action-hover-bg);
}
.row-status-dropdown .custom-select-menu { min-width: 0; width: 100%; }
.row-status-dropdown .custom-select-option { padding: 7px 6px; gap: 6px; }
.mobile-card-header > div:last-child { min-width: 120px; }
@media (max-width: 700px) {
  .details-grid:has(.notes-empty) > .details-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.mobile-card .row-status-dropdown .custom-select-menu { left: auto; right: 0; }

/* Give the existing Git picker room for branch/message metadata while editing. */
.details-facts > .detail-item:has(.cv-select-container) { grid-column: 1 / -1; }
.record-details .cv-select-trigger { border: 0; background: var(--editor-field-bg); }
.record-details .cv-select-trigger:hover { background: var(--editor-field-hover-bg); }
