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

:root {
  /* Palette */
  --bg:           #0d0d0d;
  --bg-1:         #141414;
  --bg-2:         #1a1a1a;
  --bg-3:         #222222;
  --bg-hover:     #2a2a2a;
  --border:       #2e2e2e;
  --border-focus: #555;

  /* Text */
  --text:         #e8e8e8;
  --text-2:       #999;
  --text-3:       #555;

  /* Accent */
  --green:        #3dd68c;
  --green-dim:    #1a3d28;
  --red:          #f04438;
  --red-dim:      #3d1a1a;
  --yellow:       #f5a623;
  --yellow-dim:   #3d2e0a;
  --blue:         #4a9eff;

  /* Layout */
  --sidebar-w:    220px;
  --sidebar-w-collapsed: 56px;
  --radius:       6px;
  --radius-lg:    10px;
  --transition:   0.15s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }
.muted  { color: var(--text-2); }

/* ─── Gate / Auth overlay ─────────────────────────────────────── */
.gate-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.gate-box {
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gate-box--wide {
  max-width: 560px;
}

.gate-logo {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: 4px;
}

.gate-sub {
  color: var(--text-2);
  font-size: 12.5px;
  margin-bottom: 8px;
}

.gate-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.gate-input:focus {
  border-color: var(--border-focus);
}

.gate-error {
  color: var(--red);
  font-size: 12px;
  margin-top: -4px;
}

/* Setup grid */
.setup-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setup-label {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: -4px;
}

/* ─── App shell ───────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), min-width var(--transition);
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
  min-width: var(--sidebar-w-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.sidebar.collapsed .sidebar-logo {
  opacity: 0;
  width: 0;
}

.sidebar-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  border-radius: 4px;
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
}

.sidebar-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform var(--transition);
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-toggle:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 8px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section-header {
  padding: 14px 6px 4px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.sidebar.collapsed .nav-section-label {
  opacity: 0;
}

.nav-section-spacer {
  flex: 1;
  min-height: 16px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius);
  color: var(--text-2);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--bg-3);
  color: var(--text);
}

.nav-item--sub {
  padding-left: 12px;
}

.nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.nav-label {
  font-size: 13px;
  overflow: hidden;
  transition: opacity var(--transition), width var(--transition);
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.nav-badge {
  margin-left: auto;
  background: var(--green-dim);
  color: var(--green);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

/* ─── Main content ────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
}

/* ─── Views ───────────────────────────────────────────────────── */
.view {
  padding: 32px 36px;
  max-width: 1200px;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 28px;
}

.view-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}

.view-subtitle {
  font-size: 12.5px;
  color: var(--text-2);
}

.view-date {
  font-size: 12px;
  color: var(--text-3);
  margin-left: auto;
}

.view-header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Panels ──────────────────────────────────────────────────── */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn-primary:hover {
  background: #ccc;
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger {
  color: var(--red);
  border-color: var(--red-dim);
}

.btn-danger:hover {
  background: var(--red-dim);
}

.btn-full {
  width: 100%;
}

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

/* ─── Forms ───────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 12px;
  color: var(--text-2);
}

.form-input {
  padding: 8px 11px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

.form-input:focus {
  border-color: var(--border-focus);
}

.form-input--sm { max-width: 180px; }
.form-input--xs { width: 64px; }

.form-select {
  padding: 7px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.form-select:focus {
  border-color: var(--border-focus);
}

/* ─── Dashboard ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1.1;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-3);
}

.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.activity-list {
  padding: 12px 18px;
  min-height: 120px;
}

/* ─── Data Table ──────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12.5px;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td {
  background: var(--bg-2);
  color: var(--text);
}

/* ─── Status badges ───────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.status-pending     { background: var(--bg-3); color: var(--text-2); }
.status-sent        { background: #1a2d3d; color: var(--blue); }
.status-opened      { background: var(--yellow-dim); color: var(--yellow); }
.status-replied     { background: var(--green-dim); color: var(--green); }
.status-no-response { background: var(--bg-3); color: var(--text-3); }
.status-bounced     { background: var(--red-dim); color: var(--red); }

/* ─── Tags ────────────────────────────────────────────────────── */
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* ─── Empty state ─────────────────────────────────────────────── */
.empty-state {
  color: var(--text-3);
  font-size: 12.5px;
  padding: 20px 0;
  text-align: center;
}

/* ─── Find Contacts ───────────────────────────────────────────── */
.finder-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}

.finder-input-panel { padding: 20px; }

.waterfall-log {
  padding: 16px 18px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-2);
  min-height: 120px;
  max-height: 240px;
  overflow-y: auto;
  line-height: 1.8;
}

.waterfall-log .log-step { display: flex; gap: 8px; }
.waterfall-log .log-ok   { color: var(--green); }
.waterfall-log .log-skip { color: var(--text-3); }
.waterfall-log .log-fail { color: var(--red); }

.contact-results { padding: 0; }

/* ─── Review Queue ────────────────────────────────────────────── */
.queue-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.queue-list {
  padding: 8px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.queue-card {
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
}

.queue-card:hover { background: var(--bg-2); }

.queue-card.selected {
  background: var(--bg-2);
  border-color: var(--border);
}

.queue-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.queue-card-company {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.email-preview-body {
  padding: 20px 22px;
  min-height: 280px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
}

.queue-actions {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* ─── Filter bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ─── Job Cards ───────────────────────────────────────────────── */
.job-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.job-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  transition: border-color var(--transition);
  cursor: pointer;
}

.job-card:hover {
  border-color: var(--border-focus);
}

.job-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.job-card-meta {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 3px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.job-card-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.fit-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.fit-5 { background: var(--green-dim); color: var(--green); }
.fit-4 { background: #1a3326; color: #5bdb8f; }
.fit-3 { background: var(--yellow-dim); color: var(--yellow); }
.fit-2 { background: #2d200a; color: #c68a20; }
.fit-1 { background: var(--red-dim); color: var(--red); }

/* ─── Fit Score view ──────────────────────────────────────────── */
.fitscore-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fitscore-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.fitscore-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.fitscore-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.fitscore-company {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.fitscore-breakdown {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.fitscore-dim {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-2);
  padding: 6px 10px;
  border-radius: 4px;
}

.fitscore-dim-val {
  font-weight: 600;
  color: var(--text);
}

/* ─── Application Prep ────────────────────────────────────────── */
.appprep-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
}

.appprep-sidebar { padding: 0; }

.appprep-job-list {
  padding: 8px;
}

.appprep-job-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
}

.appprep-job-item:hover { background: var(--bg-2); color: var(--text); }
.appprep-job-item.selected { background: var(--bg-2); color: var(--text); border-color: var(--border); }

.appprep-upload, .appprep-output { padding: 0; }

.upload-box {
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--text-2);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition);
  cursor: pointer;
}

.upload-box:hover, .upload-box.drag-over {
  border-color: var(--border-focus);
}

/* Tabs */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
}

.tab-btn {
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }

.tab-btn--active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-content { padding: 0; }

.doc-preview {
  padding: 22px 24px;
  line-height: 1.75;
  color: var(--text-2);
  white-space: pre-wrap;
  min-height: 320px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}

.doc-actions {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* ─── Settings ────────────────────────────────────────────────── */
.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 600px;
}

.settings-form {
  padding: 20px 22px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--on  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot--off { background: var(--text-3); }

.followup-schedule {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.followup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}

.followup-label {
  width: 90px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-2);
}

/* ─── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 12.5px;
  z-index: 9999;
  pointer-events: none;
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Scrollbars ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .finder-layout,
  .queue-layout,
  .appprep-layout { grid-template-columns: 1fr; }

  .dashboard-panels { grid-template-columns: 1fr; }

  .view { padding: 20px 18px; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: var(--sidebar-w-collapsed); min-width: var(--sidebar-w-collapsed); }
  .sidebar .nav-label,
  .sidebar .sidebar-logo,
  .sidebar .nav-section-label,
  .sidebar .nav-badge { opacity: 0; width: 0; overflow: hidden; }
}
