*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f8fafc; color: #0f172a; }
.min-h-screen { min-height: 100vh; padding: 2rem; }
.container { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }
.card { background: #fff; border-radius: 1rem; border: 1px solid #e2e8f0; padding: 1.5rem; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.header-card { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.header-left h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
.subtitle { color: #64748b; margin-top: .25rem; font-size: .9rem; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.last-updated { font-size: .85rem; color: #64748b; display: flex; align-items: center; gap: .375rem; }
/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .625rem 1.25rem; border-radius: .75rem; font-weight: 500; font-size: .875rem; border: none; cursor: pointer; transition: all .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-blue { background: #2563eb; color: #fff; }
.btn-blue:hover:not(:disabled) { background: #1d4ed8; }
.btn-green { background: #059669; color: #fff; }
.btn-green:hover:not(:disabled) { background: #047857; }
.btn-light { background: #f1f5f9; color: #475569; }
.btn-light:hover { background: #e2e8f0; }
.btn-icon { padding: .5rem; border-radius: .5rem; border: 1px solid #e2e8f0; background: #fff; color: #475569; cursor: pointer; }
.btn-icon:hover { background: #f8fafc; }
.btn-icon:disabled { opacity: .5; cursor: not-allowed; }
.btn-close { background: none; border: none; padding: .25rem; color: #94a3b8; cursor: pointer; border-radius: .5rem; }
.btn-close:hover { color: #475569; background: #f1f5f9; }

/* Tabs */
.tabs { display: flex; gap: .25rem; background: rgba(226,232,240,.5); padding: .375rem; border-radius: .75rem; width: fit-content; flex-wrap: wrap; }
.tab { display: flex; align-items: center; gap: .5rem; padding: .625rem 1rem; border-radius: .5rem; font-size: .875rem; font-weight: 600; border: none; cursor: pointer; background: transparent; color: #475569; transition: all .15s; }
.tab:hover { color: #0f172a; background: rgba(226,232,240,.5); }
.tab.active { background: #fff; color: #1d4ed8; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* Filters */
.filters-card { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filter-group { flex: 1; min-width: 160px; }
.filter-group label { display: block; font-size: .85rem; font-weight: 500; color: #334155; margin-bottom: .25rem; }
.filter-group select, .filter-group input, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: .5rem; padding: .5rem .75rem; font-size: .875rem; outline: none; transition: border .15s, box-shadow .15s; }
.filter-group select:focus, .filter-group input:focus, textarea:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.filter-btn-group { display: flex; align-items: flex-end; min-width: auto; flex: 0; }
textarea { font-family: inherit; resize: vertical; min-height: 180px; border: 1px solid #cbd5e1; border-radius: .75rem; padding: 1rem; }
/* Table */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; text-align: left; }
thead tr { background: rgba(248,250,252,.8); border-bottom: 1px solid #e2e8f0; }
th { padding: 1rem; font-weight: 600; color: #475569; font-size: .85rem; }
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
tbody tr:hover { background: rgba(248,250,252,.5); }
tbody tr.is-new { background: rgba(219,234,254,.4); }
td { padding: 1.25rem; vertical-align: top; }
.empty-state { text-align: center; padding: 3rem !important; }
.empty-icon { font-size: 3rem; color: #cbd5e1; margin-bottom: .75rem; }
.empty-title { font-size: 1.1rem; font-weight: 500; color: #64748b; }
.empty-sub { font-size: .85rem; color: #94a3b8; margin-top: .25rem; }

/* Grant row elements */
.grant-detail { display: flex; align-items: flex-start; gap: .75rem; }
.grant-icon { margin-top: .25rem; flex-shrink: 0; padding: .5rem; border-radius: .5rem; background: #f1f5f9; color: #64748b; }
.grant-icon.new { background: #dbeafe; color: #2563eb; }
.grant-name { font-weight: 600; font-size: 1rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.grant-desc { font-size: .875rem; color: #475569; margin-top: .375rem; line-height: 1.6; }
.grant-insight { font-size: .75rem; color: #64748b; margin-top: .5rem; font-style: italic; border-left: 2px solid #e2e8f0; padding-left: .5rem; }
.badge { padding: .125rem .5rem; border-radius: 9999px; font-size: .625rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.badge-new { background: #2563eb; color: #fff; }
.badge-fit-high { background: #d1fae5; color: #047857; }
.badge-fit-mid { background: #fef3c7; color: #92400e; }
.badge-fit-low { background: #fee2e2; color: #b91c1c; }
.provider-tag { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 500; color: #334155; background: rgba(241,245,249,.5); padding: .375rem .75rem; border-radius: .5rem; }
.amount-tag { display: inline-flex; align-items: center; font-size: .85rem; font-weight: 700; color: #047857; background: #ecfdf5; padding: .375rem .75rem; border-radius: .5rem; border: 1px solid #a7f3d0; }
.deadline-tag { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 500; color: #92400e; background: #fffbeb; padding: .375rem .75rem; border-radius: .5rem; border: 1px solid #fde68a; }
.grant-link { display: inline-flex; align-items: center; gap: .375rem; font-size: .85rem; color: #2563eb; font-weight: 500; text-decoration: none; }
.grant-link:hover { color: #1e40af; text-decoration: underline; }
.action-btns { display: flex; flex-direction: column; gap: .5rem; padding-top: .5rem; }
.action-btn { display: inline-flex; align-items: center; gap: .375rem; font-size: .75rem; font-weight: 500; padding: .375rem .625rem; border-radius: .375rem; border: 1px solid #e2e8f0; background: #f1f5f9; color: #475569; cursor: pointer; transition: all .1s; }
.action-btn:hover { background: #e2e8f0; }
.action-btn.active-pipeline { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.action-btn.active-rated { background: #fffbeb; color: #92400e; border-color: #fde68a; }
/* Pagination */
.pagination-card { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; }
.pagination-card span { font-size: .85rem; color: #64748b; }
.pagination-card span strong { font-weight: 500; }
.pagination-controls { display: flex; align-items: center; gap: .5rem; }
#pageInfo { font-size: .85rem; font-weight: 500; color: #334155; padding: 0 .5rem; }

/* Sources grid */
.sources-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; }
.source-card { background: #fff; border-radius: 1rem; padding: 1.5rem; border: 1px solid #e2e8f0; display: flex; flex-direction: column; transition: box-shadow .15s; }
.source-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.source-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.source-icon { padding: .75rem; background: #eff6ff; color: #2563eb; border-radius: .75rem; font-size: 1.5rem; }
.source-authority { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #64748b; background: #f1f5f9; padding: .25rem .625rem; border-radius: 9999px; }
.source-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; }
.source-card p { font-size: .875rem; color: #475569; line-height: 1.6; flex-grow: 1; margin-bottom: 1.5rem; }
.source-link { display: flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; padding: .625rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .75rem; color: #334155; font-weight: 500; text-decoration: none; transition: background .1s; }
.source-link:hover { background: #f1f5f9; }
.add-source-form { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.error-text { margin-top: .75rem; font-size: .85rem; color: #dc2626; display: flex; align-items: center; gap: .375rem; }
.error-banner { background: #fef2f2; color: #b91c1c; padding: 1rem; border-radius: .75rem; border: 1px solid #fecaca; display: flex; align-items: flex-start; gap: .75rem; font-size: .9rem; }

/* Settings */
.settings-title { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.settings-title i { color: #2563eb; }
.settings-desc { font-size: .875rem; color: #475569; margin-bottom: 1.5rem; }
.settings-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #f1f5f9; }
.saved-msg { font-size: .875rem; color: #059669; font-weight: 500; display: flex; align-items: center; gap: .375rem; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(15,23,42,.5); backdrop-filter: blur(4px); }
.modal { background: #fff; border-radius: 1rem; box-shadow: 0 20px 60px rgba(0,0,0,.15); width: 100%; max-width: 28rem; overflow: hidden; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid #f1f5f9; }
.modal-header h3 { font-weight: 700; }
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; background: #f8fafc; border-top: 1px solid #f1f5f9; display: flex; justify-content: flex-end; gap: .75rem; }
.label { font-size: .85rem; font-weight: 500; color: #334155; margin-bottom: .5rem; }
.modal-grant-name { font-size: .875rem; color: #475569; background: #f8fafc; padding: .625rem; border-radius: .5rem; border: 1px solid #f1f5f9; }
.star-rating { display: flex; gap: .5rem; }
.star-btn { background: none; border: none; cursor: pointer; font-size: 2rem; color: #cbd5e1; transition: all .1s; padding: .25rem; }
.star-btn:hover { color: #fbbf24; }
.star-btn.active { color: #f59e0b; transform: scale(1.1); }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinning svg { animation: spin 1s linear infinite; }

/* Responsive */
@media (max-width: 768px) {
  .min-h-screen { padding: 1rem; }
  .header-card { flex-direction: column; align-items: flex-start; }
  .filters-card { flex-direction: column; }
  .filter-btn-group { width: 100%; }
  .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; font-size: .8rem; }
}

/* Sign-in overlay */
.signin-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  z-index: 100;
}
.signin-card {
  background: #fff;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  padding: 3rem 2.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
  text-align: center;
  max-width: 400px;
  width: 100%;
}
.signin-icon {
  font-size: 2.5rem;
  color: #2563eb;
  margin-bottom: 1rem;
}
.signin-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .5rem;
}
.signin-subtitle {
  color: #64748b;
  font-size: .9rem;
  margin-bottom: 1.5rem;
}
.signin-btn {
  width: 100%;
  justify-content: center;
  padding: .75rem 1.25rem;
  font-size: 1rem;
  text-decoration: none;
}
.signin-error {
  background: #fef2f2;
  color: #b91c1c;
  padding: .75rem 1rem;
  border-radius: .5rem;
  border: 1px solid #fecaca;
  font-size: .875rem;
  margin-bottom: 1rem;
}

/* User info in header */
.user-info {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.user-email {
  font-size: .85rem;
  color: #475569;
  font-weight: 500;
}
.btn-signout {
  font-size: .8rem;
  padding: .375rem .75rem;
}
