:root {
  --bg-body: #0b1120;
  --bg-main: #020617;
  --bg-card: #020617;
  --bg-card-soft: #020617;
  --bg-sidebar: #020617;
  --border-subtle: #1e293b;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --text-main: #e5e7eb;
  --text-soft: #9ca3af;
  --text-muted: #6b7280;
  --danger: #f97373;
  --success: #4ade80;
  --warn: #facc15;
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.85);
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 999px;
  --gap-lg: 24px;
  --gap-md: 16px;
  --gap-sm: 10px;
  --transition-fast: 160ms ease-out;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #0f172a 0, #020617 50%, #000 100%);
  color: var(--text-main);
}

/* LOGIN PAGE */

.page-login {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: rgba(15, 23, 42, 0.98);
  border-radius: 24px;
  border: 1px solid rgba(30, 64, 175, 0.9);
  box-shadow: var(--shadow-soft);
  padding: 18px 18px 16px;
}

.login-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  background: radial-gradient(circle at 20% 0%, #38bdf8, #1e40af);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.4);
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text-main {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.brand-text-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.login-card__header h1 {
  margin: 0 0 4px;
  font-size: 18px;
}

.login-card__header p {
  margin: 0;
  font-size: 12px;
  color: var(--text-soft);
}

.login-form {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Компактные поля именно на странице логина */
.page-login .login-label {
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
}

.page-login .input {
  height: 38px;
  line-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
}



.login-label {
  font-size: 12px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Компактные поля только на странице логина */
.login-form .input {
  height: 38px;           /* фиксированная адекватная высота */
  padding: 6px 12px;
  border-radius: 999px;
}

.input {
  flex: 1 1 20px;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.96);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  border-color: rgba(56, 189, 248, 0.9);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.login-actions {
  margin-top: 4px;
}

.btn {
  border-radius: 999px;
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, #38bdf8, #1d4ed8);
  color: #0b1120;
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn.btn--ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid rgba(51, 65, 85, 0.9);
}

.btn.btn--xs {
  padding: 4px 8px;
  font-size: 11px;
}

.login-btn {
  width: 100%;
}

.login-error {
  margin-top: 6px;
  font-size: 11px;
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border-radius: 12px;
  padding: 6px 8px;
  border: 1px solid rgba(248, 113, 113, 0.6);
}

.login-footer {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.login-form.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* CABINET LAYOUT */

body:not(.page-login) {
  display: flex;
  min-height: 100vh;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
  gap: 18px;
}

/* SIDEBAR */

.sidebar {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 24px;
  border: 1px solid rgba(30, 64, 175, 0.55);
  box-shadow: var(--shadow-soft);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 18px;
  align-self: flex-start;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}


.sidebar__client {
  padding: 10px 12px;
  border-radius: 16px;
  background: radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.08), transparent 60%);
  border: 1px solid rgba(30, 64, 175, 0.45);
}

.sidebar__client-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sidebar__client-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.sidebar__client-note {
  font-size: 12px;
  color: var(--text-soft);
}

.sidebar__nav {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), transform var(--transition-fast);
}

.nav-item:hover {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(30, 64, 175, 0.7);
  color: var(--text-main);
  transform: translateY(-1px);
}

.nav-item--active {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.18), rgba(30, 64, 175, 0.85));
  border-color: rgba(56, 189, 248, 0.8);
  color: #e5f5ff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2);
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.6);
}

.nav-item--active .nav-dot {
  background: #e5f5ff;
}

.sidebar__footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed rgba(51, 65, 85, 0.9);
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar__footer-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sidebar__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.5);
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 4px;
}

.sidebar__badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

/* MAIN AREA */

.main {
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.08), transparent 55%),
    linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.98));
  border-radius: 28px;
  border: 1px solid rgba(30, 64, 175, 0.9);
  box-shadow: var(--shadow-soft);
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: var(--gap-lg);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.main::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* HEADER */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(30, 64, 175, 0.65);
}

.header__titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header__title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header__subtitle {
  font-size: 12px;
  color: var(--text-soft);
}

.header__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.period-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(51, 65, 85, 0.9);
}

.period-switch__btn {
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.period-switch__btn--active {
  background: linear-gradient(135deg, #38bdf8, #1d4ed8);
  color: #0b1120;
  font-weight: 600;
}

.header__profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(51, 65, 85, 0.9);
  font-size: 12px;
  color: var(--text-soft);
}

.header__avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 0, #38bdf8, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.5);
}

/* VIEW SWITCHER */

.view {
  display: none;
  flex-direction: column;
  gap: var(--gap-lg);
  animation: fadeIn 0.18s ease-out;
}

.view--active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* KPI CARDS */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap-md);
}

.card {
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.08), transparent 55%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(30, 64, 175, 0.7);
  padding: 12px 12px 14px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.96));
  mix-blend-mode: soft-light;
  opacity: 0.8;
  pointer-events: none;
}

.card__inner {
  position: relative;
  z-index: 1;
}

.card__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.card__value {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 2px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.card__value-sub {
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 400;
}

.card__hint {
  font-size: 11px;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.card__delta {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.5);
}

.card__separator {
  height: 1px;
  margin: 8px 0;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(148, 163, 184, 0.35), transparent);
}

.card__pair-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-soft);
}

/* PANELS & GRID */

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1.05fr);
  gap: var(--gap-md);
}

.panel {
  background: rgba(15, 23, 42, 0.92);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(30, 64, 175, 0.6);
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.08), transparent 60%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.panel__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.panel__title {
  font-size: 13px;
  font-weight: 500;
}

.panel__subtitle {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 2px;
}

.panel__tags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-soft);
  background: rgba(15, 23, 42, 0.96);
}

.chip--active {
  border-color: rgba(56, 189, 248, 0.9);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(15, 23, 42, 0.98));
  color: #e0f2fe;
}

.chart-placeholder {
  height: 170px;
  border-radius: 14px;
  border: 1px dashed rgba(51, 65, 85, 0.9);
  background-image: linear-gradient(
    to bottom,
    rgba(15, 23, 42, 0.85),
    rgba(15, 23, 42, 0.96)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 0 6px;
}

.panel__footer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--text-soft);
  justify-content: space-between;
}

.stat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
}

.stat-list__row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.stat-list__label {
  color: var(--text-muted);
}

.stat-list__value {
  font-weight: 500;
  color: var(--text-main);
}

.stat-list__badge {
  font-size: 11px;
  color: var(--success);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap-md);
}

/* TABLE */

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

.table thead {
  background: rgba(15, 23, 42, 0.98);
}

.table th,
.table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(30, 64, 175, 0.5);
  text-align: left;
  white-space: nowrap;
}

.table th {
  font-weight: 500;
  color: var(--text-soft);
}

.table td {
  color: var(--text-main);
}

.table tr:last-child td {
  border-bottom: none;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 10px;
  color: var(--text-soft);
  background: rgba(15, 23, 42, 0.96);
}

.badge-status__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #22c55e;
}

.badge-status--ended .badge-status__dot {
  background: #f97373;
}

/* FEED */

.feed-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11px;
}

.feed-item {
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid rgba(30, 64, 175, 0.7);
}

.feed-item__time {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.feed-item__text {
  color: var(--text-soft);
}

.feed-item__accent {
  color: #e0f2fe;
  font-weight: 500;
}

/* CLIENT CARD */

.client-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.client-card {
  margin-top: 4px;
  padding: 10px 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(30, 64, 175, 0.7);
  background: rgba(15, 23, 42, 0.96);
}

.client-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.client-card__name {
  font-size: 13px;
  font-weight: 500;
}

.client-card__id {
  font-size: 11px;
  color: var(--text-muted);
}

.client-card__badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.7);
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.12);
}

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

.client-card__item {
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(30, 64, 175, 0.6);
}

.client-card__label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.client-card__value {
  font-size: 12px;
  font-weight: 500;
}

/* SETTINGS */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.settings-block {
  padding: 10px 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(30, 64, 175, 0.7);
  background: rgba(15, 23, 42, 0.96);
}

.settings-block__title {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
}

.settings-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.settings-label {
  font-size: 11px;
  color: var(--text-soft);
  min-width: 140px;
}

.settings-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  font-size: 11px;
  cursor: pointer;
}

.tag-checkbox input {
  accent-color: #38bdf8;
}

/* SWITCH (TOGGLE) */

.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  transition: 0.18s;
}

.switch__slider::before {
  content: "";
  position: absolute;
  height: 12px;
  width: 12px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background-color: #64748b;
  transition: 0.18s;
}

.switch input:checked + .switch__slider {
  background: linear-gradient(135deg, #38bdf8, #1d4ed8);
  border-color: rgba(56, 189, 248, 0.9);
}

.switch input:checked + .switch__slider::before {
  transform: translateX(14px);
  background-color: #0b1120;
}

/* RESPONSIVE */

@media (max-width: 1080px) {
  .grid-main {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 800px) {
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }

  .sidebar {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 20px;
  }

  .sidebar__nav,
  .sidebar__client,
  .sidebar__footer {
    display: none;
  }

  


  .brand-text-sub {
    display: none;
  }

  .main {
    padding: 14px 12px 16px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header__controls {
    justify-content: flex-start;
  }

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

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

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