:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-hover: #1a1a1a;
  --border: #2a2a2a;
  --border-light: #333;
  --text: #f5f5f5;
  --text-muted: #888;
  --accent: #fff;
  --accent-hover: #e8e8e8;
  --danger: #e74c3c;
  --success: #27ae60;
  --radius: 12px;
  --radius-sm: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --duration-fast: 0.15s;
  --duration: 0.25s;
  --duration-slow: 0.4s;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-focus: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

* {
  box-sizing: border-box;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes wipPulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

@keyframes wipShine {
  0% { background-position: -120% 0; }
  100% { background-position: 220% 0; }
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  animation: fadeIn var(--duration-slow) var(--ease-out) forwards;
}

/* Login */
.page-login {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
}

.platform-bar--standalone {
  flex-shrink: 0;
}

.page-login .login-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 24px auto;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: slideUp var(--duration-slow) var(--ease-out) 0.1s both;
  transition: box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.login-card:hover {
  border-color: var(--border-light);
}

.login-card .logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 600;
}

.login-card .subtitle {
  margin: 0 0 28px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease),
    border-color var(--duration) var(--ease), transform var(--duration-fast) var(--ease);
}

.btn:active {
  transform: scale(0.98);
}

.btn-yandex {
  background: var(--accent);
  color: var(--bg);
  width: 100%;
}

.btn-yandex:hover {
  background: var(--accent-hover);
  color: var(--bg);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 1.1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-sm:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
}
#refresh {
  transition: transform var(--duration) var(--ease), background var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}
#refresh:hover {
  transform: rotate(90deg);
}
#refresh:active {
  transform: rotate(90deg) scale(0.95);
}

.login-card .error {
  margin-top: 16px;
  color: var(--danger);
  font-size: 0.9rem;
}

/* Dashboard */
.page-dashboard {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
}

.app-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* Боковое иконочное меню */
.sidebar {
  width: 64px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 8px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: transform var(--duration) var(--ease), color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.sidebar-nav-item:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
  transform: scale(1.08);
}

.sidebar-nav-item--active {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav-item--active:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.08);
}

.sidebar-icon {
  display: block;
  flex-shrink: 0;
}

.sidebar-icon--logo {
  width: 32px;
  height: 32px;
}

/* Верхняя панель платформ: Я.Директ, Авито, VK Ads */
.platform-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.platform-tiles {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex: 1;
}

.platform-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 140px;
  padding: 12px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease),
    transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.platform-tile:hover {
  border-color: var(--border-light);
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.platform-tile--active {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.platform-tile img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Инвентарь: раскрывающееся меню справа */
.inventory-wrap {
  position: relative;
}

.inventory-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.inventory-toggle:hover {
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.08);
}

.inventory-toggle .arrow {
  font-size: 0.7rem;
  opacity: 0.8;
  transition: transform var(--duration) var(--ease);
}

.inventory-wrap.open .inventory-toggle .arrow {
  transform: rotate(180deg);
}

.inventory-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px 0;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--duration) var(--ease), visibility var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}

.inventory-wrap.open .inventory-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.inventory-menu a {
  display: block;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background var(--duration) var(--ease);
}

.inventory-menu a:hover {
  background: var(--surface-hover);
}

/* Страница «в доработке» */
.page-wip .wip-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 48px 24px;
  text-align: center;
}

.page-wip .wip-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 16px;
  animation: wipPulse 2.5s var(--ease) infinite;
}

.page-wip .wip-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  opacity: 0.85;
  margin: 0;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}
.brand-logo-svg {
  color: var(--accent);
  flex-shrink: 0;
  display: block;
}

.brand {
  font-weight: 700;
  color: var(--accent);
}

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

.btn-brand-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.btn-brand-edit:hover {
  color: var(--accent);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.05);
}

.page-title {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Страница списка кабинетов */
.list-wrap {
  animation: slideUp var(--duration-slow) var(--ease-out) 0.05s both;
}

.cabinet-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.btn-add-cabinet-list {
  margin-left: auto;
}

.cabinet-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background var(--duration-fast) var(--ease), border-color var(--duration) var(--ease);
}

.cabinet-list-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
}

.cabinet-list-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cabinet-list-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

.cabinet-list-login {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.cabinet-list-setka {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cabinet-list-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-cabinet-rename {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.btn-cabinet-rename:hover {
  color: var(--accent);
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.05);
}

.btn-cabinet-rename .icon-pencil {
  display: block;
}

.btn-cabinet-status {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.btn-cabinet-status:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.04);
}

.btn-cabinet-status--blocked.is-active {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(231, 76, 60, 0.12);
}

.btn-cabinet-status--actual.is-active {
  color: var(--success);
  border-color: var(--success);
  background: rgba(39, 174, 96, 0.12);
}

@media (max-width: 600px) {
  .cabinet-list-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .cabinet-list-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .list-toolbar .btn-add-cabinet-list {
    margin-left: 0;
    width: 100%;
  }
}

/* Название аккаунта и мелкая подпись логина */
.tree-col-name {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.tree-col-name-text {
  font-weight: 500;
}

.tree-col-login-sub {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0.65;
  font-family: ui-monospace, monospace;
}

.tree-col-balance-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  margin-top: 2px;
}

/* Стрелка у средней цены с комиссией (в рублях): красная > 19.8 ₽, зелёная < 19.8 ₽ */
.price-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.85em;
  line-height: 1;
  vertical-align: middle;
}

.price-arrow--red {
  color: var(--danger);
}

.price-arrow--green {
  color: var(--success);
}

.tree-item-campaign .tree-col-name,
.tree-summary .tree-col-name {
  flex-direction: row;
  align-items: center;
}

.tree-item-campaign .tree-col-login-sub,
.tree-summary .tree-col-login-sub {
  display: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Выпадающие меню: Период и Статистика */
.period-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.period-label select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 36px 10px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  min-width: 140px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease),
    background var(--duration) var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.period-label select:hover {
  border-color: var(--border-light);
  background-color: var(--surface-hover);
}
.period-label select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
#period {
  min-width: 160px;
}
#filterCampaigns {
  min-width: 180px;
}

.custom-dates {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-dates input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.custom-dates input:hover {
  border-color: var(--border-light);
}
.custom-dates input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.custom-dates input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.7;
}

.header-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: header-spinner-rotate 0.7s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}
.header-spinner[hidden] {
  display: none;
}
@keyframes header-spinner-rotate {
  to { transform: rotate(360deg); }
}

.last-update {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.main {
  flex: 1;
  padding: 24px;
  overflow: auto;
  animation: fadeIn var(--duration-slow) var(--ease-out) 0.1s both;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  animation: pulse 1.2s var(--ease) infinite;
}

.error-block {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text-muted);
  animation: slideUp var(--duration) var(--ease-out);
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.stats-table th,
.stats-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.stats-table th {
  background: rgba(0, 0, 0, 0.2);
  font-weight: 600;
  color: var(--text-muted);
}

.stats-table tbody tr {
  transition: background var(--duration-fast) var(--ease);
}
.stats-table tbody tr:hover {
  background: var(--surface-hover);
}

.stats-table tfoot tr {
  background: rgba(0, 0, 0, 0.25);
  font-weight: 600;
}

.stats-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-table .row-error {
  color: var(--danger);
  font-size: 0.85rem;
}

/* Tree: аккаунты и кампании */
.tree-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  animation: slideUp var(--duration-slow) var(--ease-out) 0.05s both;
  transition: border-color var(--duration) var(--ease);
}

.tree-wrap-yandex-icon {
  position: absolute;
  top: -6px;
  left: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
  opacity: 1;
}

.period-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.15) 100%);
  transition: background var(--duration) var(--ease);
}

.period-totals {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 0;
}

.period-summary-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 8px;
}

.period-metric {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.period-metric-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.period-metric-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.period-currency-note {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.8;
  text-transform: none;
  letter-spacing: 0;
}

.target-price-block {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.target-price-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.target-price-input {
  width: 72px;
  padding: 6px 8px;
  font-size: 0.9rem;
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--duration) var(--ease);
}

.target-price-input:hover,
.target-price-input:focus {
  border-color: var(--border-light);
  outline: none;
}

.add-cabinet-inline {
  flex-shrink: 0;
  margin-left: auto;
}

.btn-add-cabinet {
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease),
    background var(--duration) var(--ease), transform var(--duration-fast) var(--ease);
}

.btn-add-cabinet:hover {
  color: var(--accent);
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.06);
}
.btn-add-cabinet:active {
  transform: scale(0.97);
}

.add-cabinet-to-client-wrap {
  padding: 10px 18px 14px;
  margin-top: 0;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  position: relative;
}

.add-cabinet-to-client-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px dashed var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

.add-cabinet-to-client-btn:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-light);
}

.add-cabinet-to-client-dropdown {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 100%;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  animation: slideUp var(--duration) var(--ease-out);
}

.add-cabinet-to-client-dropdown button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.85rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.add-cabinet-to-client-dropdown button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.add-cabinet-to-client-dropdown button + button {
  border-top: 1px solid var(--border);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn var(--duration) var(--ease-out);
}

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 320px;
  max-width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: modalIn var(--duration-slow) var(--ease-out);
  transition: border-color var(--duration) var(--ease);
}
.modal:focus-within {
  border-color: var(--border-light);
}

.modal-title {
  margin: 0 0 12px;
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-hint {
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-login-display {
  margin: 0 0 12px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
}

.modal-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.modal-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.95rem;
  margin-bottom: 16px;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}
.modal-input::placeholder {
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

.add-cabinet-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  margin-bottom: 8px;
}

.add-cabinet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.add-cabinet-wrap .add-cabinet-label {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.add-cabinet-input {
  min-width: 160px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

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

.add-cabinet-token-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.add-cabinet-token-form .add-cabinet-label {
  width: 100%;
  margin-bottom: 4px;
}

.login-card .token-form {
  text-align: left;
  margin-bottom: 20px;
}

.login-card .token-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.login-card .token-form input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}

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

.login-card .login-divider {
  margin: 20px 0 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.add-cabinet-wrap select {
  min-width: 220px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--bg);
}
.btn-primary:active {
  transform: scale(0.98);
}

.btn-remove {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.btn-remove:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.05);
}

.tree-header {
  display: grid;
  grid-template-columns: 36px 1fr 140px 120px 100px 160px 160px 56px;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.25);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.tree-header .tree-col-num,
.tree-col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tree {
  padding: 0;
}

.tree-item {
  border-bottom: 1px solid var(--border);
  animation: slideUp var(--duration) var(--ease-out) both;
}
.tree-item:nth-child(1) { animation-delay: 0.02s; }
.tree-item:nth-child(2) { animation-delay: 0.05s; }
.tree-item:nth-child(3) { animation-delay: 0.08s; }
.tree-item:nth-child(4) { animation-delay: 0.11s; }
.tree-item:nth-child(5) { animation-delay: 0.14s; }
.tree-item:nth-child(6) { animation-delay: 0.17s; }
.tree-item:nth-child(7) { animation-delay: 0.2s; }
.tree-item:nth-child(8) { animation-delay: 0.23s; }
.tree-item:nth-child(9) { animation-delay: 0.26s; }
.tree-item:nth-child(n+10) { animation-delay: 0.3s; }

.tree-item:last-child {
  border-bottom: none;
}

.tree-item-head {
  display: grid;
  grid-template-columns: 36px 1fr 140px 120px 100px 160px 160px 56px;
  gap: 12px;
  padding: 12px 18px;
  align-items: center;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  font-size: 0.95rem;
}

.tree-item-head:hover {
  background: var(--surface-hover);
}

.tree-item-head:focus {
  outline: 2px solid var(--border-light);
  outline-offset: -2px;
}

.tree-col-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

.tree-toggle {
  color: var(--text-muted);
  font-size: 0.85rem;
  user-select: none;
  transition: color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.tree-item-head:hover .tree-toggle {
  color: var(--text);
}
.tree-item-head[aria-expanded="true"] .tree-toggle {
  color: var(--accent);
}

.tree-item-children {
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 0 8px 18px;
  border-left: 3px solid var(--accent);
  margin-left: 18px;
  animation: fadeIn var(--duration) var(--ease-out);
}

.tree-summary {
  display: grid;
  grid-template-columns: 36px 1fr 140px 120px 100px 160px 160px 56px;
  gap: 12px;
  padding: 10px 0 10px 0;
  margin-left: -18px;
  padding-left: 18px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  border-bottom: 1px dashed var(--border);
  margin-bottom: 8px;
  animation: fadeIn var(--duration) var(--ease-out);
}

.tree-item-campaign {
  display: grid;
  grid-template-columns: 36px 1fr 140px 120px 100px 160px 160px 56px;
  gap: 12px;
  padding: 8px 0 8px 0;
  margin-left: -18px;
  padding-left: 18px;
  font-size: 0.9rem;
  transition: background var(--duration-fast) var(--ease);
}

.tree-col-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.tree-item-campaign:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tree-campaign-name {
  color: var(--text-muted);
}

.tree-loading {
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tree-item-children .row-error {
  color: var(--danger);
  padding: 12px 0;
}

@media (max-width: 900px) {
  .tree-header,
  .tree-item-head,
  .tree-summary,
  .tree-item-campaign {
    grid-template-columns: 28px 1fr 90px 80px 90px 90px 56px;
  }
  .tree-header span:nth-child(3),
  .tree-item-head .tree-col-login,
  .tree-summary .tree-col-login,
  .tree-item-campaign .tree-col-login {
    display: none;
  }
}

@media (max-width: 700px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-right {
    width: 100%;
  }
  .stats-table th, .stats-table td {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  .tree-header,
  .tree-item-head,
  .tree-summary,
  .tree-item-campaign {
    grid-template-columns: 24px 1fr 70px 70px 70px 70px 56px;
    gap: 8px;
    padding-left: 12px;
  }
  .tree-header span:nth-child(7),
  .tree-item-head .tree-col-num:last-of-type,
  .tree-summary .tree-col-num:last-of-type,
  .tree-item-campaign .tree-col-num:last-of-type {
    display: none;
  }
  .tree-item-children {
    margin-left: 12px;
    padding-left: 12px;
  }
  .tree-summary,
  .tree-item-campaign {
    margin-left: -12px;
    padding-left: 12px;
  }
  .add-cabinet-wrap {
    flex-wrap: wrap;
  }
  .add-cabinet-wrap select {
    min-width: 180px;
  }
}
