/* ============================================================
   OpStop v3 — Design System
   Dark theme. GitHub-inspired. Defense-grade.
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:            #0d1117;
  --surface:       #161b22;
  --surface-hover: #1c2230;
  --surface-alt:   #21262d;

  /* Borders */
  --border:        #21262d;
  --border-focus:  #388bfd;

  /* Text */
  --text:          #e6edf3;
  --muted:         #8b949e;
  --subtle:        #6e7681;

  /* Brand */
  --blue:          #4493f8;
  --blue-dark:     #1f6feb;
  --blue-dim:      #1c2d43;

  /* Status */
  --green:         #3fb950;
  --green-dim:     #1a3a1f;
  --yellow:        #d29922;
  --yellow-dim:    #3d2e00;
  --red:           #f85149;
  --red-dim:       #3d1212;
  --purple:        #bc8cff;
  --teal:          #2dd4bf;
  --teal-dark:     #0d7e73;
  --teal-dim:      #0a2f2d;

  /* Score colors */
  --score-green:   #3fb950;
  --score-blue:    #4493f8;
  --score-yellow:  #d29922;

  /* Urgency */
  --urgent-hot:    #f85149;
  --urgent-medium: #d29922;

  /* Layout */
  --sidebar-width:   220px;
  --rail-width:      220px;
  --nav-height:      56px;
  --content-max:     900px;

  /* Radius */
  --radius:    10px;
  --radius-sm:  6px;
  --radius-xs:  4px;

  /* Shadows */
  --shadow:    0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.5);

  /* Transitions */
  --t: 150ms ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top Nav ───────────────────────────────────────────────── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-logo span { color: var(--blue); }

.nav-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: none;
  transition: background var(--t), color var(--t);
}
.nav-tab:hover { background: var(--surface-alt); color: var(--text); }
.nav-tab.active { background: var(--blue-dim); color: var(--blue); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nav-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
  border-radius: var(--radius-xs);
  transition: color var(--t);
}
.nav-bell:hover { color: var(--text); }
.nav-bell .badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--t);
}
.user-pill:hover { border-color: var(--blue); }
.user-pill .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--blue-dim);
  color: var(--blue);
  font-size: .7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-pill .name {
  font-size: .8rem;
  color: var(--text);
  max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Page Shell ────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: calc(100vh - var(--nav-height));
}

/* ── Left Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
}

.sidebar-section {
  padding: 0 8px 8px;
}

.sidebar-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--subtle);
  padding: 8px 8px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--muted);
  font-size: .875rem;
  transition: background var(--t), color var(--t);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-item:hover { background: var(--surface-alt); color: var(--text); }
.sidebar-item.active { background: var(--blue-dim); color: var(--blue); font-weight: 500; }

.sidebar-item .count {
  font-size: .75rem;
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 10px;
  color: var(--muted);
}
.sidebar-item.active .count { background: var(--blue-dark); color: #fff; }

.profile-widget {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.profile-widget .label {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.profile-widget .label span { font-weight: 600; color: var(--text); }

.profile-progress {
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.profile-progress .fill {
  height: 100%;
  border-radius: 3px;
  background: var(--blue);
  transition: width .5s ease;
}
.profile-progress .fill.high { background: var(--green); }

.profile-widget .cta {
  font-size: .75rem;
  color: var(--blue);
  cursor: pointer;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-width: 0;
}

/* ── Right Rail ────────────────────────────────────────────── */
.right-rail {
  width: var(--rail-width);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Hero Greeting ─────────────────────────────────────────── */
.hero {
  margin-bottom: 20px;
}
.hero h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.hero p { color: var(--muted); font-size: .9rem; }
.hero .top-match-teaser {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  background: var(--blue-dim);
  border: 1px solid var(--blue-dark);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--blue);
}

/* ── Profile Tip Strip ─────────────────────────────────────── */
.profile-tip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--yellow-dim);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: .85rem;
  color: var(--yellow);
}
.profile-tip .tip-text { flex: 1; color: var(--text); }
.profile-tip .tip-text strong { color: var(--yellow); }
.profile-tip .tip-cta {
  background: var(--yellow);
  color: #000;
  border: none;
  padding: 4px 12px;
  border-radius: var(--radius-xs);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ── Stats Bar ─────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  min-width: 90px;
  flex: 1;
}
.stat-chip .num { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.stat-chip .lbl { font-size: .7rem; color: var(--muted); margin-top: 4px; text-align: center; }
.stat-chip.blue { border-color: var(--blue-dark); background: var(--blue-dim); }
.stat-chip.blue .num { color: var(--blue); }
.stat-chip.blue.active { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.stat-chip.green { border-color: #1a5229; background: var(--green-dim); }
.stat-chip.green .num { color: var(--green); }
.stat-chip.green.active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.stat-chip.red { border-color: #5a1a1a; background: var(--red-dim); }
.stat-chip.red .num { color: var(--red); }
.stat-chip.red.active { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.stat-chip.teal { border-color: var(--teal-dark); background: var(--teal-dim); }
.stat-chip.teal .num { color: var(--teal); }
.stat-chip.teal.active { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.stat-chip.active { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.stat-chip:hover { opacity: 0.85; transition: opacity 0.15s; }

/* ── Section Header ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
}
.section-header .view-all {
  margin-left: auto;
  font-size: .8rem;
  color: var(--blue);
  cursor: pointer;
}

/* ── Threshold Bar ─────────────────────────────────────────────── */
.threshold-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.threshold-label {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.threshold-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.threshold-btn {
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--t);
}
.threshold-btn:hover { border-color: var(--blue); color: var(--text); }
.threshold-btn.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue);
}
.threshold-count {
  margin-left: auto;
  font-size: .75rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Feed Toggles ──────────────────────────────────────────── */
.feed-toggles { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.sort-select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: .8rem;
  cursor: pointer;
  height: 28px;
  margin-left: auto;
}
.sort-select:hover { border-color: var(--muted); }
.sort-select:focus { outline: none; border-color: var(--blue); }
.feed-toggle {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--t);
}
.feed-toggle:hover { border-color: var(--green); color: var(--text); }
.feed-toggle.active {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

/* ── Search Bar ─────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin-bottom: 14px;
}
.search-wrap .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .9rem;
  pointer-events: none;
}
.search-input {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px 9px 34px;
  font-size: .875rem;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--blue); }
.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  padding: 2px 4px;
  display: none;
}
.search-clear.visible { display: block; }

/* ── NEW Pill ──────────────────────────────────────────────── */
.pill-new {
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.pill-hot {
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  text-transform: uppercase;
}
.pill-type {
  font-size: .65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Match Row ─────────────────────────────────────────────── */
.match-list { display: flex; flex-direction: column; gap: 8px; }

.match-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--t), background var(--t);
  cursor: pointer;
}
.match-row:hover {
  border-color: var(--blue-dark);
  background: var(--surface-hover);
}

.match-rank {
  font-size: .75rem;
  font-weight: 700;
  color: var(--subtle);
  min-width: 24px;
  text-align: center;
  padding-top: 3px;
}

.match-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  flex-shrink: 0;
}
.score-circle {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  border: 2px solid currentColor;
}
.score-circle.score-green { color: var(--score-green); background: var(--green-dim); }
.score-circle.score-blue  { color: var(--score-blue);  background: var(--blue-dim); }
.score-circle.score-yellow{ color: var(--score-yellow);background: var(--yellow-dim); }

.match-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  flex-shrink: 0;
}

.match-body { flex: 1; min-width: 0; }
.match-body .agency-line {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 3px;
}
.match-body .title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.match-body .matched-on {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.match-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: .7rem;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}

.match-right {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 110px;
}
.deadline-label {
  font-size: .75rem;
  font-weight: 600;
}
.deadline-hot    { color: var(--red); }
.deadline-medium { color: var(--yellow); }
.deadline-normal { color: var(--muted); }
.deadline-closed { color: var(--subtle); text-decoration: line-through; }

.match-actions { display: flex; gap: 5px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t), border-color var(--t), color var(--t);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--blue-dark);
  color: #fff;
  border-color: var(--blue-dark);
}
.btn-primary:hover { background: var(--blue); border-color: var(--blue); }

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--blue); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--blue); }
.btn-saved { background: rgba(68,147,248,0.12); color: var(--blue) !important; border-color: var(--blue) !important; }

.btn-sm { padding: 4px 10px; font-size: .75rem; }
.btn-lg { padding: 10px 22px; font-size: .95rem; }

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Rail Cards ─────────────────────────────────────────────── */
.rail-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.rail-card h3 {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.rail-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
}
.rail-stat:last-child { border-bottom: none; }
.rail-stat .lbl { color: var(--muted); }
.rail-stat .val { font-weight: 600; color: var(--text); }
.rail-stat.clickable { cursor: pointer; border-radius: 6px; padding: 5px 6px; margin: 0 -6px; transition: background 0.15s; }
.rail-stat.clickable:hover { background: var(--surface-alt); }
.rail-stat.clickable.active { background: var(--blue-dim); border-bottom-color: transparent; }
.rail-stat.clickable.active .lbl { color: var(--blue); }
.rail-stat.clickable.active .val { color: var(--blue); }

/* Mini bar chart */
.mini-bar { margin-top: 6px; }
.mini-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: .75rem;
}
.mini-bar-row .bar-label { color: var(--muted); min-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-bar-row .bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
}
.mini-bar-row .bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
}
.mini-bar-row .bar-count { color: var(--muted); min-width: 24px; text-align: right; }
.mini-bar-row { cursor: pointer; border-radius: 4px; padding: 2px 4px; margin: 0 -4px; transition: background 0.15s; }
.mini-bar-row:hover { background: var(--surface-alt); }
.mini-bar-row.active { background: var(--blue-dim); }
.mini-bar-row.active .bar-label { color: var(--blue); }

/* ── Browse Footer Strip ────────────────────────────────────── */
.browse-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 16px;
  font-size: .875rem;
}
.browse-strip p { color: var(--muted); }
.browse-strip p strong { color: var(--text); }

/* ── Loading / Skeleton ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-state {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 0;
}
.skel-row { height: 88px; border-radius: var(--radius); }

/* ── Error / Empty State ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state .icon { font-size: 2rem; margin-bottom: 12px; }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* ── Profile Wizard ─────────────────────────────────────────── */
.wizard-wrap {
  max-width: 640px;
  margin: 40px auto;
  padding: 0 20px;
}

.wizard-header { text-align: center; margin-bottom: 32px; }
.wizard-header .otto-badge {
  font-size: 2rem;
  margin-bottom: 8px;
}
.wizard-header h1 { font-size: 1.5rem; font-weight: 700; }
.wizard-header p { color: var(--muted); margin-top: 4px; }

.step-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
}
.step-bar .step {
  flex: 1;
  text-align: center;
}
.step-bar .step .dot {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-bottom: 6px;
  transition: background var(--t);
}
.step-bar .step.done .dot { background: var(--green); }
.step-bar .step.active .dot { background: var(--blue); }
.step-bar .step .name {
  font-size: .65rem;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.step-bar .step.active .name { color: var(--blue); }
.step-bar .step.done .name { color: var(--green); }

.wizard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.wizard-card .otto-msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 12px 14px;
  background: var(--blue-dim);
  border: 1px solid var(--blue-dark);
  border-radius: var(--radius-sm);
}
.wizard-card .otto-msg .badge { font-size: 1.1rem; flex-shrink: 0; }
.wizard-card .otto-msg p { font-size: .875rem; color: var(--text); line-height: 1.5; }

.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--t);
  font-family: inherit;
}
.form-input:focus, .form-select:focus { border-color: var(--border-focus); }

.form-hint { font-size: .75rem; color: var(--subtle); margin-top: 4px; }

/* Checkbox grid */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
  font-size: .825rem;
  color: var(--muted);
}
.check-item:hover { border-color: var(--blue); background: var(--blue-dim); color: var(--text); }
.check-item.checked { border-color: var(--blue); background: var(--blue-dim); color: var(--text); }
.check-item input { accent-color: var(--blue); cursor: pointer; }

/* Radio group */
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--t);
  font-size: .9rem;
}
.radio-item:hover { border-color: var(--blue); }
.radio-item.selected { border-color: var(--blue); background: var(--blue-dim); }
.radio-item input { accent-color: var(--blue); }

/* Chips */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: .8rem;
  cursor: pointer;
  transition: all var(--t);
}
.chip:hover { border-color: var(--blue); color: var(--text); }
.chip.selected { border-color: var(--blue); background: var(--blue-dim); color: var(--text); }
.chip .remove { font-size: .7rem; opacity: .6; }

/* NAICS scraped list */
.naics-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: border-color var(--t);
}
.naics-item.checked { border-color: var(--blue); background: var(--blue-dim); }
.naics-item input { margin-top: 3px; accent-color: var(--blue); }
.naics-item .naics-info .code { font-weight: 600; font-size: .85rem; }
.naics-item .naics-info .desc { font-size: .8rem; color: var(--muted); }
.naics-item .naics-info .source { font-size: .7rem; color: var(--subtle); margin-top: 2px; }

/* Wizard footer */
.wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
}
.wizard-footer .skip { font-size: .8rem; color: var(--subtle); cursor: pointer; }
.wizard-footer .skip:hover { color: var(--muted); }

/* Done step */
.done-step {
  text-align: center;
  padding: 20px 0;
}
.done-step .score-ring {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 6px solid var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--blue);
}
.done-step h2 { font-size: 1.4rem; margin-bottom: 8px; }
.done-step p { color: var(--muted); margin-bottom: 24px; }

/* ── Opportunity Detail ──────────────────────────────────────── */
.opp-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
}

.opp-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 20px;
  border: none;
  background: none;
  padding: 0;
  transition: color var(--t);
}
.opp-back:hover { color: var(--text); }

.opp-header { margin-bottom: 24px; }
.opp-header .badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.opp-header h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 10px; line-height: 1.3; }
.opp-header .meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: .8rem;
  color: var(--muted);
}

.opp-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.opp-main { display: flex; flex-direction: column; gap: 16px; }
.opp-side { display: flex; flex-direction: column; gap: 16px; }

/* AI analysis section */
.analysis-card { }
.analysis-card .analysis-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
  font-size: .875rem;
  line-height: 1.6;
  color: var(--text);
  min-height: 80px;
  white-space: pre-wrap;
}
.analysis-card .analysis-meta {
  font-size: .75rem;
  color: var(--subtle);
  margin-top: 8px;
}
.loading-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Match breakdown */
.reason-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--blue-dim);
  border: 1px solid var(--blue-dark);
  color: var(--blue);
  font-size: .75rem;
  margin: 3px;
}

/* ── Bottom Nav (mobile only — hidden on desktop) ───────────── */
.bottom-nav { display: none; }

/* ── Filter Sheet (mobile only — hidden on desktop) ────────── */
.filter-sheet { display: none; }

/* ── Agency Inline (mobile only) ────────────────────────────── */
.agency-inline { display: none; }

/* ── Active Filter Strip (mobile only) ──────────────────────── */
.active-filter-strip { display: none; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* 3.1 Top Nav */
  .nav-tabs { display: none; }
  .user-pill .name { display: none; }
  .user-pill { padding: 4px; gap: 0; }
  .user-pill .avatar { width: 32px; height: 32px; font-size: .8rem; min-width: 32px; }
  .top-nav { padding: 0 12px; gap: 10px; }

  /* 3.2 Bottom Navigation Bar */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: .65rem;
    color: var(--muted);
    cursor: pointer;
    background: none;
    border: none;
    position: relative;
  }
  .bottom-nav-item.active { color: var(--blue); }
  .bottom-nav-item .icon { font-size: 1.2rem; }
  .bottom-nav-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 20px);
    background: var(--blue);
    color: #fff;
    font-size: .55rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 14px;
    text-align: center;
  }

  /* 3.3 Sidebar → Filter Sheet */
  .sidebar { display: none !important; }
  .filter-sheet {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
  }
  .filter-sheet.open { display: block; }
  .filter-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
  }
  .filter-sheet-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    padding: 12px 16px 80px;
    -webkit-overflow-scrolling: touch;
  }
  .filter-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
  }
  .filter-section-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--subtle);
    margin: 16px 0 8px;
  }
  .filter-pill-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .filter-pill {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--muted);
    font-size: .85rem;
    cursor: pointer;
    transition: all var(--t);
  }
  .filter-pill.active {
    background: var(--blue-dim);
    border-color: var(--blue);
    color: var(--blue);
    font-weight: 600;
  }
  .filter-apply-btn {
    position: sticky;
    bottom: 0;
    width: 100%;
    padding: 14px;
    background: var(--blue-dark);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
  }

  /* 3.5 Right Rail → Agency Inline */
  .right-rail { display: none; }
  .agency-inline {
    display: block;
    margin-bottom: 14px;
  }
  .agency-inline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
  }
  .agency-inline-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 8px 12px;
    display: none;
  }
  .agency-inline-body.expanded { display: block; }

  /* 3.6 Search Bar */
  .search-wrap {
    position: sticky;
    top: 52px;
    z-index: 90;
    background: var(--bg);
    padding: 8px 14px;
    margin: 0 -14px 12px;
  }
  .search-input { font-size: 16px; }

  /* 3.7 Match Row — Score-prominent layout */
  /* flex-wrap:wrap gives us: [score | body] on row 1, [right full-width] on row 2 */
  .match-row {
    flex-wrap: wrap;
    gap: 0;
    padding: 14px;
    border-radius: 10px;
  }
  .match-rank { display: none; }
  .match-score {
    flex-shrink: 0;
    min-width: 48px;
    margin-right: 12px;
    margin-bottom: 8px;
    align-self: flex-start;
  }
  .score-circle {
    width: 46px;
    height: 46px;
    font-size: .9rem;
  }
  .match-divider { display: none; }
  .match-body {
    flex: 1;
    min-width: 0;
  }
  .match-body .title {
    font-size: 1rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .match-right {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    min-width: unset;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 4px;
  }
  .match-actions { gap: 8px; }
  .btn-sm {
    padding: 8px 14px;
    font-size: .85rem;
    min-height: 38px;
  }

  /* 3.8 Threshold Bar → Active Filter Strip */
  .threshold-bar { display: none; }
  .active-filter-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
  }
  .active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--blue-dim);
    border: 1px solid var(--blue-dark);
    border-radius: 20px;
    font-size: .75rem;
    color: var(--blue);
    cursor: pointer;
    white-space: nowrap;
  }
  .active-filter-chip .remove { font-size: .85rem; opacity: .7; }

  /* 3.9 Stats Bar — horizontal scroll */
  .stats-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    gap: 8px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
  }
  .stats-bar::-webkit-scrollbar { display: none; }
  .stat-chip {
    flex: 0 0 auto;
    min-width: 80px;
    padding: 10px 14px;
  }
  .stat-chip .num { font-size: 1.1rem; }

  /* 3.10 App Shell Layout */
  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 52px);
  }
  .main-content {
    padding: 12px 14px;
    padding-bottom: 80px;
    overflow-y: unset;
  }

  /* Grid fixes */
  .opp-grid { grid-template-columns: 1fr; }
  .checkbox-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-blue { color: var(--blue); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ── Profile Editor ──────────────────────────────────────── */
.edit-sections { display: flex; flex-direction: column; gap: 8px; }

.edit-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.edit-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--t);
}
.edit-section-hdr:hover { background: var(--surface-hover); }

.edit-section-meta { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.edit-section-icon { font-size: 1rem; flex-shrink: 0; }
.edit-section-name { font-weight: 600; font-size: .875rem; white-space: nowrap; }
.edit-section-preview {
  font-size: .75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.edit-caret { color: var(--blue); font-size: .875rem; flex-shrink: 0; padding-left: 8px; }

.edit-section-body {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.edit-section-footer {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chip-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
}

/* ── Profile score chips ─────────────────────────────────────── */
.score-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .68rem; font-weight: 700; padding: 2px 7px;
  border-radius: 20px; margin-left: 8px; vertical-align: middle;
  flex-shrink: 0; letter-spacing: .2px; pointer-events: none;
}
.score-chip.complete { background: #052e16; color: #22c55e; border: 1px solid #14532d; }
.score-chip.missing  { background: #3d1212; color: #f87171; border: 1px solid #5a1a1a; }
