*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f11;
  --bg2: #17171a;
  --bg3: #1e1e23;
  --bg4: #26262d;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --text: #f0f0f2;
  --text2: #9090a0;
  --text3: #606070;
  --accent: #f5a623;
  --accent2: #e8942a;
  --gold: #f5a623;
  --silver: #9ba3b0;
  --bronze: #cd7f32;
  --green: #3ecf8e;
  --blue: #4f8ef7;
  --purple: #a78bfa;
  --red: #f87171;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar: 220px;
}

body {
  font-family: 'Geologica', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.logo {
  padding: 24px 20px 20px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
.logo-fav { color: var(--accent); }
.logo-liga { color: var(--text); }

.sidenav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidenav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s;
}
.sidenav-btn i { font-size: 18px; flex-shrink: 0; }
.sidenav-btn:hover { background: var(--bg3); color: var(--text); }
.sidenav-btn.active { background: var(--bg4); color: var(--text); }
.sidenav-btn.active i { color: var(--accent); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.period-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
#period-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

/* ── MAIN ── */
.main {
  margin-left: var(--sidebar);
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
  overflow: visible;
}

.screen { display: none; padding: 32px 36px; }
.screen.active { display: block; }

.screen-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.screen-header h1 { font-size: 24px; font-weight: 600; color: var(--text); }
.screen-sub { font-size: 13px; color: var(--text2); margin-top: 3px; }

/* ── BUTTONS ── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent);
  color: #000;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--bg4); border-color: var(--border2); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.3);
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-danger:hover { background: rgba(248,113,113,0.08); }

.link-btn {
  background: none; border: none; color: var(--accent);
  font-family: inherit; font-size: inherit;
  cursor: pointer; text-decoration: underline; padding: 0;
}

/* ── METRICS ── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.metric-icon {
  width: 40px; height: 40px;
  background: var(--bg3);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 20px;
  flex-shrink: 0;
}
.metric-val { font-size: 20px; font-weight: 600; color: var(--text); }
.metric-lbl { font-size: 11px; color: var(--text2); margin-top: 1px; }

/* ── LEADERBOARD TABLE ── */
.leaderboard-table { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table-head {
  display: grid;
  grid-template-columns: 48px 1fr 80px 80px 80px 80px 120px 80px;
  padding: 12px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.col-rank { text-align: center; }
.col-stat, .col-score { text-align: center; }
.col-progress { text-align: center; }

.op-row {
  display: grid;
  grid-template-columns: 48px 1fr 80px 80px 80px 80px 120px 80px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: default;
}
.op-row:last-child { border-bottom: none; }
.op-row:hover { background: var(--bg3); }
.op-row.top1 { background: rgba(245,166,35,0.05); }
.op-row.top2 { background: rgba(155,163,176,0.04); }
.op-row.top3 { background: rgba(205,127,50,0.04); }
.op-row.top1 .score-cell { color: var(--gold); }
.op-row.top2 .score-cell { color: var(--silver); }
.op-row.top3 .score-cell { color: var(--bronze); }

.rank-cell { text-align: center; font-size: 16px; }
.rank-num { font-size: 13px; font-weight: 600; color: var(--text3); }

.op-name-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.op-full-name { font-size: 14px; font-weight: 500; color: var(--text); }
.op-badges { display: flex; gap: 4px; margin-top: 2px; flex-wrap: wrap; }
.badge {
  font-size: 9px; font-weight: 600;
  padding: 1px 6px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-calls { background: rgba(79,142,247,0.15); color: #4f8ef7; }
.badge-csat  { background: rgba(62,207,142,0.15); color: #3ecf8e; }
.badge-fcr   { background: rgba(167,139,250,0.15); color: #a78bfa; }
.badge-aht   { background: rgba(245,166,35,0.15);  color: #f5a623; }

.stat-cell { text-align: center; font-size: 13px; color: var(--text); font-family: 'JetBrains Mono', monospace; }

.progress-cell { display: flex; align-items: center; justify-content: center; }
.progress-track { width: 90px; height: 6px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }

.score-cell { text-align: center; font-size: 15px; font-weight: 600; color: var(--text); font-family: 'JetBrains Mono', monospace; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 20px; gap: 12px; color: var(--text3);
}
.empty-state i { font-size: 36px; }
.empty-state p { font-size: 14px; text-align: center; }

/* ── BONUSES ── */
.bonus-list { display: flex; flex-direction: column; gap: 12px; }

.bonus-rank-card {
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: border-color 0.15s;
}
.bonus-rank-card:hover { border-color: var(--border2); }

/* Ліва колонка — ранг і приз */
.bonus-card-left {
  padding: 20px 22px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
  position: relative;
}
.bonus-card-left::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.bonus-rank-label {
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.bonus-rank-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 99px;
  font-size: 13px; font-weight: 700; border: 1px solid;
  width: fit-content;
}
.bonus-prize-section { margin-top: 4px; }
.bonus-prize-label {
  font-size: 10px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}
.bonus-prize-text {
  font-size: 18px; font-weight: 700; color: var(--text);
  flex: 1; min-width: 0; line-height: 1.2;
}
.bonus-prize-empty { color: var(--text3); font-size: 14px; font-weight: 400; font-style: italic; }

/* Список призів (адмін) */
.bonus-prizes-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.bonus-prize-row { display: flex; align-items: center; gap: 6px; }
.bonus-prize-input {
  flex: 1; min-width: 0; background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 7px 10px; border-radius: var(--radius);
  font-family: inherit; font-size: 14px; font-weight: 600; outline: none;
  transition: border-color 0.15s;
}
.bonus-prize-input:focus { border-color: var(--accent); }
.bonus-prize-del {
  flex-shrink: 0; background: none; border: 1px solid var(--border2);
  color: var(--text3); cursor: pointer; font-size: 14px;
  padding: 6px 8px; border-radius: var(--radius); transition: all 0.15s;
}
.bonus-prize-del:hover { color: var(--red); border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.06); }
.bonus-add-prize {
  background: none; border: 1px dashed var(--border2);
  color: var(--text2); cursor: pointer; font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: var(--radius);
  display: inline-flex; align-items: center; gap: 5px; transition: all 0.15s;
}
.bonus-add-prize:hover { color: var(--accent); border-color: var(--accent); }

/* Призи (читання, не-адмін) */
.bonus-prizes-readonly { display: flex; flex-direction: column; gap: 6px; }
.bonus-prize-chip {
  font-size: 15px; font-weight: 700; color: var(--text);
  padding: 6px 12px; background: var(--bg3); border-radius: var(--radius);
  line-height: 1.3;
}

/* Права колонка — оператори */
.bonus-card-right {
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 0;
}
.bonus-card-right-title {
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px;
}
.bonus-ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
}
.bonus-op-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius);
  background: var(--bg3);
}
.bonus-op-name { font-size: 13px; color: var(--text); font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bonus-op-count { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.bonus-no-ops { font-size: 13px; color: var(--text3); font-style: italic; padding: 4px 0; }

/* legacy - keep for mobile */
.bonus-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.bonus-tier-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.bonus-tier-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.bonus-tier-card.gold::before { background: var(--gold); }
.bonus-tier-card.silver::before { background: var(--silver); }
.bonus-tier-card.bronze::before { background: var(--bronze); }

.bonus-tier-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.gold .bonus-tier-label { color: var(--gold); }
.silver .bonus-tier-label { color: var(--silver); }
.bronze .bonus-tier-label { color: var(--bronze); }

.bonus-amount { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.bonus-desc { font-size: 12px; color: var(--text2); margin-bottom: 14px; }
.bonus-ops-list { display: flex; flex-direction: column; gap: 6px; }
.bonus-op-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text2);
}
.bonus-op-item .avatar { width: 24px; height: 24px; font-size: 9px; }

.bonus-config { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.bonus-config h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.bonus-rules { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.bonus-rule-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px; align-items: center;
}
.bonus-rule-row input, .bonus-rule-row select {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 7px 10px;
  border-radius: var(--radius); font-family: inherit;
  font-size: 13px; outline: none; width: 100%;
}
.rule-delete { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; padding: 4px; }
.rule-delete:hover { color: var(--red); }

/* ── OPERATORS GRID ── */
.ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.op-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color 0.15s;
}
.op-card:hover { border-color: var(--border2); }
.op-card-header { display: flex; align-items: center; gap: 10px; }
.op-card-name { font-size: 14px; font-weight: 600; color: var(--text); }
.op-card-score { font-size: 12px; color: var(--text2); }
.op-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.op-stat { background: var(--bg3); border-radius: 8px; padding: 8px 10px; }
.op-stat-val { font-size: 15px; font-weight: 600; color: var(--text); font-family: 'JetBrains Mono', monospace; }
.op-stat-lbl { font-size: 10px; color: var(--text3); margin-top: 1px; }
.op-card-actions { display: flex; gap: 6px; }
.op-action-btn {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 6px; border-radius: 8px;
  font-family: inherit; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: all 0.12s;
}
.op-action-btn:hover { background: var(--bg4); color: var(--text); }
.op-action-btn.delete:hover { color: var(--red); border-color: rgba(248,113,113,0.3); }

/* ── IMPORT ── */
.import-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; }

.upload-zone {
  background: var(--bg2); border: 1.5px dashed var(--border2);
  border-radius: var(--radius-lg); padding: 32px 20px;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; text-align: center;
  transition: border-color 0.15s; cursor: pointer; margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); }
.upload-icon { font-size: 40px; color: var(--text3); }
.upload-title { font-size: 15px; font-weight: 600; color: var(--text); }
.upload-sub { font-size: 13px; color: var(--text3); }
.upload-formats { font-size: 11px; color: var(--text3); }

.template-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.template-box h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.template-box p { font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.template-code {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--green); margin-bottom: 12px;
  white-space: pre; overflow-x: auto;
}

.import-preview-empty {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 300px; gap: 12px;
  color: var(--text3);
}
.import-preview-empty i { font-size: 36px; }

.preview-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.preview-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.preview-header h3 { font-size: 14px; font-weight: 600; }
.preview-count { font-size: 12px; color: var(--text2); }
.preview-table-wrap { overflow-x: auto; max-height: 400px; overflow-y: auto; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.preview-table th { padding: 10px 14px; background: var(--bg3); color: var(--text3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; text-align: left; position: sticky; top: 0; }
.preview-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.preview-table tr:last-child td { border-bottom: none; }
.preview-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── SETTINGS ── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.settings-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.settings-card h2 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.settings-desc { font-size: 13px; color: var(--text2); margin-bottom: 20px; }

.weights-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.weight-row { display: flex; flex-direction: column; gap: 6px; }
.weight-row label { font-size: 13px; color: var(--text2); }
.weight-control { display: flex; align-items: center; gap: 10px; }
.weight-control input[type=range] { flex: 1; accent-color: var(--accent); }
.weight-val { font-size: 13px; font-weight: 600; color: var(--text); width: 38px; text-align: right; font-family: 'JetBrains Mono', monospace; }
.weight-total { font-size: 12px; color: var(--text3); padding: 6px 0; }
.weight-total.ok { color: var(--green); }
.weight-total.bad { color: var(--red); }

.data-actions { display: flex; flex-direction: column; gap: 14px; }
.data-action-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.data-action-row:last-child { border-bottom: none; }
.data-action-title { font-size: 14px; font-weight: 500; color: var(--text); }
.data-action-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── MODAL ── (повне визначення нижче, разом з архівним) */

.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 12px; color: var(--text2); font-weight: 500; }
.form-row input {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 9px 12px;
  border-radius: var(--radius); font-family: inherit;
  font-size: 14px; outline: none; width: 100%;
  transition: border-color 0.15s;
}
.form-row input:focus { border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 12px 18px;
  border-radius: var(--radius); font-size: 14px;
  z-index: 300; animation: slideUp 0.2s ease;
  display: flex; align-items: center; gap: 8px;
  max-width: 400px;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ── FILTERS in sidebar ── */
.filter-group { margin-bottom: 12px; }
.filter-group:last-child { margin-bottom: 0; }
.filter-group input[type=date] {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 7px 10px; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; outline: none;
  color-scheme: dark;
}

/* team badge */
.badge-team {
  background: rgba(255,255,255,0.07); color: var(--text3);
  font-size: 9px; padding: 1px 6px; border-radius: 99px;
  text-transform: none; letter-spacing: 0;
}

/* Колонки задаються динамічно через JS (різні для чатів і дзвінків) */
.table-head { grid-template-columns: 48px 1fr 72px 60px 60px 80px 66px 90px 90px 72px; }
.op-row     { grid-template-columns: 48px 1fr 72px 60px 60px 80px 66px 90px 90px 72px; }

/* ── FAQ floating button (?) — лише мобільний ── */
.faq-fab { display: none; }
@media (max-width: 600px) {
  .faq-fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: 14px; bottom: 84px;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent); color: #000;
    font-size: 22px; font-weight: 800; line-height: 1;
    text-decoration: none; z-index: 150;
    box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  }
  .faq-fab:active { transform: scale(0.94); }
}

/* ── ACHRANK month picker ── */
.achrank-month-select {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 8px 12px; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; outline: none; cursor: pointer;
  color-scheme: dark;
}
.achrank-month-select:focus { border-color: var(--accent); }

/* ── ACHRANK RECORDS ── */
.achrank-records {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.achrank-record-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.15s;
  min-width: 0;
}
.achrank-record-card:hover { border-color: var(--border2); }
.rec-icon { font-size: 28px; flex-shrink: 0; }
.rec-body { min-width: 0; flex: 1; }
.rec-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.rec-value { font-size: 13px; color: var(--text2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-name  { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 600px) {
  .achrank-records {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
    scrollbar-width: none;
  }
  .achrank-records::-webkit-scrollbar { display: none; }
  .achrank-record-card {
    flex-shrink: 0;
    width: 200px;
    scroll-snap-align: start;
  }
}

/* ── ACHRANK custom columns ── */
#achrank-head,
#achrank-body .op-row {
  grid-template-columns: 48px 1fr 140px 90px 90px 180px !important;
}
#achrank-head .col-stat:not(:last-child),
#achrank-body .op-row .stat-cell:not(:last-child) {
  text-align: center !important;
  justify-content: center;
}
#achrank-body .op-row > * { overflow: hidden; min-width: 0; }

.achrank-status {
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 10px; border-radius:99px; font-size:11px; font-weight:700; border:1px solid;
  white-space: nowrap; max-width: 100%;
}

/* "До наступного" колонка */
.achrank-next-cell {
  display:flex !important; align-items:center; gap:6px;
  text-align:left !important; justify-content:flex-start !important;
  padding-left: 12px;
}
.achrank-next-count { font-size:13px; font-weight:700; color:var(--text); font-family:'JetBrains Mono',monospace; white-space:nowrap; }
.achrank-next-label { font-size:11px; color:var(--text3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.achrank-next-max   { font-size:12px; color:var(--accent); }
.header-actions {
  display: flex; align-items: center; gap: 10px;
}
.sync-status {
  font-size: 12px; color: var(--text2);
  white-space: nowrap;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.8s linear infinite; }

/* ── KYA BADGE ── */
.kya-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.kya-cell {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* KYA legend in settings */
.kya-legend {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 16px; padding: 16px;
  background: var(--bg3); border-radius: var(--radius);
}
.kya-legend-row {
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.kya-legend-grade {
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}

/* ── CHANNEL TABS ── */
.channel-tabs {
  display: flex; gap: 6px; margin-bottom: 20px;
}
.channel-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 18px; border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent; color: var(--text2);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.channel-tab:hover { background: var(--bg3); color: var(--text); }
.channel-tab.active { background: var(--bg3); color: var(--text); border-color: var(--accent); }
.channel-tab.active i { color: var(--accent); }

/* ── ARCHIVE ── */
.archive-month-block { margin-bottom: 32px; }
.archive-month-title {
  font-size: 18px; font-weight: 600; color: var(--text);
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.archive-channels { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.archive-channel-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
}
.archive-channel-label {
  font-size: 13px; font-weight: 600; color: var(--text2);
  margin-bottom: 14px;
}
.archive-top3 { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.archive-op-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
}
.archive-rank { font-size: 16px; width: 24px; text-align: center; }
.archive-name { flex: 1; font-weight: 500; }
.archive-score { font-size: 12px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }
.archive-expand-btn { width: 100%; justify-content: center; font-size: 12px; padding: 7px; }

/* modal for archive detail */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: hidden;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 820px;
  max-width: 95vw;
  height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-sm {
  width: 560px;
  height: auto;
  max-height: 90vh;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 20px; }
.modal-close:hover { color: var(--text); }
.modal-body {
  flex: 1;
  overflow-y: scroll;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  min-height: 0;
}
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-shrink: 0;
}

/* leaderboard table — 8 cols for archive modal */

/* ── OPERATOR MODAL ── */
.op-modal-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.op-modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 780px; max-width: 95vw;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.op-modal-body {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.op-kpi-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 10px;
}
.op-kpi-card {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.op-kpi-main { border-left: 3px solid var(--accent); }
.op-kpi-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.op-kpi-value { font-size: 22px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }

.op-charts-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.op-chart-box {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  height: 200px;
  display: flex; flex-direction: column;
}
.op-chart-title {
  font-size: 12px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 10px; flex-shrink: 0;
}
.op-chart-box canvas { flex: 1; min-height: 0; }

.op-daily-table-wrap { overflow-x: auto; }
.op-daily-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.op-daily-table th {
  padding: 8px 12px; background: var(--bg3);
  color: var(--text3); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  text-align: left; border-bottom: 1px solid var(--border);
}
.op-daily-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 12px;
}
.op-daily-table tr:last-child td { border-bottom: none; }
.op-daily-table tr:hover td { background: var(--bg3); }

.op-row-clickable { cursor: pointer; }
.op-row-clickable:hover { background: var(--bg4) !important; }

/* ── USER MENU ── */
.user-menu { padding: 12px; border-bottom: 1px solid var(--border); }
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  background: var(--bg3);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; margin-top: 1px; }
.logout-btn {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 16px; padding: 2px;
  transition: color 0.15s; flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); }

/* ── TELEGRAM MINI APP ── */
.tg-app body {
  background: var(--tg-theme-bg-color, var(--bg));
  color: var(--tg-theme-text-color, var(--text));
}

/* Mobile sidebar becomes bottom nav */
@media (max-width: 600px) {
  body { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0;
  }

  .logo { display: none; }
  .user-menu { display: none; }
  .sidebar-footer { display: none; }

  .sidenav {
    flex-direction: row;
    padding: 4px 6px;
    gap: 0;
    flex: 1;
    justify-content: space-around;
    align-items: center;
  }

  /* На мобілці показуємо тільки 5 кнопок */
  .sidenav-btn { display: none; }
  .sidenav-btn[data-screen="leaderboard"],
  .sidenav-btn[data-screen="bonuses"],
  .sidenav-btn[data-screen="archive"],
  .sidenav-btn[data-screen="achrank"],
  a.sidenav-btn[href="achievements.html"],
  a.sidenav-btn[href="profile.html"],
  a.sidenav-btn[href="index.html"],
  a.sidenav-btn[href="index.html#leaderboard"],
  a.sidenav-btn[href="index.html#bonuses"],
  a.sidenav-btn[href="achievements_rank.html"],
  a.sidenav-btn[href="index.html#achrank"],
  a.sidenav-btn[href="index.html#archive"] {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 5px 4px;
    font-size: 10px;
    flex: 1;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    min-width: 0;
  }

  .sidenav-btn i { font-size: 18px; }
  .sidenav-btn span { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* Профіль по центру — більший */
  a.sidenav-btn[href="profile.html"] {
    flex: 1.5;
    background: rgba(245,166,35,0.1);
    border: 1px solid rgba(245,166,35,0.25);
    border-radius: 14px;
    padding: 8px 6px;
    margin: 2px 6px;
  }
  a.sidenav-btn[href="profile.html"] i { font-size: 22px; color: var(--accent); }
  a.sidenav-btn[href="profile.html"] span { color: var(--accent); font-size: 10px; font-weight: 700; }

  #users-nav-btn { display: none !important; }

  .main {
    margin-left: 0;
    margin-bottom: 70px;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .screen { padding: 16px; }

  .screen-header {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
  }

  .screen-header h1 { font-size: 18px; }

  .metrics-row {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 8px;
  }

  .metric-card { padding: 12px; }
  .metric-val { font-size: 16px; }

  /* Hide some columns on mobile */
  .table-head .col-stat:nth-child(4),
  .table-head .col-stat:nth-child(5),
  .op-row .stat-cell:nth-child(5),
  .op-row .stat-cell:nth-child(6) {
    display: none;
  }

  .table-head, .op-row {
    grid-template-columns: 36px 1fr 60px 60px 80px 60px !important;
  }

  .op-full-name { font-size: 13px; }

  .header-actions { flex-wrap: wrap; gap: 6px; }
  .sync-status { font-size: 11px; }

  /* Archive mobile */
  .archive-channels { grid-template-columns: 1fr; }

  /* Bonus mobile */
  .bonus-tiers { grid-template-columns: 1fr; }
  .bonus-rank-card { grid-template-columns: 1fr; }
  .bonus-card-left { border-right: none; border-bottom: 1px solid var(--border); }
  .bonus-ops-grid { grid-template-columns: 1fr; }

  /* Operator modal mobile */
  .op-modal { width: 100% !important; max-width: 100% !important; height: 100vh !important; border-radius: 0 !important; }
  .op-kpi-grid { grid-template-columns: 1fr 1fr; }
  .op-charts-row { grid-template-columns: 1fr; }
}

/* ── MOBILE LEADERBOARD CARDS ── */
@media (max-width: 600px) {
  .leaderboard-table { background: transparent; border: none; border-radius: 0; }
  .table-head { display: none; }

  .op-row {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    grid-template-columns: unset !important;
  }

  .op-row .rank-cell { font-size: 18px; width: 28px; flex-shrink: 0; text-align: center; }
  .op-row .col-progress, .op-row .progress-cell { display: none !important; }

  /* Hide FRT and ART columns on mobile */
  .op-row .stat-cell:nth-child(4),
  .op-row .stat-cell:nth-child(5) { display: none; }

  .op-row .op-name-cell { flex: 1; min-width: 0; }
  .op-row .op-full-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .op-row .stat-cell { font-size: 12px; text-align: center; }
  .op-row .score-cell {
    font-size: 16px; font-weight: 700;
    color: var(--accent); min-width: 36px;
    text-align: right;
  }

  .op-row .kya-cell { flex-direction: column; gap: 2px; align-items: center; }
  .op-row .kya-cell span { font-size: 9px; }

  /* Top rows styling */
  .op-row.top1 { border-color: rgba(245,166,35,0.4); }
  .op-row.top2 { border-color: rgba(155,163,176,0.4); }
  .op-row.top3 { border-color: rgba(205,127,50,0.4); }

  /* ── ACHRANK mobile ── */
  #achrank-body .op-row { display: none !important; }
  .achrank-mobile-card {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; background: var(--bg2);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    margin-bottom: 8px;
  }
  .achrank-mobile-card.top1 { border-color: rgba(245,166,35,0.4); }
  .achrank-mobile-card.top2 { border-color: rgba(155,163,176,0.4); }
  .achrank-mobile-card.top3 { border-color: rgba(205,127,50,0.4); }
  .achrank-mobile-rank { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; }
  .achrank-mobile-body { flex: 1; min-width: 0; }
  .achrank-mobile-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .achrank-mobile-sub  { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
  .achrank-mobile-next { font-size: 11px; color: var(--text3); }
}

/* ── MOBILE OPERATOR CARDS ── */
.op-card-mobile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.op-card-mobile:active { opacity: 0.8; }
.op-card-mobile.top1 { border-color: rgba(245,166,35,0.4); }
.op-card-mobile.top2 { border-color: rgba(155,163,176,0.3); }
.op-card-mobile.top3 { border-color: rgba(205,127,50,0.3); }

.op-card-mobile-left {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.op-card-mobile-right {
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
