:root{
  --bg:#f7f8fb;
  --panel:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e5e7eb;
  --border2:#eef2f7;

  --shadow: 0 10px 30px rgba(15, 23, 42, .06);
  --shadow2: 0 2px 10px rgba(15, 23, 42, .05);

  --primary:#2563eb;
  --primarySoft: rgba(37, 99, 235, .10);

  --ok:#16a34a;
  --okSoft: rgba(22, 163, 74, .10);

  --warn:#d97706;
  --warnSoft: rgba(217, 119, 6, .12);

  --danger:#dc2626;
  --dangerSoft: rgba(220, 38, 38, .10);

  --r:16px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 700px at 20% 0%, rgba(37,99,235,.10), transparent 60%),
              radial-gradient(1000px 600px at 85% 10%, rgba(22,163,74,.08), transparent 55%),
              var(--bg);
  color: var(--text);
}

.hidden{ display:none !important; }

.muted{ color: var(--muted); }
.small{ font-size: 12px; }
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* -------- AUTH SCREEN -------- */
.auth{
  min-height: 100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 24px;
}

.authCard{
  width: min(560px, 100%);
  background: rgba(255,255,255,.80);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.authTitle{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -.3px;
}
.authSub{ margin-top: 2px; }

.authInfo{
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

.chipInline{
  display:inline-block;
  margin-left: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

/* -------- APP LAYOUT -------- */
.app{
  display:grid;
  grid-template-columns: 250px 1fr;
  min-height:100vh;
}

.sidebar{
  position: sticky;
  top:0;
  height:100vh;
  padding: 16px 12px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  display:flex;
  flex-direction:column;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding: 10px 10px 14px;
}

.logo{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  letter-spacing: .3px;
  background: linear-gradient(180deg, rgba(37,99,235,.14), rgba(37,99,235,.06));
  border: 1px solid rgba(37,99,235,.18);
  box-shadow: var(--shadow2);
}
.logo.big{
  width: 54px;
  height: 54px;
  border-radius: 18px;
  font-size: 18px;
}

.brandTitle{ font-weight: 800; letter-spacing: -.2px; }
.brandSub{ font-size: 12px; color: var(--muted); margin-top: 2px; }

.nav{
  display:flex;
  flex-direction:column;
  gap: 6px;
  padding: 6px;
}
.navItem{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor:pointer;
  text-align:left;
}
.navItem:hover{
  background: rgba(15,23,42,.03);
  border-color: rgba(15,23,42,.06);
}
.navItem.active{
  background: rgba(37,99,235,.08);
  border-color: rgba(37,99,235,.18);
}
.dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(100,116,139,.35);
}
.navItem.active .dot{
  background: rgba(37,99,235,.85);
  box-shadow: 0 0 0 6px rgba(37,99,235,.12);
}

.sidebarBottom{
  margin-top:auto;
  padding: 10px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  border-top: 1px solid var(--border2);
}

.field label{
  display:block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.main{
  padding: 20px 22px 34px;
  max-width: 1180px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap: 14px;
  padding: 18px 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.h1{ font-size: 20px; font-weight: 850; letter-spacing: -.4px; }

.grid4{ display:grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.grid2{ display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 1100px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{ height:auto; position:relative; }
  .grid4{ grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px){
  .grid4{ grid-template-columns: 1fr; }
  .grid2{ grid-template-columns: 1fr; }
}

.card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--shadow2);
}
.cardTitle{
  font-weight: 800;
  letter-spacing: -.2px;
}

.metricTop{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}
.metricLabel{ color: var(--muted); font-size: 12px; }
.metricValue{ font-size: 26px; font-weight: 900; margin-top: 10px; letter-spacing: -.4px; }
.metricHint{ color: var(--muted); font-size: 12px; margin-top: 4px; }

.input{
  width:100%;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  outline:none;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, .02);
}
.input::placeholder{ color: #94a3b8; }
.input:focus{
  border-color: rgba(37,99,235,.45);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

.row{ display:flex; align-items:center; }
.between{ justify-content:space-between; }
.gap{ gap:10px; }
.mt{ margin-top: 16px; }
.mt1{ margin-top: 10px; }
.mt2{ margin-top: 12px; }

.btn{
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  user-select:none;
  box-shadow: var(--shadow2);
}
.btn:hover{ filter: brightness(.99); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; box-shadow:none; }

.primary{
  border-color: rgba(37,99,235,.28);
  background: var(--primarySoft);
  color: #1d4ed8;
}
.danger{
  border-color: rgba(220,38,38,.28);
  background: var(--dangerSoft);
  color: #b91c1c;
}

.pill{
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12px;
  box-shadow: var(--shadow2);
}
.pill.ok{ border-color: rgba(22,163,74,.30); background: var(--okSoft); color: #15803d; }
.pill.warn{ border-color: rgba(217,119,6,.30); background: var(--warnSoft); color: #b45309; }
.pill.bad{ border-color: rgba(220,38,38,.30); background: var(--dangerSoft); color: #b91c1c; }

.chip{
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow2);
}

.userBox{
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.kv{ display:grid; grid-template-columns: 160px 1fr; gap: 8px 12px; }
@media (max-width: 520px){ .kv{ grid-template-columns: 1fr; } }

.panel{
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}
.panelTitle{ font-weight: 800; font-size: 13px; }

.sep{ height:1px; background: var(--border2); margin: 12px 0; }

.log{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  background: #0b1220;
  color: #e5e7eb;
  border: 1px solid #0b1220;
  border-radius: 14px;
  padding: 10px 12px;
  min-height: 42px;
  box-shadow: var(--shadow2);
}

.view.hidden{ display:none; }
.footer{ margin-top: 18px; padding: 10px 4px; }

@media (prefers-color-scheme: dark){
  :root{
    --bg:#0b0f18;
    --panel:#0f1524;
    --text:#e8ecff;
    --muted:#9aa4c2;
    --border:#1f2a44;
    --border2:#182238;
    --shadow: 0 18px 50px rgba(0,0,0,.45);
    --shadow2: 0 8px 20px rgba(0,0,0,.35);
  }
  body{ background: radial-gradient(1200px 700px at 20% 0%, rgba(37,99,235,.18), transparent 60%),
                    radial-gradient(1000px 600px at 85% 10%, rgba(22,163,74,.10), transparent 55%),
                    var(--bg); }
  .sidebar{ background: rgba(15,21,36,.72); }
  .topbar{ background: rgba(15,21,36,.62); }
  .authCard{ background: rgba(15,21,36,.72); }
  .input{ background: rgba(255,255,255,.02); }
  .btn{ background: rgba(255,255,255,.03); }
  .pill, .chip, .card, .panel, .userBox{ background: rgba(15,21,36,.72); }
}

/* ---------------- PROMOS UI ---------------- */
.promoList{
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.promoCard{
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow2);
}

.promoHead{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
}

.promoCode{
  font-weight: 900;
  letter-spacing: -.2px;
  font-size: 14px;
  line-height: 1.1;
}

.promoMeta{
  margin-top: 6px;
  display:grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.promoMeta .mono{ color: var(--text); }

.promoActions{
  display:flex;
  gap: 8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.promoBadges{
  display:flex;
  gap: 8px;
  flex-wrap:wrap;
  margin-top: 8px;
}

.promoRewards{
  margin-top: 10px;
  border-top: 1px solid var(--border2);
  padding-top: 10px;
  display:grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 10px;
  font-size: 12px;
}

.promoRewards .mono{
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 720px){
  .promoMeta{ grid-template-columns: 1fr; }
  .promoRewards{ grid-template-columns: 1fr; }
  .promoActions{ justify-content:flex-start; }
}

/* ===== СТАТИСТИКА (4.2) ===== */
.stTableWrap{ overflow:auto; }
.stTable{ width:100%; border-collapse:collapse; font-size:13px; }
.stTable th{ text-align:left; font-size:12px; font-weight:600; color:var(--muted); padding:8px 10px; border-bottom:1px solid var(--border2); white-space:nowrap; }
.stTable td{ padding:8px 10px; border-bottom:1px solid var(--border2); white-space:nowrap; }
.stTable tr:last-child td{ border-bottom:none; }
.stBarCell{ width:30%; min-width:90px; }
.stBar{ height:8px; border-radius:999px; background:var(--border2); overflow:hidden; }
.stBar i{ display:block; height:100%; border-radius:999px; background:linear-gradient(90deg,#60a5fa,#2563eb); }
.stBar.bad i{ background:linear-gradient(90deg,#fca5a5,#dc2626); }
.stFunnel{ display:flex; flex-direction:column; gap:10px; }
.stFunnelRow{ display:grid; grid-template-columns: minmax(0,1.4fr) 1fr 110px; gap:10px; align-items:center; font-size:13px; }
.stFunnelTitle{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.stFunnelNum{ text-align:right; white-space:nowrap; }
.stDrop{ color:#b91c1c; font-weight:700; }
.stRar{ font-size:11px; font-weight:700; padding:2px 8px; border-radius:999px; background:var(--border2); color:#334155; }
.stRar.r-rare{ background:#dbeafe; color:#1d4ed8; }
.stRar.r-epic{ background:#ede9fe; color:#6d28d9; }
.stRar.r-legendary{ background:#fef3c7; color:#b45309; }
.stRar.r-mythical{ background:#fce7f3; color:#be185d; }
.stRar.r-exclusive{ background:#ccfbf1; color:#0f766e; }
@media (max-width:720px){ .stFunnelRow{ grid-template-columns: 1fr 90px; } .stFunnelRow .stBar{ grid-column:1 / -1; order:3; } }

/* лента действий игрока */
.evList{ display:flex; flex-direction:column; max-height:420px; overflow:auto; border:1px solid var(--border2); border-radius:12px; }
.evRow{ display:grid; grid-template-columns: 86px 1fr; gap:2px 8px; padding:7px 10px; font-size:12.5px; border-bottom:1px solid var(--border2); align-items:baseline; }
.evRow .evText{ grid-column: 2; }
.evRow:last-child{ border-bottom:none; }
.evRow.isFail{ background:#fff7ed; }
.evTime{ color:var(--muted); font-size:12px; }
.evLabel{ font-weight:700; }
.evPlus{ color:#15803d; font-weight:600; }
.evMinus{ color:#b91c1c; font-weight:600; }
@media (max-width:720px){ .evRow{ grid-template-columns: 1fr; } .evRow .evText{ grid-column: 1; } }

/* колонки не распирает длинным текстом (раньше правая карточка «Игроки» уезжала за экран) */
.grid2 > *, .grid4 > *{ min-width: 0; }
.kv > div{ min-width: 0; overflow-wrap: anywhere; }

/* -------- 4.2: поле даты — календарь + кнопки-пресеты (lib/datefield.js) -------- */
.dateInput{ font-family: inherit; }
.dateChips{ display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.dateChip{
  padding:5px 10px; border-radius:999px; border:1px solid var(--border); background:#fff;
  font: inherit; font-size:12.5px; font-weight:600; cursor:pointer;
}
.dateChip:hover{ filter:brightness(.97); }
.dateChip:active{ transform:translateY(1px); }
.dateHint{ margin-top:4px; }

/* -------- 4.2: выбор голубей/яиц для промокода (lib/rewardPicker.js) -------- */
.rp{ display:flex; flex-direction:column; gap:8px; margin-top:4px; }
.rpList{ display:flex; flex-direction:column; gap:6px; }
.rpEmpty{ padding:6px 2px; }
.rpRow{
  display:grid; grid-template-columns:44px 1fr auto auto; align-items:center; gap:10px;
  padding:6px 8px; border:1px solid var(--border); border-left:4px solid var(--rc); border-radius:12px; background:#fff;
}
.rpThumb{ width:44px; height:44px; display:grid; place-items:center; }
.rpThumb img{ max-width:44px; max-height:44px; object-fit:contain; }
.rpName{ display:flex; flex-direction:column; min-width:0; }
.rpName b{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rpName small{ color:var(--rc); font-weight:700; font-size:12px; }
.rpQty{ display:flex; align-items:center; gap:4px; }
.rpBtn,.rpDel{
  width:30px; height:30px; border-radius:9px; border:1px solid var(--border); background:#fff;
  font:inherit; font-weight:800; cursor:pointer;
}
.rpDel{ color:#c0392b; }
.rpNum{ width:46px; height:30px; text-align:center; border:1px solid var(--border); border-radius:9px; font:inherit; font-weight:800; }
.rpAdd{ align-self:flex-start; }
.rpBrowser{ border:1px solid var(--border); border-radius:14px; padding:10px; background:rgba(37,99,235,.03); display:flex; flex-direction:column; gap:8px; }
.rpBrowser.hidden{ display:none; }
.rpTools{ display:flex; flex-direction:column; gap:6px; }
.rpRar{ display:flex; flex-wrap:wrap; gap:6px; }
.rpRarBtn.is-on{ background:#2563eb; color:#fff; border-color:#2563eb; }
.rpGrid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(104px, 1fr)); gap:8px; max-height:420px; overflow:auto; padding:2px; }
.rpTile{
  position:relative; display:flex; flex-direction:column; align-items:center; gap:2px; padding:8px 6px;
  border:2px solid transparent; border-radius:12px; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.08);
  font:inherit; cursor:pointer; text-align:center;
}
.rpTile:hover{ border-color:var(--rc); }
.rpTile:active{ transform:scale(.97); }
.rpTile.is-on{ border-color:var(--rc); background:color-mix(in srgb, var(--rc) 8%, #fff); }
.rpTile img{ width:64px; height:64px; object-fit:contain; }
.rpTile b{ font-size:12px; line-height:1.2; }
.rpTile small{ font-size:11px; font-weight:700; color:var(--rc); }
.rpBadge{ position:absolute; top:4px; right:4px; padding:1px 7px; border-radius:999px; background:var(--rc); color:#fff; font-size:12px; font-weight:900; }

/* награды в карточке промокода */
.rwList{ display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; }
.rwItem{
  display:inline-flex; align-items:center; gap:5px; padding:3px 9px 3px 4px; border-radius:999px;
  border:1px solid var(--border); border-left:3px solid var(--rc, #cbd5e1); background:#fff; font-size:13px;
}
.rwItem img{ width:24px; height:24px; object-fit:contain; }
