/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #F8FAFC;
  color: #1E293B;
  line-height: 1.5;
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ─── Header ──────────────────────────────────────────────── */
.header {
  background: #fff;
  border-bottom: 1px solid #E2E8F0;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.125rem;
  color: #1E293B;
}
.header-logo { color: #2563EB; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.last-sync {
  font-size: 0.75rem;
  color: #64748B;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all .15s ease;
  background: transparent;
  color: #475569;
}
.btn:hover { background: #F1F5F9; }
.btn-primary {
  background: #2563EB;
  color: #fff;
  border-color: #2563EB;
}
.btn-primary:hover { background: #1D4ED8; }
.btn-secondary {
  background: #fff;
  color: #2563EB;
  border-color: #2563EB;
}
.btn-secondary:hover { background: #EFF6FF; }
.btn-danger {
  background: #DC2626;
  color: #fff;
  border-color: #DC2626;
}
.btn-danger:hover { background: #B91C1C; }
.btn-ghost { color: #64748B; }
.btn-ghost:hover { background: #F1F5F9; color: #334155; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #94A3B8;
  padding: 4px;
}
.btn-close:hover { color: #475569; }

/* ─── Main ──────────────────────────────────────────────────── */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

/* ─── Dashboard ───────────────────────────────────────────── */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #1E293B;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label {
  font-size: 0.8125rem;
  color: #64748B;
  font-weight: 500;
}
.stat-signed .stat-value { color: #059669; }
.stat-pending .stat-value { color: #D97706; }

/* ─── Search Section ──────────────────────────────────────── */
.search-section {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}
.search-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #E2E8F0;
  margin-bottom: 16px;
  padding-bottom: 2px;
}
.tab-btn {
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748B;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  transition: all .15s;
}
.tab-btn:hover { color: #334155; }
.tab-btn.active {
  color: #2563EB;
  border-bottom-color: #2563EB;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 10px 14px;
}
.search-icon { color: #94A3B8; flex-shrink: 0; }
.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  color: #1E293B;
  outline: none;
}
.search-input::placeholder { color: #94A3B8; }

.batch-box { display: flex; flex-direction: column; gap: 12px; }
.batch-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  font-size: 0.9375rem;
  resize: vertical;
  min-height: 120px;
  background: #F8FAFC;
}
.batch-input:focus { outline: 2px solid #BFDBFE; border-color: #2563EB; }

/* ─── Results ─────────────────────────────────────────────── */
.results-section {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 20px;
}
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.results-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}
.results-actions { display: flex; gap: 8px; }
.results-table-wrapper { overflow-x: auto; }
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.results-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: #64748B;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid #E2E8F0;
}
.results-table td {
  padding: 12px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}
.results-table tr:last-child td { border-bottom: none; }
.empty-row td { padding: 40px 12px; text-align: center; }
.empty-state { color: #94A3B8; }
.empty-state .sub { font-size: 0.8125rem; margin-top: 4px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-signed {
  background: #D1FAE5;
  color: #065F46;
}
.badge-pending {
  background: #FEF3C7;
  color: #92400E;
}
.badge-unknown {
  background: #F1F5F9;
  color: #475569;
}

.cell-actions { display: flex; gap: 8px; }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #E2E8F0;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #E2E8F0;
}
.modal-text { font-size: 0.9375rem; color: #334155; margin-bottom: 12px; }
.url-box {
  display: flex;
  gap: 8px;
  align-items: center;
}
.url-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 0.875rem;
  background: #F8FAFC;
  color: #1E293B;
  width: 100%;
}
.error-text { color: #DC2626; font-size: 0.875rem; }
.hidden { display: none !important; }

/* ─── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}
.toast {
  background: #1E293B;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,.1);
  animation: toastIn .3s ease;
  max-width: 320px;
}
.toast.toast-error { background: #DC2626; }
.toast.toast-success { background: #059669; }
@keyframes toastIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Spinner ─────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #E2E8F0;
  border-top-color: #2563EB;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .dashboard { grid-template-columns: 1fr; }
  .search-box { flex-wrap: wrap; }
  .search-input { min-width: 0; width: 100%; order: 2; }
  .search-box .btn { order: 3; width: 100%; }
  .main { padding: 16px; }
}
