/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; font-size: 14px; background: #0f1117; color: #e2e8f0; }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.error-msg { color: #fc8181; font-size: 13px; margin-top: 6px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { padding: 6px 14px; border: 1px solid #4a5568; border-radius: 6px; background: #2d3748; color: #e2e8f0; cursor: pointer; font-size: 13px; transition: background .15s; }
.btn:hover { background: #4a5568; }
.btn-primary { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-danger { background: #e53e3e; border-color: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }
.icon-btn { background: none; border: none; color: #a0aec0; cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 4px; }
.icon-btn:hover { color: #e2e8f0; background: #2d3748; }

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { height: 100%; }

/* ── Login ────────────────────────────────────────────────────────────────── */
#login-screen { display: flex; align-items: center; justify-content: center; background: #0f1117; }
.login-card { background: #1a202c; border: 1px solid #2d3748; border-radius: 12px; padding: 40px 36px; width: 340px; box-shadow: 0 8px 32px rgba(0,0,0,.5); }
.login-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 24px; color: #fff; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: #a0aec0; }
.field input { width: 100%; padding: 8px 12px; background: #2d3748; border: 1px solid #4a5568; border-radius: 6px; color: #e2e8f0; font-size: 14px; }
.field input:focus { outline: none; border-color: #3b82f6; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 20px; background: #1a202c; border-bottom: 1px solid #2d3748; height: 52px; flex-shrink: 0; }
.topbar-title { font-weight: 700; font-size: 15px; color: #fff; margin-right: 8px; white-space: nowrap; }
.topbar-nav { display: flex; gap: 4px; flex: 1; }
.nav-btn { background: none; border: none; color: #a0aec0; cursor: pointer; padding: 6px 14px; border-radius: 6px; font-size: 13px; }
.nav-btn:hover, .nav-btn.active { background: #2d3748; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-label { font-size: 12px; color: #718096; }
.badge { display: inline-flex; align-items: center; justify-content: center; background: #e53e3e; color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 5px; min-width: 16px; margin-left: 2px; }

/* ── App shell ────────────────────────────────────────────────────────────── */
#app-screen { display: flex; flex-direction: column; height: 100%; }
.main-content { flex: 1; overflow-y: auto; padding: 24px; position: relative; }

/* ── Views ────────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Toolbar & filters ───────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar h2, .toolbar h3 { font-size: 18px; font-weight: 600; white-space: nowrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { padding: 6px 10px; background: #2d3748; border: 1px solid #4a5568; border-radius: 6px; color: #e2e8f0; font-size: 13px; }
.filters input:focus, .filters select:focus { outline: none; border-color: #3b82f6; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: #1a202c; }
th { padding: 10px 12px; text-align: left; font-weight: 600; color: #a0aec0; border-bottom: 1px solid #2d3748; white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid #1e2533; vertical-align: middle; }
tbody tr:hover { background: #1e2533; }
.empty-msg { text-align: center; color: #718096; padding: 40px; }

/* ── Match badges (vivid) ─────────────────────────────────────────────────── */
.match-3 { color: #00e676; font-weight: 600; }
.match-2 { color: #ff9d00; }
.match-1 { color: #ff5252; }
.match-0 { color: #90a4ae; }

/* Match label (static per type) + percentage (variable gradient) */
.match-cell { white-space: nowrap; }
.match-lbl { font-weight: 500; }
.match-lbl.match-type-3 { color: #00e676; }
.match-lbl.match-type-2 { color: #ff9d00; }
.match-lbl.match-type-1 { color: #63b3ed; }
.match-lbl.match-type-0 { color: #718096; font-weight: normal; }
.match-pct { font-size: 11px; }
.match-pct.pct-max  { color: #00e676; }
.match-pct.pct-high { color: #ff9d00; }
.match-pct.pct-med  { color: #fbd38d; }
.match-pct.pct-low  { color: #a0aec0; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.pagination button { min-width: 34px; }
.pagination .page-info { color: #718096; font-size: 12px; margin: 0 4px; }

/* ── Stats grid ───────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.stat-card { background: #1a202c; border: 1px solid #2d3748; border-radius: 8px; padding: 20px; }
.stat-card h4 { font-size: 12px; color: #718096; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #fff; }
.stat-list { list-style: none; }
.stat-list li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #2d3748; font-size: 12px; }
.stat-list li:last-child { border: none; }
.stat-list .k { color: #a0aec0; }
.stat-list .v { color: #fff; font-weight: 600; }

/* ── Notification drawer ─────────────────────────────────────────────────── */
.drawer { position: fixed; top: 52px; right: 0; width: 360px; height: calc(100% - 52px); background: #1a202c; border-left: 1px solid #2d3748; display: flex; flex-direction: column; z-index: 100; box-shadow: -4px 0 20px rgba(0,0,0,.4); }
.drawer-header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid #2d3748; font-weight: 600; }
.drawer-header span { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px; }
.notif-item { background: #2d3748; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; position: relative; }
.notif-item.unread { border-left: 3px solid #3b82f6; }
.notif-item.read { opacity: .65; }
.notif-title { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.notif-meta { font-size: 11px; color: #718096; }
.notif-del { position: absolute; top: 8px; right: 8px; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-box { background: #1a202c; border: 1px solid #2d3748; border-radius: 10px; width: 440px; max-width: 95vw; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
.modal-title { padding: 16px 20px 12px; font-size: 16px; font-weight: 600; border-bottom: 1px solid #2d3748; }
.modal-body { padding: 20px; }
.modal-body .field { margin-bottom: 14px; }
.modal-footer { padding: 12px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid #2d3748; }

/* ── Admin tabs ───────────────────────────────────────────────────────────── */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid #2d3748; padding-bottom: 8px; }
.tab-btn { background: none; border: none; color: #a0aec0; cursor: pointer; padding: 6px 16px; border-radius: 6px; font-size: 13px; }
.tab-btn:hover, .tab-btn.active { background: #2d3748; color: #fff; }
.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* ── System panel ─────────────────────────────────────────────────────────── */
.sys-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.sys-toolbar h3 { margin: 0; flex: 1; }
.sys-section { background: #1a202c; border: 1px solid #2d3748; border-radius: 8px; padding: 16px 20px; margin-top: 20px; }
.sys-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sys-section-title { font-size: 14px; font-weight: 600; color: #e2e8f0; flex: 1; }
.sys-detail-row { font-size: 13px; color: #a0aec0; }
.sys-config-note { font-size: 12px; color: #718096; margin: 0 0 12px; }
.cfg-field { margin-bottom: 16px; }
.cfg-label { display: block; font-size: 12px; font-weight: 600; color: #a0aec0; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.cfg-input { width: 100%; background: #2d3748; border: 1px solid #4a5568; border-radius: 6px; color: #e2e8f0; padding: 6px 10px; font-size: 13px; box-sizing: border-box; }
.cfg-textarea { width: 100%; background: #2d3748; border: 1px solid #4a5568; border-radius: 6px; color: #e2e8f0; padding: 6px 10px; font-size: 12px; font-family: monospace; box-sizing: border-box; resize: vertical; }
.cfg-hint { font-size: 11px; color: #4a5568; }
/* ── Config: weight sliders ─────────────────────────────────────────────────── */
.cfg-weights-total { font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 4px 0; }
.cfg-total-ok   { color: #68d391; }
.cfg-total-over { color: #fc8181; }
.cfg-sliders { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; padding-right: 4px; margin-bottom: 10px; }
.cfg-slider-row { display: flex; align-items: center; gap: 8px; }
.cfg-slider-code { width: 36px; font-size: 12px; font-weight: 600; color: #a0aec0; flex-shrink: 0; }
.cfg-slider { flex: 1; accent-color: #3b82f6; }
.cfg-slider-num { width: 70px; background: #2d3748; border: 1px solid #4a5568; border-radius: 4px; color: #e2e8f0; padding: 3px 6px; font-size: 12px; }
.cfg-weight-add { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
/* ── Config: blacklist / groups ─────────────────────────────────────────────── */
.cfg-sub-field { margin-bottom: 10px; }
.cfg-sublabel { display: block; font-size: 11px; color: #718096; margin-bottom: 3px; }
.cfg-group-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.cfg-group-name, .cfg-group-codes { background: #2d3748; border: 1px solid #4a5568; border-radius: 6px; color: #e2e8f0; padding: 5px 8px; font-size: 12px; }
/* ── Config: tag chip editor ─────────────────────────────────────────────── */
.cfg-tags-container { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: #1a202c; border: 1px solid #4a5568; border-radius: 6px; min-height: 42px; margin-bottom: 4px; }
.cfg-tags-scroll { max-height: 180px; overflow-y: auto; align-content: flex-start; }
.cfg-tag { display: inline-flex; align-items: center; gap: 4px; background: #2d3748; border: 1px solid #4a5568; border-radius: 4px; padding: 3px 8px; font-size: 12px; font-weight: 600; color: #e2e8f0; }
.cfg-tag-del { background: none; border: none; color: #718096; cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; }
.cfg-tag-del:hover { color: #fc8181; }
/* ── Login: remember me ────────────────────────────────────────────────────── */
.remember-row { margin-bottom: 10px; }
.remember-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #a0aec0; cursor: pointer; }
.remember-label input[type=checkbox] { width: auto; accent-color: #3b82f6; cursor: pointer; }

/* ── Project table rows ──────────────────────────────────────────────────── */
.proj-row { cursor: pointer; transition: background .12s; }
.row-match-3 { background: rgba(72, 199, 116, 0.18); }
.row-match-2 { background: rgba(246, 173,  85, 0.15); }
.row-match-1 { background: rgba(99, 179, 237, 0.13); }
.row-match-0 { background: transparent; }
.proj-row:hover { background: #1e2533 !important; }
.proj-row.expanded { background: rgba(99, 179, 237, 0.08) !important; }

/* ── Title cell ──────────────────────────────────────────────────────────── */
.title-cell { max-width: 380px; overflow: hidden; }
.title-link { color: #63b3ed; text-decoration: none; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-link:hover { text-decoration: underline; }

/* ── Keywords column ─────────────────────────────────────────────────────── */
.kw-col-th { white-space: nowrap; }
.kw-col { max-width: 180px; }
.kw-col .kw-tag { display: inline-block; margin-bottom: 2px; }

/* ── Flag emoji + tooltip ────────────────────────────────────────────────── */
.flag-emoji { font-size: 26px; flex-shrink: 0; cursor: default; line-height: 1; }

/* ── Title with flag spanning both lines ─────────────────────────────────── */
.title-with-flag { display: flex; align-items: center; gap: 8px; }
.title-text-block { min-width: 0; overflow: hidden; }

/* ── Preview text (always visible under title) ───────────────────────────── */
.preview-text {
  font-size: 11px; color: #94a3b8; margin-top: 3px;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Status badge ────────────────────────────────────────────────────────── */
.status-badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.status-open  { background: rgba(104, 211, 145, 0.15); color: #68d391; }
.status-closed { background: rgba(252, 129, 129, 0.15); color: #fc8181; }
.status-other { background: rgba(160, 174, 192, 0.15); color: #a0aec0; }

/* ── Expandable detail row ───────────────────────────────────────────────── */
.proj-detail td { padding: 0; border-bottom: 2px solid #2d3748; }
.detail-panel { background: #0d1117; border-left: 3px solid #3b82f6; padding: 16px 20px 16px 20px; }
.detail-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #2d3748;
}
.detail-panel-title {
  font-size: 15px; font-weight: 700; color: #fff; line-height: 1.5;
  word-break: break-word;
}
.detail-open-link {
  flex-shrink: 0; font-size: 15px; color: #3b82f6; text-decoration: none;
  padding: 2px 6px; border-radius: 4px; line-height: 1;
  transition: background .12s;
}
.detail-open-link:hover { background: rgba(59,130,246,.15); }
.detail-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.detail-copy-btn {
  background: #2d3748; border: 1px solid #4a5568; border-radius: 4px;
  color: #a0aec0; font-size: 12px; padding: 3px 10px; cursor: pointer;
  transition: background .12s, color .12s; white-space: nowrap;
}
.detail-copy-btn:hover { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.detail-desc {
  font-size: 13px; color: #cbd5e0; line-height: 1.8;
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
}
/* keep old .detail-title in case still referenced */
.detail-title { display: none; }

/* ── Keyword tags ────────────────────────────────────────────────────────── */
.detail-keywords { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.kw-tag {
  background: #2d3748; border-radius: 4px; padding: 2px 9px;
  font-size: 11px; color: #e2e8f0; border-left: 3px solid #4a5568;
}
.kw-exact   { border-color: #22d45e; }
.kw-partial { border-color: #fb923c; }
.kw-weak    { border-color: #f87171; }

/* ── Job tags ────────────────────────────────────────────────────────────── */
.detail-jobs { display: flex; flex-wrap: wrap; gap: 5px; }
.job-tag {
  background: #1a2035; border: 1px solid #3b4a6b; border-radius: 4px;
  padding: 2px 9px; font-size: 11px; color: #90cdf4;
}

/* ── Other column sizing ─────────────────────────────────────────────────── */
.budget-cell { white-space: nowrap; }
.time-cell   { white-space: nowrap; color: #a0aec0; font-size: 12px; }
.id-cell     { color: #4a5568; font-size: 11px; }

/* ── Loader ───────────────────────────────────────────────────────────────── */
.loader { text-align: center; color: #718096; padding: 40px; }

/* ── Filter panels (custom select replacements) ─────────────────────────── */
.fp-wrap { position: relative; display: inline-flex; align-items: center; gap: 3px; }
.fp-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: #2d3748; border: 1px solid #4a5568;
  border-radius: 6px; color: #e2e8f0; font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: border-color .15s;
}
.fp-trigger:hover { border-color: #63b3ed; }
.fp-wrap.fp-open .fp-trigger { border-color: #3b82f6; }
.fp-lbl { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.fp-arr { font-size: 9px; color: #718096; flex-shrink: 0; }
.fp-clear {
  background: none; border: none; color: #a0aec0; cursor: pointer;
  font-size: 12px; padding: 2px 4px; flex-shrink: 0; transition: color .12s;
}
.fp-clear:hover { color: #e2e8f0; }
.fp-clear.hidden { display: none; }
.fp-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 160px;
  background: #1a2035; border: 1px solid #4a5568;
  border-radius: 8px; z-index: 1000; padding: 8px 10px 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.6);
}
.fp-chip {
  display: block; width: 100%; padding: 5px 10px; margin-bottom: 3px;
  border-radius: 4px; font-size: 12px; cursor: pointer; user-select: none;
  background: #2d3748; color: #e2e8f0; border: 1px solid #4a5568;
  white-space: nowrap; transition: background .12s, color .12s;
}
.fp-chip:last-child { margin-bottom: 0; }
.fp-chip:hover { background: #3b4a6b; color: #fff; border-color: #63b3ed; }
.fp-chip-sel { background: #2a4365 !important; color: #90cdf4 !important; border-color: #3b82f6 !important; font-weight: 600; }
/* Country panel: 3-col grid */
#fp-country-dd {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
  min-width: 480px; max-height: 340px; overflow-y: auto;
}
#fp-country-dd .fp-chip { margin-bottom: 0; }

/* ── Keyword autocomplete ─────────────────────────────────────────────────── */
.kw-ac-wrap { position: relative; display: inline-block; }
#f-keyword { padding-right: 24px; }
.kw-clear {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #a0aec0; cursor: pointer;
  font-size: 13px; line-height: 1; padding: 2px 4px;
  z-index: 5;
  transition: color .12s;
}
.kw-clear:hover { color: #e2e8f0; }
.kw-clear.hidden { display: none; }
.kw-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  width: 680px; max-width: 90vw;
  background: #1a2035; border: 1px solid #4a5568;
  border-radius: 8px; z-index: 1000; padding: 10px 14px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.6);
}
.kw-section-label { font-size: 10px; color: #718096; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; margin-top: 4px; }
.kw-section-divider { height: 1px; background: #2d3748; margin: 10px 0; }
.kw-chips {
  column-count: 5;
  column-gap: 6px;
}
.kw-chip {
  display: block; width: 100%;
  padding: 3px 8px; margin-bottom: 4px;
  border-radius: 4px; font-size: 12px; cursor: pointer;
  background: #2d3748; color: #e2e8f0; border: 1px solid #4a5568;
  transition: background .12s, color .12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  break-inside: avoid;
}
.kw-chip:hover { background: #3b4a6b; color: #fff; border-color: #63b3ed; }
.kw-chip-top { background: rgba(99,179,237,.12); color: #90cdf4; border-color: #4a7fa5; font-weight: 500; }
.kw-chip-top:hover { background: rgba(99,179,237,.25); }

/* ── Visit button ────────────────────────────────────────────────────────── */
.visit-cell { padding: 6px 8px !important; white-space: nowrap; }
.btn-visit {
  padding: 3px 10px; border-radius: 4px; border: none; cursor: pointer;
  font-size: 11px; font-weight: 600; background: #00e676; color: #061a0c;
  transition: background .15s;
}
.btn-visit:hover { background: #69f0ae; }
.btn-visit.visited { background: rgba(246,173,85,.15); color: #f6ad55; border: 1px solid #f6ad55; cursor: default; }
.visit-cell .flag-emoji { display: none; }

/* ── Title text (plain, no anchor) ──────────────────────────────────────── */
.title-text { color: #63b3ed; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Preview text (brighter) ─────────────────────────────────────────────── */
.preview-text { color: #94a3b8 !important; }

/* ── Full description: 1/3 bigger + brighter ─────────────────────────────── */
.detail-desc { font-size: 17px !important; color: #edf2f7 !important; }

/* ── New project flash animation ─────────────────────────────────────────── */
@keyframes proj-flash {
  0%, 100% { box-shadow: inset 4px 0 0 #00e676; background: rgba(0,230,118,.13); }
  50%       { box-shadow: inset 4px 0 0 #00e676; background: rgba(0,230,118,.04); }
}
.proj-new { animation: proj-flash 1.4s ease-in-out infinite !important; }

/* ── Infinite scroll elements ─────────────────────────────────────────────── */
.projects-info-bar { color: #718096; font-size: 12px; padding: 6px 2px; }
#projects-sentinel { height: 2px; }

/* ── Notification time ────────────────────────────────────────────────────── */
.notif-time { color: #718096; font-size: 10px; }

/* ── Visited section ─────────────────────────────────────────────────────── */
#visited-sentinel { height: 2px; }
.vis-title-link { color: #63b3ed; cursor: pointer; text-decoration: none; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.vis-title-link:hover { text-decoration: underline; }
.vis-never { color: #718096; font-style: italic; font-size: 11px; }
.vis-row { cursor: default; transition: background .12s; }
.vis-row:hover { background: #1e2533; }

/* ── Mobile responsive (compact records) ────────────────────────────────── */
@media (max-width: 700px) {
  .main-content { padding: 12px; }

  .topbar {
    height: auto;
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-title { width: 100%; margin-right: 0; font-size: 14px; }
  .topbar-nav {
    order: 2;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
  .nav-btn { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
  .topbar-right {
    order: 1;
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
    gap: 8px;
  }
  .user-label {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toolbar { margin-bottom: 12px; gap: 8px; }
  .toolbar h2, .toolbar h3 { font-size: 16px; }
  .filters { width: 100%; gap: 6px; }
  .kw-ac-wrap,
  #f-keyword,
  .fp-wrap,
  .fp-trigger,
  #f-apply,
  #f-reset {
    width: 100%;
  }
  .fp-wrap { display: flex; }
  .fp-trigger { justify-content: space-between; }
  .fp-clear { margin-left: auto; }

  .kw-dropdown {
    width: 100%;
    max-width: none;
    left: 0;
    right: 0;
    padding: 8px;
  }
  .kw-chips { column-count: 2; }

  #fp-country-dd {
    grid-template-columns: 1fr;
    min-width: 0;
    max-height: 240px;
  }

  .table-wrap { overflow: visible; }
  #projects-table, #visited-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }
  #projects-table thead,
  #visited-table thead {
    display: none;
  }

  #projects-tbody,
  #visited-tbody {
    display: grid;
    gap: 10px;
  }

  #projects-table .proj-row,
  #visited-table .vis-row {
    position: relative;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 6px 8px;
    background: #171d29;
    border: 1px solid #2d3748;
    border-radius: 10px;
    padding: 10px;
  }

  #projects-table .proj-row td,
  #visited-table .vis-row td {
    min-width: 0;
    padding: 0;
    border: 0;
    white-space: normal;
    align-self: center;
  }

  /* Header: status + budget + bids */
  #projects-table .proj-row td:nth-child(1),
  #visited-table .vis-row td:nth-child(1) {
    grid-column: 1 / 4;
    grid-row: 1;
  }
  #projects-table .proj-row td:nth-child(5),
  #visited-table .vis-row td:nth-child(5) {
    grid-column: 4 / 10;
    grid-row: 1;
    text-align: center;
    justify-self: stretch;
    white-space: nowrap;
  }
  #projects-table .proj-row td:nth-child(6),
  #visited-table .vis-row td:nth-child(6) {
    grid-column: 9 / 13;
    grid-row: 1;
    text-align: right;
    justify-self: end;
    white-space: nowrap;
  }

  /* Title + preview */
  #projects-table .proj-row td:nth-child(3),
  #visited-table .vis-row td:nth-child(3) {
    grid-column: 1 / 13;
    grid-row: 2;
  }

  /* Footer one-line: match + id + posted */
  #projects-table .proj-row td:nth-child(7),
  #visited-table .vis-row td:nth-child(7) {
    grid-column: 1 / 5;
    grid-row: 3;
    white-space: nowrap;
  }
  #projects-table .proj-row td:nth-child(9),
  #visited-table .vis-row td:nth-child(11) {
    grid-column: 5 / 9;
    grid-row: 3;
    white-space: nowrap;
    color: #718096;
    justify-self: stretch;
    text-align: center;
  }
  #projects-table .proj-row td:nth-child(8),
  #visited-table .vis-row td:nth-child(8) {
    grid-column: 9 / 13;
    grid-row: 3;
    justify-self: end;
    text-align: right;
    white-space: nowrap;
  }

  /* Keywords */
  #projects-table .proj-row td:nth-child(2),
  #visited-table .vis-row td:nth-child(2) {
    grid-column: 1 / 13;
    grid-row: 4;
    margin-top: 2px;
  }

  /* Visit button (left) */
  #projects-table .proj-row td:nth-child(4),
  #visited-table .vis-row td:nth-child(4) {
    grid-column: 1 / 13;
    grid-row: 5;
    justify-self: stretch;
    margin-top: 2px;
  }

  /* Optional visited-only timings hidden on compact layout */
  #visited-table .vis-row td:nth-child(9),
  #visited-table .vis-row td:nth-child(10) {
    display: none;
  }

  #projects-table .title-cell,
  #visited-table .title-cell {
    max-width: none;
    align-items: flex-start;
  }
  .title-with-flag { width: 100%; gap: 6px; align-items: flex-start; }
  .title-cell .flag-emoji { display: none; }
  .title-text,
  .vis-title-link,
  .title-link {
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
    line-height: 1.35;
  }
  .preview-text {
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
    line-height: 1.35;
  }

  #projects-table .kw-col,
  #visited-table .kw-col {
    max-width: none;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .kw-tag { font-size: 10px; padding: 2px 7px; }

  .visit-cell {
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
  }
  .visit-cell .flag-emoji {
    display: inline-block;
    margin-left: auto;
    font-size: 30px;
    line-height: 1;
  }
  .btn-visit {
    min-width: 104px;
    text-align: center;
    padding-right: 14px;
  }
  .match-cell { justify-content: flex-start; flex-wrap: nowrap; }
  .time-cell, .id-cell { font-size: 11px; }

  #projects-table .proj-detail,
  #visited-table .proj-detail {
    display: block;
  }
  #projects-table .proj-detail td,
  #visited-table .proj-detail td {
    display: block;
    padding: 0;
    border: 0;
  }
  .detail-panel {
    width: 100%;
    padding: 16px;
    border-radius: 8px;
    margin-top: 8px;
  }
  .detail-header { gap: 8px; margin-bottom: 8px; }
  .detail-panel-title { font-size: 14px; }
  .detail-desc {
    font-size: 15px !important;
    min-height: 260px;
    max-height: 560px;
    line-height: 1.55;
  }

  .drawer {
    width: 100%;
    height: calc(100% - 52px);
    top: 52px;
    border-left: none;
  }

  .admin-tabs { overflow-x: auto; }
  #users-table { display: block; overflow-x: auto; }
}

@media (max-width: 380px) {
  .main-content { padding: 10px; }
  .topbar { padding: 8px; }
  .btn { padding: 6px 10px; font-size: 12px; }
  #projects-table .proj-row,
  #visited-table .vis-row {
    padding: 8px;
    border-radius: 9px;
  }
  #projects-table .proj-row td,
  #visited-table .vis-row td {
    gap: 8px;
    padding: 4px 0;
  }
  .title-with-flag { gap: 5px; }
  .visit-cell .flag-emoji { font-size: 28px; }
  .detail-panel { padding: 14px; }
  .detail-desc {
    min-height: 240px;
    max-height: 500px;
  }
}
