* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f5f7;
  color: #172b4d;
}
.hidden { display: none !important; }
.muted { color: #6b778c; }

/* Login */
.view { min-height: 100vh; }
#view-login {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0b3d91, #0f5fd6);
}
.card {
  background: #fff; border-radius: 10px; padding: 28px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.login-card { width: 340px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
input, select {
  padding: 9px 10px; border: 1px solid #dfe1e6; border-radius: 6px; font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: #0f5fd6; }
.error { color: #de350b; font-size: 13px; min-height: 16px; }
.btn {
  padding: 9px 14px; border: 1px solid #dfe1e6; border-radius: 6px; background: #fff;
  cursor: pointer; font-size: 14px;
}
.btn.primary { background: #0f5fd6; border-color: #0f5fd6; color: #fff; }
.btn.danger { color: #de350b; border-color: #ffbdad; }
.btn:hover { filter: brightness(.96); }

/* App layout */
#view-app { display: flex; flex-direction: column; }
header {
  display: flex; align-items: center; gap: 18px; padding: 12px 22px;
  background: #fff; border-bottom: 1px solid #e6e9ef;
}
.brand { font-size: 18px; font-weight: 700; color: #0b3d91; }
nav { display: flex; gap: 6px; flex: 1; }
.tab {
  padding: 8px 14px; border: none; background: transparent; border-radius: 6px;
  cursor: pointer; font-size: 14px; color: #42526e;
}
.tab.active { background: #0f5fd6; color: #fff; }
.userbox { display: flex; align-items: center; gap: 12px; }
#user-label { font-size: 13px; color: #42526e; }

main { padding: 22px; max-width: 1100px; width: 100%; margin: 0 auto; }
.tab-panel { animation: fade .18s ease; }
@keyframes fade { from{opacity:0} to{opacity:1} }

/* Dashboard cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 1px 3px rgba(9,30,66,.12); }
.stat .num { font-size: 30px; font-weight: 700; color: #0b3d91; }
.stat .lbl { color: #6b778c; font-size: 13px; }

.panel { background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 1px 3px rgba(9,30,66,.12); margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 17px; }
.stage-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: #e6edf7; color: #0b3d91; border-radius: 999px; padding: 5px 12px; font-size: 13px; }

/* Tables & lists */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eef1f5; }
th { color: #6b778c; font-weight: 600; }
tr:hover td { background: #f8fafd; }
.badge { display: inline-block; background: #e6edf7; color: #0b3d91; border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.badge.admin { background: #fff3e0; color: #b26a00; }
.badge.viewer { background: #e3fcef; color: #006644; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.link { color: #0f5fd6; cursor: pointer; text-decoration: underline; font-size: 13px; }

.toast {
  position: fixed; bottom: 22px; right: 22px; background: #172b4d; color: #fff;
  padding: 12px 18px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.3); font-size: 14px;
}

/* Forms: grid layout used in JD add/edit */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid label { font-weight: 600; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid textarea { padding: 9px 10px; border: 1px solid #dfe1e6; border-radius: 6px; font-size: 14px; font-family: inherit; resize: vertical; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.toolbar-actions { display: flex; gap: 8px; }

/* Filter bar (candidates) */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { font-size: 12px; }
.filters input, .filters select { padding: 7px 9px; font-size: 13px; }
.filters input { min-width: 130px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(9,30,66,.5);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100;
  overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 10px; padding: 22px; width: 100%; max-width: 720px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.modal h2 { margin: 0 0 16px; font-size: 19px; }
.status-open { background: #e3fcef; color: #006644; }
.status-on-hold, .status-paused { background: #fff3e0; color: #b26a00; }
.status-closed { background: #ffebe6; color: #bf2600; }
.status-archived { background: #eef1f5; color: #6b778c; }
.tick { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; font-size: 12px; white-space: nowrap; }
.tick input { margin: 0; }
.geo-block { border: 1px solid #e4e7ec; border-radius: 8px; padding: 12px; background: #fafbfc; }
.geo-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #6b778c; margin: 0 0 8px; }
.geo-title + .form-grid { margin-bottom: 12px; }
.geo-block .form-grid:last-child { margin-bottom: 0; }
.seg { display: inline-flex; gap: 4px; margin: 0 0 10px; padding: 3px; background: #eef1f5; border-radius: 8px; }
.seg-btn { border: 0; background: transparent; padding: 6px 12px; font-size: 13px; border-radius: 6px; cursor: pointer; color: #344563; }
.seg-btn.active { background: #fff; box-shadow: 0 1px 2px rgba(9,30,66,.25); font-weight: 600; }
.ph-row input[disabled] { background: #eef1f5; color: #6b778c; cursor: not-allowed; }
input[readonly] { background: #f4f5f7; color: #6b778c; cursor: not-allowed; }
.view-toggle { display: inline-flex; gap: 4px; margin-bottom: 12px; padding: 3px; background: #eef1f5; border-radius: 8px; }
.view-toggle .seg-btn.active { background: #fff; box-shadow: 0 1px 2px rgba(9,30,66,.25); font-weight: 600; }
#cand-table { width: 100%; border-collapse: collapse; }
#cand-table th, #cand-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eef1f5; vertical-align: top; white-space: normal; }
.cv-btn { white-space: nowrap; font-weight: 600; }
.icobtn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: 1px solid #d9dee7; border-radius: 6px; background: #fff; color: #4a5568; cursor: pointer; text-decoration: none; vertical-align: middle; }
.icobtn:hover { background: #f1f5f9; color: #1f6feb; }
.icobtn.danger:hover { color: #d93838; border-color: #e2b6b6; }
.icobtn a { display: flex; }
.cell-actions { white-space: nowrap; }
.cell-actions .icobtn { margin-right: 4px; }
.cc-top { display: flex; align-items: center; gap: 8px; }
.cc-top .icobtn { margin-left: 4px; }
.cc-jd { margin-left: auto; }
.cc-cv { margin-top: 8px; }
.chip-score { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; background: #e8f3ff; color: #1f6feb; }
.cand-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cand-card { border: 1px solid #e4e7ec; border-radius: 10px; padding: 12px 14px; background: #fff; box-shadow: 0 1px 2px rgba(9,30,66,.08); }
.cc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cc-jd { font-size: 12px; color: #44546f; background: #eef1f5; border-radius: 20px; padding: 2px 8px; white-space: nowrap; }
.cc-role { margin: 6px 0 4px; font-size: 14px; font-weight: 600; color: #172b4d; }
.cc-meta { font-size: 12px; color: #44546f; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.cc-skills { margin-top: 8px; font-size: 12px; color: #6b778c; }
.cc-bottom { margin-top: 10px; padding-top: 10px; border-top: 1px solid #eef1f5; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cc-bottom .cand-status { flex: 1; min-width: 130px; }

/* ---------- analytics charts ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; margin-bottom: 14px; }
.chart-card h3 { margin: 0 0 2px; font-size: 15px; color: #172b4d; }
.chart-box { position: relative; width: 100%; height: 260px; margin-top: 10px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

/* ---------- 3D chart (plotly) ---------- */
.chart-card-3d { margin-top: 14px; }
.chart-box-3d { position: relative; width: 100%; height: 520px; }
.chart-box-3d .js-plotly-plot { width: 100% !important; height: 100% !important; }

/* ---------- collapsible data panels (show/hide) ---------- */
.data-panel .data-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; user-select: none; }
.data-panel .data-body { margin-top: 10px; }
.data-panel .data-body.collapsed { display: none; }
/* toggle switch */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cfd8e3; border-radius: 22px; transition: .2s; }
.toggle .slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(9,30,66,.3); }
.toggle input:checked + .slider { background: #1f6feb; }
.toggle input:checked + .slider:before { transform: translateX(18px); }
