/* Admin console */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(410px, 94vw);
  padding: 32px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--sh-lg), var(--hairline);
  animation: popIn .5s var(--ease) both;
}
.login-card .mark-lg {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: var(--r);
  background: linear-gradient(150deg, var(--accent-2), var(--accent));
  color: #07182f;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(var(--accent-rgb), 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.login-actions { display: flex; justify-content: center; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-link {
  display: inline-flex;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.login-link:hover { color: var(--text); }

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: rgba(13, 15, 19, 0.96);
}
.sidebar .brand,
.sidebar .brand:link,
.sidebar .brand:visited,
.sidebar .brand:hover {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .2px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: linear-gradient(150deg, var(--accent-2), var(--accent));
  color: #07182f;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.nav-list {
  display: grid;
  gap: 4px;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nav-item .nav-ico {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: color .18s var(--ease);
}
.nav-item .nav-ico .ic { width: 19px; height: 19px; }
.nav-item em { font-style: normal; }
.nav-item:hover { color: var(--text); background: var(--glass); }
.nav-item:hover .nav-ico { color: var(--text-2); }
.nav-item.active { color: var(--accent-hi); background: var(--accent-soft); }
.nav-item.active .nav-ico { color: var(--accent); }
.sidebar-lang { display: flex; justify-content: center; padding: 6px 4px 10px; }
.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.main {
  min-width: 0;
  padding: 26px 34px 42px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.page-head h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.15;
}
.page-head .sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13.5px;
}
.view { display: none; }
.view.active { display: block; }

.grid { display: grid; gap: 14px; }
.stat-grid { grid-template-columns: repeat(4, minmax(160px, 1fr)); margin-bottom: 14px; }
.balance-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-bottom: 14px; }

.panel,
.card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh), var(--hairline);
}
.card { transition: border-color .2s var(--ease), transform .2s var(--ease); }
.card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.panel + .panel { margin-top: 14px; }
/* В сетках интервалы держит gap — сбрасываем «стековый» отступ второй панели,
   иначе второй столбец смещается вниз и панели выглядят разной высоты. */
.grid .panel + .panel,
.two-col .panel + .panel,
.settings-grid .panel + .panel { margin-top: 0; }
.view.active { animation: fadeInUp .4s var(--ease) both; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h3 { margin: 0; font-size: 16px; }
/* Балансовые плашки — единый вид; выделяем только числом-акцентом. */
.accent-panel .balance-value { color: var(--accent-hi); }
.card .c-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card .c-label { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.card .c-value,
.balance-value {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 31px;
  font-weight: 800;
}
.card .c-ico {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.card .c-ico .ic { width: 17px; height: 17px; }
.balance-hint {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 13px;
}
.split-balance {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.split-balance div {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
}
.split-balance span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.split-balance b {
  display: block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 24px;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}
td {
  padding: 12px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
}
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody tr:last-child td { border-bottom: 0; }
.empty {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filters input,
.filters select {
  width: auto;
  min-width: 150px;
  padding: 8px 10px;
  font-size: 13px;
}
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-2);
  border-radius: var(--r-xs);
  background: var(--glass-2);
  color: var(--muted);
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.icon-btn .ic { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger { color: #f0a3a3; }
.icon-btn.danger:hover { color: #fecaca; border-color: rgba(248,113,113,.4); background: var(--red-soft); }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
/* Ручной запуск: панели одной высоты, кнопка запуска прижата к низу. */
#view-create .form-panel { display: flex; flex-direction: column; height: 100%; }
#view-create .form-panel > .btn.wide:last-child { margin-top: auto; }
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.form-panel .btn.wide { margin-top: 6px; }
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
  margin-bottom: 14px;
}
.seg button {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent); color: #07182f; }
.qty-picker {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: -4px 0 12px;
}
.qty-picker button {
  min-height: 31px;
  padding: 6px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.qty-picker button:hover { border-color: var(--accent-line); color: var(--text); }

.info-line {
  margin: 10px 0 14px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12.5px;
}
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.switch:last-child { border-bottom: 0; }
.switch b { display: block; font-size: 14px; }
.switch span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.toggle {
  position: relative;
  width: 44px;
  height: 25px;
  flex: 0 0 auto;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  background: var(--surface-3);
  cursor: pointer;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--text-2);
  transition: left .18s ease, background .18s ease;
}
.toggle.on { border-color: transparent; background: var(--accent); }
.toggle.on::after { left: 21px; background: #07182f; }
.msg-count {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.batches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.batch-card {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
}
.batch-card h4 {
  margin: 0 0 4px;
  font-size: 15px;
}
.b-meta {
  color: var(--muted);
  font-size: 12px;
}
.b-bar {
  height: 6px;
  margin: 12px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}
.b-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.b-nums {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 11.5px;
}
.b-nums b {
  display: block;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
}
.b-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.codes-out {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(53, 208, 127, 0.28);
  border-radius: var(--r);
  background: var(--green-soft);
}
.co-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.codes-box {
  max-height: 220px;
  overflow-y: auto;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
}
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr);
  gap: 14px;
  align-items: stretch;
}
/* Панель-помощник (ссылка для покупателя) — по центру по вертикали, без пустоты. */
.settings-grid > .panel:last-child { display: flex; flex-direction: column; justify-content: center; }
.order-id-box {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
  color: var(--accent-hi);
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
}

.d-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.d-modal-overlay.open { opacity: 1; pointer-events: auto; }
.d-modal {
  width: min(720px, calc(100vw - 40px));
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--sh-lg), var(--hairline);
  animation: popIn .3s var(--ease) both;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-head h3 { margin: 0; }
.x-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 19px;
  cursor: pointer;
}
.x-btn:hover { color: var(--text); background: var(--surface-3); }
.kv {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 9px 14px;
  font-size: 13.5px;
}
.kv .k { color: var(--muted); }
.kv .v { min-width: 0; word-break: break-word; color: var(--text-2); }
pre.json {
  max-height: 260px;
  overflow: auto;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
  color: var(--accent-hi);
  font-family: var(--mono);
  font-size: 11.5px;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    z-index: 80;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .nav-list { display: flex; }
  .sidebar-foot { margin: 0 0 0 auto; display: flex; padding-top: 0; border-top: 0; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { padding: 20px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .balance-grid, .two-col, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sidebar .brand span:not(.brand-mark) { display: none; }
  .nav-item { padding: 8px; font-size: 0; gap: 0; }
  .nav-item span { margin: 0; }
  .page-head { flex-direction: column; }
  .stat-grid, .split-balance, .form-grid-2 { grid-template-columns: 1fr; }
  .filters input, .filters select { width: 100%; }
  .co-head { flex-direction: column; align-items: stretch; }
  .kv { grid-template-columns: 1fr; }
}

.brand-mark,
.login-card .mark-lg {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background-color: rgba(7, 24, 47, 0.72);
  background-image: url('/assets/msq-boost-logo.png');
  background-position: center;
  background-size: 86% auto;
  background-repeat: no-repeat;
  box-shadow: none;
  color: transparent;
  font-size: 0;
}

.login-card .mark-lg {
  background-size: 88% auto;
  box-shadow: none;
}
