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

:root {
  /* ── Brand palette ── */
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #323232;
  --color-text-muted: #666666;
  --color-text-light: #999999;
  --color-border: #e5e5e5;
  --color-brand-red: #e63331;
  --color-approve: #78bf89;
  --color-approve-hover: #5fa872;

  /* ── Working aliases ── */
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e5e5;
  --border-focus: #323232;
  --text: #323232;
  --text-muted: #666666;
  --text-light: #999999;
  --approve: #78bf89;
  --approve-hover: #5fa872;
  --reject: #e63331;
  --reject-hover: #c92a28;
  --danger-outline: #e63331;
  --warning-bg: #fffbe6;
  --warning-border: #f5c842;
  --warning-text: #7a5a00;
  --flag-bg: #fff8e1;
  --flag-border: #f5c842;
  --badge-pending-bg: #fff3cd;
  --badge-pending-text: #856404;
  --badge-approved-bg: #d1f5e0;
  --badge-approved-text: #155724;
  --badge-rejected-bg: #f8d7da;
  --badge-rejected-text: #721c24;
  --tag-bg: #f0f0f0;
  --tag-text: #323232;
  --tag-border: #d8d8d8;
  --nav-bg: #323232;
  --nav-text: rgba(255, 255, 255, 0.85);
  --nav-active: #ffffff;
  --nav-hover: rgba(255, 255, 255, 0.10);
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--color-brand-red); text-decoration: underline; }

/* ─── Global Main Wrapper ──────────────────────────────────── */
.main {
  min-height: calc(100vh - 52px);
}

/* ─── Navigation ───────────────────────────────────────────── */
.nav {
  background: var(--nav-bg);
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  height: 52px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  overflow: visible;
}

.nav-brand {
  display: flex;
  align-items: center;
  align-self: center;
  margin-right: 24px;
  flex-shrink: 0;
  text-decoration: none;
}

.nav-brand:hover { text-decoration: none; color: inherit; }

.nav-brand-text {
  color: var(--nav-active);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Ready for a logo image — swap <span class="nav-brand-text"> for
   <img class="nav-brand-logo" src="..." alt="E-Progress AI">    */
.nav-brand-logo {
  max-height: 30px;
  width: auto;
  object-fit: contain;
  display: block;
}

.nav-links {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.nav-link {
  color: var(--nav-text);
  font-size: 13.5px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--nav-hover);
  color: var(--nav-active);
  text-decoration: none;
}

.nav-link.active {
  color: var(--nav-active);
  font-weight: 600;
  border-bottom: 2px solid var(--color-brand-red);
}

/* ─── Page Layout ──────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.container-lg {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

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

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

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: inline-block;
  margin-bottom: 6px;
}

/* ─── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

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

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

.card-header .section-title { margin-bottom: 0; }

/* ─── Form Grid ────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 20px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px 20px;
}

/* ─── Form Fields ──────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.field input,
.field textarea,
.field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  font-family: inherit;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(50, 50, 50, 0.10);
}

.field textarea { resize: vertical; min-height: 72px; }

.field select { cursor: pointer; }

.readonly-field {
  background: #fafafa !important;
  color: var(--text-muted) !important;
  cursor: default;
}

.field-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.label-note {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* ─── Confidence Flags ─────────────────────────────────────── */
.field-flagged > label { color: #9a6800; }

.field-flagged input,
.field-flagged textarea,
.field-flagged select {
  border-color: var(--flag-border);
  background: var(--flag-bg);
}

.field-flagged input:focus,
.field-flagged textarea:focus,
.field-flagged select:focus {
  border-color: #e0a800;
  box-shadow: 0 0 0 3px rgba(245,200,66,0.18);
}

.flag-icon { margin-left: 4px; }

.flag-badge {
  display: inline-block;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  margin: 2px 3px;
}

/* ─── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
}

.alert-error {
  background: #fde8e8;
  border: 1px solid #f5b7b7;
  color: #7a1a1a;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

/* Primary — dark, used for Save / Upload / Add / Edit */
.btn-primary {
  background: #323232;
  color: #ffffff;
}
.btn-primary:hover { background: #1a1a1a; color: #ffffff; }

/* Approve / success — calm green */
.btn-approve {
  background: var(--approve);
  color: #ffffff;
}
.btn-approve:hover { background: var(--approve-hover); color: #ffffff; }

/* Reject / danger — brand red */
.btn-reject {
  background: var(--reject);
  color: #ffffff;
}
.btn-reject:hover { background: var(--reject-hover); color: #ffffff; }

/* Secondary — white with neutral border */
.btn-secondary {
  background: #ffffff;
  color: var(--text);
  border: 1px solid #d8d8d8;
}
.btn-secondary:hover { background: #f5f5f5; color: var(--text); }

/* Danger outline — for soft destructive actions */
.btn-danger-outline {
  background: transparent;
  color: var(--danger-outline);
  border: 1.5px solid var(--danger-outline);
}
.btn-danger-outline:hover { background: #fde8e8; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-block { width: 100%; justify-content: center; margin-top: 16px; }

.btn-link {
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.btn-link:hover { color: var(--color-brand-red); text-decoration: underline; }

.form-actions {
  display: flex;
  gap: 10px;
  padding: 4px 0 8px;
}

/* ─── Status Badges ────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-pending  { background: var(--badge-pending-bg);  color: var(--badge-pending-text); }
.status-approved { background: var(--badge-approved-bg); color: var(--badge-approved-text); }
.status-rejected { background: var(--badge-rejected-bg); color: var(--badge-rejected-text); }

/* ─── Data Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.data-table thead tr {
  background: #f7f7f7;
  border-bottom: 2px solid var(--border);
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

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

.table-row:hover { background: #f7f7f7; }

.col-title { font-weight: 600; max-width: 280px; }

/* ─── Metrics Table ────────────────────────────────────────── */
.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.metrics-table th,
.metrics-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.metrics-table th:first-child,
.metrics-table td:first-child { text-align: left; font-weight: 600; }

.metrics-table thead { background: #f7f7f7; }
.metrics-table tbody tr:last-child td { border-bottom: none; }

.metrics-wrap { margin-bottom: 8px; }

.delta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 12px;
  font-size: 13px;
}

.delta-label { color: var(--text-muted); font-weight: 600; }

.delta-chip {
  background: #f0f0f0;
  color: #555555;
  border: 1px solid #d8d8d8;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

/* ─── Tag Chip Editor ──────────────────────────────────────── */
.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 38px;
  cursor: text;
  transition: border-color 0.15s;
}

.tag-editor:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(50, 50, 50, 0.10);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--tag-border);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tag-text);
  font-size: 14px;
  line-height: 1;
  padding: 0 0 1px;
  opacity: 0.5;
  transition: opacity 0.1s;
}
.tag-remove:hover { opacity: 1; }

.tag-input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 2px 4px !important;
  font-size: 13px;
  min-width: 120px;
  flex: 1;
  background: transparent;
}

/* ─── Filter Bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-form select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.record-count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── Upload Zone ──────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fafafa;
}

.upload-zone:hover { border-color: #323232; background: #f5f5f5; }
.upload-zone.drag-over { border-color: #323232; background: #f0f0f0; }

.upload-icon { font-size: 36px; margin-bottom: 8px; }

.upload-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

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

.file-input { display: none; }

.file-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #f0f0f0;
  border: 1px solid #d8d8d8;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

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

/* ─── Loading State ────────────────────────────────────────── */
.loading-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: #323232;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}

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

/* ─── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-note {
  font-size: 13px;
  color: var(--text-light);
  font-style: italic;
  margin: 8px 0;
}

/* ─── Admin Grid ───────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.inline-add {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.inline-add-stack {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-add input,
.inline-add-stack input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  flex: 1;
  min-width: 120px;
  font-family: inherit;
}

.ref-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.ref-list li {
  background: #f0f0f0;
  border: 1px solid #d8d8d8;
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--text);
}

/* ─── Nav Dropdown ─────────────────────────────────────────── */
.nav-dropdown {
  display: inline-flex;
  align-items: stretch;
  position: relative;
}

.nav-dropdown-toggle {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--nav-text);
  font-size: 13.5px;
  padding: 0 12px;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.nav-dropdown-toggle:hover,
.nav-dropdown:focus-within .nav-dropdown-toggle {
  background: var(--nav-hover);
  color: var(--nav-active);
}

.nav-dropdown-toggle.active {
  color: var(--nav-active);
  font-weight: 600;
  border-bottom: 2px solid var(--color-brand-red);
}

.nav-dropdown-toggle::after {
  content: '▾';
  font-size: 10px;
  opacity: 0.7;
}

/* Gap between toggle and menu so the menu doesn't vanish on tiny mouse moves */
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% - 2px);
  left: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 220px;
  padding: 6px 0;
  z-index: 500;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-section {
  display: block;
  padding: 8px 14px 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-dropdown-item {
  display: block;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

a.nav-dropdown-item:hover {
  background: #f5f5f5;
  color: var(--text);
  text-decoration: none;
}

.nav-dropdown-disabled {
  color: var(--text-light);
  cursor: default;
  font-style: italic;
}

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

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .container { padding: 16px 14px 40px; }
  .container-lg { padding: 16px 14px 40px; }
  .page-header { flex-direction: column; }
  .admin-grid { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: flex-start; }
}

/* ─── Review Issue Cards ──────────────────────────────────── */
.review-issue-card {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  border-left: 4px solid transparent;
}

.review-issue-card-error {
  background: #fde8e8;
  border-left-color: #e63331;
}

.review-issue-card-warning {
  background: var(--warning-bg);
  border-left-color: var(--warning-border);
}

.review-issue-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.review-issue-label { font-size: 13px; font-weight: 700; }
.review-issue-card-error .review-issue-label { color: #7a1a1a; }
.review-issue-card-warning .review-issue-label { color: var(--warning-text); }

.review-issue-message { font-size: 13px; margin-bottom: 10px; }
.review-issue-card-error .review-issue-message { color: #7a1a1a; }
.review-issue-card-warning .review-issue-message { color: var(--warning-text); }

.raw-value {
  font-family: monospace;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.raw-value-error { background: #f5b7b7; color: #7a1a1a; }
.raw-value-warning { background: #f5e042; color: #5a4200; }

.btn-warning {
  background: var(--warning-border);
  color: #5a4200;
  border: 1px solid var(--warning-border);
}
.btn-warning:hover { background: #e0b500; }

/* ─── Review Page Layout ──────────────────────────────────── */
.review-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ─── Disabled Approve Button ─────────────────────────────── */
.btn-approve-disabled {
  background: #d8d8d8;
  color: #888888;
  cursor: not-allowed;
  border: none;
}
.btn-approve-disabled:hover { background: #d8d8d8; opacity: 1; }

/* ─── Tag Review ──────────────────────────────────────────── */
.tag-review-section { margin-bottom: 4px; }

.tag-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.tag-review-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--surface);
  transition: background 0.1s, border-color 0.1s;
}

.tag-review-row[data-state="accepted"] {
  background: #edf7f1;
  border-color: #7ec8a0;
}

.tag-review-row[data-state="rejected"] {
  background: #fdf0f0;
  border-color: #e8b0b0;
  opacity: 0.65;
}

.tag-review-text { font-size: 13px; color: var(--text); flex: 1; }

.tag-review-row[data-state="rejected"] .tag-review-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.tag-review-btns { display: flex; gap: 4px; flex-shrink: 0; }

.tag-review-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  color: var(--text-muted);
  line-height: 1;
}

.tag-accept-btn:hover { border-color: var(--approve); color: var(--approve); background: #edf7f1; }
.tag-reject-btn:hover { border-color: var(--reject); color: var(--reject); background: #fdf0f0; }

.tag-accept-btn.active { background: var(--approve); border-color: var(--approve); color: #fff; }
.tag-reject-btn.active { background: var(--reject); border-color: var(--reject); color: #fff; }

/* ─── Issue Card Text Overflow Protection ─────────────────── */
.review-issue-message,
.review-issue-card p,
.review-issue-card li,
.review-issue-card .field-note {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

/* ─── Nav Right (User Area) ────────────────────────────────── */
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 8px;
  flex-shrink: 0;
}

.nav-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.40);
  cursor: default;
  text-decoration: none;
  transition: color 0.15s;
  line-height: 1;
}

.nav-settings:hover { color: rgba(255, 255, 255, 0.65); text-decoration: none; }

.nav-user-name {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-logout-form { display: inline; margin: 0; padding: 0; }

.nav-logout-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.nav-logout-btn:hover { color: #ffffff; text-decoration: underline; }

/* ─── Login Page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.login-tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-config-error {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  text-align: left;
  margin-bottom: 20px;
  line-height: 1.5;
}

.login-error {
  background: #fde8e8;
  border: 1px solid #f5b7b7;
  color: #7a1a1a;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 20px;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: #323232;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-google:hover { background: #1a1a1a; color: #ffffff; text-decoration: none; }

.btn-google-disabled {
  background: #d0d0d0;
  color: #888888;
  cursor: not-allowed;
}

.btn-google-disabled:hover { background: #d0d0d0; color: #888888; }

/* ─── Settings Layout ──────────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  align-items: start;
}

.settings-sidebar {
  position: sticky;
  top: 72px;
}

.settings-nav { display: flex; flex-direction: column; }

.settings-nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  padding: 6px 8px 3px;
}

.settings-nav-item {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s;
}

.settings-nav-item:hover { background: #f0f0f0; text-decoration: none; color: var(--text); }

.settings-nav-item.active {
  background: #ebebeb;
  font-weight: 600;
  color: var(--text);
}

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

/* ─── Permission Table ─────────────────────────────────────── */
.perm-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.perm-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
  font-size: 13px;
}

.perm-table th {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 6px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.perm-table th:first-child { text-align: left; }

.perm-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.perm-row-label { font-size: 13px; color: var(--text); }

.perm-table-cell { text-align: center; }

.nav-settings {
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
}

@media (max-width: 640px) {
  .settings-layout {
    grid-template-columns: 1fr;
    padding: 16px 14px 40px;
  }
  .settings-sidebar { position: static; }
}

/* ─── Brief Enhancer ──────────────────────────────────────── */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
}

.checkbox-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
}

.checkbox-item input[type="checkbox"] {
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 1px;
}

.brief-pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

/* ─── Brief Paste Editor (contenteditable) ────────────────────── */
.brief-paste-editor {
  min-height: 200px;
  max-height: 420px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  overflow-y: auto;
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.brief-paste-editor:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(50, 50, 50, 0.10);
}

.brief-paste-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-light);
  pointer-events: none;
  display: block;
}

.brief-paste-editor p    { margin: 0 0 8px; }
.brief-paste-editor ul,
.brief-paste-editor ol   { padding-left: 20px; margin: 4px 0 8px; }
.brief-paste-editor li   { margin: 2px 0; }
.brief-paste-editor h1,
.brief-paste-editor h2,
.brief-paste-editor h3   { font-weight: 700; margin: 10px 0 4px; }
.brief-paste-editor h1   { font-size: 1.15em; }
.brief-paste-editor h2   { font-size: 1.05em; }
.brief-paste-editor h3   { font-size: 1em; }
.brief-paste-editor a    { color: var(--text); text-decoration: underline; }
.brief-paste-editor hr   { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* ─── Rich Brief Display (workspace / read-only) ──────────────── */
.brief-rich {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.brief-rich p         { margin: 0 0 8px; }
.brief-rich p:last-child { margin-bottom: 0; }
.brief-rich ul,
.brief-rich ol        { padding-left: 20px; margin: 4px 0 8px; }
.brief-rich li        { margin: 2px 0; }
.brief-rich h1,
.brief-rich h2,
.brief-rich h3        { font-weight: 700; margin: 12px 0 4px; }
.brief-rich h1        { font-size: 1.15em; }
.brief-rich h2        { font-size: 1.05em; }
.brief-rich h3        { font-size: 1em; }
.brief-rich a         { color: var(--text); text-decoration: underline; }
.brief-rich a:hover   { color: var(--color-brand-red); }
.brief-rich hr        { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.brief-rich blockquote {
  border-left: 3px solid var(--border);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-muted);
}

/* Brief Enhancer tag pickers (Ad Concepts, Angles) */
.meta-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  align-items: center;
  padding: 6px 0;
}

.meta-tags-empty {
  font-size: 12px;
  color: var(--text-light);
  font-style: italic;
}

.tag-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.tag-add-row select {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
}

.tag-add-row select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(50, 50, 50, 0.10);
}

/* Brief Enhancer session status badges */
/* ─── Brief Enhancer Evidence Retrieval ───────────────────────── */
.evidence-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.evidence-stat {
  display: flex;
  flex-direction: column;
}

.evidence-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.evidence-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}

.evidence-score-table {
  font-size: 12px;
}

.score-col {
  text-align: center;
  padding: 8px 6px;
  white-space: nowrap;
}

.score-cell {
  color: var(--text-light);
}

.score-hit {
  color: var(--text);
  font-weight: 600;
}

.evidence-test-link {
  font-size: 12px;
  font-family: monospace;
  color: var(--text);
}

.evidence-test-link:hover { color: var(--color-brand-red); }

.evidence-test-id {
  font-size: 12px;
  font-family: monospace;
  color: var(--text);
}

.evidence-test-title {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Brief Enhancer Relevance Pruning ────────────────────────── */
.pruning-rejected-details {
  margin-top: 8px;
}

.pruning-rejected-summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
}

.pruning-rejected-summary:hover { color: var(--text); }

.pruning-rejected-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pruning-rejected-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 12px;
}

.pruning-test-id {
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
}

.pruning-test-title {
  font-size: 11px;
  color: var(--text-muted);
}

.pruning-reason {
  font-size: 12px;
  color: var(--text);
  margin-top: 2px;
}

.status-draft_created             { background: #f0f0f0; color: #555555; }
.status-metadata_ready            { background: #e8f4fd; color: #1a6fa8; }
.status-metadata_confirmed        { background: #e8f4fd; color: #1a6fa8; }
.status-evidence_selected         { background: #e8f4fd; color: #1a6fa8; }
.status-relevance_pruned          { background: #fff3cd; color: #856404; }
.status-recommendations_generated { background: #fff3cd; color: #856404; }
.status-decisions_saved           { background: #fff3cd; color: #856404; }
.status-final_generated           { background: #d1f5e0; color: #155724; }
.status-brief_card_saved          { background: #d1f5e0; color: #155724; }
