:root {
  --crm-white: #ffffff;
  --crm-ink: #111111;
  --crm-text: #1f2328;
  --crm-muted: #667085;
  --crm-line: #e4e7ec;
  --crm-soft: #f6f7f9;
  --crm-soft-strong: #eef1f5;
  --crm-red: #e30613;
  --crm-red-dark: #b9000a;
  --crm-yellow: #ffd400;
  --crm-green: #159447;
  --crm-shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
  --crm-radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  text-size-adjust: 100%;
}

body.crm-admin-page {
  min-height: 100vh;
  margin: 0;
  color: var(--crm-text);
  background:
    linear-gradient(180deg, #ffffff 0, #ffffff 140px, #f4f5f7 140px, #f4f5f7 100%);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.crm-shell {
  width: min(100% - 40px, 1480px);
  margin: 0 auto;
  padding: 18px 0 32px;
}

.crm-topbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(320px, 1.15fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 72px;
}

.crm-brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.crm-brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: var(--crm-ink);
  background: var(--crm-yellow);
  border-radius: var(--crm-radius);
  font-size: 20px;
}

.crm-brand strong,
.crm-status-band h1,
.crm-panel h2,
.crm-kpis strong {
  color: var(--crm-ink);
  font-weight: 900;
}

.crm-brand strong {
  display: block;
  font-size: 21px;
  line-height: 1.05;
}

.crm-brand small {
  display: block;
  margin-top: 2px;
  color: var(--crm-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.crm-token-form {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  background: var(--crm-white);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.05);
}

.crm-token-form label,
.crm-filters label {
  color: var(--crm-muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.crm-token-form input,
.crm-filters input,
.crm-filters select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--crm-ink);
  background: var(--crm-white);
  border: 1px solid var(--crm-line);
  border-radius: 6px;
  outline: 0;
}

.crm-token-form input:focus,
.crm-filters input:focus,
.crm-filters select:focus {
  border-color: var(--crm-red);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.1);
}

.crm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.crm-button,
.crm-icon-button,
.crm-text-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  color: var(--crm-ink);
  background: var(--crm-white);
  border: 1px solid var(--crm-line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.crm-button {
  padding: 0 14px;
}

.crm-button-dark {
  color: var(--crm-white);
  background: var(--crm-ink);
  border-color: var(--crm-ink);
}

.crm-button:hover,
.crm-icon-button:hover,
.crm-text-button:hover {
  border-color: var(--crm-red);
}

.crm-button-dark:hover {
  background: var(--crm-red);
  border-color: var(--crm-red);
}

.crm-icon-button {
  width: 42px;
  padding: 0;
}

.crm-text-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--crm-red);
  background: #fff6f7;
  border-color: #ffd9dc;
}

.crm-status-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.45fr);
  gap: 22px;
  align-items: end;
  margin-top: 18px;
  padding: 24px 0 16px;
  border-top: 1px solid var(--crm-line);
}

.crm-status-band h1 {
  margin: 0;
  font-size: clamp(30px, 3.8vw, 58px);
  line-height: 1;
  text-transform: uppercase;
}

.crm-status-band p {
  margin: 0;
  color: var(--crm-muted);
  font-size: 15px;
  line-height: 1.45;
}

.crm-status-band p.is-ok {
  color: var(--crm-green);
  font-weight: 800;
}

.crm-status-band p.is-error {
  color: var(--crm-red);
  font-weight: 800;
}

.crm-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.crm-kpis article,
.crm-panel {
  background: var(--crm-white);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  box-shadow: var(--crm-shadow);
}

.crm-kpis article {
  display: grid;
  gap: 4px;
  min-height: 112px;
  padding: 18px;
  border-left: 4px solid var(--crm-red);
}

.crm-kpis article:nth-child(4) {
  border-left-color: var(--crm-yellow);
}

.crm-kpis span,
.crm-panel-head span,
.crm-table th {
  color: var(--crm-muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.crm-kpis strong {
  font-size: 38px;
  line-height: 1;
}

.crm-kpis small {
  color: var(--crm-muted);
  font-size: 13px;
}

.crm-layout {
  display: grid;
  grid-template-columns: 255px minmax(0, 1fr) 330px;
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}

.crm-panel {
  min-width: 0;
  padding: 16px;
}

.crm-panel-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.crm-panel h2 {
  margin: 0;
  font-size: 18px;
}

.crm-filters {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 9px;
}

.crm-filter-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 5px;
}

.crm-filter-buttons button {
  min-height: 38px;
  color: var(--crm-ink);
  background: var(--crm-soft);
  border: 1px solid var(--crm-line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 850;
}

.crm-filter-buttons button:hover,
.crm-filter-buttons button.is-active {
  color: var(--crm-white);
  background: var(--crm-red);
  border-color: var(--crm-red);
}

.crm-meta-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--crm-line);
}

.crm-meta-list div {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
}

.crm-meta-list dt,
.crm-meta-list dd {
  margin: 0;
  font-size: 12px;
}

.crm-meta-list dt {
  color: var(--crm-muted);
  font-weight: 800;
}

.crm-meta-list dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--crm-ink);
}

.crm-table-wrap {
  max-height: 684px;
  overflow: auto;
  border: 1px solid var(--crm-line);
  border-radius: 7px;
}

.crm-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.crm-table th,
.crm-table td {
  padding: 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--crm-line);
}

.crm-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--crm-soft);
}

.crm-table tbody tr:hover {
  background: #fffafa;
}

.crm-time,
.crm-subtext,
.crm-cell-title small {
  color: var(--crm-muted);
  font-size: 12px;
}

.crm-cell-title {
  display: grid;
  gap: 4px;
}

.crm-cell-title strong {
  color: var(--crm-ink);
  font-size: 14px;
}

.crm-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 3px 8px;
  color: var(--crm-ink);
  background: var(--crm-soft-strong);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 900;
}

.crm-badge.is-lead {
  color: var(--crm-white);
  background: var(--crm-red);
}

.crm-badge.is-call {
  color: var(--crm-ink);
  background: var(--crm-yellow);
}

.crm-badge.is-traffic {
  color: var(--crm-green);
  background: #eaf7ef;
}

.crm-empty {
  height: 180px;
  color: var(--crm-muted);
  text-align: center;
}

.crm-side {
  display: grid;
  gap: 12px;
}

.crm-rank-list,
.crm-lead-list {
  display: grid;
  gap: 8px;
}

.crm-rank-item,
.crm-lead-item {
  display: grid;
  gap: 6px;
  padding: 11px;
  background: var(--crm-soft);
  border: 1px solid var(--crm-line);
  border-radius: 7px;
}

.crm-rank-title {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.crm-rank-title strong,
.crm-lead-item strong {
  min-width: 0;
  color: var(--crm-ink);
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.crm-rank-count {
  flex: 0 0 auto;
  color: var(--crm-white);
  background: var(--crm-red);
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 950;
}

.crm-rank-bar {
  height: 5px;
  overflow: hidden;
  background: #dde2ea;
  border-radius: 999px;
}

.crm-rank-bar span {
  display: block;
  height: 100%;
  width: var(--rank, 0%);
  background: linear-gradient(90deg, var(--crm-red), var(--crm-yellow));
}

.crm-lead-item a {
  width: fit-content;
  color: var(--crm-red);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 1180px) {
  .crm-topbar,
  .crm-status-band,
  .crm-layout {
    grid-template-columns: 1fr;
  }

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

  .crm-actions {
    justify-content: flex-start;
  }

  .crm-filters {
    position: static;
  }

  .crm-side {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .crm-shell {
    width: min(100% - 24px, 1480px);
    padding-top: 12px;
  }

  .crm-kpis,
  .crm-side {
    grid-template-columns: 1fr;
  }

  .crm-status-band h1 {
    font-size: clamp(28px, 10vw, 42px);
  }

  .crm-panel,
  .crm-kpis article {
    padding: 14px;
  }

  .crm-actions {
    display: grid;
    grid-template-columns: 42px 1fr;
  }

  .crm-actions .crm-button {
    width: 100%;
  }
}
