@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --text: #152033;
  --muted: #718096;
  --line: #e6ebf2;
  --primary: #5b5ce2;
  --primary-deep: #4748c8;
  --primary-soft: #eeeeff;
  --cyan: #09b8cb;
  --cyan-soft: #e8f9fb;
  --positive: #15956f;
  --positive-soft: #e8f8f2;
  --negative: #e05262;
  --negative-soft: #feeff1;
  --warning: #e59b28;
  --sidebar: #10182c;
  --shadow: 0 10px 30px rgba(22, 34, 55, 0.055);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: 230px;
  flex-direction: column;
  padding: 24px 16px 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 92%, rgba(91, 92, 226, 0.24), transparent 32%),
    var(--sidebar);
  color: #f8fafc;
  transition: width 200ms ease, transform 200ms ease;
}

.sidebar::after {
  display: none;
}

.sidebar__head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 22px;
}

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

.sidebar-toggle {
  display: grid;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
  color: #8f9bb2;
  cursor: pointer;
  place-items: center;
  transition: 160ms ease;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar-toggle svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: currentColor;
  transform: rotate(180deg);
  transition: transform 180ms ease;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #8f9bb2;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: 180ms ease;
}

.nav-item__icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  color: currentColor;
  place-items: center;
}

.nav-item__icon svg,
.logout-button__icon svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.nav-item__icon--text {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.045);
  color: white;
}

.nav-item--active {
  border-color: rgba(129, 130, 255, 0.16);
  background: rgba(91, 92, 226, 0.18);
  color: #a9aaff;
}

.sidebar__footer {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 0;
}

.logout-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
  color: #cbd5e1;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: 160ms ease;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.logout-button__icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
}

.main-content {
  min-height: 100vh;
  margin-left: 230px;
  padding: 0 32px 44px;
  transition: margin-left 200ms ease;
}

@media (min-width: 761px) {
  body.sidebar-collapsed .sidebar {
    width: 76px;
    padding-inline: 12px;
  }

  body.sidebar-collapsed .sidebar__head {
    justify-content: center;
  }

  body.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(0deg);
  }

  body.sidebar-collapsed .nav-item,
  body.sidebar-collapsed .logout-button {
    justify-content: center;
    gap: 0;
    padding-inline: 0;
  }

  body.sidebar-collapsed .nav-item span:not(.nav-item__icon),
  body.sidebar-collapsed .logout-button__text {
    display: none;
  }

  body.sidebar-collapsed .main-content {
    margin-left: 76px;
  }
}

.topbar {
  display: flex;
  min-height: 97px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.filters,
.filter-group {
  display: flex;
  align-items: center;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: 160ms ease;
}

.button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button--primary {
  background: var(--primary);
  box-shadow: 0 7px 18px rgba(91, 92, 226, 0.2);
  color: white;
}

.button--primary:hover {
  background: var(--primary-deep);
  transform: translateY(-1px);
}

.button--primary:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.button--ghost {
  border-color: var(--line);
  background: white;
}

.button--ghost:hover {
  background: var(--panel-muted);
}

.button--dark {
  border-color: #17213a;
  background: #17213a;
  color: white;
}

.button--dark:hover {
  background: #0f172a;
  transform: translateY(-1px);
}

.button--danger {
  border-color: rgba(224, 82, 98, .22);
  background: var(--negative-soft);
  color: var(--negative);
}

.button--danger:hover {
  border-color: rgba(224, 82, 98, .38);
  background: #fde5e8;
}

.filters {
  position: sticky;
  z-index: 20;
  top: 0;
  align-items: flex-end;
  gap: 18px;
  margin: 0 -32px;
  padding: 16px 32px;
  border-bottom: 1px solid rgba(230, 235, 242, 0.85);
  background: rgba(245, 247, 251, 0.93);
  backdrop-filter: blur(14px);
}

.filter-group {
  gap: 9px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.custom-select {
  position: relative;
  min-width: 175px;
}

.custom-select__button {
  display: flex;
  width: 100%;
  min-width: 155px;
  height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 0 8px 18px rgba(20, 32, 52, 0.04);
}

.custom-select__button::after {
  width: 7px;
  height: 7px;
  border-right: 2px solid #8b96aa;
  border-bottom: 2px solid #8b96aa;
  content: '';
  transform: rotate(45deg) translateY(-2px);
  transition: 160ms ease;
}

.custom-select.is-open .custom-select__button::after {
  transform: rotate(225deg) translateY(-1px);
}

.custom-select__menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  display: none;
  max-height: 270px;
  overflow-y: auto;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 18px 48px rgba(20, 32, 52, 0.16);
}

.custom-select.is-open .custom-select__menu {
  display: flex;
}

.custom-select__option {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 8px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.custom-select__option:hover,
.custom-select__option[aria-selected="true"] {
  background: var(--primary-soft);
  color: var(--primary);
}

.custom-select__button:focus,
.table-search input:focus {
  border-color: #b9b9f8;
  box-shadow: 0 0 0 3px rgba(91, 92, 226, 0.09);
}

.compare-arrow {
  display: grid;
  width: 28px;
  height: 38px;
  margin-top: 19px;
  color: #a4aec0;
  place-items: center;
}

.compare-arrow svg {
  display: block;
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.filter-source {
  margin-left: auto;
}

.filter-source .custom-select {
  min-width: 190px;
}

.icon-button,
.mobile-menu,
.modal__close {
  display: inline-grid;
  border: 0;
  cursor: pointer;
  place-items: center;
}

.icon-button {
  width: 38px;
  height: 38px;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  color: var(--muted);
}

.icon-button:hover {
  color: var(--primary);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button img {
  width: 17px;
  height: 17px;
  display: block;
}

.icon-button.is-spinning img {
  animation: spin 0.7s linear infinite;
}

.dashboard-loading {
  display: flex;
  min-height: 420px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
}

.dashboard-loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1s ease-in-out infinite;
}

.dashboard-loading span:nth-child(2) { animation-delay: 0.15s; }
.dashboard-loading span:nth-child(3) { animation-delay: 0.3s; }
.dashboard-loading p { margin: 0 0 0 6px; font-size: 14px; font-weight: 600; }

.section-block {
  scroll-margin-top: 90px;
  padding-top: 27px;
}

.section-heading,
.panel__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.section-heading {
  margin-bottom: 15px;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

.legend-dot--previous { background: #cbd5e1; }
.legend-dot--current { background: var(--primary); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.kpi-card {
  position: relative;
  min-height: 136px;
  padding: 13px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi-card::after {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--stage-color, var(--primary));
  content: '';
  opacity: 0.85;
}

.kpi-card__title {
  display: flex;
  min-height: 22px;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.kpi-card__title strong {
  font-size: 13px;
  font-weight: 800;
}

.kpi-card__title span {
  color: #a0aabc;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.kpi-card__main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 7px;
  margin-top: 7px;
}

.kpi-card__value {
  min-width: 0;
}

.kpi-card__value strong {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.055em;
}

.kpi-card__deltas {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 3px;
  margin-top: 5px;
  text-align: right;
}

.kpi-card__deltas .delta {
  padding: 0;
  background: transparent;
  font-size: 12px;
}

.kpi-card__previous {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #f0f2f6;
  color: var(--muted);
  font-size: 12px;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.delta--up {
  background: var(--positive-soft);
  color: var(--positive);
}

.delta--down {
  background: var(--negative-soft);
  color: var(--negative);
}

.delta--flat {
  background: #f1f4f8;
  color: #7b879a;
}

.reference-grid {
  display: grid;
  grid-template-columns: minmax(290px, 1fr) minmax(340px, 1.25fr) minmax(240px, 0.82fr);
  gap: 14px;
  margin-top: 16px;
  scroll-margin-top: 90px;
}

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel__header {
  min-height: 43px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.panel-note {
  color: #9aa5b6;
  font-size: 14px;
  font-weight: 600;
}

.drop-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.drop-item {
  display: grid;
  grid-template-columns: 80px minmax(60px, 1fr) 55px;
  align-items: center;
  gap: 10px;
}

.drop-item__label {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-item__track {
  height: 8px;
  overflow: hidden;
  border-radius: 5px;
  background: #f1f3f7;
}

.drop-item__bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--negative);
}

.drop-item--positive .drop-item__bar {
  background: var(--positive);
}

.drop-item__value {
  min-width: 48px;
  text-align: right;
  font-size: 14px;
  font-weight: 800;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-color: #cbd3df transparent;
  scrollbar-width: thin;
}

.data-table th {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  color: #909bae;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: right;
  text-transform: uppercase;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table td {
  padding: 8px;
  border-bottom: 1px solid #eff2f6;
  text-align: right;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: #fbfcfe;
}

.table-change {
  font-weight: 800;
  white-space: nowrap;
}

.table-change.delta--up {
  background: transparent;
}

.table-change.delta--down {
  background: transparent;
}

.table-change.delta--flat {
  background: transparent;
}

.change-bar {
  display: grid;
  grid-template-columns: 52px minmax(48px, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 108px;
}

.change-bar > strong {
  color: var(--negative);
  font-size: 12px;
  text-align: right;
}

.change-bar > span {
  height: 10px;
  overflow: hidden;
  border-radius: 2px;
  background: #fde1e5;
}

.change-bar i {
  display: block;
  height: 100%;
  background: #f05261;
}

.change-bar--up > strong {
  color: var(--positive);
}

.change-bar--up > span {
  background: #dff4ec;
}

.change-bar--up i {
  background: var(--positive);
}

.data-table__stage {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.data-table__stage i {
  width: 7px;
  height: 7px;
  border-radius: 3px;
  background: var(--stage-color);
}

.table-primary {
  font-weight: 800;
}

.table-muted {
  display: block;
  margin-top: 1px;
  color: #a3adbc;
  font-size: 12px;
}

.panel--sources {
  margin-top: 16px;
  scroll-margin-top: 90px;
}

.sources-section__header {
  margin-bottom: 12px;
}

.table-search {
  position: relative;
  width: 220px;
}

.table-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  color: var(--text);
  font-size: 14px;
}

.data-table--sources td {
  padding-top: 9px;
  padding-bottom: 9px;
}

.source-tables-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.source-table-card {
  min-width: 0;
  padding: 18px;
}

.source-table-card h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.2;
}

.source-stage-head {
  background: var(--stage-color) !important;
  color: #0f172a !important;
  text-align: center !important;
}

.data-table--sources th,
.data-table--sources td {
  padding-right: 7px;
  padding-left: 7px;
}

.data-table--sources th:not(:first-child),
.data-table--sources td:not(:first-child) {
  text-align: right;
}

.source-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
}

.employees-page {
  padding-bottom: 28px;
}

.employees-toolbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin: 0 -32px;
  padding: 16px 32px;
  border-bottom: 1px solid rgba(230, 235, 242, 0.85);
  background: rgba(245, 247, 251, 0.93);
  backdrop-filter: blur(14px);
}

.employees-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.employees-toolbar .custom-select {
  min-width: 190px;
}

.employees-filter-field .custom-select {
  width: 250px;
  min-width: 250px;
}

.employees-sync-button {
  min-height: 38px;
}

.employees-sync-button img {
  display: block;
  width: 17px;
  height: 17px;
  filter: brightness(0) invert(1);
}

.employees-sync-button.is-spinning img {
  animation: spin 0.7s linear infinite;
}

.employees-updated {
  margin: 0 0 9px auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.employees-loading {
  display: flex;
  min-height: 360px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
}

.employees-loading[hidden] {
  display: none;
}

.employees-loading > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1s ease-in-out infinite;
}

.employees-loading > span:nth-child(2) { animation-delay: 0.15s; }
.employees-loading > span:nth-child(3) { animation-delay: 0.3s; }

.employees-loading p {
  margin: 0 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}

.employees-empty {
  max-width: 600px;
  margin: 28px auto 0;
  text-align: center;
}

.employees-empty p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.employees-dashboard[hidden] {
  display: none;
}

.employees-stage-cards {
  display: grid;
  grid-template-columns: repeat(7, minmax(136px, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.employee-stage-card {
  position: relative;
  min-width: 0;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
}

.employee-stage-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--stage-color);
  content: '';
}

.employee-stage-card__top {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: #536176;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.employee-stage-card__top > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.employee-stage-card__top small {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.employee-stage-card__dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--stage-color);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--stage-color) 13%, transparent);
}

.employee-stage-card > strong {
  display: block;
  margin-top: 13px;
  color: #172238;
  font-size: clamp(20px, 1.55vw, 27px);
  font-weight: 800;
  line-height: 1;
}

.employee-stage-card__track {
  display: block;
  height: 5px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

.employee-stage-card__track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--stage-color);
}

.employee-stage-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.employee-stage-card__meta b {
  font-size: 14px;
}

.employees-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  margin-top: 18px;
}

.employees-content-main {
  display: grid;
  min-width: 0;
  gap: 18px;
}

.employees-insights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.employees-table-panel {
  margin-top: 0;
  padding: 20px 0 0;
  overflow: hidden;
}

.employees-table-heading {
  padding: 0 20px;
}

.employees-table-heading .panel-lead {
  margin: 5px 0 0;
}

.employees-period {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.employees-table-scroll {
  border-top: 1px solid var(--line);
}

.employees-table {
  min-width: 1510px;
  font-size: 14px;
}

.employees-table th,
.employees-table td {
  height: 54px;
  padding: 9px 10px;
  font-size: 14px;
  text-align: center;
}

.employees-table thead th {
  color: #68758a;
  font-size: 14px;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: none;
  white-space: nowrap;
}

.employees-head-groups th {
  height: 38px;
  background: #f4f6fa;
  color: #526075;
}

.employees-head-columns th {
  height: 54px;
  background: #fafbfc;
}

.employees-table .employee-stage-head {
  box-shadow: inset 0 3px var(--stage-color);
}

.employee-sort-button {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 2px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  font-weight: inherit;
  line-height: 1.25;
  text-align: center;
}

.employee-sort-button:hover,
.employee-sort-button.is-active {
  background: rgba(91, 92, 226, 0.08);
  color: var(--primary-deep);
}

.employees-table thead tr:first-child > th:first-child .employee-sort-button {
  justify-content: flex-start;
  text-align: left;
}

.employee-sort-state {
  display: block;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--primary-deep);
}

.employee-sort-state svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.employee-sort-state:empty {
  display: none;
}

.employees-table thead tr:first-child > th:first-child,
.employees-table tbody td:first-child,
.employees-table tfoot th:first-child {
  position: sticky;
  z-index: 2;
  left: 0;
  min-width: 220px;
  max-width: 260px;
  background: white;
  text-align: left;
}

.employees-table thead tr:first-child > th:first-child {
  z-index: 4;
  background: #f4f6fa;
}

.employees-table tfoot th:first-child {
  z-index: 3;
  background: #f4f6fa;
}

.employees-table tbody tr:hover td:first-child {
  background: #fbfcfe;
}

.employees-head-columns th:first-child {
  position: static;
  min-width: 0;
  max-width: none;
  background: #fafbfc;
  text-align: center;
}

.employees-table tbody td:nth-child(n+2):nth-child(-n+8) {
  color: #243147;
  font-weight: 750;
}

.employees-table tbody tr:nth-child(even) td {
  background: #fbfcfe;
}

.employees-table tbody tr:hover td {
  background: #f7f9fd;
}

.employee-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.employee-name__content {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  flex: 1;
  flex-direction: column;
  gap: 4px;
}

.employee-name__content > strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-name__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.employee-rank {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 9px;
  background: #f0f3f8;
  color: #667389;
  font-size: 14px;
  font-weight: 800;
  place-items: center;
}

.employee-inactive {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: #f1f4f8;
  color: #7b879a;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.employee-rate-cell {
  min-width: 96px;
}

.employee-rate-pill {
  position: relative;
  display: grid;
  width: 82px;
  min-height: 32px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #f1f4f8;
  color: #667389;
  place-items: center;
}

.employee-rate-pill i {
  position: absolute;
  z-index: 0;
  inset: 0 auto 0 0;
  width: var(--rate-progress);
  background: rgba(91, 92, 226, 0.12);
}

.employee-rate-pill strong {
  position: relative;
  z-index: 1;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.employee-rate-pill--good {
  background: #edfaf5;
  color: #087e5a;
}

.employee-rate-pill--good i {
  background: rgba(21, 149, 111, 0.14);
}

.employee-rate-pill--neutral {
  background: #edf4ff;
  color: #2d67ba;
}

.employee-rate-pill--neutral i {
  background: rgba(47, 111, 237, 0.13);
}

.employee-rate-pill--low {
  background: #fff1f3;
  color: #ce3f51;
}

.employee-rate-pill--low i {
  background: rgba(224, 82, 98, 0.14);
}

.employee-rate-pill--empty {
  color: #8792a4;
}

.employee-rate-pill--over {
  box-shadow: inset 0 0 0 1px currentColor;
}

.employee-rate-cell--final .employee-rate-pill {
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.employees-table tfoot th {
  height: 50px;
  border-top: 2px solid var(--line);
  background: #f4f6fa;
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
  text-align: center;
  text-transform: none;
}

.employee-rating-card {
  padding: 18px;
}

.employee-rating-card__heading {
  margin-bottom: 16px;
}

.employee-rating-card__eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.employee-rating-card h2 {
  margin: 0;
  font-size: 16px;
}

.employee-rating-list {
  display: grid;
  gap: 12px;
}

.employee-rating-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 8px;
}

.employee-rating-position {
  color: #8792a4;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.employee-rating-name {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-rating-track {
  position: relative;
  grid-column: 2;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

.employee-rating-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--positive);
}

.employee-rating-card--weak .employee-rating-track i {
  background: var(--negative);
}

.employee-rating-item > strong {
  grid-column: 3;
  grid-row: 1 / span 2;
  font-size: 14px;
  text-align: right;
}

.employee-rating-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.employees-transition-panel {
  padding: 20px 0 12px;
  overflow: hidden;
}

.employees-transition-heading {
  padding: 0 20px 16px;
}

.employees-transition-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

.employees-transition-chart {
  min-width: 1160px;
  padding: 12px 20px 8px;
}

.employee-transition-row {
  display: grid;
  grid-template-columns: 190px repeat(6, minmax(135px, 1fr));
  min-height: 43px;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #edf1f5;
}

.employee-transition-row:last-child {
  border-bottom: 0;
}

.employee-transition-row > strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-transition-row--head {
  min-height: 52px;
  color: #68758a;
  font-size: 14px;
  font-weight: 800;
}

.employee-transition-label {
  position: relative;
  padding-left: 14px;
  font-size: 14px;
  line-height: 1.25;
}

.employee-transition-label::before {
  position: absolute;
  top: 4px;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--transition-color);
  content: '';
}

.employee-transition-value {
  display: grid;
  grid-template-columns: minmax(60px, 1fr) 58px;
  align-items: center;
  gap: 7px;
}

.employee-transition-value > i {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

.employee-transition-value > i b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--transition-color);
}

.employee-transition-value em {
  color: #526075;
  font-size: 14px;
  font-style: normal;
  font-weight: 750;
  text-align: right;
  white-space: nowrap;
}

.employee-transition-label--new_to_working,
.employee-transition-value--new_to_working { --transition-color: #16a36f; }
.employee-transition-label--working_to_psm,
.employee-transition-value--working_to_psm { --transition-color: #2f6fed; }
.employee-transition-label--psm_to_pstl,
.employee-transition-value--psm_to_pstl { --transition-color: #8b5cf6; }
.employee-transition-label--pstl_to_vstl,
.employee-transition-value--pstl_to_vstl { --transition-color: #f59e0b; }
.employee-transition-label--vstl_to_invoice,
.employee-transition-value--vstl_to_invoice { --transition-color: #ec4899; }
.employee-transition-label--invoice_to_success,
.employee-transition-value--invoice_to_success { --transition-color: #14a89a; }

.source-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  place-items: center;
}

.cell-change {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 700;
}

.cell-change--up { color: var(--positive); }
.cell-change--down { color: var(--negative); }

.empty-row td {
  padding: 35px;
  color: var(--muted);
  text-align: center !important;
}

.error-state {
  max-width: 470px;
  margin: 90px auto;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  text-align: center;
}

.error-state > span {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 15px;
  border-radius: 50%;
  background: var(--negative-soft);
  color: var(--negative);
  font-size: 20px;
  font-weight: 800;
  place-items: center;
}

.error-state p {
  color: var(--muted);
}

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-open {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 15, 30, 0.62);
  backdrop-filter: blur(5px);
}

.modal__card {
  position: relative;
  z-index: 1;
  width: min(540px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  background: white;
  box-shadow: 0 30px 90px rgba(7, 13, 28, 0.28);
  animation: modal-in 180ms ease-out;
}

.modal__card h2 {
  font-size: 22px;
}

.modal__lead {
  margin: 7px 35px 20px 0;
  color: var(--muted);
  font-size: 14px;
}

.modal__close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f4f6f9;
  color: #7f8a9d;
  font-size: 20px;
}

.dropzone {
  display: flex;
  min-height: 170px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
  border: 1.5px dashed #cdd3df;
  border-radius: 14px;
  background: #fafbfe;
  cursor: pointer;
  text-align: center;
  transition: 160ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dropzone__icon {
  display: grid;
  width: 45px;
  height: 45px;
  margin-bottom: 12px;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary);
  place-items: center;
}

.dropzone strong {
  font-size: 14px;
}

.dropzone > span:last-child {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.format-hint {
  margin-top: 13px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f6f8fb;
  color: var(--muted);
  font-size: 14px;
}

.format-hint strong {
  display: block;
  margin-bottom: 4px;
  color: #59667b;
}

.format-hint code {
  white-space: normal;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
}

.import-result {
  margin-top: 13px;
  padding: 11px 13px;
  border-radius: 9px;
  background: var(--positive-soft);
  color: var(--positive);
  font-size: 14px;
  font-weight: 600;
}

.import-result__warnings {
  margin-top: 8px;
  color: var(--text);
  font-weight: 500;
}

.import-result__warnings ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.import-result__warnings li + li {
  margin-top: 4px;
}

.import-result.is-error {
  background: var(--negative-soft);
  color: var(--negative);
}

.toast-stack {
  position: fixed;
  z-index: 150;
  right: 20px;
  bottom: 20px;
  display: flex;
  width: min(360px, calc(100vw - 40px));
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--positive);
  border-radius: 10px;
  background: white;
  box-shadow: 0 14px 40px rgba(18, 28, 48, 0.16);
  font-size: 14px;
  font-weight: 600;
  animation: toast-in 220ms ease-out;
}

.toast--error {
  border-left-color: var(--negative);
}

.auth-page {
  min-height: 100vh;
  background: var(--bg);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: white;
  box-shadow: 0 24px 70px rgba(22, 34, 55, 0.12);
}

.login-card h1 {
  margin-bottom: 22px;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #566276;
  font-size: 14px;
  font-weight: 800;
}

.login-card input {
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  font-size: 16px;
}

.login-card input:focus {
  border-color: #b9b9f8;
  box-shadow: 0 0 0 3px rgba(91, 92, 226, 0.09);
}

.login-card .button {
  width: 100%;
  margin-top: 8px;
}

.login-error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--negative-soft);
  color: var(--negative);
  font-size: 14px;
  font-weight: 800;
}

.sources-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(420px, 1.2fr);
  gap: 16px;
  padding-top: 27px;
}

.sources-page {
  display: grid;
  gap: 16px;
  padding-top: 27px;
}

.sources-page .sources-layout {
  padding-top: 0;
}

.source-selector-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.source-selector-panel h2,
.bitrix-months-panel h2 {
  margin: 0 0 5px;
}

.source-selector-panel .panel-lead,
.bitrix-months-panel .panel-lead {
  margin: 0;
}

.source-switch {
  display: inline-grid;
  min-width: 330px;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-muted);
}

.source-switch button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: 160ms ease;
}

.source-switch button:hover {
  color: var(--text);
}

.source-switch button.is-active {
  background: white;
  color: var(--primary-deep);
  box-shadow: 0 5px 16px rgba(20, 32, 52, 0.09);
}

.source-mode {
  min-width: 0;
}

.bitrix-source-grid {
  display: grid;
  grid-template-columns: minmax(440px, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
}

.bitrix-months-panel {
  margin-top: 16px;
}

.bitrix-log-panel {
  margin-top: 16px;
}

.bitrix-log-panel .panel-lead {
  margin-bottom: 0;
}

.data-table--bitrix-log th:first-child,
.data-table--bitrix-log td:first-child {
  white-space: nowrap;
}

.log-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--positive-soft);
  color: var(--positive);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.log-status--error {
  background: var(--negative-soft);
  color: var(--negative);
}

.log-message {
  min-width: 280px;
  max-width: 620px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.connection-status,
.package-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--negative-soft);
  color: var(--negative);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.connection-status.is-connected,
.package-status {
  background: var(--positive-soft);
  color: var(--positive);
}

.package-status--partial {
  background: #fff6e7;
  color: #b56d00;
}

.settings-form,
.sync-form {
  display: grid;
  gap: 14px;
}

.account-settings-page {
  display: grid;
  gap: 18px;
}

.direct-dashboard {
  display: grid;
  gap: 18px;
}

.direct-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.direct-toolbar h2,
.direct-account-card h2,
.direct-modal__head h2,
.direct-empty h2 {
  margin: 0;
}

.direct-toolbar .panel-lead {
  margin: 5px 0 0;
}

.direct-toolbar__actions,
.direct-connection-row__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.direct-sync-button img {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1);
}

.direct-notice {
  padding: 13px 16px;
  border: 1px solid rgba(21, 149, 111, .2);
  border-radius: 12px;
  background: var(--positive-soft);
  color: var(--positive);
  font-size: 14px;
  font-weight: 700;
  white-space: pre-line;
}

.direct-notice--error {
  border-color: rgba(224, 82, 98, .2);
  background: var(--negative-soft);
  color: var(--negative);
}

.direct-empty {
  display: grid;
  min-height: 240px;
  align-content: center;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.direct-empty p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
}

.direct-empty--error {
  border-color: rgba(224, 82, 98, .25);
}

.direct-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 340px));
  justify-content: start;
  gap: 14px;
}

.direct-account-card {
  position: relative;
  display: flex;
  min-height: 310px;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.direct-account-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: #9ca3af;
  content: '';
}

.direct-account-card--good::before { background: var(--positive); }
.direct-account-card--warn::before { background: var(--warning); }
.direct-account-card--crit::before,
.direct-account-card--error::before { background: var(--negative); }

.direct-account-card__head {
  min-width: 0;
}

.direct-account-card__head h2 {
  font-size: 18px;
}

.direct-account-card__head a,
.direct-account-card__head > div > span {
  display: inline-block;
  max-width: 100%;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.direct-status {
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.direct-status--good { color: var(--positive); }
.direct-status--warn { color: #b66f00; }
.direct-status--crit,
.direct-status--error { color: var(--negative); }

.direct-balance {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 2px 10px;
  padding: 14px 15px;
  border-radius: 14px;
  background: var(--panel-muted);
}

.direct-balance__head {
  display: flex;
  grid-column: 1 / -1;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.direct-balance__head > span:first-child {
  color: var(--muted);
  font-size: 14px;
}

.direct-balance strong {
  font-size: clamp(26px, 2.2vw, 34px);
  line-height: 1.1;
  letter-spacing: -.045em;
}

.direct-balance small {
  padding-bottom: 3px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.direct-account-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.direct-account-meta > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.direct-account-meta dt,
.direct-account-meta dd {
  margin: 0;
  font-size: 14px;
}

.direct-account-meta dt { color: var(--muted); }
.direct-account-meta dd { font-weight: 700; text-align: right; }

.direct-account-error {
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--negative-soft);
  color: var(--negative);
  font-size: 14px;
}

.direct-card-settings {
  width: 100%;
  margin-top: auto;
}

.direct-modal {
  position: fixed;
  z-index: 110;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  background: rgba(9, 15, 30, .64);
  backdrop-filter: blur(5px);
}

.direct-modal[hidden] { display: none; }

.direct-modal__panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: 0 30px 90px rgba(7, 13, 28, .3);
}

.direct-modal__panel--wide { width: min(860px, 100%); }

.direct-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.direct-token-field {
  height: auto !important;
  min-height: 108px;
  padding-top: 11px;
  resize: vertical;
}

.direct-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.direct-checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 700;
}

.direct-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.direct-connection-list {
  display: grid;
  gap: 10px;
}

.direct-connection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-muted);
}

.direct-connection-row > div:first-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.direct-connection-row span,
.direct-connection-row small {
  color: var(--muted);
  font-size: 14px;
}

.direct-connection-row small { color: var(--negative); }

.direct-log-output {
  min-height: 240px;
  max-height: 60vh;
  margin: 0;
  padding: 15px;
  overflow: auto;
  border-radius: 12px;
  background: #111827;
  color: #dbeafe;
  font: 14px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.account-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.account-settings-card {
  align-self: start;
}

.account-settings-card .panel__header {
  margin-bottom: 18px;
}

.account-settings-card .panel__header h2 {
  margin: 0 0 5px;
}

.account-settings-card .panel-lead {
  margin: 0;
}

.account-password-form {
  max-width: 520px;
}

.settings-message,
.settings-empty {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
}

.settings-message--success {
  border: 1px solid rgba(17, 148, 94, .22);
  background: var(--positive-soft);
  color: var(--positive);
}

.settings-message--error {
  border: 1px solid rgba(224, 67, 77, .22);
  background: var(--negative-soft);
  color: var(--negative);
}

.settings-empty {
  background: var(--panel-muted);
  color: var(--muted);
}

.blocked-ip-table code {
  font-size: 14px;
}

.button--compact {
  min-height: 36px;
  padding: 7px 12px;
}

.field-label {
  display: grid;
  gap: 7px;
  color: #657287;
  font-size: 14px;
  font-weight: 800;
}

.settings-form .field-input,
.sync-form .field-input {
  height: 44px;
}

.field-input[readonly] {
  background: var(--panel-muted);
  color: var(--muted);
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.sync-last-run {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.sync-last-run.is-error {
  color: var(--negative);
}

.modal__actions--left {
  justify-content: flex-start;
}

.sync-form {
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
}

.sync-form .button {
  min-height: 44px;
}

.period-name {
  display: grid;
  gap: 2px;
}

.period-name small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  gap: 7px;
}

.panel-lead {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.bitrix-dev {
  display: grid;
  gap: 16px;
  padding-top: 18px;
}

.bitrix-hero,
.bitrix-toolbar,
.bitrix-filters {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.bitrix-hero {
  align-items: stretch;
}

.bitrix-toolbar .panel-lead {
  max-width: 880px;
  margin-bottom: 0;
}

.bitrix-hero .panel-lead {
  max-width: 760px;
  margin-bottom: 0;
}

.bitrix-eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 14px;
  font-weight: 900;
}

.bitrix-decision {
  display: grid;
  min-width: 280px;
  max-width: 390px;
  gap: 5px;
  padding: 16px;
  border-radius: 14px;
  background: #f8fafc;
}

.bitrix-decision span,
.bitrix-decision em {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  font-weight: 700;
}

.bitrix-decision strong {
  color: var(--text);
  font-size: 19px;
  font-weight: 900;
}

.bitrix-filters {
  align-items: center;
  justify-content: flex-start;
}

.bitrix-filters label {
  display: flex;
  min-width: 210px;
  flex-direction: column;
  gap: 6px;
  color: #657287;
  font-size: 14px;
  font-weight: 800;
}

.field-input {
  width: 100%;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: white;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(20, 32, 52, 0.04);
}

.field-input:focus {
  border-color: #b9b9f8;
  box-shadow: 0 0 0 3px rgba(91, 92, 226, 0.09);
}

.bitrix-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
}

.bitrix-pipeline-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 10px;
}

.bitrix-pipeline-card {
  display: grid;
  min-height: 126px;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfe;
}

.bitrix-pipeline-card.is-active {
  border-color: rgba(91, 92, 226, 0.35);
  background: var(--primary-soft);
}

.bitrix-pipeline-card strong,
.bitrix-pipeline-card span,
.bitrix-pipeline-card b,
.bitrix-pipeline-card em {
  display: block;
}

.bitrix-pipeline-card strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.bitrix-pipeline-card span,
.bitrix-pipeline-card em {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  font-weight: 700;
}

.bitrix-pipeline-card b {
  color: var(--text);
  font-size: 23px;
  line-height: 1.05;
}

.bitrix-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.bitrix-card span,
.bitrix-card em {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  font-weight: 700;
}

.bitrix-card strong {
  display: block;
  margin: 5px 0 2px;
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
  line-height: 1.1;
}

.bitrix-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.bitrix-grid--wide-left {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
}

.bitrix-note h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.bitrix-note p {
  margin: 0;
  color: var(--muted);
}

.bitrix-note p + p {
  margin-top: 10px;
}

.bitrix-note strong {
  color: var(--text);
  font-weight: 900;
}

.bitrix-warning {
  color: var(--warning) !important;
  font-weight: 800;
}

.bitrix-note--error {
  border-color: #ffd3d9;
  background: var(--negative-soft);
}

.bitrix-note--error p {
  color: var(--negative);
  font-weight: 700;
}

.bitrix-list {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding-left: 20px;
  color: #48566c;
  font-size: 14px;
}

.bitrix-steps {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 22px;
  color: #48566c;
  font-size: 14px;
}

.bitrix-steps li::marker {
  color: var(--primary);
  font-weight: 900;
}

.bitrix-field-hint {
  margin-top: 0;
}

.bitrix-field-hint + .bitrix-field-hint {
  margin-top: 10px;
}

.data-table--bitrix code {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 7px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
}

.data-table--bitrix tfoot th {
  padding: 9px 8px;
  border-top: 1px solid var(--line);
  background: #f4f7fb;
  text-align: right;
}

.data-table--bitrix tfoot th:first-child {
  text-align: left;
}

.icon-button--inline {
  margin-top: 0;
}

.file-name {
  font-weight: 800;
}

.table-action {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.table-action--danger {
  border-color: #ffd3d9;
  background: var(--negative-soft);
  color: var(--negative);
}

.table-action:disabled {
  cursor: wait;
  opacity: 0.6;
}

.mobile-menu {
  display: none;
}

[hidden] {
  display: none !important;
}

@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(15px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1550px) {
  .employees-stage-cards {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }

  .employees-content-grid { grid-template-columns: minmax(0, 1fr); }
  .employees-insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1260px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

  .kpi-card {
    min-height: 138px;
  }

}

@media (max-width: 1000px) {
  .direct-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .direct-toolbar__actions {
    justify-content: flex-start;
  }

  .employees-stage-cards {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .employees-insights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reference-grid {
    grid-template-columns: 1fr;
  }

  .sources-layout {
    grid-template-columns: 1fr;
  }

  .bitrix-source-grid {
    grid-template-columns: 1fr;
  }

  .source-tables-grid {
    grid-template-columns: 1fr;
  }

  .bitrix-summary-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .bitrix-pipeline-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .bitrix-grid--wide-left,
  .bitrix-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .direct-account-grid {
    grid-template-columns: 1fr;
  }

  .direct-toolbar__actions,
  .direct-connection-row,
  .direct-connection-row__actions {
    align-items: stretch;
    flex-direction: column;
  }

  .direct-toolbar__actions .button,
  .direct-connection-row__actions .button {
    width: 100%;
  }

  .direct-account-card__head {
    flex-direction: column;
  }

  .direct-form-row {
    grid-template-columns: 1fr;
  }

  .direct-modal {
    align-items: flex-start;
    padding: 10px;
  }

  .direct-modal__panel {
    max-height: calc(100vh - 20px);
  }

  .account-settings-grid {
    grid-template-columns: 1fr;
  }

  body.menu-open {
    overflow: hidden;
  }

  .sidebar {
    z-index: 80;
    width: 230px;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }

  .sidebar__head {
    display: none;
  }

  .sidebar-mobile-close {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    margin: 0 0 18px auto;
    padding: 0 3px 0 10px;
    border: 0;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
  }

  .sidebar-mobile-close span:first-child {
    display: grid;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.075);
    color: white;
    font-size: 24px;
    line-height: 1;
    place-items: center;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 70;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(10, 16, 30, 0.46);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(9, 15, 30, 0.3);
  }

  body.menu-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .nav-item span:not(.nav-item__icon),
  .sidebar__footer {
    display: block;
  }

  .nav-item__icon {
    display: grid;
  }

  .nav-item {
    justify-content: flex-start;
    align-items: center;
  }

  .main-content {
    margin-left: 0;
    padding-inline: 16px;
  }

  .topbar {
    min-height: 80px;
  }

  .mobile-menu {
    display: flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    margin-right: -9px;
    border-radius: 8px;
    background: transparent;
  }

  .mobile-menu span {
    width: 17px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
  }

  h1 { font-size: 20px; }
  .button--primary { padding-inline: 12px; }

  .filters {
    position: relative;
    top: auto;
    flex-wrap: wrap;
    margin-inline: -16px;
    padding: 14px 16px 18px;
  }

  .employees-toolbar {
    position: relative;
    top: auto;
    flex-wrap: wrap;
    margin-inline: -16px;
    padding: 14px 16px 18px;
  }

  .employees-toolbar label {
    min-width: 0;
    flex: 1;
  }

  .employees-toolbar .employees-filter-field {
    width: 100%;
    flex-basis: 100%;
  }

  .employees-filter-field .custom-select,
  .employees-filter-field .custom-select__button {
    width: 100%;
    min-width: 0;
  }

  .employees-toolbar .custom-select,
  .employees-toolbar .custom-select__button {
    width: 100%;
    min-width: 0;
  }

  .employees-updated {
    width: 100%;
    margin: 0;
  }

  .employees-table-panel {
    margin-top: 0;
  }

  .employees-table-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .employees-table thead tr:first-child > th:first-child,
  .employees-table tbody td:first-child,
  .employees-table tfoot th:first-child {
    min-width: 190px;
    max-width: 210px;
  }

  .employees-stage-cards {
    gap: 10px;
    margin-top: 16px;
  }

  .employee-stage-card {
    padding: 14px;
  }

  .employees-content-grid {
    margin-top: 14px;
  }

  .employees-insights {
    grid-template-columns: minmax(0, 1fr);
  }

  .employees-transition-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .filter-group--periods label {
    flex: 1;
  }

  .custom-select,
  .custom-select__button,
  .filter-source .custom-select {
    width: 100%;
    min-width: 0;
  }

  .filter-source {
    flex: 1;
    margin-left: 0;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .kpi-card {
    padding: 14px;
  }

  .kpi-card__value strong { font-size: 22px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .panel { padding: 17px; }
  .panel__header--responsive { align-items: stretch; flex-direction: column; }
  .table-search { width: 100%; }

  .source-selector-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .source-switch {
    width: 100%;
    min-width: 0;
  }

  .sync-form {
    grid-template-columns: 1fr;
  }

  .bitrix-hero,
  .bitrix-toolbar,
  .bitrix-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .bitrix-decision {
    max-width: none;
  }

  .bitrix-filters label,
  .bitrix-filters .custom-select,
  .bitrix-filters .custom-select__button {
    width: 100%;
    min-width: 0;
  }

  .bitrix-summary-grid {
    grid-template-columns: 1fr;
  }

  .bitrix-pipeline-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 128px; }
  .filter-group--periods { align-items: flex-end; }
  .compare-arrow { margin-bottom: 0; }
  .modal__card { padding: 23px 18px; }
  .login-card { padding: 24px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
