:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --navy: #0f172a;
  --navy-2: #1e293b;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --blue-bg: #dbeafe;
  --red: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* ---- Login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 32px; width: 100%; max-width: 360px; text-align: center;
}
.login-integration {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 58px; margin-bottom: 4px;
}
.login-integration img:first-child { width: 50px; height: 50px; object-fit: contain; }
.login-integration .login-rentsyst {
  width: 112px; height: 42px; object-fit: contain; padding: 7px 9px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
}
.login-link { color: var(--blue); font-size: 23px; font-weight: 700; }
.login-card h1 { font-size: 20px; margin: 16px 0 4px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  margin: 16px 0 12px; font-size: 15px;
}

/* ---- Buttons ---- */
.btn {
  border: none; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: filter .15s, background .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(.96); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:not(:disabled):hover, .btn-success:not(:disabled):hover { filter: brightness(1.05); box-shadow: 0 2px 8px rgba(37,99,235,.25); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-outline { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { width: 100%; justify-content: center; }

/* ---- Layout ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: #090b10; color: #cbd5e1;
  border-right: 1px solid #1f2937; padding: 18px 12px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 0; align-self: flex-start; height: 100vh;
  overflow-y: auto; overscroll-behavior: contain;
}
.integration-brand {
  padding: 5px 5px 18px; margin-bottom: 4px; border-bottom: 1px solid #202632;
}
.brand-services { display: flex; align-items: center; gap: 7px; }
.service-logo {
  height: 46px; display: grid; place-items: center; border-radius: 10px; overflow: hidden;
}
.service-logo-usedesk { width: 46px; background: #11151d; border: 1px solid #252b36; }
.service-logo-usedesk img { width: 40px; height: 40px; object-fit: contain; }
.service-logo-rentsyst { width: 108px; padding: 5px 7px; background: #f8fafc; border: 1px solid #dbe2ea; }
.service-logo-rentsyst img { width: 100%; height: 100%; object-fit: contain; }
.sync-link { width: 36px; height: 30px; position: relative; display: grid; place-items: center; }
.sync-track {
  position: absolute; left: 2px; right: 2px; top: 14px; height: 1px; background: #334155;
}
.sync-dot {
  position: absolute; top: 11px; left: 3px; width: 7px; height: 7px; border-radius: 50%;
  background: #3b82f6; animation: sync-travel 1.8s ease-in-out infinite alternate;
}
@keyframes sync-travel { from { transform: translateX(0); } to { transform: translateX(24px); } }
.brand-title { margin-top: 12px; color: #f8fafc; font-size: 15px; font-weight: 750; letter-spacing: .01em; }
.brand-subtitle { margin-top: 2px; color: #64748b; font-size: 11px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  background: transparent; border: none; color: #cbd5e1; text-align: left; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 10px;
}
.nav-item .ico { width: 18px; display: inline-block; text-align: center; opacity: .9; }
.nav-item:hover { background: #171c25; color: #fff; }
.nav-item.active { background: #1d4ed8; color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: rgba(255, 255, 255, 0.9); backdrop-filter: saturate(1.2) blur(6px);
  border-bottom: 1px solid var(--border); padding: 12px 20px; position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.mobile-brand { display: none; align-items: center; gap: 5px; }
.user-greeting {
  display: flex; align-items: center; gap: 9px; border: 1px solid rgba(99, 102, 241, .16); border-radius: 14px;
  padding: 6px 11px; background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 55%, #fff7ed 100%);
  color: var(--text); cursor: pointer; text-align: left;
  box-shadow: 0 5px 18px rgba(79, 70, 229, .10);
}
.user-greeting:hover { border-color: rgba(79, 70, 229, .3); box-shadow: 0 7px 22px rgba(79, 70, 229, .16); }
.user-greeting span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.user-greeting small { color: #4f46e5; font-size: 10px; font-weight: 700; }
.user-greeting strong { font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.user-avatar {
  position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(135deg, #2563eb, #7c3aed 60%, #ec4899); color: #fff; font-size: 21px; font-weight: 800;
  box-shadow: 0 4px 10px rgba(79, 70, 229, .24);
}
.user-avatar.avatar-admin {
  background: linear-gradient(135deg, #7c2d12, #dc2626 52%, #f59e0b);
  box-shadow: 0 5px 14px rgba(220, 38, 38, .25);
}
.user-avatar.avatar-admin::after {
  content: "👑"; position: absolute; right: -7px; top: -10px; transform: rotate(12deg);
  font-size: 16px; filter: drop-shadow(0 2px 2px rgba(15, 23, 42, .25));
}
.refresh-result { min-width: 112px; color: #15803d; font-size: 11px; font-weight: 700; text-align: right; }

.account-create {
  display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px;
  margin: 14px 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc;
}
.account-create-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.accounts-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.account-row {
  display: grid; grid-template-columns: 38px minmax(150px, 1fr) 150px 100px 130px;
  gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff;
}
.account-avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: #dbeafe; color: #1d4ed8; font-weight: 800;
}
.account-main { display: flex; flex-direction: column; min-width: 0; }
.account-main span { color: var(--muted); font-size: 11px; }
.account-role { border: 1px solid var(--border); border-radius: 8px; padding: 7px; background: #fff; }
.account-enabled { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-gray { background: #e2e8f0; color: var(--muted); }
.pill-red { background: #fee2e2; color: var(--red); }
.pill-manual { background: #fef3c7; color: #b45309; }

/* ---- Подвкладки Опрос / План ---- */
.subtabs { display: flex; gap: 6px; margin-bottom: 16px; }
.subtab {
  border: 1px solid var(--border); background: #fff; color: var(--muted); border-radius: 10px;
  padding: 8px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.subtab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---- Сегментированный переключатель Забор/Доставка ---- */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.seg-btn { background: #fff; border: none; padding: 8px 18px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.seg-btn.active { background: var(--blue); color: #fff; }
.seg-sm { margin-bottom: 0; }
.seg-sm .seg-btn { padding: 5px 12px; font-size: 12px; }
.head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.date-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-weight: 600;
  font-size: 12px;
}
.inline-fld {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.inline-fld select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  background: #fff;
}

/* ---- Редактор шаблона ---- */
.tpl { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; }
.tpl > summary { cursor: pointer; padding: 10px 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
.tpl-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.tpl-lang { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.tpl-lang textarea {
  width: 100%; resize: vertical; border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  font-size: 13px; font-family: inherit; color: var(--text);
}
.tpl-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.template-picker {
  display: flex; flex-direction: column; gap: 6px; width: min(100%, 430px);
  color: #64748b; font-size: 11px; font-weight: 800; letter-spacing: .025em;
}
.template-picker select {
  appearance: none; width: 100%; min-height: 42px; border: 1px solid #bfdbfe; border-radius: 11px;
  padding: 9px 42px 9px 13px; color: #172554; font-size: 13px; font-weight: 750;
  background-color: #f8fbff;
  background-image:
    linear-gradient(45deg, transparent 50%, #2563eb 50%),
    linear-gradient(135deg, #2563eb 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .07);
  cursor: pointer;
}
.template-picker select:hover { border-color: #93c5fd; background-color: #f0f7ff; }
.template-picker select:focus {
  outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}
.template-create {
  display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 10px;
  align-items: end; padding: 10px 0 2px; border: 0; border-top: 1px solid #e2e8f0; background: transparent;
}
.template-create .fld { display: flex; flex-direction: column; gap: 5px; color: #64748b; font-size: 11px; font-weight: 700; }
.template-create input, .template-create select {
  width: 100%; height: 38px; border: 1px solid #cbd5e1; border-radius: 9px;
  padding: 7px 10px; background: #fff; color: #0f172a; font: inherit;
}
.template-create input:focus, .template-create select:focus {
  outline: none; border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(59, 130, 246, .1);
}
.template-create-actions { display: flex; align-items: center; gap: 6px; padding-bottom: 1px; }
.template-create-actions .btn { height: 38px; padding: 8px 12px; }
.template-apply { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; }
.template-apply select {
  height: 38px; min-width: 170px; border: 1px solid #bfdbfe; border-radius: 9px;
  padding: 7px 30px 7px 10px; background: #f8fbff; color: #1e3a8a; font-size: 12px; font-weight: 700;
}
.manager-guide { background: #f8fafc; }
.guide-steps { margin: 0; padding-left: 22px; color: var(--text); font-size: 13px; line-height: 1.55; }
.guide-steps li + li { margin-top: 4px; }
.chk-all { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---- Разделы рассылок (динамические вкладки) ---- */
.section-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.section-tab { border: 1px solid var(--border); background: #fff; color: var(--muted); border-radius: 10px; padding: 7px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.section-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
#section-add { margin-top: 4px; }

.section-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.section-meta .fld { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.section-meta input, .section-meta select { border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; color: var(--text); font-family: inherit; }
.section-meta select:disabled { background: #f1f5f9; color: var(--muted); }

/* ---- Ручное добавление получателя ---- */
.manual-add { display: inline-flex; gap: 8px; align-items: center; }
.manual-add input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; min-width: 220px; }

.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-label { font-size: 13px; color: var(--muted); }
.toggle input { display: none; }
.toggle .slider {
  width: 40px; height: 22px; background: #cbd5e1; border-radius: 999px; position: relative; transition: background .15s;
}
.toggle .slider::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff;
  border-radius: 50%; transition: transform .15s;
}
.toggle input:checked + .slider { background: var(--blue); }
.toggle input:checked + .slider::after { transform: translateX(18px); }

.content { padding: 20px; flex: 1; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; margin: 0; }
.card-actions { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tbl tr.skip td { opacity: .55; }
.badge { padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge-synced { background: var(--blue-bg); color: var(--blue); }
.badge-rental { background: var(--green-bg); color: var(--green); }
.badge-done, .badge-cancel { background: #f1f5f9; color: var(--muted); }
.chat-link { color: var(--blue); text-decoration: none; }
.channel-icon {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 4px;
  border-radius: 6px; font-size: 9px; font-weight: 800; color: #334155; background: #e2e8f0;
  vertical-align: middle;
}
.channel-logo {
  width: 20px; height: 20px; object-fit: contain; vertical-align: middle; flex: 0 0 auto;
}
.channel-link {
  position: relative; display: inline-grid; place-items: center;
  width: 30px; height: 30px; padding: 0; border-radius: 9px; line-height: 1; text-decoration: none;
}
.channel-link:hover { background: #f1f5f9; }
.channel-link-label {
  position: absolute; right: -3px; bottom: -2px; display: grid; place-items: center;
  width: 13px; height: 13px; border: 1px solid #fff; border-radius: 50%;
  background: #2563eb; color: #fff; font-size: 8px; font-weight: 900;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .22);
}
.channel-link:hover .channel-link-label { background: #1d4ed8; }
.channel-whatsapp { color: #166534; background: #dcfce7; }
.channel-telegram { color: #075985; background: #e0f2fe; }
.channel-instagram { color: #9d174d; background: #fce7f3; }
.channel-facebook { color: #1d4ed8; background: #dbeafe; }
.channel-email { color: #92400e; background: #fef3c7; font-size: 12px; }
.sent-yes { color: var(--green); font-weight: 700; }
.sent-no { color: #cbd5e1; }
.reason { color: var(--muted); font-size: 12px; }
.reason-ok { color: #16a34a; font-weight: 600; }

/* Редактируемая временная вилка */
.plan-range {
  width: 100%; min-width: 0; max-width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 8px; font-size: 12px; font-family: ui-monospace, Consolas, monospace; color: var(--text);
  letter-spacing: -0.02em;
}
.plan-range:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-bg); }
.location-editor { display: flex; align-items: center; gap: 5px; }
.plan-location {
  width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 6px; font-size: 11px; color: var(--text);
}
.plan-location:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-bg); }

/* Ручные строки и статусы рассылки */
.badge-manual {
  display: inline-block; font-size: 10px; font-weight: 700; color: #b45309; background: #fef3c7;
  border-radius: 6px; padding: 1px 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .02em;
}
.badge-rs-only {
  display: inline-block; font-size: 10px; font-weight: 700; color: #6d28d9; background: #ede9fe;
  border-radius: 6px; padding: 1px 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .02em;
}
.badge-freeform {
  display: inline-block; font-size: 10px; font-weight: 700; color: #0369a1; background: #e0f2fe;
  border-radius: 6px; padding: 1px 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .02em;
}
.badge-kind {
  display: inline-block; font-size: 9px; font-weight: 700; color: #1d4ed8; background: #eff6ff;
  border-radius: 5px; padding: 1px 5px; vertical-align: middle; letter-spacing: .01em; margin-right: 4px;
}
.row-waiting td { background: #fffbeb; }
.row-fail td { background: #fff1f2; }
.row-rs-extra td { background: #fef9c3; }
.row-rs-only td { background: #faf5ff; }
.row-freeform td { background: #f0f9ff; }
.driver-only-lock { font-size: 14px; color: #7c3aed; }
.driver-only-msg { color: #6d28d9; font-size: 11px; line-height: 1.35; padding: 6px 2px; }
.st-rs-only { background: #ede9fe; color: #6d28d9; }
.badge-quality {
  display: inline-block; margin: 3px 0 0 5px; padding: 2px 6px; border-radius: 999px;
  font-size: 9px; font-weight: 800; line-height: 1.2;
}
.badge-long { background: #dbeafe; color: #1d4ed8; }
.badge-rs { background: #ede9fe; color: #6d28d9; }
.badge-warning { background: #fef3c7; color: #92400e; }
.long-rental-checks { margin-top: 10px; }
.long-rental-check { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #e2e8f0; font-size: 12px; }
.long-rental-check:last-child { border-bottom: 0; }
.long-rental-check a { flex: 0 0 auto; color: #2563eb; font-weight: 700; text-decoration: none; }
.mini-x {
  border: none; background: transparent; color: var(--red); cursor: pointer; font-size: 13px;
  margin-left: 8px; padding: 2px 6px; border-radius: 6px;
}
.mini-x:hover { background: #fee2e2; }
.plan-manual-add { margin-top: 10px; }
.plan-manual-add select {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; background: #fff;
}
.plan-task-add {
  margin-top: 8px; border: 1px solid #bae6fd; border-radius: 10px; background: #f8fcff;
}
.plan-task-add summary {
  padding: 9px 11px; cursor: pointer; color: #0369a1; font-size: 12px; font-weight: 750;
}
.plan-task-fields {
  display: grid; grid-template-columns: minmax(220px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr);
  gap: 8px; padding: 0 10px 10px;
}
.plan-task-fields input, .plan-task-fields select {
  min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  background: #fff; color: var(--text); font: inherit; font-size: 12px;
}
.plan-task-fields .btn { justify-content: center; }
.sort-control {
  display: inline-flex; align-items: center; gap: 7px; color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.sort-control select {
  max-width: 360px; border: 1px solid #93c5fd; border-radius: 8px;
  padding: 7px 30px 7px 9px; background: #eff6ff; color: #1e3a8a; font-size: 12px; font-weight: 700;
}
.office-picker {
  display: flex; align-items: center; gap: 3px;
  color: var(--muted); font-size: 10px; font-weight: 700;
}
.office-picker select {
  min-width: 76px; max-width: 96px; padding: 3px 4px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--text); font-size: 11px;
}
.office-icon { font-size: 12px; line-height: 1; }

/* Сверка с RentSyst Daily Plan */
.plan-reconcile { margin-top: 12px; }
.reconcile-result { margin-top: 10px; }
.reconcile-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.reconcile-meta { font-size: 12px; }
.reconcile-h { margin: 10px 0 6px; font-size: 13px; font-weight: 700; }
.reconcile-list { margin: 0 0 8px; padding-left: 18px; font-size: 13px; line-height: 1.45; }
.reconcile-miss li {
  color: #b91c1c; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 7px;
}
.reconcile-miss .btn-add-rs { flex: 0 0 auto; color: #166534; border-color: #86efac; background: #f0fdf4; }
.reconcile-extra li { color: #a16207; }
.reconcile-ok { margin: 4px 0; font-size: 13px; color: #16a34a; }
.reconcile-error { color: var(--red); font-size: 13px; }
.reconcile-note {
  margin-top: 10px; color: #854d0e; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 8px; padding: 9px 11px; font-size: 12px; line-height: 1.45;
}
.pill-red { background: #fee2e2; color: #b91c1c; }
.pill-yellow { background: #fef9c3; color: #a16207; }
.pill-green { background: #dcfce7; color: #166534; }

/* Подзаголовок блока (Забор/Доставка) в едином списке */
.group-row td {
  background: #f1f5f9; font-weight: 700; font-size: 13px; color: var(--navy);
  padding: 8px 12px; border-top: 2px solid var(--border);
  text-transform: uppercase; letter-spacing: .03em;
}
.group-row-content {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.group-progress {
  margin-left: auto; padding: 3px 8px; border-radius: 999px;
  background: #fff; border: 1px solid #cbd5e1;
  color: #64748b; font-size: 10px; font-weight: 700;
  text-transform: none; letter-spacing: 0; white-space: nowrap;
}
.group-progress.is-complete {
  border-color: #fca5a5; background: #fff1f2; color: #b91c1c;
}
.block-period-filter {
  display: inline-flex; align-items: center; gap: 7px; text-transform: none;
  letter-spacing: 0; color: #475569; font-size: 11px; white-space: nowrap;
}
.block-period-filter select {
  min-width: 105px; min-height: 32px; border: 1px solid #93c5fd; border-radius: 8px;
  padding: 5px 28px 5px 9px; background: #fff; color: #1e3a8a;
  font: inherit; font-size: 12px; font-weight: 700;
}
.period-empty td {
  padding: 10px 14px; color: var(--muted); font-size: 12px; font-style: italic;
  background: #f8fafc;
}
.empty { color: var(--muted); padding: 14px 4px; }

/* ---- Таблица «Опрос» с редактируемым сообщением ---- */
.opros-tbl td { white-space: normal; vertical-align: top; }
.opros-tbl .c-chk { width: 34px; }
.opros-tbl .c-msg { min-width: 260px; }
.opros-tbl .c-bike, .opros-tbl .c-client, .opros-tbl .c-range, .opros-tbl .c-dtype, .opros-tbl .c-loc { white-space: nowrap; }
.opros-tbl textarea.msg {
  width: 100%; min-width: 240px; resize: vertical; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; font-size: 13px; font-family: inherit; color: var(--text); line-height: 1.4;
}
.opros-tbl tr.skip textarea.msg { background: #f8fafc; }

/* ---- Таблица «План» с тумблером и редактируемым текстом ---- */
.plan-tbl { table-layout: fixed; }
.plan-tbl td { white-space: normal; vertical-align: top; }
.plan-tbl .c-msg { min-width: 0; }
.plan-tbl textarea.plan-msg {
  width: 100%;
  min-width: 0;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  line-height: 1.4;
}
.plan-toggle { justify-content: center; margin: 0 auto; }
.plan-tpl-editor { margin-top: -2px; }
.plan-tpl-editor .tpl-body {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px;
}
.plan-tpl-editor .template-picker,
.plan-tpl-editor .template-create,
.plan-tpl-editor .tpl-actions { grid-column: 1 / -1; }
.plan-tpl-editor .tpl-lang {
  gap: 6px; padding: 10px; border: 1px solid #dbeafe; border-radius: 11px; background: #f8fbff;
  color: #1d4ed8; font-size: 11px; letter-spacing: .04em;
}
.plan-tpl-editor .tpl-lang textarea {
  min-height: 96px; padding: 11px 12px; border-color: #cbd5e1; background: #fff;
  color: #0f172a; font-size: 14px; font-weight: 400; line-height: 1.5; letter-spacing: 0;
}
.plan-tbl .c-time { font-weight: 600; }
.plan-tbl .c-note textarea.plan-note {
  width: 100%;
  min-width: 0;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  line-height: 1.4;
}

@media (min-width: 761px) {
  .plan-tbl { width: 100%; font-size: 12px; }
  .plan-tbl th:nth-child(1) { width: 9%; }
  .plan-tbl th:nth-child(2) { width: 11%; }
  .plan-tbl th:nth-child(3) { width: 5%; min-width: 0; }
  .plan-tbl th:nth-child(4) { width: 4%; }
  .plan-tbl th:nth-child(5) { width: 24%; }
  .plan-tbl th:nth-child(6) { width: 8%; min-width: 0; }
  .plan-tbl th:nth-child(7) { width: 12%; }
  .plan-tbl th:nth-child(8) { width: 12%; }
  .plan-tbl th:nth-child(9) { width: 12%; }
  .plan-tbl th:nth-child(10) { width: 3%; min-width: 34px; }
  .plan-tbl th,
  .plan-tbl td {
    padding-left: 3px;
    padding-right: 3px;
    overflow-wrap: anywhere;
  }
  .plan-tbl .lang-btn { min-width: 23px; padding: 4px 5px; font-size: 10px; }
  .plan-tbl .plan-toggle .slider { width: 34px; height: 20px; }
  .plan-tbl .plan-toggle .slider::after { width: 16px; height: 16px; }
  .plan-tbl .plan-toggle input:checked + .slider::after { transform: translateX(14px); }
  .plan-tbl textarea.plan-msg { padding: 6px; font-size: 12px; }
  .plan-tbl .channel-link { width: 27px; }
  .plan-tbl .c-loc,
  .plan-tbl .c-status {
    overflow-wrap: normal;
    word-break: normal;
  }
  .plan-tbl th:nth-child(3),
  .plan-tbl th:nth-child(4),
  .plan-tbl .c-lang,
  .plan-tbl .c-send {
    text-align: center;
  }
  .plan-tbl .c-lang,
  .plan-tbl .c-send {
    vertical-align: middle;
  }
  .plan-tbl .c-send .toggle {
    display: inline-flex;
  }
  .plan-tbl .c-chat { text-align: center; }
}

/* ---- Переключатель языка строки RU/EN ---- */
.lang-seg {
  display: inline-flex; flex-direction: row; flex-wrap: nowrap; flex-shrink: 0;
  white-space: nowrap; vertical-align: middle;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.lang-btn {
  border: none; background: #fff; color: var(--muted); padding: 5px 9px; font-size: 11px;
  font-weight: 700; cursor: pointer; transition: background .12s, color .12s;
  white-space: nowrap; line-height: 1; min-width: 28px;
}
.plan-tbl .c-lang { white-space: nowrap; overflow-wrap: normal; text-align: center; vertical-align: middle; }
.plan-tbl .c-lang .lang-seg { margin: 0 auto; }
.lang-btn.active { background: var(--blue); color: #fff; }

/* ---- Ячейка статуса рассылки ---- */
.status-cell { display: flex; align-items: flex-start; gap: 5px; flex-wrap: wrap; }
.status-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.st-badge { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.st-unsent { background: #f1f5f9; color: var(--muted); }
.st-sent { background: #dcfce7; color: #166534; }
.st-fail { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.st-replied { background: var(--blue-bg); color: var(--blue); }
.st-agreed { background: #fee2e2; color: #b91c1c; }
.st-sub { color: #b45309; font-size: 10px; font-weight: 650; line-height: 1.2; }
.st-sent-at { color: var(--muted); font-size: 10px; line-height: 1.2; }
.send-error {
  color: #b91c1c; font-size: 10px; font-weight: 650; line-height: 1.25;
  max-width: 190px; white-space: normal;
}
.agree-chk { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); cursor: pointer; }
.agree-btn {
  border: 1px solid #86efac; border-radius: 6px; padding: 3px 6px; background: #f0fdf4;
  color: #166534; font-size: 10px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.agree-btn:hover { background: #dcfce7; }
.agree-icon { display: none; }
.agree-btn.is-agreed {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 76px; min-height: 25px; padding: 3px 7px;
  border: 1px solid #ef4444; border-radius: 7px; background: #fff;
  color: #991b1b; font-size: 10px;
}
.agree-btn.is-agreed:hover { background: #fff1f2; }
.agree-btn.is-agreed .agree-icon {
  display: inline-grid; place-items: center; width: 16px; height: 16px;
  border-radius: 50%; background: #dc2626; color: #fff; font-size: 11px; line-height: 1;
}
.status-cell.is-agreed .st-badge { display: none; }

/* ---- Ссылка на карту ---- */
.map-link { color: var(--blue); text-decoration: none; font-weight: 600; white-space: nowrap; }
.map-link:hover { text-decoration: underline; }

/* ---- Поиск по таблице ---- */
.search-fld {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px;
  min-width: 220px; font-family: inherit; color: var(--text);
}

/* ---- Индикатор загрузки ---- */
.loading-cell { color: var(--muted); padding: 18px 8px; text-align: center; }
.spinner {
  display: inline-block; width: 14px; height: 14px; vertical-align: middle; margin-right: 6px;
  border: 2px solid #cbd5e1; border-top-color: var(--blue); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Rules ---- */
.rules-list { display: flex; flex-direction: column; gap: 10px; }
.rule-row {
  display: grid; grid-template-columns: 1fr 180px 40px 70px; gap: 10px; align-items: start;
  padding: 12px; border: 1px solid var(--border); border-radius: 10px;
}
.rule-row textarea { width: 100%; min-height: 40px; resize: vertical; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; font-family: inherit; }
.rule-row input[type=text], .rule-row select { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; }
.rule-actions { display: flex; gap: 6px; }
.icon-btn { border: 1px solid var(--border); background: #fff; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; }
.icon-btn.del { color: var(--red); border-color: #fecaca; }
.rule-reply { grid-column: 1 / -1; }

/* ---- Support alerts / FAQ ---- */
.alerts-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.alerts-status { margin: 8px 0 14px; font-size: 13px; }
.alerts-safety {
  display: grid; grid-template-columns: 160px minmax(240px, 1fr) auto;
  gap: 12px; align-items: end; padding: 12px; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 10px;
}
.alerts-safety .fld { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.alerts-safety select, .alerts-safety input[type="text"] {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; background: #fff; font: inherit; color: var(--text);
}
.alerts-engine-btn {
  min-width: 154px; border-color: #cbd5e1; background: #fff; color: #64748b;
}
.alerts-engine-btn::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8;
  display: inline-block; margin-right: 7px;
}
.alerts-engine-btn.is-enabled {
  border-color: #86efac; background: #f0fdf4; color: #15803d;
}
.alerts-engine-btn.is-enabled::before { background: #22c55e; }
.alerts-engine-btn:disabled { opacity: .65; cursor: wait; }
.check-line { display: flex; align-items: center; gap: 6px; min-height: 36px; font-size: 12px; }
.alerts-warning {
  margin-top: 10px; border: 1px solid #fbbf24; background: #fffbeb; color: #92400e;
  border-radius: 8px; padding: 9px 11px; font-size: 12px;
}
.faq-table-wrap { margin-top: 14px; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.faq-table-head, .faq-rule {
  display: grid; grid-template-columns: minmax(220px, 1.05fr) minmax(260px, 1.4fr) minmax(210px, .9fr) 140px;
}
.faq-table-head {
  min-width: 920px; background: #f1f5f9; color: #475569; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.faq-table-head span { padding: 10px; border-right: 1px solid var(--border); }
.faq-table-head span:last-child { border-right: 0; }
.faq-rules { min-width: 920px; }
.faq-rule {
  border-top: 1px solid var(--border); background: #fff;
}
.faq-rule:first-child { border-top: 0; }
.faq-cell { padding: 9px; border-right: 1px solid var(--border); min-width: 0; }
.faq-cell:last-child { border-right: 0; }
.faq-rule input[type="text"], .faq-rule textarea {
  display: block; width: 100%; border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 8px; font-size: 12px; font-family: inherit; color: var(--text); resize: vertical;
}
.faq-rule textarea + textarea, .faq-rule input + textarea { margin-top: 7px; }
.faq-question { font-weight: 700; }
.faq-model-filter {
  display: block; margin-top: 8px; color: #475569; font-size: 11px; font-weight: 700;
}
.faq-model-filter small { color: var(--muted); font-size: 10px; font-weight: 500; }
.faq-model-filter .faq-bike-models { margin-top: 4px; font-weight: 500; }
.faq-model-filter + .faq-triggers { margin-top: 7px; }
.faq-actions-cell { display: flex; flex-direction: column; gap: 9px; font-size: 12px; }
.faq-actions-cell label { display: flex; gap: 6px; align-items: flex-start; }
.faq-rule .faq-del { color: var(--red); border-color: #fecaca; }

/* ---- Ресинк тикета ---- */
.resync-box { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.resync-box h3 { font-size: 14px; margin: 0 0 4px; }
.resync-box .manual-add { margin-top: 10px; }
.resync-log { margin-top: 12px; max-height: 220px; }
.field-help { margin: 5px 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.field-help code { color: #334155; background: #f1f5f9; border-radius: 4px; padding: 1px 4px; }
.result-box { margin-top: 10px; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; font-size: 13px; }
.result-ok { color: #166534; border-color: #86efac; background: #f0fdf4; }
.result-bad { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.result-warn { color: #92400e; border-color: #fde68a; background: #fffbeb; }

/* ---- Ручная склейка чат/бронь ---- */
.link-fixer { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.link-fixer input {
  flex: 1; min-width: 220px; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
}
#link-result { margin-top: 8px; }
#link-result a { color: var(--blue); }

/* ---- Sync / logs ---- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin-bottom: 16px; font-size: 13px; }
.kv .k { color: var(--muted); }
.diag-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}
.diag-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}
.diag-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
}
.diag-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 4px;
}
.diag-row .k { color: var(--muted); }

/* ---- Статус связи (упрощённая диагностика) ---- */
.conn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  margin: 4px 0 16px;
}
.conn-card {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: #fff;
}
.conn-name { min-width: 58px; font-size: 13px; font-weight: 700; color: var(--text); }
.conn-dot { font-size: 18px; line-height: 1; }
.conn-logo { width: 92px; height: 34px; object-fit: contain; object-position: left center; }
.conn-card:first-child .conn-logo { width: 42px; height: 42px; }
.conn-status { font-size: 12px; color: var(--muted); }
.conn-ok { border-color: #bbf7d0; background: #f0fdf4; }
.conn-ok .conn-dot { color: #16a34a; }
.conn-bad { border-color: #fecaca; background: #fef2f2; }
.conn-bad .conn-dot { color: #dc2626; }
.conn-idle .conn-dot { color: #9ca3af; }
.logs {
  background: #0b1220; color: #cbd5e1; border-radius: 10px; padding: 14px; max-height: 60vh; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; white-space: pre-wrap;
}
.log-filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.autorefresh { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow);
  z-index: 100; font-size: 14px; max-width: 90vw;
}

/* ---- Bottom nav (mobile) ---- */
.bottom-nav { display: none; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .sidebar { display: none; }
  .cards { grid-template-columns: 1fr; }
  .rule-row { grid-template-columns: 1fr; }
  .diag-grid { grid-template-columns: 1fr; }
  .conn-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; padding-bottom: 82px; min-width: 0; overflow-x: hidden; }
  .card { padding: 14px; min-width: 0; overflow-x: hidden; }
  .section-meta { flex-direction: column; }
  .manual-add {
    width: 100%; display: flex; flex-wrap: wrap; align-items: stretch;
  }
  .manual-add input { flex: 1 1 160px; min-width: 0; }
  .manual-add select { flex: 1 1 120px; min-width: 0; }
  .manual-add .btn { flex: 1 1 100%; }
  .tpl, .plan-task-add { max-width: 100%; min-width: 0; overflow: hidden; }
  .tpl > summary, .plan-task-add summary {
    display: block; max-width: 100%; overflow-wrap: anywhere; word-break: break-word;
    padding-right: 12px;
  }
  .card-head { flex-wrap: wrap; }
  .topbar {
    position: sticky; top: 0; background: #090b10; border-color: #1f2937; color: #fff;
    padding: 7px 9px; gap: 5px; flex-wrap: nowrap;
  }
  .mobile-brand { display: flex; flex-shrink: 0; gap: 2px; }
  .mobile-brand .service-logo { width: 29px; height: 29px; padding: 3px; border-radius: 8px; }
  .mobile-brand .service-logo-usedesk img { width: 23px; height: 23px; object-fit: contain; }
  .mobile-brand .service-logo-rentsyst { width: 56px; }
  .mobile-brand .sync-link { width: 16px; }
  .mobile-brand .sync-track { left: 1px; right: 1px; }
  .mobile-brand .sync-dot { left: 1px; animation-name: sync-travel-mobile; }
  .topbar .title { display: none; }
  .topbar-right { gap: 4px; min-width: 0; }
  .topbar .user-greeting { background: #141923; color: #fff; padding: 3px 5px; gap: 5px; min-width: 0; }
  .topbar .user-avatar { width: 29px; height: 29px; font-size: 18px; flex-shrink: 0; }
  .topbar .user-greeting:hover { background: #1f2937; }
  .topbar .user-greeting small { color: #94a3b8; }
  .topbar #logout-btn { color: #e2e8f0; padding: 6px 4px; font-size: 12px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
    border-top: 1px solid var(--border); justify-content: space-around; padding: 6px 4px; z-index: 50;
  }
  .bottom-nav .nav-item { flex-direction: column; gap: 2px; color: var(--muted); font-size: 11px; padding: 6px 8px; }
  .bottom-nav .nav-item.active { background: transparent; color: var(--blue); }
  .bottom-nav .nav-item .ico { font-size: 18px; }
  .account-create { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .account-row { grid-template-columns: 38px minmax(140px, 1fr) 140px; }
  .account-enabled, .account-reset { grid-column: auto; }
  .search-fld { min-width: 0; width: 100%; }
  .link-fixer input { min-width: 0; }
  .alerts-safety { grid-template-columns: 1fr 1fr; }
}
@keyframes sync-travel-mobile { from { transform: translateX(0); } to { transform: translateX(8px); } }

/* ---- Мобильные карточки для широких таблиц (Опрос/План) ---- */
@media (max-width: 760px) {
  .alerts-actions .btn { flex: 1; min-width: 110px; }
  .alerts-safety { grid-template-columns: 1fr; }
  .faq-table-wrap { overflow: visible; border: 0; }
  .faq-table-head { display: none; }
  .faq-rules { min-width: 0; display: grid; gap: 10px; }
  .faq-rule {
    display: block; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
  }
  .faq-cell { border-right: 0; border-top: 1px solid var(--border); }
  .faq-cell:first-child { border-top: 0; }
  .faq-cell::before {
    content: attr(data-label); display: block; margin-bottom: 6px;
    color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase;
  }
  .faq-actions-cell { display: grid; grid-template-columns: 1fr 1fr; }
  .faq-actions-cell .faq-del { grid-column: 1 / -1; }
  .plan-task-fields { grid-template-columns: 1fr; }
  .user-greeting small { display: none; }
  .user-greeting strong { max-width: 100px; }
  .plan-tpl-editor .tpl-body { grid-template-columns: 1fr; }
  .plan-tpl-editor .template-picker,
  .plan-tpl-editor .template-create,
  .plan-tpl-editor .tpl-actions,
  .plan-tpl-editor .tpl-lang { grid-column: 1; }
  .template-create { grid-template-columns: 1fr; }
  .template-create-actions { grid-column: 1; }
  .template-apply { width: 100%; margin-left: 0; }
  .template-apply select { flex: 1; min-width: 0; }
  .sort-control { width: 100%; align-items: stretch; flex-direction: column; gap: 4px; }
  .sort-control select { width: 100%; max-width: none; }
  .table-wrap { overflow-x: visible; }
  .opros-tbl, .opros-tbl tbody, .plan-tbl, .plan-tbl tbody { display: block; width: 100%; }
  .opros-tbl .thead-row, .plan-tbl .thead-row { display: none; }
  .opros-tbl tr, .plan-tbl tr {
    display: block; border: 1px solid var(--border); border-radius: 10px;
    padding: 8px 10px; margin-bottom: 8px; background: #fff; box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
  }
  .plan-tbl tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 4px; }
  .opros-tbl tr.skip, .plan-tbl tr.skip { opacity: 1; }

  .opros-tbl td, .plan-tbl td {
    display: flex; align-items: baseline; gap: 7px;
    border: none; border-top: 1px solid var(--border); padding: 4px 0; white-space: normal;
  }
  .plan-tbl td { grid-column: 1 / -1; min-width: 0; }
  .plan-tbl td.c-lang { grid-column: 1; padding-right: 6px; }
  .plan-tbl td.c-send { grid-column: 2; padding-left: 6px; }
  .plan-tbl td.c-time { grid-column: 1; padding-right: 6px; }
  .plan-tbl td.c-loc { grid-column: 2; padding-left: 6px; }
  .plan-tbl td.c-lang::before, .plan-tbl td.c-send::before,
  .plan-tbl td.c-time::before, .plan-tbl td.c-loc::before { flex: 0 0 auto; }
  .plan-tbl td.c-time .plan-range,
  .plan-tbl td.c-loc .plan-location,
  .plan-tbl td.c-loc .location-editor { width: 100%; min-width: 0; }
  .plan-tbl td.c-loc .location-editor { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
  .opros-tbl tr td:first-child, .plan-tbl tr td:first-child { border-top: none; }
  .opros-tbl td::before, .plan-tbl td::before {
    content: attr(data-label); color: var(--muted); font-weight: 600; font-size: 11px;
    flex: 0 0 28%; white-space: nowrap;
  }
  .opros-tbl td > *, .plan-tbl td > * { min-width: 0; }
  .opros-tbl td.c-chat, .plan-tbl td.c-chat { align-items: center; }

  /* Имя клиента — заголовок карточки */
  .opros-tbl td[data-label="Клиент"], .plan-tbl td[data-label="Клиент"] {
    display: block; font-weight: 700; font-size: 15px; padding: 0 0 5px;
    border-top: none; border-bottom: 1px solid var(--border); margin-bottom: 2px;
  }
  .opros-tbl td[data-label="Клиент"]::before, .plan-tbl td[data-label="Клиент"]::before { display: none; }

  /* Чекбокс «Выбор» — рядом с заголовком */
  .opros-tbl td[data-label="Выбор"] { border-top: none; padding-bottom: 0; }

  /* Сообщение и комментарий — метка сверху, поле на всю ширину */
  .opros-tbl td.c-msg, .plan-tbl td.c-msg, .plan-tbl td.c-note { display: block; }
  .opros-tbl td.c-msg::before, .plan-tbl td.c-msg::before, .plan-tbl td.c-note::before {
    display: block; margin-bottom: 3px; flex: none;
  }
  .opros-tbl td.c-msg textarea, .plan-tbl td.c-msg textarea, .plan-tbl td.c-note textarea {
    width: 100% !important; min-width: 0 !important; min-height: 54px;
  }
  .plan-tbl td.c-note textarea.plan-note { min-height: 42px; }
  .account-create { grid-template-columns: 1fr; padding: 10px; }
  .account-create-actions { grid-column: 1; }
  .account-row { grid-template-columns: 34px 1fr; }
  .account-row .account-role, .account-row .account-enabled, .account-row .account-reset {
    grid-column: 1 / -1; width: 100%;
  }

  /* Подзаголовок блока — столбиком, без вылета сортировки */
  .plan-tbl tr.group-row {
    display: block; border: none; border-radius: 0; padding: 0; margin: 4px 0 10px;
    background: transparent; box-shadow: none;
  }
  .plan-tbl tr.group-row td {
    display: block; border: none; border-radius: 8px; padding: 8px 10px;
  }
  .plan-tbl tr.group-row td::before { content: ""; }
  .group-row-content {
    flex-wrap: wrap; align-items: flex-start; gap: 8px;
  }
  .group-row-content > span:first-child {
    flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere;
  }
  .group-progress { margin-left: 0; }
  .block-period-filter {
    width: 100%; flex-wrap: wrap; white-space: normal;
  }
  .block-period-filter select {
    width: 100%; min-width: 0;
  }

  .opros-tbl td.empty, .plan-tbl td.empty, .opros-tbl td.loading-cell, .plan-tbl td.loading-cell {
    display: block; text-align: center; border-top: none;
  }
  .opros-tbl td.empty::before, .plan-tbl td.empty::before,
  .opros-tbl td.loading-cell::before, .plan-tbl td.loading-cell::before { content: ""; }
}
