/* Панель управления «ГАЦИК» — /admin. Переиспользует :root из style.css. */
/* [hidden] должен побеждать display у .login-wrap/.panel-view (иначе оба видны) */
[hidden] { display: none !important; }
body.admin {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.admin .muted { color: var(--muted); }
.admin h1 { font-size: 18px; margin: 0; }
.admin h2 { font-size: 15px; margin: 0 0 14px; font-weight: 650; }
.admin label { display: block; font-size: 12px; color: var(--text-dim); margin: 10px 0 4px; font-weight: 600; }
.admin input[type=text], .admin input[type=password], .admin input[type=file], .admin select {
  width: 100%; box-sizing: border-box; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit; outline: none;
}
.admin textarea {
  width: 100%; box-sizing: border-box; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit;
  resize: vertical; min-height: 70px; outline: none;
}
.admin input:focus, .admin select:focus, .admin textarea:focus { border-color: var(--accent); }
.admin .hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 8px 0; }
.admin .hint b { color: var(--text-dim); }

/* Кнопки */
.admin .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 9px; padding: 9px 15px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: all 0.12s;
}
.admin .btn:hover { border-color: var(--accent); }
.admin .btn.primary { background: var(--accent); border-color: var(--accent); color: #04121c; }
.admin .btn.primary:hover { filter: brightness(1.08); }
.admin .btn.ghost { background: transparent; }
.admin .btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.admin .btn.good:hover { border-color: var(--good); color: var(--good); }
.admin .btn.wide { width: 100%; margin-top: 6px; }
.admin .btn.sm { padding: 6px 11px; font-size: 12.5px; }
.admin .btn.xs { padding: 3px 8px; font-size: 11px; }

/* ===== Экран входа ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 24px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-mark { font-size: 30px; }
.login-error { color: var(--bad); font-size: 12.5px; min-height: 18px; margin: 8px 0 2px; }
.login-card .back { display: block; text-align: center; margin-top: 14px; font-size: 12.5px; text-decoration: none; }
.auth-page { min-height: 100vh; }
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at top, rgba(54, 194, 255, 0.16), transparent 34%), var(--bg);
}
.auth-card { width: min(420px, 100%); }
.auth-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px;
}
.auth-mode {
  border: 1px solid var(--line); background: var(--bg); color: var(--text-dim);
  border-radius: 10px; padding: 10px 12px; font: inherit; font-weight: 700; cursor: pointer;
}
.auth-mode.active { background: var(--accent); border-color: var(--accent); color: #04121c; }
.auth-form[hidden] { display: none !important; }
.auth-notice { margin-top: 16px; text-align: center; font-size: 12px; }

/* ===== Панель ===== */
.panel-view { min-height: 100vh; display: flex; flex-direction: column; }
.adm-top {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.adm-brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.adm-tabs { display: flex; gap: 4px; margin-left: 8px; flex: 1 1 420px; flex-wrap: wrap; }
.adm-tab {
  border: none; background: transparent; color: var(--text-dim); font: inherit; font-weight: 600;
  padding: 7px 14px; border-radius: 9px; cursor: pointer;
}
.adm-tab:hover { color: var(--text); background: var(--line-soft); }
.adm-tab.active { background: var(--accent); color: #04121c; }
.pend-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; margin-left: 4px;
}
.adm-user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--text-dim);
  background: var(--line-soft); font-size: 12px; font-weight: 700;
}
.adm-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.adm-main { flex: 1; padding: 20px; max-width: 1200px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.adm-section { display: none; }
.adm-section.active { display: block; }
.adm-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
.mod-grid { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
.adm-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.wide-card { max-width: 820px; }

.adm-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick-map { height: 240px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); margin-top: 4px; }
.pick-coords { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.form-note-good { color: var(--good); }
.form-note-bad { color: var(--bad); }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin-top: 12px; }
.chk input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.perm-grid {
  display: grid; grid-template-columns: 1fr; gap: 4px;
  margin-top: 8px;
}

.chip-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 999px; background: var(--line-soft); border: 1px solid var(--line);
  color: var(--text-dim); font-size: 12px; margin-left: 6px;
}
.pad { padding: 12px 2px; }

/* Список каналов / аккаунтов */
.ch-list { display: flex; flex-direction: column; gap: 10px; }
.ch-item {
  border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; background: var(--bg);
}
.ch-item.off { opacity: 0.55; }
.ch-head { display: flex; align-items: center; gap: 8px; }
.ch-ref { font-weight: 650; word-break: break-all; }
.ch-side { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.ch-side.ukraine { background: #2f8fed; } .ch-side.russia { background: #e5484d; } .ch-side.neutral { background: #9aa4b2; }
.ch-meta { font-size: 12px; color: var(--text-dim); margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px 10px; }
.ch-tag { background: var(--line-soft); border: 1px solid var(--line); border-radius: 7px; padding: 2px 7px; }
.ch-tag.auto { color: var(--warn); } .ch-tag.news { color: var(--good); } .ch-tag.mod { color: var(--accent); }
.ch-row-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.ch-inline-mode {
  display: inline-flex; align-items: center; gap: 6px; margin-right: auto;
  font-size: 11px; color: var(--muted); font-weight: 600;
}
.ch-inline-mode select {
  width: auto; min-width: 150px; padding: 4px 28px 4px 8px; font-size: 11.5px;
  border-radius: 8px; background: var(--panel);
}

/* тег «вступил в каналы» в шапке карточки аккаунта */
.ch-joined { margin-left: auto; color: var(--accent); white-space: nowrap; font-weight: 600; }

.section-head-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-head-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.section-head-actions select { min-width: 220px; }

.inline-copy {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center;
}

.session-tools {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; margin: 14px 0 16px;
}

.session-list, .audit-list {
  display: flex; flex-direction: column; gap: 10px;
}

.user-item, .invite-item, .session-item, .audit-item {
  border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; background: var(--bg);
}

.user-top, .session-top, .audit-top {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.user-name, .invite-name, .session-name, .audit-title {
  font-weight: 700; color: var(--text);
}

.pill-row {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px;
}

.creds-row {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  background: var(--line-soft); border: 1px solid var(--line);
}
.creds-label { font-size: 12px; color: var(--text-dim); }
.creds-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text); user-select: all;
}

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--line-soft); color: var(--text-dim); font-size: 11px; font-weight: 700;
}

.invite-result {
  margin-top: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}

.session-meta, .audit-meta {
  margin-top: 8px; font-size: 12px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 6px 12px;
}

.audit-route {
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
}

.audit-json {
  margin-top: 8px; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-dim); background: var(--line-soft); border-radius: 8px; padding: 8px 10px;
}

/* ===== Логи воркера ===== */
.logs-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.logs-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.log-view {
  max-height: 62vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); padding: 6px 0; margin-top: 6px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.log-line {
  display: flex; align-items: baseline; gap: 9px; padding: 3px 12px;
  border-bottom: 1px solid var(--line-soft); white-space: pre-wrap; word-break: break-word;
}
.log-line:last-child { border-bottom: none; }
.log-ts { color: var(--muted); flex: 0 0 auto; }
.log-lvl { flex: 0 0 auto; width: 14px; text-align: center; }
.log-acc {
  flex: 0 0 auto; color: var(--text-dim); background: var(--line-soft);
  border-radius: 6px; padding: 0 6px; font-size: 11px;
}
.log-msg { flex: 1 1 auto; color: var(--text-dim); }
.log-error { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.log-error .log-lvl, .log-error .log-msg { color: var(--bad); }
.log-warn .log-lvl, .log-warn .log-msg { color: var(--warn); }
.log-info .log-lvl { color: var(--accent); }

/* Дубли */
.dup-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--line-soft); cursor: pointer;
}
.dup-row:first-of-type { border-top: none; }
.dup-row input[type="checkbox"] { flex: 0 0 auto; }
.dup-text { flex: 1 1 260px; min-width: 0; font-size: 13px; color: var(--text); }
.dup-src { font-size: 12px; white-space: nowrap; }

/* Модерация */
.pending-list { display: flex; flex-direction: column; gap: 12px; }
.pend-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--bg); }
.pend-head { display: flex; align-items: flex-start; gap: 10px; }
.pend-head .ch-head { flex: 1 1 auto; min-width: 0; }
.pend-delete {
  flex: 0 0 auto; width: 30px; height: 30px; padding: 0;
  border-radius: 999px; line-height: 1;
}
.pend-text { font-size: 13.5px; line-height: 1.5; margin: 4px 0 10px; }
.pend-meta { font-size: 12px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 12px; }
.pend-map-wrap { margin-bottom: 12px; }
.pend-map { height: 220px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.pend-map-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 8px; flex-wrap: wrap;
}
.pend-coords {
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-dim);
}
.pend-map-state { font-size: 12px; color: var(--muted); }
.pend-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .adm-grid { grid-template-columns: 1fr; }
  .adm-tabs { margin-left: 0; overflow-x: auto; }
  .adm-actions { margin-left: 0; width: 100%; }
  .pend-map { height: 190px; }
  .pend-head { gap: 8px; }
  .session-tools { grid-template-columns: 1fr; }
  .inline-copy { grid-template-columns: 1fr; }
}
