:root {
  --bg: #0f1419;
  --bg-elev: #171e26;
  --bg-soft: #1d2732;
  --line: #2a3644;
  --text: #e7eef6;
  --muted: #8fa3b8;
  --accent: #3d9bfd;
  --accent-2: #2f6fed;
  --ok: #3ecf8e;
  --bad: #ff6b6b;
  --warn: #e6b84d;
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2a3d 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #132033 0%, transparent 50%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--line);
  background: rgba(12, 16, 22, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: var(--text);
}
.brand-mark {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.brand-sub { color: var(--muted); font-size: 0.85rem; }

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.sidebar nav a {
  color: var(--muted);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  color: var(--text);
  background: var(--bg-soft);
}

/* Каркас сайдбара: кнопка меню показывается только на узких экранах */
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.nav-toggle {
  display: none;
  white-space: nowrap;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}
.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.seed-form button,
.btn,
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #2a3b50, #223246);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
}
.btn:hover, button:hover { border-color: #3d5168; }
.seed-form button { width: 100%; }

.table-scroll {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.table-scroll.wide {
  max-height: 640px;
}
.table-scroll .table {
  margin: 0;
  white-space: nowrap;
}
.table.dense th,
.table.dense td {
  font-size: 0.75rem;
  padding: 0.35rem 0.4rem;
}
.table.dense th {
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  z-index: 1;
}
.content {
  padding: 1.5rem 1.75rem 2.5rem;
  max-width: none;
  /* grid-элемент по умолчанию не сжимается: широкие таблицы ломали страницу */
  min-width: 0;
  overflow-x: hidden;
}

.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin: 0.2rem 0 0.4rem; font-size: 1.75rem; font-weight: 600; }
.page-head p { margin: 0; color: var(--muted); }
.crumb { font-size: 0.9rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.stat-value { display: block; font-size: 1.5rem; font-weight: 600; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 1rem;
}
.panel h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 600;
}

.block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}
.block-tile {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}
.block-tile span { color: var(--muted); font-size: 0.85rem; }
.block-tile:hover { border-color: var(--accent); text-decoration: none; }

.block-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}
.block-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
  min-height: 7.5rem;
}
.block-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.block-card.has-issues {
  border-color: #6a3a3a;
  box-shadow: inset 3px 0 0 #c0392b;
}
.block-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.block-card-top strong {
  font-size: 1.05rem;
  font-weight: 600;
}
.block-card-id {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}
.block-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.block-card-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.block-card-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #c0392b, #e68628);
  border-radius: 2px;
}
.block-card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: auto;
  padding-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--accent);
}
.block-card-link {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.block-card-link:hover { color: #fff; }
.block-card-matches {
  font-size: 0.75rem;
  line-height: 1.35;
  margin: 0.15rem 0 0.1rem;
}
.blocks-search {
  margin-top: 0.75rem;
  max-width: 52rem;
}

.comments-panel { margin-top: 0.75rem; }
.comments-panel .comments-count {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0.05rem 0.4rem;
  margin-left: 0.25rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.comments-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin: 0.5rem 0 0.75rem;
}
.comments-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.comments-form .comments-author { width: 9rem; }
.comments-form .comments-body { flex: 1 1 16rem; min-width: 12rem; }
.comments-form input,
.comments-form textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elev, #1a1f2a);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.comments-form button { align-self: flex-end; }
.comments-status { margin: 0 0 0.5rem; font-size: 0.85rem; }
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 22rem;
  overflow: auto;
}
.comment-item {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.comment-item header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}
.comment-item header time { color: var(--muted); font-variant-numeric: tabular-nums; }
.comment-item p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}
.house-card-comments { color: var(--accent); }
.house-card-comments.has-comments { font-weight: 600; }

.endpoint-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.endpoint-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.endpoint-list span { color: var(--muted); font-size: 0.85rem; }

.kv-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.kv-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
.kv-list li span { color: var(--muted); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 500; }
.table.compact { font-size: 0.85rem; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.muted { color: var(--muted); }
.clip {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.row-actions form { margin: 0; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg-elev);
  text-decoration: none;
}
.chip em { font-style: normal; color: var(--text); }
.chip.active, .chip:hover {
  color: var(--text);
  border-color: var(--accent);
  text-decoration: none;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.78rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.tag-apartment { border-color: #3d6f9b; color: #9fcaff; }
.tag-switchboard { border-color: #9b7a3d; color: #ffd78a; }
.tag-office { border-color: #3d9b7a; color: #8dffd0; }
.tag-mop { border-color: #7a3d9b; color: #d9a8ff; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
}
.preset {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--bg-soft);
}
.preset code { font-size: 0.75rem; color: var(--accent); }
.preset span { color: var(--muted); font-size: 0.8rem; }

.explorer-form { display: flex; flex-direction: column; gap: 0.75rem; }
.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.form-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 140px;
  flex: 1;
}
.form-row label.grow { flex: 3; }
.form-row input,
.form-row select {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}

.json {
  margin: 0;
  padding: 0.9rem;
  overflow: auto;
  max-height: 560px;
  background: #0b1016;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.85rem;
}
.filter-panel { padding-bottom: 1rem; }
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
}
.filter-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  min-width: 110px;
}
.filter-form label.grow { flex: 2; min-width: 200px; }
.filter-form input,
.filter-form select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.map-toolbar h2 { margin: 0; font-size: 1rem; }
.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
}
.ip-map { display: flex; flex-direction: column; gap: 0.55rem; }
.ip-node, .port-node {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  padding: 0.15rem 0.55rem 0.45rem;
}
.port-node { background: var(--bg); margin: 0.4rem 0; }
.ip-node > summary,
.port-node > summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.2rem;
  list-style: none;
}
.ip-node > summary::-webkit-details-marker,
.port-node > summary::-webkit-details-marker { display: none; }
.ip-title { display: flex; gap: 0.55rem; align-items: baseline; font-weight: 500; }
.ip-meta { color: var(--muted); font-size: 0.85rem; }
.ip-actions { display: inline-flex; gap: 0.4rem; align-items: center; margin-left: auto; }
.ping-result { font-family: var(--mono); font-size: 0.78rem; min-width: 4rem; }
.zabbix-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 7.5rem;
  font-size: 0.82rem;
}
.zabbix-badge {
  display: inline-block;
  width: fit-content;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 0.75rem;
  line-height: 1.25;
}
.zabbix-unavailable { color: #f0a0a0; border-color: #6a3a3a; background: rgba(122, 42, 42, 0.18); }
.zabbix-available { color: #8fd4a8; border-color: #2f6a4f; background: rgba(47, 106, 79, 0.15); }
.zabbix-unknown { color: var(--muted); }
.zabbix-disabled { color: #e6b84d; border-color: #8a6a2a; background: rgba(230, 184, 77, 0.1); }
.zabbix-error { color: #e6b84d; border-color: #8a6a2a; }
.zabbix-duration {
  color: var(--bad);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}
.ports-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  max-width: 16rem;
}
.converters-ip-table .port-chip {
  font-size: 0.72rem;
  padding: 0.12rem 0.4rem;
  text-decoration: none;
}
.filter-form .grow { flex: 1 1 14rem; min-width: 12rem; }
.filter-form .grow input { width: 100%; }

.house-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}
.house-cards-compact {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.65rem;
}
.house-cards-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: center;
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
}
.sev-legend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 0.72rem;
}
.sev-legend.sev-full {
  color: #ffb0a8;
  border-color: #a33;
  background: rgba(192, 57, 43, 0.22);
}
.sev-legend.sev-major {
  color: #ffd0a0;
  border-color: #a15a20;
  background: rgba(230, 134, 40, 0.18);
}
.sev-legend.sev-partial {
  color: #f0d080;
  border-color: #8a6a2a;
  background: rgba(201, 162, 39, 0.12);
}
.sev-legend.sev-single {
  color: #9aa3ad;
  border-color: #4a5560;
  background: rgba(255, 255, 255, 0.03);
}
.house-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.house-cards-compact .house-card {
  padding: 0.7rem 0.8rem;
  gap: 0.35rem;
  border-radius: 8px;
}
.house-card.has-issues { border-color: #6a3a3a; }
.house-card.sev-card-full {
  border-color: #a33;
  box-shadow: inset 3px 0 0 #c0392b;
}
.house-card.sev-card-major {
  border-color: #a15a20;
  box-shadow: inset 3px 0 0 #e68628;
}
.house-card.sev-card-warn,
.house-card.sev-card-partial {
  border-color: #6a4a2a;
  box-shadow: inset 3px 0 0 #c9a227;
}
.house-card.sev-card-bad {
  border-color: #a33;
  box-shadow: inset 3px 0 0 #c0392b;
}

/* Индикатор состояния дома и его ключевые цифры */
.house-sev {
  flex-shrink: 0;
  width: 4px;
  border-radius: 3px;
  align-self: stretch;
  background: #3a4654;
}
.house-sev.sev-ok { background: #3ecf8e; }
.house-sev.sev-warn { background: #e0b84d; }
.house-sev.sev-bad { background: #c0392b; }
.house-sev.sev-muted { background: #4a5563; }

.house-card-wide {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
  align-items: baseline;
  font-size: 0.82rem;
}
.house-card-wide b { font-family: var(--mono); font-size: 0.98rem; }
.house-card-wide .bad, .house-card-wide .bad b { color: var(--bad); }
.house-card-wide .ok, .house-card-wide .ok b { color: var(--ok); }

.house-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: stretch;
}
.house-card header a { color: var(--text); text-decoration: none; flex: 1 1 auto; min-width: 0; }
.house-card header a:hover { color: var(--accent); }
.house-card-offline {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.house-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
  align-items: center;
}
.house-cards-compact .house-card-stats { font-size: 0.75rem; }
.house-card-tag {
  font-size: 0.68rem;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  font-weight: 600;
}
.house-card-tag.tag-full {
  color: #ffb0a8;
  background: rgba(192, 57, 43, 0.22);
  border: 1px solid #6a3a3a;
}
.house-card-tag.tag-major {
  color: #ffd0a0;
  background: rgba(230, 134, 40, 0.18);
  border: 1px solid #a15a20;
}
.house-card-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.house-card-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #c0392b, #e68628);
}
.house-card-okline { margin: 0; font-size: 0.78rem; }
.house-card footer {
  display: flex;
  gap: 0.85rem;
  margin-top: 0.15rem;
  font-size: 0.85rem;
}
.house-cards-compact .house-card footer {
  gap: 0.55rem;
  font-size: 0.78rem;
}
.port-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.1rem; }
.port-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  padding: 0.35rem 0.5rem;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1.25;
  min-width: 5.8rem;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.02);
}
.port-chip:hover { color: var(--text); border-color: var(--accent); text-decoration: none; filter: brightness(1.08); }
.port-chip-head {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.port-chip-pct {
  margin-left: auto;
  font-size: 0.66rem;
  font-weight: 700;
  font-family: var(--mono);
  padding: 0.02rem 0.28rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
}
.port-chip-port {
  font-weight: 700;
  color: #7eb6f0;
  font-size: 0.78rem;
  font-family: var(--mono);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.port-chip-sev {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.05rem 0.28rem;
  border-radius: 3px;
  white-space: nowrap;
}
.port-chip-ip {
  font-size: 0.62rem;
  font-family: var(--mono);
  color: #6a737c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.port-chip-type {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.08rem 0.2rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.15);
}
.port-chip-label {
  color: #9eb4c8;
  font-size: 0.68rem;
  font-weight: 600;
}
.port-chip-nums {
  display: inline-flex;
  align-items: baseline;
  gap: 0.15rem;
  font-family: var(--mono);
}
.port-chip-total {
  color: #5dba7a;
  font-weight: 700;
}
.port-chip-slash {
  color: #6a737c;
  font-weight: 400;
}
.port-chip-off {
  color: #e07070;
  font-weight: 700;
}
.port-chip.sev-full {
  border-color: #a33;
  background: rgba(192, 57, 43, 0.2);
  box-shadow: inset 3px 0 0 #c0392b;
}
.port-chip.sev-full .port-chip-sev {
  color: #ffb0a8;
  background: rgba(192, 57, 43, 0.35);
}
.port-chip.sev-major {
  border-color: #a15a20;
  background: rgba(230, 134, 40, 0.16);
  box-shadow: inset 3px 0 0 #e68628;
}
.port-chip.sev-major .port-chip-sev {
  color: #ffd0a0;
  background: rgba(230, 134, 40, 0.28);
}
.port-chip.sev-partial {
  border-color: #8a6a2a;
  background: rgba(201, 162, 39, 0.1);
  box-shadow: inset 3px 0 0 #c9a227;
}
.port-chip.sev-partial .port-chip-sev {
  color: #f0d080;
  background: rgba(201, 162, 39, 0.2);
}
.port-chip.sev-single {
  border-color: #4a5560;
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.85;
}
.port-chip.sev-single .port-chip-sev {
  color: #9aa3ad;
  background: rgba(255, 255, 255, 0.06);
}
.port-chip-type.sev-full {
  background: rgba(192, 57, 43, 0.18);
}
.port-chip-type.sev-major {
  background: rgba(230, 134, 40, 0.14);
}
.port-more {
  font-size: 0.72rem;
  align-self: center;
  color: var(--accent);
  text-decoration: underline;
}
.bad-chip { border-color: #6a3a3a; background: rgba(122, 42, 42, 0.12); }
.warn-chip { border-color: #6a4a2a; background: rgba(138, 74, 42, 0.1); }
.converter-mini {
  border-top: 1px solid var(--line);
  padding-top: 0.4rem;
  font-size: 0.85rem;
}
.converter-mini-head {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}
.converter-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.converter-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: 0.75rem 0.85rem;
}
.converter-card.has-issues { border-color: #6a3a3a; }
.converter-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.converter-ip { font-size: 1.05rem; }
.converter-card-meta {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}
.device-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.55rem;
  padding: 0.45rem 0 0.2rem;
}
.device-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  padding: 0.7rem 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.device-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.device-card.offline {
  border-color: #6a3a3a;
  background: rgba(255, 107, 107, 0.06);
  box-shadow: inset 3px 0 0 #c0392b;
}
.device-card.online { border-color: #2f6a4f; }
.device-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  align-items: center;
}
.device-card-apt {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: rgba(90, 140, 200, 0.2);
  border: 1px solid #3d6a8a;
  color: #9ec8e8;
}
.device-card-apt.empty {
  opacity: 0.55;
  font-weight: 500;
}
.device-card-serial {
  font-family: var(--mono);
  font-size: 0.95rem;
}
.device-card-model {
  color: var(--muted);
  font-size: 0.8rem;
}
.device-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.hw-apt {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  background: rgba(90, 140, 200, 0.28);
  border: 1px solid #3d6a8a;
  color: #b7dbf5;
  font-family: var(--mono);
  min-width: 3.2rem;
  text-align: center;
  white-space: nowrap;
}
.hw-apt.is-switchboard,
.hw-apt-switchboard,
.device-card-apt.is-switchboard {
  background: rgba(155, 122, 61, 0.22);
  border-color: #9b7a3d;
  color: #ffd78a;
}
.hw-apt.is-mop,
.hw-apt-mop,
.device-card-apt.is-mop {
  background: rgba(122, 61, 155, 0.22);
  border-color: #7a3d9b;
  color: #d9a8ff;
}
.hw-apt.is-office,
.device-card-apt.is-office {
  background: rgba(61, 122, 155, 0.2);
  border-color: #3d7a9b;
  color: #9ad0f0;
}
.hw-apt.is-other,
.device-card-apt.is-other {
  background: rgba(255, 255, 255, 0.06);
  border-color: #4a5560;
  color: var(--muted);
}
.hw-apt-empty {
  opacity: 0.45;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  border-color: #4a5560;
  color: #8a939c;
}
#map-export-excel.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.hw-device {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  flex: 1;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.hw-device:hover {
  border-color: var(--accent);
  background: rgba(90, 140, 200, 0.1);
  text-decoration: none;
  color: var(--text);
}
.hw-device.is-offline {
  border-color: #6a3a3a;
  background: rgba(192, 57, 43, 0.12);
  box-shadow: inset 3px 0 0 #c0392b;
}
.hw-device.is-online {
  border-color: #2f5a45;
}
.hw-device.is-mode-off {
  border-style: dashed;
}
.hw-device-main {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
  flex: 1 1 10rem;
}
.hw-device-model {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.25;
}
.hw-device-serial {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: #9aa3ad;
}
.hw-device-goto {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--accent);
  white-space: nowrap;
}
.hw-device:hover .hw-device-goto { text-decoration: underline; }
.hw-leaf-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  width: 100%;
  min-width: 0;
}
.hw-leaf-row > .hw-device { flex: 1 1 14rem; }
.hw-poll-btn { flex: 0 0 auto; white-space: nowrap; }
.hw-live-reading {
  flex: 1 1 12rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.35;
  color: #9ad0b0;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #2f5a45;
  background: rgba(47, 106, 79, 0.12);
  max-width: 100%;
  word-break: break-word;
}
.hw-live-reading.is-fail {
  color: #e8a0a0;
  border-color: #6a3a3a;
  background: rgba(192, 57, 43, 0.12);
}
.hw-live-reading.is-busy {
  color: #e0c080;
  border-color: #6a5a30;
  background: rgba(180, 140, 40, 0.12);
}
.hw-ep-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  min-width: 4.5rem;
  justify-content: center;
  white-space: nowrap;
}
.hw-ep-status.is-ok {
  color: #8fd4a8;
  border-color: #2f6a4f;
  background: rgba(47, 106, 79, 0.18);
}
.hw-ep-status.is-busy {
  color: #e0c080;
  border-color: #6a5a30;
  background: rgba(180, 140, 40, 0.18);
}
.hw-ep-status.is-bad {
  color: #e8a0a0;
  border-color: #6a3a3a;
  background: rgba(192, 57, 43, 0.15);
}
.hw-live-panel {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.hw-live-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.45rem 0.75rem;
  margin-top: 0.5rem;
}
.hw-live-fields .kv {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.82rem;
}
.hw-live-fields .kv span { color: var(--muted); font-size: 0.72rem; }
.hw-live-fields .kv strong { font-family: var(--mono); font-weight: 500; }
.hw-live-raw {
  margin-top: 0.65rem;
  max-height: 14rem;
  overflow: auto;
  font-size: 0.75rem;
  white-space: pre-wrap;
}
.hw-gradarus-link {
  font-size: 0.72rem;
  margin-left: 0.25rem;
  align-self: center;
}
.hw-reg-stats {
  display: inline-flex;
  margin-right: 0.15rem;
}
.hw-badge-ok {
  color: #8fd4a8;
  border-color: #2f6a4f;
  background: rgba(47, 106, 79, 0.15);
}
.hw-children > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}
.highlight-panel { border-color: #3d5a7a; }
.active-btn { border-color: var(--accent) !important; color: var(--accent); }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-top: 0.75rem;
}
.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.inline-form input,
.inline-form select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
.bad-stat .stat-value { color: var(--bad); }
.seed-form { margin-top: 0.35rem; }

/* Tree / types / channels */
.tree-branch {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  min-width: 2.4rem;
}
.tree-section-title {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}
.reg-node {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 28, 38, 0.7);
  padding: 0.15rem 0.55rem 0.45rem;
  margin: 0.4rem 0;
}
.reg-node > summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  padding: 0.5rem 0.15rem;
  list-style: none;
}
.reg-node > summary::-webkit-details-marker { display: none; }
.type-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.type-pills.compact .pill { font-size: 0.68rem; padding: 0.1rem 0.35rem; }
.pill {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}
.pill-ELECTRICITY { border-color: #3d6a9a; color: #7eb6f0; background: rgba(61, 155, 253, 0.12); }
.pill-HEAT { border-color: #9a6a3d; color: #f0b87e; background: rgba(230, 184, 77, 0.12); }
.pill-HVS { border-color: #3d7a8a; color: #6fd0e0; background: rgba(80, 180, 200, 0.12); }
.pill-GVS { border-color: #8a4a4a; color: #f08a8a; background: rgba(255, 107, 107, 0.1); }
.pill-OTHER { border-color: #555; }
.tag-res, .tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.tag-ELECTRICITY, .tag-res.tag-ELECTRICITY { color: #7eb6f0; border-color: #3d6a9a; }
.tag-HEAT, .tag-res.tag-HEAT { color: #f0b87e; border-color: #9a6a3d; }
.tag-HVS, .tag-COLD_WATER, .tag-res.tag-HVS, .tag-res.tag-COLD_WATER { color: #6fd0e0; border-color: #3d7a8a; }
.tag-GVS, .tag-HOT_WATER, .tag-res.tag-GVS, .tag-res.tag-HOT_WATER { color: #f08a8a; border-color: #8a4a4a; }
.tag-apartment { color: #9ec5ff; }
.tag-switchboard { color: #e6b84d; }
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.55rem;
  padding: 0.35rem 0 0.2rem;
}
.channel-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  padding: 0.55rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.channel-head {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.channel-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.channel-row .device-card { min-width: 0; }
.group-block { margin-top: 0.55rem; }
.reg-block { margin-top: 0.35rem; }
.port-list { padding-left: 0.35rem; }
.soft-link { color: var(--muted); font-size: 0.78rem; }
.soft-link:hover { color: var(--accent); }
.tree-mini .converter-mini summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  list-style: none;
}
.tree-mini .converter-mini summary::-webkit-details-marker { display: none; }
.port-tree { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.35rem; }
.port-tree-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid transparent;
}
.port-tree-row:hover { border-color: var(--line); }
.premise-card { color: inherit; text-decoration: none; }
.premise-card:hover { border-color: var(--accent); text-decoration: none; }

/* Аппаратные связи — дерево-пилюли */
.hw-panel { background: #1a1f26; }
.hw-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin: 0 0 1rem;
  font-size: 0.85rem;
}
.hw-tree {
  font-size: 0.92rem;
  overflow-x: auto;
  padding: 0.25rem 0.35rem 0.75rem;
}
.hw-tree ul.hw-children {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.15rem;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  margin-left: 0.55rem;
}
.hw-tree > details > ul.hw-children {
  margin-left: 0.85rem;
}
.hw-tree li {
  position: relative;
  margin: 0.35rem 0;
  padding-left: 0.85rem;
}
.hw-tree li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.95rem;
  width: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.28);
}
.hw-node > summary.hw-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-start;
  padding: 0.2rem 0.15rem;
  border-radius: 8px;
}
.hw-node > summary.hw-summary:hover {
  background: rgba(255, 255, 255, 0.03);
}
.hw-node > summary.hw-summary::-webkit-details-marker { display: none; }
.hw-twist {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.35rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  position: relative;
}
.hw-twist::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.35rem;
  height: 0.35rem;
  border-right: 2px solid #c8d4e0;
  border-bottom: 2px solid #c8d4e0;
  transform: translate(-60%, -60%) rotate(-45deg);
  transition: transform 0.12s ease;
}
details.hw-node[open] > summary > .hw-twist::before {
  transform: translate(-40%, -70%) rotate(45deg);
}
.tree-controls .btn.active-btn {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.conv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  min-width: 14rem;
}
.converters-table td.clip { max-width: 14rem; }
.hw-actions {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  opacity: 0.85;
  margin-left: auto;
}
.hw-pill {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  max-width: min(980px, 100%);
  padding: 0.35rem 0.75rem;
  border-radius: 10px;
  color: #e8eaed;
  text-decoration: none;
  font-weight: 500;
  line-height: 1.35;
  border: 1px solid transparent;
  vertical-align: middle;
  white-space: normal;
}
a.hw-pill:hover {
  text-decoration: none;
  filter: brightness(1.06);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.hw-ok {
  background: rgba(47, 122, 69, 0.28);
  border-color: #2f7a45;
}
.hw-warn {
  background: rgba(138, 74, 42, 0.32);
  border-color: #8a4a2a;
}
.hw-bad {
  background: rgba(122, 42, 42, 0.38);
  border-color: #7a2a2a;
}
.hw-muted {
  background: rgba(58, 66, 76, 0.55);
  border-color: #555e6a;
}
.hw-converter-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}
.hw-pill-sub {
  font-weight: 400;
  opacity: 0.85;
  font-size: 0.85em;
}
.hw-port-desc {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  font-size: 0.95rem;
  line-height: 1.4;
  color: #c8d4e0;
  max-width: 100%;
  white-space: normal;
  padding: 0.15rem 0 0.1rem 0.15rem;
}
.hw-desc-type {
  font-weight: 600;
  color: #e8eef5;
}
.hw-desc-res {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.hw-desc-chip {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border-radius: 5px;
  border: 1px solid #4a5a6a;
  background: rgba(80, 110, 140, 0.2);
  font-size: 0.82rem;
  color: #d0dce8;
}
.hw-desc-models {
  font-size: 0.88rem;
  color: #aebccc;
}
.hw-desc-notes {
  font-size: 0.82rem;
  color: #8a9aaa;
  font-style: italic;
}
.hw-stats {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  vertical-align: middle;
}
.hw-count-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  text-decoration: none !important;
  border: 1px solid transparent;
  line-height: 1.2;
  white-space: nowrap;
}
a.hw-count-chip:hover { filter: brightness(1.12); }
.hw-count-label {
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: lowercase;
  opacity: 0.9;
}
.hw-count-num {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
}
.hw-count-chip.total {
  background: rgba(45, 140, 80, 0.35);
  border-color: #2f8a4f;
  color: #9fe0b4;
}
.hw-count-chip.total .hw-count-num { color: #7dffa3; }
.hw-count-chip.bad {
  background: rgba(180, 50, 50, 0.4);
  border-color: #c0392b;
  color: #ffb0a8;
}
.hw-count-chip.bad .hw-count-num { color: #ff8a80; }
.hw-count-chip.ok {
  background: rgba(45, 140, 80, 0.2);
  border-color: #2f6a4f;
  color: #8fd4a8;
}
.hw-count-chip.ok .hw-count-num { color: #8fd4a8; }
.hw-count-chip.muted {
  background: rgba(255, 255, 255, 0.06);
  border-color: #4a5560;
  color: #9aa3ad;
}
.hw-count-chip.muted .hw-count-num { color: #c8d0d8; }
.hw-stat-total,
.hw-stat-link.hw-stat-total { color: #7dffa3; }
.hw-stat-link {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hw-stat-bad,
.hw-stat-link.hw-stat-bad { color: #ff8a80; }
.hw-stat-ok-off { color: #8aa896; }
.hw-stat-sep { display: none; }
.hw-port-link {
  color: #7eb6f0;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}
.hw-port-link:hover {
  color: #b7d8f8;
}
.hw-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: center;
  margin: 0.65rem 0 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.hw-legend .hw-pill {
  text-decoration: none;
  cursor: pointer;
}
.hw-legend .hw-pill:hover {
  filter: brightness(1.12);
  text-decoration: none;
}
.hw-leaf {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
}
.hw-channel-row { gap: 0.35rem 0.45rem; }
.hw-channel-pill { font-size: 0.82rem; }
.hw-leaf-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.water-icons {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.water-ico {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.1rem 0.35rem 0.1rem 0.2rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  border: 1px solid transparent;
  vertical-align: middle;
}
.water-ico svg { flex-shrink: 0; }
.water-hvs {
  color: #6fd0e0;
  background: rgba(80, 180, 200, 0.14);
  border-color: #3d7a8a;
}
.water-gvs {
  color: #f08a8a;
  background: rgba(255, 107, 107, 0.12);
  border-color: #8a4a4a;
}
.hw-legend .water-ico { margin: 0 0.1rem; }

.hw-type-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0.55rem 0 0.85rem;
}
.hw-type-nav-label { font-size: 0.8rem; margin-right: 0.15rem; }
.hw-type-jump {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 7px;
  padding: 0.28rem 0.65rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1.3;
}
.hw-type-jump em {
  font-style: normal;
  color: var(--muted);
  margin-left: 0.2rem;
}
.hw-type-jump:hover { border-color: var(--accent); color: #fff; }
.hw-type-jump.hw-type-electricity { border-color: #3d6a9a; color: #7eb6f0; }
.hw-type-jump.hw-type-switchboard { border-color: #9b7a3d; color: #ffd78a; }
.hw-type-jump.hw-type-heat { border-color: #9a5a3d; color: #f0a87e; }
.hw-type-jump.hw-type-water { border-color: #2d7a7a; color: #7ed6d0; }
.hw-type-jump.is-active { box-shadow: 0 0 0 1px currentColor; }

.hw-port-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}
.hw-type-chip {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.hw-type-chip.hw-type-electricity { border-color: #3d6a9a; color: #7eb6f0; }
.hw-type-chip.hw-type-switchboard { border-color: #9b7a3d; color: #ffd78a; }
.hw-type-chip.hw-type-heat { border-color: #9a5a3d; color: #f0a87e; }
.hw-type-chip.hw-type-water { border-color: #2d7a7a; color: #7ed6d0; }
.hw-type-chip.hw-type-lighting { border-color: #3d7a9a; color: #9fe0ff; }
.hw-type-chip.hw-type-water_reg { border-color: #2d8a6a; color: #8fe6c0; }

.hw-node.hw-jump-flash > .hw-summary {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.readings-sync-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
.readings-sync-form .map-check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.readings-subhead {
  margin: 0.85rem 0 0.55rem;
  font-size: 0.95rem;
}
.device-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin: 0.35rem 0 0.75rem;
  align-items: flex-start;
}
.device-hero-main { min-width: 0; flex: 1 1 16rem; }
.device-hero-main h1 {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.55rem;
  line-height: 1.2;
}
.device-hero-apt {
  display: inline-block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: rgba(90, 140, 200, 0.28);
  border: 1px solid #3d6a8a;
  color: #b7dbf5;
}
.device-hero-model {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.device-hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  margin-top: 0.55rem;
}
.device-status-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--line);
}
.device-status-pill.ok {
  color: #8fd4a8;
  border-color: #2f6a4f;
  background: rgba(47, 106, 79, 0.18);
}
.device-status-pill.bad {
  color: #ffb0a8;
  border-color: #6a3a3a;
  background: rgba(192, 57, 43, 0.2);
}
.device-hero-side {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 12rem;
}
.device-hero-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.device-hero-stat strong { font-size: 0.92rem; }
.device-info-panel { margin-top: 0.25rem; }
.reading-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid #3d5a7a;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(40, 70, 110, 0.35), rgba(16, 22, 32, 0.9));
}
.reading-hero-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.reading-hero-value {
  display: block;
  font-family: var(--mono);
  font-size: 1.65rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}
.reading-hero-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-end;
  color: var(--muted);
  font-size: 0.8rem;
}
.readings-latest {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.45rem;
}
.reading-chip {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
a.reading-chip:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.reading-chip.is-primary {
  border-color: var(--accent);
  background: rgba(70, 120, 180, 0.12);
}
.reading-name {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reading-value {
  font-family: var(--mono);
  font-size: 1.05rem;
  word-break: break-all;
}
.reading-meta {
  font-size: 0.68rem;
}
.readings-series-table td code {
  font-size: 0.9rem;
}
.hw-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hw-badge-bad {
  color: #f0a0a0;
  border-color: #6a3a3a;
  background: rgba(122, 42, 42, 0.35);
}
.hw-badge-mode {
  color: #f0c070;
  border-color: #8a6a2a;
  background: rgba(138, 90, 30, 0.35);
}
.hw-badge-note {
  color: #b8c8d8;
  border-style: dashed;
  max-width: 360px;
}
.hw-id-link {
  margin-left: 0.35rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 400;
  font-size: 0.85em;
}
.hw-id-link:hover { color: #fff; }
.hw-ext {
  font-size: 0.72rem;
  color: #8eb8e8;
  text-decoration: none;
  border: 1px solid #3d5a7a;
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
}
.hw-ext:hover { color: #fff; border-color: var(--accent); text-decoration: none; }
.hw-actions a.btn { text-decoration: none; }
.hw-mode-off {
  outline: 1px dashed #e6b84d;
}

.flashes { margin-bottom: 1rem; }
.flash {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 0.4rem;
}
.flash-ok { border-color: #2f6a4f; background: #143226; }
.flash-error { border-color: #6a2f2f; background: #321414; }

.tag-LIGHT { color: #e6c35a; border-color: #8a7a3a; }
.light-house-panel.has-issues { border-color: #6a3a3a; }
.light-house-panel.all-ok { border-color: #2f5a45; }
.light-stats {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.light-house-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}
.light-house-title h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.light-house-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.light-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
}
.light-chip.ok { color: #8fd4a8; border-color: #2f6a4f; }
.light-chip.bad { color: #f0a0a0; border-color: #6a3a3a; }
.light-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.6rem;
}
.light-card {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(28, 36, 48, 0.95), rgba(16, 22, 32, 0.98));
  padding: 0.7rem 0.75rem 0.65rem;
  font-size: 0.84rem;
  min-height: 9.5rem;
}
.light-card.is-online { border-color: #2f6a4f; box-shadow: inset 0 0 0 1px rgba(47, 106, 79, 0.25); }
.light-card.is-offline { border-color: #6a3a3a; background: linear-gradient(160deg, rgba(48, 28, 28, 0.55), rgba(16, 18, 24, 0.98)); }
.light-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  align-items: flex-start;
}
.light-serial {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  word-break: break-all;
  line-height: 1.25;
}
.light-serial:hover { color: var(--accent); }
.light-kind {
  flex-shrink: 0;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.14rem 0.4rem;
  border-radius: 6px;
  border: 1px solid #8a7a3a;
  color: #e6c35a;
  background: rgba(138, 122, 58, 0.18);
}
.light-card.kind-astro .light-kind {
  border-color: #3d6a8a;
  color: #8ec4e8;
  background: rgba(61, 106, 138, 0.22);
}
.light-card-model {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.light-card-ip code {
  font-size: 0.78rem;
  color: #b8d0e8;
}
.light-card-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.1rem;
}
.light-status-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.light-card-warn {
  color: #e6b84d;
  font-size: 0.72rem;
}
.light-card-note {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.light-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  margin-top: auto;
  padding-top: 0.35rem;
}
.light-card-actions .soft-link {
  font-size: 0.78rem;
}

.arshin-panel .arshin-status,
.arshin-port-panel .status-valid,
.arshin-cell.status-valid { color: #8fd4a8; }
.arshin-status.status-expired,
.arshin-port-panel .status-expired,
.arshin-cell.status-expired { color: #e6b84d; }
.arshin-status.status-unfit,
.arshin-status.status-not_found,
.arshin-status.status-error,
.arshin-port-panel .status-unfit,
.arshin-port-panel .status-not_found,
.arshin-port-panel .status-error,
.arshin-cell.status-unfit,
.arshin-cell.status-not_found,
.arshin-cell.status-error { color: #f0a0a0; }
.arshin-status.status-ambiguous,
.arshin-port-panel .status-ambiguous,
.arshin-cell.status-ambiguous { color: #8ec4e8; }
.arshin-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  margin: 0.55rem 0 0.75rem;
}
.arshin-status-label { font-size: 1rem; }
.arshin-kv { margin-top: 0.25rem; }
.arshin-candidates { margin-top: 0.75rem; }
.arshin-candidates summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.arshin-port-hint { margin: 0.45rem 0 0; font-size: 0.82rem; }
.arshin-cell .muted { display: block; font-size: 0.72rem; }
.hw-badge.hw-arshin {
  border-color: #3d5a7a;
  color: #9ec0e0;
  background: rgba(40, 70, 100, 0.35);
  max-width: 340px;
  white-space: nowrap;
}
.hw-badge.hw-arshin.is-empty {
  display: none;
}
.hw-badge.hw-arshin.status-valid { color: #8fd4a8; border-color: #2f6a4f; }
.hw-badge.hw-arshin.status-expired { color: #e6b84d; border-color: #8a6a2a; }
.hw-badge.hw-arshin.status-unfit,
.hw-badge.hw-arshin.status-not_found,
.hw-badge.hw-arshin.status-error { color: #f0a0a0; border-color: #6a3a3a; }
.hw-badge.hw-arshin.status-ambiguous { color: #8ec4e8; border-color: #3d6a8a; }
.hw-arshin-link {
  color: inherit;
  text-decoration: none;
}
.hw-arshin-link:hover { text-decoration: underline; }

.map-filters {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
}
.map-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}
.map-filters-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 7.5rem;
}
.map-filters-row select,
.map-filters-row input[type="number"],
.map-filters-row input[type="search"] {
  min-width: 8rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}
.map-filters-row .map-check {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  min-width: auto;
  padding-bottom: 0.35rem;
}
.map-filter-hint { margin: 0.55rem 0 0; font-size: 0.82rem; }
.map-filter-groups {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.map-filter-group {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.map-filter-group-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.map-filters-row select#map-port-scale,
.map-filters-row #map-device-type {
  min-width: 12rem;
}
.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.9fr);
  gap: 1rem;
  align-items: start;
}
.map-panel { padding-bottom: 0.75rem; }
.leaflet-host {
  height: min(70vh, 640px);
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1a222c;
  z-index: 1;
}
.map-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.55rem;
}
.map-presets .btn { font-size: 0.75rem; }
.map-focus-type {
  margin-top: 4px;
  font-size: 12px;
  color: #f0b87e;
}
.fault-focus {
  font-size: 0.78rem;
  color: #f0b87e;
}

.map-dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  margin-right: 0.2rem;
  vertical-align: middle;
}
.map-dot.ok { background: #2f7a45; }
.map-dot.warn { background: #8a4a2a; }
.map-dot.bad { background: #7a2a2a; }
.map-dot.muted { background: #3a424c; }
.map-dot.zabbix {
  background: #7a2a2a;
  box-shadow: 0 0 0 3px rgba(220, 60, 60, 0.85);
}
.map-dot.port-hot {
  background: #8a4a2a;
  box-shadow: 0 0 0 3px rgba(230, 140, 40, 0.9);
}
.map-side { max-height: min(78vh, 720px); overflow: auto; }
.fault-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.fault-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background: var(--bg);
  font-size: 0.85rem;
  cursor: pointer;
}
.fault-item:hover { border-color: var(--accent); text-decoration: none; }
.fault-item.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fault-item.status-bad { border-color: #6a3a3a; }
.fault-item.status-warn { border-color: #6a4a2a; }
.fault-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.2rem; }
.fault-chip {
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(122, 42, 42, 0.25);
  border: 1px solid #6a3a3a;
  color: var(--text);
}
.crm-map-marker { background: transparent !important; border: none !important; }
.fault-item.has-zabbix {
  border-color: #a33;
  box-shadow: inset 3px 0 0 #c0392b;
}
.fault-item.has-port-full {
  border-color: #a15a20;
  box-shadow: inset 3px 0 0 #e68628;
}
.fault-item.has-port-major {
  border-color: #8a6a2a;
  box-shadow: inset 3px 0 0 #c9a227;
}
.fault-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.fault-item-top strong {
  font-size: 0.9rem;
  line-height: 1.25;
  flex: 1 1 auto;
  min-width: 0;
}

/* Карточка дома в списке: индикатор серьёзности и метрики */
.fault-sev {
  flex-shrink: 0;
  width: 8px;
  align-self: stretch;
  min-height: 1.1rem;
  border-radius: 3px;
  background: #3a4654;
  margin-top: 0.15rem;
}
.fault-sev.sev-major { background: #d9534f; }
.fault-sev.sev-partial { background: #e6862d; }
.fault-sev.sev-single { background: #d9c24f; }
.fault-sev.sev-ok { background: #3ecf8e; }

.fault-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.15rem 0.5rem;
  margin-top: 0.3rem;
  font-size: 0.76rem;
}
.fault-metric { display: flex; justify-content: space-between; gap: 0.35rem; min-width: 0; }
.fault-metric .muted { font-size: 0.72rem; }
.fault-metric b { font-family: var(--mono); }
.fault-metric b.ok { color: var(--ok); }
.fault-metric b.bad { color: var(--bad); }

/* Иконки состава оборудования на карточке дома */
.fault-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
  margin-top: 0.4rem;
}
.fault-type-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.fault-type-icon .ti { font-size: 0.8rem; line-height: 1; }
.fault-type-icon .tn { font-size: 0.7rem; }
.fault-type-icon .tc { font-family: var(--mono); font-weight: 600; }
.fault-type-icon.is-bad { border-color: #6a3a3a; color: #f0b0b0; background: rgba(255, 107, 107, 0.09); }
.fault-type-icon.type-electricity { border-left: 2px solid #e6c84f; }
.fault-type-icon.type-lighting { border-left: 2px solid #7fd4ff; }
.fault-type-icon.type-heat { border-left: 2px solid #ff8a5c; }
.fault-type-icon.type-water { border-left: 2px solid #5ca8ff; }
.fault-type-icon.type-switchboard { border-left: 2px solid #9aa7b8; }
.fault-type-icon.type-water_reg { border-left: 2px solid #6fd4c4; }

.fault-chip .chip-icon { margin-right: 0.2rem; }
.fault-chip-electricity { border-left: 2px solid #e6c84f; }
.fault-chip-lighting { border-left: 2px solid #7fd4ff; }
.fault-chip-heat { border-left: 2px solid #ff8a5c; }
.fault-chip-water { border-left: 2px solid #5ca8ff; }

/* Ключевые цифры карточки: неисправно / работает / всего */
.fault-wide {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
  align-items: baseline;
  margin-top: 0.3rem;
  font-size: 0.8rem;
}
.fault-wide b { font-family: var(--mono); font-size: 0.95rem; }
.fault-wide .bad { color: var(--bad); }
.fault-wide .bad b { color: var(--bad); }
.fault-wide .ok { color: var(--ok); }
.fault-wide .ok b { color: var(--ok); }

.fault-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: center;
  margin-top: 0.3rem;
  font-size: 0.72rem;
}
.fault-worst {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
  align-items: center;
  margin-top: 0.3rem;
  font-size: 0.72rem;
}
.fault-worst .fault-link { font-family: var(--mono); }

.fault-offline-pill {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  background: rgba(122, 42, 42, 0.28);
  border: 1px solid #6a3a3a;
  color: #f0a0a0;
  white-space: nowrap;
}
.fault-offline-pill.is-ok {
  background: rgba(42, 106, 74, 0.24);
  border-color: #2f6a4f;
  color: #93e5bd;
}
.map-popup-shared { color: var(--warn); }
.fault-ports {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.15rem;
}
.port-sev {
  font-size: 0.7rem;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  font-family: var(--mono);
  border: 1px solid var(--line);
  color: var(--muted);
}
.port-sev.full {
  color: #ffd0a0;
  border-color: #a15a20;
  background: rgba(230, 134, 40, 0.22);
}
.port-sev.major {
  color: #f0d080;
  border-color: #8a6a2a;
  background: rgba(201, 162, 39, 0.18);
}
.port-sev.partial,
.port-sev.single {
  color: #c8c0b0;
  border-color: #5a5040;
}
.fault-zabbix {
  color: #f0a0a0;
  font-size: 0.78rem;
  font-family: var(--mono);
}
.fault-converters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.2rem;
}
.map-conv-chip {
  font-size: 0.7rem;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
}
.map-conv-chip.is-bad {
  color: #f0a0a0;
  border-color: #6a3a3a;
  background: rgba(122, 42, 42, 0.2);
}
.fault-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.fault-link {
  font-size: 0.72rem;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.crm-map-popup .leaflet-popup-content-wrapper {
  background: #1a1f26;
  color: #e8eaed;
  border-radius: 10px;
  border: 1px solid #333;
}
.crm-map-popup .leaflet-popup-tip { background: #1a1f26; }
.crm-map-popup a { color: #7eb6f0; }
.map-popup { min-width: 240px; max-width: 340px; font: 13px/1.4 system-ui, sans-serif; }
.map-popup .muted { color: #9aa3ad; }
.map-popup .map-types { margin-top: 4px; font-size: 12px; color: #9aa3ad; }
.map-popup .map-geo { margin-top: 6px; font-size: 11px; color: #777; }
.map-zabbix-line { margin-top: 6px; color: #f0a0a0; font-size: 12px; }
.map-converters {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid #333;
}
.map-conv-title { font-size: 11px; color: #9aa3ad; margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.03em; }
.map-conv { margin-bottom: 0.45rem; padding: 0.35rem 0.4rem; border-radius: 6px; background: rgba(255,255,255,0.03); }
.map-conv.is-zabbix-bad { background: rgba(122, 42, 42, 0.22); border: 1px solid #6a3a3a; }
.map-conv-head { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.2rem; }
.map-zabbix-badge {
  font-size: 0.7rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: rgba(192, 57, 43, 0.35);
  color: #f0a0a0;
  border: 1px solid #6a3a3a;
}
.map-port-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: baseline;
  font-size: 12px;
  margin: 0.12rem 0;
  padding: 0.15rem 0.25rem;
  border-radius: 4px;
}
.map-port-row.is-hot {
  background: rgba(230, 134, 40, 0.12);
  border: 1px solid rgba(161, 90, 32, 0.45);
}
.map-port-row .map-off { color: #f0a0a0; }
.map-res {
  font-size: 11px;
  color: #9aa3ad;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  border: 1px solid transparent;
}
.map-res.is-hot {
  color: #ffd0a0;
  border-color: #a15a20;
  background: rgba(230, 134, 40, 0.15);
}
.map-port-alerts {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.4rem 0 0.2rem;
}
.map-port-alert {
  display: block;
  font-size: 11px;
  font-family: var(--mono);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  text-decoration: none;
  border: 1px solid #5a5040;
  color: #e0d0b0;
  background: rgba(255, 255, 255, 0.03);
}
.map-port-alert.full {
  border-color: #a15a20;
  color: #ffd0a0;
  background: rgba(230, 134, 40, 0.18);
}
.map-port-alert.major {
  border-color: #8a6a2a;
  color: #f0d080;
  background: rgba(201, 162, 39, 0.14);
}
.map-port-link { font-size: 11px; margin-left: auto; }
.map-popup-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.55rem;
  font-size: 12px;
}

/* —— Сервера (Zabbix) —— */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.85rem;
}
.server-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.server-card.status-offline { border-color: #6a3a3a; box-shadow: inset 3px 0 0 #c0392b; }
.server-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}
.server-card-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.server-card-head h2 a { color: var(--text); text-decoration: none; }
.server-card-head h2 a:hover { color: var(--accent); }
.server-desc { margin: 0.25rem 0 0; font-size: 0.82rem; }
.server-ip { font-size: 0.78rem; }
.server-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.srv-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  line-height: 1.25;
  background: rgba(255, 255, 255, 0.03);
}
.srv-pill.ok { color: #8fd4a8; border-color: #2f6a4f; background: rgba(47, 106, 79, 0.14); }
.srv-pill.bad { color: #f0a0a0; border-color: #6a3a3a; background: rgba(122, 42, 42, 0.18); }
.srv-pill.warn { color: #e6b84d; border-color: #8a6a2a; background: rgba(230, 184, 77, 0.12); }
.srv-pill.muted { color: var(--muted); }
.srv-pill.metric { min-width: 9rem; }
.srv-bar {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.srv-bar i {
  display: block;
  height: 100%;
  background: #5b9bd5;
}
.srv-pill.warn .srv-bar i,
.srv-pill.bad .srv-bar i { background: #e67e22; }
.server-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: auto;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}
.server-actions { margin-left: auto; display: flex; gap: 0.35rem; }
.server-resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}
.server-resource-grid h3 { margin: 0 0 0.35rem; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.server-resource-grid p { margin: 0; font-size: 0.92rem; }
.server-graphs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 0.85rem;
}
.server-graph-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  background: var(--bg);
}
.server-graph-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
}
.server-graph-canvas { height: 200px; position: relative; }
.server-graph-links { margin-top: 0.4rem; font-size: 0.78rem; }
.sev {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.75rem;
  border: 1px solid var(--line);
}
.sev-4, .sev-5 { color: #f0a0a0; border-color: #6a3a3a; }
.sev-3 { color: #e6b84d; border-color: #8a6a2a; }
.sev-2 { color: #8ec4e8; border-color: #3d6a8a; }

/* —— Терминал —— */
.terminal-target-grid {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.8fr 0.6fr;
  gap: 0.75rem 1rem;
  align-items: end;
}
.terminal-target-grid-wide {
  grid-template-columns: 1.6fr 1fr 1.6fr 0.55fr;
  margin-bottom: 0.85rem;
}
.terminal-target-grid-ports {
  grid-template-columns: 2.4fr 1fr 0.7fr;
  margin-bottom: 0.65rem;
}
.term-port-select-wrap select {
  width: 100%;
  max-width: 100%;
}
.term-port-meta {
  margin: 0.35rem 0 0.15rem;
}
.term-link-banner {
  margin: 0.35rem 0 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
}
.term-link-banner-fail {
  background: rgba(220, 70, 70, 0.14);
  border-color: rgba(220, 70, 70, 0.45);
  color: #ffb4b4;
}
.term-link-banner-warn {
  background: rgba(220, 160, 40, 0.14);
  border-color: rgba(220, 160, 40, 0.45);
  color: #ffd48a;
}
.term-link-banner-ok {
  background: rgba(60, 160, 100, 0.12);
  border-color: rgba(60, 160, 100, 0.4);
  color: #9de0b8;
}
  font-size: 0.88rem;
  margin: 0.25rem 0 0.75rem;
  line-height: 1.4;
}
.term-devices-wrap h3 {
  margin: 0;
  font-size: 1rem;
}
.term-poll-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  margin: 0.15rem 0 0.55rem;
  font-size: 0.8rem;
}
.term-poll-swatch::before {
  content: "";
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  margin-right: 0.35rem;
  border-radius: 2px;
  vertical-align: -0.05rem;
}
.term-poll-swatch.term-poll-ok::before { background: #2f9e5f; }
.term-poll-swatch.term-poll-stale::before { background: #c0392b; }
.term-poll-swatch.term-poll-never::before { background: #1a1a1a; border: 1px solid #666; }
.term-devices-scroll {
  max-height: min(70vh, 720px);
  overflow: auto;
}
.term-devices-wrap .table td,
.term-devices-wrap .table th {
  white-space: nowrap;
}
.term-devices-wrap .table tbody tr.term-dev-ok td {
  color: #3ecf8e;
}
.term-devices-wrap .table tbody tr.term-dev-stale td {
  color: #ff6b6b;
}
.term-devices-wrap .table tbody tr.term-dev-never td {
  color: #9aa3ad;
}
.term-devices-wrap .table tbody tr.term-dev-never {
  box-shadow: inset 3px 0 0 #0a0a0a;
  background: rgba(0, 0, 0, 0.28);
}
.term-devices-wrap .table tbody tr.term-dev-ok:hover,
.term-devices-wrap .table tbody tr.term-dev-stale:hover,
.term-devices-wrap .table tbody tr.term-dev-never:hover {
  background: rgba(90, 140, 200, 0.08);
}
.term-devices-wrap .table tbody tr.term-dev-never:hover {
  background: rgba(0, 0, 0, 0.38);
}
.term-devices-wrap .table tbody tr.term-reg {
  font-weight: 600;
  background: rgba(56, 120, 180, 0.12);
}
.term-devices-wrap .table tbody tr.term-reg-open {
  box-shadow: inset 3px 0 0 #3a8fd6;
}
.term-devices-wrap .table tbody tr.term-ch td:nth-child(3),
.term-devices-wrap .table tbody tr.term-ch td:nth-child(4) {
  padding-left: 0.85rem;
}
.term-devices-wrap .table tbody tr.term-ch {
  background: rgba(255, 255, 255, 0.03);
}
.term-devices-wrap .table tbody tr.term-hit {
  outline: 1px solid rgba(58, 143, 214, 0.55);
}
.term-water-hvs,
.term-water-gvs {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  margin-right: 0.25rem;
}
.term-water-hvs {
  background: rgba(56, 140, 220, 0.25);
  color: #7ec8ff;
}
.term-water-gvs {
  background: rgba(220, 100, 60, 0.28);
  color: #ffb08a;
}
.term-reg-toggle {
  margin-right: 0.2rem;
  min-width: 1.4rem;
  padding: 0.1rem 0.25rem;
  font-size: 0.7rem;
  line-height: 1.2;
}
#term-devices-table th:first-child,
#term-devices-table td:first-child {
  white-space: nowrap;
  width: 2.5rem;
}
#term-devices-table .term-poll-addr {
  color: #9ec3e8;
  font-weight: 500;
}
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0 0.2rem;
  min-width: 1.2rem;
}
.term-reg-actions .btn {
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
}
.term-ch-reading {
  color: #c8d0d8;
  font-size: 0.8rem;
}
.term-live-cell {
  font-size: 0.78rem;
  max-width: 28rem;
  line-height: 1.25;
  color: #c5d0da;
}
.term-t-rev,
.term-reading-warn .term-reading-value {
  color: #f07178 !important;
  font-weight: 600;
}
.term-err {
  color: #e6a23c;
}
.term-reading-card.term-reading-warn {
  border-color: #a04048;
  background: rgba(160, 48, 56, 0.18);
}
.term-search-hint {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.82rem;
}
.term-linergo-link {
  font-weight: 600;
  color: #5a8cc8;
  text-decoration: none;
}
.term-linergo-link:hover {
  text-decoration: underline;
}
.term-readings-panel {
  border-color: #3d6a8a;
}
#terminal-root.term-busy {
  opacity: 0.85;
  pointer-events: none;
}
#terminal-root.term-busy .term-devices-wrap {
  pointer-events: none;
}
.term-readings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
}
.term-reading-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}
.term-reading-card.meta {
  border-color: #3d5168;
}
.term-reading-card.bad {
  border-color: #6a3a3a;
}
.term-reading-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.term-reading-value {
  font-size: 1.05rem;
  font-weight: 500;
  word-break: break-word;
}
.terminal-target-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.terminal-target-grid select,
.terminal-target-grid input,
.term-actions select,
.term-actions input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}
.term-num { width: 5.5rem; }
.term-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
}
.term-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.4rem 0.75rem;
}
.term-tab:hover { color: var(--text); border-color: var(--line); }
.term-tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(61, 155, 253, 0.12);
}
.term-pane { display: none; }
.term-pane.active { display: block; }
.term-actions {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 0.85rem;
}
.term-actions label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.term-check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem !important;
  padding-bottom: 0.45rem;
}
.term-hint { margin: 0.65rem 0 0; font-size: 0.85rem; }
.term-prof-params {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.65rem 0.85rem;
  align-items: flex-end;
}
.term-prof-params label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.term-profile-target {
  margin-bottom: 0.35rem;
}
.term-profile-target input.mono {
  min-width: 7.5rem;
}
.term-tekon-scan-panel .map-toolbar {
  margin-bottom: 0.5rem;
}
.term-tekon-scan-scroll {
  max-height: 280px;
}
.term-tekon-scan-panel .table td,
.term-tekon-scan-panel .table th {
  white-space: nowrap;
}
.term-tekon-scan-panel .table td:nth-child(5) {
  white-space: normal;
  max-width: 28rem;
  font-size: 0.8rem;
}
.terminal-log-panel .map-toolbar { margin-bottom: 0.5rem; }
.terminal-log {
  margin: 0;
  min-height: 280px;
  max-height: 55vh;
  overflow: auto;
  padding: 0.85rem 1rem;
  background: #0a0e13;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c8d6e5;
}
.term-ex {
  margin: 0.12rem 0;
  font-family: inherit;
}
.term-ex-ok,
.term-ex-fail {
  margin-top: 0.7rem;
}
.term-ex-tx { color: #38bdf8; }
.term-ex-rx { color: #4ade80; }
.term-ex-info { color: #94a3b8; }
.term-ex-err { color: #f87171; }
.term-ex-ok { color: #86efac; }
.term-ex-fail { color: #fca5a5; }
.term-ex-sep {
  margin: 0.55rem 0 0.25rem;
  color: #64748b;
  border-top: 1px solid #1e293b;
  padding-top: 0.35rem;
}
.term-ex-tag {
  font-weight: 600;
  margin-right: 0.35rem;
}
.term-ex-hex {
  opacity: 0.92;
  letter-spacing: 0.02em;
}

/* Адаптивность вынесена в конец файла: см. блок «Адаптивность» ниже */

/* --- Настройки --- */
/* display у .rule-form label перебивает браузерное [hidden] — фиксируем оба варианта */
[hidden] { display: none !important; }
.rule-form .is-hidden { display: none !important; }

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.6rem;
}
.settings-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
}
.settings-tab:hover {
  color: var(--text);
  background: var(--bg-soft);
  text-decoration: none;
}
.settings-tab.active {
  color: var(--text);
  background: var(--bg-soft);
  border-color: var(--accent);
}
.settings-tab em {
  font-style: normal;
  font-size: 0.75rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}
.settings-tab.active em { color: var(--accent); border-color: var(--accent); }

.settings-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.9rem;
}

.rule-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
  align-items: end;
}
.rule-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.rule-form label.grow { grid-column: span 2; }
.rule-form input,
.rule-form select,
.rule-form textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  width: 100%;
}
.rule-form .rule-form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.rule-hint { color: var(--muted); font-size: 0.78rem; }
.rule-preview { font-size: 0.85rem; min-height: 1.2rem; }
.rule-preview.ok { color: var(--ok); }
.rule-preview.err { color: var(--bad); }

.rules-table td { vertical-align: middle; }
.rules-table .rule-target { font-family: var(--mono); font-size: 0.82rem; }
.rules-table tr.is-off { opacity: 0.5; }
/* чтобы колонка действий всегда попадала в экран */
.rules-table td:nth-child(4),
.rules-table td:nth-child(5),
.rules-table td:nth-child(8) { max-width: 17rem; overflow: hidden; text-overflow: ellipsis; }
.rules-table td:last-child { min-width: 15rem; }
.rules-table .row-actions { flex-wrap: wrap; }
.empty-ports-table td:nth-child(3) { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.empty-ports-table td:nth-child(2) .rule-status { white-space: normal; }
.rule-details,
.rule-detail { max-width: 100%; }
.rule-detail .comments-form .comments-body textarea { min-height: 2.4rem; }
.rule-status {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  white-space: nowrap;
}
.rule-status.offline { color: var(--bad); border-color: #6b2f2f; }
.rule-status.online { color: var(--ok); border-color: #2f6b4c; }
.rule-status.scope-dashboard { color: var(--warn); border-color: #6b5a2f; }
.rule-hidden-badge {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px dashed var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.rule-hidden-badge[title] { cursor: help; }
.house-card-hidden {
  color: var(--muted);
  font-size: 0.75rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.3rem;
  margin: 0.2rem 0 0;
}
.rule-presets { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rule-presets button { font-size: 0.78rem; padding: 0.3rem 0.6rem; }

/* Детали правила: порты дома и комментарии */
.rule-details { margin-top: 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; }
.rule-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
}
.rule-detail > summary {
  cursor: pointer;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  list-style: none;
  padding: 0.2rem 0;
}
.rule-detail > summary::-webkit-details-marker { display: none; }
.rule-detail > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.8rem;
}
.rule-detail[open] > summary::before { content: "▾"; }
.rule-comments { margin-top: 0.5rem; border-top: 1px dashed var(--line); padding-top: 0.6rem; }
.rule-comments-title { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 600; }
.rule-comments .comments-form { display: flex; gap: 0.6rem; align-items: end; flex-wrap: wrap; }
.rule-comments .comments-list { margin-top: 0.6rem; }
.rule-comments .comment-item { margin-bottom: 0.4rem; }
.rule-comments .comment-item p { margin: 0.2rem 0 0; }

/* Пустые порты */
.empty-reason { white-space: nowrap; }

/* ==========================================================================
   Адаптивность
   Блок намеренно в конце файла: правила ниже перекрывают базовые стили.
   ========================================================================== */

/* Длинные адреса, IP и слова не должны растягивать страницу */
body { -webkit-text-size-adjust: 100%; }
.page-head h1,
.page-head p,
.panel h2,
.house-card header a,
.mono,
.rule-target { overflow-wrap: anywhere; }
.stat-value { overflow-wrap: anywhere; }

/* --- Большие мониторы --------------------------------------------------- */
@media (min-width: 1440px) {
  .stat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .house-cards { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
}

/* --- Компактные ноутбуки (1100–1439) ------------------------------------ */
@media (max-width: 1439px) {
  .stat-grid[style] { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .map-layout { grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.9fr); }
}

/* --- Планшеты в ландшафте (901–1100) ------------------------------------ */
@media (max-width: 1100px) {
  .stat-grid,
  .stat-grid[style] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .two-col { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; }
  .leaflet-host { height: min(60vh, 520px); }
  .terminal-target-grid,
  .terminal-target-grid-wide,
  .terminal-target-grid-ports { grid-template-columns: 1fr 1fr; }
  .terminal-target-grid > *,
  .terminal-target-grid-wide > *,
  .terminal-target-grid-ports > * { min-width: 0; }
  .hw-leaf-row > .hw-device { flex: 1 1 100%; }
}

/* --- Планшеты и меню-гамбургер (<=1024) --------------------------------- */
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 60;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }
  .nav-toggle { display: inline-block; }
  .sidebar .nav-links {
    display: none;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.6rem;
    max-height: 62vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--line);
    padding-top: 0.6rem;
  }
  .sidebar.nav-open .nav-links { display: flex; }
  .sidebar.nav-open .sidebar-actions { display: flex; }
  .sidebar .sidebar-actions { display: none; }
  .sidebar .nav-links a { padding: 0.7rem 0.75rem; }
  .content { padding: 1rem 1rem 2rem; }
  .page-head h1 { font-size: 1.45rem; }
}

/* --- Телефоны (<=900) --------------------------------------------------- */
@media (max-width: 900px) {
  .stat-grid,
  .stat-grid[style] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .house-cards,
  .house-cards-compact { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
  .block-grid { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }
  .comments-form { flex-wrap: wrap; }
  .comments-form .comments-author { width: 100%; }
  .comments-form .comments-body { flex: 1 1 100%; min-width: 0; }
  .comments-form button { align-self: stretch; }
  .house-card footer { gap: 0.5rem 0.9rem; }
}

/* --- Телефоны (<=640) --------------------------------------------------- */
@media (max-width: 640px) {
  .conv-actions { min-width: 0; }
  .rules-table td:last-child { min-width: 0; }
  .rules-table .row-actions { flex-wrap: wrap; gap: 0.3rem; }
  .empty-ports-table td:nth-child(3) { max-width: 9rem; }
  .content { padding: 0.85rem 0.75rem 2rem; }
  .sidebar { padding: 0.6rem 0.75rem; }
  .brand-mark { font-size: 1.25rem; }
  .brand-sub { font-size: 0.78rem; }
  .page-head h1 { font-size: 1.3rem; }
  .page-head p { font-size: 0.9rem; }
  .panel { padding: 0.85rem 0.8rem 1rem; }

  .stat-grid,
  .stat-grid[style] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0.5rem; }
  .stat { padding: 0.7rem 0.75rem; }
  .stat-value { font-size: 1.25rem; }
  .stat-label { font-size: 0.78rem; }

  .actions-row,
  .row-actions,
  .map-toolbar { gap: 0.5rem; }
  .actions-row > .btn,
  .actions-row > form > .btn,
  .row-actions > .btn,
  .row-actions > form > .btn,
  .map-toolbar > .btn { flex: 0 1 auto; }

  /* Формы: одно поле в строку и шрифт 16px, чтобы iOS не зумил */
  .filter-form,
  .inline-form { flex-direction: column; align-items: stretch; }
  .filter-form label,
  .filter-form label.grow,
  .inline-form label { min-width: 0; width: 100%; }
  .filter-form input,
  .filter-form select,
  .inline-form input,
  .inline-form select,
  .rule-form input,
  .rule-form select,
  .rule-form textarea,
  .search-form input,
  .search-form select { font-size: 1rem; }
  .filter-form input[style],
  .inline-form input[style] { width: 100% !important; }
  .rule-form label.grow { grid-column: auto; }

  /* Таблицы: прокрутка по горизонтали внутри блока, а не всей страницей */
  .table-scroll { max-height: 68vh; }
  .table-scroll .table { white-space: nowrap; }
  .rules-table td:last-child { min-width: 0; }

  .house-cards,
  .house-cards-compact { grid-template-columns: 1fr; }
  .house-card footer a { font-size: 0.82rem; }

  .terminal-target-grid,
  .terminal-target-grid-wide,
  .terminal-target-grid-ports { grid-template-columns: 1fr; }
  .terminal-target-grid label,
  .terminal-target-grid-wide label,
  .terminal-target-grid-ports label { width: 100%; min-width: 0; }
  .terminal-target-grid input,
  .terminal-target-grid select,
  .terminal-target-grid-wide input,
  .terminal-target-grid-wide select,
  .terminal-target-grid-ports input,
  .terminal-target-grid-ports select { width: 100%; min-width: 0; max-width: 100%; }
  .term-num { width: 100%; }
  .leaflet-host { height: 52vh; }

  /* Строка «Комментарии к дому … история сохраняется» */
  .comments-panel .map-toolbar { flex-direction: column; align-items: flex-start; }
  .rule-comments .comments-form { flex-direction: column; align-items: stretch; }
  .rule-comments .comments-form label,
  .rule-comments .comments-form .comments-author { width: 100%; }
  .rule-comments .comments-form textarea,
  .rule-comments .comments-form input { width: 100%; }
  .rule-comments .comments-form button { align-self: stretch; }

  /* Тач-цели */
  .btn,
  button { min-height: 2.5rem; }
  .btn-sm { min-height: 2.1rem; padding: 0.35rem 0.6rem; }

  .kv-list li { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
  .hw-actions { flex-wrap: wrap; }
  .settings-tabs { gap: 0.3rem; }
  .settings-tab { padding: 0.45rem 0.65rem; font-size: 0.9rem; }
}

/* --- Узкие телефоны (<=420) -------------------------------------------- */
@media (max-width: 420px) {
  .stat-grid,
  .stat-grid[style] { grid-template-columns: 1fr 1fr !important; }
  .stat-value { font-size: 1.15rem; }
  .page-head h1 { font-size: 1.2rem; }
  .hw-count-label { display: none; }
  .port-chip { min-width: 0; }
}

/* ==========================================================================
   Вход, профиль и админ-панель
   ========================================================================== */

/* Страница входа: без сайдбара, по центру */
body.auth-layout .shell { grid-template-columns: 1fr; }
body.auth-layout .content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem 1rem;
}
.login-wrap { width: 100%; max-width: 26rem; margin: 0 auto; }
.login-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.5rem 1.75rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.login-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}
.login-head .brand-mark { font-size: 1.5rem; font-weight: 600; letter-spacing: 0.03em; }
.login-card h1 { margin: 0.2rem 0 0; font-size: 1.25rem; font-weight: 600; }
.login-card p { margin: 0; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.login-card input {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
}
.login-btn { margin-top: 0.35rem; width: 100%; }

/* Страница ошибки */
.error-panel { text-align: center; padding: 2.5rem 1.5rem; }
.error-panel .error-code {
  font-family: var(--mono);
  font-size: 3rem;
  font-weight: 600;
  color: var(--bad);
  line-height: 1;
  margin-bottom: 0.4rem;
}
.error-panel h1 { margin: 0 0 0.5rem; font-size: 1.4rem; }
.error-panel .actions-row { justify-content: center; margin-top: 1.2rem; }

/* Блок пользователя в сайдбаре */
.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.sidebar-user-info { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.sidebar-user-info strong { font-size: 0.9rem; overflow-wrap: anywhere; }
.sidebar-user-info .muted { font-size: 0.78rem; }

/* Вкладки админ-панели */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.6rem;
}
.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
}
.admin-tab:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.admin-tab.active { color: var(--text); background: var(--bg-soft); border-color: var(--accent); }
.admin-tab em {
  font-style: normal;
  font-size: 0.75rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}

/* Пользователи */
.user-role-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  white-space: nowrap;
}
.user-role-badge.role-admin { color: #ffd78a; border-color: #9b7a3d; }
.user-role-badge.role-operator { color: #9fcaff; border-color: #3d6f9b; }
.user-status { font-size: 0.8rem; color: var(--ok); white-space: nowrap; }
.user-status.is-disabled { color: var(--bad); }
tr.is-disabled td { opacity: 0.6; }

/* Журнал */
.audit-action { font-size: 0.85rem; white-space: nowrap; }
.audit-category { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.audit-result { font-size: 0.8rem; white-space: nowrap; color: var(--ok); }
.audit-result.is-error { color: var(--bad); }
.changes-list {
  margin: 0.2rem 0 0;
  padding-left: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.changes-list li { margin: 0; }

/* Настройки CRM */
.setting-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--line);
}
.setting-row:last-child { border-bottom: none; }
.setting-row label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; }
.setting-row input[type="text"],
.setting-row input[type="number"] {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  max-width: 34rem;
}
.setting-row input[type="checkbox"] { width: 1.1rem; height: 1.1rem; }
.setting-hint { font-size: 0.78rem; }
.setting-meta { font-size: 0.75rem; color: var(--muted); }

@media (max-width: 640px) {
  .sidebar-user { flex-direction: column; align-items: stretch; gap: 0.4rem; }
  .settings-tab, .admin-tab { flex: 1 1 auto; justify-content: center; }
}

/* ==========================================================================
   Раздел «Администрирование»
   ========================================================================== */

/* Навигация раздела: карточки с иконкой, заголовком и пояснением */
.admin-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.admin-nav-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.admin-nav-item:hover {
  border-color: var(--accent);
  background: var(--bg-soft);
  text-decoration: none;
}
.admin-nav-item.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(61, 155, 253, 0.16), rgba(61, 155, 253, 0.05));
  box-shadow: inset 0 0 0 1px rgba(61, 155, 253, 0.35);
}
.admin-nav-icon {
  font-size: 1.1rem;
  line-height: 1.2;
  color: var(--accent);
  flex: 0 0 auto;
}
.admin-nav-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.admin-nav-body strong { font-size: 0.92rem; font-weight: 600; }
.admin-nav-desc { font-size: 0.75rem; color: var(--muted); }
.admin-nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 0.72rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--accent);
  white-space: nowrap;
}

/* Пункт «Администрирование» в главном меню — визуально отделён */
.sidebar nav a.nav-admin {
  margin-top: 0.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
  color: var(--text);
  font-weight: 500;
}

/* Кнопки в блоке пользователя */
.sidebar-user-actions { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.sidebar-user-actions form { margin: 0; }

@media (max-width: 640px) {
  .admin-nav { grid-template-columns: 1fr; }
  .admin-nav-desc { display: none; }
  .sidebar-user-actions { justify-content: space-between; }
}

/* ==========================================================================
   Карточка прибора и квартиры: показания, динамика, технические данные
   ========================================================================== */

/* Крупные показатели текущих значений */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.metric-card.is-primary { border-color: var(--accent); }
.metric-card.is-warn { border-color: #8a6a2a; }
.metric-card.is-bad { border-color: #6a3a3a; background: rgba(255, 107, 107, 0.07); }
.metric-label { font-size: 0.78rem; color: var(--muted); }
.metric-value { font-size: 1.5rem; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; }
.metric-hint { font-size: 0.72rem; color: var(--muted); }

/* Группы параметров */
.param-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  padding: 0.4rem 0.7rem;
  margin-bottom: 0.5rem;
}
.param-group > summary {
  cursor: pointer;
  font-weight: 500;
  padding: 0.25rem 0;
  list-style: none;
}
.param-group > summary::-webkit-details-marker { display: none; }
.param-group > summary::before { content: "▸ "; color: var(--muted); }
.param-group[open] > summary::before { content: "▾ "; }
.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.3rem 0.6rem;
  margin: 0.4rem 0 0.6rem;
}
.param-grid.compact { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.param-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  min-width: 0;
}
.param-item.is-primary { border-color: var(--accent); }
.param-name { font-size: 0.72rem; color: var(--muted); overflow-wrap: anywhere; }
.param-value { font-family: var(--mono); font-size: 0.9rem; }
.param-time { font-size: 0.68rem; color: var(--muted); }

/* Замечания по работе прибора */
.notice-list { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.6rem 0; }
.notice {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 0.85rem;
}
.notice span { color: var(--muted); }
.notice-bad { border-color: #6a3a3a; background: rgba(255, 107, 107, 0.09); }
.notice-warn { border-color: #8a6a2a; background: rgba(230, 184, 77, 0.09); }
.notice-info { border-color: #3d6a8a; background: rgba(61, 155, 253, 0.08); }
.notice-ok { border-color: #2f6a4f; background: rgba(62, 207, 142, 0.08); }

/* Импульсные входы */
.impulse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.impulse-card {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.6rem 0.7rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--bg);
}

/* Периоды и график динамики */
.period-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: end;
  margin-bottom: 0.5rem;
}
.period-row label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }
.period-row input,
.period-row select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
}
.period-btn.active { border-color: var(--accent); color: var(--text); background: var(--bg-soft); }
.chart-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 0.7rem 0.8rem;
  margin: 0.75rem 0;
}
.chart-head { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.chart-svg { width: 100%; height: 140px; display: block; }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-legend { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.72rem; color: var(--muted); flex-wrap: wrap; }

/* Технические данные: скрыты под кнопкой */
.tech-details {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  background: var(--bg-soft);
}
.tech-summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  padding: 0.2rem 0;
  color: var(--accent);
}
.tech-summary::-webkit-details-marker { display: none; }
.tech-summary::before { content: "▸ "; color: var(--muted); }
.tech-details[open] .tech-summary::before { content: "▾ "; }
.tech-details[open] .tech-summary { margin-bottom: 0.3rem; }

/* Плитки приборов на карточке квартиры */
.device-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0.7rem;
}
.device-tile {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.device-tile.is-offline { border-color: #6a3a3a; }
.device-tile-head { display: flex; gap: 0.5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.device-tile-place { display: inline-flex; gap: 0.4rem; align-items: center; color: var(--text); text-decoration: none; min-width: 0; }
.device-tile-place strong { font-size: 0.92rem; overflow-wrap: anywhere; }
.device-tile-meta { display: flex; gap: 0.6rem; flex-wrap: wrap; font-size: 0.75rem; }
.device-tile-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.4rem;
}
.tile-value {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.tile-value.is-primary { border-color: var(--accent); }
.tile-value.is-warn { border-color: #8a6a2a; }
.tile-value.is-bad { border-color: #6a3a3a; }
.tile-label { font-size: 0.7rem; color: var(--muted); }
.tile-value strong { font-family: var(--mono); font-size: 0.92rem; }
.tile-problems { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.tile-problems li { font-size: 0.75rem; padding: 0.15rem 0.4rem; border-radius: 5px; border: 1px solid var(--line); }
.tile-problem-bad { color: var(--bad); border-color: #6a3a3a; }
.tile-problem-warn { color: var(--warn); border-color: #8a6a2a; }
.tile-problem-info { color: var(--accent); border-color: #3d6a8a; }
.device-tile-empty { margin: 0; font-size: 0.8rem; }
.tile-params { border-top: 1px dashed var(--line); padding-top: 0.35rem; }
.tile-params > summary { cursor: pointer; font-size: 0.78rem; color: var(--muted); }
.device-tile-foot { margin-top: auto; }

@media (max-width: 640px) {
  .device-tile-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-svg { height: 110px; }
  .param-grid { grid-template-columns: 1fr; }
  .period-row { flex-direction: column; align-items: stretch; }
}

/* Дерево портов: панель управления и подсказки */
.tree-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  font-size: 0.85rem;
}
.tree-toolbar .actions-row { margin: 0; }
.hw-hidden-chip {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px dashed var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.hw-node > summary.hw-summary { scroll-margin-top: 3rem; }

/* Уровни дерева выделяем левой полосой, чтобы взгляд не терялся */
.hw-tree details[data-hw-level="1"] > summary { border-left: 2px solid #3d6a9a; }
.hw-tree details[data-hw-level="2"] > summary { border-left: 2px solid #2f6fed; }
.hw-tree details[data-hw-level="3"] > summary { border-left: 2px solid #2a3644; }
.hw-tree details[data-hw-level="1"] > summary,
.hw-tree details[data-hw-level="2"] > summary,
.hw-tree details[data-hw-level="3"] > summary { padding-left: 0.5rem; }

@media (max-width: 900px) {
  .tree-toolbar { flex-direction: column; align-items: stretch; }
}

/* ==========================================================================
   Работы по неисправностям
   ========================================================================== */

/* Метки статусов работы */
.work-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.work-status.status-new { color: #ffd78a; border-color: #8a6a2a; background: rgba(230, 184, 77, 0.14); }
.work-status.status-work { color: #8fbcff; border-color: #2f6fed; background: rgba(47, 111, 237, 0.16); }
.work-status.status-planned { color: #c9a6ff; border-color: #6a4a9a; background: rgba(150, 110, 230, 0.14); }
.work-status.status-monitor { color: #7ed6d0; border-color: #2d7a7a; background: rgba(45, 122, 122, 0.16); }
.work-status.status-done { color: #93e5bd; border-color: #2f6a4f; background: rgba(62, 207, 142, 0.14); }
.work-status.status-cancel { color: #9aa7b8; border-color: #46525f; background: rgba(120, 132, 148, 0.12); }

.work-priority {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}
.work-priority.prio-high { color: #ffc98a; border: 1px solid #a15a20; background: rgba(230, 134, 40, 0.18); }
.work-priority.prio-critical { color: #ffb0a8; border: 1px solid #a33; background: rgba(192, 57, 43, 0.22); }

/* Баннер «ведутся работы» на карточках приборов и портов */
.work-banner {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.7rem 0.85rem;
  margin: 0.6rem 0;
  border: 1px solid #2f6fed;
  border-left-width: 3px;
  border-radius: 10px;
  background: rgba(47, 111, 237, 0.1);
}
.work-banner-icon { font-size: 1.2rem; line-height: 1; }
.work-banner-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.work-banner-body p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; }
.btn-work-active { border-color: #2f6fed; color: #8fbcff; }
.work-take-form { display: inline-flex; }
.work-take-form button { border-color: #2f6fed; color: #8fbcff; }

/* Чипы «в работе» в дереве и портах */
.hw-work-chip {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid #2f6fed;
  color: #8fbcff;
  background: rgba(47, 111, 237, 0.14);
  text-decoration: none;
  white-space: nowrap;
}
.hw-work-chip:hover { background: rgba(47, 111, 237, 0.26); }
.house-card-tag.tag-work {
  color: #8fbcff;
  background: rgba(47, 111, 237, 0.16);
  border: 1px solid #2f6fed;
  text-decoration: none;
}
.port-chip.under-work { border-color: #2f6fed; }
.port-chip-work {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  color: #8fbcff;
  margin-bottom: 0.15rem;
}

/* Карточки работ в списке */
.works-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 0.8rem;
  align-items: start;
}
.works-side { position: sticky; top: 0.6rem; }
.work-stats { margin-bottom: 0.8rem; }
.works-group-switch { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.works-group-switch .btn.active { border-color: var(--accent); color: var(--text); background: var(--bg-soft); }
.works-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.7rem;
}
.works-filters label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.78rem; color: var(--muted); }
.works-filters input,
.works-filters select,
.work-form input,
.work-form select,
.work-form textarea,
.work-log-form select,
.work-log-form textarea,
.work-status-form select,
.work-status-form textarea,
.work-finish-form input,
.work-finish-form textarea,
.work-edit-form input,
.work-edit-form select,
.work-edit-form textarea,
.note-form input,
.note-form select,
.note-form textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  min-width: 0;
}
.work-list { display: flex; flex-direction: column; gap: 0.5rem; }
.work-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--bg-soft);
}
.work-card.work-work { border-left-color: #2f6fed; }
.work-card.work-new { border-left-color: #8a6a2a; }
.work-card.work-planned { border-left-color: #6a4a9a; }
.work-card.work-monitor { border-left-color: #2d7a7a; }
.work-card.work-done { border-left-color: #2f6a4f; }
.work-card.work-cancel { border-left-color: #46525f; }
.work-card header { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.work-title { color: var(--text); text-decoration: none; font-weight: 600; flex: 1 1 auto; min-width: 0; }
.work-title:hover { color: var(--accent); }
.work-age { font-size: 0.75rem; color: var(--muted); font-family: var(--mono); }
.work-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; font-size: 0.78rem; align-items: center; }
.work-target { font-family: var(--mono); }
.work-problem { margin: 0; font-size: 0.85rem; color: #d8c9a8; }
.work-result { margin: 0; font-size: 0.85rem; color: var(--muted); }
.work-card footer { display: flex; gap: 0.7rem; flex-wrap: wrap; font-size: 0.8rem; }

.work-form, .work-log-form, .work-status-form, .work-finish-form, .work-edit-form, .note-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.work-form label, .work-log-form label, .work-status-form label,
.work-finish-form label, .work-edit-form label, .note-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.work-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.work-log-row { display: grid; grid-template-columns: 14rem; gap: 0.5rem; }
.work-hint { font-size: 0.72rem; }

/* Карточка работы */
.work-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24rem;
  gap: 0.8rem;
  align-items: start;
}
.work-side { display: flex; flex-direction: column; gap: 0.8rem; }
.work-log-list { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.7rem; }
.work-log {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px;
  background: var(--bg-soft);
}
.work-log header { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; font-size: 0.78rem; }
.work-log header time { margin-left: auto; color: var(--muted); font-family: var(--mono); }
.work-log p { margin: 0.3rem 0 0; font-size: 0.88rem; }
.log-kind {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.work-log.log-problem { border-left-color: #c0392b; }
.work-log.log-plan { border-left-color: #6a4a9a; }
.work-log.log-result { border-left-color: #2f6a4f; }
.work-log.log-status { border-left-color: #2f6fed; }
.work-log.log-resource { border-left-color: #8a6a2a; }
.work-log.log-target, .work-log.log-comment { border-left-color: #46525f; }

/* Отчёт о работах */
.report-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; margin-bottom: 0.8rem; }
.report-house { margin-bottom: 0.8rem; }
.report-table td { vertical-align: top; }
.report-problem { font-size: 0.76rem; }
.report-row.status-done { background: rgba(62, 207, 142, 0.05); }

/* Заметки сотрудников */
.notes-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 23rem;
  gap: 0.8rem;
  align-items: start;
}
.notes-side { position: sticky; top: 0.6rem; }
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0.6rem;
}
.note-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.note-card.is-shared { border-left: 3px solid #2d7a7a; }
.note-card.is-private { border-left: 3px solid #46525f; }
.note-card.is-pinned { border-color: #8a6a2a; }
.note-card header { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.note-body { margin: 0; white-space: pre-wrap; font-size: 0.88rem; }
.note-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; font-size: 0.72rem; align-items: center; }
.note-visibility {
  font-size: 0.68rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.note-visibility.shared { color: #7ed6d0; border-color: #2d7a7a; }
.note-tags { color: var(--accent); }
.note-target { color: var(--muted); font-family: var(--mono); }
.note-card footer { display: flex; gap: 0.5rem; }
.note-target-fieldset {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.note-target-fieldset legend { font-size: 0.74rem; color: var(--muted); padding: 0 0.25rem; }
.notes-mini { display: flex; flex-direction: column; gap: 0.4rem; }
.note-mini { padding: 0.5rem 0.6rem; border: 1px dashed var(--line); border-radius: 8px; background: var(--bg); }
.note-mini header { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--muted); }
.note-mini p { margin: 0.25rem 0 0; font-size: 0.84rem; white-space: pre-wrap; }

/* Работы на карте */
.fault-works { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.3rem; }
.fault-work {
  display: flex;
  gap: 0.35rem;
  align-items: baseline;
  padding: 0.2rem 0.45rem;
  border: 1px solid #2f6fed;
  border-radius: 6px;
  background: rgba(47, 111, 237, 0.12);
  color: #8fbcff;
  text-decoration: none;
  font-size: 0.74rem;
}
.fault-work:hover { background: rgba(47, 111, 237, 0.22); }
.fault-work .fw-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fault-work .fw-assignee { margin-left: auto; color: var(--muted); }
.map-port-work {
  font-size: 0.68rem;
  color: #8fbcff;
  border: 1px solid #2f6fed;
  border-radius: 4px;
  padding: 0.02rem 0.3rem;
  text-decoration: none;
}
.map-port-row.is-work { border-left: 2px solid #2f6fed; }

/* Панель комментариев: подсказки */
.comments-panel .comments-toolbar { display: flex; gap: 0.3rem; }
.comments-panel .comments-filter.active { border-color: var(--accent); color: var(--text); }
.comments-note-count {
  font-size: 0.78rem;
  color: #ffd78a;
  margin-left: 0.4rem;
}
.comments-hint {
  font-size: 0.76rem;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding: 0.15rem 0 0.15rem 0.55rem;
  margin-bottom: 0.5rem;
}
.comments-hint strong { color: #ffd78a; }
.comments-form { flex-wrap: wrap; }
.comments-kind, .comments-pin {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.comments-form select,
.comments-form input[type="text"] {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
}
.comment-item.is-note {
  border-left: 3px solid #8a6a2a;
  background: rgba(230, 184, 77, 0.07);
}
.comment-item.is-pinned { border-color: #8a6a2a; }
.comment-kind {
  font-size: 0.68rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.comment-kind.note { color: #ffd78a; border-color: #8a6a2a; }
.comment-kind.pinned { color: #ffd78a; }

@media (max-width: 1200px) {
  .works-layout, .work-detail-layout, .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .works-side, .work-side, .notes-side { position: static; }
  .report-columns { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .work-form-row { grid-template-columns: 1fr; }
  .work-log-row { grid-template-columns: 1fr; }
  .notes-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Раздел «Работы»: подменю, задачи, собственные таблицы
   ========================================================================== */

.works-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.8rem;
}
.works-nav-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--text);
  min-width: 10rem;
}
.works-nav-item:hover { border-color: var(--accent); }
.works-nav-item.active { border-color: var(--accent); background: rgba(61, 155, 253, 0.12); }
.works-nav-item .wn-icon { font-size: 1.05rem; line-height: 1; }
.works-nav-item .wn-text { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.works-nav-item .wn-text strong { font-size: 0.85rem; }
.works-nav-item .wn-text span { font-size: 0.7rem; color: var(--muted); }

/* Задачи: раскладка и списки */
.tasks-layout {
  display: grid;
  grid-template-columns: 19rem minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
}
.tasks-side { position: sticky; top: 0.6rem; display: flex; flex-direction: column; gap: 0.6rem; }
.tasks-main { min-width: 0; }
.task-lists { display: flex; flex-direction: column; gap: 0.25rem; }
.task-list-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}
.task-list-item:hover { background: var(--bg); border-color: var(--line); }
.task-list-item.active { background: var(--bg); border-color: var(--accent); }
.task-list-item .tl-icon { font-size: 0.95rem; }
.task-list-item .tl-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-list-item .tl-counts { display: flex; gap: 0.3rem; font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.task-list-item .tl-counts .bad { color: var(--bad); }
.task-list-item .tl-shared { font-size: 0.75rem; }
.task-list-item.color-green { border-left: 3px solid #3ecf8e; }
.task-list-item.color-blue { border-left: 3px solid #3d9bfd; }
.task-list-item.color-amber { border-left: 3px solid #e0b84d; }
.task-list-item.color-red { border-left: 3px solid #e05d4d; }
.task-list-item.color-violet { border-left: 3px solid #a06ee0; }
.task-list-item.color-teal { border-left: 3px solid #2d9a9a; }

.task-list-form, .tasks-webhook {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.6rem 0.7rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.task-list-form label, .tasks-webhook label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.task-list-form input, .task-list-form select,
.tasks-webhook input, .tasks-webhook select,
.task-form input, .task-form select, .task-form textarea,
.subtask-add input, .table-form input, .table-form select,
.table-help input, .table-bottom textarea, .table-bottom input, .table-bottom select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  min-width: 0;
}
.task-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.task-list-edit { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tasks-subhead { font-size: 0.85rem; margin: 0; }

.task-form { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.8rem; }
.task-form-main { display: flex; gap: 0.4rem; }
.task-form-main input[type="text"] { flex: 1 1 auto; font-size: 0.95rem; padding: 0.55rem 0.7rem; }
.task-form-advanced { border: 1px dashed var(--line); border-radius: 8px; padding: 0.4rem 0.6rem; }
.task-form-advanced > summary { cursor: pointer; font-size: 0.8rem; color: var(--muted); }
.task-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.task-form-grid label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.78rem; color: var(--muted); }

.task-list { display: flex; flex-direction: column; gap: 0.45rem; }
.task-item {
  display: flex;
  gap: 0.55rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-left-color: #46525f;
  border-radius: 10px;
  background: var(--bg-soft);
  align-items: flex-start;
}
.task-item.is-overdue { border-left-color: #c0392b; background: rgba(192, 57, 43, 0.06); }
.task-item.is-shared { border-left-color: #2d7a7a; }
.task-item.is-done { opacity: 0.62; }
.task-item.is-done .task-title { text-decoration: line-through; }
.task-check { flex-shrink: 0; }
.task-check-btn {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ok);
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}
.task-check-btn:hover { border-color: var(--ok); }
.task-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.task-head { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.task-title { font-weight: 600; font-size: 0.92rem; }
.task-shared { font-size: 0.7rem; color: #7ed6d0; border: 1px solid #2d7a7a; border-radius: 4px; padding: 0.02rem 0.3rem; }
.task-list-badge { font-size: 0.72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0.02rem 0.32rem; }
.task-text { margin: 0; font-size: 0.85rem; color: #d8c9a8; white-space: pre-wrap; }
.task-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; font-size: 0.75rem; color: var(--muted); align-items: center; }
.task-due.bad { color: var(--bad); font-weight: 600; }
.task-link { color: var(--accent); text-decoration: none; font-family: var(--mono); }
.task-link:hover { text-decoration: underline; }
.task-subtasks-count { color: var(--muted); }
.task-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }
.task-actions .btn { padding: 0.15rem 0.4rem; font-size: 0.8rem; }

.subtask-list { list-style: none; margin: 0.2rem 0 0; padding: 0 0 0 0.2rem; display: flex; flex-direction: column; gap: 0.2rem; }
.subtask-list li { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; }
.subtask-list li.is-done span { text-decoration: line-through; opacity: 0.7; }
.subtask-check {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ok);
  border-radius: 5px;
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
}
.subtask-del button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.subtask-del button:hover { color: var(--bad); }
.subtask-add { display: flex; gap: 0.3rem; margin-top: 0.3rem; }
.subtask-add input { flex: 1 1 auto; font-size: 0.8rem; padding: 0.25rem 0.45rem; }

/* Собственные таблицы */
.tables-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 0.8rem;
  align-items: start;
}
.tables-side { display: flex; flex-direction: column; gap: 0.8rem; position: sticky; top: 0.6rem; }
.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0.6rem;
}
.table-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.table-card.is-shared { border-left: 3px solid #2d7a7a; }
.table-card header { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.table-card-title { color: var(--text); text-decoration: none; font-weight: 600; flex: 1 1 auto; min-width: 0; }
.table-card-title:hover { color: var(--accent); }
.table-card-meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; font-size: 0.78rem; color: var(--muted); }
.table-card-hook { font-size: 0.74rem; color: #8fbcff; display: flex; flex-direction: column; gap: 0.1rem; }
.table-card footer { display: flex; gap: 0.7rem; font-size: 0.8rem; }
.table-form { display: flex; flex-direction: column; gap: 0.5rem; }
.table-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }
.table-help { border-top: 1px dashed var(--line); padding-top: 0.6rem; }
.table-help h3 { font-size: 0.88rem; margin: 0 0 0.4rem; }
.table-help-list { margin: 0 0 0.5rem; padding-left: 1.1rem; font-size: 0.8rem; color: var(--muted); }
.table-help-list li { margin-bottom: 0.2rem; }

.table-sent-status { font-size: 0.8rem; padding: 0.35rem 0.6rem; border-radius: 8px; margin-bottom: 0.6rem; }
.table-sent-status.ok { color: #93e5bd; border: 1px solid #2f6a4f; background: rgba(62, 207, 142, 0.1); }
.table-sent-status.err { color: #f0a0a0; border: 1px solid #6a3a3a; background: rgba(192, 57, 43, 0.1); }

.table-editor-scroll { overflow-x: auto; margin-bottom: 0.6rem; }
.table-editor { border-collapse: separate; border-spacing: 0 0.2rem; width: 100%; }
.table-editor th {
  text-align: left;
  font-size: 0.76rem;
  color: var(--muted);
  padding: 0.25rem 0.35rem;
  white-space: nowrap;
}
.table-editor th .te-type { display: block; font-size: 0.62rem; opacity: 0.6; font-family: var(--mono); }
.table-editor td { padding: 0; }
.table-editor input {
  width: 100%;
  min-width: 8rem;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
}
.table-editor input:focus { border-color: var(--accent); outline: none; }
.table-editor .te-num { width: 2.2rem; text-align: right; color: var(--muted); font-family: var(--mono); font-size: 0.75rem; padding-right: 0.4rem; }
.table-editor .te-del { width: 2rem; }
.te-del-btn {
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  border-radius: 5px;
  width: 1.6rem;
  height: 1.6rem;
}
.te-del-btn:hover { color: var(--bad); border-color: #6a3a3a; }

.table-bottom {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 0.8rem;
  align-items: start;
}
.table-bottom textarea {
  font-family: var(--mono);
  font-size: 0.8rem;
  width: 100%;
  resize: vertical;
}
.code-block {
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.45;
  background: #0c1116;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  overflow-x: auto;
  white-space: pre;
  max-height: 26rem;
}
.steps { margin: 0 0 0.6rem; padding-left: 1.2rem; font-size: 0.85rem; }
.steps li { margin-bottom: 0.3rem; }

@media (max-width: 1200px) {
  .tasks-layout, .tables-layout { grid-template-columns: minmax(0, 1fr); }
  .tasks-side, .tables-side { position: static; }
}
@media (max-width: 700px) {
  .task-form-row { grid-template-columns: 1fr; }
  .works-nav-item { min-width: 0; flex: 1 1 45%; }
  .tasks-grid, .tables-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Подбор объектов из базы, модальные окна, панели создания
   ========================================================================== */

.picker { position: relative; }
.picker input[data-picker-input] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}
.picker input[data-picker-input]:focus { border-color: var(--accent); outline: none; }
.picker-list {
  position: absolute;
  z-index: 60;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  max-height: 17rem;
  overflow-y: auto;
  background: #131a22;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  padding: 0.2rem;
}
.picker-item {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}
.picker-item:hover, .picker-item.is-active { background: rgba(61, 155, 253, 0.16); }
.picker-item .pi-kind {
  flex-shrink: 0;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.02rem 0.3rem;
}
.picker-item .pi-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item .pi-title { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item .pi-meta { margin-left: auto; font-family: var(--mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.picker-empty { padding: 0.5rem 0.6rem; color: var(--muted); font-size: 0.82rem; }
.picker-info {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-left: 2px solid var(--accent);
  padding-left: 0.55rem;
}
.picker-info .pi-models { display: block; margin-top: 0.15rem; font-size: 0.74rem; }
.picker-field { display: flex; flex-direction: column; gap: 0.2rem; }
.picker-field > label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }

/* Тип объекта в форме работы */
.work-type-row { display: flex; flex-direction: column; gap: 0.35rem; }
.work-type-switch { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.work-type-btn.active { border-color: var(--accent); color: var(--text); background: rgba(61, 155, 253, 0.14); }

.btn.primary-action {
  border-color: var(--accent);
  color: #cfe6ff;
  background: rgba(61, 155, 253, 0.14);
}
.btn.primary-action:hover { background: rgba(61, 155, 253, 0.24); }

/* Раскрывающиеся панели создания */
.create-panel { border-color: var(--accent); }
.note-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.5rem;
}
.note-form-grid label,
.note-form-wide > label,
.note-form-wide > .map-check {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.note-form-grid input, .note-form-grid select,
.note-form-wide input, .note-form-wide select, .note-form-wide textarea,
.tasks-webhook-wide input,
.table-create-grid input, .table-create-grid select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  min-width: 0;
}
.note-pin-label { justify-content: flex-end; }
.note-target-grid {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: start;
}
.note-target-grid > label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }
.table-create-grid {
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) minmax(18rem, 1fr);
  gap: 0.8rem;
  align-items: start;
}

/* Списки задач строкой сверху */
.task-lists-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed var(--line);
}
.task-lists-bar .task-list-item { border: 1px solid var(--line); background: var(--bg-soft); }
.tasks-layout-wide, .tables-layout-wide { grid-template-columns: minmax(0, 1fr); }

/* Модальные окна */
body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(6, 10, 14, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: min(46rem, 100%);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 4rem);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-close {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  border-radius: 8px;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); border-color: var(--accent); }
.modal-body { padding: 0.9rem 1rem; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--bg-soft);
}
.works-main-note { margin-top: 0; }

@media (max-width: 900px) {
  .note-target-grid, .table-create-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-overlay { padding: 0.8rem 0.5rem; }
  .modal { max-height: calc(100vh - 1.6rem); }
  .modal-body { padding: 0.8rem; }
}
@media (max-width: 700px) {
  .work-type-switch .btn { flex: 1 1 45%; }
  .picker-list { max-height: 13rem; }
  .note-form-grid { grid-template-columns: 1fr; }
  .task-lists-bar { flex-direction: column; }
}

/* ==========================================================================
   Задачи: рельса умных списков, быстрый ввод, плотные строки, drawer, bulk
   ========================================================================== */

.tasks-shell {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
}
.tasks-rail {
  position: sticky;
  top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.7rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}
.rail-group { display: flex; flex-direction: column; gap: 0.12rem; }
.rail-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0 0.35rem 0.2rem;
}
.rail-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.45rem;
  border-radius: 7px;
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}
.rail-item:hover { background: var(--bg); border-color: var(--line); }
.rail-item.active { background: rgba(61, 155, 253, 0.14); border-color: var(--accent); }
.rail-item .rail-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item .rail-count { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.rail-item .rail-count.bad { color: var(--bad); font-weight: 700; }
.rail-item .rail-shared { font-size: 0.72rem; }
.rail-item .rail-icon { font-size: 0.9rem; }
.rail-item.color-green { border-left: 3px solid #3ecf8e; }
.rail-item.color-blue { border-left: 3px solid #3d9bfd; }
.rail-item.color-amber { border-left: 3px solid #e0b84d; }
.rail-item.color-red { border-left: 3px solid #e05d4d; }
.rail-item.color-violet { border-left: 3px solid #a06ee0; }
.rail-item.color-teal { border-left: 3px solid #2d9a9a; }
.rail-empty { font-size: 0.78rem; padding: 0 0.35rem; }
.tasks-body { min-width: 0; display: flex; flex-direction: column; gap: 0.7rem; }

/* Быстрый ввод одной строкой */
.quick-add {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: rgba(61, 155, 253, 0.06);
}
.quick-add-row { display: flex; gap: 0.4rem; align-items: center; }
.quick-add-row input[type="text"] {
  flex: 1 1 auto;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.55rem 0.7rem;
}
.quick-add-row input[type="text"]:focus { border-color: var(--accent); outline: none; }
.quick-shared {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.quick-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  font-size: 0.8rem;
}
.quick-preview .qp-title { font-weight: 600; }
.quick-preview .qp-chip {
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.74rem;
}
.quick-hint { font-size: 0.72rem; margin: 0; }
.quick-hint code, .keys-grid kbd {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.02rem 0.25rem;
}

/* Панель фильтров и группировки */
.tasks-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.tasks-toolbar-left { display: flex; gap: 0.4rem; align-items: baseline; }
.tasks-toolbar-filters { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.tasks-toolbar-filters input[type="search"],
.tasks-toolbar-filters select {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
}
.tasks-toolbar-filters input[type="search"] { min-width: 12rem; }
.tasks-toolbar-right { display: flex; gap: 0.25rem; }

/* Плотные строки задач */
.task-groups { display: flex; flex-direction: column; gap: 0.7rem; }
.task-group-head {
  position: sticky;
  top: 0;
  z-index: 5;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--bg);
  padding: 0.2rem 0.4rem;
  margin: 0 0 0.25rem;
  border-radius: 6px;
}
.task-rows {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
}
.task-row {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid transparent;
  background: transparent;
  outline: none;
}
.task-row + .task-row { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.task-row:hover { background: rgba(255, 255, 255, 0.03); }
.task-row.is-focused { background: rgba(61, 155, 253, 0.12); box-shadow: inset 0 0 0 1px var(--accent); }
.task-row.is-picked { background: rgba(61, 155, 253, 0.16); }
.task-row.is-done { opacity: 0.55; }
.task-row.is-done .task-title { text-decoration: line-through; }
.task-row.is-cancelled { opacity: 0.45; }
.task-row.is-cancelled .task-title { text-decoration: line-through; }
.task-row.is-overdue { border-left-color: #c0392b; }
.task-row.prio-critical { border-left-color: #c0392b; }
.task-row.prio-high { border-left-color: #e68628; }
.task-row.prio-normal { border-left-color: #46525f; }
.task-row.prio-low { border-left-color: #3a4654; }

.task-pick { width: 0.95rem; height: 0.95rem; accent-color: var(--accent); cursor: pointer; opacity: 0.35; }
.task-row:hover .task-pick, .task-pick:checked { opacity: 1; }
.task-done-btn {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ok);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  flex-shrink: 0;
}
.task-done-btn:hover { border-color: var(--ok); }
.task-prio-dot { width: 7px; height: 7px; border-radius: 50%; background: #46525f; flex-shrink: 0; }
.prio-high .task-prio-dot { background: #e68628; }
.prio-critical .task-prio-dot { background: #e05d4d; box-shadow: 0 0 0 2px rgba(224, 93, 77, 0.25); }
.prio-low .task-prio-dot { background: #3a4654; }
.task-title {
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.05rem 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-title:hover { color: var(--accent); }
.task-title-edit {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  min-width: 12rem;
  width: 100%;
}
.task-row-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.74rem;
  color: var(--muted);
  justify-content: flex-end;
}
.task-due { font-family: var(--mono); white-space: nowrap; }
.task-due.bad { color: var(--bad); font-weight: 600; }
.task-list-chip { border: 1px solid var(--line); border-radius: 4px; padding: 0.02rem 0.3rem; white-space: nowrap; }
.task-assignee { white-space: nowrap; }
.task-sub-count { font-family: var(--mono); }
.task-work-link { color: var(--accent); text-decoration: none; font-family: var(--mono); }
.task-row-actions { display: flex; gap: 0.15rem; opacity: 0; transition: opacity 0.12s; }
.task-row:hover .task-row-actions, .task-row.is-focused .task-row-actions { opacity: 1; }
.task-act {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  border-radius: 5px;
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  cursor: pointer;
  white-space: nowrap;
}
.task-act:hover { color: var(--text); border-color: var(--accent); }
.tasks-empty { padding: 0.8rem; }

/* Массовые действия */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(61, 155, 253, 0.12);
}
.bulk-count { font-size: 0.85rem; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.bulk-select {
  font: inherit;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.25rem 0.4rem;
}

/* Карточка задачи справа */
.task-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(32rem, 92vw);
  z-index: 180;
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}
.task-drawer[hidden] { display: none; }
.task-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
}
.task-drawer-body { padding: 0.8rem 0.9rem 2rem; overflow-y: auto; }
.task-card { display: flex; flex-direction: column; gap: 0.6rem; }
.task-card h3 { margin: 0; font-size: 1.02rem; }
.task-card-flags { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; font-size: 0.78rem; }
.task-card-props { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.3rem 0.8rem; margin: 0; }
.task-card-props > div { display: flex; gap: 0.4rem; align-items: baseline; }
.task-card-props dt { color: var(--muted); font-size: 0.76rem; min-width: 4.6rem; }
.task-card-props dd { margin: 0; font-size: 0.84rem; }
.task-card-props dd.bad { color: var(--bad); }
.task-card-section { border-top: 1px dashed var(--line); padding-top: 0.5rem; }
.task-card-section h4 { margin: 0 0 0.4rem; font-size: 0.86rem; }
.task-card-body { margin: 0; font-size: 0.86rem; white-space: pre-wrap; color: #d8c9a8; }
.task-card-edit { display: flex; flex-direction: column; gap: 0.5rem; }
.task-card-edit label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.78rem; color: var(--muted); }
.task-card-edit input, .task-card-edit select, .task-card-edit textarea,
.task-comment-form textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  min-width: 0;
}
.task-comment-form { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.5rem; }
.task-comments { display: flex; flex-direction: column; gap: 0.35rem; }

/* Уведомление с отменой */
.undo-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 1.4rem;
  z-index: 220;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: #131a22;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  font-size: 0.85rem;
}
.undo-toast[hidden] { display: none; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.35rem 0.8rem; font-size: 0.85rem; }

@media (max-width: 1100px) {
  .tasks-shell { grid-template-columns: minmax(0, 1fr); }
  .tasks-rail { position: static; flex-direction: row; flex-wrap: wrap; gap: 0.6rem 1rem; }
  .rail-group { flex: 1 1 12rem; }
}
@media (max-width: 700px) {
  .task-row { grid-template-columns: auto auto auto minmax(0, 1fr); }
  .task-row-meta { grid-column: 4 / -1; justify-content: flex-start; }
  .task-row-actions { grid-column: 4 / -1; opacity: 1; }
  .tasks-toolbar-filters input[type="search"] { min-width: 100%; }
  .task-drawer { width: 100%; }
}

/* ==========================================================================
   Таблица в стиле Excel: лента, строка формул, сетка, вкладки, статус-бар
   ========================================================================== */

.xl {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  overflow: hidden;
}
.xl-titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.xl-back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
}
.xl-back:hover { color: var(--text); background: var(--bg); }
.xl-name {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  min-width: 10rem;
}
.xl-name:hover { border-color: var(--line); }
.xl-name:focus { border-color: var(--accent); outline: none; background: var(--bg); }
.xl-saved { font-size: 0.76rem; }
.xl-saved.ok { color: var(--ok); }
.xl-saved.err { color: var(--bad); }
.xl-titlebar-right { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-left: auto; align-items: center; }
.xl-inline-form { display: inline; }

.xl-btn {
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
}
.xl-btn:hover { border-color: var(--accent); }
.xl-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.xl-btn-primary { background: #1d5c9e; border-color: #2b7bd0; color: #eef5ff; font-weight: 600; }
.xl-btn-primary:hover { background: #2470bd; }
.xl-btn-danger:hover { border-color: var(--bad); color: #f3b0a6; }

.xl-menu { position: relative; }
.xl-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 40;
  min-width: 11rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #131a22;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
.xl-menu-list a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
}
.xl-menu-list a:hover { background: var(--bg); color: var(--accent); }

.xl-alert {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.2rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--line);
  background: rgba(62, 207, 142, 0.07);
  color: #a9e6c9;
}
.xl-alert-err { background: rgba(224, 93, 77, 0.1); color: #f0b3aa; }
.xl-hint { width: 100%; color: var(--muted); }

/* лента инструментов */
.xl-ribbon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: #141b23;
}
.xl-group { display: flex; gap: 0.2rem; align-items: center; padding-right: 0.4rem; border-right: 1px solid var(--line); }
.xl-group:last-child { border-right: none; }
.xl-group-right { margin-left: auto; padding-right: 0; }

/* строка формул */
.xl-formulabar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.xl-cellref {
  font-family: var(--mono);
  font-size: 0.78rem;
  min-width: 3.4rem;
  text-align: center;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--text);
}
.xl-fx { color: var(--muted); font-style: italic; font-size: 0.8rem; }
.xl-formula {
  flex: 1 1 auto;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.3rem 0.5rem;
  min-width: 5rem;
}
.xl-formula:focus { border-color: var(--accent); outline: none; }

.xl-paste {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: rgba(61, 155, 253, 0.07);
}
.xl-paste textarea {
  font-family: var(--mono);
  font-size: 0.8rem;
  width: 100%;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  resize: vertical;
}
.xl-paste-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.xl-check { font-size: 0.78rem; color: var(--muted); }

/* сетка */
.xl-sheetwrap {
  overflow: auto;
  max-height: 62vh;
  background: var(--bg);
}
.xl-sheet {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 0.84rem;
  table-layout: fixed;
}
.xl-sheet th,
.xl-sheet td {
  border-right: 1px solid #2a3540;
  border-bottom: 1px solid #2a3540;
  padding: 0;
  height: 1.85rem;
  vertical-align: middle;
}
.xl-corner,
.xl-rowhead {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 2.8rem;
  min-width: 2.8rem;
  background: #1b242e;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-align: center;
}
.xl-rowhead.is-active { background: #26333f; color: var(--text); }
.xl-colhead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #1b242e;
  min-width: 12rem;
  padding: 0.15rem 0.4rem;
  text-align: left;
  cursor: pointer;
}
.xl-colhead.is-active { background: #26333f; }
.xl-colletter {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  margin-right: 0.35rem;
}
.xl-coltitle { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.xl-colhead input {
  display: none;
  width: 100%;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.25rem;
}
.xl-colhead input.is-editing { display: block; }
.xl-colhead input.is-editing + .xl-coltitle,
.xl-colhead input.is-editing ~ .xl-coltitle { display: none; }
.xl-addcol,
.xl-addcell {
  width: 2.4rem;
  min-width: 2.4rem;
  background: #1b242e;
  text-align: center;
  border-right: none;
}
.xl-plus {
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
}
.xl-plus:hover { color: var(--accent); }

.xl-cell {
  padding: 0.28rem 0.45rem;
  color: var(--text);
  cursor: cell;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 12rem;
  max-width: 24rem;
}
.xl-cell.is-center { text-align: center; }
.xl-cell.is-bold { font-weight: 700; }
.xl-cell.is-selected {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: rgba(61, 155, 253, 0.1);
}
.xl-cellinput {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: none;
  outline: none;
}

/* вкладки и статус-бар */
.xl-tabsbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-top: 1px solid var(--line);
  background: #141b23;
  font-size: 0.78rem;
}
.xl-tab {
  padding: 0.2rem 0.6rem;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
}
.xl-tab-active { background: var(--bg-soft); color: var(--text); font-weight: 600; }
.xl-statusline { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-left: auto; color: var(--muted); }

/* сворачиваемые панели настроек */
.xl-drawer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}
.xl-drawer[hidden] { display: none; }
.xl-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.xl-drawer-head h3 { margin: 0; font-size: 0.9rem; }
.xl-drawer-body { padding: 0.6rem; }
.xl-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.6rem;
}
.xl-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
}
.xl-card h4 { margin: 0; font-size: 0.86rem; }
.xl-small { font-size: 0.76rem; }
.xl-token { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.xl-token input {
  flex: 1 1 11rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
}
.xl-form { display: flex; flex-direction: column; gap: 0.4rem; }
.xl-form-wide { max-width: 30rem; }
.xl-field { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.78rem; color: var(--muted); }
.xl-field input, .xl-field select {
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.32rem 0.45rem;
}
.xl-details { border: 1px solid var(--line); border-radius: 7px; padding: 0.35rem 0.45rem; background: var(--bg-soft); }
.xl-details summary { cursor: pointer; font-size: 0.8rem; color: var(--accent); }
.xl-details .code-block { margin: 0.4rem 0; }

/* листы внизу */
.xl-tabs { display: flex; flex-wrap: wrap; gap: 0.2rem; align-items: center; }
.xl-tab {
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.xl-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.xl-tab-active { background: var(--bg-soft); color: var(--text); font-weight: 600; border-color: var(--line); border-bottom-color: transparent; }
.xl-btn-mini { padding: 0.15rem 0.4rem; font-size: 0.72rem; }
.xl-btn-accent { border-color: #2b7bd0; color: #cfe4ff; }

/* строка формул: сведения о выделении */
.xl-selinfo { font-size: 0.74rem; color: var(--muted); white-space: nowrap; }

/* импорт из базы CRM */
.xldb-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.xldb-preview { margin-top: 0.5rem; }
.xldb-scroll {
  max-height: 22rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.xldb-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 0.78rem; }
.xldb-table th,
.xldb-table td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0.25rem 0.45rem; text-align: left; }
.xldb-table thead th {
  position: sticky;
  top: 0;
  background: #1b242e;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  z-index: 2;
}
.xldb-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }

@media (max-width: 900px) {
  .xl-sheetwrap { max-height: 55vh; }
  .xl-ribbon { gap: 0.25rem; }
  .xl-group { padding-right: 0.25rem; }
  .xl-group-right { margin-left: 0; }
  .xl-statusline { margin-left: 0; width: 100%; }
}

/* ==========================================================================
   Настройки: состояние системы, карточки параметров, превью бренда
   ========================================================================== */

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.6rem;
}
.health-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.health-card strong { font-size: 1rem; }
.health-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.small { font-size: 0.75rem; }
.muted-count { font-size: 0.76rem; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 0.6rem;
}
.setting-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.setting-card > label:first-child { font-size: 0.84rem; font-weight: 600; }
.setting-card input[type="text"],
.setting-card input[type="number"],
.setting-card select {
  font: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.35rem 0.5rem;
  width: 100%;
}
.setting-card input:focus, .setting-card select:focus { border-color: var(--accent); outline: none; }
.setting-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--muted); }
.setting-check input { width: auto; }
.setting-hint { font-size: 0.72rem; line-height: 1.35; }

.brand-preview { margin-bottom: 0.7rem; }
.brand-preview-box {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.9rem;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: var(--bg-soft);
}
.brand-preview-box .brand-mark { font-size: 1.05rem; font-weight: 700; }
.brand-preview-box .brand-sub { font-size: 0.78rem; color: var(--muted); }

.settings-savebar {
  position: sticky;
  bottom: 0.5rem;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  margin: 0.7rem 0;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(61, 155, 253, 0.1);
}
.dirty-hint { color: #f0c674; font-weight: 600; }

@media (max-width: 700px) {
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .health-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-savebar { position: static; }
}

/* ==========================================================================
   Неисправности: бейджи критичности, таблица, действия
   ========================================================================== */

.sev-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.sev-badge.sev-full { background: rgba(224, 93, 77, 0.18); border-color: #c0392b; color: #f3b0a6; }
.sev-badge.sev-major { background: rgba(230, 134, 40, 0.16); border-color: #e68628; color: #f2c08a; }
.sev-badge.sev-partial { background: rgba(224, 184, 77, 0.14); border-color: #e0b84d; color: #ead7a0; }
.sev-badge.sev-single { background: rgba(120, 140, 160, 0.14); border-color: var(--line); color: var(--muted); }

.fault-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0 0.7rem;
}

.faults-table td, .faults-table th { vertical-align: middle; }
.faults-table .fault-row.sev-full { border-left: 3px solid #c0392b; }
.faults-table .fault-row.sev-major { border-left: 3px solid #e68628; }
.faults-table .fault-row.sev-partial { border-left: 3px solid #e0b84d; }
.faults-table .fault-row.sev-single { border-left: 3px solid #46525f; }

.port-type-chip {
  display: inline-block;
  margin: 0.05rem 0.2rem 0.05rem 0;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.fault-links { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.work-chip {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.work-chip.status-work { border-color: #2b7bd0; color: #cfe4ff; }
.work-chip.status-new { border-color: #e0b84d; color: #ead7a0; }
.work-chip.status-planned { border-color: #a06ee0; color: #ddc8f5; }
.work-chip.status-monitor { border-color: #2d9a9a; color: #bfe8e8; }
.task-chip {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
}
.task-chip:hover, .work-chip:hover { border-color: var(--accent); color: var(--accent); }

.fault-actions { display: flex; flex-wrap: wrap; gap: 0.2rem; align-items: center; }
.fault-form { display: inline; }

.fault-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}
.fault-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.76rem;
  color: var(--muted);
}
.fault-filters select, .fault-filters input[type="search"], .fault-filters input[type="number"] {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.3rem 0.45rem;
}
.fault-filters input[type="search"] { min-width: 12rem; }
.fault-filters .map-check { flex-direction: row; align-items: center; gap: 0.3rem; padding-bottom: 0.35rem; }

@media (max-width: 900px) {
  .fault-filters { flex-direction: column; align-items: stretch; }
  .fault-filters input[type="search"] { min-width: 0; }
  .faults-table { font-size: 0.8rem; }
}
}



/* Постраничная навигация списков */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
}
.pager .btn.active-btn { border-color: var(--accent); color: var(--accent); font-weight: 600; }


/* ==========================================================================
   Виджеты дашборда
   ========================================================================== */

.widgets-block { margin-bottom: 1rem; }
.widget-section { margin-bottom: 0.7rem; }
.widget-section-title {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.3rem 0.2rem;
}
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.55rem;
}
.widget-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.widget-card.widget-ok { border-left-color: #3ecf8e; }
.widget-card.widget-warn { border-left-color: #e0b84d; }
.widget-card.widget-bad { border-left-color: #c0392b; }
.widget-card.widget-muted { border-left-color: #46525f; }
.widget-head { display: flex; align-items: center; gap: 0.35rem; }
.widget-icon { font-size: 0.95rem; }
.widget-title { flex: 1 1 auto; font-size: 0.82rem; font-weight: 600; }
.widget-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.widget-link:hover { color: var(--accent); }
.widget-value { display: flex; align-items: baseline; gap: 0.4rem; }
.widget-value b { font-size: 1.5rem; line-height: 1.1; }
.widget-card.widget-bad .widget-value b { color: #f0a0a0; }
.widget-card.widget-ok .widget-value b { color: #93e5bd; }
.widget-caption { font-size: 0.74rem; color: var(--muted); }
.widget-details { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.widget-details li { display: flex; justify-content: space-between; gap: 0.4rem; font-size: 0.74rem; color: var(--muted); }
.widget-details li.bad { color: #e8a79c; }
.widget-details li b { font-family: var(--mono); }
.widget-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.widget-items li { display: flex; flex-direction: column; font-size: 0.75rem; }
.widget-items a { color: var(--text); text-decoration: none; }
.widget-items a:hover { color: var(--accent); }
.widget-error { margin: 0; font-size: 0.7rem; color: #e0b84d; }

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


/* Настройки виджетов */
.widget-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 0.6rem;
}
.widget-setting-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-left: 3px solid #3ecf8e;
  border-radius: 10px;
  background: var(--bg-soft);
}
.widget-setting-card.widget-off { border-left-color: #46525f; opacity: 0.75; }
.widget-setting-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; justify-content: space-between; }
.widget-setting-head strong { font-size: 0.85rem; }
.widget-setting-fields { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.setting-mini { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.75rem; color: var(--muted); }
.setting-mini input { font: inherit; font-size: 0.82rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0.25rem 0.4rem; width: 8rem; }
.setting-mini input:focus { border-color: var(--accent); outline: none; }


/* Верхняя панель сохранения настроек */
.settings-topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(61, 155, 253, 0.12);
}


/* Обновление виджетов */
.widget-refresh {
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 0.3rem;
  cursor: pointer;
  margin-left: auto;
}
.widget-refresh:hover { color: var(--accent); border-color: var(--accent); }
.widget-loading { position: relative; }
.widget-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: widget-pulse 1.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes widget-pulse {
  0% { opacity: 0.15; }
  50% { opacity: 0.5; }
  100% { opacity: 0.15; }
}
.widget-loading .widget-value b { opacity: 0.6; }

/* ==========================================================================
   Раздел «Отдых»: мини-игры, личные результаты и рейтинг сотрудников
   ========================================================================== */

.rest-head-actions { align-items: center; }
.rest-head-actions .chip em { font-style: normal; color: var(--text); font-weight: 600; }

.rest-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.rest-panel-head h2 { margin: 0; }

/* --- карточки игр -------------------------------------------------------- */
.rest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.75rem;
}
.rest-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.rest-card:hover { border-color: var(--accent); }
.rest-card-top { display: flex; align-items: flex-start; gap: 0.65rem; }
.rest-icon {
  font-size: 1.5rem;
  line-height: 1;
  width: 2.4rem;
  height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.rest-card-title { flex: 1 1 auto; min-width: 0; }
.rest-card-title h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.rest-card-title h3 a { color: var(--text); text-decoration: none; }
.rest-card-title h3 a:hover { color: var(--accent); }
.rest-genre { font-size: 0.78rem; color: var(--muted); }
.rest-place {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.rest-place-gold { color: var(--warn); border-color: rgba(230, 184, 77, 0.5); background: rgba(230, 184, 77, 0.1); }
.rest-tagline { margin: 0; color: var(--muted); font-size: 0.88rem; }
.rest-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.82rem; color: var(--muted); }
.rest-meta b { color: var(--text); }
.rest-leader {
  font-size: 0.84rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px dashed var(--line);
}
.rest-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: auto; }
.rest-controls { font-size: 0.78rem; }

/* --- рейтинг ------------------------------------------------------------- */
.rest-columns {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1rem;
  align-items: start;
}
.rest-side-col { display: flex; flex-direction: column; }
.rest-filters { margin-bottom: 0.6rem; }
.rest-table .rest-rank { width: 2.6rem; }
.rest-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--muted);
}
.rest-medal-1 { color: #1b1b1b; background: #e6b84d; border-color: #e6b84d; }
.rest-medal-2 { color: #1b1b1b; background: #c7d0da; border-color: #c7d0da; }
.rest-medal-3 { color: #1b1b1b; background: #d09a63; border-color: #d09a63; }
.rest-row-me { background: rgba(61, 155, 253, 0.1); }
.rest-you {
  margin-left: 0.35rem;
  font-size: 0.72rem;
  color: var(--accent);
  border: 1px solid rgba(61, 155, 253, 0.5);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}
.rest-me-line { margin: 0.6rem 0 0; font-size: 0.9rem; }
.rest-purge { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.9rem; }

.rest-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.rest-feed li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.rest-feed li:last-child { border-bottom: 0; padding-bottom: 0; }
.rest-feed a, .rest-feed > li > .rest-feed-body { display: flex; align-items: center; gap: 0.5rem; flex: 1 1 auto; min-width: 0; color: inherit; text-decoration: none; }
.rest-feed a:hover b { color: var(--accent); }
.rest-feed-icon { font-size: 1.1rem; }
.rest-feed-body { display: flex; flex-direction: column; min-width: 0; }
.rest-feed-body b { font-weight: 600; }
.rest-feed-body .muted { font-size: 0.78rem; }
.rest-feed-score { font-variant-numeric: tabular-nums; font-weight: 600; }
.rest-feed-time { font-size: 0.75rem; white-space: nowrap; }

.rest-rules { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.86rem; }
.rest-rules li { margin-bottom: 0.3rem; }
.rest-rules code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.05rem 0.3rem;
  color: var(--text);
}
.rest-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.rest-sub { margin: 0 0 0.45rem; font-size: 0.92rem; font-weight: 600; }

/* --- страница игры ------------------------------------------------------- */
.rest-game-head h1 { display: flex; align-items: center; gap: 0.5rem; }
.rest-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 1rem;
  align-items: start;
}
.rest-main { min-width: 0; }
.rest-side { display: flex; flex-direction: column; }

.rest-hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.rest-hud-item {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.rest-hud-label { font-size: 0.74rem; color: var(--muted); }
.rest-hud-value { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.rest-hud-small { font-size: 0.95rem; }

.rest-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.rest-variant { display: flex; flex-direction: column; font-size: 0.76rem; color: var(--muted); gap: 0.15rem; }
.rest-variant select { min-width: 12rem; }
.rest-status { margin-left: auto; font-size: 0.85rem; }
.rest-status.ok { color: var(--ok); }
.rest-status.bad { color: var(--bad); }

.rest-board-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0.4rem 0 0.2rem;
  overflow: auto;
}
.rest-board {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 520px;
  --cols: 4;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  outline: none;
}
.rest-board:focus-visible { box-shadow: 0 0 0 2px rgba(61, 155, 253, 0.5); border-radius: 8px; }

.rest-canvas {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 100%;
  height: auto;
  touch-action: none;
}

/* 2048 */
.r2048-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: clamp(0.8rem, 2.6vw, 1.4rem);
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, color 0.12s ease;
}
.r2048-t2 { background: #22303f; color: var(--text); }
.r2048-t4 { background: #26394b; color: var(--text); }
.r2048-t8 { background: #2b4a5e; }
.r2048-t16 { background: #2f5a6b; }
.r2048-t32 { background: #34707a; }
.r2048-t64 { background: #3a8a80; }
.r2048-t128 { background: #4a9a63; }
.r2048-t256 { background: #7aa93f; }
.r2048-t512 { background: #b39a35; }
.r2048-t1024 { background: #c47f2c; }
.r2048-t2048 { background: #d05b3a; color: #fff; }
.r2048-tbig { background: #a83a5c; color: #fff; }
.r2048-new { animation: r2048-pop 0.16s ease-out; }
@keyframes r2048-pop { from { transform: scale(0.82); opacity: 0.6; } to { transform: scale(1); opacity: 1; } }

/* Сапёр */
.rmine {
  gap: 2px;
  --cols: 9;
  max-width: min(100%, 560px);
  user-select: none;
}
.rmine-wide { max-width: min(100%, 900px); }
.rmine-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: clamp(0.6rem, 1.6vw, 0.95rem);
  font-weight: 600;
  cursor: pointer;
}
.rmine-cell:hover { border-color: var(--accent); }
.rmine-cell.is-open { background: var(--bg-elev); cursor: default; border-color: #223040; }
.rmine-cell.is-open:hover { border-color: #223040; }
.rmine-cell.is-mine { background: rgba(255, 107, 107, 0.25); }
.rmine-cell.is-boom { background: var(--bad); color: #14181d; }
.rmine-cell.is-flag { color: var(--warn); }
.rmine-cell.n1 { color: #6fb3f5; }
.rmine-cell.n2 { color: #3ecf8e; }
.rmine-cell.n3 { color: #ff8f8f; }
.rmine-cell.n4 { color: #b48cf2; }
.rmine-cell.n5 { color: #e6b84d; }
.rmine-cell.n6 { color: #6fd0e0; }
.rmine-cell.n7 { color: #d9a0b0; }
.rmine-cell.n8 { color: var(--muted); }

/* Пятнашки */
.r15 { gap: 5px; --cols: 4; max-width: min(100%, 460px); }
.r15-tile {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(180deg, #26394b, #1f2c3a);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: clamp(1rem, 3vw, 1.6rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.r15-tile:hover { border-color: var(--accent); }
.r15-tile.is-ok { border-color: rgba(62, 207, 142, 0.5); }
.r15-tile.is-empty { background: transparent; border-style: dashed; cursor: default; }
.r15-tile.is-hint { border-color: var(--warn); box-shadow: 0 0 0 2px rgba(230, 184, 77, 0.4); }

/* Пары */
.rmem { gap: 7px; --cols: 4; max-width: min(100%, 480px); }
.rmem-card {
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #223040, #1a2431);
  font-size: clamp(1rem, 3vw, 1.7rem);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.rmem-card:hover { border-color: var(--accent); }
.rmem-card.is-open { background: var(--bg-soft); border-color: var(--accent); }
.rmem-card.is-done { background: rgba(62, 207, 142, 0.15); border-color: var(--ok); cursor: default; }

/* Реверси */
.rrev { gap: 3px; --cols: 8; max-width: min(100%, 520px); }
.rrev-cell {
  aspect-ratio: 1 / 1;
  border-radius: 5px;
  background: #223a2c;
  border: 1px solid #2c4a38;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.rrev-cell.is-hint { cursor: pointer; box-shadow: inset 0 0 0 2px rgba(230, 184, 77, 0.55); }
.rrev-cell.is-hint:hover { background: #2b4a38; }
.rrev-stone {
  display: block;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.35);
}
.rrev-w { background: radial-gradient(circle at 35% 30%, #ffffff, #c8d3de); }
.rrev-b { background: radial-gradient(circle at 35% 30%, #4a5560, #14181d); }
.rrev-last { box-shadow: 0 0 0 2px var(--warn); }

/* Экранные кнопки управления */
.rest-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.9rem;
}
.rest-pad-row { display: flex; gap: 0.3rem; }
.rest-pad-btn {
  font: inherit;
  min-width: 3rem;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
}
.rest-pad-btn:hover { border-color: var(--accent); color: var(--accent); }
.rest-pad-hint { font-size: 0.76rem; }

/* Итог партии */
.rest-result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 20, 25, 0.72);
  border-radius: var(--radius);
  z-index: 3;
}
.rest-result[hidden] { display: none; }
.rest-result-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  text-align: center;
  max-width: 24rem;
}
.rest-result-title { font-size: 1.05rem; font-weight: 600; }
.rest-result-text { color: var(--muted); font-size: 0.9rem; }
.rest-result-actions { display: flex; gap: 0.5rem; }

.rest-stat-list { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.88rem; }
.rest-stat-list > div { display: flex; justify-content: space-between; gap: 0.5rem; }

.rest-leaders { list-style: none; margin: 0 0 0.4rem; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.rest-leaders li { display: flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; }
.rest-leaders li.is-me { background: rgba(61, 155, 253, 0.12); border-radius: 6px; padding: 0.1rem 0.3rem; }
.rest-leader-name { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.rest-leader-name .muted { font-size: 0.74rem; }
.rest-leader-score { font-variant-numeric: tabular-nums; }

.rest-games-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.rest-games-list a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-size: 0.86rem;
}
.rest-games-list a:hover { border-color: var(--accent); }
.rest-games-list .muted { margin-left: auto; font-size: 0.76rem; }

@media (max-width: 1100px) {
  .rest-columns, .rest-layout { grid-template-columns: minmax(0, 1fr); }
  .rest-side { order: 2; }
}
@media (max-width: 620px) {
  .rest-two-col { grid-template-columns: 1fr; }
  .rest-status { margin-left: 0; width: 100%; }
  .rest-board { max-width: 100%; }
}

/* Контейнер canvas-игр (змейка) и подсветка подсказки в реверси */
.rest-canvas-holder { display: flex; justify-content: center; width: 100%; }
.rrev-cell.is-last { box-shadow: inset 0 0 0 2px var(--warn); }

/* ==========================================================================
   Карточные столы раздела «Отдых»: дурак и покер
   ========================================================================== */

/* --- игральные карты ----------------------------------------------------- */
.card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  width: 2.6rem;
  height: 3.7rem;
  border-radius: 6px;
  background: #f4f7fb;
  border: 1px solid #b9c6d4;
  color: #131a22;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  user-select: none;
  flex: 0 0 auto;
}
.card-rank { font-size: 1rem; }
.card-suit { font-size: 1.15rem; }
.card-red { color: #c0392b; }
.card-black { color: #16202b; }
.card-back {
  background: repeating-linear-gradient(45deg, #24405e, #24405e 5px, #1b3247 5px, #1b3247 10px);
  border-color: #35597c;
}
.card-empty {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--line);
  box-shadow: none;
}
.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-2px); }
.card.is-playable { box-shadow: 0 0 0 2px var(--ok); cursor: pointer; }
.card.is-playable:hover { transform: translateY(-3px); }
.card.is-picked { box-shadow: 0 0 0 2px var(--warn); transform: translateY(-4px); }
.card-cover { margin-top: -2.5rem; margin-left: 0.7rem; }
.card-trump { box-shadow: 0 0 0 2px var(--warn); }
.cards-backs { display: inline-flex; gap: 0.15rem; flex-wrap: wrap; }
.cards-backs .card { width: 1.7rem; height: 2.4rem; border-radius: 4px; }
.cards-backs-more { font-size: 0.75rem; align-self: center; }

/* --- лобби --------------------------------------------------------------- */
.cards-create {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.7rem 1rem;
  align-items: end;
}
.cards-create label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.82rem; color: var(--muted); }
.cards-create select, .cards-create input[type="text"] { min-width: 0; }
.cards-check { flex-direction: row; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text); }
.cards-create-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.7rem; }
.cards-columns { align-items: start; }
.cards-open-table td { vertical-align: middle; }
.cards-code { display: flex; gap: 0.5rem; margin-bottom: 0.4rem; }
.cards-code input { text-transform: uppercase; letter-spacing: 0.12em; max-width: 12rem; }
.cards-sub { margin: 1rem 0 0.4rem; font-size: 0.95rem; font-weight: 600; }
.cards-mine { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.cards-mine a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.cards-mine a:hover { border-color: var(--accent); }
.cards-mine-icon { font-size: 1.2rem; }
.cards-mine-body { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.cards-mine-body .muted { font-size: 0.78rem; }
.cards-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}
.cards-chip.ok { color: var(--ok); border-color: rgba(62, 207, 142, 0.5); }
.cards-chip.warn { color: var(--warn); border-color: rgba(230, 184, 77, 0.5); }
.cards-chip.bad { color: var(--bad); border-color: rgba(255, 107, 107, 0.5); }

/* --- стол ---------------------------------------------------------------- */
.cards-page { position: relative; }
.cards-head .actions-row { align-items: center; }
.cards-copy {
  font: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.3rem;
  margin-left: 0.35rem;
}
.cards-copy:hover { color: var(--accent); border-color: var(--accent); }
.cards-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 1rem;
  align-items: start;
}
.cards-table-panel { display: flex; flex-direction: column; gap: 0.8rem; }
.cards-opponents {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}
.cards-opponent {
  flex: 1 1 150px;
  max-width: 240px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.cards-opponent.is-turn { border-color: var(--warn); box-shadow: 0 0 0 1px rgba(230, 184, 77, 0.4); }
.cards-opponent.is-folded { opacity: 0.55; }
.cards-opponent-head { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; font-size: 0.9rem; }
.cards-opponent-meta { font-size: 0.78rem; }
.cards-opponent-hand { display: flex; gap: 0.2rem; flex-wrap: wrap; }
.cards-opponent-hand .card { width: 1.9rem; height: 2.7rem; border-radius: 4px; }
.cards-opponent-hand .card-rank { font-size: 0.8rem; }
.cards-opponent-hand .card-suit { font-size: 0.9rem; }

.cards-felt {
  border-radius: 14px;
  border: 1px solid #2b4a38;
  background: radial-gradient(circle at 50% 30%, #1f4433, #16301f 70%);
  padding: 0.9rem;
  min-height: 9.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.6rem;
}
.cards-center { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.cards-board { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; align-items: flex-start; min-height: 3.7rem; }
.cards-pair { display: flex; flex-direction: column; align-items: center; min-width: 2.6rem; }
.cards-table-empty { font-size: 0.85rem; }
.cards-pot { display: flex; gap: 0.6rem; align-items: center; }
.cards-pot-value {
  font-weight: 600;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
}
.cards-deck { display: flex; gap: 0.5rem; align-items: center; justify-content: center; }
.cards-deck-info { font-size: 0.8rem; color: var(--muted); }

.cards-me { border-top: 1px dashed var(--line); padding-top: 0.6rem; }
.cards-me-head { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.35rem; }
.cards-me-name { font-weight: 600; }
.cards-me-stack { font-size: 0.8rem; }
.cards-hand { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: flex-end; min-height: 3.8rem; }

.cards-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.cards-turn { font-size: 0.9rem; }
.cards-turn.ok { color: var(--ok); }
.cards-turn.bad { color: var(--bad); }
.cards-turn.warn { color: var(--warn); }
.cards-buttons { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.cards-raise { display: flex; align-items: center; gap: 0.5rem; }
.cards-raise input[type="range"] { width: 12rem; }
.cards-raise input[type="number"] { width: 6rem; }
.cards-draw-hint { font-size: 0.82rem; flex-basis: 100%; }

.cards-side { display: flex; flex-direction: column; }
.cards-seats { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.cards-seats li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
}
.cards-seats li.is-turn { border-color: var(--warn); }
.cards-seats li.is-me { background: rgba(61, 155, 253, 0.12); }
.cards-seats li.is-free { opacity: 0.6; border-style: dashed; }
.cards-seats li.is-left { opacity: 0.5; text-decoration: line-through; }
.cards-seat-name { flex: 1 1 auto; min-width: 0; }
.cards-seat-right { font-variant-numeric: tabular-nums; color: var(--muted); }
.cards-side-actions { display: flex; flex-direction: column; gap: 0.4rem; }
.cards-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 15rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
}
.cards-log-row { padding: 0.2rem 0.35rem; border-radius: 6px; background: var(--bg-soft); }
.cards-log-row.kind-end, .cards-log-row.kind-pot { background: rgba(62, 207, 142, 0.12); }
.cards-log-row.kind-fold, .cards-log-row.kind-take { background: rgba(255, 107, 107, 0.1); }
.cards-log-row.kind-timeout { background: rgba(230, 184, 77, 0.12); }

.cards-showdown { display: flex; flex-direction: column; gap: 0.3rem; width: 100%; margin-top: 0.4rem; }
.cards-showdown-row { display: flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; flex-wrap: wrap; }
.cards-showdown-row.is-win { color: var(--ok); }

.cards-result {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 19, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.cards-result[hidden] { display: none; }
.cards-result-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  min-width: 20rem;
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: center;
}
.cards-result-body { display: flex; flex-direction: column; gap: 0.25rem; }
.cards-result-row { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; }
.cards-result-actions { display: flex; gap: 0.5rem; justify-content: center; }

@media (max-width: 1100px) {
  .cards-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .card { width: 2.2rem; height: 3.1rem; }
  .cards-raise input[type="range"] { width: 8rem; }
}

/* --- Вход по Face ID (WebAuthn / passkeys) -------------------------------- */
.passkey-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  background: linear-gradient(180deg, var(--accent-2), #2456bd);
  border: 1px solid #2456bd;
  border-radius: 8px;
  cursor: pointer;
}
.passkey-btn:hover { border-color: #4a7ee0; }
.passkey-btn[disabled] { opacity: 0.55; cursor: progress; }
.passkey-icon { font-size: 1.15rem; line-height: 1; }

.passkey-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.2rem 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.passkey-divider::before,
.passkey-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.passkey-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.1rem;
}
.passkey-status.is-error { color: var(--bad); }
.passkey-status.is-ok { color: var(--ok); }

.passkey-help {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.passkey-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.2rem 0 0; }
.passkey-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.passkey-item-main { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.passkey-item-title { font-weight: 500; }
.passkey-item-meta { font-size: 0.76rem; color: var(--muted); }
.passkey-item-meta .passkey-sync { color: var(--accent); }
.passkey-empty {
  padding: 0.65rem 0.75rem;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.passkey-name-input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}
.passkey-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.passkey-actions label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }

