/* Planora Admin — тот же визуальный язык, что planora.ee */
:root {
  --ink: #111216;
  --muted: #696b75;
  --line: rgba(20, 22, 30, .09);
  --paper: #f8f9fb;
  --white: rgba(255, 255, 255, .82);
  --blue: #1684ff;
  --violet: #8257ff;
  --pink: #ef6dca;
  --cyan: #39d8d4;
  --shadow: 0 24px 60px rgba(49, 55, 78, .12);
  --card: rgba(255, 255, 255, .78);
  --ok: #1f9d6c;
  --warn: #c9841a;
  --danger: #e0456a;
  --side-w: 248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(77, 194, 255, .11), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(238, 113, 218, .10), transparent 30%),
    var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

/* —— Login —— */
.login-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.login-card {
  width: min(420px, 100%);
  padding: 28px 28px 24px;
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 28px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(150%);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.login-brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(34, 19, 58, .18);
}
.login-brand strong {
  font-size: 20px;
  letter-spacing: -.02em;
}
.login-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 18px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(28, 30, 39, .08);
  background: rgba(255, 255, 255, .7);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.login-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--violet));
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -.03em;
  line-height: 1.15;
}
.login-card h1 span {
  background: linear-gradient(120deg, var(--blue), var(--violet) 55%, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-card p.lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 15px;
  font-size: 14px;
  font-weight: 650;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  width: 100%;
  background: #111216;
  color: #fff;
  box-shadow: 0 10px 24px rgba(17, 18, 22, .16);
}
.btn-primary:hover { opacity: .92; }
.btn-ghost {
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(17, 18, 22, .08);
  color: var(--ink);
}
.btn-soft {
  background: linear-gradient(135deg, rgba(22, 132, 255, .12), rgba(130, 87, 255, .12));
  color: #2a3a8f;
  border: 1px solid rgba(22, 132, 255, .15);
}
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.login-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.otp-row {
  display: none;
  margin-top: 14px;
  gap: 10px;
}
.otp-row.show { display: flex; }
.otp-row input {
  flex: 1;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(17, 18, 22, .1);
  background: #fff;
  letter-spacing: .2em;
  font-weight: 650;
}

/* —— App shell —— */
.app {
  display: none;
  min-height: 100%;
}
.app.show { display: grid; grid-template-columns: var(--side-w) 1fr; }

.mobile-top,
.mobile-dim {
  display: none;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(20px) saturate(140%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 18px;
  font-weight: 650;
  letter-spacing: -.02em;
}
.side-brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: 0 5px 14px rgba(34, 19, 58, .18);
}
.side-label {
  margin: 10px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #8a8d98;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  color: #565862;
  font-size: 14px;
  font-weight: 560;
  border: 1px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .8); color: var(--ink); }
.nav-item.active {
  background: #111216;
  color: #fff;
  box-shadow: 0 10px 22px rgba(17, 18, 22, .14);
}
.nav-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
}
.nav-item.active .dot { opacity: 1; background: var(--cyan); }
.side-foot {
  margin-top: auto;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--line);
}
.side-foot .who { font-size: 13px; font-weight: 650; }
.side-foot .role { font-size: 11px; color: var(--muted); margin-top: 2px; }
.side-foot .actions { margin-top: 10px; display: flex; gap: 8px; }
.side-foot .actions .btn { min-height: 34px; padding: 0 10px; font-size: 12px; flex: 1; }

.main {
  min-width: 0;
  padding: 22px 28px 40px;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.crumb {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.crumb a { color: var(--blue); font-weight: 600; }
.topbar h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -.03em;
}
.topbar .sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 520px;
  line-height: 1.4;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 14px;
}
.card {
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 14px 40px rgba(44, 52, 78, .06);
  backdrop-filter: blur(18px);
  padding: 18px;
}
.card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  letter-spacing: -.01em;
}
.card .hint { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.03em;
}
.stat-value small {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 4px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-ok { background: rgba(31, 157, 108, .12); color: var(--ok); }
.badge-warn { background: rgba(201, 132, 26, .14); color: var(--warn); }
.badge-danger { background: rgba(224, 69, 106, .12); color: var(--danger); }
.badge-neutral { background: rgba(17, 18, 22, .06); color: var(--muted); }

.table-wrap { overflow: auto; border-radius: 16px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #8a8d98;
  font-weight: 700;
}
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(22, 132, 255, .04); }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}
.search {
  flex: 1;
  min-width: 180px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(17, 18, 22, .1);
  background: #fff;
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.alert-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .65);
  border: 1px solid var(--line);
}
.alert-row strong { display: block; font-size: 13px; margin-bottom: 2px; }
.alert-row span { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* Map page */
.map-board {
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 10px 0 20px;
}
.map-node {
  min-width: 160px;
  padding: 14px 18px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  text-align: center;
  box-shadow: 0 10px 28px rgba(44, 52, 78, .07);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.map-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(44, 52, 78, .12);
}
.map-node strong { display: block; font-size: 14px; }
.map-node span { font-size: 11px; color: var(--muted); }
.map-node.home {
  background: #111216;
  color: #fff;
  border: 0;
}
.map-node.home span { color: rgba(255, 255, 255, .65); }
.map-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.map-arrow {
  color: #a0a3ad;
  font-size: 18px;
  line-height: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .03em;
  text-transform: uppercase;
}
.field input, .field select, .field textarea {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(17, 18, 22, .1);
  background: #fff;
}
.field textarea { min-height: 90px; resize: vertical; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.hidden { display: none !important; }
.page { display: none; }
.page.active { display: block; animation: fade .25s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.demo-banner {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(22, 132, 255, .1), rgba(130, 87, 255, .1));
  border: 1px solid rgba(22, 132, 255, .15);
  font-size: 12px;
  color: #3a3f6b;
  line-height: 1.4;
}

/* Lab: страница не прыгает; скролл только внутри блоков. Весь экран — отдельные правила, не трогаем. */
body.is-lab-page .main {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  padding: 10px 16px 10px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
body.is-lab-page #page-max-schema.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  animation: none;
}
body.is-lab-page .maxsch-shell:not(.is-fs-local):not(:fullscreen) {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
body.is-lab-page .maxsch-shell:not(.is-fs-local):not(:fullscreen) .maxsch-layout {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  align-items: stretch;
}
body.is-lab-page .maxsch-shell:not(.is-fs-local):not(:fullscreen) .maxsch-board {
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}
body.is-lab-page .maxsch-shell:not(.is-fs-local):not(:fullscreen) .maxsch-side {
  position: relative;
  top: auto;
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: auto;
}

.period-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.period-tab {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(17, 18, 22, .1);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.period-tab.active {
  background: #111216;
  color: #fff;
  border-color: #111216;
}

.expand-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(17, 18, 22, .1);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  transition: transform .15s ease;
}
.expand-btn.open { transform: rotate(-180deg); }

tr.op-main { cursor: pointer; }
tr.op-main:hover { background: rgba(17, 18, 22, .03); }
.op-detail-row td {
  padding: 0 12px 14px;
  background: rgba(246, 247, 251, .9);
  border-bottom: 1px solid var(--line);
}
.op-detail-box { padding: 12px 4px 4px; }
.op-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.op-detail-grid > div {
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(17, 18, 22, .06);
}
.op-detail-grid span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.op-detail-grid strong {
  font-size: 13px;
  font-weight: 700;
}
.op-detail-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.op-fail {
  color: #c0392b;
}
.stitch-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  vertical-align: middle;
  white-space: nowrap;
}
.stitch-ok {
  background: rgba(46, 125, 50, 0.12);
  color: #2e7d32;
}
.stitch-warn {
  background: rgba(201, 132, 26, 0.16);
  color: var(--warn);
}
.stitch-bad {
  background: rgba(192, 57, 43, 0.14);
  color: #c0392b;
}
tr.op-stitch-bad > td:nth-child(4) {
  font-weight: 700;
}
.person-wallet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.person-wallet-grid > div {
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--muted) 10%, transparent);
}
.person-wallet-grid span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.person-wallet-grid strong {
  font-size: 16px;
  font-weight: 700;
}
.person-hist-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.op-conv-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  font-size: 12px;
}
.op-conv-row > span {
  color: var(--muted);
  font-weight: 600;
}
.op-conv-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
  flex: 1 1 180px;
}
.op-copy-id {
  padding: 4px 10px !important;
  font-size: 12px !important;
  min-height: 0 !important;
}
.op-conv-actions { margin-top: 10px; }

/* Conversation view (spy narrative + gated chat) */
.conv-view-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 12, 18, .45);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 18px;
}
.conv-view-overlay.hidden { display: none !important; }
.conv-view-panel {
  width: min(1100px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
  padding: 18px 18px 22px;
}
.conv-view-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.conv-view-crumb { font-size: 12px; color: var(--muted); }
.conv-view-head h2 { margin: 4px 0; font-size: 22px; }
.conv-view-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}
.conv-view-summary {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f6fb;
  border: 1px solid rgba(17,18,22,.06);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
}
.conv-view-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .conv-view-split { grid-template-columns: 1fr; }
}
.conv-view-col h3 { margin: 0 0 6px; font-size: 15px; }
.conv-view-feed {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow: auto;
}
.conv-spy-item, .conv-turn {
  border: 1px solid rgba(17,18,22,.07);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
.conv-spy-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.conv-spy-item p { margin: 0; font-size: 13px; line-height: 1.4; }
.conv-turn-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.conv-turn pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
}
.conv-view-chat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.conv-view-chat-actions input {
  flex: 1;
  min-width: 160px;
  border: 1px solid rgba(17,18,22,.12);
  border-radius: 10px;
  padding: 8px 10px;
}
.conv-locked, .conv-empty {
  padding: 18px;
  border-radius: 12px;
  background: #f7f8fb;
  color: var(--muted);
  text-align: center;
}
.spend-total {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: #2c344e;
}

.rates-group {
  border: 1px solid rgba(17, 18, 22, .08);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}
.rates-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 0;
  background: rgba(246, 247, 251, .9);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}
.rates-group-body { padding: 0 8px 10px; }
.rate-input {
  width: 88px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(17, 18, 22, .12);
  font-size: 13px;
  font-weight: 600;
}

.perm-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}
.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(246, 247, 251, .9);
  border: 1px solid rgba(17, 18, 22, .06);
  font-size: 13px;
}
.perm-row span { color: var(--ink); font-weight: 600; }
.perm-row input[type="checkbox"] {
  width: 42px;
  height: 24px;
  accent-color: #111216;
  cursor: pointer;
}
.nav-item.nav-hidden { display: none !important; }
tr.team-selected { background: rgba(22, 132, 255, .08); }

.notify-person.active {
  border-color: rgba(91, 108, 255, .35);
  background: rgba(91, 108, 255, .08);
}
.ticket-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
}
.ticket-msg {
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(17, 18, 22, .06);
  background: rgba(246, 247, 251, .95);
}
.ticket-msg.admin {
  background: rgba(91, 108, 255, .08);
  border-color: rgba(91, 108, 255, .18);
}
.ticket-msg-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.ticket-msg-text {
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 14px;
}
#ticketReplyText, #demoTicketBody {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
  background: #fff;
}

@media (max-width: 980px) {
  body {
    background:
      radial-gradient(circle at 18% 0%, rgba(77, 194, 255, .13), transparent 28%),
      radial-gradient(circle at 86% 4%, rgba(238, 113, 218, .10), transparent 30%),
      var(--paper);
  }
  .app.show {
    display: block;
    min-height: 100%;
  }
  .mobile-top {
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 62px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(248, 249, 251, .86);
    backdrop-filter: blur(20px) saturate(150%);
  }
  .mobile-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 750;
  }
  .mobile-brand img {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    box-shadow: 0 5px 14px rgba(34, 19, 58, .16);
  }
  .mobile-menu-btn,
  .mobile-quick-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid rgba(17, 18, 22, .08);
    border-radius: 14px;
    background: rgba(255, 255, 255, .78);
    color: var(--ink);
  }
  .mobile-menu-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }
  .mobile-menu-btn span {
    width: 18px;
    height: 2px;
    border-radius: 99px;
    background: currentColor;
  }
  .mobile-quick-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
  }
  .mobile-dim {
    position: fixed;
    inset: 0;
    z-index: 38;
    background: rgba(17, 18, 22, .22);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }
  body.nav-open .mobile-dim {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  .side {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(84vw, 318px);
    height: 100dvh;
    padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--line);
    border-bottom: 0;
    background: rgba(255, 255, 255, .92);
    transform: translateX(-105%);
    transition: transform .2s ease;
    overflow: auto;
    box-shadow: 18px 0 50px rgba(17, 18, 22, .14);
  }
  body.nav-open .side { transform: translateX(0); }
  .side-brand { padding-bottom: 12px; }
  .side-label { margin-top: 12px; }
  .nav-item {
    min-height: 46px;
    border-radius: 15px;
    font-size: 15px;
  }
  .side-foot { margin-top: 16px; }
  .main {
    padding: 16px 14px calc(30px + env(safe-area-inset-bottom));
  }
  .demo-banner {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 14px;
  }
  .topbar {
    display: block;
    margin-bottom: 14px;
  }
  .topbar h1 {
    font-size: 25px;
    line-height: 1.12;
  }
  .topbar .sub {
    font-size: 13px;
    max-width: none;
  }
  .topbar > .btn,
  .topbar > button,
  .topbar .row-actions {
    margin-top: 12px;
  }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .op-detail-grid { grid-template-columns: 1fr 1fr; }
  .card {
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 10px 26px rgba(44, 52, 78, .06);
  }
  .card h3 { font-size: 14px; }
  .card .hint { margin-bottom: 10px; }
  .stat-value { font-size: 24px; }
  .toolbar,
  .row-actions,
  .period-tabs,
  .rates-filter {
    gap: 8px;
  }
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }
  .search,
  .toolbar select.search,
  .field input,
  .field select,
  .field textarea {
    width: 100%;
    min-width: 0 !important;
    min-height: 46px;
    font-size: 16px;
  }
  .btn,
  .period-tab {
    min-height: 44px;
  }
  .row-actions .btn,
  .topbar .btn,
  .card > .btn {
    flex: 1 1 auto;
  }
  .period-tabs,
  .rates-filter {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .period-tabs::-webkit-scrollbar,
  .rates-filter::-webkit-scrollbar {
    display: none;
  }
  .period-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .table-wrap {
    overflow: visible;
    border-radius: 0;
  }
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }
  thead { display: none; }
  table { font-size: 13px; }
  tbody {
    display: grid;
    gap: 10px;
  }
  tr {
    border: 1px solid var(--line);
    border-radius: 15px;
    background: rgba(255, 255, 255, .72);
    overflow: hidden;
  }
  tr.clickable:active,
  tr.op-main:active,
  tr[data-ticket-id]:active {
    transform: scale(.99);
  }
  th,
  td {
    white-space: normal;
    border-bottom: 1px solid rgba(17, 18, 22, .06);
    padding: 10px 12px;
  }
  td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    text-align: right;
  }
  td::before {
    content: attr(data-label);
    flex: 0 0 min(42%, 160px);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    line-height: 1.35;
    text-align: left;
    text-transform: uppercase;
  }
  td:empty::before,
  td[data-label=""]::before {
    display: none;
  }
  td:last-child { border-bottom: 0; }
  td > * {
    min-width: 0;
  }
  td .row-actions,
  td.row-actions {
    justify-content: flex-end;
  }
  td.row-actions {
    display: flex;
    flex-wrap: wrap;
  }
  td.row-actions::before {
    align-self: center;
  }
  .op-main td:first-child {
    justify-content: flex-end;
    padding-bottom: 2px;
  }
  .op-main td:first-child::before {
    display: none;
  }
  .op-detail-row {
    margin-top: -10px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    background: rgba(246, 247, 251, .94);
  }
  .op-detail-row td {
    display: block;
    text-align: left;
    padding: 0 10px 12px;
  }
  .op-detail-row td::before {
    display: none;
  }
  .op-detail-grid {
    grid-template-columns: 1fr;
  }
  .rates-group-head {
    min-height: 48px;
  }
  .rate-input {
    width: 112px;
    min-height: 38px;
  }
  .perm-row {
    align-items: center;
  }
  .perm-row input[type="checkbox"] {
    flex: 0 0 auto;
  }
  .alert-row {
    border-radius: 15px;
    padding: 11px;
  }
  .map-board {
    align-items: stretch;
    justify-items: stretch;
  }
  .map-row {
    display: grid;
    grid-template-columns: 1fr;
  }
  .map-node {
    width: 100%;
    min-width: 0;
  }
  .ticket-thread {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .login-shell {
    align-items: start;
    place-items: start stretch;
    padding: calc(18px + env(safe-area-inset-top)) 14px 18px;
  }
  .login-card {
    padding: 22px 18px 18px;
    border-radius: 22px;
  }
  .login-card h1 { font-size: 25px; }
  .login-pill { border-radius: 14px; }
  .otp-row {
    display: grid !important;
    grid-template-columns: 1fr auto;
  }
  .main { padding-left: 12px; padding-right: 12px; }
  .grid-3,
  .grid-2,
  .stack {
    gap: 10px;
  }
  .card { padding: 12px; }
  .topbar h1 { font-size: 23px; }
  .crumb { line-height: 1.35; }
  .row-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .row-actions .btn,
  .topbar .btn,
  .card > .btn,
  .btn-primary,
  .btn-soft,
  .btn-ghost {
    width: 100%;
  }
  td {
    display: grid;
    grid-template-columns: 1fr;
    text-align: left;
    gap: 5px;
  }
  td::before {
    flex: none;
    width: auto;
  }
  td.row-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  td.row-actions::before {
    margin-bottom: 4px;
  }
  .op-main td:first-child {
    display: flex;
  }
  .side {
    width: min(90vw, 330px);
  }
  .side-foot .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* —— Админ-ИИ чат —— */
.admin-ai-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 12px;
  min-height: 62vh;
}
@media (max-width: 860px) {
  .admin-ai-layout { grid-template-columns: 1fr; }
}
.admin-ai-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 70vh;
  overflow: auto;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(20, 22, 30, 0.08);
  background: #fff;
}
.admin-ai-thread {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.admin-ai-thread.is-on,
.admin-ai-thread:hover {
  background: rgba(130, 87, 255, 0.08);
  border-color: rgba(130, 87, 255, 0.2);
}
.admin-ai-main {
  display: flex;
  flex-direction: column;
  min-height: 62vh;
  border-radius: 12px;
  border: 1px solid rgba(20, 22, 30, 0.08);
  background: #fff;
  overflow: hidden;
}
.admin-ai-messages {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}
.admin-ai-bubble {
  max-width: min(520px, 78%);
  width: fit-content;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.45;
}
.admin-ai-bubble .k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 4px;
}
.admin-ai-bubble.is-you {
  align-self: flex-end;
  background: rgba(22, 132, 255, 0.12);
  border-bottom-right-radius: 6px;
}
.admin-ai-bubble.is-ai {
  align-self: flex-start;
  background: rgba(130, 87, 255, 0.1);
  border-bottom-left-radius: 6px;
}
.admin-ai-via {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 650;
  color: #6b7280;
  text-transform: none;
  letter-spacing: 0;
}
.admin-ai-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border-top: 1px solid rgba(20, 22, 30, 0.08);
}
.admin-ai-composer .btn-primary {
  width: auto;
  min-width: 110px;
  min-height: 40px;
  padding: 0 16px;
}
.admin-ai-composer textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid rgba(20, 22, 30, 0.12);
  padding: 8px 10px;
  font: inherit;
}

/* Router slot mismatch (brains) */
.field.slot-mismatch-field label { color: var(--danger); }
select.slot-mismatch { border-color: var(--danger) !important; box-shadow: 0 0 0 1px rgba(224,69,106,.25); }
.router-save-danger .badge { background: rgba(224,69,106,.15); color: var(--danger); }
