:root {
  --ink: #0F172A;
  --ink-soft: #334155;
  --muted: #64748B;
  --muted-soft: #94A3B8;
  --line: #E2E8F0;
  --line-soft: #F1F5F9;
  --surface: #FFFFFF;
  --bg: #F8FAFC;
  --primary: #0B5FFF;
  --primary-soft: rgba(11, 95, 255, 0.08);

  --green: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;
  --violet: #7C3AED;
  --sky: #0EA5E9;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 999px;
  --space: 24px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, system-ui, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

button { font-family: inherit; }

.hidden { display: none !important; }

/* ============ LOGIN ============ */
#login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #F8FAFC 0%, #EEF2FF 100%);
  z-index: 10;
}

.login-card {
  background: var(--surface);
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 380px;
  max-width: 92vw;
}

.login-logo {
  height: 32px;
  margin-bottom: 28px;
  object-fit: contain;
  object-position: left center;
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.login-card p.subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

button.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--ink);
  color: white;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.12s;
}

button.btn-primary:hover:not(:disabled) { opacity: 0.88; }
button.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: #FEF2F2;
  color: var(--red);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* ============ APP SHELL ============ */
#app-shell { min-height: 100vh; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-header img.logo { height: 24px; object-fit: contain; }

.app-header h1 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.005em;
}

.app-header .spacer { flex: 1; }

.app-header .meta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.btn-secondary {
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-soft);
  transition: border-color 0.12s, background 0.12s;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--ink-soft);
  background: var(--line-soft);
}

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

main {
  padding: 24px 28px 56px;
  max-width: auto;
  margin: 0 auto;
}

/* ============ FILTERS ============ */
.filters-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

.filters-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  transition: background 0.12s;
}

.filters-panel > summary::-webkit-details-marker { display: none; }
.filters-panel > summary:hover { background: var(--line-soft); }

.filters-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  font-weight: 600;
}

.filters-hint {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
}

.filters-chevron {
  color: var(--muted);
  transition: transform 0.18s ease;
}

.filters-panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

.filters-panel[open] .filters-chevron { transform: rotate(180deg); }
.filters-panel[open] .filters-hint { display: none; }

.filters-panel[open] .filters-grid,
.filters-panel[open] .filters-actions { padding-left: 20px; padding-right: 20px; }
.filters-panel[open] .filters-grid { padding-top: 20px; }
.filters-panel[open] .filters-actions { padding-bottom: 20px; }

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.filters-grid .field { margin: 0; }
.filters-grid .field label { font-size: 10px; }
.filters-grid .field input,
.filters-grid .field select { padding: 7px 10px; font-size: 12px; }

.filters-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

/* ============ KPI CARDS ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.kpi-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  padding: 10px 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}

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

/* ============ CARDS & CHARTS ============ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.card h3 {
  font-size: 12px;
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card.full { grid-column: 1 / -1; }

.chart-host {
  position: relative;
  height: 280px;
}
.chart-host.tall { height: 360px; }

/* ============ PIPELINE ============ */
.pipeline-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.pipeline-summary .mini {
  text-align: left;
}

.pipeline-summary .mini .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.pipeline-summary .mini .val {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

#chart-funnel { display: flex; flex-direction: column; gap: 10px; }

.pipe-row {
  display: grid;
  grid-template-columns: 180px 1fr 80px;
  align-items: center;
  gap: 16px;
}

.pipe-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pipe-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}

.pipe-rate {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pipe-bar {
  height: 28px;
  background: var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.pipe-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-sm);
  transition: width 0.3s ease;
}

.pipe-applied .pipe-fill   { background: #0B5FFF; }
.pipe-interview .pipe-fill { background: #0EA5E9; }
.pipe-offer .pipe-fill     { background: #F59E0B; }
.pipe-hired .pipe-fill     { background: #10B981; }

.pipe-value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

/* ============ TABLES ============ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

.table-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.table-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.table-head .meta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.table-head .spacer { flex: 1; }

.table-head select,
.table-head input {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
}
.table-head input { min-width: 200px; }

.table-scroll {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th, td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}

th {
  background: var(--surface);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line);
}

tbody tr:hover { background: var(--line-soft); }
tbody tr.row-alert { background: #FEF2F2; }
tbody tr.row-alert:hover { background: #FEE2E2; }

.cell-mono {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Monaco, monospace;
  font-size: 11px;
  color: var(--muted);
}

.empty {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 12px;
}

/* ============ PILLS ============ */
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.status-open, .status-approved {
  background: #ECFDF5; color: #047857; border-color: #A7F3D0;
}
.status-closed {
  background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE;
}
.status-paused {
  background: #FFFBEB; color: #B45309; border-color: #FDE68A;
}
.status-canceled, .status-rejected {
  background: #FEF2F2; color: #B91C1C; border-color: #FECACA;
}
.status-pending {
  background: #F5F3FF; color: #6D28D9; border-color: #DDD6FE;
}

.type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--surface);
}

.type-job { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }
.type-req { background: #F5F3FF; color: #6D28D9; border-color: #DDD6FE; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-danger { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.badge-ok { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }

/* ============ PROGRESS BAR ============ */
.progress {
  width: 120px;
  height: 6px;
  background: var(--line-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

/* ============ HEATMAP ============ */
.heatcell {
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ============ LOADER ============ */
#global-loader {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--sky));
  background-size: 200% 100%;
  animation: loaderSlide 1.2s linear infinite;
  z-index: 100;
}

@keyframes loaderSlide {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============ TOASTS ============ */
#toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  font-size: 12px;
  font-weight: 500;
  min-width: 240px;
  transition: opacity 0.3s, transform 0.3s;
}

.toast-info { border-left: 3px solid var(--primary); }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-out { opacity: 0; transform: translateX(20px); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  main { padding: 16px; }
  .app-header { padding: 12px 16px; gap: 12px; }
  .app-header h1 { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .pipe-row { grid-template-columns: 100px 1fr 60px; gap: 8px; }
  .filters-grid { grid-template-columns: repeat(2, 1fr); }
}
