:root {
  color-scheme: dark;
  /* серии графиков (проверены на контраст и дальтонизм для тёмного и светлого фона) */
  --viz-1: #3987e5;
  --viz-2: #d95926;
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d212a;
  --surface-3: #262b36;
  --border: #2a303c;
  --text: #eceef2;
  --text-2: #b4bbc8;
  --muted: #818999;
  --accent: #e6b43c;
  --accent-ink: #1a1405;
  --accent-soft: rgba(230, 180, 60, 0.13);
  --series: #3987e5;
  --good: #2fb344;
  --warn: #e8862e;
  --bad: #e5544f;
  --info: #4c9bf0;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --paper: #fcfcfa;
  --paper-ink: #17181a;
}

:root[data-theme="light"] {
  color-scheme: light;
  --viz-1: #2a78d6;
  --viz-2: #eb6834;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --surface-3: #e9ebf0;
  --border: #dfe2e9;
  --text: #15171c;
  --text-2: #454b58;
  --muted: #6e7686;
  --accent: #a3740a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(163, 116, 10, 0.1);
  --series: #2a78d6;
  --good: #16803a;
  --warn: #b85c0a;
  --bad: #c7362f;
  --info: #1d6fd0;
  --shadow: 0 12px 32px rgba(20, 25, 40, 0.12);
}

/* ---------- темы: выбираются в меню (палитра внизу), хранятся в localStorage ----------
   --bg-image - фон страницы (градиенты), --accent-grad - заливка главных кнопок */

:root[data-theme="pink"] {
  --bg: #0b0609;
  --bg-image: radial-gradient(1200px 700px at 100% -10%, rgba(255, 64, 160, 0.28), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(190, 40, 140, 0.24), transparent 60%), #0b0609;
  --surface: rgba(24, 12, 20, 0.88);
  --surface-2: rgba(36, 16, 29, 0.9);
  --surface-3: #3a1a2e;
  --border: #3d1f33;
  --text: #fbeef6;
  --text-2: #e3bcd3;
  --muted: #a77f97;
  --accent: #ff4fa8;
  --accent-ink: #1a0510;
  --accent-soft: rgba(255, 79, 168, 0.16);
  --accent-grad: linear-gradient(135deg, #ff7ac2, #ff2d8f 55%, #c21877);
  --series: #ff6fb7;
}

:root[data-theme="midnight"] {
  --bg: #070b16;
  --bg-image: radial-gradient(1000px 600px at 90% -10%, rgba(70, 110, 255, 0.22), transparent 60%), #070b16;
  --surface: rgba(14, 20, 38, 0.9);
  --surface-2: #131b33;
  --surface-3: #1c2647;
  --border: #22305a;
  --text: #e8edff;
  --text-2: #aab6dc;
  --muted: #7482ab;
  --accent: #6c8cff;
  --accent-ink: #050a1f;
  --accent-soft: rgba(108, 140, 255, 0.16);
  --accent-grad: linear-gradient(135deg, #8aa4ff, #5a72ff);
}

:root[data-theme="emerald"] {
  --bg: #06110d;
  --bg-image: radial-gradient(1000px 600px at 100% 0%, rgba(30, 200, 130, 0.18), transparent 60%), #06110d;
  --surface: rgba(12, 28, 22, 0.9);
  --surface-2: #10261d;
  --surface-3: #173528;
  --border: #1d3d2f;
  --text: #e6f6ef;
  --text-2: #a9d2c0;
  --muted: #6f9a87;
  --accent: #2ed39a;
  --accent-ink: #03140d;
  --accent-soft: rgba(46, 211, 154, 0.15);
  --accent-grad: linear-gradient(135deg, #5ef0b8, #1fae7c);
}

:root[data-theme="amethyst"] {
  --bg: #0d0816;
  --bg-image: radial-gradient(1100px 650px at 0% -10%, rgba(150, 80, 255, 0.25), transparent 60%),
    radial-gradient(800px 500px at 110% 100%, rgba(90, 60, 220, 0.2), transparent 60%), #0d0816;
  --surface: rgba(22, 14, 36, 0.9);
  --surface-2: #1f1533;
  --surface-3: #2c1f48;
  --border: #33255a;
  --text: #f1eaff;
  --text-2: #c7b6ea;
  --muted: #8f7db4;
  --accent: #a77bff;
  --accent-ink: #0e0520;
  --accent-soft: rgba(167, 123, 255, 0.16);
  --accent-grad: linear-gradient(135deg, #c3a2ff, #8a55ff);
}

:root[data-theme="crimson"] {
  --bg: #0f0707;
  --bg-image: radial-gradient(1000px 600px at 100% -10%, rgba(200, 40, 40, 0.24), transparent 60%), #0f0707;
  --surface: rgba(28, 13, 13, 0.9);
  --surface-2: #261212;
  --surface-3: #361919;
  --border: #3e1e1e;
  --text: #fbecec;
  --text-2: #dcb3b3;
  --muted: #a27a7a;
  --accent: #e0423c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(224, 66, 60, 0.16);
  --accent-grad: linear-gradient(135deg, #f0625b, #b8312f);
}

:root[data-theme="ocean"] {
  --bg: #04111a;
  --bg-image: linear-gradient(160deg, #052033, #04111a 50%, #021a1f);
  --surface: rgba(8, 28, 40, 0.88);
  --surface-2: #0b2635;
  --surface-3: #113548;
  --border: #173f54;
  --text: #e4f6fb;
  --text-2: #a3cfdc;
  --muted: #6b9aa8;
  --accent: #22c3e6;
  --accent-ink: #021318;
  --accent-soft: rgba(34, 195, 230, 0.15);
  --accent-grad: linear-gradient(135deg, #4fdcf5, #1593c9);
}

:root[data-theme="sunset"] {
  --bg: #120a0c;
  --bg-image: radial-gradient(1100px 650px at 100% -10%, rgba(255, 120, 60, 0.26), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(230, 60, 120, 0.22), transparent 60%), #120a0c;
  --surface: rgba(30, 16, 18, 0.88);
  --surface-2: #2a1619;
  --surface-3: #3a2024;
  --border: #452529;
  --text: #fff0e8;
  --text-2: #e3bfae;
  --muted: #a8847a;
  --accent: #ff8a4c;
  --accent-ink: #1c0a03;
  --accent-soft: rgba(255, 138, 76, 0.16);
  --accent-grad: linear-gradient(135deg, #ffb35c, #ff6b5a 50%, #e8457f);
}

:root[data-theme="graphite"] {
  --bg: #0c0c0c;
  --surface: #151515;
  --surface-2: #1c1c1c;
  --surface-3: #262626;
  --border: #2c2c2c;
  --text: #f0f0f0;
  --text-2: #bdbdbd;
  --muted: #858585;
  --accent: #e8e8e8;
  --accent-ink: #111111;
  --accent-soft: rgba(255, 255, 255, 0.1);
}

:root[data-theme="sakura"] {
  color-scheme: light;
  --viz-1: #2a78d6;
  --viz-2: #eb6834;
  --bg: #fdf3f7;
  --bg-image: radial-gradient(1000px 600px at 100% -10%, rgba(255, 150, 200, 0.35), transparent 60%), #fdf3f7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-2: #fdf0f5;
  --surface-3: #f8e1eb;
  --border: #f0d3e0;
  --text: #2a1520;
  --text-2: #5e3a4c;
  --muted: #94707f;
  --accent: #d6337f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(214, 51, 127, 0.1);
  --accent-grad: linear-gradient(135deg, #f0619f, #c92470);
  --good: #16803a;
  --warn: #b85c0a;
  --bad: #c7362f;
  --info: #1d6fd0;
  --shadow: 0 12px 32px rgba(120, 40, 80, 0.12);
}

:root[data-theme="sand"] {
  color-scheme: light;
  --viz-1: #2a78d6;
  --viz-2: #eb6834;
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #f8f3e8;
  --surface-3: #eee6d6;
  --border: #e3d9c4;
  --text: #2a2418;
  --text-2: #5a4e38;
  --muted: #8a7d63;
  --accent: #9a6a12;
  --accent-ink: #ffffff;
  --accent-soft: rgba(154, 106, 18, 0.1);
  --good: #16803a;
  --warn: #b85c0a;
  --bad: #c7362f;
  --info: #1d6fd0;
  --shadow: 0 12px 32px rgba(60, 45, 20, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg-image, var(--bg));
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

svg.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* каркас */

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100%;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

/* верхняя панель с кнопкой меню - только на телефоне */
.topbar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  font-weight: 700;
  font-size: 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
}

/* логотип - картинка favicon.svg, у нее свой фон */
img.brand-mark.logo {
  display: block;
  background: none;
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(230, 180, 60, 0.18);
}

.topbar a {
  display: flex;
}

.brand small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-2);
  font-weight: 500;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav .count {
  margin-left: auto;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 12px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  min-width: 0;
}

.user-chip div {
  min-width: 0;
}

.user-chip b,
.user-chip small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip small {
  color: var(--muted);
  font-size: 12px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  object-fit: cover;
  flex: none;
}

.avatar.big {
  width: 76px;
  height: 76px;
}

.foot-actions {
  display: flex;
  gap: 6px;
}

.foot-actions .btn {
  flex: 1;
}

.main {
  padding: 28px 32px 60px;
  max-width: 1320px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* элементы */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-3);
}

.btn.primary {
  background: var(--accent-grad, var(--accent));
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.danger {
  color: var(--bad);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn.small {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.btn.icon-only {
  width: 36px;
  padding: 0;
}

.btn.small.icon-only {
  width: 30px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

input,
select,
textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  outline: none;
}

textarea {
  height: auto;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

label.field {
  display: block;
}

label.field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
}

.search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search svg {
  position: absolute;
  left: 11px;
  top: 9px;
  color: var(--muted);
}

.search input {
  padding-left: 36px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-head a,
.link {
  color: var(--accent);
  font-weight: 550;
  cursor: pointer;
}

.grid {
  display: grid;
  gap: 16px;
}

.tiles {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 16px;
}

.cols-2 {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: start;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tile.pick {
  cursor: pointer;
  transition: border-color 0.15s;
}

.tile.pick:hover,
.tile.pick.active {
  border-color: var(--accent);
}

.tile .label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
}

.tile .value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.tile .hint {
  color: var(--muted);
  font-size: 12.5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.dot.good,
.badge.good::before {
  background: var(--good);
}

.dot.warn,
.badge.warn::before {
  background: var(--warn);
}

.dot.bad,
.badge.bad::before {
  background: var(--bad);
}

.dot.info,
.badge.info::before {
  background: var(--info);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.badge.plain::before {
  display: none;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.chip:hover {
  color: var(--text);
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.chip b {
  color: var(--muted);
  font-weight: 500;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .spacer {
  flex: 1;
}

/* таблицы и списки */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table.data {
  width: 100%;
  border-collapse: collapse;
}

table.data th {
  padding: 10px 14px;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

table.data th[data-sort] {
  cursor: pointer;
}

table.data th[data-sort]:hover {
  color: var(--text);
}

table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tr:last-child td {
  border-bottom: none;
}

table.data tbody tr:hover {
  background: var(--surface-2);
}

table.data tr.clickable {
  cursor: pointer;
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sub {
  color: var(--muted);
  font-size: 12.5px;
}

.strong {
  font-weight: 600;
}

.nowrap {
  white-space: nowrap;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.list-row:first-child {
  padding-top: 0;
}

.list-row .grow {
  flex: 1;
  min-width: 0;
}

.list-row .grow > * {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-row a.grow:hover .strong {
  color: var(--accent);
}

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
}

.empty svg {
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 16px;
}

.notice svg {
  color: var(--warn);
  margin-top: 1px;
}

.notice p {
  margin: 2px 0 0;
  color: var(--text-2);
}

.skeleton {
  height: 120px;
  border-radius: var(--radius);
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--surface-2) 50%,
    var(--surface) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* графики */

.bar-rows {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  gap: 9px 12px;
  align-items: center;
}

.bar-rows .track {
  height: 10px;
}

.bar-rows .fill {
  height: 100%;
  min-width: 2px;
  border-radius: 0 4px 4px 0;
  background: var(--series);
}

.bar-rows .n {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.columns {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 150px;
  border-bottom: 1px solid var(--border);
}

.columns .col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  cursor: default;
}

.columns .col i {
  display: block;
  width: min(100%, 44px);
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: var(--series);
}

.columns .col:hover i {
  filter: brightness(1.2);
}

.columns .col span {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.columns-x {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.columns-x span {
  flex: 1;
  text-align: center;
  white-space: nowrap;
}

.stack {
  display: flex;
  gap: 2px;
  height: 10px;
  margin: 4px 0 12px;
}

.stack i {
  min-width: 3px;
  border-radius: 3px;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--text-2);
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#tooltip {
  position: fixed;
  z-index: 50;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  pointer-events: none;
  white-space: nowrap;
}

/* шаблоны */

.template-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.template-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}

.template-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.template-card p {
  margin: 0;
  color: var(--text-2);
  flex: 1;
}

.template-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.group-title {
  margin: 22px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.group-title:first-child {
  margin-top: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.workspace.editor {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inline {
  display: flex;
  gap: 8px;
}

.sticky {
  position: sticky;
  top: 16px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-2);
}

.tabs button {
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.tabs button.active {
  background: var(--surface-3);
  color: var(--text);
}

.paper {
  padding: 18px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: auto;
  word-break: break-word;
  min-height: 200px;
}

.paper img {
  max-width: 100%;
  vertical-align: bottom;
}

.paper table {
  width: 100%;
  border-collapse: collapse;
}

.paper td,
.paper th {
  padding: 10px;
  border: 1px solid #d5d8de;
}

.paper a {
  color: #1d6fd0;
  text-decoration: underline;
}

.paper blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid #c9ccd3;
  background: #f1f2f4;
}

/* предпросмотр в оформлении форума: цвета и размеры взяты из его стилей */

.forum {
  --f-page: hsl(240, 2%, 12%);
  --f-bg: hsl(0, 0%, 15%);
  --f-alt: hsl(0, 0%, 19%);
  --f-text: #fff;
  --f-muted: hsl(0, 0%, 60%);
  --f-border: hsl(0, 0%, 22%);
  --f-border-light: hsl(0, 0%, 18%);
  --f-accent: hsl(22, 100%, 59%);
  padding: 12px;
  border-radius: 10px;
  background: var(--f-page);
  overflow-x: auto;
}

.forum.light {
  --f-page: hsl(214, 95%, 93%);
  --f-bg: hsl(214, 100%, 97%);
  --f-alt: hsl(214, 61%, 89%);
  --f-text: #000;
  --f-muted: hsl(214, 11%, 45%);
  --f-border: hsl(215, 32%, 93%);
  --f-border-light: hsl(215, 32%, 97%);
}

.forum-post {
  display: flex;
  padding: 6px;
  border-radius: 12px;
  background: var(--f-bg);
  color: var(--f-text);
  font: 15px/1.4 "Roboto", "Helvetica Neue", Helvetica, sans-serif;
}

.forum-user {
  flex: 0 0 170px;
  padding: 10px;
  border-radius: 12px;
  background: var(--f-alt);
  text-align: center;
}

.forum-user img {
  width: 96px;
  height: 96px;
  margin-bottom: 0.5em;
  border-radius: 50%;
  object-fit: cover;
}

.forum-user b {
  display: block;
  word-break: break-word;
}

.forum-user small {
  display: block;
  font-size: 12px;
}

.forum-user span {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  border: 1px solid var(--f-accent);
  border-radius: 2px;
  font-size: 75%;
}

.forum-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px;
}

.forum-date {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--f-border-light);
  color: var(--f-muted);
  font-size: 12px;
}

.forum-body {
  margin: 10px 0;
  word-break: break-word;
}

.forum-body img {
  max-width: 100%;
  vertical-align: bottom;
}

.forum-body table {
  max-width: 100%;
  border-collapse: collapse;
}

.forum-body td,
.forum-body th {
  padding: 3px;
  border: 1px solid var(--f-border);
  background: var(--f-bg);
}

.forum-body a {
  color: inherit;
  text-decoration: underline;
}

.forum-body blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--f-accent);
  background: var(--f-alt);
}

@media (max-width: 760px) {
  .forum-user {
    flex-basis: 110px;
  }

  .forum-user img {
    width: 64px;
    height: 64px;
  }
}

mark.missing {
  padding: 1px 4px;
  border-radius: 4px;
  background: #ffe08a;
  color: #4a3500;
  font-weight: 600;
  font-style: normal;
}

pre.code,
textarea.code {
  margin: 0;
  font: 13px/1.55 Consolas, "Cascadia Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

pre.code {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  max-height: 640px;
  overflow: auto;
}

.missing-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--text-2);
  font-size: 13px;
}

.missing-list button,
.var {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font: 12.5px Consolas, "Cascadia Mono", monospace;
  cursor: pointer;
}

.missing-list button {
  font-family: inherit;
  border-color: transparent;
  background: rgba(255, 200, 60, 0.18);
}

.var:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ready {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--good);
  font-weight: 600;
}

.bb-tools {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 9px 9px 0 0;
  background: var(--surface-2);
}

.bb-tools button {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.bb-tools button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.bb-tools .sep {
  width: 1px;
  margin: 4px 3px;
  background: var(--border);
}

.bb-tools + textarea {
  border-radius: 0 0 9px 9px;
  min-height: 380px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 118px auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.field-row .options {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 8px;
}

.field-row .hint {
  grid-column: 1 / -1;
}

label.field > span.field-hint,
.field-hint {
  display: block;
  margin: 4px 0 0;
  font-weight: 400;
  color: var(--muted);
  font-size: 12.5px;
}

.instructions {
  margin-bottom: 0;
  white-space: pre-line;
}

/* подсказки переменных в редакторе, как в VS Code */
.ac {
  position: fixed;
  z-index: 70;
  width: 360px;
  max-width: calc(100vw - 16px);
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ac div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
}

.ac div.active,
.ac div:hover {
  background: var(--accent-soft);
}

.ac code {
  color: var(--accent);
  font: 12.5px Consolas, "Cascadia Mono", monospace;
  white-space: nowrap;
}

.ac span {
  flex: 1;
  min-width: 0;
  color: var(--text-2);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac small {
  color: var(--muted);
  font-size: 11px;
}

.ac.picker div {
  align-items: center;
}

.ac.picker b {
  flex: none;
  max-width: 55%;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac.picker span {
  text-align: right;
}

.ac .ac-empty {
  color: var(--muted);
  cursor: default;
}

.field .bound {
  margin-left: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.notice.ogp {
  border-left-color: var(--accent);
}

.notice.ogp svg {
  color: var(--accent);
}

.notice.tech {
  border-left-color: var(--info);
}

.notice.tech svg {
  color: var(--info);
}

.segmented {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-2);
}

.segmented button {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.field-row .acts {
  display: flex;
  gap: 2px;
}

details.help {
  color: var(--text-2);
  font-size: 13px;
}

details.help summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 550;
}

details.help code,
.kbd {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  font: 12.5px Consolas, monospace;
}

details.help ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

/* рассылка: конструктор сообщений */

.bc-blk {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.bc-blk.t17 {
  border-left-color: var(--accent);
}

.bc-blk.t9 {
  border-left-color: var(--info);
}

.bc-blk.t1,
.bc-blk.t2 {
  border-left-color: var(--good);
}

.bc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border-bottom: 1px solid var(--border);
}

.bc-head .sub {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bc-head .spacer {
  flex: 1;
}

.bc-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
}

.bc-kids {
  display: flex;
  flex-direction: column;
}

.bc-kids .bc-blk {
  background: var(--surface);
}

.bc-add {
  max-width: 220px;
  height: 32px;
}

.bc-acc {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface);
}

.bc-item {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.bc-item .field {
  flex: 1;
}

.bc-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.bc-check input {
  width: auto;
  height: auto;
}

.bc-ranks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px 12px;
}

.bc-people {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
}

input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 2px;
}

/* превью сообщения как в Discord */
.dc-wrap {
  overflow-x: auto;
}

.dc {
  display: flex;
  gap: 12px;
  min-width: 420px;
  padding: 14px;
  border-radius: 8px;
  background: #313338;
  color: #dbdee1;
}

.dc-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: none;
}

.dc-body {
  flex: 1;
  min-width: 0;
  font: 15px/1.375 "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.dc-name {
  margin-bottom: 4px;
  font-weight: 600;
  color: #f2f3f5;
}

.dc-tag {
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 3px;
  background: #5865f2;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  vertical-align: 2px;
}

.dc-msg,
.dc-cont {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dc-cont {
  padding: 16px;
  border: 1px solid #3f4147;
  border-radius: 8px;
  background: #2b2d31;
}

.dc-sec {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.dc-grow {
  flex: 1;
  min-width: 0;
}

.dc-md {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.dc-md.h1 {
  font-size: 24px;
  font-weight: 700;
}

.dc-md.h2 {
  font-size: 20px;
  font-weight: 700;
}

.dc-md.h3 {
  font-size: 16px;
  font-weight: 700;
}

.dc-md.sub {
  color: #949ba4;
  font-size: 13px;
}

.dc-md.quote {
  padding-left: 12px;
  border-left: 4px solid #4e5058;
}

.dc-md code {
  padding: 0 0.2em;
  border-radius: 4px;
  background: #1e1f22;
  font: 85%/1.3 Consolas, monospace;
}

.dc-md a {
  color: #00a8fc;
}

.dc-mention {
  padding: 0 2px;
  border-radius: 3px;
  background: rgba(88, 101, 242, 0.3);
  color: #c9cdfb;
  font-weight: 500;
}

.dc-spoiler {
  border-radius: 3px;
  background: #1e1f22;
  color: transparent;
}

.dc-spoiler:hover {
  color: inherit;
}

.dc-emo {
  width: 1.375em;
  height: 1.375em;
  vertical-align: bottom;
}

.dc-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dc-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 16px;
  border-radius: 8px;
  background: #4e5058;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}

.dc-btn .dc-emo {
  width: 20px;
  height: 20px;
}

.dc-ext {
  opacity: 0.8;
  font-size: 11px;
}

.dc-thumb {
  width: 85px;
  height: 85px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
}

.dc-gal {
  display: grid;
  gap: 4px;
  overflow: hidden;
  border-radius: 8px;
}

.dc-gal.g2 {
  grid-template-columns: 1fr 1fr;
}

.dc-gal.g3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.dc-gi {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.dc-gal.g1 .dc-gi {
  height: auto;
  max-height: 350px;
}

.dc-ph {
  background: #1e1f22;
}

.dc hr {
  margin: 0;
  border: 0;
  border-top: 1px solid #3f4147;
}

/* боковая панель с деталями */

.drawer-back {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: min(440px, 100%);
  height: 100%;
  padding: 22px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kv {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 9px 12px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  word-break: break-word;
}

.copyable {
  cursor: pointer;
  border-bottom: 1px dashed var(--border);
}

.copyable:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* сотрудники и профиль */

.people {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.person-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.initials {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  flex: none;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.profile-head .grow {
  flex: 1;
  min-width: 200px;
}

.profile-head h1 {
  margin-bottom: 4px;
}

/* вход */

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(
      900px 500px at 50% -10%,
      var(--accent-soft),
      transparent 70%
    ),
    var(--bg);
}

.login .card {
  width: min(420px, 100%);
  padding: 30px;
  box-shadow: var(--shadow);
}

.login .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  margin-bottom: 16px;
}

.login .brand-mark svg {
  width: 24px;
  height: 24px;
}

.login p {
  margin: 6px 0 20px;
  color: var(--text-2);
}

.login .btn {
  width: 100%;
  height: 40px;
  margin-top: 12px;
}

.login .error {
  margin-top: 12px;
  color: var(--bad);
  font-weight: 550;
}

.login details {
  margin-top: 18px;
}

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-weight: 550;
}

.toast.error svg {
  color: var(--bad);
}

.toast.ok svg {
  color: var(--good);
}

@media (max-width: 1000px) {
  .workspace,
  .workspace.editor,
  .cols-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .sticky {
    position: static;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 10px 0 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .topbar .brand-mark {
    width: 32px;
    height: 32px;
    flex: none;
  }

  .topbar-title {
    flex: 1;
    min-width: 0;
    font-weight: 650;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar .count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
  }

  /* меню выезжает под верхней панелью на весь экран */
  .sidebar {
    display: none;
  }

  .shell.menu-open .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 39;
    display: flex;
    height: auto;
    padding: 12px;
    overflow-y: auto;
    border-right: none;
    animation: menu-in 0.16s ease-out;
  }

  .shell.menu-open .sidebar .brand {
    display: none;
  }

  .shell.menu-open .nav a {
    padding: 12px 14px;
    font-size: 15px;
  }

  .sidebar-foot {
    padding-top: 12px;
  }

  @keyframes menu-in {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
  }

  .main {
    padding: 18px 16px 48px;
  }

  /* плитки по две в ряд, заголовки карточек переносятся */
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .tile {
    padding: 14px;
  }

  .tile .value {
    font-size: 24px;
    word-break: break-word;
  }

  .card-head {
    flex-wrap: wrap;
  }

  h1 {
    font-size: 21px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

.forum-body .bb-spoiler {
  margin: 6px 0;
  padding: 6px 10px;
  border: 1px solid var(--f-border);
  border-radius: 4px;
}

.forum-body .bb-spoiler summary {
  cursor: pointer;
  font-weight: 600;
}

/* ---------- макросы: строки действий и игровой чат ---------- */

/* действие макроса: сверху выбор действия и кнопки, снизу ввод на всю ширину */
.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.action-row > select {
  grid-column: 1;
  grid-row: 1;
  max-width: 320px;
  min-width: 0;
}

.action-row > .acts {
  grid-column: 2;
  grid-row: 1;
}

.action-row > input,
.action-row > textarea,
.action-row > .sub,
.action-row > .anim-pick {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  width: 100%;
}

.action-row > .param-text {
  min-height: 38px;
  resize: none;
  overflow: hidden;
  line-height: 1.45;
}

.action-row .acts {
  display: flex;
  gap: 2px;
}

/* цвета сняты со скриншота чата GTA5RP */
.game-chat {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #2a3338, #1b2226 60%, #222a2e);
  color: #fff;
  font-family: Roboto, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  max-height: 560px;
  overflow: auto;
}

.chat-line {
  overflow-wrap: anywhere;
}

.chat-time {
  color: #fff;
  font-weight: 600;
}

.chat-line.whisper { color: #b4b4b4; }
.chat-line.me,
.chat-me { color: #c49be8; }
.chat-line.do { color: #9b8aa6; font-weight: 500; }
.chat-line.do .chat-time { font-weight: 600; }
.chat-line.info { color: #5aa2f5; }
.chat-line.faction { color: #4b8ff0; }
.chat-line.dep { color: #f08a6c; }
.chat-line.megafon { color: #f3d34a; }
.chat-line.family { color: #36d3d3; }
.chat-line.group { color: #d6e33c; }
.chat-ok { color: #5fd068; }

.chat-meta {
  margin: 2px 0;
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  font-weight: 500;
  font-style: italic;
  text-shadow: none;
}



/* анимация: категория и название */
.action-row > .anim-pick {
  display: grid;
  grid-template-columns: minmax(120px, 190px) minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.anim-pick > * {
  min-width: 0;
  width: 100%;
}


/* ---------- выбор темы ---------- */

.theme-menu {
  position: fixed;
  z-index: 60;
  width: 300px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.theme-menu .grid-themes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.theme-menu button {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.theme-menu button:hover,
.theme-menu button.active {
  border-color: var(--accent);
  color: var(--text);
}

.theme-menu .swatch {
  height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(127, 127, 127, 0.25);
}

/* избранное и включённое напоминание */
.btn.fav-on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn.fav-on svg {
  fill: currentColor;
}


/* ---------- графики ---------- */

svg.viz {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.viz-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.viz-axis {
  fill: var(--muted);
  font-size: 11px;
}

.viz-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.viz-hit rect {
  fill: transparent;
}

.viz-hit .viz-cross,
.viz-hit .viz-dot {
  opacity: 0;
}

.viz-hit:hover .viz-cross,
.viz-hit:hover .viz-dot {
  opacity: 1;
}

.viz-cross {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.viz-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-2);
  font-size: 12.5px;
}

.viz-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px;
}

.viz-bars {
  display: grid;
  grid-template-columns: minmax(80px, 150px) minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: center;
  font-size: 13px;
}

.viz-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-2);
}

.viz-track {
  display: flex;
  gap: 2px;
  height: 14px;
}

.viz-track i {
  height: 100%;
  border-radius: 0 4px 4px 0;
}

.viz-track i:not(:last-child) {
  border-radius: 0;
}

.viz-value {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}


/* ---------- окно подтверждения ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  animation: modal-fade 0.15s ease-out;
}

.modal {
  display: flex;
  gap: 14px;
  width: min(440px, 100%);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  animation: modal-pop 0.15s ease-out;
}

.modal h2 {
  font-size: 17px;
}

.modal p {
  margin: 6px 0 0;
  color: var(--text-2);
}

.modal-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-icon.danger {
  background: color-mix(in srgb, var(--bad) 15%, transparent);
  color: var(--bad);
}

.btn.danger-fill {
  border-color: var(--bad);
  background: var(--bad);
  color: #fff;
}

@keyframes modal-fade {
  from { opacity: 0; }
}

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
}

.test-result {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
}

.test-result.bad {
  color: var(--bad);
}


/* ---------- значки пользователей ---------- */

.ubadge {
  --c: #e6b43c;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: color-mix(in srgb, var(--c) 70%, var(--text));
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ubadge.as-button {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.c-gold { --c: #e6b43c; }
.c-pink { --c: #ff4fa8; }
.c-violet { --c: #9b6bff; }
.c-blue { --c: #3987e5; }
.c-cyan { --c: #22c3d6; }
.c-green { --c: #2fb36b; }
.c-red { --c: #e5544f; }
.c-gray { --c: #8a8f9c; }

.ubadge-emoji {
  font-weight: 400;
  cursor: default;
}

.badge-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.swatches {
  display: flex;
  gap: 4px;
}

.swatch-dot {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
}

.swatch-dot.active {
  border-color: var(--text);
}

@media (max-width: 720px) {
  .badge-row {
    grid-template-columns: 64px minmax(0, 1fr) auto;
  }

  .badge-row .swatches {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}


/* ---------- меню действий в строке таблицы ---------- */

.row-menu {
  display: inline-block;
}

.row-menu > summary {
  list-style: none;
  white-space: nowrap;
}

.row-menu > summary::-webkit-details-marker {
  display: none;
}

.row-menu-list {
  position: fixed;
  z-index: 50;
  display: grid;
  min-width: 230px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--surface-3);
}

.menu-item.danger {
  color: var(--bad);
}

.menu-item svg {
  width: 16px;
  height: 16px;
  flex: none;
}


/* ---------- выбор эмодзи ---------- */

.emoji-input {
  width: 64px;
  font-size: 20px;
  text-align: center;
  cursor: pointer;
}

.emoji-panel {
  position: fixed;
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 16px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.emoji-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.emoji-tabs button {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.emoji-tabs button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}

.emoji-grid button {
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.emoji-grid button:hover {
  background: var(--surface-3);
  transform: scale(1.12);
}




/* ---------- поле "флажки" ---------- */

.checks {
  display: grid;
  gap: 4px;
  max-height: 420px;
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.checks-title {
  margin: 8px 4px 2px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 650;
}

.checks-title:first-of-type {
  margin-top: 2px;
}

.check-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 400;
  white-space: pre-line;
  cursor: pointer;
}

.check-item:hover {
  background: var(--surface-3);
}

.check-item input {
  flex: none;
  width: auto;
  height: auto;
  margin-top: 3px;
}
