:root {
  color-scheme: dark;
  --bg: #0F172A;
  --surface: #1B2336;
  --surface-2: #232C42;
  --muted: #272F42;
  --border: #334155;
  --border-strong: #475569;
  --fg: #F8FAFC;
  --fg-muted: #94A3B8;
  --accent: #22C55E;
  --on-accent: #0F172A;
  --danger: #F87171;
  --ring: #F8FAFC;
  --private: #FBBF24;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Fira Code", ui-monospace, "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --topbar-h: 61px; /* уточняется из app.js — для липкой шапки таблицы */
  --star: #FACC15;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #F1F5F9;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --muted: #E2E8F0;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --fg: #0F172A;
    --fg-muted: #475569;
    --accent: #15803D;
    --on-accent: #FFFFFF;
    --danger: #B91C1C;
    --ring: #0F172A;
    --private: #B45309;
    --star: #CA8A04;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 14px; height: 14px; }

/* ---------- Шапка ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; border-radius: var(--radius-sm); }
.brand-mark { display: inline-flex; gap: 4px; padding: 7px 8px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.brand-mark i { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-muted); }
.brand-mark i:first-child { background: var(--accent); }
.brand-name { font-weight: 600; letter-spacing: .08em; }
.brand-sub { color: var(--fg-muted); }

.account { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--muted); color: var(--fg); font-weight: 600;
}
.avatar.is-guest { color: var(--fg-muted); }
.account-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.account-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.account-role { font-size: 13px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.account-role.is-editor { color: var(--accent); }

/* ---------- Кнопки и поля ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--fg-muted); }
.btn-ghost { background: transparent; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, white); border-color: transparent; }
.btn-block { width: 100%; }

.btn-icon {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--fg-muted);
}
.btn-icon:hover { background: var(--muted); color: var(--fg); }

.segmented {
  display: inline-flex; padding: 3px; gap: 3px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--fg-muted);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.segmented button:hover:not(:disabled) { color: var(--fg); }
.segmented [aria-checked="true"], .segmented [aria-selected="true"] { background: var(--muted); color: var(--fg); font-weight: 500; }
.segmented-full { display: flex; width: 100%; }
.segmented-full button { flex: 1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label { font-size: 14px; color: var(--fg-muted); }
.field input {
  min-height: 44px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg);
}
.field input[aria-invalid="true"] { border-color: var(--danger); }
.password-wrap { position: relative; display: flex; }
.password-wrap input { flex: 1; min-width: 0; padding-right: 48px; }
.password-toggle {
  position: absolute; top: 2px; right: 2px; bottom: 2px; width: 44px;
  display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--fg-muted);
}
.password-toggle:hover { color: var(--fg); background: var(--muted); }
.password-toggle[aria-pressed="true"] { color: var(--fg); }
.hint { font-size: 13px; color: var(--fg-muted); }

.field-inline { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-muted); font-size: 14px; }
.field-inline select {
  min-height: 40px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg);
}

.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; color: var(--fg-muted); font-size: 14px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Страница ---------- */

.page { max-width: 1280px; margin: 0 auto; padding: 24px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; }
.toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }

.readonly-note {
  display: flex; align-items: center; gap: 8px; margin: 16px 0 0; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--fg-muted); font-size: 14px;
}
.readonly-note .icon { flex: none; }
.status { min-height: 24px; margin: 12px 0; color: var(--fg-muted); font-size: 14px; }
.status.is-error { color: var(--danger); }

.grid {
  display: grid; gap: 16px; align-items: start;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 860px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.group-title {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 8px 0 -4px;
  font-size: 13px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-muted);
}
.group-title:first-child { margin-top: 0; }
.group-title .icon { color: var(--star); fill: currentColor; }

/* ---------- Карточка монитора ---------- */

.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.card-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-name { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; overflow-wrap: break-word; min-width: 0; }
.card-link { color: inherit; text-decoration: none; border-radius: 4px; }
.card-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-badges { display: flex; align-items: center; gap: 4px; flex: none; }
.card.is-favorite { border-color: color-mix(in srgb, var(--star) 45%, var(--border)); }
.count { white-space: nowrap; }

.card-more {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  border-top: 1px solid var(--border); color: var(--fg-muted); font-size: 14px; text-decoration: none;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.card-more:hover { background: var(--surface-2); color: var(--fg); }

/* Звезда избранного: контур — не в избранном, заливка — в избранном. */
.star-btn {
  display: grid; place-items: center; width: 36px; height: 36px; margin: -6px -6px -6px 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--fg-muted);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.star-btn:hover { background: var(--muted); color: var(--star); }
.star-btn[aria-pressed="true"] { color: var(--star); }
.star-btn[aria-pressed="true"] .icon { fill: currentColor; }
.star-btn:disabled { opacity: .6; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--fg-muted); }
.owner { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.owner-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chip.is-public { color: var(--accent); }
.chip.is-private { color: var(--private); }

.guid, .id-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 6px; margin-right: -6px;
  border: 0; border-radius: 6px; background: transparent; color: var(--fg-muted);
}
.guid:hover, .id-btn:hover { background: var(--muted); color: var(--fg); }
.guid code, .id-btn code { font: 12px var(--font-mono); }

.attrs { width: 100%; border-collapse: collapse; font-size: 14px; }
.attrs th {
  padding: 8px 16px; text-align: left; font-size: 12px; font-weight: 500;
  color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em;
}
.attrs td { padding: 8px 16px; border-top: 1px solid var(--border); vertical-align: baseline; }
.attrs th:nth-child(n+2), .attrs td:nth-child(n+2) { padding-left: 4px; }
.attrs .num { text-align: right; }
.attrs .value { font: 500 15px var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.attrs .unit { color: var(--fg-muted); white-space: nowrap; }
.attrs .time { color: var(--fg-muted); font: 12px var(--font-mono); white-space: nowrap; }
.attrs .name { overflow-wrap: break-word; hyphens: auto; }
.attrs tr.is-updated .value { animation: flash 1.2s var(--ease); }
@keyframes flash { from { color: var(--accent); } to { color: inherit; } }

.card-empty { margin: 0; padding: 16px; color: var(--fg-muted); font-size: 14px; }

/* Скелетон на время загрузки — резервирует место, чтобы не прыгала вёрстка. */
.card.is-skeleton { min-height: 220px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty {
  grid-column: 1 / -1; padding: 48px 24px; text-align: center; color: var(--fg-muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty strong { display: block; margin-bottom: 4px; color: var(--fg); font-weight: 500; }

/* ---------- Страница монитора ---------- */

.back-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin-left: -6px; padding: 0 6px;
  color: var(--fg-muted); text-decoration: none; border-radius: var(--radius-sm); font-size: 14px;
}
.back-link:hover { color: var(--fg); background: var(--muted); }

.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; margin: 8px 0 16px; }
.detail-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.detail-title h1 { margin: 0; font-size: 26px; font-weight: 600; line-height: 1.25; overflow-wrap: break-word; min-width: 0; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 6px; color: var(--fg-muted); font-size: 14px; }
.detail-meta .guid { margin-right: 0; }

.fav-toggle[aria-pressed="true"] { border-color: color-mix(in srgb, var(--star) 60%, var(--border)); color: var(--star); }
.fav-toggle[aria-pressed="true"] .icon { fill: currentColor; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 0 0 16px; }
.stat { padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat dt { font-size: 13px; color: var(--fg-muted); }
.stat dd { margin: 2px 0 0; font: 500 18px var(--font-mono); font-variant-numeric: tabular-nums; }

.search { position: relative; flex: 1 1 280px; max-width: 420px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--fg-muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 40px; padding: 0 12px 0 40px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.search input::placeholder { color: var(--fg-muted); }

/* Таблица атрибутов — без overflow:hidden у обёртки, иначе не работает липкая шапка. */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.detail-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.detail-table th {
  position: sticky; top: var(--topbar-h); z-index: 1;
  padding: 0; background: var(--surface-2); border-bottom: 1px solid var(--border-strong);
  text-align: left; font-size: 12px; font-weight: 500; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em;
}
.detail-table th:first-child { border-top-left-radius: var(--radius); }
.detail-table th:last-child { border-top-right-radius: var(--radius); }
.detail-table th.num, .detail-table td.num { text-align: right; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 4px; width: 100%; min-height: 40px; padding: 0 12px;
  border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit;
}
th.num .sort-btn { justify-content: flex-end; }
.sort-btn:hover { color: var(--fg); }
.sort-btn .icon { opacity: .5; }
th[aria-sort] .sort-btn { color: var(--fg); }
th[aria-sort] .sort-btn .icon { opacity: 1; }
.detail-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: baseline; }
.detail-table tbody tr:last-child td { border-bottom: 0; }
.detail-table tbody tr:hover td { background: var(--surface-2); }
.detail-table .pos { width: 1%; color: var(--fg-muted); font: 12px var(--font-mono); text-align: right; }
.detail-table .name { overflow-wrap: break-word; hyphens: auto; }
.detail-table .value { font: 500 15px var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.detail-table .unit { color: var(--fg-muted); white-space: nowrap; }
.detail-table .time { color: var(--fg-muted); font: 12px var(--font-mono); white-space: nowrap; }
.detail-table .id { width: 1%; white-space: nowrap; }
.detail-table .id-btn { margin: -4px 0; }
.detail-table tr.is-updated .value { animation: flash 1.2s var(--ease); }
.detail-table mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 2px; }
.table-empty { padding: 32px 16px; text-align: center; color: var(--fg-muted); }

.notice { padding: 48px 24px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--fg-muted); }
.notice strong { display: block; margin-bottom: 4px; color: var(--fg); font-size: 18px; font-weight: 500; }
.notice .btn { margin-top: 16px; }

/* ---------- Пагинация ---------- */

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; }
.pager-info { color: var(--fg-muted); font-size: 14px; }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pager-pages .btn { min-width: 40px; padding: 0 10px; font-variant-numeric: tabular-nums; }
.pager-pages .btn[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.pager-gap { min-width: 24px; text-align: center; color: var(--fg-muted); }

/* ---------- Диалог входа ---------- */

dialog {
  width: min(420px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--border-strong); border-radius: 16px;
  background: var(--surface); color: var(--fg);
}
dialog::backdrop { background: rgb(2 6 23 / .6); backdrop-filter: blur(2px); }
dialog form { display: flex; flex-direction: column; gap: 16px; padding: 20px 24px 24px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-right: -8px; }
.dialog-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.form-error { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--fg); color: var(--bg); font-size: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .3);
}

/* ---------- Адаптивность ---------- */

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .brand-sub { display: none; }
  .account { gap: 8px; }
  .account-name, .account-role { max-width: 96px; }
  .account .btn span { display: none; }
  .page { padding: 16px; }
  .toolbar, .toolbar-right { width: 100%; }
  .toolbar-right { justify-content: space-between; }
  .refresh span { display: none; }
  .detail-title h1 { font-size: 21px; }
  .detail-table .pos, .detail-table th[data-key="position"], .detail-table .id { display: none; }
  .detail-table td, .sort-btn { padding-left: 8px; padding-right: 8px; }
  .detail-table .time { white-space: normal; }
  .search { max-width: none; }
  .attrs .time { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
}

/* Спрайт иконок: в разметке без inline-стилей — их запрещает CSP. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ==================== Реалмы, группы, управление ==================== */

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Навигация в шапке */
.mainnav { display: flex; align-items: center; gap: 4px; margin-right: auto; margin-left: 16px; min-width: 0; }
.mainnav a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); color: var(--fg-muted); text-decoration: none; font-size: 15px; white-space: nowrap;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.mainnav a:hover { color: var(--fg); background: var(--muted); }
.mainnav a[aria-current="page"] { color: var(--fg); background: var(--muted); font-weight: 500; }
.mainnav a[hidden] { display: none; }

.view-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 24px; margin: 4px 0 16px; }
.view-head h1 { margin: 0; font-size: 26px; font-weight: 600; line-height: 1.25; overflow-wrap: break-word; }
.view-head .hint { margin: 4px 0 0; }
.is-skeleton-text { min-width: 240px; min-height: 32px; border-radius: 6px; background: var(--muted); }

/* Карточки реалмов */
.realm-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .realm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.realm-card {
  display: flex; flex-direction: column; gap: 8px; min-height: 120px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit; text-decoration: none;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
a.realm-card:hover { border-color: var(--fg-muted); background: var(--surface-2); }
.realm-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.realm-name { margin: 0; font-size: 19px; font-weight: 600; line-height: 1.3; overflow-wrap: break-word; min-width: 0; }
.realm-desc { margin: 0; color: var(--fg-muted); font-size: 14px; }
.realm-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: auto; color: var(--fg-muted); font-size: 14px; }
.realm-meta span { display: inline-flex; align-items: center; gap: 6px; }
.realm-card.is-skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }

.chip.is-role { border-color: transparent; background: var(--muted); color: var(--fg); }
.chip.is-admin, .chip.is-editor { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

/* Вкладки групп: прокручиваются по горизонтали внутри себя, страница вбок не скроллится */
.tabs-scroll {
  display: flex; gap: 4px; max-width: 100%; padding: 3px; overflow-x: auto; scrollbar-width: thin;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.tabs-scroll [role="tab"] {
  display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 36px; padding: 0 12px;
  border: 0; border-radius: 7px; background: transparent; color: var(--fg-muted); white-space: nowrap;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.tabs-scroll [role="tab"]:hover { color: var(--fg); }
.tabs-scroll [aria-selected="true"] { background: var(--muted); color: var(--fg); font-weight: 500; }
.tab-count { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--bg); color: var(--fg-muted); font: 12px/20px var(--font-mono); text-align: center; }
.toolbar > .tabs-scroll { flex: 1 1 auto; min-width: 0; }

/* Хлебные крошки на странице монитора */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.crumb {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--fg-muted); font-size: 13px; text-decoration: none;
}
.crumb:hover { color: var(--fg); border-color: var(--fg-muted); }
.where { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-table .act { width: 1%; white-space: nowrap; padding-left: 0; }
.notice-actions { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.notice-actions .btn { margin-top: 0; }

/* Кнопки */
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); background: transparent; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); }
.btn-icon-sm { width: 32px; height: 32px; }
a.btn { color: inherit; text-decoration: none; }

/* Управление */
.admin-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .admin-layout { grid-template-columns: 260px minmax(0, 1fr); } }
.admin-side {
  display: flex; flex-direction: column; gap: 2px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
@media (min-width: 900px) { .admin-side { position: sticky; top: calc(var(--topbar-h) + 16px); } }
.side-title { margin: 8px 8px 4px; font-size: 12px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-muted); }
.side-title:first-child { margin-top: 0; }
.side-item {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; width: 100%;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--fg-muted); text-align: left;
}
.side-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item:hover { background: var(--muted); color: var(--fg); }
.side-item[aria-current="true"] { background: var(--muted); color: var(--fg); font-weight: 500; }
.side-action { margin-top: 8px; justify-content: flex-start; }
.admin-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-title { margin: 0; font-size: 22px; font-weight: 600; }
.panel { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-bar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.panel-bar h3 { margin: 0; font-size: 17px; font-weight: 600; }
.panel-bar .hint { margin: 2px 0 0; max-width: 60ch; }

.data-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { padding: 8px 10px; text-align: left; font-size: 12px; font-weight: 500; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border-strong); }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: break-word; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { vertical-align: middle; }
.select-sm { min-height: 34px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); }

/* Диалог-форма */
.form-dialog { width: min(460px, calc(100vw - 32px)); }
.form-dialog-wide { width: min(640px, calc(100vw - 32px)); }
.form-dialog form > .hint { margin: -8px 0 0; }
.field select, .field textarea {
  min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--fg); font: inherit;
}
.field textarea { resize: vertical; }
.form-dialog .search { max-width: none; }
.pick-list { display: flex; flex-direction: column; max-height: min(50vh, 420px); overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.pick-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover { background: var(--surface-2); }
.pick-item input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.pick-name { flex: 1; min-width: 0; overflow-wrap: break-word; }
.pick-meta { color: var(--fg-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }

@media (max-width: 640px) {
  .mainnav { margin-left: 4px; gap: 0; }
  .mainnav a { padding: 0 10px; }
  .mainnav a span { display: none; }
  .view-head h1 { font-size: 22px; }
  .toolbar > .tabs-scroll { flex-basis: 100%; }
  .pick-meta { display: none; }
  /* Таблица монитора на телефоне: без горизонтальной прокрутки страницы. */
  .detail-table td, .sort-btn { padding-left: 6px; padding-right: 6px; }
  .detail-table .value { font-size: 14px; }
  .detail-table .time { font-size: 11px; }
  .detail-table .act { padding-right: 2px; }
  .detail-table .act .btn-icon-sm { width: 28px; height: 28px; }
}
