:root {
  --ink: #0D0F13;
  --ink-soft: #171A21;
  --bg: #14161B;
  --surface: #1C1F26;
  --border: #2B2F38;
  --text: #E7E8EA;
  --text-soft: #93989F;
  --accent: #3D8C77;
  --accent-hover: #4CA48D;
  --accent-soft: #1E3833;
  --danger: #E27373;
  --danger-soft: #3A2323;
  --font-display: 'Manrope', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--font-display); margin: 0; }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 14px; }

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
/* Чекбоксы и радио — не текстовые поля, общие стили выше (width:100%,
   паддинги, рамка) их только раздувают и сдвигают. Возвращаем нативный вид. */
input[type="checkbox"], input[type="radio"] {
  width: auto;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--accent);
  flex: none;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 12px;
}
label > input, label > select, label > textarea { margin-top: 5px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--accent-soft); color: var(--accent-hover); }
.btn-secondary:hover { background: #294a42; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #4a2b2b; }
.btn-ghost { background: transparent; color: #C7CCD6; border: 1px solid #2A3140; }
.btn-ghost:hover { background: var(--ink-soft); }
.btn-block { width: 100%; }

/* ---------- Экраны авторизации ---------- */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(61,140,119,0.20), transparent 45%),
    var(--ink);
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.auth-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}
.auth-card h1 { font-size: 21px; margin-bottom: 6px; }
.auth-sub { color: var(--text-soft); font-size: 13px; margin: 0 0 20px; line-height: 1.5; }
.auth-card label { margin-top: 16px; }
.auth-card button { margin-top: 8px; }
.auth-error {
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
  min-height: 16px;
  margin-top: 10px;
}

/* ---------- Каркас приложения ---------- */

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

.topbar {
  width: 100%;
  flex-shrink: 0;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 32px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}
.brand-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 16px; }

.nav { display: flex; flex-direction: row; gap: 8px; flex: 1; flex-wrap: wrap; }
.nav-item {
  text-align: center;
  background: transparent;
  border: none;
  color: #A9AFBC;
  padding: 13px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
}
.nav-item:hover { background: var(--ink-soft); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,0.14);
}
.nav-item.active .nav-count { background: rgba(255,255,255,0.28); }

.topbar-user { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-hover);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 700; color: #fff; }
.user-role { font-size: 11.5px; color: #8890A0; }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 20px;
}
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.view-sub { color: var(--text-soft); font-size: 12.5px; margin: 6px 0 0; max-width: 480px; line-height: 1.5; }

.stat-strip {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.stat-chip {
  font-size: 12.5px;
  color: var(--text-soft);
  font-family: var(--font-mono);
}
.stat-chip b { color: var(--text); font-family: var(--font-body); font-weight: 700; }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar input { flex: 1; min-width: 180px; }
.toolbar select { width: 200px; flex-shrink: 0; }

.quick-add {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.quick-add input {
  width: 220px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}
.quick-add .button-group { flex: 1; margin-top: 0; min-width: 200px; }
.quick-add .btn { flex-shrink: 0; }

.recruiter-stats {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 16px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.recruiter-stats:empty { display: none; }
.mini-table { width: 100%; border-collapse: collapse; min-width: 520px; }
.mini-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-soft);
  font-weight: 700;
  padding: 10px 10px;
}
.mini-table td {
  padding: 9px 10px;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.mini-table td.mini-num { font-family: var(--font-mono); color: var(--text-soft); }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; min-width: 640px; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #20232B;
}
.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.table tbody tr { cursor: pointer; transition: background 0.1s ease; }
.table tbody tr:hover { background: #22262F; }
.table tbody tr:last-child td { border-bottom: none; }
.cell-name { font-weight: 700; }
.cell-mono { font-family: var(--font-mono); color: var(--text-soft); font-size: 12.5px; }
.call-icon {
  display: none;
  text-decoration: none;
  margin-left: 4px;
  filter: grayscale(1);
  opacity: 0.75;
}
.call-icon:hover { filter: none; opacity: 1; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; }

.tag-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}
#profession-readonly { margin-top: 6px; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--text-soft); }
.empty-state p { margin-bottom: 14px; }

/* ---------- Модалки ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 30px;
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-wide { max-width: 920px; }
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none; border: none;
  font-size: 22px; color: var(--text-soft);
  width: 30px; height: 30px;
  border-radius: 50%;
}
.modal-close:hover { background: var(--bg); }

.modal-grid {
  display: grid;
  grid-template-columns: 1fr;
}
.modal-wide .modal-grid.two-col {
  grid-template-columns: 3fr 2fr;
  gap: 34px;
}
.modal-col.calls-col {
  border-left: 1px solid var(--border);
  padding-left: 30px;
}
.calls-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.calls-col-header h2 { margin-bottom: 0; }
.recruiter-badge-group { display: flex; align-items: center; gap: 8px; }
.btn-unassign {
  border: none;
  background: var(--danger-soft);
  color: var(--danger);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}
.btn-unassign:hover { opacity: 0.8; }

.form-row-buttons {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.phone-row { display: flex; gap: 8px; margin-top: 5px; }
.phone-row input { margin-top: 0; }
.btn-call { display: none; flex-shrink: 0; white-space: nowrap; }

.call-form { margin-bottom: 18px; }
#call-date-input { margin-bottom: 8px; }
.call-form-hint { font-size: 11.5px; color: var(--text-soft); margin: -4px 0 0; line-height: 1.4; }
.call-form-label { margin-bottom: 12px; }
#caller-auto-note { margin-bottom: 12px; }

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 100px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.12s ease;
}
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.call-form-row { display: flex; gap: 8px; margin-bottom: 8px; }
.call-form textarea { margin-bottom: 10px; }

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 340px;
  overflow-y: auto;
}
.timeline-item {
  position: relative;
  padding: 0 0 18px 20px;
  border-left: 2px solid var(--border);
}
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -6px; top: 2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}
.timeline-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-soft);
  margin-bottom: 3px;
}
.timeline-result { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.timeline-comment { font-size: 13px; color: var(--text-soft); line-height: 1.45; }
.timeline-comment-empty { font-style: italic; opacity: 0.7; }
.timeline-empty { color: var(--text-soft); font-size: 13px; padding: 10px 0; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
}
.toast.error { background: var(--danger); }

@media (max-width: 860px) {
  .app { min-height: 100vh; }

  .btn-call { display: inline-flex; }
  .call-icon { display: inline-block; }

  .topbar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 10px;
  }
  .brand { padding-bottom: 0; }
  .nav {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 2px;
    flex-wrap: nowrap;
  }
  .nav-item { white-space: nowrap; flex-shrink: 0; padding: 11px 18px; font-size: 14px; }
  .topbar-user { flex-direction: row; align-items: center; gap: 10px; }
  .topbar-user .user-chip { flex: 1; min-width: 0; }
  .topbar-user .btn { width: auto; flex-shrink: 0; }
  .user-name, .user-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .main { padding: 16px; }

  .view-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .view-header .btn { width: 100%; }
  .header-actions { flex-direction: column; width: 100%; }

  .toolbar { flex-direction: column; }
  .toolbar input, .toolbar select { width: 100%; min-width: 0; }

  .quick-add { flex-direction: column; align-items: stretch; }
  .quick-add input { width: 100%; }
  .quick-add .btn { width: 100%; }

  /* На iOS шрифт инпутов меньше 16px вызывает авто-зум при фокусе */
  input, select, textarea { font-size: 16px; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
  .modal-wide { max-width: 100%; }
  .modal-wide .modal-grid.two-col { grid-template-columns: 1fr; }
  .modal-col.calls-col {
    border-left: none;
    border-top: none;
    padding-left: 0;
    padding-top: 0;
    margin-top: 0;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    order: -1;
  }

  .call-form-row { flex-direction: column; }
  .form-row-buttons { flex-direction: column; }
  .form-row-buttons .btn { width: 100%; }

  .chip-btn { padding: 8px 14px; }

  .table th, .table td { padding: 10px 12px; }
}
