/* Fitted Role — light, professional. Clean canvas, strong hierarchy, hairline
   borders, one confident indigo accent, green reserved for "fit". No ornament. */

:root {
  --canvas:    #f5f6f8;
  --surface:   #ffffff;
  --surface-2: #fafbfc;

  --ink:       #16191f;
  --ink-2:     #4a5261;
  --ink-3:     #6b7383;
  --ink-faint: #98a1af;

  --line:      #e6e8ee;
  --line-2:    #d7dbe3;

  --accent:    #3a45b5;   /* interactive: buttons, links, active nav */
  --accent-2:  #eef0fb;   /* accent tint */
  --pos:       #12855a;   /* fit / healthy */
  --pos-2:     #e7f4ee;
  --warn:      #a9741a;
  --warn-2:    #f7efe0;
  --neg:       #c0392b;
  --neg-2:     #fbebe9;

  --ui:   'Inter', system-ui, -apple-system, sans-serif;
  --head: 'Archivo', var(--ui);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow:    0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.08), 0 2px 6px rgba(16,24,40,.04);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
/* full-height flex column so the swipe deck can fill exactly the space under
   the top bar with no hardcoded heights and no page scroll */
#app { position: relative; min-height: 100dvh; display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
.mono { font-family: var(--mono); }

/* wordmark */
.brand-mark {
  font-family: var(--head); font-weight: 700; font-size: 15px;
  letter-spacing: -0.01em; color: var(--ink);
  display: inline-flex; align-items: center; gap: 9px;
  white-space: nowrap; flex-shrink: 0;
}
.brand-mark::before {
  content: ""; width: 18px; height: 18px; border-radius: 5px;
  background: var(--accent);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.55);
}

/* ============================ LOGIN ============================ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  font-family: var(--head); font-weight: 700; font-size: 27px; line-height: 1.15;
  letter-spacing: -0.02em; margin: 22px 0 8px;
}
.login-card p.sub { color: var(--ink-3); font-size: 14px; margin-bottom: 28px; }
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 500; color: var(--ink-2);
  margin-bottom: 7px;
}
.field input {
  width: 100%; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 11px 13px; color: var(--ink);
  font-family: var(--ui); font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.btn-primary {
  width: 100%; background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 12px; font-weight: 600; font-size: 14px;
  transition: filter .15s, transform .05s; box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.err { color: var(--neg); font-size: 13px; margin-top: 14px; min-height: 18px; }

/* ============================ SHELL ============================ */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 13px 28px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10; flex: 0 0 auto;
}
.nav { display: flex; gap: 2px; }
.nav a {
  text-decoration: none; color: var(--ink-3); font-size: 14px; font-weight: 500;
  padding: 7px 13px; border-radius: 7px;
}
.nav a.active { color: var(--accent); background: var(--accent-2); }
.nav a:hover { color: var(--ink); }
.top .spacer { flex: 1; }
.top .who { font-size: 13px; color: var(--ink-faint); }
.top .signout {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2);
  border-radius: 7px; padding: 7px 13px; font-size: 13px; font-weight: 500;
  white-space: nowrap; flex-shrink: 0;
}
.top .signout:hover { border-color: var(--neg); color: var(--neg); }

.view { padding: 28px; max-width: 1500px; margin: 0 auto; width: 100%; flex: 1 1 auto; }
/* the inbox deck fills the space under the top bar exactly — no padding, no scroll */
.view:has(.swipe-view) { padding: 0; max-width: none; display: flex; }

/* responsive header: keep it to one line on narrow screens */
@media (max-width: 600px) {
  .top { gap: 12px; padding: 10px 14px; }
  .top .who { display: none; }
  .nav a { padding: 7px 10px; font-size: 13px; }
  .view { padding: 18px 14px; }
}

.live {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500; color: var(--ink-3);
}
.live .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--pos);
  box-shadow: 0 0 0 0 rgba(18,133,90,.4); animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(18,133,90,.45); } 50% { box-shadow: 0 0 0 6px rgba(18,133,90,0); } }

/* ============================ MONITOR ============================ */
.mon-head { display: flex; align-items: baseline; gap: 18px; margin-bottom: 22px; }
.mon-head h1 {
  font-family: var(--head); font-weight: 700; font-size: 26px; letter-spacing: -0.02em;
}
.mon-head .clock { font-family: var(--mono); color: var(--ink-faint); font-size: 13px; }
.mon-head .spacer { flex: 1; }

/* pipeline: a clean stat row */
.flow {
  display: flex; margin-bottom: 24px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.stage {
  flex: 1 1 0; min-width: 150px; padding: 22px 24px; position: relative;
  display: flex; flex-direction: column; gap: 6px;
}
.stage:not(:last-child) { border-right: 1px solid var(--line); }
.stage .s-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint);
}
.stage .s-value {
  font-family: var(--head); font-weight: 700; font-size: 38px; line-height: 1;
  letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums;
}
.stage .s-sub { font-size: 12px; color: var(--ink-3); }
.stage.active .s-value { color: var(--accent); }
.stage .flow-arrow { display: none; }
.stage.active .s-label { color: var(--accent); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr; } }

/* pipeline flow wraps into a grid on narrow screens instead of clipping */
@media (max-width: 720px) {
  .flow { flex-wrap: wrap; }
  .stage { flex: 1 1 33%; min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .stage:nth-child(3n) { border-right: none; }
  .stage .s-value { font-size: 30px; }
}
/* tables scroll horizontally rather than squish */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .utable { min-width: 520px; }
.runs-scroll { max-height: 540px; overflow-y: auto; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm);
}
.panel > h2 {
  font-family: var(--head); font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--ink-2); margin-bottom: 16px; display: flex; align-items: center; gap: 9px;
}
.panel > h2 .count {
  color: var(--ink-faint); font-weight: 500; font-family: var(--mono); font-size: 12px;
}

.src-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.src {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 15px 16px; border-left: 3px solid var(--line-2);
}
.src.ok      { border-left-color: var(--pos); }
.src.failed  { border-left-color: var(--neg); }
.src.running { border-left-color: var(--warn); }
.src.idle    { border-left-color: var(--line-2); }
.src .src-top { display: flex; align-items: center; justify-content: space-between; }
.src .src-name { font-weight: 600; font-size: 14px; }
.src .src-state {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 5px; background: var(--canvas); color: var(--ink-3);
}
.src.ok .src-state { color: var(--pos); background: var(--pos-2); }
.src.failed .src-state { color: var(--neg); background: var(--neg-2); }
.src.running .src-state { color: var(--warn); background: var(--warn-2); }
.src .src-nums { display: flex; gap: 20px; margin-top: 12px; font-family: var(--mono); font-size: 14px; }
.src .src-nums b { color: var(--ink); font-weight: 600; }
.src .src-nums span { color: var(--ink-faint); display: block; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; font-family: var(--ui); }
.src .src-when { margin-top: 9px; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.src.disabled { opacity: .55; }

.utable { width: 100%; border-collapse: collapse; font-size: 14px; }
.utable th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-faint); padding: 8px 11px;
  border-bottom: 1px solid var(--line);
}
.utable td { padding: 12px 11px; border-bottom: 1px solid var(--line); font-family: var(--mono); }
.utable td.email { font-family: var(--ui); font-weight: 500; }
.utable tr:last-child td { border-bottom: none; }
.tag { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 5px; }
.tag.on  { background: var(--pos-2); color: var(--pos); }
.tag.off { background: var(--neg-2); color: var(--neg); }
.num-cell { color: var(--ink); }
.num-cell.zero { color: var(--ink-faint); }

.fail-row {
  border: 1px solid var(--line); border-left: 3px solid var(--neg); background: var(--surface-2);
  border-radius: 8px; padding: 12px 15px; margin-bottom: 10px;
}
.fail-row .fr-top { display: flex; justify-content: space-between; font-size: 13px; }
.fail-row .fr-comp { color: var(--neg); font-weight: 600; font-family: var(--mono); }
.fail-row .fr-when { color: var(--ink-faint); font-family: var(--mono); font-size: 12px; }
.fail-row .fr-err { margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: pre-wrap; word-break: break-word; max-height: 54px; overflow: hidden; }
.empty { color: var(--ink-faint); font-size: 14px; padding: 10px 0; }
.full { grid-column: 1 / -1; }

/* ============================ SWIPE INBOX — card stack ============================ */
.swipe-view {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 16px;
}
/* a fixed-footprint deck: consistent card size, centered — no wasted space */
.swipe-stack {
  position: relative; width: 100%; max-width: 400px; height: min(520px, 100%);
}
.swipe-card {
  position: absolute; inset: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 30px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; justify-content: center;
  touch-action: none; cursor: grab; user-select: none;
  will-change: transform; overflow: hidden;
}
.swipe-card:active { cursor: grabbing; }
.swipe-card.behind-1 { transform: scale(0.955) translateY(16px); box-shadow: var(--shadow); }
.swipe-card.behind-2 { transform: scale(0.91) translateY(32px); box-shadow: var(--shadow-sm); }
.swipe-card.snap { transition: transform .28s cubic-bezier(.2,.8,.3,1); }
.swipe-card.gone { transition: transform .38s ease-out, opacity .38s ease-out; }

/* APPLY / PASS stamps that fade in as you drag */
.swipe-badge {
  position: absolute; top: 28px; padding: 6px 14px; border-radius: 8px;
  font-family: var(--head); font-weight: 700; font-size: 20px; letter-spacing: 0.04em;
  border: 3px solid; opacity: 0; pointer-events: none; text-transform: uppercase;
}
.swipe-badge.like { right: 26px; color: var(--pos); border-color: var(--pos); transform: rotate(12deg); }
.swipe-badge.nope { left: 26px;  color: var(--neg); border-color: var(--neg); transform: rotate(-12deg); }

.swipe-controls { display: flex; gap: 22px; align-items: center; justify-content: center; }
.swipe-controls .round {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line-2);
  background: var(--surface); box-shadow: var(--shadow); font-size: 22px; line-height: 1;
  display: grid; place-items: center; color: var(--ink-2); transition: transform .1s, border-color .15s, color .15s;
}
.swipe-controls .round:hover { transform: translateY(-2px); }
.swipe-controls .round.pass:hover { border-color: var(--neg); color: var(--neg); }
.swipe-controls .round.apply { width: 64px; height: 64px; background: var(--accent); color: #fff; border-color: var(--accent); font-size: 24px; }
.swipe-controls .count { font-size: 13px; color: var(--ink-faint); font-family: var(--mono); margin: 0 4px; min-width: 62px; text-align: center; }

/* applications view still uses plain stacked cards */
.inbox { max-width: 560px; margin: 0 auto; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 26px; margin-bottom: 16px; box-shadow: var(--shadow);
}

/* card content (shared by .card and .swipe-card) */
.card .c-company, .swipe-card .c-company {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent);
}
.card .c-title, .swipe-card .c-title {
  font-family: var(--head); font-weight: 700; font-size: 24px; line-height: 1.18;
  letter-spacing: -0.02em; margin: 7px 0 14px;
}
.card .c-meta, .swipe-card .c-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.card .chip, .swipe-card .chip {
  font-size: 12px; font-weight: 500; background: var(--canvas); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 10px; color: var(--ink-2);
}
.card .c-reason, .swipe-card .c-reason {
  color: var(--ink-2); font-size: 14px; line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 13px 15px; margin: 14px 0;
}
/* fit score = a clean meter (the one signature moment) */
.card .c-score, .swipe-card .c-score {
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card .c-score .fit-meter, .swipe-card .c-score .fit-meter {
  flex: 1; height: 6px; background: var(--canvas); border-radius: 3px; overflow: hidden;
}
.card .c-score .fit-meter i, .swipe-card .c-score .fit-meter i {
  display: block; height: 100%; background: var(--pos); border-radius: 3px;
}
.swipe-actions { display: flex; gap: 12px; margin-top: 2px; }
.swipe-actions button, .swipe-actions .apply {
  flex: 1; padding: 13px; border-radius: 8px; font-weight: 600; font-size: 14px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  font-family: var(--ui); text-align: center; text-decoration: none;
}
.swipe-actions .pass:hover { border-color: var(--neg); color: var(--neg); }
.swipe-actions .apply { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-sm); }
.swipe-actions .apply:hover { filter: brightness(1.06); }

.loading { color: var(--ink-3); font-size: 14px; text-align: center; padding: 48px; }

/* ============================ APPLICATIONS TRACKER ============================ */
.tracker { max-width: 920px; margin: 0 auto; }
.tracker-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.tracker-head h1 { font-family: var(--head); font-weight: 700; font-size: 24px; letter-spacing: -0.02em; }
.tracker-head .count { color: var(--ink-faint); font-family: var(--mono); font-size: 13px; }

.app-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.app-toolbar input, .app-toolbar select {
  font-family: var(--ui); font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 9px 12px;
}
.app-toolbar input { flex: 1; min-width: 180px; }
.app-toolbar input:focus, .app-toolbar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }

.app-list { display: flex; flex-direction: column; gap: 8px; }
.app-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 16px; display: flex; align-items: center; gap: 12px 14px; flex-wrap: wrap;
  box-shadow: var(--shadow-sm); transition: border-color .12s;
}
.app-row:hover { border-color: var(--line-2); }
.app-row .status-badge { flex-shrink: 0; }
.app-row .r-main { flex: 1 1 200px; min-width: 0; cursor: pointer; }
.app-row .r-title { font-weight: 600; font-size: 15px; color: var(--ink); }
.app-row .r-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.app-row .r-fit { font-family: var(--mono); font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.app-row .r-fit b { color: var(--pos); }
.app-row .r-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
/* on narrow screens, actions drop to their own full-width line */
@media (max-width: 560px) {
  .app-row .r-fit { margin-left: auto; }
  .app-row .r-actions { flex: 1 1 100%; }
  .app-row .r-actions .mini-btn { flex: 1; text-align: center; }
}

.status-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.s-ready    { background: var(--accent-2); color: var(--accent); }
.status-badge.s-review   { background: var(--warn-2); color: var(--warn); }
.status-badge.s-applied  { background: var(--pos-2); color: var(--pos); }
.status-badge.s-tailoring{ background: var(--canvas); color: var(--ink-3); }
.status-badge.s-abandoned{ background: var(--neg-2); color: var(--neg); }

.mini-btn {
  font-size: 12px; font-weight: 600; font-family: var(--ui);
  padding: 6px 11px; border-radius: 7px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn.danger:hover { border-color: var(--neg); color: var(--neg); }
.mini-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.mini-btn.primary:hover { filter: brightness(1.06); color: #fff; }
.mini-date { font-family: var(--mono); font-size: 12px; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 7px; }

/* details page */
.detail-back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 14px; text-decoration: none; margin-bottom: 16px; }
.detail-back:hover { color: var(--accent); }
.detail-head h1 { font-family: var(--head); font-weight: 700; font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; }
.detail-head .d-company { color: var(--accent); font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; align-items: center; }
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
@media (max-width: 820px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 20px; align-items: center; }

.analysis-col h3, .side-card h3 {
  font-family: var(--head); font-size: 13px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 10px; letter-spacing: .01em;
}
.sw-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.sw-list li { font-size: 14px; line-height: 1.5; color: var(--ink-2); padding-left: 26px; position: relative; }
.sw-list li::before {
  position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  font-size: 12px; font-weight: 700; line-height: 16px; text-align: center;
}
.sw-list.strengths li::before { content: "+"; color: var(--pos); background: var(--pos-2); }
.sw-list.weaknesses li::before { content: "!"; color: var(--warn); background: var(--warn-2); }
.why-box { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 14px 16px; font-size: 14px; line-height: 1.55; color: var(--ink-2); margin-bottom: 20px; }

.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.side-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.side-row:last-child { border-bottom: none; }
.side-row .k { color: var(--ink-3); } .side-row .v { font-family: var(--mono); color: var(--ink); }
.resume-preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 16px; font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--ink-2); white-space: pre-wrap; max-height: 420px; overflow-y: auto; }
