*, *::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: right; }
.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); }

.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: right; 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: 4px; background: var(--bg4); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }

.score-cell { text-align: right; 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-tiers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,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 ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); width: 460px; max-width: 95vw;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 20px; padding: 2px; transition: color 0.12s; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.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;
}
@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;
}

/* updated table columns (9 cols now) */
.table-head, .op-row {
  grid-template-columns: 48px 1fr 72px 72px 72px 72px 72px 110px 72px !important;
}

/* ── SYNC BUTTON & SPIN ── */
.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: flex-end;
  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-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: 6px 8px;
    gap: 0;
    flex: 1;
    justify-content: space-around;
  }

  .sidenav-btn {
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    font-size: 10px;
    flex: 1;
    justify-content: center;
    border-radius: 8px;
  }

  .sidenav-btn i { font-size: 20px; }
  .sidenav-btn span { font-size: 10px; }

  #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; }

  /* 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); }
}

/* ── 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;
}
