*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--main-bg);
  color: var(--text-primary);
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent-bright);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.22s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 12px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-text {
  min-width: 0;
  flex: 1;
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sidebar-brand p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sidebar-toggle {
  flex-shrink: 0;
  color: var(--text-muted);
}

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

.sidebar-toggle-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.22s ease;
}

.app-shell.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.app-shell.sidebar-collapsed .sidebar-brand {
  flex-direction: column;
  align-items: center;
  padding: 14px 8px 10px;
}

.app-shell.sidebar-collapsed .sidebar-brand-text,
.app-shell.sidebar-collapsed .nav-section-title,
.app-shell.sidebar-collapsed .nav-item-label,
.app-shell.sidebar-collapsed .sidebar-footer-text {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.app-shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px;
  gap: 0;
}

.app-shell.sidebar-collapsed .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  margin-left: 0;
  min-width: 1.1rem;
  padding: 0 4px;
  font-size: 9px;
}

.app-shell.sidebar-collapsed .nav-item {
  position: relative;
}

.app-shell.sidebar-collapsed .sidebar-nav {
  padding: 12px 8px 20px;
}

.app-shell.sidebar-collapsed .sidebar-footer {
  padding: 12px 8px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 24px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: var(--section-header-size);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--section-header-color);
  padding: 8px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--icon-gap);
  min-height: var(--item-height);
  padding: var(--item-padding);
  border: none;
  border-radius: var(--item-radius);
  background: transparent;
  color: var(--item-inactive-text);
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg {
  width: var(--icon-size);
  height: var(--icon-size);
  flex-shrink: 0;
}

.nav-item-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.nav-item.active svg {
  color: var(--item-active-text);
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--badge-bg);
  color: var(--badge-text);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.sidebar-backdrop-mobile {
  display: none;
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.prototype-banner {
  background: rgba(59, 130, 246, 0.12);
  border-bottom: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--accent-bright);
  padding: 10px 24px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.prototype-banner strong {
  font-weight: 600;
}

.topbar {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.5);
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-sidebar-toggle {
  flex-shrink: 0;
}

.topbar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.topbar-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.content {
  flex: 1;
  padding: 20px 24px 32px;
  overflow: auto;
}

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-card .value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-card.accent .value {
  color: var(--accent-bright);
}

.stat-card.warning .value {
  color: var(--warning);
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.filter-group.search {
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.filter-group input,
.filter-group select {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--main-bg);
  color: var(--text-primary);
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--item-hover-bg);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
}

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  font-size: 13px;
}

.candidates-table {
  table-layout: fixed;
  min-width: 0;
}

.candidates-table th {
  position: relative;
  overflow: hidden;
}

.candidates-table th .th-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 10px;
}

.candidates-table td {
  overflow: hidden;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  z-index: 2;
}

.col-resize-handle::after {
  content: "";
  position: absolute;
  top: 20%;
  bottom: 20%;
  right: 4px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.15s;
}

.col-resize-handle:hover::after,
.is-resizing-columns .col-resize-handle::after {
  background: rgba(59, 130, 246, 0.65);
}

body.is-resizing-columns {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing-columns * {
  cursor: col-resize !important;
}

thead {
  background: rgba(0, 0, 0, 0.2);
}

th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--text-secondary);
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

tbody tr.selected {
  background: rgba(59, 130, 246, 0.08);
}

.candidate-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.candidate-name {
  font-weight: 600;
  color: var(--text-primary);
}

.candidate-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-contact {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.badge-review {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.badge-drop {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-pending {
  background: var(--badge-bg);
  color: var(--badge-text);
}

.badge-ai {
  border: 1px dashed rgba(255, 255, 255, 0.15);
}

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-weight: 700;
  background: var(--surface-elevated);
}

.score-high {
  color: #4ade80;
}

.score-mid {
  color: #fbbf24;
}

.score-low {
  color: #f87171;
}

.human-select {
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--main-bg);
  color: var(--text-primary);
  font-size: 12px;
  min-width: 110px;
}

.candidates-table .human-select {
  width: 100%;
  min-width: 0;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-width: 148px;
}

.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-link-action {
  height: 30px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-link-action.is-disabled,
.link-unavailable {
  height: 30px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  cursor: help;
  white-space: nowrap;
}

.col-text .cell-text {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}

.cell-text.muted {
  color: var(--text-muted);
  font-style: italic;
}

.screening-line + .screening-line {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

/* Resume panel */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
}

.panel-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.resume-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  width: var(--panel-width);
  height: var(--panel-height);
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transform: translate(-50%, -48%) scale(0.97);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.25s ease, opacity 0.2s ease, visibility 0.2s;
  z-index: 101;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.resume-panel.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.panel-header h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.panel-header .sub {
  font-size: 13px;
  color: var(--text-muted);
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.panel-body {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

.panel-details {
  width: min(360px, 38%);
  flex-shrink: 0;
  padding: 18px 20px;
  border-right: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  overflow-y: auto;
}

.panel-details strong {
  color: var(--text-primary);
}

.panel-details .detail-block {
  margin-bottom: 14px;
}

.panel-details .detail-block:last-child {
  margin-bottom: 0;
}

.panel-frame-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #0a0c10;
  position: relative;
}

.panel-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.panel-expand {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  background: rgba(15, 17, 23, 0.92);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.panel-expand:hover {
  background: var(--surface-elevated);
}

.panel-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  background: rgba(10, 12, 16, 0.92);
  z-index: 2;
}

.panel-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 24px;
  text-align: center;
  background: #0a0c10;
  z-index: 3;
}

.panel-placeholder svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.panel-loading[hidden],
.panel-placeholder[hidden],
.panel-frame-wrap iframe[hidden],
.panel-expand[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .resume-panel {
    width: 96vw;
    height: 92vh;
  }

  .panel-body {
    flex-direction: column;
  }

  .panel-details {
    width: 100%;
    max-height: 34%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 900px) {
  .sidebar-backdrop-mobile {
    display: block;
  }

  .topbar-sidebar-toggle {
    display: inline-flex !important;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.22s ease, width 0.22s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }

  .app-shell.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop-mobile {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 89;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
  }

  .app-shell.sidebar-mobile-open .sidebar-backdrop-mobile {
    opacity: 1;
    visibility: visible;
  }

  .sidebar-toggle {
    display: none;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }
}

.nav-count {
  min-width: 1.5rem;
  text-align: center;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  padding: 2px 7px;
}

.settings-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 960px;
}

.page-view[hidden] {
  display: none !important;
}

.settings-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

.settings-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.settings-hint {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-form {
  display: grid;
  gap: 14px;
  max-width: 420px;
}

.settings-form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.settings-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.form-message {
  font-size: 13px;
}

.form-message.success {
  color: var(--success, #3ecf8e);
}

.form-message.error {
  color: var(--danger, #f87171);
}

.users-table td,
.users-table th {
  font-size: 13px;
}

.user-status-active {
  color: var(--success, #3ecf8e);
}

.user-status-inactive {
  color: var(--text-muted);
}

.reports-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.reports-filters {
  margin-bottom: 0;
}

.reports-grid {
  display: grid;
  gap: 20px;
}

.reports-card-wide {
  grid-column: 1 / -1;
}

.report-status-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.report-stat-card {
  background: var(--main-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.report-stat-card.status-contact {
  border-color: rgba(34, 197, 94, 0.35);
}

.report-stat-card.status-review {
  border-color: rgba(245, 158, 11, 0.35);
}

.report-stat-card.status-drop {
  border-color: rgba(239, 68, 68, 0.35);
}

.report-stat-card.status-pending {
  border-color: rgba(107, 114, 128, 0.35);
}

.report-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.report-stat-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.report-stat-pct {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.report-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 48px;
  gap: 12px;
  align-items: center;
}

.report-bar-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.report-bar-track {
  height: 10px;
  background: var(--main-bg);
  border-radius: 999px;
  overflow: hidden;
}

.report-bar-fill {
  height: 100%;
  border-radius: 999px;
  min-width: 0;
  transition: width 0.25s ease;
}

.report-bar-fill.status-contact {
  background: var(--success);
}

.report-bar-fill.status-review {
  background: var(--warning);
}

.report-bar-fill.status-drop {
  background: var(--danger);
}

.report-bar-fill.status-pending {
  background: var(--text-muted);
}

.report-bar-count {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

.reports-table th,
.reports-table td {
  font-size: 13px;
  text-align: left;
}

.reports-table th:not(:first-child),
.reports-table td:not(:first-child) {
  text-align: center;
  width: 88px;
}

.reports-total-row {
  background: rgba(255, 255, 255, 0.03);
}

.reports-total-row td {
  border-top: 1px solid var(--border);
}

.num-contact {
  color: var(--success);
}

.num-review {
  color: var(--warning);
}

.num-drop {
  color: var(--danger);
}

.num-pending {
  color: var(--text-muted);
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.selection-count {
  font-size: 13px;
  color: var(--text-muted);
}

.col-check {
  text-align: center;
}

.col-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

tr.row-selected {
  background: rgba(59, 130, 246, 0.08);
}

@media (max-width: 900px) {
  .report-status-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-bar-row {
    grid-template-columns: 64px 1fr 40px;
  }
}
