/* ═══════════════════════════════════════════════════════════════════════════
   GrantMind — Design System
   Warm, mission-driven aesthetic
═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  /* Warm creams */
  --cream:        #faf8f5;
  --cream-100:    #f5f1ea;
  --cream-200:    #ede7dc;
  --cream-300:    #e5ddd0;

  /* Warm browns */
  --brown-900:    #2c2825;
  --brown-700:    #4a403b;
  --brown-500:    #7a6b61;
  --brown-300:    #b0a396;
  --brown-100:    #ddd5cc;

  /* Terracotta (primary accent) */
  --terra-600:    #b85c2f;
  --terra-500:    #c4703f;
  --terra-400:    #d48558;
  --terra-300:    #e2a07c;
  --terra-200:    #eabd9e;
  --terra-100:    #f5dece;
  --terra-50:     #fdf5ef;

  /* Sage green (secondary accent) */
  --sage-600:     #5c8060;
  --sage-500:     #7a9e7e;
  --sage-400:     #96b699;
  --sage-200:     #c4d9c6;
  --sage-100:     #d8eeda;
  --sage-50:      #f0f7f1;

  /* Semantic colors */
  --amber-500:    #c4943f;
  --amber-100:    #f5e6c0;
  --amber-50:     #fdf7e6;
  --red-500:      #c44f3f;
  --red-200:      #eca99f;
  --red-50:       #fdf2f0;
  --blue-500:     #4f7ec4;
  --blue-50:      #eff4fd;

  --white:        #ffffff;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(44, 40, 37, 0.05);
  --shadow-sm:    0 1px 4px rgba(44, 40, 37, 0.08);
  --shadow:       0 2px 8px rgba(44, 40, 37, 0.10);
  --shadow-lg:    0 4px 20px rgba(44, 40, 37, 0.13);

  /* Radii */
  --r-sm:         6px;
  --r:            10px;
  --r-lg:         14px;
  --r-xl:         20px;
  --r-full:       9999px;

  /* Typography */
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* Layout */
  --sidebar-w:    228px;
  --page-pad:     28px;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--brown-900);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--terra-500); text-decoration: none; }
a:hover { color: var(--terra-600); text-decoration: underline; }

input, textarea, select, button { font-family: var(--font); font-size: inherit; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--cream-100);
  border-right: 1px solid var(--cream-300);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

#main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  height: 100vh;
}

/* ── Sidebar Brand ──────────────────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--cream-300);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--terra-50);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--terra-100);
}

.brand-text { display: flex; flex-direction: column; gap: 1px; }

.brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brown-900);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--brown-300);
  letter-spacing: 0.02em;
  font-weight: 400;
  line-height: 1.2;
}

/* ── Sidebar Navigation ─────────────────────────────────────────────────── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--brown-500);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.14s, color 0.14s;
  cursor: pointer;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  background: var(--cream-200);
  color: var(--brown-700);
  text-decoration: none;
}

.nav-item.active {
  background: var(--terra-50);
  color: var(--terra-600);
  border: 1px solid var(--terra-100);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--brown-100);
  color: var(--brown-700);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--r-full);
  line-height: 1.6;
}

.nav-badge.urgent {
  background: var(--red-500);
  color: white;
}

/* ── Sidebar Footer ─────────────────────────────────────────────────────── */
.sidebar-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--cream-300);
}

.api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--brown-300);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brown-100);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.ok      { background: var(--sage-500); }
.status-dot.error   { background: var(--red-500); }
.status-dot.warning { background: var(--amber-500); }

/* ── Page Layout ────────────────────────────────────────────────────────── */
.page {
  padding: var(--page-pad);
  max-width: 1100px;
}

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

.page-header-left { min-width: 0; flex: 1; }

.page-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brown-900);
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: break-word;
  word-break: break-word;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--brown-500);
  margin-top: 3px;
  font-weight: 400;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.14s, box-shadow 0.14s, opacity 0.14s, transform 0.1s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:hover   { text-decoration: none; }
.btn:active  { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--terra-500);
  color: white;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--terra-600); color: white; }

.btn-secondary {
  background: white;
  color: var(--brown-700);
  border: 1px solid var(--cream-300);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--cream-100); border-color: var(--brown-100); color: var(--brown-700); }

.btn-ghost {
  background: transparent;
  color: var(--brown-500);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--cream-200); color: var(--brown-700); }

.btn-danger {
  background: var(--red-500);
  color: white;
  box-shadow: var(--shadow-xs);
}
.btn-danger:hover { background: #b03a2a; color: white; }

.btn-sage {
  background: var(--sage-500);
  color: white;
  box-shadow: var(--shadow-xs);
}
.btn-sage:hover { background: var(--sage-600); color: white; }

.btn-amber {
  background: var(--amber-500);
  color: white;
  box-shadow: var(--shadow-xs);
}
.btn-amber:hover { background: #a87a30; color: white; }

.btn-blue {
  background: var(--blue-500);
  color: white;
  box-shadow: var(--shadow-xs);
}
.btn-blue:hover { background: #3d68a8; color: white; }

.btn-lg  { padding: 11px 22px; font-size: 0.95rem; }
.btn-sm  { padding: 6px 12px;  font-size: 0.8rem; }

.btn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-ghost-sm {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--brown-300);
  font-size: 0.8rem;
  padding: 3px 6px;
  border-radius: var(--r-sm);
  transition: color 0.14s, background 0.14s;
}
.btn-ghost-sm:hover { color: var(--red-500); background: var(--red-50); }

/* ── KB Controls ────────────────────────────────────────────────────────── */
.kb-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.search-wrap {
  position: relative;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--brown-300);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--cream-300);
  background: white;
  color: var(--brown-900);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
  box-shadow: var(--shadow-xs);
}
.search-input:focus {
  border-color: var(--terra-300);
  box-shadow: 0 0 0 3px rgba(196, 112, 63, 0.12);
}
.search-input::placeholder { color: var(--brown-300); }

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 5px 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--cream-300);
  background: white;
  color: var(--brown-500);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
  white-space: nowrap;
}
.chip:hover { background: var(--cream-100); color: var(--brown-700); }
.chip.active {
  background: var(--terra-50);
  color: var(--terra-600);
  border-color: var(--terra-200);
  font-weight: 600;
}

/* ── Document Grid ──────────────────────────────────────────────────────── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

/* ── Document Card ──────────────────────────────────────────────────────── */
.doc-card {
  background: white;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.12s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--cream-200);
  transform: translateY(-1px);
}

.doc-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.doc-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.14s;
}

.doc-card:hover .doc-card-actions { opacity: 1; }

.doc-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--brown-300);
  transition: background 0.14s, color 0.14s;
}

.doc-action-btn:hover         { background: var(--cream-200); color: var(--brown-700); }
.doc-action-btn.delete:hover  { background: var(--red-50);    color: var(--red-500); }

.doc-action-btn svg { width: 14px; height: 14px; }

.doc-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown-900);
  line-height: 1.3;
  flex: 1;
}

.doc-card-desc {
  font-size: 0.8rem;
  color: var(--brown-500);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.doc-card-meta {
  font-size: 0.75rem;
  color: var(--brown-300);
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc-card-meta .sep { opacity: 0.5; }

/* Category badge */
.cat-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cat-mission     { background: var(--terra-50);  color: var(--terra-600);  }
.cat-programs    { background: var(--sage-50);   color: var(--sage-600);   }
.cat-staff       { background: var(--amber-50);  color: var(--amber-500);  }
.cat-financial   { background: #f0f5e0;          color: #5e7a2a;           }
.cat-impact      { background: var(--sage-50);   color: var(--sage-600);   }
.cat-application { background: #e8f0fa;          color: #3d62a0;           }
.cat-other       { background: var(--cream-200); color: var(--brown-500);  }

/* Category icon backgrounds */
.cat-icon-mission     { background: var(--terra-50);  }
.cat-icon-programs    { background: var(--sage-50);   }
.cat-icon-staff       { background: var(--amber-50);  }
.cat-icon-financial   { background: #f0f5e0;          }
.cat-icon-impact      { background: var(--sage-50);   }
.cat-icon-application { background: #e8f0fa;          }
.cat-icon-other       { background: var(--cream-200); }

/* ── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  max-width: 480px;
  margin: 0 auto;
}

.empty-icon { margin-bottom: 20px; }
.empty-icon svg { width: 72px; height: 72px; }

.empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brown-900);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.empty-desc {
  font-size: 0.875rem;
  color: var(--brown-500);
  line-height: 1.6;
  margin-bottom: 20px;
}

.empty-suggestions {
  background: var(--cream-100);
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  padding: 16px 20px;
  text-align: left;
  width: 100%;
  margin-bottom: 24px;
}

.suggestions-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brown-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.empty-suggestions ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.empty-suggestions li {
  font-size: 0.85rem;
  color: var(--brown-700);
  padding-left: 14px;
  position: relative;
}

.empty-suggestions li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--terra-400);
}

/* ── Upload Zone ────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--cream-300);
  border-radius: var(--r);
  background: var(--cream-100);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--terra-400);
  background: var(--terra-50);
}

.upload-zone-icon { width: 48px; height: 48px; margin-bottom: 4px; }

.upload-zone.mini { padding: 20px; }
.upload-zone.mini .upload-zone-icon { width: 32px; height: 32px; }

.upload-zone-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown-700);
}

.upload-zone-sub {
  font-size: 0.83rem;
  color: var(--brown-500);
}

.upload-hint {
  font-size: 0.75rem;
  color: var(--brown-300);
  margin-top: 2px;
}

.upload-file-info {
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  background: white;
  padding: 12px 14px;
}

.upload-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-file-icon {
  width: 32px;
  height: 32px;
  background: var(--terra-50);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--terra-500);
}

.upload-file-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.upload-file-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--brown-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-file-size {
  font-size: 0.75rem;
  color: var(--brown-300);
}

/* Upload progress */
.upload-progress {
  padding: 16px;
  border-top: 1px solid var(--cream-200);
}

.progress-bar {
  height: 6px;
  background: var(--cream-200);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--terra-500);
  border-radius: var(--r-full);
  transition: width 0.3s;
  width: 0%;
}

.progress-label {
  font-size: 0.8rem;
  color: var(--brown-500);
  text-align: center;
}

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 40, 37, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  padding: 20px;
}

.modal {
  background: white;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.18s ease;
}

.modal-wide { max-width: 720px; }
.modal-sm   { max-width: 360px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--cream-200);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brown-900);
  letter-spacing: -0.01em;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--brown-300);
  margin-top: 3px;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--r-sm);
  color: var(--brown-300);
  flex-shrink: 0;
  transition: background 0.14s, color 0.14s;
}
.modal-close:hover { background: var(--cream-100); color: var(--brown-700); }
.modal-close svg { width: 14px; height: 14px; }

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-body.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--cream-200);
  flex-shrink: 0;
}

/* ── Form Elements ──────────────────────────────────────────────────────── */
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-row   { display: flex; gap: 12px; flex-wrap: wrap; }
.form-field { flex: 1; min-width: 160px; }
.form-field-sm { flex: 0 0 140px; min-width: 0; }

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brown-700);
  letter-spacing: 0.01em;
}

.field-optional {
  font-weight: 400;
  color: var(--brown-300);
}

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brown-700);
}

.required { color: var(--terra-500); }

input[type="text"],
input[type="date"],
input[type="search"],
input[type="number"],
textarea,
select {
  padding: 9px 12px;
  border: 1px solid var(--cream-300);
  border-radius: var(--r-sm);
  background: white;
  color: var(--brown-900);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--terra-300);
  box-shadow: 0 0 0 3px rgba(196, 112, 63, 0.12);
}

input::placeholder, textarea::placeholder { color: var(--brown-300); }

textarea { resize: vertical; line-height: 1.55; }
.textarea-lg { min-height: 180px; }
.textarea-sm { min-height: 80px; }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23b0a396' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

/* ── Confirm Modal ──────────────────────────────────────────────────────── */
.confirm-icon { margin-bottom: 14px; }
.confirm-icon svg { width: 48px; height: 48px; }

.confirm-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brown-900);
  margin-bottom: 6px;
}

.confirm-desc {
  font-size: 0.875rem;
  color: var(--brown-500);
  margin-bottom: 4px;
}

/* ── Document Content View ──────────────────────────────────────────────── */
.doc-content-area {
  background: var(--cream-100);
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  padding: 20px;
  min-height: 200px;
  max-height: 60vh;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--brown-700);
  white-space: pre-wrap;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.doc-content-loading {
  color: var(--brown-300);
  font-style: italic;
  font-family: var(--font);
}

/* ── Toast Notifications ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 340px;
  animation: toast-in 0.22s ease;
  border: 1px solid transparent;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast-success { background: white; color: var(--brown-900); border-color: var(--sage-200); }
.toast-error   { background: white; color: var(--brown-900); border-color: var(--red-200); }
.toast-info    { background: white; color: var(--brown-900); border-color: var(--cream-300); }

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast-success .toast-dot { background: var(--sage-500); }
.toast-error   .toast-dot { background: var(--red-500); }
.toast-info    .toast-dot { background: var(--terra-400); }

/* ── Callouts ───────────────────────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.callout-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.callout-warn {
  background: var(--amber-50);
  border-color: var(--amber-100);
  color: var(--brown-700);
}
.callout-warn .callout-icon { color: var(--amber-500); }

.callout-info {
  background: var(--blue-50);
  border-color: #c8d9f0;
  color: var(--brown-700);
}
.callout-info .callout-icon { color: var(--blue-500); }

.callout a.link { color: var(--terra-500); font-weight: 500; }

/* ── Grant Writing ──────────────────────────────────────────────────────── */
.gw-panel { max-width: 720px; }
.gw-form  { display: flex; flex-direction: column; gap: 0; }

.form-section {
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  background: white;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
}

.form-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brown-900);
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.form-section-desc {
  font-size: 0.875rem;
  color: var(--brown-500);
  margin: -8px 0 16px;
  line-height: 1.5;
}

.step-num {
  width: 24px;
  height: 24px;
  background: var(--terra-500);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.rfp-tabs {
  display: flex;
  gap: 4px;
  background: var(--cream-100);
  border: 1px solid var(--cream-300);
  border-radius: var(--r-sm);
  padding: 4px;
  width: fit-content;
  margin-bottom: 12px;
}

.rfp-tab {
  padding: 6px 14px;
  border: none;
  background: none;
  border-radius: calc(var(--r-sm) - 2px);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--brown-500);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.rfp-tab.active {
  background: white;
  color: var(--brown-900);
  box-shadow: var(--shadow-xs);
}

.rfp-panel { display: flex; flex-direction: column; gap: 10px; }

.tone-selector {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tone-option { display: none; }
.tone-option input { display: none; }

.tone-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
  min-width: 140px;
  background: white;
}

.tone-option { display: block; }

.tone-option input:checked + .tone-card {
  border-color: var(--terra-300);
  background: var(--terra-50);
}

.tone-card:hover { border-color: var(--terra-200); background: var(--terra-50); }

.tone-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brown-900);
}

.tone-desc {
  font-size: 0.75rem;
  color: var(--brown-500);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.file-selected-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--cream-100);
  border: 1px solid var(--cream-300);
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  color: var(--brown-700);
}

.file-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--terra-400); }

.rfp-analyzing { color: var(--terra-500); font-size: 0.8rem; display: inline-flex; align-items: center; gap: 4px; }

/* ── Draft Edit Textarea ────────────────────────────────────────────────── */
.draft-edit-textarea {
  min-height: 420px;
  resize: vertical;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.7;
}

/* ── Draft View ─────────────────────────────────────────────────────────── */
.draft-stream {
  background: white;
  border: 1px solid var(--cream-300);
  border-radius: var(--r-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  min-height: 300px;
  max-width: 820px;
}

.draft-content {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--brown-900);
  white-space: pre-wrap;
}

.draft-content h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brown-900);
  margin: 24px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--cream-200);
  letter-spacing: -0.01em;
}

.draft-content h2:first-child { margin-top: 0; }

.draft-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--terra-500);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Grant Tracker ──────────────────────────────────────────────────────── */
.tracker-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 110px;
  box-shadow: var(--shadow-xs);
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brown-900);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--brown-300);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.deadline-alerts {
  background: var(--red-50);
  border: 1px solid var(--red-200);
  border-radius: var(--r);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deadline-alert-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--red-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.deadline-alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--brown-700);
}

.deadline-alert-item .days-left {
  font-weight: 700;
  color: var(--red-500);
}

.tracker-controls {
  margin-bottom: 16px;
}

.grants-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grant-card {
  background: white;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  transition: box-shadow 0.16s;
}

.grant-card:hover { box-shadow: var(--shadow-sm); }

/* Top row: funder info on the left, action buttons on the right */
.grant-card-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
}

.grant-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.grant-funder {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.grant-program {
  font-size: 0.8rem;
  color: var(--brown-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.grant-submitter {
  font-size: 0.75rem;
  color: var(--brown-300);
  margin-top: 2px;
}

.grant-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.grant-amount {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brown-700);
}

.grant-deadline {
  font-size: 0.8rem;
  color: var(--brown-500);
  white-space: nowrap;
}

.grant-deadline.urgent {
  color: var(--red-500);
  font-weight: 600;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-full);
  white-space: nowrap;
}

.status-drafting  { background: var(--cream-200);  color: var(--brown-500);  }
.status-submitted { background: #e8f0fa;            color: #3d62a0;           }
.status-pending   { background: var(--amber-50);   color: var(--amber-500);  }
.status-awarded   { background: var(--sage-100);   color: var(--sage-600);   }
.status-declined  { background: var(--red-50);     color: var(--red-500);    }

.grant-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.14s;
}
.grant-card:hover .grant-card-actions { opacity: 1; }

/* ── Priority Badges ────────────────────────────────────────────────────── */
.priority-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-full);
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.priority-high   { background: var(--red-50);   color: var(--red-500);   border: 1px solid var(--red-200);    }
.priority-medium { background: var(--amber-50); color: var(--amber-500); border: 1px solid var(--amber-100);  }
.priority-low    { background: var(--sage-100); color: var(--sage-600);  border: 1px solid var(--sage-200);   }

/* ── Tracker Sort + Filter Controls ────────────────────────────────────── */
.tracker-sort-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.sort-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brown-600);
  white-space: nowrap;
}
.sort-select {
  width: auto;
  min-width: 170px;
  font-size: 0.8rem;
  padding: 5px 28px 5px 10px;
}
#grant-priority-filters {
  margin-top: 6px;
}
.chip-high.active   { background: var(--red-50);   color: var(--red-500);   border-color: var(--red-200);   }
.chip-medium.active { background: var(--amber-50); color: var(--amber-500); border-color: var(--amber-100); }
.chip-low.active    { background: var(--sage-100); color: var(--sage-600);  border-color: var(--sage-200);  }

/* ── Utility ────────────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

.cursor-pointer { cursor: pointer; }

.link {
  color: var(--terra-500);
  text-decoration: underline;
  cursor: pointer;
}

.link:hover { color: var(--terra-600); }

code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.85em;
  background: var(--cream-200);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brown-100); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--brown-300); }

/* ── Spinner ────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner-terra {
  border-color: var(--terra-100);
  border-top-color: var(--terra-500);
}

/* ════════════════════════════════════════════════════════════════════════════
   GRANT FILES — inline panel inside Grant Writing
════════════════════════════════════════════════════════════════════════════ */

.gf-panel {
  border: 1.5px solid var(--brown-150, #e8ddd4);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 28px;
}

.gf-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--brown-50);
  border-bottom: 1px solid var(--brown-100);
}

.gf-panel-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--brown-800);
}

.gf-panel-warn {
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
}

.gf-drop-mini {
  padding: 9px 16px;
  font-size: 0.8125rem;
  color: var(--brown-400);
  text-align: center;
  cursor: pointer;
  border-bottom: 1px dashed var(--brown-200);
  transition: background 0.12s, color 0.12s;
}
.gf-drop-mini:hover,
.gf-drop-mini.drag-over {
  background: var(--terra-50);
  color: var(--terra-600);
}

.gf-upload-queue-inline {
  padding: 0 16px;
}
.gf-upload-queue-inline .gf-queue-item {
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--brown-50);
  background: transparent;
  padding: 8px 0;
}

.gf-inline-list {
  padding: 4px 16px;
  max-height: 200px;
  overflow-y: auto;
}

.gf-inline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--brown-50);
}
.gf-inline-row:last-child { border-bottom: none; }

.gf-inline-info { flex: 1; min-width: 0; }

.gf-inline-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--brown-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gf-inline-meta {
  font-size: 0.75rem;
  color: var(--brown-400);
  margin-top: 1px;
}

.gf-inline-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.gf-inline-empty {
  font-size: 0.8125rem;
  color: var(--brown-400);
  padding: 10px 0;
  margin: 0;
  text-align: center;
}

.gf-file-icon.sm {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-size: 0.6rem;
  flex-shrink: 0;
}

/* ═══════════════════ Legacy standalone upload zone ═══════════════════════ */
/* Drop zone */
.gf-upload-zone {
  border: 2px dashed var(--terra-300);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 24px;
  background: var(--terra-50);
}
.gf-upload-zone:hover,
.gf-upload-zone.drag-over {
  border-color: var(--terra-500);
  background: #fdf3ec;
}
.gf-upload-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  display: block;
}
.gf-upload-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown-800);
  margin: 0 0 4px;
}
.gf-upload-sub {
  font-size: 0.875rem;
  color: var(--brown-500);
  margin: 0 0 6px;
}

/* Upload queue */
.gf-upload-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.gf-queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--brown-50);
  border: 1px solid var(--brown-100);
  border-radius: 10px;
  font-size: 0.875rem;
}
.gf-queue-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--brown-800);
  font-weight: 500;
}
.gf-queue-status {
  font-size: 0.8125rem;
  color: var(--brown-400);
  white-space: nowrap;
}
.gf-queue-status.uploading { color: var(--terra-600); }
.gf-queue-status.done      { color: var(--sage-600); }
.gf-queue-status.error     { color: var(--red-500); }

/* Files grid */
.gf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* File card */
.gf-card {
  background: white;
  border: 1.5px solid var(--brown-100);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.gf-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
  border-color: var(--terra-200);
}
.gf-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.gf-file-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.gf-file-icon.pdf  { background: #fde8e8; color: #c53030; }
.gf-file-icon.html { background: #e6f4ea; color: #276749; }
.gf-file-icon.word { background: #dbeafe; color: #1d4ed8; }
.gf-file-icon.other{ background: var(--brown-100); color: var(--brown-600); }

.gf-card-info {
  flex: 1;
  min-width: 0;
}
.gf-card-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--brown-900);
  word-break: break-word;
  line-height: 1.3;
  margin-bottom: 3px;
}
.gf-card-meta {
  font-size: 0.8125rem;
  color: var(--brown-400);
}

.gf-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.gf-btn {
  padding: 5px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 7px;
  border: 1.5px solid var(--brown-200);
  background: white;
  color: var(--brown-700);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  line-height: 1.4;
}
.gf-btn:hover {
  background: var(--brown-50);
  border-color: var(--brown-300);
}
.gf-btn.danger {
  color: var(--red-500);
  border-color: var(--red-200);
}
.gf-btn.danger:hover {
  background: var(--red-50);
  border-color: var(--red-300);
}

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

/* ── Welcome Modal ───────────────────────────────────────────────────────── */
.modal-welcome {
  max-width: 560px;
  width: 100%;
  padding: 0;
  overflow: hidden;
}

.modal-welcome-header {
  text-align: center;
  padding: 36px 36px 24px;
  background: var(--terra-50);
  border-bottom: 1px solid var(--cream-300);
}

.welcome-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: white;
  border-radius: 14px;
  border: 1.5px solid var(--terra-200);
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(196,112,63,0.12);
}

.welcome-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brown-900);
  margin: 0 0 8px;
}

.welcome-subtitle {
  font-size: 0.9rem;
  color: var(--brown-500);
  margin: 0;
  line-height: 1.5;
}

.welcome-steps {
  padding: 24px 36px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.welcome-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.welcome-step-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: var(--terra-50);
  border: 1.5px solid var(--terra-200);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--terra-500);
}

.welcome-step-icon svg {
  width: 18px;
  height: 18px;
}

.welcome-step-body h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown-900);
  margin: 0 0 4px;
}

.welcome-step-body p {
  font-size: 0.84rem;
  color: var(--brown-500);
  margin: 0;
  line-height: 1.55;
}

.btn-lg {
  padding: 11px 32px;
  font-size: 0.95rem;
}

/* ── Sidebar "How it works" button ───────────────────────────────────────── */
.btn-how-it-works {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--brown-300);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.btn-how-it-works:hover {
  color: var(--brown-500);
  background: var(--cream-100);
}

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.dash-quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.dash-section { margin-bottom: 24px; }
.dash-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brown-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.deadline-alerts.dash-deadlines { margin-bottom: 0; }

.dash-lower-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 720px) {
  .dash-lower-grid { grid-template-columns: 1fr; }
}

.dash-panel {
  background: white;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.dash-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--cream-200);
}
.dash-panel-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brown-900);
}
.dash-panel-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--terra-500);
  text-decoration: none;
}
.dash-panel-link:hover { color: var(--terra-600); text-decoration: underline; }

.dash-empty-panel {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.dash-empty-panel p { font-size: 0.85rem; color: var(--brown-500); line-height: 1.5; }

.dash-grant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--cream-200);
}
.dash-grant-row:last-child { border-bottom: none; }
.dash-grant-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.dash-grant-funder {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brown-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-grant-deadline { font-size: 0.75rem; color: var(--brown-500); }
.dash-grant-deadline.urgent { color: var(--red-500); font-weight: 600; }
.dash-grant-row-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.dash-kb-summary {
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--cream-200);
}
.dash-kb-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brown-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-kb-list {
  list-style: none;
  padding: 6px 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dash-kb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--brown-700);
}
.dash-kb-item.missing { color: var(--brown-300); }
.dash-kb-check {
  font-size: 0.85rem;
  font-weight: 700;
  width: 16px;
  flex-shrink: 0;
  color: var(--sage-500);
}
.dash-kb-item.missing .dash-kb-check { color: var(--brown-200); }
.dash-kb-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--cream-200);
  font-size: 0.8rem;
  color: var(--brown-500);
  gap: 10px;
}
.dash-kb-prompt.dash-kb-complete {
  color: var(--sage-600);
  font-weight: 500;
  justify-content: center;
}

/* ── Sidebar user / logout ──────────────────────────────────────────────── */
/* Admin org-switcher */
.sidebar-org-switcher {
  padding: 8px 16px 6px;
  border-top: 1px solid var(--cream-200);
  margin-top: 4px;
}
.org-switcher-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brown-400);
  margin-bottom: 4px;
}
.org-switcher-select {
  width: 100%;
  padding: 5px 8px;
  font-size: 0.78rem;
  border: 1px solid var(--cream-300);
  border-radius: var(--r-sm);
  background: white;
  color: var(--brown-800);
  cursor: pointer;
}
.org-switcher-select:focus {
  outline: none;
  border-color: var(--terra-300);
  box-shadow: 0 0 0 2px rgba(196,112,63,0.12);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 8px;
  border-top: 1px solid var(--cream-200);
  margin-top: 8px;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-org {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brown-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 0.7rem;
  color: var(--brown-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-logout {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  background: transparent;
  color: var(--brown-400);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-logout:hover {
  color: var(--red-500);
  background: var(--red-50);
  border-color: var(--red-200);
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-body {
  background: var(--cream-50);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}
.login-page {
  width: 100%;
  max-width: 480px;
}
.login-card {
  background: white;
  border: 1px solid var(--cream-300);
  border-radius: calc(var(--r) * 2);
  box-shadow: var(--shadow-md);
  padding: 32px 36px 28px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.login-logo-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brown-900);
  letter-spacing: -0.02em;
}
.login-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--cream-200);
  margin-bottom: 20px;
}
.login-tab {
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brown-400);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.login-tab:hover { color: var(--brown-700); }
.login-tab.active {
  color: var(--terra-500);
  border-bottom-color: var(--terra-500);
}
.login-subtitle {
  font-size: 0.85rem;
  color: var(--brown-500);
  margin-bottom: 20px;
  line-height: 1.5;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brown-700);
}
.login-field input {
  padding: 10px 12px;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--brown-900);
  background: var(--cream-50);
  transition: border-color 0.15s;
  outline: none;
}
.login-field input:focus { border-color: var(--terra-400); background: white; }
.login-submit { width: 100%; justify-content: center; margin-top: 4px; }
.login-error {
  font-size: 0.82rem;
  color: var(--red-500);
  background: var(--red-50);
  border: 1px solid var(--red-200);
  border-radius: var(--r);
  padding: 8px 12px;
}
.login-success {
  font-size: 0.82rem;
  color: var(--sage-600);
  background: var(--sage-50, #f0f4ea);
  border: 1px solid var(--sage-200);
  border-radius: var(--r);
  padding: 8px 12px;
}
.login-footer-link {
  margin-top: 12px;
  text-align: center;
}
.login-text-btn {
  background: none;
  border: none;
  color: var(--terra-500);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.login-text-btn:hover { text-decoration: underline; }

/* ── Admin page ─────────────────────────────────────────────────────────── */
.admin-body {
  background: var(--cream-50);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
}
.admin-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: white;
  border-bottom: 1px solid var(--cream-200);
  box-shadow: var(--shadow-xs);
}
.admin-logo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.admin-logo-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brown-900);
}
.admin-topbar-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brown-500);
  padding-left: 12px;
  border-left: 1px solid var(--cream-300);
}
.admin-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-user-email { font-size: 0.8rem; color: var(--brown-500); }

.admin-main { padding: 24px; max-width: 1100px; margin: 0 auto; }
.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--cream-200);
  margin-bottom: 24px;
}
.admin-tab {
  padding: 8px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brown-400);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.admin-tab:hover { color: var(--brown-700); }
.admin-tab.active { color: var(--terra-500); border-bottom-color: var(--terra-500); }

.admin-section { display: none; }
.admin-section.active { display: block; }

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.admin-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brown-900);
}

.admin-table-wrap {
  background: white;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brown-500);
  border-bottom: 1px solid var(--cream-200);
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 14px;
  color: var(--brown-800);
  border-bottom: 1px solid var(--cream-100);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--cream-50); }

.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.admin-badge-active   { background: var(--sage-100);   color: var(--sage-600);   }
.admin-badge-inactive { background: var(--cream-200);  color: var(--brown-400);  }
.admin-badge-admin    { background: var(--terra-100, #fde8df); color: var(--terra-600); }
.admin-badge-member   { background: var(--cream-200);  color: var(--brown-500);  }

.admin-stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.admin-stat-card {
  background: white;
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  padding: 16px 18px;
}
.admin-stat-org   { font-size: 0.875rem; font-weight: 700; color: var(--brown-900); margin-bottom: 10px; }
.admin-stat-row   { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--brown-500); margin-bottom: 4px; }
.admin-stat-val   { font-weight: 600; color: var(--brown-800); }
.admin-stat-last  { font-size: 0.72rem; color: var(--brown-300); margin-top: 6px; }

.admin-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--brown-400);
  font-size: 0.875rem;
}

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 0; }
.activity-event {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--cream-200);
}
.activity-event:last-child { border-bottom: none; }
.activity-icon {
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream-100);
  border-radius: 8px;
  flex-shrink: 0;
}
.activity-body { flex: 1; min-width: 0; }
.activity-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--brown-700);
}
.activity-detail {
  font-size: 0.82rem;
  color: var(--brown-500);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-meta {
  font-size: 0.72rem;
  color: var(--brown-300);
  margin-top: 2px;
}
.activity-time {
  font-size: 0.72rem;
  color: var(--brown-300);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}
.activity-date-divider {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brown-300);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 0 6px;
  border-bottom: 1px solid var(--cream-200);
  margin-bottom: 2px;
}

/* Admin modal */
.admin-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.admin-modal-overlay.open { display: flex; }
.admin-modal {
  background: white;
  border-radius: calc(var(--r) * 2);
  box-shadow: var(--shadow-xl, 0 20px 60px rgba(0,0,0,.15));
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 440px;
}
.admin-modal-title { font-size: 1rem; font-weight: 700; color: var(--brown-900); margin-bottom: 18px; }
.admin-modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.admin-error { font-size: 0.82rem; color: var(--red-500); margin-top: 8px; min-height: 18px; }

.admin-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--brown-500);
  text-decoration: none;
  padding: 5px 10px;
  border: 1px solid var(--cream-300);
  border-radius: var(--r-sm);
  background: white;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}
.admin-back-link:hover {
  color: var(--terra-600);
  border-color: var(--terra-300);
  background: var(--cream-50);
}

/* Compact inline select used in admin tables */
.input-sm {
  padding: 4px 8px;
  font-size: 0.78rem;
  width: auto;
  border: 1px solid var(--cream-300);
  border-radius: var(--r-sm);
  background: white;
  color: var(--brown-800);
  cursor: pointer;
}

/* ── Feedback Button & Modal ─────────────────────────────────────────────── */
.feedback-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px 9px 12px;
  background: var(--terra-500);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(196,112,63,0.35);
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
  letter-spacing: 0.01em;
}
.feedback-fab:hover {
  background: #a85a2e;
  box-shadow: 0 4px 16px rgba(196,112,63,0.45);
  transform: translateY(-1px);
}
.feedback-fab svg { flex-shrink: 0; }

.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,15,5,0.4);
  z-index: 1100;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}
.feedback-overlay.hidden { display: none; }

.feedback-modal {
  background: white;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
  width: 380px;
  max-width: calc(100vw - 48px);
  padding: 22px 22px 18px;
  animation: slideUp 0.18s ease;
}
.feedback-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.feedback-modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brown-900);
}
.feedback-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--brown-300);
  padding: 2px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.12s;
}
.feedback-modal-close:hover { color: var(--brown-700); }

.feedback-category-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.feedback-cat-btn {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--cream-300);
  background: white;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--brown-500);
  cursor: pointer;
  transition: all 0.12s;
}
.feedback-cat-btn:hover,
.feedback-cat-btn.active {
  border-color: var(--terra-400);
  background: #fdf3ec;
  color: #a85a2e;
}

.feedback-textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  border: 1.5px solid var(--cream-300);
  border-radius: 8px;
  font-size: 0.87rem;
  font-family: inherit;
  color: var(--brown-900);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  background: #fdfaf7;
}
.feedback-textarea:focus { border-color: var(--terra-400); background: white; }

.feedback-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 10px;
}
.feedback-status {
  font-size: 0.8rem;
  color: var(--brown-400);
  flex: 1;
  min-width: 0;
}
.feedback-status.success { color: #2e7d32; }
.feedback-status.error   { color: var(--red-500, #c0392b); }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Log Detail Modal sections ───────────────────────────────────────────── */
.log-modal-section {
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #ece8e3;
  border-radius: 8px;
}
.log-modal-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #5c4a3a;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ════════════════════════════════════════════════════════════════════════════
   My Feedback page + thread modal
════════════════════════════════════════════════════════════════════════════ */

/* ── Ticket list cards ───────────────────────────────────────────────────── */
.fb-ticket-card {
  background: var(--white);
  border: 1px solid var(--cream-300);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.fb-ticket-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--terra-300);
}
.fb-ticket-unread {
  border-left: 3px solid var(--terra-500);
  background: var(--terra-50);
}
.fb-ticket-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.fb-ticket-cat {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brown-500);
  text-transform: capitalize;
}
.fb-ticket-message {
  font-size: 0.875rem;
  color: var(--brown-700);
  margin: 0 0 8px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.fb-ticket-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.fb-reply-count {
  font-size: 0.75rem;
  color: var(--brown-300);
}
.fb-unread-dot {
  color: var(--terra-500);
  font-size: 0.7rem;
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.fb-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.fb-status-open {
  background: var(--sage-100);
  color: var(--sage-600);
}
.fb-status-inprogress {
  background: var(--amber-100);
  color: var(--amber-500);
}
.fb-status-resolved {
  background: var(--cream-200);
  color: var(--brown-300);
}

/* ── Thread modal ────────────────────────────────────────────────────────── */
.modal-feedback-thread {
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fbt-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 420px;
  background: var(--cream);
}
.fbt-bubble-wrap {
  display: flex;
}
.fbt-wrap-user  { justify-content: flex-start; }
.fbt-wrap-admin { justify-content: flex-end; }
.fbt-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
}
.fbt-bubble-user {
  background: var(--white);
  border: 1px solid var(--cream-300);
  border-bottom-left-radius: 4px;
}
.fbt-bubble-admin {
  background: var(--terra-500);
  color: var(--white);
  border-bottom-right-radius: 4px;
}
.fbt-bubble-meta {
  font-size: 0.7rem;
  margin-bottom: 4px;
  opacity: 0.65;
}
.fbt-bubble-text {
  white-space: pre-wrap;
}
.fbt-screenshot-thumb {
  margin-top: 8px;
  max-width: 100%;
  max-height: 160px;
  border-radius: 6px;
  cursor: pointer;
  display: block;
}

/* ── Reply bar ───────────────────────────────────────────────────────────── */
.fbt-reply-bar {
  border-top: 1px solid var(--cream-300);
  padding: 12px;
  background: var(--white);
  flex-shrink: 0;
}
.fbt-reply-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.fbt-reply-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--cream-300);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--brown-900);
  background: var(--cream);
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.4;
}
.fbt-reply-input:focus {
  border-color: var(--terra-400);
  background: var(--white);
}
.fbt-reply-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.fbt-attach-btn {
  cursor: pointer;
  color: var(--brown-300);
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
}
.fbt-attach-btn:hover {
  color: var(--terra-500);
  background: var(--terra-50);
}
.fbt-reply-error {
  font-size: 0.8rem;
  color: var(--red-500);
  margin-top: 6px;
}
.fbt-screenshot-preview {
  position: relative;
  display: inline-block;
  margin-bottom: 8px;
}
.fbt-screenshot-preview img {
  max-height: 80px;
  border-radius: 6px;
  border: 1px solid var(--cream-300);
}
.fbt-remove-screenshot {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brown-500);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ════════════════════════════════════════════════════════════════════════════
   Grant draft — AI chat sidebar
════════════════════════════════════════════════════════════════════════════ */

.gw-draft-body {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* Draft stream: stays max-width when sidebar is closed, shrinks when open */
.gw-draft-body .draft-stream {
  flex: 1;
  min-width: 0;
}

/* Sidebar */
.gw-chat-sidebar {
  width: 340px;
  flex-shrink: 0;
  background: var(--white);
  border: 1px solid var(--cream-300);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  max-height: 780px;
  min-height: 400px;
  position: sticky;
  top: 20px;
}

.gw-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--cream-200);
  flex-shrink: 0;
}
.gw-chat-title {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--brown-700);
  display: flex;
  align-items: center;
}
.gw-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--brown-300);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.gw-chat-close:hover {
  color: var(--brown-700);
  background: var(--cream-100);
}

.gw-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gw-chat-intro {
  font-size: 0.825rem;
  color: var(--brown-300);
  line-height: 1.5;
  text-align: center;
  padding: 20px 8px;
}

/* Message bubbles */
.gw-chat-bubble-wrap { display: flex; }
.gw-chat-bubble-wrap--user      { justify-content: flex-end; }
.gw-chat-bubble-wrap--assistant { justify-content: flex-start; }
.gw-chat-bubble {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.825rem;
  line-height: 1.55;
}
.gw-chat-bubble--user {
  background: var(--terra-500);
  color: var(--white);
  border-bottom-right-radius: 3px;
}
.gw-chat-bubble--assistant {
  background: var(--cream-100);
  color: var(--brown-900);
  border: 1px solid var(--cream-200);
  border-bottom-left-radius: 3px;
}
.gw-chat-typing {
  letter-spacing: 3px;
  opacity: 0.4;
  animation: gw-chat-pulse 1.2s ease-in-out infinite;
}
@keyframes gw-chat-pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 0.8; }
}

/* Code in chat bubbles */
.gw-chat-code {
  background: rgba(0,0,0,0.06);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 0.78rem;
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Menlo', 'Consolas', monospace;
}
.gw-chat-inline-code {
  background: rgba(0,0,0,0.07);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.85em;
}

/* Suggested text blocks */
.gw-suggested-block {
  margin: 8px 0 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--terra-200);
}
.gw-suggested-label {
  background: var(--terra-50);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--terra-600);
  padding: 4px 8px;
}
.gw-suggested-text {
  background: var(--white);
  font-size: 0.78rem;
  padding: 8px 10px;
  margin: 0;
  white-space: pre-wrap;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  line-height: 1.5;
}
.gw-suggested-text:hover { background: var(--cream); }

/* Input area */
.gw-chat-input-area {
  border-top: 1px solid var(--cream-200);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.gw-chat-input {
  width: 100%;
  resize: none;
  border: 1px solid var(--cream-300);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: 0.825rem;
  font-family: inherit;
  color: var(--brown-900);
  background: var(--cream);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
  line-height: 1.4;
}
.gw-chat-input:focus {
  border-color: var(--terra-400);
  background: var(--white);
}

/* ── Draft-view modal: side-by-side body + chat layout ────────────────────── */
.dv-body-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.dv-body-wrap .modal-body {
  min-width: 0;       /* allow shrinking when sidebar opens */
}

/* Chat sidebar variant for inside a modal (no sticky, no fixed height) */
.gw-chat-sidebar--modal {
  position: relative;
  top: auto;
  height: auto;
  min-height: 0;
  max-height: none;
  align-self: stretch;
  width: 320px;
  border-radius: 0;
  border-top: none;
  border-bottom: none;
  border-right: none;
  border-left: 1px solid var(--cream-200);
  box-shadow: none;
}

/* Expand the modal wider when the chat panel is open */
.modal-wide--chat-open {
  max-width: min(1080px, 95vw);
}

/* ── Draft truncation banner ──────────────────────────────────────────────── */
.draft-truncation-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 20px 0 8px;
  padding: 14px 16px;
  background: #fffbf0;
  border: 1.5px solid #e6b84a;
  border-radius: var(--r-md);
}
.draft-truncation-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}
.draft-truncation-body {
  flex: 1;
  min-width: 0;
}
.draft-truncation-body strong {
  display: block;
  font-size: 0.88rem;
  color: var(--brown-900);
  margin-bottom: 3px;
}
.draft-truncation-body p {
  font-size: 0.8rem;
  color: var(--brown-500);
  margin: 0;
}
.draft-truncation-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.btn-teal {
  background: #4a7c88;
  color: white;
  box-shadow: var(--shadow-xs);
}
.btn-teal:hover { background: #3a6470; color: white; }

/* ── Grant report requirements panel ─────────────────────────────────────── */
.grant-report-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--cream-100);
  font-size: 13px;
}
.grant-report-row:last-child { border-bottom: none; }
.grant-report-title {
  flex: 1;
  min-width: 0;
}
.grant-report-title.submitted {
  text-decoration: line-through;
  color: #aaa;
}
.grant-report-due {
  font-size: 11px;
  white-space: nowrap;
  color: #999;
}
.grant-report-due.overdue { color: var(--red-500); font-weight: 600; }
.grant-report-due.submitted-date { color: #2e7d32; }

/* ── My Funders page ──────────────────────────────────────────────────────── */
.funder-node {
  margin-bottom: 10px;
}
.funder-card {
  background: #fffdf9;
  border: 1px solid #e8d9c4;
  border-radius: 10px;
  padding: 14px 16px;
  transition: box-shadow 0.15s;
}
.funder-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.funder-card-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.funder-card-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.funder-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.funder-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.funder-expand-btn:hover { background: var(--cream-100); color: #555; }
.funder-name {
  font-size: 15px;
  font-weight: 600;
  color: #2d1f0e;
  line-height: 1.3;
}
.funder-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.funder-type-label {
  font-size: 11px;
  color: #888;
  background: var(--cream-100);
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
}
.funder-website-link {
  font-size: 11px;
  color: #4a7c88;
  text-decoration: none;
}
.funder-website-link:hover { text-decoration: underline; }
.funder-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
/* Status badges */
.funder-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 10px;
  white-space: nowrap;
}
.funder-badge--active      { background: #d4edda; color: #1a6130; }
.funder-badge--prospective { background: #fff3cd; color: #856404; }
.funder-badge--past        { background: #e9ecef; color: #555; }
/* Notes */
.funder-notes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eddcc8;
  font-size: 12px;
  color: #7a6050;
  white-space: pre-wrap;
  line-height: 1.5;
}
/* Contacts panel */
.funder-contacts-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eddcc8;
}
.funder-contacts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.funder-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: var(--cream-50, #fffaf4);
  border-radius: 6px;
  flex-wrap: wrap;
}
.funder-contact-info {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
