/* CSS Custom Properties */
:root {
  /* Colors - Header */
  --header-bg: #009cbd;
  --header-border: #007a96;
  --header-text: #ffffff;
  --header-link-hover: #d0f2f8;
  --header-link-active: #a0e4f1;

  /* Colors - Status Badges */
  --status-active-bg: #c6f6d5;
  --status-active-text: #22543d;
  --status-on-hold-bg: #fef5e7;
  --status-on-hold-text: #744210;
  --status-completed-bg: #bee3f8;
  --status-completed-text: #2c5282;
  --status-archived-bg: #e2e8f0;
  --status-archived-text: #4a5568;

  /* Colors - UI */
  --bg-primary: #ffffff;
  --bg-secondary: #f7fafc;
  --text-primary: #1a202c;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  --link-color: #3182ce;
  --link-hover: #2c5282;

  /* Colors - Feedback */
  --success-bg: #c6f6d5;
  --success-text: #22543d;
  --error-bg: #fed7d7;
  --error-text: #742a2a;
  --warning-bg: #fef5e7;
  --warning-text: #744210;
  --info-bg: #bee3f8;
  --info-text: #2c5282;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
}

/* ── Stat Cards ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (min-width: 600px) { .stats-row { grid-template-columns: repeat(5, 1fr); } }

.stat-card {
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid transparent;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card.stat-active {
  outline: 2px solid var(--link-color);
  outline-offset: -2px;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Skeleton shimmer */
.skeleton-bar {
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e2e8f0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Base Reset and Typography */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--spacing-md);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Loading Bar */
#loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #3182ce, #63b3ed);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  z-index: 9999;
  opacity: 0;
}

#loading-bar.active {
  opacity: 1;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    transform: scaleX(0);
  }
  50% {
    transform: scaleX(0.5);
  }
  100% {
    transform: scaleX(1);
  }
}

/* App Header */
.app-header {
  background-color: var(--header-bg);
  border-bottom: 2px solid var(--header-border);
  padding: var(--spacing-md) var(--spacing-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title {
  color: var(--header-text);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.header-nav {
  display: flex;
  gap: var(--spacing-lg);
}

.header-nav a {
  color: var(--header-text);
  text-decoration: none;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  transition: background-color 0.2s ease;
  font-weight: 500;
}

.header-nav a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--header-link-hover);
}

.header-nav a.active {
  background-color: rgba(144, 205, 244, 0.2);
  color: var(--header-link-active);
}

/* Profile Menu */
.profile-menu {
  position: relative;
}

.profile-icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #ffffff;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.5px;
  transition: background 0.15s;
}

.profile-icon-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.profile-icon-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

.profile-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  z-index: 1100;
  overflow: hidden;
  flex-direction: column;
}

.profile-dropdown.open {
  display: flex;
}

.profile-dropdown-name {
  padding: 14px 18px 2px;
  font-weight: 600;
  color: #1a202c;
  font-size: 0.95rem;
}

.profile-dropdown-email {
  padding: 0 18px 12px;
  font-size: 0.78rem;
  color: #718096;
  border-bottom: 1px solid #edf2f7;
}

.profile-dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 18px;
  font-size: 0.88rem;
  color: #2d3748;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.1s;
}

.profile-dropdown-item:hover {
  background: #f7fafc;
}

.profile-dropdown-logout {
  border-top: 1px solid #edf2f7;
  color: #e53e3e;
}

.profile-dropdown-logout:hover {
  background: #fff5f5;
}

/* User Badges */
.user-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.user-badge-admin {
  background-color: #fefcbf;
  color: #975a16;
}

.user-badge-user {
  background-color: #bee3f8;
  color: #2a4365;
}

.user-badge-active {
  background-color: #c6f6d5;
  color: #276749;
}

.user-badge-inactive {
  background-color: #fed7d7;
  color: #9b2c2c;
}

/* Main Content Area */
#app-content {
  max-width: 1200px;
  margin: var(--spacing-xl) auto;
  padding: 0 var(--spacing-xl);
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  transition: margin-right 0.25s ease;
}

/* Shift content when AI chat panel is open */
body.ai-chat-open #app-content {
  margin-right: var(--ai-chat-width, 400px);
}

body.ai-chat-open .app-header {
  padding-right: calc(var(--spacing-xl) + var(--ai-chat-width, 400px));
}

#app-content.full-width {
  max-width: none;
  margin-top: var(--spacing-md);
  margin-bottom: 0;
}

/* Route Views */
.route-view {
  display: none;
}

.route-view.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Table views: toolbar + footer stay visible, only table body scrolls */
.route-view.active .datatable-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.route-view.active:has(.datatable-wrapper) {
  overflow: hidden;
}

.route-view.active .datatable-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-badge.active {
  background-color: var(--status-active-bg);
  color: var(--status-active-text);
}

.status-badge.on-hold {
  background-color: var(--status-on-hold-bg);
  color: var(--status-on-hold-text);
}

.status-badge.completed {
  background-color: var(--status-completed-bg);
  color: var(--status-completed-text);
}

.status-badge.archived {
  background-color: var(--status-archived-bg);
  color: var(--status-archived-text);
}

/* Cards */
.card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-md);
}

.card-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.card-body {
  padding: 0;
}

.card-footer {
  border-top: 1px solid var(--border-color);
  padding-top: var(--spacing-md);
  margin-top: var(--spacing-md);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: #3182ce;
  color: white;
}

.btn:hover {
  background-color: #2c5282;
  text-decoration: none;
}

.btn-secondary {
  background-color: #718096;
  color: white;
}

.btn-secondary:hover {
  background-color: #4a5568;
}

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

.btn-danger:hover {
  background-color: #c53030;
}

.modal-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-footer-right {
  display: flex;
  gap: var(--spacing-sm);
  margin-left: auto;
}

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

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

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

.form-input-highlight {
  background-color: #dbeafe;
}

/* Phase multi-select */
.phase-multi-select {
  position: relative;
}

.phase-multi-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.phase-multi-btn.active {
  border-color: #3182ce;
}

.phase-multi-dd {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 100%;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 200;
  padding: 4px 0;
}

.phase-multi-dd.show {
  display: block;
}

.phase-multi-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
}

.phase-multi-item:hover {
  background: #edf2f7;
}

.phase-multi-item input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table thead {
  background-color: var(--bg-secondary);
}

.table th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
}

.table td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

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

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

/* Utility Classes */
.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

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

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap {
  gap: var(--spacing-md);
}

.gap-sm {
  gap: var(--spacing-sm);
}

.gap-lg {
  gap: var(--spacing-lg);
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mt-5 { margin-top: var(--spacing-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mb-5 { margin-bottom: var(--spacing-xl); }

.ml-0 { margin-left: 0; }
.ml-1 { margin-left: var(--spacing-xs); }
.ml-2 { margin-left: var(--spacing-sm); }
.ml-3 { margin-left: var(--spacing-md); }
.ml-4 { margin-left: var(--spacing-lg); }

.mr-0 { margin-right: 0; }
.mr-1 { margin-right: var(--spacing-xs); }
.mr-2 { margin-right: var(--spacing-sm); }
.mr-3 { margin-right: var(--spacing-md); }
.mr-4 { margin-right: var(--spacing-lg); }

/* Grid Layouts */
.grid-2-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

.grid-3-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
}

/* Sortable Table Headers */
th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]:hover {
  background-color: #e2e8f0;
}

/* Search and Filter UI */
.search-bar {
  width: 100%;
  font-size: 1rem;
  padding: var(--spacing-md);
}

.filter-bar {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-md);
}

.results-count {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: var(--spacing-sm);
}

/* Error Messages */
.error-message {
  display: none;
  color: var(--error-text);
  font-size: 0.75rem;
  margin-top: var(--spacing-xs);
}

.error-message.active {
  display: block;
}

/* Dialog/Modal Styling */
dialog {
  max-width: 700px;
  width: 90%;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

dialog .card {
  margin: 0;
}

/* Drawer (slides from right) */
dialog.drawer {
  position: fixed;
  top: 0;
  left: auto;
  right: 0;
  height: 100vh;
  max-height: 100vh;
  width: 380px;
  max-width: 90vw;
  margin: 0;
  border-radius: 0;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
}

dialog.drawer[open] {
  transform: translateX(0);
}

dialog.drawer::backdrop {
  background-color: rgba(0, 0, 0, 0.4);
}

dialog.drawer .card {
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 0;
}

dialog.drawer .card-body {
  flex: 1;
  overflow-y: auto;
}

dialog.drawer .card-header {
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

dialog.drawer .card-footer {
  border-top: 1px solid var(--border-color);
  padding-top: var(--spacing-md);
}

dialog.drawer-wide {
  width: 50vw;
  max-width: 50vw;
}

dialog.drawer-twothirds {
  width: 66.67vw;
  max-width: 66.67vw;
}

dialog.drawer-twothirds.from-project {
  right: 50vw;
  max-width: 50vw;
}

/* Contact projects sub-panel */
.contact-projects-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-project-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border-color);
}

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

.contact-project-name {
  flex: 1;
  font-weight: 500;
}

.contact-project-role {
  background: var(--primary);
  color: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.contact-project-status {
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green { background: #d1fae5; color: #065f46; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #374151; }

/* Drawer form sections */
dialog.drawer fieldset {
  border: 2px solid #000;
  border-radius: var(--radius-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  margin: 0 0 var(--spacing-lg) 0;
}

dialog.drawer legend {
  font-size: 1rem;
  font-weight: 700;
  padding: 0 var(--spacing-sm);
}

/* Badge Button (clickable badge wrapper) */
.badge-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  transition: opacity 0.15s, border-color 0.15s;
}

.badge-btn:hover {
  opacity: 0.85;
  border-color: var(--primary);
}

.badge-btn .badge,
.badge-btn .feedback-badge {
  pointer-events: none;
}

/* Option Picker Drawer Content */
.option-picker-grid {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.option-picker-btn {
  display: block;
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s, box-shadow 0.1s;
}

.option-picker-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.option-picker-btn.active {
  box-shadow: var(--shadow-lg);
}

/* Settings Config Buttons */
.settings-config-btn {
  display: block;
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: #3182ce;
  color: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.settings-config-btn:hover {
  background: #2b6cb0;
}

/* Config Editor Drawer Rows */
.cfg-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

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

.cfg-row .cfg-color {
  width: 32px;
  height: 32px;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.cfg-row .badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 60px;
  text-align: center;
}

.cfg-row .cfg-label {
  flex: 2;
  min-width: 0;
}

.cfg-row .cfg-id {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cfg-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.cfg-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.cfg-btn:hover {
  background: var(--bg-secondary);
}

.cfg-btn.cfg-del:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

/* Responsive Design */

/* Tablet: 900px */
@media (max-width: 900px) {
  .app-header {
    flex-wrap: wrap;
    gap: var(--spacing-md);
  }

  .header-nav {
    width: 100%;
    justify-content: center;
    order: 3;
  }

  #app-content {
    padding: 0 var(--spacing-md);
  }
}

/* Mobile: 768px */
@media (max-width: 768px) {
  .header-nav {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }

  .header-nav a {
    flex: 1 1 auto;
    text-align: center;
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.375rem; }
  h3 { font-size: 1.125rem; }

  .table {
    font-size: 0.875rem;
  }

  .table th,
  .table td {
    padding: var(--spacing-sm);
  }

  .grid-2-col,
  .grid-3-col {
    grid-template-columns: 1fr;
  }
}

/* Small Mobile: 540px */
@media (max-width: 540px) {
  .app-header {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .header-title {
    font-size: 1.25rem;
  }

  .header-nav {
    flex-direction: column;
    gap: var(--spacing-xs);
  }

  .header-nav a {
    width: 100%;
  }

  #app-content {
    margin: var(--spacing-md) auto;
    padding: 0 var(--spacing-sm);
  }

  .card {
    padding: var(--spacing-md);
  }

  .btn {
    width: 100%;
  }

  .flex {
    flex-direction: column;
  }
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: var(--spacing-xl);
  font-style: italic;
}

/* Filter buttons */
.filter-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background-color: var(--bg-secondary);
}

.filter-btn.active {
  background-color: #3182ce;
  color: white;
  border-color: #3182ce;
}

/* Pursuits Grid */
.pursuits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.pursuit-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  transition: box-shadow 0.2s ease;
}

.pursuit-card:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.pursuit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
  gap: var(--spacing-sm);
}

.pursuit-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary-color);
  text-decoration: none;
  flex-grow: 1;
}

.pursuit-name:hover {
  text-decoration: underline;
}

.pursuit-meta {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  font-size: 0.875rem;
  color: var(--text-secondary);
}


/* Pursuit Detail Layout — Two Column */
.pursuit-detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  margin-top: var(--spacing-lg);
}

@media (max-width: 1024px) {
  .pursuit-detail-layout {
    grid-template-columns: 1fr;
  }
}

.pursuit-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

@media (max-width: 640px) {
  .pursuit-info-grid {
    grid-template-columns: 1fr;
  }
}

.info-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
}

.info-card label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

.info-card div {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

/* Decision and Outcome Sections */
.decision-section,
.outcome-section {
  margin-top: var(--spacing-lg);
  padding: var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
}

.decision-section h3,
.outcome-section h3 {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}



/* Notes Section */
.notes-section {
  margin-top: var(--spacing-lg);
  padding: var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
}

.notes-section h3 {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

/* Links Panel (pursuit detail) */
.links-panel {
  margin-top: var(--spacing-lg);
}

.links-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
}

.links-panel-header h3 {
  margin: 0;
}

.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  margin-bottom: var(--spacing-xs);
}

.link-row-anchor {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #3182ce;
  text-decoration: none;
  min-width: 0;
}

.link-row-anchor span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row-anchor:hover {
  text-decoration: underline;
}

.link-delete-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.link-delete-btn:hover {
  color: #e53e3e;
}

.link-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

/* Notes Panel (pursuit detail Col 2) */
.notes-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
}

.notes-panel-header h3 {
  margin: 0;
}

.note-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  margin-bottom: var(--spacing-sm);
}

.note-card-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8125rem;
}

.note-meta {
  flex: 1;
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.note-actions {
  display: flex;
  gap: 2px;
}

.note-edit-btn,
.note-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1;
}

.note-edit-btn:hover,
.note-delete-btn:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.note-delete-btn:hover {
  color: #c53030;
}

.note-card-body {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.note-type-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.note-type-call { background-color: #bee3f8; color: #2c5282; }
.note-type-meeting { background-color: #c6f6d5; color: #22543d; }
.note-type-internal { background-color: #e2e8f0; color: #4a5568; }
.note-type-decision { background-color: #fefcbf; color: #975a16; }

.note-form {
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background-color: var(--bg-secondary);
}

.note-form select {
  margin-bottom: var(--spacing-sm);
}

.note-form textarea {
  margin-bottom: var(--spacing-sm);
  resize: vertical;
}

.note-form-actions {
  display: flex;
  gap: var(--spacing-sm);
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: var(--spacing-lg);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  cursor: pointer;
  font-size: 0.9375rem;
}

.radio-label input[type="radio"] {
  cursor: pointer;
}

/* Settings Page */
.settings-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  align-items: start;
}

@media (max-width: 768px) {
  .settings-sections {
    grid-template-columns: 1fr;
  }
}

.settings-section {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: var(--spacing-lg);
}

.settings-section h3 {
  margin: 0 0 var(--spacing-lg);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

.settings-logo-preview {
  margin-top: var(--spacing-sm);
  padding: var(--spacing-md);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  text-align: center;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-logo-preview img {
  max-height: 80px;
  max-width: 100%;
  object-fit: contain;
}

.settings-actions {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

/* Feedback Table (Settings) */
.feedback-table {
  width: 100%;
  border-collapse: collapse;
}

.feedback-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.feedback-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
}

.feedback-table tr:hover {
  background: var(--bg-secondary);
  cursor: pointer;
}

.feedback-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.feedback-type-bug { background: #fed7d7; color: #c53030; }
.feedback-type-feature { background: #bee3f8; color: #2b6cb0; }
.feedback-type-question { background: #e2e8f0; color: #4a5568; }
.feedback-priority-critical { background: #fed7d7; color: #c53030; }
.feedback-priority-high { background: #fed7d7; color: #e53e3e; }
.feedback-priority-medium { background: #fefcbf; color: #975a16; }
.feedback-priority-low { background: #e2e8f0; color: #718096; }
.feedback-status-open { background: #bee3f8; color: #2b6cb0; }
.feedback-status-in-progress { background: #fefcbf; color: #975a16; }
.feedback-status-closed { background: #e2e8f0; color: #4a5568; }

/* ── Project Detail Tabs ── */
.project-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 4px;
}
.tab-btn {
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover {
  background: #e2e8f0;
}
.tab-btn.active {
  background: var(--bg-primary);
  border-bottom-color: var(--bg-primary);
  color: var(--link-color);
  font-weight: 600;
  margin-bottom: -2px;
  border-top: 2px solid var(--link-color);
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* Data completeness badge */
.completeness-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.completeness-badge.high   { background: var(--success-bg); color: var(--success-text); }
.completeness-badge.medium { background: var(--warning-bg); color: var(--warning-text); }
.completeness-badge.low    { background: var(--error-bg);   color: var(--error-text);   }

.items-end { align-items: flex-end; }

/* ── Project field label/value layout ── */
.proj-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}
.proj-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.proj-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.proj-empty {
  font-size: 0.85rem;
  color: #e57373;
  font-style: italic;
}
