/* Панель AURORA Team — тёмная тема с фиолетовым акцентом (как тема входа aurora-team). */
:root {
  --accent: #7c5cff;
  --accent-2: #2fd3c5;
  --accent-hover: #6346f0;
  --accent-soft: rgba(124, 92, 255, .14);
  --bg: #0d0f1a;
  --bg-2: #121526;
  --panel: #161a2e;
  --panel-2: #1c2138;
  --line: #262c47;
  --line-2: #323a5c;
  --text: #e8eaf6;
  --text-2: #a3a9c7;
  --text-3: #6f7698;
  --ok: #3ddc97;
  --ok-soft: rgba(61, 220, 151, .12);
  --warn: #f5b84a;
  --warn-soft: rgba(245, 184, 74, .12);
  --bad: #ff5d7a;
  --bad-soft: rgba(255, 93, 122, .12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(47, 211, 197, .08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 600; margin-bottom: 10px; }
p { margin: 4px 0 0; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.link { color: #b4a3ff; text-decoration: none; }
.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- иконки ---------- */
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-xs { width: 12px; height: 12px; }

/* ---------- верхняя панель и навигация ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: 60px; padding: 0 20px;
  background: rgba(13, 15, 26, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 18px rgba(124, 92, 255, .5); }
.brand-text { font-size: 17px; letter-spacing: .08em; font-weight: 300; }
.brand-text b { font-weight: 700; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-title { color: var(--text-3); font-size: 13px; padding-left: 16px; border-left: 1px solid var(--line); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.who { text-align: right; line-height: 1.25; }
.who-name { font-weight: 600; }
.who-id { font-size: 12px; color: var(--text-2); font-family: var(--mono); }

.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar { width: 220px; flex: none; padding: 18px 12px; border-right: 1px solid var(--line); background: rgba(18, 21, 38, .5); }
.nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 78px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--panel); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav-link.active .icon { color: var(--accent); }
.main { flex: 1; min-width: 0; padding: 26px 28px 60px; outline: none; }

/* ---------- страницы ---------- */
.page { max-width: 1400px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px 20px; }
.table-card { overflow: hidden; transition: opacity .15s; }
.dim { opacity: .55; pointer-events: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 240px; max-width: 380px; }
.search .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 34px; width: 100%; }

.input, .select {
  height: 36px; padding: 0 12px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit;
}
textarea.input { height: auto; padding: 8px 12px; resize: vertical; }
.input:focus, .select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.select { padding-right: 28px; cursor: pointer; }
.input-date { width: 150px; }
.input::placeholder { color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 16px rgba(124, 92, 255, .3); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #e9465f; }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: rgba(255, 93, 122, .35); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--bad-soft); }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--text-2); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn-sm { width: 22px; height: 22px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 11px 12px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-compact td, .table-compact th { padding: 8px 10px; }
.th-btn { all: unset; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.th-btn:hover { color: var(--text); }
.th-btn:focus-visible { outline: 2px solid var(--accent); }
.sorted { color: var(--text) !important; }
.sort-mark { font-size: 9px; color: var(--accent); }
.col-check { width: 38px; }
.row-link { cursor: pointer; transition: background .1s; }
.row-link:hover { background: rgba(124, 92, 255, .06); }
.row-link.selected { background: rgba(124, 92, 255, .1); }
.row-off td { color: var(--text-3); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--line); gap: 12px; }
.pager-btns { display: flex; align-items: center; gap: 8px; color: var(--text-2); }

/* ---------- значки и метки ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: var(--panel-2); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: #c3b6ff; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 12px; white-space: nowrap; }
.chip-group { background: var(--accent-soft); border-color: rgba(124, 92, 255, .3); color: #cfc5ff; }
.chip-more { color: var(--text-2); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--text-2); white-space: nowrap; }
.tag-access { background: rgba(47, 211, 197, .12); color: var(--accent-2); }
.tag-group { background: var(--accent-soft); color: #c3b6ff; }
.tag-user { background: var(--warn-soft); color: var(--warn); }
.tag-link { background: rgba(120, 170, 255, .12); color: #9cc0ff; }
.tag-sync { background: var(--ok-soft); color: var(--ok); }
.tag-bulk { background: rgba(255, 140, 200, .12); color: #ff9fd0; }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.details-cell { max-width: 340px; color: var(--text-2); font-size: 13px; }

/* ---------- массовые действия ---------- */
.bulkbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(124, 92, 255, .22), rgba(124, 92, 255, .08));
  border: 1px solid rgba(124, 92, 255, .45);
  animation: rise .15s ease-out;
}

/* ---------- состояния ---------- */
.empty { padding: 44px 20px; text-align: center; }
.empty-title { font-weight: 600; }
.empty-sub { color: var(--text-2); margin-top: 4px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px; color: var(--text-2); }
.loading-full { min-height: 100vh; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.error-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bad-soft); color: #ffc2cd; border: 1px solid rgba(255, 93, 122, .3); }
.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text-2); font-size: 13px; }
.notice-warn { background: var(--warn-soft); color: #ffd99a; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- уведомления ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { padding: 11px 16px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--ok); box-shadow: var(--shadow); animation: rise .18s ease-out; transition: opacity .4s, transform .4s; }
.toast-error { border-left-color: var(--bad); }
.toast-warn { border-left-color: var(--warn); }
.toast-out { opacity: 0; transform: translateX(10px); }

/* ---------- модальные окна ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; background: rgba(5, 6, 12, .66); backdrop-filter: blur(3px); animation: fade .12s; }
.modal { width: 100%; max-width: 480px; max-height: 80vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); animation: rise .15s ease-out; }
.modal-wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 6px 18px 12px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { font-size: 13px; color: var(--text-2); padding: 0; margin-bottom: 6px; }
.form-error { color: var(--bad); font-size: 13px; min-height: 1em; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer; }
.check:hover { border-color: var(--accent); }
.check-disabled { opacity: .6; cursor: default; }
.check-disabled:hover { border-color: var(--line-2); }
.code { margin: 0; padding: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow: auto; }
.impact-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 10px; }

/* ---------- карточка пользователя ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(5, 6, 12, .5); opacity: 0; transition: opacity .18s; }
.drawer-backdrop.open { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(640px, 100vw); background: var(--bg-2); border-left: 1px solid var(--line-2); box-shadow: var(--shadow); transform: translateX(24px); opacity: 0; transition: transform .2s ease-out, opacity .2s; overflow-y: auto; }
.drawer.open { transform: none; opacity: 1; }
.drawer-inner { padding: 14px 22px 40px; }
.drawer-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.drawer-body { display: flex; flex-direction: column; gap: 14px; }
.profile { display: flex; gap: 16px; align-items: center; }
.avatar { width: 58px; height: 58px; flex: none; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), #4b3bb8); box-shadow: 0 6px 20px rgba(124, 92, 255, .35); }
.profile-main { min-width: 0; }
.profile-main h2 { overflow-wrap: anywhere; }
.profile-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.id-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 12px; color: var(--text-2); }
.id-pill b { color: var(--text); font-size: 13px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card-section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.section-body { display: flex; flex-direction: column; gap: 8px; }
.access-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.access-row:last-child { border-bottom: 0; }
.access-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line-2); }
.access-row.has .dot { background: var(--ok); box-shadow: 0 0 8px rgba(61, 220, 151, .6); }
.access-main { flex: 1; min-width: 0; }
.access-title { font-weight: 600; }
.access-row.no .access-title { color: var(--text-2); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.inline-form .select, .inline-form .input { flex: 1; min-width: 0; }
.inline-form.wrap { flex-wrap: wrap; }
.inline-form.wrap .input, .inline-form.wrap .select { flex: 1 1 160px; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.kv > :last-child { text-align: right; overflow-wrap: anywhere; }

/* ---------- группы ---------- */
.split { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; align-items: start; }
.split-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 78px; max-height: calc(100vh - 100px); overflow-y: auto; }
.split-list .search { max-width: none; flex: none; }
.split-detail { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; min-height: 240px; }
.split-detail .card-section { background: var(--bg-2); }
.group-item { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm); text-decoration: none; border: 1px solid transparent; }
.group-item:hover { background: var(--panel-2); }
.group-item.active { background: var(--accent-soft); border-color: rgba(124, 92, 255, .4); }
.group-item-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.suggest-wrap { position: relative; margin-bottom: 10px; }
.suggest-wrap .search { max-width: none; }
.suggest { position: absolute; left: 0; right: 0; top: 40px; z-index: 10; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow); overflow: hidden; }
.suggest:empty { display: none; }
.suggest-item { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 90px 1fr 1fr; gap: 10px; width: 100%; padding: 8px 12px; cursor: pointer; }
.suggest-item:hover, .suggest-item:focus-visible { background: var(--accent-soft); }
.suggest-empty { padding: 10px 12px; }

/* ---------- сервисы ---------- */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.svc-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.svc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.svc-head h3 { margin: 0; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); }
.svc-stat { padding: 8px 0; color: var(--text-2); }
.svc-stat b { font-size: 24px; color: var(--text); font-weight: 700; }

/* ---------- синхронизация ---------- */
.status-card { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 18px 20px; }
.status-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line-2); flex: none; }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 12px rgba(61, 220, 151, .7); }
.status-dot.bad { background: var(--bad); box-shadow: 0 0 12px rgba(255, 93, 122, .7); }
.status-dot.run { background: var(--accent); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }
.status-title { font-weight: 600; font-size: 16px; }
.status-card .stats { margin-left: auto; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat { min-width: 86px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); }
.stat-v { font-size: 18px; font-weight: 700; }
.stat-l { font-size: 11px; color: var(--text-3); }
.stat-bad .stat-v { color: var(--bad); }
.result-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; border-color: rgba(124, 92, 255, .45); }
.result-card h3 { margin: 0; }
#sync-body { display: flex; flex-direction: column; gap: 16px; }

/* ---------- экраны входа/ошибок ---------- */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.center-card { width: 100%; max-width: 440px; padding: 34px 32px; text-align: center; background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.center-card .brand { margin-bottom: 14px; }
.center-icon { width: 54px; height: 54px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.center-icon .icon { width: 26px; height: 26px; }
.center-actions { margin-top: 14px; display: flex; gap: 10px; }

/* ---------- адаптив ---------- */
@media (max-width: 960px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; overflow-x: auto; position: static; }
  .nav-link span { white-space: nowrap; }
  .main { padding: 18px 16px 40px; }
  .split { grid-template-columns: 1fr; }
  .split-list { position: static; max-height: none; }
  .topbar-title { display: none; }
  .checks { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .who { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
