/* Kavinsky - панель бота. Матовое стекло поверх тёмного графита, один тёплый акцент.
 * Размеры и состояния элементов - как у shadcn/ui (кнопка 36px, поле 36-38px, кольцо фокуса 3px). */
:root {
  /* Фон и стекло */
  --bg: #111113;
  --glass: rgba(255, 255, 255, .05);
  --glass-2: rgba(255, 255, 255, .08);
  --glass-3: rgba(255, 255, 255, .12);
  --glass-bar: rgba(17, 17, 19, .7);
  --glass-pop: rgba(28, 28, 31, .88);
  --inset: rgba(0, 0, 0, .24);
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .14);
  --line-3: rgba(255, 255, 255, .22);
  --highlight: rgba(255, 255, 255, .07);
  --blur: saturate(150%) blur(18px);
  /* Текст */
  --text: #eee8dd;
  --muted: #aca69c;
  --faint: #8a857d;
  /* Цвета с аватарки и баннера: пыльная лаванда, графит и кремовый */
  --accent: #8a80a2;
  --accent-2: #b5acc9;
  --accent-soft: rgba(138, 128, 162, .18);
  --accent-line: rgba(166, 156, 196, .55);
  --ring: rgba(166, 156, 196, .42);
  --primary: #f2e9da;
  --primary-ink: #1c1b1e;
  /* Состояния */
  --ok: #6fcf97;
  --warn: #e8c35a;
  --bad: #ef7c7c;
  --info: #7fb4e6;
  /* Форма */
  --radius: 14px;
  --radius-md: 9px;
  --radius-sm: 7px;
  --shadow: inset 0 1px 0 var(--highlight), 0 18px 40px -22px rgba(0, 0, 0, .75);
  --shadow-pop: inset 0 1px 0 var(--highlight), 0 24px 60px -18px rgba(0, 0, 0, .8);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "Onest", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", Consolas, ui-monospace, monospace;
  --topbar: 56px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--bg); }
body {
  position: relative; z-index: 0; margin: 0; min-height: 100dvh; color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  /* Подвал всегда внизу экрана, а не посреди короткой страницы */
  display: flex; flex-direction: column;
}
body > .layout, body > main { flex: 1 0 auto; }
/* Ровный фон с лёгким зерном - без градиентов */
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
::selection { background: rgba(138, 128, 162, .45); color: #fff; }

a { color: var(--accent-2); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
a:focus-visible, summary:focus-visible, .nav a:focus-visible, .tabs a:focus-visible, .guild-switch:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--ring); border-radius: var(--radius-md);
}
code, kbd {
  font-family: var(--mono); font-size: .86em; background: rgba(255, 255, 255, .07); border: 1px solid var(--line);
  padding: .08em .38em; border-radius: 6px;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; margin-top: 1.7em; }
h3 { font-size: 15.5px; font-weight: 600; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.num, .mono, td.num { font-variant-numeric: tabular-nums; }

/* Иконки Lucide */
.i { width: 18px; height: 18px; flex: none; stroke-width: 1.8; vertical-align: -.2em; }
.i.sm { width: 15px; height: 15px; }
.i.lg { width: 22px; height: 22px; }
.i.ok { color: var(--ok); } .i.warn { color: var(--warn); } .i.bad { color: var(--bad); } .i.info { color: var(--info); }
h1 .h-ico {
  display: inline-grid; place-items: center; width: 38px; height: 38px; margin-right: 12px; vertical-align: -8px;
  border-radius: 11px; background: var(--glass-2); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--highlight);
}
h1 .h-ico .i { width: 19px; height: 19px; color: var(--accent-2); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-md);
  background: var(--primary); color: var(--primary-ink); font-weight: 600;
}
.skip:focus { top: 10px; text-decoration: none; }

/* ---------- Каркас ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  height: var(--topbar); padding: 0 18px; background: var(--glass-bar);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
/* Логотип - буква «F» с аватарки (app/web/static/brand/mark.png) */
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: block; flex: none; overflow: hidden;
  border: 1px solid var(--line-2); box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .6);
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.topbar .spacer { flex: 1; }
.owner-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; padding: 6px 10px; border-radius: var(--radius-md); }
.owner-link:hover { color: var(--text); background: var(--glass-2); text-decoration: none; }
.owner-link .i { color: var(--accent-2); width: 16px; height: 16px; }
.userchip { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13.5px; }
.userchip img { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-2); }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 12px; font-weight: 500;
  padding: 3px 10px 3px 8px; border-radius: 99px; border: 1px solid var(--line); background: var(--glass); color: var(--muted);
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status-pill.on { color: #bfe9cf; } .status-pill.on::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(111, 207, 151, .16); }
.status-pill.off { color: #f0dca4; } .status-pill.off::before { background: var(--warn); }

.layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); }
.layout.solo { grid-template-columns: minmax(0, 1fr); }
.sidebar {
  position: sticky; top: calc(var(--topbar) + 12px); height: calc(100dvh - var(--topbar) - 24px); overflow-y: auto;
  margin: 12px 0 12px 12px; padding: 12px 10px; border-radius: 16px;
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.guild-switch {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 11px; color: var(--text); margin-bottom: 10px;
  border: 1px solid transparent; transition: background .15s var(--ease), border-color .15s var(--ease);
}
.guild-switch:hover { text-decoration: none; background: var(--glass-2); border-color: var(--line); }
.guild-switch .gname { font-weight: 600; line-height: 1.25; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-switch .gsub { font-size: 12px; color: var(--muted); }
.guild-switch .gtext { min-width: 0; flex: 1; }
.guild-switch .i { color: var(--faint); }
.gicon {
  width: 36px; height: 36px; border-radius: 11px; flex: none; display: grid; place-items: center; font-weight: 650;
  background: var(--glass-2); border: 1px solid var(--line); color: var(--muted); overflow: hidden;
}
.gicon img { width: 100%; height: 100%; object-fit: cover; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 7px 10px; border-radius: var(--radius-md);
  color: var(--muted); font-size: 14px; font-weight: 500; margin-bottom: 1px; transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--glass-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--glass-3); color: var(--text); box-shadow: inset 0 1px 0 var(--highlight); }
.nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav .ico { display: grid; place-items: center; width: 20px; }
.nav .ico .i { width: 17px; height: 17px; }
.nav a.active .ico .i { color: var(--accent-2); }
.nav .divider { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 18px 10px 6px; }
.plan-box { margin-top: 14px; padding: 12px; border-radius: 11px; background: var(--inset); border: 1px solid var(--line); font-size: 13px; }
.plan-box b { display: block; font-size: 14px; }
.plan-box a { display: inline-flex; align-items: center; gap: 4px; }

.content { padding: 30px 34px 90px; max-width: 1080px; width: 100%; }
.content.wide { max-width: 1280px; }
main.content:focus { outline: none; }
.lede { color: var(--muted); font-size: 15px; max-width: 760px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; }
.footer { flex-shrink: 0; color: var(--faint); font-size: 12px; padding: 12px 24px; border-top: 1px solid var(--line); }
.footer a { color: var(--muted); }

/* ---------- Стеклянные поверхности ---------- */
.card, .stat, .server-card, .feats, .login-card {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.card { padding: 18px 20px; margin-bottom: 14px; }
a.card { display: block; color: inherit; transition: border-color .15s var(--ease), background .15s var(--ease), transform .15s var(--ease); }
a.card:hover { text-decoration: none; border-color: var(--line-2); background: var(--glass-2); }
.card.flat { background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.card h3 { margin-bottom: .35em; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { padding: 16px 18px; }
.stat .num { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.note {
  border: 1px solid rgba(127, 180, 230, .22); background: rgba(127, 180, 230, .07); border-radius: 11px; padding: 12px 14px;
  color: var(--muted); font-size: 14px; margin: 12px 0;
}
.note b { color: var(--text); }
.note.warn { background: rgba(232, 195, 90, .07); border-color: rgba(232, 195, 90, .28); }
.note.bad { background: rgba(239, 124, 124, .07); border-color: rgba(239, 124, 124, .3); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------- Функции: сгруппированный список, как в настройках приложений ---------- */
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 28px 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(111, 207, 151, .15); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(232, 195, 90, .15); }
.dot-none { background: #50525a; }
.dot-lock { background: #6b6d75; }
.feats { display: grid; gap: 0; padding: 4px; }
.feat {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 14px 12px; border-radius: 11px; transition: background .15s var(--ease);
}
.feat + .feat { box-shadow: 0 -1px 0 var(--line); }
.feat:hover { background: rgba(255, 255, 255, .035); }
.feat.locked { opacity: .6; }
.feat-icon {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--text);
  background: var(--glass-2); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--highlight);
}
.feat-icon .i { width: 19px; height: 19px; }
.feat-title { font-weight: 600; color: var(--text); font-size: 15px; }
.feat-title:hover { color: var(--text); }
.feat-state { display: block; font-size: 13px; color: var(--muted); margin: 2px 0 4px; }
.feat-desc { color: var(--muted); font-size: 14px; display: block; }
.feat-hint { display: block; font-size: 13px; color: var(--warn); margin-top: 5px; }
.feat-hint.info { color: var(--faint); }
.feat-needs { display: block; font-size: 13px; color: var(--faint); margin-top: 5px; }
.feat-actions { display: flex; align-items: center; gap: 10px; padding-top: 8px; }
.feats > .chips { padding: 0 12px 14px 66px; margin: -6px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; background: var(--inset); color: var(--muted); border: 1px solid var(--line); }
.chip code { background: none; border: 0; padding: 0; color: var(--text); }

/* Переключатель (как Switch в shadcn, чуть крупнее для пальца) */
.tgl { position: relative; display: inline-flex; align-items: center; cursor: pointer; padding: 4px; margin: -4px; }
.tgl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw {
  width: 38px; height: 22px; border-radius: 99px; background: rgba(255, 255, 255, .14); position: relative; flex: none;
  border: 1px solid var(--line); transition: background .18s var(--ease), border-color .18s var(--ease);
}
.sw::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #d9d9dc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45); transition: transform .18s var(--ease), background .18s var(--ease);
}
.tgl input:checked + .sw { background: var(--accent); border-color: var(--accent); }
.tgl input:checked + .sw::after { transform: translateX(16px); background: #fff; }
.tgl input:focus-visible + .sw { box-shadow: 0 0 0 3px var(--ring); }
.tgl input:disabled + .sw { opacity: .4; cursor: not-allowed; }
.tgl-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tgl-row:last-child { border-bottom: 0; }
.tgl-row .tgl { margin-top: -2px; }
.tgl-text { cursor: pointer; }

/* ---------- Формы ---------- */
.field { margin-bottom: 18px; }
.field > label, .field .flabel { display: flex; align-items: center; gap: 6px; font-weight: 550; font-size: 14px; margin-bottom: 5px; }
.field .fhint { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.field .ferr { color: var(--bad); font-size: 13px; margin-top: 6px; }
input[type=text], input[type=number], input[type=url], input[type=search], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; max-width: 100%; min-height: 38px; background: var(--inset); color: var(--text); border: 1px solid var(--line-2);
  border-radius: var(--radius-md); padding: 8px 12px; font: inherit; font-size: 14.5px; outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25); transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--line-3); }
input:focus, select:focus, textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--ring); background: rgba(0, 0, 0, .3); }
textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 13px; }
select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3a4ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 16px;
}
select option, select optgroup { background: #1a1b1f; color: var(--text); }
input[type=file] { font: inherit; font-size: 13.5px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-size: 13px; font-weight: 550; color: var(--text); margin-right: 12px; padding: 6px 12px; min-height: 32px;
  border-radius: var(--radius-md); border: 1px solid var(--line-2); background: var(--glass-2); cursor: pointer;
  box-shadow: inset 0 1px 0 var(--highlight); transition: background .15s var(--ease), border-color .15s var(--ease);
}
input[type=file]::file-selector-button:hover { background: var(--glass-3); border-color: var(--line-3); }
input[type=file]:focus-visible { outline: none; }
input[type=file]:focus-visible::file-selector-button { box-shadow: 0 0 0 3px var(--ring); }
input.narrow, select.narrow { max-width: 340px; }
input[type=number] { max-width: 180px; font-variant-numeric: tabular-nums; }
input[type=checkbox]:not(.tgl input):not(.pick input) { accent-color: var(--accent); width: 16px; height: 16px; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form > * { flex: none; }
.inline-form > span { flex: 1 1 180px; min-width: 0; }
.inline-form select, .inline-form input[type=text] { width: auto; min-width: min(240px, 100%); flex: 1; }

.help { position: relative; display: inline-flex; }
.help-btn {
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--glass-2); color: var(--muted);
  font-size: 11px; font-weight: 700; cursor: pointer; display: grid; place-items: center; padding: 0; line-height: 1;
}
.help-btn:hover, .help.open .help-btn { color: var(--text); border-color: var(--accent-line); }
.help-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.help-pop {
  display: none; position: absolute; left: 26px; top: -8px; width: 320px; z-index: 40; background: var(--glass-pop); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 11px; padding: 10px 12px; font-size: 13px; font-weight: 400; line-height: 1.5;
  box-shadow: var(--shadow-pop); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.help.open .help-pop { display: block; }

/* Выбор ролей и каналов */
.picker { border: 1px solid var(--line-2); border-radius: 11px; background: var(--inset); }
.picker-head { display: flex; gap: 8px; padding: 8px; border-bottom: 1px solid var(--line); align-items: center; }
.picker-head input { min-height: 32px; padding: 5px 10px; font-size: 13.5px; background: rgba(255, 255, 255, .04); }
.picker-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.picker-list { max-height: 228px; overflow-y: auto; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; scrollbar-width: thin; }
.pick {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 11px 4px 9px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--glass); cursor: pointer; font-size: 13.5px; user-select: none; color: var(--muted);
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.pick input { display: none; }
.pick .rc { width: 10px; height: 10px; border-radius: 50%; background: #9a9ca6; flex: none; }
.pick:hover { border-color: var(--line-2); color: var(--text); }
.pick.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.pick .note-tag { font-size: 11px; color: var(--faint); }
.pick.dim { opacity: .55; }

/* ---------- Кнопки (варианты shadcn: default → primary, outline → .btn, ghost, destructive → danger) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 7px 15px;
  border: 1px solid var(--line-2); background: var(--glass-2); color: var(--text); border-radius: var(--radius-md);
  font: inherit; font-size: 14px; font-weight: 550; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: inset 0 1px 0 var(--highlight); touch-action: manipulation;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .08s var(--ease);
}
.btn .i { width: 16px; height: 16px; }
.btn:hover { background: var(--glass-3); border-color: var(--line-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 6px 18px -8px rgba(0, 0, 0, .7); }
.btn.primary:hover { background: #f8f1e5; border-color: #f8f1e5; }
.btn.danger { background: rgba(239, 124, 124, .12); border-color: rgba(239, 124, 124, .38); color: #f6adad; }
.btn.danger:hover { background: rgba(239, 124, 124, .2); }
.btn.ok { background: rgba(111, 207, 151, .12); border-color: rgba(111, 207, 151, .36); color: #a5e3bf; }
.btn.ok:hover { background: rgba(111, 207, 151, .2); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--glass-2); color: var(--text); }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; gap: 6px; }
.btn.sm .i { width: 15px; height: 15px; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; min-height: 44px; font-size: 15px; font-weight: 600; padding: 10px 20px; }
.btn.discord:hover { background: #4f5bdb; border-color: #4f5bdb; }
.btn.discord .i { width: 20px; height: 20px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Панель «сохранить изменения» */
.savebar {
  position: sticky; bottom: 16px; z-index: 25; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--glass-pop); border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 10px 10px 18px; margin-top: 18px;
  box-shadow: var(--shadow-pop); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.savebar .msg { color: var(--muted); font-size: 14px; }
.js .savebar { opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease); }
.js form.dirty .savebar { opacity: 1; transform: none; pointer-events: auto; }
.js form.dirty .savebar .msg { color: var(--warn); }

/* Таблицы настроек функции */
.rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin: 10px 0; }
.row-item { border: 1px solid var(--line); border-radius: 11px; background: var(--inset); transition: border-color .15s var(--ease); }
.row-item:hover { border-color: var(--line-2); }
.row-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 46px; }
.row-head .grip {
  cursor: grab; color: var(--faint); padding: 4px; border-radius: 6px; user-select: none; background: none; border: 0;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
}
.row-head .grip:hover { color: var(--text); background: var(--glass-2); }
.row-head .grip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.row-title { font-weight: 600; flex: 0 1 auto; max-width: 45%; min-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-summary { color: var(--muted); font-size: 13px; display: flex; gap: 12px; flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; }
.row-summary > span { overflow: hidden; text-overflow: ellipsis; }
.row-edit { display: inline-flex; align-items: center; gap: 4px; }
.row-edit .i { transition: transform .15s var(--ease); }
.row-item.open .row-edit .i { transform: rotate(180deg); }
.row-body { border-top: 1px solid var(--line); padding: 14px; display: none; }
.row-item.open { border-color: var(--line-2); }
.row-item.open .row-body { display: block; }
.row-item.dragging { opacity: .5; }
.row-item.drop-target { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.add-row { border: 1px dashed var(--line-2); border-radius: 11px; padding: 14px; margin-top: 10px; background: rgba(0, 0, 0, .12); }
.add-row .fields-inline { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.add-row .field { margin-bottom: 0; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; color: var(--faint); font-weight: 550; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s var(--ease); }
table.data tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 550; line-height: 1.5; padding: 1px 8px;
  border-radius: 6px; background: var(--glass-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; vertical-align: 1px;
}
.badge .i { width: 13px; height: 13px; }
.badge.ok { color: #a5e3bf; border-color: rgba(111, 207, 151, .3); background: rgba(111, 207, 151, .09); }
.badge.warn { color: #f0dca4; border-color: rgba(232, 195, 90, .3); background: rgba(232, 195, 90, .09); }
.badge.bad { color: #f6adad; border-color: rgba(239, 124, 124, .32); background: rgba(239, 124, 124, .09); }
.badge.info { color: #b3d4f3; border-color: rgba(127, 180, 230, .3); background: rgba(127, 180, 230, .09); }
.user { display: inline-flex; align-items: center; gap: 8px; }
.user img { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); }
.state-line { display: inline-flex; align-items: center; gap: 6px; }

/* Предпросмотр Discord - цвета самого Discord, чтобы было видно, как выйдет на сервере */
.dc-preview {
  --dc-accent: #8a80a2;
  background: #313338; border-radius: 12px; padding: 16px; color: #dbdee1; font-family: "gg sans", var(--font);
  border: 1px solid rgba(255, 255, 255, .06); box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .8);
}
.dc-msg { display: grid; grid-template-columns: 40px 1fr; gap: 12px; }
.dc-ava { display: block; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #1e1f22; }
.dc-name { font-weight: 600; color: #f2f3f5; }
.dc-name .bot { background: #5865f2; color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: 2px; }
.dc-box { margin-top: 6px; background: #2b2d31; border-left: 4px solid var(--dc-accent); border-radius: 8px; padding: 12px 14px; max-width: 520px; }
.dc-box img.banner { width: 100%; border-radius: 6px; margin-bottom: 10px; display: block; }
.dc-box .dc-list { margin-top: 10px; padding-top: 10px; border-top: 1px solid #3f4147; color: #b5bac1; font-size: 14px; }
.dc-md { font-size: 14.5px; line-height: 1.4; word-wrap: break-word; }
.dc-md h1 { font-size: 22px; margin: 6px 0; } .dc-md h2 { font-size: 19px; margin: 6px 0; } .dc-md h3 { font-size: 16px; margin: 6px 0; }
.dc-md .sub { font-size: 12px; color: #949ba4; }
.dc-md blockquote { margin: 2px 0; padding-left: 10px; border-left: 4px solid #4e5058; }
.dc-md code { background: #1e1f22; border: 0; }
.dc-md pre { background: #1e1f22; padding: 8px; border-radius: 6px; white-space: pre-wrap; }
.dc-md .mention { background: rgba(88, 101, 242, .3); color: #c9cdfb; padding: 0 3px; border-radius: 3px; }
.dc-md .spoiler { background: #1e1f22; color: transparent; border-radius: 3px; }
.dc-md .spoiler:hover { color: inherit; }
.dc-md ul { margin: 4px 0; padding-left: 22px; }
.dc-md a { color: #00a8fc; }
.dc-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.dc-btn { background: #4e5058; color: #fff; font-size: 14px; padding: 6px 14px; border-radius: 6px; }
.dc-btn.primary { background: #5865f2; }
.dc-select { margin-top: 10px; background: #1e1f22; border: 1px solid #1e1f22; color: #949ba4; padding: 9px 12px; border-radius: 6px; font-size: 14px; }

/* Всплывающие сообщения */
.flashes { position: fixed; right: 18px; top: calc(var(--topbar) + 14px); z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100vw - 36px)); }
.flash {
  position: relative; background: var(--glass-pop); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 38px 12px 36px;
  box-shadow: var(--shadow-pop); font-size: 14px; animation: slide .22s var(--ease); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.flash::before { content: ""; position: absolute; left: 14px; top: 17px; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(111, 207, 151, .16); }
.flash.error::before { background: var(--bad); box-shadow: 0 0 0 3px rgba(239, 124, 124, .16); }
.flash.info::before { background: var(--info); box-shadow: 0 0 0 3px rgba(127, 180, 230, .16); }
.flash .x {
  position: absolute; top: 7px; right: 7px; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
}
.flash .x:hover { background: var(--glass-2); color: var(--text); }
@keyframes slide { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Серверы */
.servers { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.server-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: border-color .15s var(--ease); }
.server-card:hover { border-color: var(--line-2); }
.server-card .top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.server-card .gicon { width: 50px; height: 50px; border-radius: 15px; font-size: 19px; }
.server-card .name { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-card .meta { color: var(--muted); font-size: 13px; }
.server-card .actions { display: flex; gap: 8px; margin-top: auto; }

/* Вход */
.login-card { --pad: 32px; max-width: 440px; margin: 72px auto; border-radius: 20px; padding: var(--pad); overflow: hidden; }
/* Баннер с Discord-профиля бота во всю ширину карточки */
.login-banner {
  display: block; width: calc(100% + 2 * var(--pad)); max-width: none; height: auto; aspect-ratio: 17 / 6; object-fit: cover;
  margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 26px; border-bottom: 1px solid var(--line);
}
.login-card h1 { font-size: 24px; }
.check-list { list-style: none; padding: 0; margin: 10px 0 16px; display: grid; gap: 8px; color: var(--muted); }
.check-list li { display: flex; gap: 10px; align-items: flex-start; }
.check-list .i { width: 17px; height: 17px; color: var(--ok); margin-top: 2px; }
.login-card ul:not(.check-list) { color: var(--muted); padding-left: 20px; }
.divider-text { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12.5px; margin: 14px 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Графики */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bars .b { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; transition: opacity .12s; }
.bars .b:hover { opacity: 1; }
.bars .b.zero { background: var(--line-2); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 60px; gap: 10px; align-items: center; margin-bottom: 8px; }
.bar-row .track { height: 8px; background: var(--inset); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 99px; }

/* Табы - как TabsList в shadcn */
.tabs {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; margin: 10px 0 18px; border-radius: 11px;
  background: var(--inset); border: 1px solid var(--line);
}
.tabs a {
  display: inline-flex; align-items: center; min-height: 30px; padding: 5px 13px; border-radius: 8px; border: 1px solid transparent;
  color: var(--muted); font-size: 13.5px; font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease);
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on { background: var(--glass-3); color: var(--text); border-color: var(--line-2); box-shadow: inset 0 1px 0 var(--highlight); }

details.box { border: 1px solid var(--line); border-radius: 11px; padding: 0; margin: 10px 0; background: var(--inset); }
details.box > summary { cursor: pointer; padding: 12px 14px; font-weight: 550; list-style: none; display: flex; align-items: center; gap: 8px; }
details.box > summary::-webkit-details-marker { display: none; }
details.box > summary::before {
  content: ""; width: 16px; height: 16px; flex: none; background: var(--muted); transition: transform .15s var(--ease);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m9 18 6-6-6-6'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m9 18 6-6-6-6'/></svg>") center / contain no-repeat;
}
details.box[open] > summary::before { transform: rotate(90deg); }
details.box > summary:hover { color: var(--text); }
details.box > .inner { padding: 0 14px 14px; }

dialog.confirm {
  background: var(--glass-pop); color: var(--text); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; max-width: 440px;
  box-shadow: var(--shadow-pop); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
dialog.confirm::backdrop { background: rgba(6, 7, 9, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 7px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.answer { background: var(--inset); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; margin: 6px 0; white-space: pre-wrap; }
.answer .q { color: var(--muted); font-size: 13px; margin-bottom: 3px; white-space: normal; }

/* Без поддержки размытия стекло становится плотнее, чтобы текст читался */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .topbar, .savebar, .flash, .help-pop, dialog.confirm { background: #16171b; }
  .card, .stat, .server-card, .feats, .login-card, .sidebar { background: #141519; }
}
@media (prefers-reduced-transparency: reduce) {
  body::after { display: none; }
  .topbar, .savebar, .flash, .help-pop, dialog.confirm { background: #16171b; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .card, .stat, .server-card, .feats, .login-card, .sidebar { background: #141519; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  table.data { display: block; overflow-x: auto; }
  table.data.stack { display: table; }
  table.data.stack thead { display: none; }
  table.data.stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.data.stack tr:last-child { border-bottom: 0; }
  table.data.stack td { display: block; padding: 4px 0; border-bottom: 0; }
  .sidebar {
    position: static; height: auto; margin: 10px 12px 0; padding: 8px; border-radius: 14px; overflow: visible;
  }
  .guild-switch { margin-bottom: 6px; }
  .nav { position: relative; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: none; margin: 0; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; white-space: nowrap; min-height: 34px; }
  .nav a.active::before { display: none; }
  .nav a.active { border-color: var(--accent-line); }
  .nav .divider, .sidebar .plan-box { display: none; }
  .content { padding: 22px 16px 90px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .feat { grid-template-columns: 40px minmax(0, 1fr); }
  .feat-actions { grid-column: 2 / -1; padding-top: 0; }
  .feats > .chips { padding-left: 12px; }
  .kv { grid-template-columns: 1fr; }
  .help-pop { left: auto; right: -10px; top: 24px; width: min(300px, 80vw); }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .userchip .uname, .owner-link .ol-text, .topbar .logout-text { display: none; }
  .login-card { margin: 32px 16px; --pad: 24px; }
  h1 .h-ico { width: 34px; height: 34px; margin-right: 10px; vertical-align: -7px; }
  .savebar { flex-wrap: wrap; }
}
