/* ==========================================================================
   D&Q Rolodex Design System
   Matches Drawn & Quarterly Shared Directory Aesthetic
   ========================================================================== */

:root {
  --font-serif: 'Newsreader', 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Light Theme Palette */
  --bg-app: #fcfcfb;
  --bg-sidebar: #f7f8f6;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f7f9f6;
  --bg-active-row: #f0f5ee;
  --bg-sidebar-active: #e6ede4;

  --text-primary: #181c18;
  --text-secondary: #656d64;
  --text-muted: #8b948a;
  --text-inverse: #ffffff;

  --border-subtle: #e8eae6;
  --border-strong: #d0d5ce;
  --border-focus: #1e3a2f;

  --brand-green: #1e3a2f;
  --brand-green-hover: #142820;
  --brand-green-light: #eef3ec;

  --badge-dup-bg: #fffbeb;
  --badge-dup-border: #fcd34d;
  --badge-dup-text: #92400e;

  --tag-bg: #f3f5f2;
  --tag-border: #e1e5df;
  --tag-text: #323a31;

  /* Relationship Indicator Colors */
  --color-journalist: #2b6cb0;
  --color-bookseller: #8c5a23;
  --color-librarian: #2f855a;
  --color-festival: #9b2c2c;
  --color-translator: #6b46c1;
  --color-agent: #285e61;
  --color-rights: #2b6cb0;
  --color-academic: #276749;
  --color-printer: #7b341e;
  --color-distributor: #553c9a;
  --color-publicist: #702459;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.08);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 9999px;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-app: #121412;
  --bg-sidebar: #171a17;
  --bg-surface: #1a1d1a;
  --bg-surface-hover: #212621;
  --bg-active-row: #222d24;
  --bg-sidebar-active: #243527;

  --text-primary: #ededeb;
  --text-secondary: #9da69c;
  --text-muted: #6f786e;
  --text-inverse: #121412;

  --border-subtle: #292e29;
  --border-strong: #3d453d;
  --border-focus: #4b856c;

  --brand-green: #376350;
  --brand-green-hover: #467963;
  --brand-green-light: #203328;

  --badge-dup-bg: #302611;
  --badge-dup-border: #785a15;
  --badge-dup-text: #fef08a;

  --tag-bg: #232823;
  --tag-border: #353d35;
  --tag-text: #d4dbd3;
}

/* Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--text-primary);
  background-color: var(--bg-app);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  overflow-x: hidden;
}

/* Left Sidebar */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 24px 0 16px 0;
  user-select: none;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 0 20px 24px 20px;
}

.brand-logo {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  cursor: pointer;
}

.brand-sub {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* Sidebar Navigation */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 10px;
  margin-bottom: 24px;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.12s ease;
  cursor: pointer;
}

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

.nav-item.active {
  background-color: var(--bg-sidebar-active);
  color: var(--brand-green);
  font-weight: 600;
}

[data-theme="dark"] .nav-item.active {
  color: #a7d8be;
}

.nav-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-item.active .nav-count {
  color: var(--brand-green);
  font-weight: 600;
}

[data-theme="dark"] .nav-item.active .nav-count {
  color: #a7d8be;
}

.nav-item.empty-state {
  font-style: italic;
  color: var(--text-muted);
  font-size: 12px;
  cursor: default;
}

.nav-item.empty-state:hover {
  background: transparent;
}

/* Sidebar Sections */
.sidebar-section {
  padding: 0 10px;
  margin-bottom: 24px;
}

.section-title {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0 12px 8px 12px;
}

.relationship-list, .saved-views-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.rel-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.rel-item.active {
  background-color: var(--bg-sidebar-active);
  color: var(--text-primary);
  font-weight: 600;
}

.rel-label-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.square-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  flex-shrink: 0;
  border-radius: 1px;
}

.rel-count {
  font-size: 11px;
  color: var(--text-muted);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 14px 0 14px;
  border-top: 1px solid var(--border-subtle);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s ease;
}

.user-pill:hover {
  background-color: var(--bg-surface-hover);
}

.user-avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background-color: var(--brand-green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Main Content Area */
.main-content {
  flex: 1;
  min-width: 0;
  background-color: var(--bg-surface);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

.view-panel {
  display: none;
  flex-direction: column;
  padding: 32px 48px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

.view-panel.active {
  display: flex;
}

/* Header */
.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

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

/* Theme Toggle Pill */
.theme-toggle-pill {
  display: flex;
  background-color: var(--bg-app);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.theme-btn {
  background: transparent;
  border: none;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.12s ease;
}

.theme-btn.active {
  background-color: var(--text-primary);
  color: var(--bg-surface);
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--brand-green);
  color: #ffffff;
  border: 1px solid var(--brand-green);
}

.btn-primary:hover {
  background-color: var(--brand-green-hover);
}

.btn-outline {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-outline:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.btn-sm {
  padding: 4px 12px;
  font-size: 11.5px;
}

/* Filter Toolbar */
.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  width: 380px;
  max-width: 100%;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 74px 0 34px;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.12s ease;
  font-family: inherit;
}

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

.search-shortcut-badge {
  position: absolute;
  right: 10px;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-app);
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.quick-chips-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}

.chip-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.chip-btn.active {
  background-color: var(--brand-green-light);
  border-color: var(--brand-green);
  color: var(--brand-green);
  font-weight: 600;
}

[data-theme="dark"] .chip-btn.active {
  color: #a7d8be;
}

.color-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 1px;
}

.dot-journalist { background-color: var(--color-journalist); }
.dot-bookseller { background-color: var(--color-bookseller); }
.dot-librarian { background-color: var(--color-librarian); }
.dot-festival { background-color: var(--color-festival); }

.more-filters-dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  padding: 6px 0;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 14px 4px 14px;
}

.dropdown-item {
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--text-primary);
  cursor: pointer;
}

.dropdown-item:hover {
  background-color: var(--bg-surface-hover);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: 4px 0;
}

/* Results Status Bar */
.results-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px 0;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.results-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.active-filters-wrap {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-strong);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

.filter-pill-tag strong {
  color: var(--text-primary);
}

.btn-clear-chip {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 3px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: all 0.12s ease;
  margin-left: 2px;
}

.btn-clear-chip:hover {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.12);
}

.btn-clear-all {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: underline;
  padding: 2px 6px;
  transition: color 0.12s ease;
}

.btn-clear-all:hover {
  color: var(--text-primary);
}

/* Table Container & Layout */
.table-container {
  width: 100%;
  border-top: 1px solid var(--border-subtle);
  overflow-x: auto;
  min-height: 420px;
}

.rolodex-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.rolodex-table th {
  padding: 12px 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
}

.th-name { width: 22%; }
.th-role { width: 25%; }
.th-location { width: 14%; }
.th-relationship { width: 12%; }
.th-tags { width: 17%; }
.th-last-contact { width: 10%; text-align: right; }

.rolodex-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color 0.08s ease;
  position: relative;
}

.rolodex-table tbody tr:hover {
  background-color: var(--bg-surface-hover);
}

.rolodex-table tbody tr.selected {
  background-color: var(--bg-active-row);
  outline: 2px solid var(--brand-green);
  outline-offset: -2px;
}

.rolodex-table td {
  padding: 14px 14px;
  font-size: 13px;
  vertical-align: middle;
}

/* Name Cell */
.name-cell-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: #4a729a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.name-meta-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entity-name {
  font-weight: 600;
  color: var(--text-primary);
}

.dup-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background-color: var(--badge-dup-bg);
  border: 1px solid var(--badge-dup-border);
  color: var(--badge-dup-text);
  padding: 1px 5px;
  border-radius: 2px;
  width: fit-content;
}

/* Role & Organization Cell */
.role-primary {
  color: var(--text-primary);
  font-weight: 500;
}

.org-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 1px;
}

/* Location Cell */
.location-cell {
  color: var(--text-secondary);
}

/* Relationship Badge */
.relationship-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Tags List */
.tags-cell-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 3px;
  background-color: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--tag-text);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.1s ease;
}

.tag-pill:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-surface-hover);
}

.tag-pill.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

/* Last Contact Cell */
.last-contact-cell {
  color: var(--text-muted);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

/* Empty State */
.table-empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Status Bar Right */
.status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quick-pagination {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}

.quick-page-indicator {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0 4px;
  white-space: nowrap;
  user-select: none;
}

.btn-page-nav {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
}

.btn-page-nav:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-page-nav:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.35;
}

/* Directory Footer & Pagination */
.directory-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 16px;
}

.footer-left {
  display: flex;
  align-items: center;
}

.footer-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.keyboard-guide {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-hint kbd {
  display: inline-block;
  background-color: var(--bg-app);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: inherit;
  color: var(--text-secondary);
}

.divider {
  color: var(--border-strong);
}

.pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  font-family: inherit;
}

.pagination-btn:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.pagination-btn.active {
  background-color: var(--brand-green-light);
  border-color: var(--brand-green);
  color: var(--brand-green);
  font-weight: 700;
}

[data-theme="dark"] .pagination-btn.active {
  color: #a7d8be;
}

.pagination-btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.4;
  border-color: var(--border-subtle);
}

.pagination-nav-btn {
  padding: 0 8px;
  font-size: 11.5px;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 30px;
  color: var(--text-muted);
  font-size: 12px;
}

.page-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.page-size-select {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.12s ease;
}

.page-size-select:focus {
  border-color: var(--border-focus);
}

.pagination-info {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .directory-footer {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .footer-left, .footer-center, .footer-right {
    width: 100%;
    justify-content: center;
  }
}

/* ==================== VIEW 2: DETAIL VIEW STYLES ==================== */

.detail-header-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 28px;
}

.back-link-btn {
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}

.back-link-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.detail-profile-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
}

.detail-avatar {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-sm);
  background-color: #4a729a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.detail-name {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.15;
}

.detail-subhead {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 66% 31%;
  gap: 3%;
  align-items: start;
}

/* Left Column Sections */
.detail-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-section:last-child {
  border-bottom: none;
}

.detail-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 14px;
}

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

.section-helper-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* Details Key-Value Table */
.details-kv-table {
  width: 100%;
  border-collapse: collapse;
}

.details-kv-table td {
  padding: 9px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.kv-key {
  width: 130px;
  color: var(--text-muted);
}

.kv-val {
  color: var(--text-primary);
  font-weight: 400;
}

.detail-link {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}

.detail-link:hover {
  text-decoration-color: var(--text-primary);
}

/* Tags Manager */
.tags-manager-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background-color: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--tag-text);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.detail-tag-label:hover {
  text-decoration: underline;
}

.tag-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.tag-remove-btn:hover {
  color: #c53030;
}

.btn-add-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background-color: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}

.btn-add-tag:hover {
  border-color: var(--brand-green);
  color: var(--brand-green);
}

.inline-tag-form {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-sm {
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}

/* Notes Text */
.notes-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Contact Log Table */
.contact-log-table {
  width: 100%;
  border-collapse: collapse;
}

.contact-log-table td {
  padding: 10px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.log-date-col {
  width: 110px;
  color: var(--text-muted);
  font-size: 12px;
}

.log-summary-col {
  color: var(--text-primary);
}

.log-actor-col {
  width: 100px;
  text-align: right;
  color: var(--text-muted);
  font-size: 12px;
}

/* Right Column Cards */
.sidebar-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  background-color: var(--bg-surface);
}

.card-title {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.card-muted {
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-muted);
}

.record-meta-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.record-meta-line strong {
  color: var(--text-primary);
}

.record-meta-line code {
  font-size: 12px;
  background-color: var(--bg-app);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.audit-events-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
}

.audit-event-item {
  font-size: 11.5px;
  border-left: 2px solid var(--brand-green);
  padding-left: 8px;
  color: var(--text-secondary);
}

.audit-event-type {
  font-weight: 600;
  color: var(--text-primary);
}

.audit-event-meta {
  color: var(--text-muted);
  font-size: 10.5px;
}

.same-org-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}

.same-org-item:last-child {
  border-bottom: none;
}

.same-org-item:hover .same-org-name {
  color: var(--brand-green);
}

.same-org-name {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text-primary);
}

.same-org-role {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ==================== DIALOG / MODAL STYLES ==================== */

.app-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: transparent;
  margin: auto;
  max-width: 540px;
  width: 90vw;
  box-shadow: var(--shadow-modal);
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.dialog-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dialog-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
}

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

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

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

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

.form-input.textarea {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

/* Entity Type Radio Chips */
.entity-type-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-chip input {
  display: none;
}

.radio-chip span {
  display: inline-block;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
}

.radio-chip input:checked + span {
  background-color: var(--brand-green-light);
  border-color: var(--brand-green);
  color: var(--brand-green);
  font-weight: 600;
}

[data-theme="dark"] .radio-chip input:checked + span {
  color: #a7d8be;
}

/* User Switcher */
.user-presets {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.user-select-btn {
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 14px;
}

.user-avatar-xs {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  background: var(--brand-green);
  color: #fff;
  font-size: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.oauth-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.oauth-section h4 {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.import-options {
  padding: 10px 0;
}

.import-option-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-app);
}

.import-option-card h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.import-option-card p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

.import-status-text {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--brand-green);
  font-weight: 600;
}
