:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --primary: #064e3b;
  --accent: #059669;
  --accent-hov: #047857;
  --accent-light: #d1fae5;
  --trusted: #059669;
  --trusted-light: #d1fae5;
  --avoid: #dc2626;
  --avoid-light: #fee2e2;
  --unknown: #9ca3af;
  --unknown-light: #f3f4f6;
  --border: #e5e7eb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh; margin: 0; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; letter-spacing: inherit; }
button { border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { display: block; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

/* Layout */
.app {
  width: min(100%, 480px); margin: 0 auto;
  padding: 0 clamp(12px, 3.5vw, 20px);
}
.screen { display: none; padding-top: 12px; padding-bottom: 24px; }
.screen.active { display: block; }
.screen > .screen-title {
  margin: 0 0 16px; font-size: 22px; font-weight: 800; letter-spacing: -.03em;
  color: var(--primary);
}
.stack { display: grid; gap: 10px; margin-top: 10px; }

/* Status message */
.status {
  margin: 0 0 8px; padding: 10px 14px; border-radius: 8px;
  background: var(--surface); color: var(--text-muted);
  font-size: 13px; line-height: 18px; border: 1px solid var(--border);
}

/* Top tabs */
.top-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; background: var(--bg);
}
.top-tabs button {
  flex: 1; padding: 14px 0 12px; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  background: transparent; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.top-tabs button:hover { color: var(--text); }
.top-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

/* Search wraps */
.jobs-search-wrap, .buyer-search-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s;
}
.jobs-search-wrap:focus-within, .buyer-search-wrap:focus-within {
  border-color: var(--accent);
}
.jobs-search-icon, .buyer-search-icon {
  flex: 0 0 auto; width: 18px; height: 18px; color: var(--text-light);
  stroke-width: 2;
}
#jobsSearch, #buyerSearch {
  flex: 1; min-width: 0; height: 44px; border: 0; outline: 0;
  background: transparent; color: var(--text);
  font-size: 14px; font-weight: 600;
}
#jobsSearch::placeholder, #buyerSearch::placeholder { color: var(--text-light); font-weight: 500; }

/* Stats grid */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0;
}
.stats article {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); transition: background .15s;
}
.stats article:active { background: var(--bg); }
.stats article .stat-icon {
  flex: 0 0 auto; width: 38px; height: 38px; display: grid;
  place-items: center; border-radius: 10px;
}
.stats article .stat-icon svg { width: 20px; height: 20px; stroke-width: 1.5; }
.stats article .stat-body { flex: 1; min-width: 0; }
.stats article .stat-body strong { display: block; font-size: 24px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
.stats article .stat-body span { display: block; font-size: 11px; line-height: 1.3; color: var(--text-muted); font-weight: 600; margin-top: 1px; }
.stat-icon-buyers { background: #eef2ff; color: #4f46e5; }
.stat-icon-trusted { background: var(--trusted-light); color: var(--trusted); }
.stat-icon-avoid { background: var(--avoid-light); color: var(--avoid); }

/* Filter pills */
.filters, .status-filters {
  display: flex; gap: 6px; margin: 12px 0; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filters::-webkit-scrollbar, .status-filters::-webkit-scrollbar { display: none; }
.filters button, .status-filters button {
  flex: 0 0 auto; padding: 7px 16px; border-radius: 8px;
  background: var(--surface); color: var(--text-muted);
  font-size: 12px; font-weight: 600; transition: all .15s;
  border: 1px solid var(--border);
}
.filters button:hover, .status-filters button:hover { border-color: var(--accent); color: var(--accent); }
.filters button.active, .status-filters button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Buyer card */
.buyer-card {
  display: grid; gap: 0;
  border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--unknown);
  transition: border-color .15s;
}
.buyer-card.flag-trusted { border-left-color: var(--trusted); }
.buyer-card.flag-avoid { border-left-color: var(--avoid); }
.buyer-card.flag-unknown { border-left-color: var(--unknown); }
.buyer-card .buyer-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 14px 0;
}
.buyer-card .buyer-avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--trusted-light); color: var(--trusted);
  font-size: 13px; font-weight: 800;
}
.buyer-card .buyer-info { flex: 1; min-width: 0; }
.buyer-card .buyer-info .name {
  display: block; font-size: 13px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.buyer-card .buyer-info .meta-text {
  display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.buyer-card .buyer-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.icon-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 5px 8px; border-radius: 8px; transition: all .15s;
  color: var(--text-muted); background: transparent; font-size: 10px; font-weight: 700;
}
.icon-btn:hover { background: var(--accent-light); color: var(--accent); }
.icon-btn.danger { color: var(--text-muted); }
.icon-btn.danger:hover { background: var(--avoid-light); color: var(--avoid); }
.icon-btn svg { width: 14px; height: 14px; stroke-width: 1.5; }
.buyer-card .buyer-note { padding: 8px 14px 14px; }
.buyer-card .note {
  width: 100%; min-height: 48px; padding: 8px 10px; resize: vertical;
  border: 1px solid var(--border); border-radius: 8px; outline: 0;
  background: var(--bg); color: var(--text); font-size: 11px; line-height: 1.5;
  transition: border-color .15s;
}
.buyer-card .note:focus { border-color: var(--accent); }

/* Submitted job card (buyer detail rows) */
.submitted-card {
  padding: 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border);
}
.submitted-card .job-head {
  display: flex; align-items: center; gap: 10px;
}
.submitted-card .job-head .status-dot {
  flex: 0 0 auto; width: 10px; height: 10px; border-radius: 999px;
}
.submitted-card .job-head .status-dot.satisfied { background: var(--trusted); }
.submitted-card .job-head .status-dot.unsatisfied { background: var(--avoid); }
.submitted-card .job-head .status-dot.submitted,
.submitted-card .job-head .status-dot.pending { background: var(--unknown); }
.submitted-card .job-head .job-id { font-size: 13px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.submitted-card .job-head .job-time { font-size: 12px; color: var(--text-light); flex: 0 0 auto; }

/* Job card (jobs view) */
.job-card {
  padding: 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border);
}
.job-card .job-card-head {
  display: flex; align-items: center; gap: 10px;
}
.job-card .job-card-head .status-dot {
  flex: 0 0 auto; width: 10px; height: 10px; border-radius: 999px;
}
.job-card .job-card-head .status-dot.satisfied { background: var(--trusted); }
.job-card .job-card-head .status-dot.unsatisfied { background: var(--avoid); }
.job-card .job-card-head .status-dot.submitted,
.job-card .job-card-head .status-dot.pending { background: var(--unknown); }
.job-card-id {
  flex: 1; min-width: 0; font-size: 14px; font-weight: 800; letter-spacing: .3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.job-card-status {
  font-size: 10px; font-weight: 800; text-transform: uppercase; flex: 0 0 auto;
}
.job-card-status.satisfied { color: var(--trusted); }
.job-card-status.unsatisfied { color: var(--avoid); }
.job-card-status.submitted,
.job-card-status.pending { color: var(--unknown); }
.job-card-buyer {
  margin-top: 8px; display: flex; align-items: center;
}
.job-card-link {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
}
.job-card-avatar {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--trusted-light); color: var(--trusted);
  font-size: 10px; font-weight: 800;
}
.job-card-name {
  font-size: 12px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.job-card-stats {
  margin-top: 8px; font-size: 11px; color: var(--text-muted); font-weight: 600;
}
.job-card-time {
  margin-top: 6px; display: flex; align-items: center; gap: 8px;
}
.job-card-time .job-time-display {
  font-size: 12px; color: var(--text-muted);
}
.job-card-time .time-input {
  padding: 4px 8px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--bg); color: var(--text); font-size: 12px;
  outline: 0; max-width: 200px;
}
.time-edit-btn {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 6px;
  color: var(--text-light); background: transparent;
  transition: all .15s;
}
.time-edit-btn:hover { background: var(--accent-light); color: var(--accent); }
.time-edit-btn svg { width: 14px; height: 14px; stroke-width: 1.5; }

/* Buyer filter tag */
.buyer-filter-tag {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px;
  background: var(--accent-light); color: var(--accent);
  font-size: 12px; font-weight: 700; margin-top: 10px;
}
.buyer-filter-tag #clearBuyerFilter {
  margin-left: auto; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 6px;
  color: var(--accent); background: transparent; transition: background .15s;
}
.buyer-filter-tag #clearBuyerFilter:hover { background: rgba(5,150,105,.15); }
.buyer-filter-tag #clearBuyerFilter svg { width: 14px; height: 14px; stroke-width: 2; }

.jobs-link { color: var(--accent); text-decoration: none; font-weight: 700; }
.jobs-link:hover { text-decoration: underline; }

/* Load more */
.load-more-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 12px; border-radius: 10px;
  background: var(--surface); color: var(--accent);
  font-size: 13px; font-weight: 700; transition: all .15s;
  border: 1px solid var(--border); margin-top: 4px;
}
.load-more-btn:hover { background: var(--accent-light); border-color: var(--accent); }
.load-more-btn svg { width: 14px; height: 14px; stroke-width: 2; }

/* Copy interaction */
[data-copy-text] { cursor: pointer; }
[data-copy-text]:active { opacity: .6; }
.copy-flash { background: var(--accent-light) !important; border-radius: 4px; }

/* Buyer detail */
.buyer-detail {
  padding: 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
}
.buyer-detail .buyer-head {
  display: flex; align-items: center; gap: 12px;
}
.buyer-detail .buyer-head .profile { flex: 1; min-width: 0; color: var(--accent); font-weight: 800; text-decoration: none; font-size: 15px; }
.buyer-detail .buyer-head .profile:hover { text-decoration: underline; }
.buyer-detail .buyer-head .flag {
  display: inline-flex; padding: 5px 12px; border-radius: 6px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
}
.buyer-detail .buyer-head .flag.trusted { background: var(--trusted-light); color: var(--trusted); }
.buyer-detail .buyer-head .flag.avoid { background: var(--avoid-light); color: var(--avoid); }
.buyer-detail .buyer-head .flag.unknown { background: var(--unknown-light); color: var(--unknown); }
.buyer-detail .buyer-head .flag.blacklisted { background: var(--avoid-light); color: var(--avoid); }
.buyer-detail .detail-meta {
  margin-top: 8px; font-size: 13px; color: var(--text-muted); line-height: 1.5;
}

/* Empty state */
.mini-card {
  display: grid; place-items: center; text-align: center;
  padding: 48px 24px 44px; border-radius: 12px; background: var(--surface);
  border: 1px dashed var(--border);
}
.mini-card .empty-icon {
  display: grid; place-items: center;
  width: 56px; height: 56px; border-radius: 12px;
  background: var(--bg); color: var(--text-light); margin-bottom: 16px;
}
.mini-card .empty-icon svg { width: 26px; height: 26px; stroke-width: 1.3; }
.mini-card strong {
  display: block; font-size: 15px; font-weight: 800; color: var(--text-muted);
}
.mini-card .meta { margin-top: 6px; font-size: 13px; color: var(--text-light); line-height: 1.5; font-weight: 500; }

/* Buttons */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; margin-bottom: 12px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
  transition: background .15s;
}
.back-btn:hover { background: var(--accent-hov); }
.back-btn svg { width: 16px; height: 16px; stroke-width: 2; }
.delete-job {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border-radius: 6px; margin-top: 8px;
  background: var(--avoid-light); color: var(--avoid); font-size: 11px; font-weight: 700;
  transition: background .15s;
}
.delete-job:hover { background: #fecaca; }
.delete-job svg { width: 14px; height: 14px; stroke-width: 1.5; }

/* Settings */
.settings-card {
  display: grid; gap: 18px; padding: 24px; margin-top: 4px;
  border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border);
}
.settings-header {
  display: flex; align-items: center; gap: 14px;
}
.settings-header > div { flex: 1; }
.settings-icon {
  flex: 0 0 auto; width: 40px; height: 40px; display: grid;
  place-items: center; border-radius: 10px;
  background: var(--trusted-light); color: var(--trusted);
}
.settings-icon svg { width: 20px; height: 20px; stroke-width: 1.5; }
.settings-header h2 { margin: 0; font-size: 17px; font-weight: 800; color: var(--primary); letter-spacing: -.01em; }
.conn-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--text-light); flex: 0 0 auto;
  transition: background .15s;
}
.conn-dot.active { background: var(--trusted); }
.field-label {
  display: block; font-size: 12px; font-weight: 700; color: var(--text); margin: 0 0 0 4px;
}
.field-input-wrap {
  position: relative; display: flex; align-items: center;
}
.field-icon {
  position: absolute; left: 10px; z-index: 1; pointer-events: none;
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
}
.field-icon svg { width: 15px; height: 15px; stroke-width: 1.5; }
.field-icon-url { background: #eef2ff; color: #4f46e5; }
.field-icon-token { background: var(--trusted-light); color: var(--trusted); }
.field-input-wrap input {
  width: 100%; height: 48px;
  padding: 0 48px 0 44px;
  border: 1px solid var(--border); border-radius: 8px; outline: 0;
  background: var(--bg); font-size: 14px; color: var(--text);
  transition: border-color .15s;
}
.field-input-wrap input:focus { border-color: var(--accent); }
.field-input-wrap input::placeholder { color: var(--text-light); font-weight: 500; }
.field-action {
  position: absolute; right: 4px; z-index: 1;
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; color: var(--text-light);
  transition: background .15s, color .15s;
}
.field-action:hover { background: var(--accent-light); color: var(--accent); }
.field-action svg { width: 16px; height: 16px; stroke-width: 1.5; }
.settings-card .save-btn {
  height: 48px; border-radius: 8px; color: #fff; font-weight: 800; font-size: 15px;
  background: var(--accent); transition: background .15s;
  letter-spacing: .01em;
}
.settings-card .save-btn:hover { background: var(--accent-hov); }

/* Skeleton */
.skeleton {
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  padding: 18px 16px;
}
.skeleton .line {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton .line + .line { margin-top: 10px; }
.skeleton .line:nth-child(1) { width: 55%; }
.skeleton .line:nth-child(2) { width: 75%; }
.skeleton .line:nth-child(3) { width: 35%; }

/* Animations */
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Small screens */
@media (max-width: 400px) {
  .app { padding-left: 10px; padding-right: 10px; }
  .stats article { padding: 12px; gap: 10px; }
  .stats article .stat-icon { width: 32px; height: 32px; }
  .stats article .stat-icon svg { width: 17px; height: 17px; }
  .stats article .stat-body strong { font-size: 20px; }
  .top-tabs button { font-size: 13px; padding: 12px 0 10px; }
}

@media (max-width: 340px) {
  .app { padding-left: 8px; padding-right: 8px; }
  #jobsSearch, #buyerSearch { height: 40px; font-size: 13px; }
  .jobs-search-wrap, .buyer-search-wrap { padding: 0 10px; }
  .stats { gap: 8px; }
  .stats article { padding: 10px; gap: 8px; }
  .stats article .stat-icon { width: 28px; height: 28px; }
  .stats article .stat-body strong { font-size: 18px; }
  .buyer-card .buyer-head { flex-wrap: wrap; gap: 8px; }
  .buyer-card .buyer-actions { margin-left: auto; }
  .field-input-wrap input { height: 44px; font-size: 13px; padding: 0 44px 0 40px; }
  .field-action { width: 30px; height: 30px; }
  .field-action svg { width: 14px; height: 14px; }
  .field-icon { width: 24px; height: 24px; left: 8px; }
  .field-icon svg { width: 13px; height: 13px; }
  .settings-card .save-btn { height: 44px; font-size: 14px; }
  .top-tabs button { font-size: 12px; padding: 10px 0 8px; }
}
