:root {
  --bg: #f4f4f1;
  --paper: #ffffff;
  --ink: #1d1f22;
  --ink-2: #2b2e33;
  --muted: #6f737a;
  --line: #d8d8d2;
  --line-dark: #32363c;
  --accent: #111316;
  --accent-soft: #ecece8;
  --accent-2: #cfd2d6;
  --danger: #b42318;
  --ok: #0f7a42;
  --warning: #7a5b00;
  --shadow: 0 24px 70px rgba(17, 19, 22, .10);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 8% 0%, rgba(0,0,0,.08) 0, rgba(0,0,0,0) 32%),
    linear-gradient(180deg, #f7f7f4 0%, var(--bg) 100%);
  color: var(--ink);
}
a { color: inherit; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: #191c20;
  color: #f6f6f3;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; min-width: 300px; text-decoration: none; }
.logo-img {
  width: 300px;
  max-width: min(300px, 70vw);
  height: auto;
  display: block;
  object-fit: contain;
}
.nav { display: flex; align-items: center; gap: 14px; color: rgba(246,246,243,.80); font-size: 14px; flex-wrap: wrap; justify-content: flex-end; }
.nav a { text-decoration: none; border-bottom: 1px solid transparent; padding: 7px 0; position: relative; }
.nav a:hover { color: #fff; border-bottom-color: #fff; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: #fff; color: #111316; font-size: 11px; font-weight: 900; }
.logout { color: #f6d2d2 !important; }
.role { color: rgba(246,246,243,.58); white-space: nowrap; }
.container { width: min(1180px, calc(100% - 32px)); margin: 30px auto 68px; }
.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 120px); }
.login-card {
  width: min(520px, 100%);
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 34px;
  box-shadow: var(--shadow);
}
.login-logo { display: flex; margin-bottom: 24px; }
.login-logo img { width: 100%; max-width: 420px; height: auto; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.12; letter-spacing: -.02em; }
h1 { font-size: clamp(28px, 4vw, 46px); font-weight: 950; text-transform: uppercase; }
h2 { font-size: 24px; font-weight: 900; }
h3 { font-size: 18px; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: 0 14px 38px rgba(17,19,22,.06);
}
.accent-card { border-color: #bfc1c6; background: linear-gradient(180deg, #fff 0%, #f1f1ee 100%); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin: 0 0 22px; }
.page-head p { margin: 12px 0 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: linear-gradient(180deg, #ffffff 0%, #eeeeea 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 16px 36px rgba(17,19,22,.06);
}
.stat-card span { display: block; font-size: 34px; font-weight: 950; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: 11px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.button {
  border: 0;
  border-radius: 999px;
  padding: 11px 17px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  transition: transform .15s ease, background-color .15s ease, border-color .15s ease, opacity .15s ease;
  font: inherit;
  font-weight: 850;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.button.secondary { background: var(--accent-soft); color: var(--ink); border: 1px solid var(--line); }
.button.ghost { background: transparent; border: 1px solid var(--line-dark); color: var(--ink); }
.full-width { width: 100%; }
.alert { padding: 12px 14px; border-radius: 14px; background: #fff0ee; border: 1px solid #f1b7b0; color: var(--danger); margin: 16px 0; }
.info-hint { margin-top: 18px; padding: 14px; background: #f3f3ef; border: 1px solid var(--line); border-radius: 16px; color: var(--muted); line-height: 1.6; font-size: 14px; }
input, textarea, select {
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  background: #fbfbfa;
  color: var(--ink);
  border-radius: 14px;
  outline: none;
  font: inherit;
  min-height: 46px;
}
input[type="file"] { padding: 10px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(17,19,22,.08); background: #fff; }
label { color: var(--muted); font-size: 14px; }
.form-stack { display: grid; gap: 14px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.inline-form > input, .inline-form > select { min-width: 220px; flex: 1; }
.inline-form.compact > input, .inline-form.compact > select { min-width: 150px; flex: 1; }
.check { display: flex; gap: 8px; align-items: center; white-space: nowrap; color: var(--ink); }
.check input { width: auto; margin: 0; min-height: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.strong-link { color: var(--ink); font-weight: 900; text-decoration: none; }
.strong-link:hover { text-decoration: underline; }
.pill { display: inline-flex; padding: 5px 10px; border-radius: 999px; background: #e7e8e4; color: #24272b; border: 1px solid #d5d6d0; font-size: 12px; font-weight: 750; }
.profile-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 22px; align-items: start; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-grid div { background: #f5f5f2; border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.info-grid small, .note-box small, .status-box small { display: block; color: var(--muted); margin-bottom: 7px; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.info-grid b { display: block; }
.status-box { margin-top: 16px; padding: 16px; background: #1f2328; color: #fff; border: 1px solid #1f2328; border-radius: 18px; }
.status-box small { color: rgba(255,255,255,.65); }
.big-status { font-size: 23px; font-weight: 950; color: #fff; }
.note-box { margin-top: 14px; padding: 14px; border-radius: 16px; background: #f5f5f2; border: 1px solid var(--line); }
.public-note { border-color: #bec1c6; }
.internal-note { border-style: dashed; border-color: #9a8d5f; background: #fbf8ea; }
.item-list { display: grid; gap: 10px; margin-top: 14px; }
.item-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 14px; background: #f7f7f4; border: 1px solid var(--line); border-radius: 16px; }
.item-block { padding: 15px; background: #f7f7f4; border: 1px solid var(--line); border-radius: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.mini-form { border: 1px dashed #bcbdb7; background: #fbfbfa; padding: 14px; border-radius: 18px; margin-bottom: 12px; }
.link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; font-weight: 850; padding: 0; font: inherit; }
.role-badge { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; background: #f0f0ec; color: var(--muted); font-size: 12px; }
.status-ok { color: var(--ok); font-weight: 850; }
.status-danger { color: var(--danger); font-weight: 850; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chat-list { display: grid; gap: 10px; }
.chat-card { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 16px; border: 1px solid var(--line); background: #f7f7f4; border-radius: 18px; text-decoration: none; }
.chat-card:hover { background: #fff; border-color: #afb2b8; }
.chat-card p { margin: 8px 0 0; color: var(--muted); max-width: 720px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; border-radius: 999px; background: #111316; color: #fff; font-weight: 900; }
.chat-wrap { display: grid; gap: 18px; }
.conversation { display: grid; gap: 12px; max-height: 58vh; overflow-y: auto; padding-right: 4px; }
.message { max-width: min(760px, 90%); padding: 12px 14px; border-radius: 18px; border: 1px solid var(--line); }
.message.mine { justify-self: end; background: #1f2328; color: #fff; border-color: #1f2328; }
.message.theirs { justify-self: start; background: #f7f7f4; }
.message-meta { font-size: 12px; opacity: .72; margin-bottom: 6px; }
.message-body { white-space: pre-wrap; line-height: 1.5; }
.message-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.message-form textarea { margin: 0; }
@media (max-width: 900px) {
  .topbar { position: static; flex-direction: column; align-items: stretch; padding: 12px 14px; gap: 12px; }
  .brand { min-width: 0; justify-content: center; }
  .logo-img { width: min(380px, 100%); max-width: 100%; }
  .nav { justify-content: flex-start; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
  .nav a, .role { font-size: 13px; }
  .role { width: 100%; white-space: normal; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .stats-grid, .profile-grid, .two-col, .grid-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .container { width: min(100% - 20px, 1180px); margin-top: 18px; }
  .card { padding: 16px; border-radius: 18px; }
  .section-title { flex-direction: column; align-items: flex-start; }
  .inline-form, .inline-form.compact { display: grid; grid-template-columns: 1fr; align-items: stretch; }
  .inline-form > input, .inline-form > select, .inline-form.compact > input, .inline-form.compact > select { min-width: 0; }
  .item-row { flex-direction: column; align-items: stretch; }
  .form-actions .button, .item-row .button, .inline-form .button { width: 100%; }
  .message-form { grid-template-columns: 1fr; }
  .message { max-width: 100%; }
}
@media (max-width: 640px) {
  h1 { font-size: 28px; }
  h2 { font-size: 21px; }
  .login-card { padding: 22px; border-radius: 22px; }
  .login-logo img { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border: 1px solid var(--line); border-radius: 16px; padding: 10px; margin-bottom: 10px; background: #f7f7f4; }
  td { border: 0; padding: 8px 4px; display: grid; grid-template-columns: 112px 1fr; gap: 10px; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 850; }
}

/* v3 refinements */
.nav-link {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  padding: 9px 12px !important;
  border: 1px solid rgba(255,255,255,.11) !important;
  border-radius: 999px;
  background: rgba(255,255,255,.045);
  transition: transform .16s ease, background-color .16s ease, border-color .16s ease, color .16s ease;
}
.nav-link:hover { transform: translateY(-1px); background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.32) !important; text-decoration: none; }
.nav-icon { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; font-size: 10px; opacity: .82; transition: transform .18s ease; }
.nav-link:hover .nav-icon { transform: scale(1.2) rotate(-7deg); }
.logout { padding: 9px 12px !important; border: 1px solid rgba(255,210,210,.28) !important; border-radius: 999px; text-decoration: none; transition: transform .16s ease, background-color .16s ease; }
.logout:hover { transform: translateY(-1px); background: rgba(255,210,210,.08); }
.button { position: relative; overflow: hidden; box-shadow: 0 9px 22px rgba(17,19,22,.06); }
.button:active { transform: translateY(0) scale(.98); }
.button.primary:hover { background: #2a2e34; }
.button.secondary:hover, .button.ghost:hover { background: #fff; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.search-bar { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 10px; align-items: center; }
.search-bar input { margin: 0; min-height: 48px; }
.form-divider { margin: 4px 0 2px; padding-top: 8px; border-top: 1px dashed var(--line); color: var(--ink); font-weight: 900; text-transform: uppercase; letter-spacing: .05em; font-size: 12px; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.contact-card { padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: #f5f5f2; display: grid; gap: 5px; }
.contact-card small { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.contact-card span { color: var(--muted); font-size: 14px; }
.editable-offer { display: grid; gap: 12px; }
.terms-check { align-items: flex-start; white-space: normal; line-height: 1.45; }
.terms-check a { font-weight: 850; }
.policy-card { max-width: 980px; margin-left: auto; margin-right: auto; }
.policy-card h2 { margin-top: 28px; }
.policy-card li { margin: 8px 0; line-height: 1.55; }
.policy-footer { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.compact-head { margin-bottom: 10px; }
.padded { padding: 16px; }
.messenger-card {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 68vh;
  overflow: hidden;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 14px 38px rgba(17,19,22,.06);
}
.messenger-sidebar { border-right: 1px solid var(--line); background: #f3f3ef; min-height: 68vh; display: flex; flex-direction: column; }
.messenger-title { padding: 18px; font-weight: 950; text-transform: uppercase; letter-spacing: .05em; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.messenger-main { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; min-height: 68vh; }
.chat-header { padding: 18px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.chat-header h2 { margin-bottom: 4px; }
.chat-card { border-radius: 0; border-width: 0 0 1px 0; background: transparent; padding: 14px 16px; align-items: center; }
.chat-card.active { background: #fff; box-shadow: inset 4px 0 0 var(--accent); }
.chat-card:hover { transform: none; background: #fff; }
.chat-card-text { min-width: 0; flex: 1; }
.avatar { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 999px; background: #1f2328; color: #fff; display: grid; place-items: center; font-weight: 950; }
.conversation { padding: 20px; max-height: none; overflow-y: auto; align-content: start; background: linear-gradient(180deg, #fbfbfa 0%, #f3f3ef 100%); }
.empty-chat { margin: auto; color: var(--muted); text-align: center; padding: 24px; }
.empty-chat.big { align-self: center; }
.message-form { padding: 14px; border-top: 1px solid var(--line); background: #fff; }
.message-form textarea { resize: vertical; max-height: 180px; }
.message { animation: messageIn .18s ease both; }
@keyframes messageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.card, .messenger-card { animation: softIn .18s ease both; }
@keyframes softIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 900px) {
  .search-bar { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
  .messenger-card { grid-template-columns: 1fr; min-height: auto; }
  .messenger-sidebar { min-height: auto; max-height: 320px; overflow-y: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .messenger-main { min-height: 560px; }
  .nav-link, .logout { white-space: nowrap; }
}
@media (max-width: 640px) {
  .messenger-card { border-radius: 18px; }
  .messenger-main { min-height: 520px; }
  .conversation { padding: 14px; }
  .message-form { grid-template-columns: 1fr; }
  .message-form .button { width: 100%; }
  .nav { display: flex; flex-wrap: nowrap; overflow-x: auto; }
  .nav-link, .logout { flex: 0 0 auto; }
  .role { flex: 0 0 100%; }
}

/* v4 navigation, search, login policy and messenger fixes */
.topbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 24px;
}
.brand { min-width: 220px; flex: 0 0 auto; }
.logo-img { width: 230px; max-width: 230px; }
.nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}
.nav-link {
  display: inline-flex !important;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 9px 14px !important;
  min-height: 38px;
  border: 1px solid rgba(255,255,255,.16) !important;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: rgba(246,246,243,.88);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: .01em;
}
.nav-link:hover { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.34) !important; color: #fff; transform: translateY(-1px); }
.logout {
  flex: 0 0 auto;
  white-space: nowrap;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
}
.role {
  flex: 0 1 auto;
  min-width: 120px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.nav-badge { margin-left: 6px; }
.search-card { padding: 16px; }
.search-bar { grid-template-columns: minmax(220px, 1fr) auto auto; }
.search-bar .button { min-width: 112px; }

.terms-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f7f7f4;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.45;
}
.terms-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.terms-box {
  width: 22px;
  height: 22px;
  border: 1.5px solid #9da1a8;
  border-radius: 7px;
  background: #fff;
  margin-top: 2px;
  display: inline-grid;
  place-items: center;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.terms-box::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  transition: transform .15s ease;
}
.terms-card input:checked + .terms-box { background: var(--accent); border-color: var(--accent); }
.terms-card input:checked + .terms-box::after { transform: rotate(-45deg) scale(1); }
.terms-card:has(input:focus-visible) { box-shadow: 0 0 0 4px rgba(17,19,22,.08); border-color: var(--accent); }
.terms-text { display: grid; gap: 3px; }
.terms-text b { color: var(--ink); font-size: 14px; }
.terms-text span { color: var(--muted); font-size: 13px; }
.terms-text a { color: var(--ink); font-weight: 850; }

.messenger-card {
  height: min(720px, calc(100vh - 185px));
  min-height: 560px;
  max-height: 760px;
  overflow: hidden;
}
.messenger-sidebar,
.messenger-main {
  min-height: 0;
  height: 100%;
}
.messenger-sidebar { overflow: hidden; }
.chat-list { overflow-y: auto; min-height: 0; }
.messenger-main {
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.conversation {
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.message-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.chat-card-text b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-card-text .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
  .brand { min-width: 190px; }
  .logo-img { width: 200px; max-width: 200px; }
  .role { display: none; }
}
@media (max-width: 900px) {
  .topbar {
    position: sticky;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    gap: 10px;
  }
  .brand { min-width: 132px; }
  .logo-img { width: 132px; max-width: 132px; }
  .nav { justify-content: flex-start; gap: 7px; padding-bottom: 0; }
  .nav-link, .logout { padding: 8px 11px !important; font-size: 13px; min-height: 36px; }
  .messenger-card { height: calc(100vh - 142px); min-height: 560px; grid-template-columns: 1fr; }
  .messenger-sidebar { height: 210px; min-height: 210px; max-height: 210px; border-right: 0; border-bottom: 1px solid var(--line); }
  .messenger-main { height: calc(100% - 210px); min-height: 0; }
  .search-bar { grid-template-columns: 1fr; }
  .search-bar .button { width: 100%; }
}
@media (max-width: 640px) {
  .topbar { align-items: stretch; }
  .brand { display: none; }
  .nav { width: 100%; }
  .messenger-card { height: calc(100vh - 130px); min-height: 520px; }
  .messenger-sidebar { height: 180px; min-height: 180px; max-height: 180px; }
  .messenger-main { height: calc(100% - 180px); }
  .chat-header { padding: 13px 14px; }
  .chat-header h2 { font-size: 18px; }
  .conversation { padding: 12px; }
  .message-form { padding: 10px; }
  .terms-card { grid-template-columns: 22px 1fr; padding: 12px; }
}

/* v5 structural refinements */
.nav-link, .logout, .button { transform: none !important; transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease !important; }
.nav-link:hover, .logout:hover, .button:hover { transform: none !important; }
.card, .messenger-card, .message { animation: none !important; }
@keyframes messageIn { from { opacity: 1; transform: none; } to { opacity: 1; transform: none; } }
@keyframes softIn { from { opacity: 1; transform: none; } to { opacity: 1; transform: none; } }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #fafaf8; }
.action-cell { display: flex; gap: 8px; flex-wrap: wrap; }
.info-grid.single { grid-template-columns: 1fr; }
.separate-action { margin-top: 12px; }
.scroll-list { display: grid; gap: 10px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.completed-list { max-height: 300px; margin-top: 12px; }
.completed-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.completed-box summary { cursor: pointer; font-weight: 900; color: var(--ink); }
.work-item p { margin: 9px 0 0; }
.work-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.done-item { opacity: .84; }
.reports-list { max-height: 420px; overflow-y: auto; padding-right: 4px; }
.assign-list { display: grid; gap: 8px; max-height: 520px; overflow-y: auto; padding-right: 4px; }
.assign-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #f7f7f4; cursor: pointer; color: var(--ink); }
.assign-row input { width: auto; min-height: 0; margin-top: 4px; }
.assign-row span { display: grid; gap: 4px; }
.assign-row small { color: var(--muted); }
.toggle-form { margin: 0; }
.toggle-switch { width: 52px; height: 30px; border-radius: 999px; border: 1px solid var(--line); background: #c7c9c3; padding: 3px; cursor: pointer; display: inline-flex; align-items: center; justify-content: flex-start; }
.toggle-switch span { display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.toggle-switch.is-on { justify-content: flex-end; background: #111316; }
.messenger-card { height: min(780px, calc(100vh - 180px)); min-height: 600px; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.chat-search { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 8px; align-items: center; min-width: min(520px, 52%); }
.chat-search input { margin: 0; min-height: 40px; }
.message-action-form { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; height: 100%; overflow: hidden; }
.message-actions-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fff; }
.message-actions-bar select { width: auto; min-width: 230px; margin: 0; min-height: 40px; }
.conversation { height: 100%; max-height: none; overflow-y: auto; }
.message { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 10px; max-width: min(780px, 94%); }
.message.mine { grid-template-columns: auto 1fr; }
.message-select { display: flex; align-items: flex-start; padding-top: 2px; }
.message-select input { width: auto; min-height: 0; margin: 0; }
.message-content { min-width: 0; }
.attachment-card { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.72); border: 1px solid rgba(0,0,0,.10); }
.message.mine .attachment-card { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); }
.attachment-card a { font-weight: 900; }
.chat-image { display: block; max-width: min(340px, 100%); max-height: 260px; object-fit: contain; border-radius: 14px; margin-top: 10px; border: 1px solid rgba(0,0,0,.1); background: #fff; }
.chat-image-link { display: inline-block; }
.message-form { grid-template-columns: 1fr minmax(180px, 260px) auto; align-items: end; }
.message-form input[type="file"] { margin: 0; }
.messenger-main { grid-template-rows: auto minmax(0, 1fr) auto; }

@media (max-width: 900px) {
  .chat-header { display: grid; grid-template-columns: 1fr; }
  .chat-search { min-width: 0; width: 100%; grid-template-columns: 1fr; }
  .message-actions-bar { flex-wrap: wrap; }
  .message-actions-bar select { width: 100%; min-width: 0; }
  .message-form { grid-template-columns: 1fr; }
  .scroll-list, .reports-list { max-height: 360px; }
}
@media (max-width: 640px) {
  .message { max-width: 100%; }
  .chat-image { max-width: 100%; }
  .action-cell { display: grid; grid-template-columns: 1fr; }
}

/* v6 stability fixes */
.nav a:hover, .nav-link:hover, .logout:hover, .button:hover,
.nav a:focus, .nav-link:focus, .logout:focus, .button:focus {
  transform: none !important;
}
.nav a, .nav-link, .logout, .button {
  transform: none !important;
  translate: none !important;
}
.nav-link:hover {
  background: rgba(255,255,255,.14) !important;
  border-color: rgba(255,255,255,.34) !important;
  color: #fff !important;
}
.logout:hover { background: rgba(255,210,210,.10) !important; }
.button.primary:hover { background: #2b3036; }
.button.secondary:hover, .button.ghost:hover { background: #fff; }
.button.danger-outline {
  color: var(--danger);
  background: #fff;
  border: 1px solid rgba(180,35,24,.32);
}
.button.danger-outline:hover { background: #fff3f1; }

.users-table td[data-label="Активность профиля"] {
  white-space: nowrap;
}
.ios-switch {
  display: inline-flex;
  vertical-align: middle;
  align-items: center;
  cursor: pointer;
  user-select: none;
  margin-right: 10px;
}
.ios-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ios-slider {
  width: 54px;
  height: 32px;
  border-radius: 999px;
  background: #cfd2cc;
  border: 1px solid #b9bdb5;
  position: relative;
  display: inline-block;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.ios-slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(0,0,0,.22);
  transition: left .15s ease;
}
.ios-switch input:checked + .ios-slider {
  background: #111316;
  border-color: #111316;
}
.ios-switch input:checked + .ios-slider::before { left: 24px; }
.ios-switch input:disabled + .ios-slider { opacity: .55; cursor: wait; }
.activity-label { display: inline-block; color: var(--muted); font-size: 13px; vertical-align: middle; }
.profile-activity-control {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f7f7f4;
}
.profile-activity-control span { color: var(--muted); }
.profile-activity-control b { min-width: 110px; }

.messenger-v6 {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: min(780px, calc(100vh - 180px));
  min-height: 620px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(17,19,22,.08);
}
.dialog-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  background: #f4f4f1;
  border-right: 1px solid var(--line);
}
.dialog-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.dialog-panel-head b {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 12px;
}
.dialog-panel-head span {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  font-weight: 900;
}
.dialog-list {
  min-height: 0;
  overflow-y: auto;
}
.dialog-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  background: transparent;
  align-items: center;
}
.dialog-item:hover { background: #fff; }
.dialog-item.active {
  background: #fff;
  box-shadow: inset 4px 0 0 var(--accent);
}
.dialog-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #191c20;
  color: #fff;
  font-weight: 950;
  flex: 0 0 auto;
}
.dialog-avatar.large { width: 50px; height: 50px; }
.dialog-text { min-width: 0; display: grid; gap: 2px; }
.dialog-text strong, .dialog-text small, .dialog-text em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dialog-text strong { font-size: 14px; }
.dialog-text small { color: var(--muted); font-size: 12px; font-style: normal; }
.dialog-text em { color: var(--muted); font-size: 12px; font-style: normal; }
.dialog-unread {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #111316;
  color: #fff;
  font-size: 12px;
  font-weight: 950;
}
.chat-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fbfbfa;
}
.chat-top {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 520px);
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.chat-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-person h2 {
  margin: 0;
  font-size: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-person p { margin: 4px 0 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-search-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}
.message-search-form input { min-height: 40px; margin: 0; }
.message-search-form .button { min-height: 40px; padding: 8px 13px; }
.chat-workspace {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.bulk-actions span { color: var(--muted); font-size: 13px; min-width: 86px; }
.bulk-actions select { width: 220px; min-height: 38px; margin: 0; }
.bulk-actions .button { min-height: 38px; padding: 8px 12px; }
.chat-scroll {
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  background:
    radial-gradient(circle at 0 0, rgba(0,0,0,.04), transparent 28%),
    linear-gradient(180deg, #fbfbfa 0%, #f1f1ee 100%);
}
.bubble-row {
  display: grid;
  grid-template-columns: 26px minmax(0, min(680px, 86%));
  gap: 9px;
  align-items: start;
  margin-bottom: 12px;
}
.bubble-row.mine { justify-content: end; grid-template-columns: 26px minmax(0, min(680px, 86%)); }
.bubble-check { padding-top: 10px; cursor: pointer; }
.bubble-check input { position: absolute; opacity: 0; }
.bubble-check span {
  width: 18px;
  height: 18px;
  display: block;
  border: 1px solid #b9bdb5;
  border-radius: 6px;
  background: #fff;
}
.bubble-check input:checked + span { background: #111316; border-color: #111316; box-shadow: inset 0 0 0 4px #fff; }
.bubble {
  border: 1px solid var(--line);
  border-radius: 19px;
  padding: 12px 14px;
  background: #fff;
  min-width: 0;
  box-shadow: 0 8px 18px rgba(17,19,22,.04);
}
.bubble-row.mine .bubble { background: #1f2328; color: #fff; border-color: #1f2328; }
.bubble header {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  align-items: center;
  font-size: 12px;
  opacity: .78;
  margin-bottom: 7px;
}
.bubble header b { font-size: 13px; }
.bubble header time { opacity: .76; }
.bubble-text { white-space: pre-wrap; line-height: 1.48; overflow-wrap: anywhere; }
.bubble-image {
  display: block;
  width: auto;
  max-width: min(360px, 100%);
  max-height: 280px;
  object-fit: contain;
  border-radius: 14px;
  margin-top: 10px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.10);
}
.file-chip {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 13px;
  padding: 10px 12px;
  background: #f2f2ef;
  border: 1px solid rgba(0,0,0,.09);
}
.bubble-row.mine .file-chip { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.24); }
.file-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip a { font-weight: 900; }
.composer {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--line);
}
.composer textarea {
  min-height: 48px;
  max-height: 140px;
  margin: 0;
  resize: vertical;
}
.file-button input { position: absolute; opacity: 0; pointer-events: none; }
.file-button span {
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 850;
  cursor: pointer;
}
.file-button span:hover { background: #fff; }
.empty-state { color: var(--muted); padding: 18px; }
.empty-state.center { text-align: center; align-self: center; justify-self: center; }
.empty-state.stretch { min-height: 100%; display: grid; place-items: center; }

@media (max-width: 1050px) {
  .messenger-v6 { grid-template-columns: 300px minmax(0, 1fr); }
  .chat-top { grid-template-columns: 1fr; }
  .message-search-form { grid-template-columns: 1fr auto auto; }
}
@media (max-width: 760px) {
  .messenger-v6 {
    grid-template-columns: 1fr;
    grid-template-rows: 210px minmax(0, 1fr);
    height: calc(100vh - 132px);
    min-height: 620px;
  }
  .dialog-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-top { padding: 12px; gap: 10px; }
  .message-search-form { grid-template-columns: 1fr; }
  .bulk-actions { flex-wrap: wrap; }
  .bulk-actions select { width: 100%; }
  .chat-scroll { padding: 12px; }
  .bubble-row, .bubble-row.mine { grid-template-columns: 22px minmax(0, 1fr); }
  .composer { grid-template-columns: 1fr; }
  .composer .button, .file-button span { width: 100%; }
  .chat-person h2 { font-size: 18px; }
}
@media (max-width: 640px) {
  .activity-label { display: block; margin-top: 6px; }
  .ios-switch { margin-right: 0; }
  .profile-activity-control { align-items: flex-start; flex-direction: column; }
}

/* v7 cleanup: stable navigation, clean work cards, iOS toggles, v4-style messenger */
.topbar,
.nav,
.nav-link,
.logout {
  overflow: visible !important;
}
.nav a,
.nav-link,
.logout,
.button {
  transform: none !important;
  translate: none !important;
  top: auto !important;
  border-bottom-color: transparent !important;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease, opacity .14s ease, box-shadow .14s ease !important;
}
.nav a:hover,
.nav-link:hover,
.logout:hover,
.button:hover,
.nav a:focus,
.nav-link:focus,
.logout:focus,
.button:focus {
  transform: none !important;
  translate: none !important;
  border-bottom-color: transparent !important;
}
.nav-link {
  height: 40px !important;
  min-height: 40px !important;
  line-height: 1 !important;
  padding: 0 15px !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
  border: 0 !important;
}
.nav-link:hover {
  background: rgba(255,255,255,.15) !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.36);
}
.logout {
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 15px !important;
  border: 0 !important;
  box-shadow: inset 0 0 0 1px rgba(255,210,210,.28);
}
.logout:hover { box-shadow: inset 0 0 0 1px rgba(255,210,210,.48); }

.ios-toggle {
  width: 56px;
  height: 32px;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: #cfd2cc;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px #b7bbb4;
  transition: background-color .15s ease, opacity .15s ease, box-shadow .15s ease !important;
}
.ios-toggle span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(0,0,0,.24);
  transition: margin-left .15s ease !important;
}
.ios-toggle.is-on {
  background: #111316;
  box-shadow: inset 0 0 0 1px #111316;
}
.ios-toggle.is-on span { margin-left: 24px; }
.ios-toggle:disabled { opacity: .55; cursor: wait; }
.ios-toggle:hover { background: #bcc0ba; }
.ios-toggle.is-on:hover { background: #2a2e34; }
.activity-label { margin-left: 8px; }
.profile-activity-control .ios-toggle { flex: 0 0 auto; }

/* clean task/agreement blocks */
#tasks .scroll-list,
#agreements .scroll-list {
  gap: 12px;
  max-height: 440px;
  padding-right: 8px;
}
.work-item {
  display: grid;
  gap: 9px;
  padding: 16px;
  margin: 0;
  background: #f8f8f5;
  border: 1px solid #d9dad4;
  border-radius: 18px;
  overflow: hidden;
}
.work-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
}
.work-head b {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
  font-size: 15px;
}
.work-head .pill {
  justify-self: end;
  white-space: nowrap;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.work-item .muted.small {
  display: block;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.work-item p {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.work-item .form-actions {
  margin-top: 2px;
  padding-top: 9px;
  border-top: 1px solid rgba(0,0,0,.06);
}
.completed-box {
  display: block;
  background: #fbfbfa;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
.completed-box summary {
  list-style-position: inside;
  margin-bottom: 10px;
}
.mini-form {
  display: grid;
  gap: 12px;
}
.inline-form.compact {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 180px) auto;
  gap: 10px;
  align-items: center;
}
.inline-form.compact .check {
  align-self: center;
  padding: 0 2px;
}
.inline-form.compact .button { white-space: nowrap; }

/* return chats to a clean v4-like messenger while keeping v6 functions */
.messenger-v7 {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: min(760px, calc(100vh - 180px));
  min-height: 620px;
  overflow: hidden;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 14px 38px rgba(17,19,22,.06);
}
.messenger-v7 .messenger-sidebar {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: #f3f3ef;
  overflow: hidden;
}
.messenger-v7 .messenger-title {
  padding: 18px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.messenger-v7 .chat-list {
  min-height: 0;
  overflow-y: auto;
}
.messenger-v7 .chat-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  border-radius: 0;
  border-width: 0 0 1px 0;
  background: transparent;
  padding: 14px 16px;
  align-items: center;
  text-decoration: none;
}
.messenger-v7 .chat-card.active {
  background: #fff;
  box-shadow: inset 4px 0 0 var(--accent);
}
.messenger-v7 .chat-card:hover { background: #fff; }
.messenger-v7 .chat-card-text { min-width: 0; }
.messenger-v7 .chat-card-text b,
.messenger-v7 .chat-card-text .small,
.messenger-v7 .chat-card-text p {
  display: block;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.messenger-v7 .chat-card-text p { margin-top: 5px; }
.messenger-v7 .avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #1f2328;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 950;
}
.messenger-v7 .small-avatar { width: 44px; height: 44px; }
.messenger-v7 .messenger-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fbfbfa;
}
.messenger-v7 .chat-header {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 520px);
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.chat-title-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.chat-title-block h2 {
  margin: 0 0 4px;
  font-size: 22px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-title-block .muted {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.chat-search-v7 {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}
.chat-search-v7 input { margin: 0; min-height: 40px; }
.chat-search-v7 .button { min-height: 40px; padding: 8px 12px; }
.message-action-form-v7 {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.message-actions-bar-v7 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.message-actions-bar-v7 span { color: var(--muted); font-size: 13px; min-width: 86px; }
.message-actions-bar-v7 select { width: 220px; min-height: 38px; margin: 0; }
.message-actions-bar-v7 .button { min-height: 38px; padding: 8px 12px; }
.messenger-v7 .conversation {
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  padding: 20px;
  align-content: start;
  background: linear-gradient(180deg, #fbfbfa 0%, #f3f3ef 100%);
}
.message-row {
  display: grid;
  grid-template-columns: 24px minmax(0, min(760px, 88%));
  gap: 8px;
  align-items: start;
  margin-bottom: 12px;
}
.message-row.mine {
  justify-content: end;
}
.message-picker {
  padding-top: 10px;
  cursor: pointer;
}
.message-picker input { position: absolute; opacity: 0; pointer-events: none; }
.message-picker span {
  width: 18px;
  height: 18px;
  display: block;
  border: 1px solid #b9bdb5;
  border-radius: 6px;
  background: #fff;
}
.message-picker input:checked + span {
  background: #111316;
  border-color: #111316;
  box-shadow: inset 0 0 0 4px #fff;
}
.messenger-v7 .message {
  display: block;
  max-width: none;
  width: 100%;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(17,19,22,.04);
}
.messenger-v7 .message.mine {
  background: #1f2328;
  color: #fff;
  border-color: #1f2328;
}
.messenger-v7 .message.theirs { background: #fff; }
.messenger-v7 .message-meta {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  opacity: .72;
}
.messenger-v7 .message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.message-form-v7 {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.message-form-v7 textarea { margin: 0; resize: vertical; max-height: 180px; }
.file-button-v7 input { position: absolute; opacity: 0; pointer-events: none; }
.file-button-v7 span {
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 850;
  cursor: pointer;
}
.file-button-v7 span:hover { background: #fff; }

@media (max-width: 1050px) {
  .messenger-v7 { grid-template-columns: 300px minmax(0, 1fr); }
  .messenger-v7 .chat-header { grid-template-columns: 1fr; }
  .chat-search-v7 { grid-template-columns: 1fr auto auto; }
}
@media (max-width: 900px) {
  .nav { overflow-x: auto !important; overflow-y: visible !important; }
  .inline-form.compact { grid-template-columns: 1fr; }
  .work-head { grid-template-columns: 1fr; }
  .work-head .pill { justify-self: start; max-width: 100%; }
}
@media (max-width: 760px) {
  .messenger-v7 {
    grid-template-columns: 1fr;
    grid-template-rows: 210px minmax(0, 1fr);
    height: calc(100vh - 132px);
    min-height: 620px;
  }
  .messenger-v7 .messenger-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .messenger-v7 .chat-header { padding: 12px; }
  .chat-search-v7 { grid-template-columns: 1fr; }
  .message-actions-bar-v7 select { width: 100%; }
  .messenger-v7 .conversation { padding: 12px; }
  .message-row,
  .message-row.mine { grid-template-columns: 22px minmax(0, 1fr); }
  .message-form-v7 { grid-template-columns: 1fr; }
  .message-form-v7 .button,
  .file-button-v7 span { width: 100%; }
}
@media (max-width: 640px) {
  .activity-label { display: inline-block; margin-left: 6px; margin-top: 0; }
  .ios-toggle { width: 54px; height: 31px; }
}

/* v8 messenger: clean messenger-style chat with attachments, previews, soft-delete, stable scroll */
.messenger-pro {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: min(780px, calc(100vh - 170px));
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255,255,255,.96);
  overflow: hidden;
  box-shadow: 0 16px 42px rgba(17,19,22,.07);
}
.dialog-column {
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #f4f4f0;
}
.dialog-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 950;
}
.dialog-column-head span {
  min-width: 28px;
  min-height: 28px;
  padding: 4px 8px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #111316;
  color: #fff;
  font-size: 12px;
}
.dialog-list-pro {
  overflow-y: auto;
  min-height: 0;
}
.dialog-link {
  display: grid;
  grid-template-columns: 44px minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  text-decoration: none;
  color: var(--text);
  background: transparent;
}
.dialog-link:hover { background: rgba(255,255,255,.8); }
.dialog-link.active { background: #fff; box-shadow: inset 4px 0 0 var(--accent); }
.dialog-avatar-pro {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #111316;
  color: #fff;
  font-weight: 950;
  flex: 0 0 auto;
}
.dialog-avatar-pro.large { width: 50px; height: 50px; }
.dialog-info-pro { display: grid; gap: 2px; min-width: 0; }
.dialog-info-pro strong,
.dialog-info-pro small,
.dialog-info-pro em {
  display: block;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dialog-info-pro strong { font-size: 14px; }
.dialog-info-pro small { color: var(--muted); font-size: 12px; font-style: normal; }
.dialog-info-pro em { color: var(--muted); font-size: 12px; font-style: normal; }
.dialog-badge {
  min-width: 22px;
  height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #111316;
  color: #fff;
  font-size: 12px;
  display: grid;
  place-items: center;
}
.chat-column {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  background: #fbfbfa;
}
.chat-head-pro {
  display: grid;
  grid-template-columns: minmax(230px,1fr) minmax(260px,520px);
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.chat-companion {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.chat-companion h2 {
  margin: 0 0 4px;
  font-size: 21px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-companion p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-search-pro {
  display: grid;
  grid-template-columns: minmax(120px,1fr) auto auto;
  gap: 8px;
  align-items: center;
}
.chat-search-pro input { margin: 0; min-height: 40px; }
.chat-search-pro .button { min-height: 40px; padding: 8px 12px; }
.chat-action-shell {
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  min-height: 0;
  overflow: hidden;
}
.chat-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-wrap: wrap;
}
.chat-action-bar span { color: var(--muted); font-size: 13px; min-width: 86px; }
.chat-action-bar select { width: 230px; min-height: 38px; margin: 0; }
.chat-action-bar .button { min-height: 38px; padding: 8px 12px; }
.message-scroll {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(0,0,0,.025), transparent 26%),
    linear-gradient(180deg, #fbfbfa 0%, #f1f1ed 100%);
}
.bubble-row {
  display: grid;
  grid-template-columns: 24px minmax(0, min(760px, 86%));
  gap: 8px;
  align-items: start;
  margin-bottom: 12px;
}
.bubble-row.mine { justify-content: end; }
.bubble-select { padding-top: 11px; cursor: pointer; }
.bubble-select.empty { width: 24px; min-height: 1px; }
.bubble-select input { position: absolute; opacity: 0; pointer-events: none; }
.bubble-select span {
  width: 18px;
  height: 18px;
  display: block;
  border-radius: 6px;
  border: 1px solid #b9bdb5;
  background: #fff;
}
.bubble-select input:checked + span {
  background: #111316;
  border-color: #111316;
  box-shadow: inset 0 0 0 4px #fff;
}
.bubble {
  width: 100%;
  max-width: none;
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  box-shadow: 0 8px 18px rgba(17,19,22,.04);
  overflow: hidden;
}
.bubble.mine { background: #1f2328; color: #fff; border-color: #1f2328; border-bottom-right-radius: 8px; }
.bubble.theirs { background: #fff; color: var(--text); border-bottom-left-radius: 8px; }
.bubble.deleted { opacity: .72; font-style: italic; }
.bubble-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  font-size: 12px;
  opacity: .72;
  margin-bottom: 7px;
}
.bubble-meta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble-meta time { flex: 0 0 auto; white-space: nowrap; }
.bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.deleted-text { color: inherit; }
.bubble-attachment { display: grid; gap: 8px; margin-top: 10px; }
.image-preview-link { display: inline-block; width: fit-content; max-width: 100%; }
.image-preview {
  display: block;
  max-width: min(360px,100%);
  max-height: 260px;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.12);
  background: #fff;
}
.file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  padding: 10px;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 14px;
  background: rgba(255,255,255,.65);
}
.bubble.mine .file-preview { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.22); }
.file-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #111316;
  color: #fff;
  font-size: 10px;
  font-weight: 950;
}
.bubble.mine .file-icon { background: #fff; color: #111316; }
.file-preview strong,
.file-preview small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.file-preview small { color: var(--muted); font-size: 12px; }
.bubble.mine .file-preview small { color: rgba(255,255,255,.72); }
.download-link {
  width: fit-content;
  color: inherit;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.compose-bar {
  display: grid;
  grid-template-columns: minmax(180px,1fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.compose-bar textarea { margin: 0; resize: vertical; max-height: 160px; }
.attach-button input { position: absolute; opacity: 0; pointer-events: none; }
.attach-button span {
  min-height: 44px;
  padding: 11px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  font-weight: 850;
  cursor: pointer;
  white-space: nowrap;
}
.attach-button span:hover { background: #fff; }
.chosen-file {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  min-height: 0;
}
.empty-chat-pro {
  margin: auto;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}
.empty-chat-pro.big { align-self: center; }
.small-empty { padding: 18px; }

@media (max-width: 1050px) {
  .messenger-pro { grid-template-columns: 300px minmax(0,1fr); }
  .chat-head-pro { grid-template-columns: 1fr; }
  .chat-search-pro { grid-template-columns: 1fr auto auto; }
}
@media (max-width: 760px) {
  .messenger-pro {
    grid-template-columns: 1fr;
    grid-template-rows: 220px minmax(0,1fr);
    height: calc(100vh - 132px);
    min-height: 660px;
    border-radius: 20px;
  }
  .dialog-column { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-head-pro { padding: 12px; }
  .chat-search-pro { grid-template-columns: 1fr; }
  .chat-action-bar select { width: 100%; }
  .message-scroll { padding: 12px; }
  .bubble-row,
  .bubble-row.mine { grid-template-columns: 22px minmax(0,1fr); }
  .bubble-meta { display: grid; gap: 3px; }
  .compose-bar { grid-template-columns: 1fr; }
  .compose-bar .button,
  .attach-button span { width: 100%; }
}

/* v9: stable task/agreement cards and clean messenger interface */
.nav a,
.nav-link,
.logout,
.button,
.button:hover,
.button:focus,
.button:active {
  transform: none !important;
  translate: none !important;
}

#tasks .scroll-list,
#agreements .scroll-list,
.completed-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  max-height: 430px !important;
  overflow-y: auto !important;
  padding: 2px 8px 4px 2px !important;
  align-items: stretch !important;
}
#tasks .scroll-list > *,
#agreements .scroll-list > *,
.completed-list > * {
  flex: 0 0 auto;
}
#tasks .work-item,
#agreements .work-item,
.completed-list .work-item {
  margin: 0 !important;
  width: 100%;
  box-sizing: border-box;
  display: grid !important;
  gap: 10px !important;
  padding: 16px !important;
  border-radius: 18px !important;
  border: 1px solid #d9dad4 !important;
  background: #f8f8f5 !important;
}
.work-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: 14px !important;
  align-items: start !important;
}
.work-head b {
  min-width: 0;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.work-head .pill {
  justify-self: end;
  align-self: start;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.work-item .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.work-item form { margin: 0; }
.completed-box { margin-top: 14px; }

.messenger-clean {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: min(780px, calc(100vh - 170px));
  min-height: 640px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(17,19,22,.07);
}
.clean-sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #f3f3ef;
  overflow: hidden;
}
.dialog-search-box {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfbfa;
}
.dialog-search-box input {
  margin: 0;
  min-height: 40px;
  border-radius: 999px;
}
.clean-dialog-list {
  min-height: 0;
  overflow-y: auto;
}
.clean-dialog-card {
  display: grid !important;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 13px 15px !important;
  border-radius: 0 !important;
  border: 0 !important;
  border-bottom: 1px solid rgba(0,0,0,.06) !important;
  background: transparent !important;
  color: var(--ink) !important;
  text-decoration: none;
  transform: none !important;
}
.clean-dialog-card:hover { background: #fff !important; }
.clean-dialog-card.active { background: #fff !important; box-shadow: inset 4px 0 0 var(--accent); }
.clean-dialog-card .chat-card-text { min-width: 0; }
.clean-dialog-card .chat-card-text b,
.clean-dialog-card .chat-card-text .small,
.clean-dialog-card .chat-card-text p {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.clean-dialog-card .chat-card-text p { margin-top: 5px; }
.large-avatar { width: 50px !important; height: 50px !important; }
.clean-chat-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fbfbfa;
  overflow: hidden;
}
.clean-chat-header {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 520px);
  gap: 14px;
  align-items: center;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.chat-contact-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.chat-contact-title h2 {
  margin: 0 0 4px;
  font-size: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-contact-title .muted {
  display: block;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clean-message-search {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}
.clean-message-search input { margin: 0; min-height: 40px; }
.clean-message-search .button { min-height: 40px; padding: 8px 12px; }
.clean-conversation {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: linear-gradient(180deg, #fbfbfa 0%, #f1f1ed 100%);
}
.message-shell {
  display: flex;
  margin-bottom: 12px;
}
.message-shell.mine { justify-content: flex-end; }
.message-shell.theirs { justify-content: flex-start; }
.clean-message {
  max-width: min(760px, 86%) !important;
  min-width: min(230px, 100%);
  display: block !important;
  padding: 12px 14px !important;
  border-radius: 20px !important;
  border: 1px solid var(--line) !important;
  box-shadow: 0 8px 18px rgba(17,19,22,.04);
  overflow: hidden;
}
.clean-message.mine {
  background: #1f2328 !important;
  color: #fff !important;
  border-color: #1f2328 !important;
  border-bottom-right-radius: 8px !important;
}
.clean-message.theirs {
  background: #fff !important;
  color: var(--ink) !important;
  border-bottom-left-radius: 8px !important;
}
.clean-message.deleted { opacity: .72; font-style: italic; }
.clean-message-meta {
  display: flex !important;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 7px !important;
  font-size: 12px;
  opacity: .72;
}
.clean-message-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clean-message-meta time { flex: 0 0 auto; white-space: nowrap; }
.clean-message .message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.deleted-note { color: inherit; }
.message-attachment-clean {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.chat-image-clean {
  display: block;
  max-width: min(360px, 100%);
  max-height: 260px;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.12);
  background: #fff;
}
.file-card-clean {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  padding: 10px;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 14px;
  background: rgba(255,255,255,.7);
  color: inherit;
  text-decoration: none;
}
.clean-message.mine .file-card-clean { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.24); }
.file-card-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #111316;
  color: #fff;
  font-size: 10px;
  font-weight: 950;
  flex: 0 0 auto;
}
.clean-message.mine .file-card-icon { background: #fff; color: #111316; }
.file-card-clean b,
.file-card-clean small {
  display: block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-card-clean small { color: var(--muted); font-size: 12px; }
.clean-message.mine .file-card-clean small { color: rgba(255,255,255,.72); }
.download-link-clean {
  width: fit-content;
  color: inherit;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.delete-message-form {
  margin: 8px 0 0;
  text-align: right;
}
.delete-message-form button {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: .68;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}
.delete-message-form button:hover { opacity: 1; text-decoration: underline; }
.clean-compose {
  display: grid !important;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.clean-compose textarea { margin: 0; resize: vertical; max-height: 150px; }
.paperclip-button input { position: absolute; opacity: 0; pointer-events: none; }
.paperclip-button span {
  width: 46px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 20px;
  cursor: pointer;
}
.paperclip-button span:hover { background: #fff; }
.chosen-file {
  grid-column: 1 / -1;
  min-height: 0;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1050px) {
  .messenger-clean { grid-template-columns: 300px minmax(0, 1fr); }
  .clean-chat-header { grid-template-columns: 1fr; }
  .clean-message-search { grid-template-columns: 1fr auto auto; }
}
@media (max-width: 900px) {
  .work-head { grid-template-columns: 1fr !important; }
  .work-head .pill { justify-self: start; max-width: 100%; }
}
@media (max-width: 760px) {
  .messenger-clean {
    grid-template-columns: 1fr;
    grid-template-rows: 220px minmax(0, 1fr);
    height: calc(100vh - 132px);
    min-height: 660px;
    border-radius: 20px;
  }
  .clean-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .clean-chat-header { padding: 12px; }
  .clean-message-search { grid-template-columns: 1fr; }
  .clean-conversation { padding: 12px; }
  .clean-message { max-width: 100% !important; }
  .clean-message-meta { display: grid !important; gap: 3px; }
  .clean-compose { grid-template-columns: 1fr !important; }
  .paperclip-button span, .clean-compose .button { width: 100%; }
  #tasks .scroll-list,
  #agreements .scroll-list,
  .completed-list { max-height: 360px !important; }
}

/* v10: fixed spacing in tasks/agreements and restored v4-like chats */
#tasks .scroll-list,
#agreements .scroll-list,
#tasks details .scroll-list,
#agreements details .scroll-list {
  display: block !important;
  max-height: 430px !important;
  overflow-y: auto !important;
  padding: 4px 10px 8px 2px !important;
}
#tasks .scroll-list > .item-block,
#agreements .scroll-list > .item-block,
#tasks details .scroll-list > .item-block,
#agreements details .scroll-list > .item-block {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  margin: 0 0 18px 0 !important;
  padding: 18px 20px !important;
  border: 1px solid #d7d8d2 !important;
  border-radius: 18px !important;
  background: #f8f8f5 !important;
  box-shadow: 0 8px 22px rgba(17, 19, 22, .035) !important;
}
#tasks .scroll-list > .item-block:last-child,
#agreements .scroll-list > .item-block:last-child,
#tasks details .scroll-list > .item-block:last-child,
#agreements details .scroll-list > .item-block:last-child {
  margin-bottom: 0 !important;
}
#tasks .work-head,
#agreements .work-head {
  display: flex !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  gap: 28px !important;
  width: 100% !important;
  margin-bottom: 8px !important;
}
#tasks .work-head b,
#agreements .work-head b {
  display: block !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
  line-height: 1.3 !important;
  overflow-wrap: anywhere !important;
}
#tasks .work-head .pill,
#agreements .work-head .pill {
  flex: 0 0 auto !important;
  margin-left: auto !important;
  align-self: flex-start !important;
  white-space: nowrap !important;
  max-width: 220px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  position: static !important;
}
#tasks .work-item p,
#agreements .work-item p {
  margin: 10px 0 0 !important;
}
#tasks .work-item .form-actions,
#agreements .work-item .form-actions {
  margin-top: 12px !important;
  display: flex !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
}
.completed-box { margin-top: 18px !important; }
.completed-box summary { cursor: pointer; }

.messenger-v4-clean {
  display: grid !important;
  grid-template-columns: 340px minmax(0, 1fr) !important;
  height: min(760px, calc(100vh - 180px)) !important;
  min-height: 620px !important;
  overflow: hidden !important;
  border: 1px solid var(--line) !important;
  border-radius: 24px !important;
  background: #fff !important;
  box-shadow: 0 16px 42px rgba(17,19,22,.07) !important;
}
.messenger-v4-clean .messenger-sidebar {
  min-height: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
  border-right: 1px solid var(--line) !important;
  background: #f3f3ef !important;
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) !important;
}
.messenger-v4-clean .messenger-title {
  padding: 16px 16px 12px !important;
  font-weight: 950 !important;
}
.dialog-search-simple {
  padding: 0 14px 14px !important;
  border-bottom: 1px solid var(--line) !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: 8px !important;
}
.dialog-search-simple input { margin: 0 !important; min-height: 40px !important; border-radius: 999px !important; }
.dialog-search-simple .button { min-height: 40px !important; padding: 8px 12px !important; }
.dialog-search-simple .button.ghost { grid-column: 1 / -1; width: fit-content; }
.messenger-v4-clean .chat-list {
  min-height: 0 !important;
  overflow-y: auto !important;
  display: block !important;
  padding: 0 !important;
}
.messenger-v4-clean .chat-card {
  display: grid !important;
  grid-template-columns: 44px minmax(0, 1fr) auto !important;
  gap: 12px !important;
  align-items: center !important;
  padding: 14px 15px !important;
  min-height: 74px !important;
  border: 0 !important;
  border-bottom: 1px solid rgba(0,0,0,.06) !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--ink) !important;
  text-decoration: none !important;
  transform: none !important;
}
.messenger-v4-clean .chat-card:hover { background: #fff !important; }
.messenger-v4-clean .chat-card.active { background: #fff !important; box-shadow: inset 4px 0 0 var(--accent) !important; }
.messenger-v4-clean .chat-card-text { min-width: 0 !important; }
.messenger-v4-clean .chat-card-text b,
.messenger-v4-clean .chat-card-text .small,
.messenger-v4-clean .chat-card-text p {
  display: block !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  margin: 0 !important;
}
.messenger-v4-clean .chat-card-text p { margin-top: 5px !important; color: var(--muted) !important; }
.messenger-v4-clean .messenger-main {
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  background: #fbfbfa !important;
}
.messenger-v4-clean .chat-header {
  padding: 16px 20px !important;
  border-bottom: 1px solid var(--line) !important;
  background: #fff !important;
}
.messenger-v4-clean .chat-header h2 { margin: 0 0 4px !important; font-size: 22px !important; }
.messenger-v4-clean .conversation {
  display: grid !important;
  align-content: start !important;
  gap: 12px !important;
  min-height: 0 !important;
  height: 100% !important;
  max-height: none !important;
  overflow-y: auto !important;
  padding: 20px !important;
  background: linear-gradient(180deg, #fbfbfa 0%, #f1f1ed 100%) !important;
}
.messenger-v4-clean .message {
  display: block !important;
  grid-template-columns: none !important;
  width: fit-content !important;
  max-width: min(760px, 86%) !important;
  min-width: min(230px, 100%) !important;
  padding: 12px 14px !important;
  border-radius: 18px !important;
  border: 1px solid var(--line) !important;
  box-shadow: 0 8px 18px rgba(17,19,22,.04) !important;
  transform: none !important;
}
.messenger-v4-clean .message.mine { justify-self: end !important; background: #1f2328 !important; color: #fff !important; border-color: #1f2328 !important; border-bottom-right-radius: 8px !important; }
.messenger-v4-clean .message.theirs { justify-self: start !important; background: #fff !important; color: var(--ink) !important; border-bottom-left-radius: 8px !important; }
.messenger-v4-clean .message.deleted { opacity: .72 !important; font-style: italic !important; }
.messenger-v4-clean .message-meta { display: block !important; font-size: 12px !important; opacity: .72 !important; margin: 0 0 7px !important; }
.messenger-v4-clean .message-body { white-space: pre-wrap !important; line-height: 1.5 !important; overflow-wrap: anywhere !important; }
.message-attachment-v4 { display: grid; gap: 8px; margin-top: 10px; }
.chat-image-v4 { display: block; max-width: min(340px, 100%); max-height: 250px; object-fit: contain; border-radius: 14px; border: 1px solid rgba(0,0,0,.12); background: #fff; }
.attachment-link, .attachment-file-v4 { color: inherit; font-weight: 850; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.delete-message-form-v4 { margin: 8px 0 0 !important; text-align: right !important; }
.delete-message-form-v4 button { border: 0; background: transparent; color: inherit; opacity: .68; font-size: 12px; font-weight: 800; cursor: pointer; padding: 0; }
.delete-message-form-v4 button:hover { opacity: 1; text-decoration: underline; }
.message-form-v4 {
  display: grid !important;
  grid-template-columns: auto minmax(180px, 1fr) auto !important;
  gap: 10px !important;
  align-items: end !important;
  padding: 12px !important;
  border-top: 1px solid var(--line) !important;
  background: #fff !important;
}
.message-form-v4 textarea { margin: 0 !important; resize: vertical !important; max-height: 150px !important; }
.attach-button-v4 input { position: absolute; opacity: 0; pointer-events: none; }
.attach-button-v4 span { width: 46px; height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--accent-soft); font-size: 20px; cursor: pointer; }
.attach-button-v4 span:hover { background: #fff; }
.chosen-file-v4 { grid-column: 1 / -1; min-height: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  #tasks .work-head,
  #agreements .work-head { gap: 12px !important; }
  #tasks .work-head .pill,
  #agreements .work-head .pill { max-width: 160px !important; }
}
@media (max-width: 760px) {
  .messenger-v4-clean {
    grid-template-columns: 1fr !important;
    grid-template-rows: 230px minmax(0, 1fr) !important;
    height: calc(100vh - 132px) !important;
    min-height: 660px !important;
    border-radius: 20px !important;
  }
  .messenger-v4-clean .messenger-sidebar { border-right: 0 !important; border-bottom: 1px solid var(--line) !important; }
  .dialog-search-simple { grid-template-columns: 1fr auto !important; }
  .messenger-v4-clean .conversation { padding: 12px !important; }
  .messenger-v4-clean .message { max-width: 100% !important; }
  .message-form-v4 { grid-template-columns: 1fr !important; }
  .attach-button-v4 span, .message-form-v4 .button { width: 100%; }
  #tasks .scroll-list,
  #agreements .scroll-list,
  #tasks details .scroll-list,
  #agreements details .scroll-list { max-height: 360px !important; }
  #tasks .work-head,
  #agreements .work-head { flex-wrap: wrap !important; }
  #tasks .work-head .pill,
  #agreements .work-head .pill { margin-left: 0 !important; max-width: 100% !important; }
}


/* v11 final polish: stronger task/agreement spacing, stable responsive layout, corrected chat composer */
.two-col,
.profile-grid,
.grid-form,
.info-grid {
  min-width: 0;
}
#tasks,
#agreements {
  min-width: 0;
  overflow: hidden;
}
#tasks .work-list,
#agreements .work-list,
.completed-list.work-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 18px !important;
  row-gap: 18px !important;
  max-height: 440px !important;
  overflow-y: auto !important;
  padding: 4px 10px 10px 2px !important;
  margin-top: 12px !important;
  scrollbar-width: thin;
}
#tasks .work-list > .work-item,
#agreements .work-list > .work-item,
.completed-list.work-list > .work-item,
#tasks .scroll-list > .work-item,
#agreements .scroll-list > .work-item {
  flex: 0 0 auto !important;
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 18px 20px !important;
  border: 1px solid #d5d6d0 !important;
  border-radius: 18px !important;
  background: #f8f8f5 !important;
  box-shadow: 0 8px 22px rgba(17, 19, 22, .045) !important;
}
#tasks .work-list > .work-item + .work-item,
#agreements .work-list > .work-item + .work-item,
.completed-list.work-list > .work-item + .work-item,
#tasks .scroll-list > .work-item + .work-item,
#agreements .scroll-list > .work-item + .work-item {
  margin-top: 18px !important;
}
#tasks .work-head,
#agreements .work-head,
.completed-list .work-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) max-content !important;
  column-gap: 24px !important;
  row-gap: 8px !important;
  align-items: start !important;
  width: 100% !important;
  margin-bottom: 8px !important;
}
#tasks .work-head b,
#agreements .work-head b,
.completed-list .work-head b {
  display: block !important;
  min-width: 0 !important;
  max-width: 100% !important;
  line-height: 1.32 !important;
  overflow-wrap: anywhere !important;
  word-break: normal !important;
}
#tasks .work-head .pill,
#agreements .work-head .pill,
.completed-list .work-head .pill {
  justify-self: end !important;
  align-self: start !important;
  margin-left: 0 !important;
  white-space: nowrap !important;
  max-width: 220px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  position: static !important;
}
#tasks .work-item p,
#agreements .work-item p,
.completed-list .work-item p {
  margin: 10px 0 0 !important;
  line-height: 1.5 !important;
  overflow-wrap: anywhere !important;
}
#tasks .work-item .muted.small,
#agreements .work-item .muted.small,
.completed-list .work-item .muted.small {
  line-height: 1.45 !important;
  overflow-wrap: anywhere !important;
}
#tasks .work-item .form-actions,
#agreements .work-item .form-actions,
.completed-list .work-item .form-actions {
  margin-top: 12px !important;
}
.mini-form {
  overflow: hidden;
}

.message-form-v4 {
  display: grid !important;
  grid-template-columns: minmax(240px, 1fr) 48px auto !important;
  gap: 10px !important;
  align-items: end !important;
  padding: 12px !important;
  border-top: 1px solid var(--line) !important;
  background: #fff !important;
}
.message-form-v4 textarea {
  grid-column: 1 !important;
  min-width: 0 !important;
  width: 100% !important;
  margin: 0 !important;
  resize: vertical !important;
  max-height: 140px !important;
}
.message-form-v4 .attach-button-v4 {
  grid-column: 2 !important;
  width: 48px !important;
  min-width: 48px !important;
  margin: 0 !important;
}
.message-form-v4 .attach-button-v4 span {
  width: 48px !important;
  height: 44px !important;
  padding: 0 !important;
}
.message-form-v4 .button {
  grid-column: 3 !important;
  min-height: 44px !important;
  white-space: nowrap !important;
}
.chosen-file-v4 {
  grid-column: 1 / -1 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
.nav-link,
.logout,
.button,
.nav-link:hover,
.logout:hover,
.button:hover,
.nav-link:active,
.logout:active,
.button:active,
.nav-link:focus,
.logout:focus,
.button:focus {
  transform: none !important;
  translate: none !important;
  top: auto !important;
  position: relative;
}
.nav-link:hover,
.logout:hover {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18) !important;
}
.messenger-v4-clean .message {
  overflow-wrap: anywhere !important;
}
.messenger-v4-clean .conversation {
  overscroll-behavior: contain !important;
}

@media (max-width: 900px) {
  .topbar { overflow: hidden; }
  .nav {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    justify-content: flex-start !important;
    padding-bottom: 2px !important;
  }
  .nav-link,
  .logout {
    flex: 0 0 auto !important;
  }
  .two-col,
  .profile-grid {
    grid-template-columns: 1fr !important;
  }
  #tasks .work-head,
  #agreements .work-head,
  .completed-list .work-head {
    grid-template-columns: minmax(0, 1fr) max-content !important;
    column-gap: 12px !important;
  }
  #tasks .work-head .pill,
  #agreements .work-head .pill,
  .completed-list .work-head .pill {
    max-width: 150px !important;
  }
}
@media (max-width: 760px) {
  .container { width: min(100% - 20px, 1180px) !important; margin-top: 14px !important; }
  .card { padding: 14px !important; }
  #tasks .work-list,
  #agreements .work-list,
  .completed-list.work-list,
  #tasks .scroll-list,
  #agreements .scroll-list {
    max-height: 350px !important;
    gap: 14px !important;
    padding-right: 4px !important;
  }
  #tasks .work-list > .work-item,
  #agreements .work-list > .work-item,
  .completed-list.work-list > .work-item,
  #tasks .scroll-list > .work-item,
  #agreements .scroll-list > .work-item {
    padding: 14px !important;
    border-radius: 16px !important;
  }
  #tasks .work-list > .work-item + .work-item,
  #agreements .work-list > .work-item + .work-item,
  .completed-list.work-list > .work-item + .work-item,
  #tasks .scroll-list > .work-item + .work-item,
  #agreements .scroll-list > .work-item + .work-item {
    margin-top: 14px !important;
  }
  #tasks .work-head,
  #agreements .work-head,
  .completed-list .work-head {
    grid-template-columns: 1fr !important;
  }
  #tasks .work-head .pill,
  #agreements .work-head .pill,
  .completed-list .work-head .pill {
    justify-self: start !important;
    max-width: 100% !important;
  }
  .messenger-v4-clean {
    height: calc(100vh - 132px) !important;
    min-height: 640px !important;
  }
  .message-form-v4 {
    grid-template-columns: 48px minmax(0, 1fr) !important;
    gap: 8px !important;
  }
  .message-form-v4 textarea {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
  }
  .message-form-v4 .attach-button-v4 {
    grid-column: 1 !important;
    grid-row: 2 !important;
  }
  .message-form-v4 .button {
    grid-column: 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }
  .chosen-file-v4 {
    grid-column: 1 / -1 !important;
    grid-row: 3 !important;
  }
}
