:root {
  --navy: #3e3d40; /* Mindworx Dark Charcoal */
  --navy-2: #2b2a2d; /* Darker Charcoal for gradients */
  --ink: #2a2a2a;
  --muted: #68798d;
  --line: #dbe3ec;
  --canvas: #f2f5f8;
  --panel: #ffffff;
  --blue: #E85616; /* Mindworx Orange for primary buttons */
  --blue-soft: #fdeee7; /* Light orange tint for tags */
  --teal: #E85616; /* Mindworx Orange for AI Button */
  --green: #22a873; /* Keeping success green */
  --amber: #9d5a00;
  --danger: #a43a2d;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-family: Aptos, "Segoe UI Variable", "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, select, input, .file-button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, .file-button:focus-within, a:focus-visible { outline: 3px solid rgba(21, 87, 214, .28); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .55; }

.app-header { min-height: 74px; padding: 12px clamp(18px, 3vw, 42px); display: grid; grid-template-columns: minmax(190px, 1fr) minmax(260px, 440px) minmax(340px, 1fr); align-items: center; gap: 22px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--navy); text-decoration: none; font-size: 20px; font-weight: 800; letter-spacing: -.025em; }
.brand-shape { width: 27px; height: 27px; display: inline-block; transform: rotate(45deg); border: 7px solid #35b9aa; border-bottom-color: #2f73ee; border-radius: 7px 10px 7px 10px; }
.role-control { display: grid; gap: 5px; min-width: 0; max-width: 100%; }
.role-control select { width: 100%; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
select, input { min-height: 39px; padding: 0 12px; border: 1px solid #c9d4df; border-radius: 9px; background: white; color: var(--ink); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.sync-state { display: inline-flex; align-items: center; gap: 6px; color: #126447; font-size: 11px; font-weight: 700; white-space: nowrap; }
.sync-state.loading { color: #5d7085; }.sync-state.loading i { background: #7e91a6; box-shadow: 0 0 0 4px rgba(126, 145, 166, .12); }
.sync-state.error { color: var(--danger); }.sync-state.error i { background: var(--danger); box-shadow: 0 0 0 4px rgba(164, 58, 45, .12); }
.sync-state i, .status i { width: 7px; height: 7px; border-radius: 50%; background: #22a873; box-shadow: 0 0 0 4px rgba(34, 168, 115, .12); }
.file-button, .refresh-button { min-height: 37px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #c9d4df; border-radius: 8px; background: white; color: #294761; font-size: 11px; font-weight: 750; cursor: pointer; white-space: nowrap; }
.refresh-button:hover, .file-button:hover { background: #f5f7f9; }

main { width: min(1480px, calc(100% - clamp(24px, 5vw, 72px))); margin: 24px auto 32px; }
.role-summary { min-height: 164px; display: grid; grid-template-columns: minmax(330px, 1.2fr) minmax(560px, 1.8fr); overflow: hidden; border-radius: 15px; background: var(--navy); box-shadow: 0 14px 32px rgba(16, 43, 78, .14); }
.role-copy { padding: 23px 26px; background: linear-gradient(120deg, var(--navy) 20%, var(--navy-2)); color: white; }
.status { display: flex; align-items: center; gap: 8px; color: #a7dacd; font-size: 11px; font-weight: 750; }
.role-copy h1 { margin: 14px 0 6px; color: white; font-size: clamp(23px, 2.3vw, 32px); line-height: 1.05; letter-spacing: -.035em; }
.role-copy p { max-width: 68ch; margin: 0; color: #bfd0e2; font-size: 12px; line-height: 1.55; }
.criteria { margin-top: 15px; display: flex; flex-wrap: wrap; gap: 6px; }
.criteria span { padding: 5px 8px; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; color: #d9e7f4; background: rgba(255,255,255,.06); font-size: 9px; }
.metrics { margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: white; }
.metrics div { padding: 29px 20px; border-left: 1px solid #e4eaf0; }
.metrics dt { color: var(--muted); font-size: 11px; }
.metrics dd { margin: 14px 0 5px; color: var(--ink); font-size: clamp(28px, 3vw, 38px); font-weight: 780; letter-spacing: -.04em; }
.metrics small { color: #8c99a8; font-size: 9px; }

.role-config { margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; overflow: hidden; }
.role-config summary { min-height: 58px; padding: 11px 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; list-style: none; }
.role-config summary::-webkit-details-marker { display: none; }
.role-config summary > span:first-child { display: grid; gap: 3px; }.role-config summary strong { font-size: 12px; }.role-config summary small { color: var(--muted); font-size: 9px; }
.summary-action { color: var(--blue); font-size: 9px; font-weight: 750; }.role-config:not([open]) .summary-action { font-size: 0; }.role-config:not([open]) .summary-action::after { content: "Edit criteria"; font-size: 9px; }
.criteria-form { padding: 14px 16px 16px; display: grid; grid-template-columns: 1.3fr 1fr 160px; gap: 11px; border-top: 1px solid var(--line); background: #f8fafc; }
.criteria-form label { display: grid; gap: 5px; }.criteria-form label > span { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.ai-control { grid-column: 1 / -1; min-height: 49px; padding-top: 3px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ai-feedback { display: grid; gap: 3px; }.ai-feedback strong { color: #24425f; font-size: 10px; }.ai-feedback span { color: var(--muted); font-size: 9px; }.ai-feedback.success strong { color: var(--green); }.ai-feedback.error strong { color: var(--danger); }
.ai-rank-button, .btn-primary { 
  min-height: 39px; 
  padding: 0 16px; 
  border: 1px solid #c9460d; 
  border-radius: 9px; 
  background: var(--blue); /* Pulls the exact Mindworx orange */
  color: white; 
  font-size: 11px; 
  font-weight: 750; 
  cursor: pointer; 
  box-shadow: 0 7px 16px rgba(232, 86, 22, 0.25); 
  transition: background 0.2s, box-shadow 0.2s;
}
.ai-rank-button:hover, .btn-primary:hover { 
  background: #cc4d1f; 
}
.ai-rank-button:disabled, .btn-primary:disabled { 
  box-shadow: none; 
  opacity: 0.6; 
  cursor: not-allowed; 
}

.action-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.toolbar { margin: 22px 0 12px; display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.filters { display: flex; align-items: end; gap: 10px; }
.search-field { width: min(380px, 45vw); }
#source-filter { min-width: 175px; }
.compare-button { min-height: 41px; padding: 0 14px; border: 1px solid #104cbf; border-radius: 9px; background: var(--blue); color: white; font-size: 11px; font-weight: 750; cursor: pointer; box-shadow: 0 7px 16px rgba(21, 87, 214, .18); }
.compare-button span { margin-left: 7px; padding: 3px 6px; border-radius: 999px; background: rgba(255,255,255,.17); }

.dashboard-view { display: grid; grid-template-columns: minmax(670px, 1fr) 346px; gap: 14px; align-items: start; }
.candidate-table, .candidate-detail, .comparison-view { border: 1px solid var(--line); border-radius: 14px; background: white; }
.table-title { min-height: 61px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.table-title h2 { margin: 0 0 3px; font-size: 15px; letter-spacing: -.02em; }
.table-title p { margin: 0; color: var(--muted); font-size: 9px; }
.table-title > span { padding: 5px 8px; border-radius: 999px; background: #fff2d5; color: #78500d; font-size: 9px; font-weight: 700; white-space: nowrap; }
.table-head, .candidate-row { 
  display: grid; 
  /* Added a 32px column at the start for the checkbox */
  grid-template-columns: 32px 48px minmax(230px, 1.6fr) minmax(180px, 1fr) 72px 90px; 
  align-items: center; 
}

.export-checkbox {
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: var(--blue); /* Makes the checkbox Mindworx orange when ticked */
}
.table-head { min-height: 39px; padding: 0 13px; border-bottom: 1px solid var(--line); color: #7e8c9d; font-size: 9px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.candidate-row { width: 100%; min-height: 84px; padding: 10px 13px; border: 0; border-bottom: 1px solid #e8edf2; background: white; color: inherit; text-align: left; cursor: pointer; transition: background .18s ease-out, box-shadow .18s ease-out; }
.candidate-row:hover { background: #f8fafc; }
.candidate-row.selected { background: #f1f6ff; box-shadow: inset 1px 0 var(--blue); }
.candidate-select { min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.rank { color: #758497; font-size: 12px; }
.identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; background: #e2ebfb; color: #174fae; font-size: 10px; font-weight: 800; }
.identity strong, .identity span, .identity small { display: block; }
.identity strong { margin-bottom: 4px; font-size: 12px; }
.identity span { max-width: 32ch; overflow: hidden; color: #52657b; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.identity small { margin-top: 4px; color: #8a97a7; font-size: 9px; }
.skills { display: flex; flex-wrap: wrap; gap: 4px; }
.skills span, .comparison-skills span { padding: 4px 6px; border: 1px solid #dbe3eb; border-radius: 5px; background: #f7f9fb; color: #53647a; font-size: 8px; }
.score { display: grid; gap: 2px; justify-items: start; }
.score strong { color: var(--green); font-size: 20px; letter-spacing: -.035em; }
.score small { color: #8a97a7; font-size: 8px; }
.score-empty { min-height: 28px; }
.row-compare { min-height: 30px; padding: 0 7px; border: 1px solid #cbd6e2; border-radius: 7px; background: white; color: #24425f; font-size: 9px; font-weight: 700; cursor: pointer; }
.row-compare.active { border-color: #76bdb1; background: #e4f6f1; color: #0c665d; }
.empty-state { min-height: 260px; padding: 40px 20px; place-content: center; text-align: center; }
.empty-state h3 { margin: 0; font-size: 15px; }
.empty-state p { color: var(--muted); font-size: 11px; }
.empty-state button { padding: 8px 11px; border: 0; border-radius: 7px; background: var(--blue); color: white; font-size: 10px; cursor: pointer; }

.candidate-detail { position: sticky; top: 14px; padding: 18px; }
.detail-person { display: flex; align-items: center; gap: 11px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-person .avatar { width: 48px; height: 48px; border-radius: 14px; }
.source { display: inline-block; margin-bottom: 5px; padding: 3px 7px; border-radius: 999px; background: var(--blue-soft); color: #174fae; font-size: 8px; font-weight: 750; }
.detail-person h2 { margin: 0 0 3px; font-size: 18px; letter-spacing: -.025em; }
.detail-person p { margin: 0; color: #5e7084; font-size: 10px; }
.ai-pending { margin: 15px 0 0; padding: 16px 14px; border-radius: 11px; background: #f4f7fa; color: #41566d; }
.ai-pending strong { font-size: 11px; }
.ai-pending p { margin: 6px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.match-summary { margin: 15px 0; padding: 14px; border-radius: 11px; background: var(--navy-2); color: white; }
.match-summary div { display: flex; align-items: baseline; justify-content: space-between; }
.match-summary span { color: #aac5df; font-size: 10px; }
.match-summary strong { font-size: 26px; letter-spacing: -.035em; }
.match-summary p { margin: 8px 0 0; color: #c5d7e7; font-size: 10px; line-height: 1.5; }
.detail-block { margin-top: 16px; }
.detail-block h3, .heatmap h3 { margin: 0 0 8px; font-size: 11px; }
.detail-block ul { margin: 0; padding-left: 17px; color: #56687d; font-size: 9px; line-height: 1.55; }
.heatmap { margin-top: 17px; }
.heatmap-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.heat-cell { min-height: 67px; padding: 7px 6px; display: flex; flex-direction: column; justify-content: space-between; border-radius: 8px; background: #f2c3bb; color: #622d25; }
.heat-cell.limited { background: #f5dfb4; color: #6d430a; }
.heat-cell.moderate { background: #f3d694; color: #62430a; }
.heat-cell.strong { background: #a9dfce; color: #164f43; }
.heat-cell.excellent { background: #17816b; color: white; }
.heat-cell span { min-height: 19px; font-size: 6px; line-height: 1.2; font-weight: 750; }
.heat-cell strong { font-size: 16px; }
.heat-cell small { font-size: 6px; text-transform: capitalize; opacity: .8; }
.detail-meta { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: #8795a5; font-size: 8px; line-height: 1.5; }

.comparison-view { overflow: hidden; }
.comparison-view > header { min-height: 75px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.comparison-view h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.025em; }
.comparison-view header p { margin: 0; color: var(--muted); font-size: 10px; }
.comparison-view header button { min-height: 36px; padding: 0 12px; border: 1px solid #cbd6e2; border-radius: 8px; background: white; color: #24425f; font-size: 10px; font-weight: 700; cursor: pointer; }
.comparison-grid { padding: 13px; display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 9px; overflow-x: auto; }
.comparison-card { min-width: 230px; padding: 14px; border: 1px solid #dbe3eb; border-radius: 12px; background: #fbfcfd; }
.comparison-card h3 { margin: 7px 0 3px; font-size: 14px; }
.comparison-card > p { min-height: 27px; margin: 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.comparison-score { margin: 13px 0; display: flex; align-items: baseline; gap: 6px; }
.comparison-score strong { color: var(--green); font-size: 27px; letter-spacing: -.04em; }
.comparison-score span { color: var(--muted); font-size: 8px; }
.comparison-pending { margin: 13px 0; color: var(--muted); font-size: 8px; font-weight: 700; }
.comparison-facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 7px; }
.comparison-facts div { min-width: 0; }
.comparison-facts .wide { grid-column: 1 / -1; }
.comparison-facts dt { margin-bottom: 4px; color: #7e8c9d; font-size: 7px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.comparison-facts dd { margin: 0; color: #29415a; font-size: 9px; font-weight: 650; line-height: 1.45; }
.comparison-skills { display: flex; flex-wrap: wrap; gap: 4px; }
.comparison-card .heatmap-grid { margin-top: 12px; grid-template-columns: repeat(2, 1fr); }
.comparison-card .heat-cell:last-child { grid-column: 1 / -1; }
.demo-note { margin: 15px 0 0; color: #7b8999; font-size: 9px; text-align: center; }

@media (max-width: 1100px) {
  .app-header { grid-template-columns: 180px 1fr; }.role-control { grid-column: 2; grid-row: 1; }.header-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .role-summary { grid-template-columns: 1fr; }.metrics { min-height: 120px; }
  .dashboard-view { grid-template-columns: 1fr; }.candidate-detail { position: static; }
}
@media (max-width: 760px) {
  .app-header { display: flex; flex-wrap: wrap; }.role-control { order: 3; width: 100%; }.header-actions { margin-left: auto; }.sync-state { display: none; }
  main { width: calc(100% - 24px); margin-top: 14px; }.metrics { grid-template-columns: 1fr 1fr; }.metrics div { padding: 18px; border-top: 1px solid #e4eaf0; }
  .toolbar { align-items: stretch; flex-direction: column; }.filters { align-items: stretch; flex-direction: column; }.search-field { width: 100%; }.compare-button { width: 100%; }
  .criteria-form { grid-template-columns: 1fr 1fr; }.criteria-form label:first-child { grid-column: 1 / -1; }
  .table-head { display: none; }.candidate-row { grid-template-columns: 32px minmax(0, 1fr) 58px 75px; }.candidate-row .skills { display: none; }.identity span { max-width: 50vw; }
  .comparison-grid { grid-template-columns: repeat(4, 250px); }
}
@media (max-width: 480px) {
  .brand { width: 100%; }.header-actions { width: 100%; }.header-actions > * { flex: 1; }.metrics dd { font-size: 28px; }
  .candidate-row { grid-template-columns: 28px minmax(0, 1fr) 55px; }.candidate-row .row-compare { display: none; }.identity span { max-width: 48vw; }
  .heatmap-grid { grid-template-columns: repeat(2, 1fr); }.heat-cell:last-child { grid-column: 1 / -1; }
  .criteria-form { display: block; }.criteria-form label { margin-bottom: 10px; }.ai-control { align-items: stretch; flex-direction: column; }.ai-rank-button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  /* Hide non-essential navigation UI */
  header, .role-criteria-card, #back-to-list, button, input {
    display: none !important;
  }
  
  /* Expand scrollable chat boxes to show full history in PDF */
  #ai-answer-box, #compare-answer-box {
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
    background: transparent !important;
  }
  
  /* Ensure radar charts render correctly */
  canvas {
    max-height: 300px !important;
    width: 100% !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
}