/* ==========================================================================
   CrewDesk — оформление: сдержанный деловой стиль.
   ========================================================================== */
:root {
  --bg: #eceef2;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #46505e;
  --faint: #7e8898;
  --line: #c6cdd7;
  --line-2: #dde2e9;
  --line-strong: #aeb8c6;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-sf: rgba(37, 99, 235, .09);
  --danger: #dc2626;
  --ok: #16a34a;
  --hi: #ffe58f;
  --sidebar: #f3f5f8;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .07), 0 4px 14px rgba(16, 24, 40, .10);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .09);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Иконки */
.ic {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  color: currentColor;
  flex: none;
}

.ic-sm {
  width: 14px;
  height: 14px;
}

.ic-muted {
  color: var(--faint);
}

.app {
  display: flex;
  height: 100vh;
}

.hidden {
  display: none !important;
}

body.noselect,
body.noselect * {
  user-select: none !important;
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

/* ---------- Главная: поиск по центру + недавние ---------- */
.logo {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #2f6fed, #1d4ed8);
  color: #fff;
  border-radius: 7px;
  font-size: 13px;
}

.brand-title {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -.01em;
}

.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.home-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Левая панель главной: только клиенты */
.home-side {
  width: 252px;
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hs-filter {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 10px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 8px 0 10px;
}

.hs-filter input {
  border: 0;
  background: transparent;
  padding: 7px 0;
  width: 100%;
  min-width: 0;
  outline: none;
  font: inherit;
}

.hs-filter:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-sf);
}

.home-clients {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 14px;
}

.home-clients::-webkit-scrollbar {
  width: 9px;
}

.home-clients::-webkit-scrollbar-thumb {
  background: #cfd4da;
  border-radius: 6px;
  border: 2px solid var(--sidebar);
}

.hc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  min-width: 0;
}

.hc-item:hover {
  background: var(--line-2);
}

.hc-item.active {
  background: var(--accent-sf);
}

.hc-item .v-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
}

.hc-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.hc-item.active .hc-name {
  color: var(--accent);
}

.hc-n {
  flex: none;
  background: var(--line-2);
  color: var(--muted);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
}

.hc-item .mini {
  opacity: .65;
}

.hc-item:hover .mini,
.hc-item.active .mini {
  opacity: 1;
}

.hc-empty {
  color: var(--faint);
  text-align: center;
  padding: 18px 6px;
}

/* Панель судов выбранного клиента */
.cp-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 4px 10px;
  min-width: 0;
}

.cp-title {
  font-weight: 650;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-sub {
  color: var(--faint);
  font-size: 12px;
  flex: none;
}

.cp-spacer {
  flex: 1;
}

.home-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex: none;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-right: 8px;
}

.ht-spacer {
  flex: 1;
}

a.home-admin {
  text-decoration: none;
}

.home-center {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 6vh 24px 48px;
}

.hc-inner {
  width: min(780px, 100%);
  margin: 0 auto;
}

.home-hero {
  margin-bottom: 8px;
}

.home-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 10px 0 16px;
  box-shadow: var(--shadow);
}

.home-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-sf), var(--shadow);
}

.home-search input {
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 15px;
  padding: 14px 0;
  width: 100%;
  min-width: 0;
}

/* нативный крестик поиска убран — есть своя кнопка очистки */
.home-search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.hs-clear {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--faint);
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex: none;
}

.hs-clear:hover {
  background: var(--line-2);
  color: var(--ink);
}

.hr-title,
.hr-group {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--faint);
  font-weight: 600;
  margin: 22px 4px 8px;
}

.recent-list,
.home-results {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.home-results .hr-group {
  margin-top: 16px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 10px 13px;
  cursor: pointer;
  min-width: 0;
}

.recent-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.recent-item .v-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
}

.ri-vessel {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: none;
  max-width: 42%;
}

.ri-client {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
}

.ri-n {
  flex: none;
  background: var(--line-2);
  color: var(--muted);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
}

.ri-when {
  flex: none;
  color: var(--faint);
  font-size: 12px;
}

.recent-item.entry-hit .ri-vessel {
  max-width: 26%;
}

.recent-item.entry-hit .ri-client {
  flex: none;
  max-width: 20%;
}

.ri-preview {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  font-size: 12px;
}

.recent-item mark {
  background: var(--hi);
  padding: 0 1px;
  border-radius: 2px;
}

.recent-empty {
  color: var(--faint);
  text-align: center;
  padding: 30px 0;
}

/* ---------- Корзина ---------- */
.trash-count {
  margin-left: auto;
  background: #fee4e2;
  color: var(--danger);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
}

.trash-box {
  width: 800px;
  max-width: 94vw;
}

/* Поиск в корзине: по названию и содержимому */
.trash-search {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 8px 0 10px;
  margin-left: 6px;
}

.trash-search input {
  border: 0;
  background: transparent;
  padding: 6px 0;
  width: 100%;
  min-width: 0;
  outline: none;
  font: inherit;
}

.trash-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-sf);
}

.trash-retention {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
  flex: none;
}

.trash-retention select {
  font: inherit;
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  background: #fff;
  cursor: pointer;
  outline: none;
}

.btn.danger-btn {
  color: var(--danger);
}

.btn.danger-btn:hover {
  background: #fee4e2;
  border-color: #fca5a1;
}

.trash-list {
  overflow-y: auto;
  max-height: 62vh;
  min-height: 120px;
  padding: 6px;
}

.trash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-2);
  border-radius: 6px;
}

.trash-item:last-child {
  border-bottom: 0;
}

.trash-item:hover {
  background: #f1f4f9;
}

.trash-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent-sf);
  color: var(--accent);
  flex: none;
  min-width: 52px;
  text-align: center;
}

.trash-kind.client {
  background: #f3e8ff;
  color: #7e22ce;
}

.trash-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.trash-name,
.trash-name small {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.trash-name small {
  color: var(--faint);
  font-weight: 400;
  font-size: 11.5px;
}

.trash-date {
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
  flex: none;
}

.t-restore {
  flex: none;
  padding: 4px 9px;
  font-size: 12px;
}

.t-restore .ic {
  width: 15px;
  height: 15px;
}

.trash-empty {
  text-align: center;
  color: var(--muted);
  padding: 46px 20px;
}

/* ---------- Просмотр содержимого из корзины (read-only) ---------- */
#trashViewModal {
  z-index: 110;
}

.trash-view-box {
  width: 1100px;
  max-width: 96vw;
}

.tv-body {
  overflow: auto;
  max-height: 78vh;
  min-height: 120px;
  padding: 4px 16px 16px;
  background: var(--bg);
}

.tv-vessel {
  font-weight: 700;
  font-size: 13.5px;
  margin: 14px 2px 6px;
}

.tv-note {
  color: var(--faint);
  font-weight: 400;
  font-size: 11.5px;
}

.tv-table-wrap {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow-x: auto;
}

.tv-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
}

.tv-table th {
  background: #edf0f5;
  color: #333c4a;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
  border: 1px solid var(--line);
  padding: 6px 9px;
  white-space: nowrap;
}

.tv-table th.tv-group {
  text-align: center;
  background: #e3e8f0;
}

.tv-table td {
  border: 1px solid var(--line-2);
  padding: 5px 9px;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
}

.tv-table td.tv-none {
  color: var(--faint);
  text-align: center;
  padding: 14px;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 6px 12px;
  transition: background .12s, border-color .12s, transform .04s;
}

.btn:hover {
  background: #f4f5f7;
}

.btn:active {
  transform: scale(.98);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-2);
}

.btn.primary .ic {
  width: 16px;
  height: 16px;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  padding: 6px 10px;
}

.btn.ghost:hover {
  background: var(--accent-sf);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s;
  flex: none;
}

.icon-btn:hover {
  background: var(--line-2);
}

.icon-btn.solid {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.icon-btn.solid:hover {
  background: var(--accent-2);
}

.mini {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--faint);
  border-radius: 5px;
  cursor: pointer;
  flex: none;
}

.mini:hover {
  background: var(--line);
  color: var(--ink);
}

/* ---------- Верхняя панель: клиент + вкладки судов + поиск ---------- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 20;
  flex: none;
  min-height: 46px;
}

.crumb-client {
  font: inherit;
  font-weight: 650;
  font-size: 13.5px;
  letter-spacing: -.01em;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: none;
  padding: 5px 9px;
  margin-right: 2px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: inherit;
  cursor: pointer;
}

.crumb-client:hover {
  background: var(--accent-sf);
}

.tab-strip {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  min-width: 0;
  flex: 1;
  scrollbar-width: thin;
  padding: 2px 0;
}

.tab-strip::-webkit-scrollbar {
  height: 5px;
}

.tab-strip::-webkit-scrollbar-thumb {
  background: #cfd4da;
  border-radius: 6px;
}

.vtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
  padding: 5px 6px 5px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12.5px;
  user-select: none;
  flex: none;
}

.vtab:hover {
  background: var(--line-2);
}

.vtab.active {
  background: var(--accent-sf);
  color: var(--ink);
  font-weight: 600;
  border-color: rgba(37, 99, 235, .25);
}

.vtab.dragging {
  opacity: .45;
}

.vtab.drop-before {
  box-shadow: inset 2px 0 0 var(--accent);
}

.vtab.drop-after {
  box-shadow: inset -2px 0 0 var(--accent);
}

.vtab .v-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c5cad1;
  flex: none;
}

.vtab.active .v-dot {
  background: var(--accent);
}

.vtab .v-n {
  font-size: 10.5px;
  opacity: .6;
  font-weight: 600;
}

.vtab .tab-menu {
  width: 18px;
  height: 18px;
}

.vtab.tab-newinput {
  padding: 2px;
}

.vtab.tab-newinput input {
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12.5px;
  outline: none;
  width: 130px;
}

.tab-add {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: var(--accent);
}

.tab-add:hover {
  background: var(--accent-sf);
  border-color: var(--accent);
}

.top-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  margin-left: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 4px 0 9px;
}

.top-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-sf);
}

.top-search input {
  border: 0;
  background: transparent;
  outline: none;
  padding: 6px 0;
  width: 160px;
  font: inherit;
}

.top-search select {
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 2px;
  max-width: 140px;
}

/* ---------- Панель форматирования ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f6f7fa;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.tb-group {
  display: flex;
  gap: 2px;
  background: var(--line-2);
  border-radius: var(--radius);
  padding: 2px;
}

.tb {
  display: inline-grid;
  place-items: center;
  min-width: 29px;
  height: 27px;
  padding: 0 7px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
  transition: background .1s;
}

.tb:hover {
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.tb:active {
  transform: scale(.96);
}

.tb .ic {
  width: 16px;
  height: 16px;
}

.tb-select {
  height: 27px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 0 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}

.tb-hint {
  color: var(--faint);
  font-size: 11.5px;
  margin-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.tb:disabled {
  opacity: .35;
  cursor: default;
}

.tb:disabled:hover {
  background: transparent;
  box-shadow: none;
}

.tb:disabled:active {
  transform: none;
}

/* Кружок «!» — подсказка по горячим клавишам */
.tb-info {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--faint);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex: none;
}

.tb-info:hover {
  color: var(--muted);
  border-color: var(--line-strong);
}

/* подсказка раскрыта — кнопка подсвечена */
.tb-info.on {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-sf);
}

.kbd-pop {
  position: fixed;
  z-index: 95;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  width: 350px;
}

.kbd-title {
  font-weight: 700;
  margin-bottom: 7px;
}

.kbd-row {
  display: flex;
  gap: 10px;
  padding: 2.5px 0;
  font-size: 12px;
  color: var(--muted);
  align-items: baseline;
}

.kbd {
  flex: none;
  min-width: 128px;
  font: 11px/1.5 Consolas, "Courier New", monospace;
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 6px;
  color: var(--ink);
  white-space: nowrap;
  text-align: center;
}

/* Правый блок панели: превью и кнопка скрина */
.tb-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.tb-shot {
  padding: 4px 10px;
  font-size: 12px;
}

.tb-shot .ic {
  width: 15px;
  height: 15px;
}

.toolbar .shot-preview img {
  height: 27px;
  max-width: 120px;
}

/* Цветовые кнопки форматирования (видно текущий цвет) */
.color-btn {
  flex-direction: column;
  gap: 2px;
  height: 27px;
}

.color-btn .ic {
  width: 14px;
  height: 14px;
}

.color-btn .sw {
  width: 16px;
  height: 4px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, .1);
}

/* ---------- Основная область ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 14px 8px;
  overflow: hidden;
}

.grid-wrap {
  flex: 1;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  overflow: auto;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #edf0f5;
  color: #333c4a;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
  border-right: 1px solid var(--line);
  padding: 0;
}

.th-in {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 9px;
}

.th-grip {
  cursor: grab;
  color: #c0c6cd;
  opacity: .7;
  display: inline-grid;
  place-items: center;
  flex: none;
}

.th-grip:active {
  cursor: grabbing;
}

.th-col:hover .th-grip {
  opacity: 1;
  color: var(--faint);
}

.col-name {
  flex: 1;
  outline: none;
  border-radius: 4px;
  padding: 1px 3px;
  cursor: text;
  min-width: 24px;
}

.col-name:focus {
  background: var(--accent-sf);
  box-shadow: 0 0 0 2px var(--accent);
  text-transform: none;
}

.col-menu {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 0;
  background: transparent;
  color: var(--faint);
  border-radius: 5px;
  cursor: pointer;
  flex: none;
}

.col-menu:hover {
  background: var(--line);
  color: var(--ink);
}

.col-menu .ic {
  width: 15px;
  height: 15px;
}

/* Кнопка сортировки в шапке столбца */
.col-sort {
  display: inline-grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  border: 0;
  background: transparent;
  color: var(--faint);
  border-radius: 5px;
  cursor: pointer;
  flex: none;
  font-size: 10px;
  line-height: 1;
  opacity: 0;
  padding: 0 3px;
}

.th-col:hover .col-sort,
.col-sort.on {
  opacity: 1;
}

.col-sort:hover {
  background: var(--line);
  color: var(--ink);
}

.col-sort.on {
  color: var(--accent);
  background: var(--accent-sf);
  font-size: 11px;
}

/* Объединённый заголовок группы */
.th-group {
  text-align: center;
  background: #e3e8f0;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.grp-in {
  padding: 7px 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.grp-name {
  font-weight: 650;
  color: var(--ink);
  cursor: text;
  outline: none;
  border-radius: 4px;
  padding: 1px 4px;
  min-width: 30px;
}

.grp-name:focus {
  background: var(--accent-sf);
  box-shadow: 0 0 0 2px var(--accent);
  text-transform: none;
}

.th-handle {
  width: 32px;
  background: #edf0f5;
}

.th-add {
  width: 40px;
  text-align: center;
}

.col-add {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 0;
  background: transparent;
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer;
}

.col-add:hover {
  background: var(--accent-sf);
}

.th-act {
  width: 72px;
  border-right: 0;
}

tbody td {
  border-bottom: 1px solid var(--line-2);
  border-right: 1px solid var(--line-2);
  padding: 0;
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #f2f5fa;
}

.td-handle {
  width: 32px;
  text-align: center;
  vertical-align: middle;
}

.row-grip {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 26px;
  margin: 2px auto;
  color: #c5cad1;
  cursor: grab;
  opacity: .35;
  border-radius: 5px;
}

tr:hover .row-grip {
  opacity: 1;
}

.row-grip:hover {
  background: var(--line-2);
  color: var(--muted);
}

.row-grip:active {
  cursor: grabbing;
}

.td-add {
  background: #fbfcfd;
}

.td-act {
  width: 72px;
  border-right: 0;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}

.act {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 0;
  background: transparent;
  color: var(--faint);
  border-radius: 5px;
  cursor: pointer;
}

.act:hover {
  background: var(--line-2);
  color: var(--ink);
}

.act.del:hover {
  background: #fee4e2;
  color: var(--danger);
}

/* Ячейка = rich-text */
.cell {
  min-height: 32px;
  padding: 6px 9px;
  outline: 0;
  font: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}

.cell:focus {
  background: var(--accent-sf);
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 3px;
}

/* Массовое выделение ячеек (Ctrl+клик / Shift) */
.cell.sel {
  background: rgba(37, 99, 235, .12);
  box-shadow: inset 0 0 0 1px var(--accent);
  border-radius: 2px;
}

/* Подсветка найденного текста */
mark.txm,
.gr-item mark {
  background: var(--hi);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* Перетаскивание строк/столбцов */
tr.dragging {
  opacity: .4;
}

tr.drop-target td {
  box-shadow: inset 0 2px 0 var(--accent);
}

th.drop-col {
  box-shadow: inset 2px 0 0 var(--accent);
}

th.dragging-col {
  opacity: .5;
}

/* Подсветка строки, к которой перешли из поиска */
@keyframes rowflash {
  0% {
    background: var(--accent-sf);
  }

  100% {
    background: transparent;
  }
}

tr.flash td {
  animation: rowflash 1.6s ease-out;
}

.table-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 2px 2px;
  flex: none;
}

/* Строка-кнопка «+ Строка» в конце таблицы */
tr.tr-addrow td {
  border-right: 0;
  border-bottom: 0;
  padding: 7px 8px;
  background: transparent;
}

tbody tr.tr-addrow:hover td {
  background: transparent;
}

.btn-addrow {
  padding: 5px 12px;
  font-size: 12.5px;
}

.hint {
  color: var(--faint);
  font-size: 11.5px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 70px 20px;
  font-size: 14.5px;
}

/* ---------- Результаты поиска по судам клиента ---------- */
.global-results {
  flex: none;
  max-height: 45%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.gr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  flex: none;
}

#grList {
  overflow-y: auto;
}

.gr-item {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 14px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  align-items: baseline;
}

.gr-item:last-child {
  border-bottom: 0;
}

.gr-item:hover {
  background: #f5f8ff;
}

.gr-item .g-vessel {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gr-item .g-info {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Автоподсказки ---------- */
.suggest-box {
  position: absolute;
  z-index: 60;
  min-width: 170px;
  max-width: 340px;
  max-height: 230px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 4px;
}

.suggest-item {
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: pre-wrap;
  font-size: 12.5px;
}

.suggest-item.active,
.suggest-item:hover {
  background: var(--accent-sf);
}

/* ---------- Выпадающее меню (⋮) ---------- */
.menu {
  position: absolute;
  z-index: 80;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 7px 11px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.menu-item .mi-lbl {
  flex: 1;
  white-space: nowrap;
}

.mi-hint {
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
  flex: none;
}

.menu-sep {
  height: 1px;
  background: var(--line-2);
  margin: 4px 6px;
}

.menu-item:hover {
  background: var(--accent-sf);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: #fee4e2;
}

.menu-item.has-color {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mi-sw {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, .15);
  flex: none;
}

/* ---------- Палитра ---------- */
.palette {
  position: absolute;
  z-index: 85;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(6, 24px);
  gap: 7px;
}

.sw-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, .12);
  cursor: pointer;
  padding: 0;
  transition: transform .08s;
}

.sw-btn:hover {
  transform: scale(1.1);
}

.sw-btn.sel {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sw-custom {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: conic-gradient(from 0deg, #dc2626, #e67e22, #d4a017, #1e8e3e, #0d9488, #2563eb, #5856d6, #8e44ad, #d63384, #dc2626);
}

.sw-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.sw-reset {
  grid-column: 1 / -1;
  border: 0;
  background: var(--line-2);
  border-radius: 7px;
  padding: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
}

.sw-reset:hover {
  background: var(--line);
  color: var(--ink);
}

.filter-pal {
  grid-template-columns: repeat(6, 24px);
}

.pal-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 4px 6px;
}

/* ---------- Тост ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 41, 55, .96);
  color: #fff;
  padding: 9px 16px;
  border-radius: 9px;
  box-shadow: var(--shadow);
  z-index: 90;
  font-weight: 500;
  font-size: 12.5px;
}

/* ---------- Скрин таблицы: превью рядом с кнопкой ---------- */
.shot-preview {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.shot-preview img {
  height: 52px;
  max-width: 220px;
  object-fit: cover;
  object-position: left top;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  background: #fff;
}

.shot-preview .shot-x {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.shot-preview .shot-x:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ---------- Скрин таблицы: модальный просмотр ---------- */
.shot-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.shot-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 94vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shot-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.shot-modal-hint {
  color: var(--muted);
  font-size: 12px;
  margin-right: auto;
}

.shot-scroll {
  overflow: auto;
  padding: 14px;
  background: var(--bg);
}

.shot-scroll img {
  display: block;
  max-width: none;
  box-shadow: var(--shadow);
  border-radius: 4px;
}

/* ---------- Скрин таблицы: офф-скрин разметка снимка ---------- */
.shot-wrap {
  background: #fff;
  padding: 18px 20px;
  width: max-content;
  font: 13px/1.45 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  color: #1f2937;
}

.shot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 10px;
}

.shot-client {
  font-size: 16px;
  font-weight: 700;
}

.shot-sep {
  margin: 0 8px;
  color: #98a1ad;
}

.shot-vessel {
  font-size: 15px;
  font-weight: 600;
  color: #2563eb;
}

.shot-date {
  color: #98a1ad;
  font-size: 12px;
  white-space: nowrap;
}

.shot-table {
  border: 1px solid #d9dde2;
  width: max-content;
}

.shot-table th {
  position: static !important;
}

.shot-table .cell {
  min-height: 0;
}
/* ---------- Мультисортировка, импорт, дата судна, быстрое создание ---------- */
/* приоритет уровня сортировки при нескольких столбцах */
.sort-prio {
  font-size: 9px;
  font-weight: 700;
  margin-left: 2px;
  line-height: 1;
}

/* компактные кнопки-состояния в тулбаре (сброс сортировки, очистка подсветки) */
.btn.tb-chip {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--accent);
  border-color: rgba(37, 99, 235, .45);
  background: var(--accent-sf);
  flex: none;
}

.btn.tb-chip:hover {
  background: #dbe7fd;
}

/* дата судна — бейдж после названия */
.v-date {
  flex: none;
  background: #eef4ff;
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, .25);
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 0 7px;
  line-height: 16px;
  white-space: nowrap;
}

/* быстрое создание судна в панели клиента */
.cp-add {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 10px;
  color: var(--faint);
}

.cp-add .cpa-name {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  color: var(--ink);
}

.cp-add:focus-within {
  border-color: var(--accent);
  border-style: solid;
}

.cpa-chk {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.cpa-chk input {
  accent-color: var(--accent);
  cursor: pointer;
}

.cp-add .cpa-btn {
  padding: 5px 12px;
  font-size: 12px;
}

/* ---------- Календарь ---------- */
.cal-pop {
  position: absolute;
  z-index: 1300;
  width: 272px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  user-select: none;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.cal-title {
  font-weight: 650;
  font-size: 13px;
}

.cal-nav {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.cal-nav:hover {
  background: var(--line-2);
  color: var(--ink);
}

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 2px;
}

.cal-dow div {
  text-align: center;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--faint);
  padding: 3px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day {
  height: 30px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}

.cal-day:hover {
  background: var(--line-2);
}

.cal-day.out {
  color: #c3c9d3;
}

.cal-day.today {
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 700;
}

.cal-day.mid {
  background: var(--accent-sf);
  border-radius: 0;
}

.cal-day.sel {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.cal-day.sel:hover {
  background: var(--accent-2);
}

.cal-day.start {
  border-radius: 7px 0 0 7px;
}

.cal-day.end {
  border-radius: 0 7px 7px 0;
}

.cal-day.start.end {
  border-radius: 7px;
}

.cal-selection {
  margin: 8px 2px 0;
  font-size: 11.5px;
  color: var(--faint);
  min-height: 15px;
}

.cal-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.cal-footer .btn {
  padding: 5px 12px;
  font-size: 12px;
}

.cal-footer .cal-apply[disabled] {
  opacity: .5;
  cursor: default;
}

/* кнопка даты в строке быстрого создания судна */
.cpa-date-btn {
  flex: none;
  border: 1px solid rgba(37, 99, 235, .3);
  background: #eef4ff;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  padding: 2px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.cpa-date-btn:hover {
  background: #dbe7fd;
}

/* ==========================================================================
   Телеграм-контакт и статус судна, фильтры поиска
   ========================================================================== */

/* ---------- Метки судна: статус ON/OFF и телеграм ---------- */
.v-sign {
  flex: none;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 0 7px;
  line-height: 16px;
  white-space: nowrap;
}

.v-sign.on {
  background: #e6f5ec;
  color: #157347;
  border: 1px solid rgba(21, 115, 71, .28);
}

.v-sign.off {
  background: #fdeceb;
  color: #b42318;
  border: 1px solid rgba(180, 35, 24, .25);
}

.v-tg {
  flex: none;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #eef7fd;
  color: #0b6a9e;
  border: 1px solid rgba(11, 106, 158, .22);
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 0 7px;
  line-height: 16px;
}

/* ---------- Строка фильтров под поиском на главной ---------- */
.home-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 4px 0;
}

.hf-lbl {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--faint);
  font-weight: 600;
}

.hf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 20px;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hf-chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.hf-chip.on {
  border-color: rgba(37, 99, 235, .45);
  background: var(--accent-sf);
  color: var(--accent);
  font-weight: 600;
}

.hf-clear {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: var(--faint);
  text-decoration: underline;
  cursor: pointer;
  padding: 5px 4px;
}

.hf-clear:hover {
  color: var(--danger);
}

/* ---------- Поле телеграма в строке быстрого создания судна ---------- */
.cp-add .cpa-tg {
  flex: none;
  width: 150px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  outline: none;
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  padding: 3px 10px;
}

.cp-add .cpa-tg:focus {
  border-color: var(--accent);
}

.cpa-sign {
  flex: none;
  min-width: 62px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--faint);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.cpa-sign:hover {
  border-color: var(--line-strong);
  color: var(--muted);
}

.cpa-sign.on {
  background: #e6f5ec;
  color: #157347;
  border-color: rgba(21, 115, 71, .35);
}

.cpa-sign.off {
  background: #fdeceb;
  color: #b42318;
  border-color: rgba(180, 35, 24, .3);
}

/* ---------- Выпадающий список существующих контактов ---------- */
.tg-drop {
  position: absolute;
  z-index: 1400;
  max-width: 340px;
  max-height: 260px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 4px;
}

.tgd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--ink);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}

.tgd-item:hover,
.tgd-item.sel {
  background: var(--accent-sf);
}

.tgd-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.tgd-n {
  flex: none;
  background: var(--line-2);
  color: var(--muted);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  padding: 0 7px;
  line-height: 16px;
}

.tgd-sign {
  flex: none;
  font-size: 10.5px;
  color: var(--faint);
  white-space: nowrap;
}

/* ---------- Выбор контакта: фильтр поиска и меню судна ---------- */
.tg-pick {
  position: absolute;
  z-index: 1400;
  width: 300px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.tgp-search {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  color: var(--faint);
  margin-bottom: 6px;
}

.tgp-search:focus-within {
  border-color: var(--accent);
}

.tgp-search input {
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  padding: 7px 0;
  width: 100%;
  min-width: 0;
}

.tgp-list {
  max-height: 250px;
  overflow: auto;
}

.tgp-empty {
  color: var(--faint);
  font-size: 12px;
  padding: 10px 8px;
}

.tgp-foot {
  border-top: 1px solid var(--line-2);
  margin-top: 6px;
  padding-top: 6px;
}

.tgp-reset {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  width: 100%;
  text-align: left;
}

.tgp-reset:hover {
  background: var(--line-2);
  color: var(--danger);
}

/* ---------- Окно «Контакты ТГ» ---------- */
.tg-box {
  width: 1000px;
  max-width: 96vw;
  height: 640px;
  max-height: 92vh;
}

.tg-scope {
  flex: none;
}

.tg-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
  flex: 1;
}

.tg-list {
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  padding: 8px;
}

.tg-item {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.tg-item:hover {
  background: #fff;
  border-color: var(--line-2);
}

.tg-item.active {
  background: #fff;
  border-color: rgba(37, 99, 235, .45);
  box-shadow: var(--shadow-sm);
}

.tgi-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.tgi-meta {
  flex: none;
  font-size: 11.5px;
  color: var(--muted);
}

.tg-vessels {
  overflow: auto;
  padding: 12px 14px;
  min-width: 0;
}

.tgv-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 8px;
}

.tgv-head strong {
  font-size: 14px;
}

.tgv-head span {
  color: var(--muted);
  font-size: 12px;
  margin-right: auto;
}

.tg-hint {
  color: var(--faint);
  font-size: 12.5px;
  padding: 16px 4px;
}

/* ==========================================================================
   Универсальный импорт из Excel
   ========================================================================== */
.import-box {
  width: 900px;
  max-width: 96vw;
  height: 640px;
  max-height: 92vh;
}

.import-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  min-height: 0;
}

.import-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  flex: none;
}

.import-msg {
  color: var(--muted);
  font-size: 12.5px;
  margin-right: auto;
}

/* дропзона выбора файла */
.imp-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  min-height: 320px;
  border: 2px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  padding: 24px;
}

.imp-drop:hover,
.imp-drop.over {
  border-color: var(--accent);
  background: var(--accent-sf);
  color: var(--accent);
}

.imp-drop-ic .ic {
  width: 44px;
  height: 44px;
}

.imp-drop-t {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.imp-drop-s {
  font-size: 12.5px;
  max-width: 460px;
}

/* блоки настроек */
.imp-h {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--faint);
  font-weight: 600;
  margin: 4px 2px 8px;
}

.imp-section {
  margin-bottom: 14px;
}

.imp-client {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--sidebar);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.imp-radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.imp-radio input {
  accent-color: var(--accent);
  cursor: pointer;
}

#impClientSel,
#impNewName,
.imp-target {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 6px 10px;
  outline: none;
}

#impClientSel:focus,
#impNewName:focus,
.imp-target:focus {
  border-color: var(--accent);
}

#impClientSel:disabled,
#impNewName:disabled {
  background: var(--line-2);
  color: var(--faint);
}

/* карточка судна */
.imp-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
}

.imp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.imp-row + .imp-row {
  margin-top: 8px;
}

.imp-idx {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-sf);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.imp-vname {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  padding: 6px 10px;
  outline: none;
}

.imp-vname:focus {
  border-color: var(--accent);
}

.imp-tg {
  flex: none;
  width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  padding: 6px 10px;
  outline: none;
}

.imp-tg:focus {
  border-color: var(--accent);
}

.imp-info {
  flex: none;
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
}

.imp-target-lbl {
  flex: none;
  font-size: 12.5px;
  color: var(--muted);
}

.imp-mode {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.imp-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #157347;
  background: #e6f5ec;
  border: 1px solid rgba(21, 115, 71, .22);
  border-radius: 7px;
  padding: 5px 9px;
}

/* ==========================================================================
   Масштаб и выравнивание: подпись панели клиентов, «Показать ещё»,
   фильтр судов в карточке, кнопка «+N» во вкладках, единые высоты контролов
   ========================================================================== */

/* подпись «Клиенты · N» над фильтром в левой панели */
.hs-cap {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 12px 12px 0;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--faint);
  font-weight: 600;
}

/* кнопка постраничной подгрузки в списках */
.hs-more {
  display: block;
  width: 100%;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 6px;
  cursor: pointer;
}

.hs-more:hover {
  background: var(--accent-sf);
  border-color: var(--accent);
}

/* фильтр судов в карточке клиента — в стиле фильтра клиентов */
.cp-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  margin-bottom: 10px;
  color: var(--faint);
}

.cp-filter input {
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  padding: 8px 0;
  width: 100%;
  min-width: 0;
  color: var(--ink);
}

.cp-filter:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-sf);
}

/* «+N» в строке вкладок судов */
.vtab-more {
  flex: none;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.vtab-more:hover {
  background: var(--accent-sf);
  border-color: var(--accent);
}

/* поле поиска клиента в диалоге импорта */
#impClientQ {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 6px 10px;
  outline: none;
  width: 170px;
}

#impClientQ:focus {
  border-color: var(--accent);
}

#impClientQ:disabled {
  background: var(--line-2);
  color: var(--faint);
}

/* ---------- Выравнивание: единые высоты контролов ---------- */
/* строка быстрого создания судна: все элементы одной высоты */
.cp-add .cpa-name {
  height: 30px;
}

.cp-add .cpa-tg {
  height: 26px;
  width: 150px;
}

.cpa-date-btn,
.cpa-sign {
  height: 22px;
  line-height: 20px;
  padding: 0 10px;
}

.cpa-sign {
  min-width: 78px;
  text-align: center;
}

.cp-add .cpa-btn {
  height: 30px;
  padding: 0 14px;
}

/* фильтры на главной: одна высота с полем поиска по краям */
.home-filters {
  padding-left: 6px;
}

.hf-chip {
  height: 30px;
  padding: 0 12px;
}

.hf-clear {
  height: 30px;
}

/* шапка карточки клиента: кнопки одной высоты */
.cp-head .btn {
  height: 30px;
  padding: 0 12px;
}

/* верх главной: кнопки одной высоты */
.home-top .btn {
  height: 32px;
  padding: 0 12px;
}

/* модальные шапки: кнопки одной высоты */
.shot-bar .btn {
  height: 30px;
  padding: 0 12px;
}

/* селекторы импорта одной высоты с полями */
#impClientSel,
#impNewName,
.imp-target {
  height: 32px;
}

.imp-vname,
.imp-tg {
  height: 32px;
}

.imp-row .cpa-date-btn,
.imp-row .cpa-sign {
  height: 24px;
  line-height: 22px;
}

/* ==========================================================================
   Явные элементы управления: кнопки «Назад», меню ⋮ у судов,
   заголовок в окне телеграм-контакта, стрелки на фильтрах
   ========================================================================== */

/* «← Главная» в шапке таблицы — заметная кнопка возврата */
.btn.ghost.btn-home {
  flex: none;
  font-weight: 600;
  border: 1px solid rgba(37, 99, 235, .35);
  background: var(--accent-sf);
}

.btn.ghost.btn-home:hover {
  background: #dbe7fd;
}

/* «← Назад» в карточке клиента */
.cp-back {
  flex: none;
  font-weight: 600;
  color: var(--muted);
}

.cp-back:hover {
  color: var(--ink);
}

/* видимая кнопка меню ⋮ в строке судна */
.ri-menu {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--muted);
}

.recent-item:hover .ri-menu {
  border-color: var(--line-strong);
  color: var(--ink);
}

.ri-menu:hover {
  background: var(--accent-sf) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* кнопка меню клиента в левой панели — всегда видима */
.hc-item .mini {
  opacity: 1;
  border: 1px solid transparent;
}

.hc-item:hover .mini {
  border-color: var(--line-2);
  background: #fff;
}

/* подпись «Фильтры поиска:» с иконкой */
.hf-lbl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* стрелка-подсказка на кнопках-фильтрах: видно, что откроется выбор */
.hf-chip::after {
  content: "▾";
  font-size: 9px;
  opacity: .55;
  margin-left: 2px;
}

/* заголовок окна выбора телеграм-контакта */
.tgp-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  padding: 2px 4px 8px;
}

.tgp-head span {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--faint);
}

/* кнопка «добавить новый контакт» в списке */
.tgp-new {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px dashed rgba(37, 99, 235, .45);
  background: var(--accent-sf);
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  border-radius: 7px;
  padding: 7px 9px;
  margin-bottom: 5px;
  cursor: pointer;
}

.tgp-new:hover {
  background: #dbe7fd;
}

.tgp-new .ic {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Логотип, фильтры главной корзины, корзина строк судна
   ========================================================================== */
.logo-img {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex: none;
  display: block;
}

/* строка фильтров в главной корзине */
.trash-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--sidebar);
  flex: none;
}

.tf-hint {
  font-size: 11.5px;
  color: var(--faint);
  margin-left: auto;
}

/* превью строки в корзине судна — одна строка с многоточием */
.vt-preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* бейджи судна в строке главной корзины */
.trash-name .v-date,
.trash-name .v-sign,
.trash-name .v-tg {
  margin-left: 6px;
  vertical-align: middle;
}

/* ==========================================================================
   Корзина строк судна — «история строк» в виде таблицы
   (зелёные — текущие в таблице, красные — удалённые, справа дата удаления)
   ========================================================================== */
.vt-box {
  width: 1120px;
}

/* вторая строка шапки: легенда цветов, счётчики, срок хранения */
.vt-subbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--sidebar);
  flex: none;
  font-size: 12px;
  color: var(--muted);
}

.vt-legend {
  display: flex;
  align-items: center;
  gap: 14px;
}

.vt-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vt-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.vt-dot.current {
  background: var(--ok);
}

.vt-dot.deleted {
  background: var(--danger);
}

.vt-counts {
  color: var(--faint);
}

.vt-retention {
  margin-left: auto;
  color: var(--faint);
}

/* область прокрутки таблицы (по вертикали и горизонтали) */
.vt-list {
  padding: 0;
  overflow: auto;
}

.vt-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
}

.vt-table th,
.vt-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-2);
  text-align: left;
  vertical-align: top;
}

.vt-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sidebar);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.vt-th-status {
  width: 30px;
}

.vt-th-date {
  width: 150px;
  white-space: nowrap;
}

.vt-th-act {
  width: 156px;
}

/* цветовая маркировка строк — как в истории изменений документа */
.vt-tr.current {
  background: #f0fdf4;
}

.vt-tr.current:hover {
  background: #e6f8ec;
}

.vt-tr.deleted {
  background: #fef2f2;
}

.vt-tr.deleted:hover {
  background: #fde5e5;
}

.vt-tr.deleted .vt-cell {
  color: #7f1d1d;
}

.vt-status .vt-dot {
  margin-top: 4px;
}

.vt-cell {
  max-width: 320px;
  overflow-wrap: anywhere;
}

/* ячейки корзины — только для чтения: гасим интерактив вложенного контента */
.vt-cell * {
  cursor: default;
}

.vt-date {
  white-space: nowrap;
  color: var(--faint);
  font-size: 12px;
}

.vt-tr.deleted .vt-date {
  color: var(--danger);
  font-weight: 600;
}

.vt-current-tag {
  color: var(--ok);
  font-weight: 600;
}

.vt-acts {
  white-space: nowrap;
}

.vt-acts .t-restore {
  padding: 4px 9px;
  font-size: 12px;
  margin-right: 4px;
}

.vt-acts .t-restore .ic {
  width: 15px;
  height: 15px;
}

.vt-empty {
  text-align: center;
  color: var(--muted);
  padding: 46px 20px;
}
