* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
}

header {
  background: #1a365d;
  color: white;
  padding: 1.5rem 2rem;
}

header h1 { font-size: 1.5rem; font-weight: 600; }
header .subtitle { font-size: 0.85rem; opacity: 0.8; margin-top: 0.25rem; }

main { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.section-header h2 { font-size: 1.25rem; flex: 1; }
.section-header .actions { display: flex; gap: 0.5rem; }

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-back { background: transparent; color: #2563eb; padding: 0.5rem 0; }
.btn-back:hover { text-decoration: underline; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-full { width: 100%; }

/* Project cards */
.project-card {
  background: white;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.project-card .name { flex: 1; font-weight: 500; }
.project-card .meta { color: #64748b; font-size: 0.8rem; }
.project-card .count {
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #94a3b8;
}

/* Table */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-size: 0.8rem;
}

th {
  background: #f8fafc;
  padding: 0.6rem 0.5rem;
  text-align: left;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

td {
  padding: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  max-width: 250px;
  word-break: break-word;
}

td.title-col { max-width: 350px; }

tr:hover { background: #f8fafc; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-found { background: #d1fae5; color: #065f46; }
.badge-not-found { background: #fee2e2; color: #991b1b; }
.badge-error { background: #fecaca; color: #7f1d1d; }
.badge-free { background: #d1fae5; color: #065f46; }
.badge-paid { background: #fee2e2; color: #991b1b; }
.badge-unknown { background: #e2e8f0; color: #475569; }

/* Progress bar */
.cost-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}
.cost-label { font-weight: 600; color: #92400e; }
.cost-amount { font-size: 1.5rem; font-weight: 700; color: #b45309; }
.cost-detail { font-size: 0.85rem; color: #92400e; }

#progress-bar { margin-bottom: 1rem; }
.progress-container {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 4px;
  transition: width 0.3s;
  width: 0%;
}

#progress-text { font-size: 0.8rem; color: #64748b; }

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #94a3b8;
}

/* Form */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.25rem; font-size: 0.875rem; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-note {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.8rem;
  margin-bottom: 1rem;
  color: #0c4a6e;
}

/* File drop */
.file-drop {
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s;
}

.file-drop:hover, .file-drop.dragover { border-color: #2563eb; background: #f0f9ff; }

.file-drop input[type="file"] {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0;
  cursor: pointer;
}

.file-drop p { color: #94a3b8; font-size: 0.875rem; }
#file-name { color: #2563eb; font-weight: 500; display: block; margin-top: 0.5rem; }

/* Link */
a.db-link {
  color: #2563eb;
  text-decoration: none;
  font-size: 0.75rem;
  word-break: break-all;
}

a.db-link:hover { text-decoration: underline; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #e2e8f0;
  border-top: 2px solid #2563eb;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
  main { padding: 1rem; }
  table { font-size: 0.7rem; }
  th, td { padding: 0.4rem 0.3rem; }
}
