:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f9fbff;
  --border: #dde3ee;
  --text: #182230;
  --text-muted: #667085;
  --text-soft: #8a94a6;
  --primary: #3559e0;
  --primary-dark: #2746b8;
  --success-bg: #ecfdf3;
  --success-text: #027a48;
  --danger-bg: #fef3f2;
  --danger-text: #b42318;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fbff 0%, #f3f6fb 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.app-shell__frame {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  padding: 28px 20px;
  background: #fff;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.sidebar__logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), #6b85ff);
  color: #fff;
  font-weight: 700;
}

.sidebar__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.sidebar__subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.sidebar__nav {
  display: grid;
  gap: 10px;
}

.sidebar__link {
  display: block;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar__link.is-active {
  background: #edf2ff;
  color: var(--primary);
}

.sidebar__link.is-muted {
  background: var(--surface-muted);
  color: var(--text-soft);
}

.app-shell__main {
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar__menu-button {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 14px;
}

.topbar__eyebrow,
.panel__eyebrow,
.auth-card__eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.topbar__title,
.panel__title {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.topbar__search input {
  width: 240px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 11px 14px;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #dbe5ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.topbar__user-name,
.topbar__user-role {
  margin: 0;
}

.topbar__user-name {
  font-weight: 700;
}

.topbar__user-role {
  color: var(--text-muted);
  font-size: 13px;
}

.page-content {
  padding: 28px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card,
.panel,
.auth-card,
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 22px;
}

.stat-card__label {
  margin: 0 0 8px;
  color: var(--text-muted);
}

.stat-card__value {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
}

.panel {
  padding: 22px;
}

.panel + .panel {
  margin-top: 24px;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.panel__filters {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.panel__filters .field__control { max-width: 560px; }
.channel-stats { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:24px; }
.channel-filters .field__control:first-child { flex:1 1 380px; }
.channel-filters select.field__control { flex:0 1 190px; }
.channel-number { white-space:nowrap; font-variant-numeric:tabular-nums; }
.channel-actions { display:flex; align-items:center; gap:8px; white-space:nowrap; }
.channel-owner-note { margin: -4px 0 8px; color: var(--text-muted); font-size: 13px; }
.channel-status { font-weight:700; }
.channel-status--active { color:var(--success-text); }
.channel-status--paused { color:#b54708; }
.channel-status--archived { color:#667085; }
.panel__count { color: var(--text-soft); font-size: 18px; font-weight: 600; }
.table-link { color: var(--primary); font-weight: 700; }
.table-link:hover { text-decoration: underline; }
.contact-name-link { color: var(--text); font-weight: 700; }
.contact-name-link:hover { color: var(--primary); text-decoration: underline; }
.contact-table-name { color: var(--text); font-weight: 700; }
.contacts-no-results { padding: 24px; color: var(--text-muted); text-align: center; }
.contacts-header-actions { display: flex; align-items: center; gap: 8px; }
.contacts-table { font-size: 12.5px; line-height: 1.3; transition: opacity 0.15s ease; }
.contacts-table.is-loading { opacity: 0.55; pointer-events: none; }
.contacts-table th,
.contacts-table td { padding: 8px 9px; vertical-align: middle; }
.contacts-table th { font-size: 11px; letter-spacing: 0.025em; white-space: nowrap; }
.contacts-table .table-sort { gap: 3px; }
.contacts-table .badge { padding: 4px 8px; font-size: 11px; }
.contacts-table .table-person__meta,
.contacts-table .telegram-channel-meta { font-size: 11px; }
.contacts-table .telegram-channel-meta { margin-top: 2px; }
.contacts-table .channel-address { display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contacts-table .table-actions { padding-right: 5px; }
.contacts-table .button--table-link,
.contacts-table .button--danger-ghost { padding: 5px 7px; border-radius: 7px; font-size: 11px; }
.contacts-sticky-header { position: fixed; z-index: 9; overflow: hidden; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.97); box-shadow: 0 5px 12px rgba(16, 24, 40, 0.08); backdrop-filter: blur(10px); }
.contacts-sticky-header[hidden] { display: none; }
.contacts-table--sticky { table-layout: fixed; background: transparent; pointer-events: none; will-change: transform; }
.contacts-table--sticky th { border-bottom: 0; background: transparent; }
.contact-table-editable { position: relative; cursor: text; transition: background-color 0.15s ease, box-shadow 0.15s ease; }
.contact-table-editable:hover { background: #f8faff; box-shadow: inset 0 0 0 1px #dbe2ff; }
.contact-table-editable.is-editing { padding: 3px 5px; background: #f8faff; }
.contact-table-editable.is-saving { opacity: 0.55; pointer-events: none; }
.contact-table-editable.is-saved { background: #ecfdf3; box-shadow: inset 0 0 0 1px #86efac; }
.contact-table-editable.has-save-error { background: #fff1f2; box-shadow: inset 0 0 0 1px #fda4af; }
.contact-table-comment.has-open-comment { background: #f1f4ff; box-shadow: inset 0 0 0 1px #a9bbff; }
.contact-table-editor { width: 100%; min-width: 105px; min-height: 28px; padding: 4px 6px; border: 1px solid var(--primary); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; outline: 2px solid rgba(71, 98, 255, 0.12); }
.contact-table-editable .select2-container { min-width: 190px; font-size: 12px; }
.contact-table-editable .select2-container--default .select2-selection--single { height: 29px; border-color: var(--primary); border-radius: 7px; outline: 2px solid rgba(71, 98, 255, 0.12); }
.contact-table-editable .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 27px; padding-left: 7px; padding-right: 25px; }
.contact-table-editable .select2-container--default .select2-selection--single .select2-selection__arrow { height: 27px; }
.select2-dropdown { border-color: #a9bbff; border-radius: 8px; box-shadow: 0 10px 28px rgba(16, 24, 40, 0.16); font-size: 13px; }
.select2-container--default .select2-search--dropdown .select2-search__field { padding: 7px 8px; border-color: var(--border); border-radius: 6px; font: inherit; outline: none; }
.select2-results__option { padding: 7px 9px; }
.contact-comment-popover { position: fixed; z-index: 1200; display: grid; gap: 10px; padding: 13px; border: 1px solid #cfd8ff; border-radius: 12px; background: var(--surface); box-shadow: 0 14px 38px rgba(16, 24, 40, 0.2); }
.contact-comment-popover__heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.contact-comment-popover__heading strong { font-size: 14px; }
.contact-comment-popover__heading span,
.contact-comment-popover__footer { color: var(--text-soft); font-size: 11px; }
.contact-comment-popover__editor { width: 100%; min-height: 138px; resize: vertical; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; background: #fbfcff; color: var(--text); font-family: inherit; font-size: 13px; line-height: 1.45; outline: none; }
.contact-comment-popover__editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(71, 98, 255, 0.12); }
.datatable-loading { padding: 36px !important; color: var(--text-muted); text-align: center !important; }
.badge--contact-new { background: #edf2ff; color: var(--primary); }
.badge--contact-in_progress { background: #fff7e6; color: #b54708; }
.badge--contact-replied,
.badge--contact-agreed { background: var(--success-bg); color: var(--success-text); }
.badge--contact-no_reply,
.badge--contact-rejected { background: var(--danger-bg); color: var(--danger-text); }
.badge--contact-archived { background: #f2f4f7; color: #667085; }
[hidden] { display: none !important; }

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 15px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table th {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.table-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.table-sort:hover { color: var(--primary); }
.table-sort__icon { width: 10px; color: var(--text-soft); }
.table-sort__icon::before { content: '↕'; }
.table-sort.is-asc .table-sort__icon::before { content: '↑'; color: var(--primary); }
.table-sort.is-desc .table-sort__icon::before { content: '↓'; color: var(--primary); }

.datatable-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
}

.datatable-summary { margin: 0; color: var(--text-muted); font-size: 14px; }
.datatable-pagination { display: flex; align-items: center; gap: 6px; }
.datatable-page {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
}
.datatable-page:hover:not(:disabled) { border-color: #a9bbff; color: var(--primary); }
.datatable-page.is-active { border-color: var(--primary); background: var(--primary); color: #fff; }
.datatable-page:disabled { cursor: not-allowed; opacity: 0.4; }

.table-person {
  display: grid;
  gap: 4px;
}

.table-person__name {
  font-weight: 700;
}

.table-person__meta {
  color: var(--text-muted);
  font-size: 13px;
}
.telegram-channel-meta { display: block; margin-top: 4px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge--status {
  background: var(--success-bg);
  color: var(--success-text);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
}

.button--primary {
  background: var(--primary);
  color: #fff;
}

.button--primary:hover {
  background: var(--primary-dark);
}

.button--secondary,
.button--ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.button--danger-ghost {
  padding: 8px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--danger-text);
  font-size: 13px;
}

.button--danger-ghost:hover { background: var(--danger-bg); }
.button--table-link { padding: 8px 10px; color: var(--primary); font-size: 13px; }
.button--table-link:hover { background: #edf2ff; }
.table-actions { width: 1%; white-space: nowrap; text-align: right !important; }
.table-actions form { display: inline-flex; margin: 0; }
.table-cell-comment { display: block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users-table td { vertical-align: middle; }
.user-self-label { display: inline-block; margin-left: 6px; color: var(--primary); font-size: 11px; font-weight: 700; }
.field__hint { display: block; margin-top: 5px; color: var(--text-soft); font-size: 12px; }

.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.modal__backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(15, 23, 42, 0.48); cursor: default; }
.modal__dialog { position: relative; width: min(620px, 100%); max-height: min(760px, calc(100vh - 48px)); overflow-y: auto; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24); }
.modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.modal__title { margin: 0; font-size: 24px; }
.modal__close { width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--surface-muted); color: var(--text-muted); cursor: pointer; font-size: 26px; line-height: 1; }
.modal__close:hover { background: #edf2ff; color: var(--primary); }
.columns-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.columns-picker__item { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.columns-picker__item:hover { border-color: #a9bbff; background: #f8faff; }
.columns-picker__item input { width: 18px; height: 18px; accent-color: var(--primary); }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.form-error { margin: 12px 0 0; color: var(--danger-text); font-size: 14px; font-weight: 600; }

.contact-detail-header { margin-bottom: 24px; padding: 4px 2px; }
.detail-back { display: inline-block; margin-bottom: 18px; color: var(--text-muted); font-weight: 600; }
.detail-back:hover { color: var(--primary); }
.detail-back-button { margin-top: 20px; }
.contact-detail-header__main { display: flex; justify-content: space-between; gap: 20px; }
.contact-detail-header__main > div:first-child { min-width: 0; }
.contact-detail-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.contact-detail-title-row h1 { margin: 0; font-size: 36px; line-height: 1.15; }
.contact-detail-header p { margin: 8px 0 0; color: var(--text-muted); font-size: 17px; }
.contact-switcher { display: grid; grid-template-columns: repeat(2, minmax(0, 190px)); gap: 10px; flex: 0 0 auto; align-self: flex-start; }
.contact-switcher__link { display: grid; gap: 4px; min-width: 0; padding: 11px 13px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--text); }
.contact-switcher__link:hover { border-color: #a9bbff; background: #f8faff; color: var(--primary); }
.contact-switcher__link--next { text-align: right; }
.contact-switcher__direction { color: var(--text-soft); font-size: 12px; font-weight: 700; }
.contact-switcher__link strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.contact-switcher__link.is-disabled { opacity: 0.45; cursor: default; }
.contact-switcher__link.is-disabled:hover { border-color: var(--border); background: var(--surface); color: var(--text); }
.contact-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.contact-tag { padding: 6px 10px; border-radius: 999px; background: #edf2ff; color: var(--primary); font-size: 13px; font-weight: 700; }
.contact-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-bottom: 24px; }
.contact-detail-grid .panel { margin: 0; }
.contact-detail-grid--lower { margin-top: 24px; }
.contact-section-title { margin: 0; font-size: 22px; }
.section-count { color: var(--text-soft); font-size: 15px; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; margin: 0; }
.detail-list div { min-width: 0; }
.detail-list dt { margin-bottom: 5px; color: var(--text-soft); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }
.inline-edit-feedback { display: grid; justify-items: end; gap: 4px; text-align: right; }
.inline-edit-help { color: var(--text-soft); font-size: 12px; }
.inline-edit-status { min-height: 17px; color: var(--text-soft); font-size: 12px; font-weight: 700; }
.inline-edit-status.is-saving { color: var(--primary); }
.inline-edit-status.is-success { color: #15803d; }
.inline-edit-status.is-error { max-width: 280px; color: var(--danger-text); }
.inline-editable { position: relative; min-height: 34px; margin: -6px -8px -6px !important; padding: 7px 30px 7px 8px; border: 1px solid transparent; border-radius: 9px; cursor: text; transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease; }
.inline-editable::after { content: '✎'; position: absolute; top: 7px; right: 9px; color: var(--text-soft); font-size: 14px; opacity: 0; transition: opacity 0.15s ease; }
.inline-editable:hover, .inline-editable:focus { border-color: #c6d2ff; background: #f8faff; outline: none; }
.inline-editable:hover::after, .inline-editable:focus::after { opacity: 1; }
.inline-editable.is-editing { padding: 0; border-color: transparent; background: transparent; }
.inline-editable.is-editing::after { display: none; }
.inline-editable.is-saving { opacity: 0.55; pointer-events: none; }
.inline-editable__control { width: 100%; min-height: 34px; padding: 6px 9px; border: 1px solid var(--primary); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; outline: 3px solid rgba(71, 98, 255, 0.12); }
.contact-methods { display: grid; gap: 10px; }
.contact-methods a, .contact-method-row { display: grid; gap: 4px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 13px; }
.contact-methods a:hover { border-color: #a9bbff; background: #f8faff; }
.contact-methods span, .contact-note > span { color: var(--text-soft); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.contact-methods strong { overflow-wrap: anywhere; }
.detail-combined-fields { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.detail-combined-fields__separator { margin: 0 5px; color: var(--text-soft); font-weight: 500; }
.contact-note { margin-top: 16px; padding: 15px; border-radius: 13px; background: var(--surface-muted); }
.contact-note p { margin: 7px 0 0; line-height: 1.55; }
.detail-muted { margin: 0; color: var(--text-muted); }
.channel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.channel-card { min-width: 0; padding: 17px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-muted); }
.channel-card__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.channel-type { color: var(--primary); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.channel-card h3 { margin: 14px 0 5px; }
.channel-card > p { margin: 0 0 15px; color: var(--text-muted); }
.channel-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.channel-metrics span { color: var(--text-soft); font-size: 12px; }
.channel-metrics strong { display: block; margin-top: 3px; color: var(--text); font-size: 15px; }
.detail-items { display: grid; gap: 10px; }
.detail-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.detail-item:last-child { border-bottom: 0; }
.detail-item h3, .detail-item p { margin: 0; }
.detail-item p { margin-top: 5px; color: var(--text-muted); }
.detail-item__aside { display: grid; justify-items: end; gap: 8px; white-space: nowrap; }
.timeline { display: grid; }
.timeline__item { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding-bottom: 18px; }
.timeline__item::before { content: ''; position: absolute; top: 12px; bottom: 0; left: 5px; width: 2px; background: var(--border); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { position: relative; z-index: 1; width: 12px; height: 12px; margin-top: 4px; border: 3px solid #cbd7ff; border-radius: 50%; background: var(--primary); }
.timeline__meta { display: flex; justify-content: space-between; gap: 12px; }
.timeline__meta span, .timeline small { color: var(--text-soft); font-size: 12px; }
.timeline p { margin: 6px 0; line-height: 1.5; }
.contact-danger-zone { display: flex; justify-content: flex-end; margin-top: 6px; padding: 18px 0; }

.button--full {
  width: 100%;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(53, 89, 224, 0.16), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #eef3fb 100%);
}

.auth-page {
  width: min(1040px, 100%);
}

.auth-card {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  overflow: hidden;
}

.auth-card__intro {
  padding: 48px;
  background:
    linear-gradient(145deg, #f2f6ff 0%, #e6edff 100%);
  border-right: 1px solid var(--border);
}

.auth-card__intro h1 {
  margin: 0 0 14px;
  font-size: 42px;
  line-height: 1.05;
}

.auth-card__intro p {
  margin: 0;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.6;
}

.form-card {
  padding: 34px;
  border: 0;
  box-shadow: none;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field__label {
  font-weight: 600;
}

.field__control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 13px 15px;
  color: var(--text);
}

.field__control:focus {
  outline: 2px solid rgba(53, 89, 224, 0.15);
  border-color: #a9bbff;
}

.alert {
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  font-weight: 600;
}

.alert--error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.alert--success { background: var(--success-bg); color: var(--success-text); }

.database-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.database-summary__value { margin: 0; font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.database-summary__value--success { color: var(--success-text); }
.database-warning { margin-bottom: 20px; padding: 15px 17px; border: 1px solid #f5d68a; border-radius: 14px; background: #fffaeb; color: #7a4d00; line-height: 1.5; }
.database-checksum { font-family: Consolas, monospace; }
.migration-error { max-width: 620px; color: var(--danger-text); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.badge--pending { background: #edf2ff; color: var(--primary); }
.badge--running { background: #fffaeb; color: #b54708; }
.badge--completed { background: var(--success-bg); color: var(--success-text); }
.badge--failed, .badge--modified { background: var(--danger-bg); color: var(--danger-text); }
.button:disabled { cursor: not-allowed; opacity: 0.5; }

.empty-state {
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: var(--surface-muted);
}

.empty-state__title {
  margin: 0 0 10px;
  font-size: 20px;
}

.empty-state__text {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.auth-card__hint {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-muted);
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .channel-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .database-summary { grid-template-columns: 1fr; }
  .channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .topbar__right {
    justify-content: space-between;
  }
}

@media (max-width: 840px) {
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 30;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .topbar__menu-button {
    display: inline-flex;
  }

  .topbar__search {
    display: none;
  }

  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-card__intro {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .contact-detail-header__main { flex-direction: column; }
  .contact-detail-grid { grid-template-columns: 1fr; }
  .contact-switcher { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .page-content,
  .topbar {
    padding: 18px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .panel__header,
  .panel__filters,
  .topbar__left,
  .topbar__right {
    flex-direction: column;
    align-items: stretch;
  }

  .datatable-footer { align-items: flex-start; flex-direction: column; }
  .columns-picker { grid-template-columns: 1fr; }
  .modal { padding: 12px; }
  .channel-grid, .detail-list { grid-template-columns: 1fr; }
  .contact-detail-title-row h1 { font-size: 29px; }
  .contact-switcher__link { padding: 10px; }
  .inline-edit-feedback { justify-items: start; text-align: left; }
}
.company-form,
.company-link-form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; color: var(--color-text, #344054); font-size: 13px; font-weight: 600; }
.field__control { width: 100%; }
.checkbox-field { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.company-links { display: grid; gap: 14px; }
.company-link-card { border: 1px solid var(--color-border, #e4e7ec); border-radius: 12px; padding: 12px 14px; background: #fff; }
.company-link-card__summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0; }
.company-link-card__summary h3, .company-link-card__summary p { margin: 0; }
.company-link-card__summary p { margin-top: 5px; color: var(--color-muted, #667085); }
.company-link-card__badges { display: flex; gap: 7px; align-items: flex-start; }
.company-link-card > .company-link-form { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--color-border, #e4e7ec); }
.company-link-card.is-editing > .company-link-form { display: grid; }
.company-link-edit { margin-left: auto; white-space: nowrap; }
.company-link-form__actions { display: flex; justify-content: space-between; gap: 12px; }
.company-link-form--new { margin-top: 16px; border: 1px dashed var(--color-primary, #465fff); border-radius: 12px; padding: 16px; }
.contact-companies-card { margin-bottom: 24px; }
.contact-detail-layout { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(360px, .88fr); gap: 24px; align-items: start; margin-bottom: 24px; }
.contact-detail-column { display: grid; gap: 0; padding-top: 6px; padding-bottom: 6px; }
.contact-detail-section { padding: 22px 0; }
.contact-detail-section + .contact-detail-section { border-top: 1px solid var(--color-border, #e4e7ec); }
.contact-detail-column .contact-companies-card { margin-bottom: 0; }
.contact-detail-column .panel__header { margin-bottom: 16px; }
.contact-detail-column--right .detail-items,
.contact-detail-column--right .timeline { max-height: 520px; overflow: auto; padding-right: 4px; }
.contact-create-form { display: grid; gap: 16px; }
.button--compact { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.agreement-card-actions { display: flex; justify-content: flex-end; gap: 5px; }
.icon-button { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--color-border, #e4e7ec); border-radius: 8px; background: #fff; color: var(--text-muted, #667085); cursor: pointer; transition: border-color .15s ease, color .15s ease, background .15s ease; }
.icon-button svg { width: 15px; height: 15px; fill: currentColor; }
.icon-button:hover { border-color: var(--color-primary, #465fff); color: var(--color-primary, #465fff); background: #f5f7ff; }
.icon-button--danger:hover { border-color: #f04438; color: #d92d20; background: #fff5f4; }
.icon-button:disabled { opacity: .5; cursor: wait; }
@media (max-width: 1080px) { .contact-detail-layout { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } .company-link-card__summary { flex-direction: column; } }
