:root {
  --primary-color: rgb(30, 120, 120);
  --primary-light: rgba(30, 120, 120, 0.10);
  --cell-hover-bg: #9ec9c7;
  --border-color: #b8c5c4;
  --text-main: #1a2b2b;
  --text-muted: #5f6f6f;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-main);
  padding-top: 10px;
}

.container-fluid { padding: 0 20px; max-width: 100%; }
.main-content { margin-top: 10px; }
.card-body { padding: 16px; }

.card {
  border-radius: 8px; box-shadow: 0 2px 15px rgba(0,0,0,0.08);
  border: 1px solid var(--border-color); margin-bottom: 15px; background: #fff;
}

.card-header-plain {
  background-color: #fff; border-bottom: 1px solid var(--border-color);
  padding: 15px 20px; border-radius: 8px 8px 0 0 !important;
}
.header-wrapper { width: 100%; align-items: center !important; }
.page-title { color: var(--text-main); }
.header-meta { color: var(--text-muted) !important; font-size: 0.85rem; }
.meta-item { display: inline; }
.header-meta b { color: inherit; }

.header-actions { flex-direction: row !important; align-items: center; justify-content: flex-end; }
.header-actions .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-color); color: var(--text-main); background: #fff; white-space: nowrap;
  line-height: 1.2; text-align: center;
}
.header-actions .btn i { line-height: 1; }
.header-actions .btn:hover:not(:disabled) {
  background-color: var(--primary-light); border-color: var(--primary-color);
  color: var(--primary-color); transform: translateY(-1px);
}
.header-actions .btn-success { color: #198754; border-color: #198754; }
.header-actions .btn-success:hover:not(:disabled) { background-color: rgba(25, 135, 84, 0.1); color: #198754; }
.header-actions .btn-danger { color: #dc3545; border-color: #dc3545; }
.header-actions .btn-danger:hover:not(:disabled) { background-color: rgba(220, 53, 69, 0.1); color: #dc3545; }

.error-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: #f8fafc;
}
.app-error {
  margin-bottom: 16px;
  border-radius: 8px; border-color: rgba(180, 35, 24, 0.28);
  background: #fff7f5; color: #5f1f1a;
}
.error-page .app-error {
  width: min(680px, 100%); margin: 0; padding: 18px 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.app-error__header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.app-error__icon {
  flex: 0 0 auto; color: #b42318; font-size: 1.2rem; line-height: 1;
}
.app-error__body { min-width: 0; }
.app-error__title {
  color: #5f1f1a; font-weight: 700; font-size: 1rem;
}
.app-error__message { color: #6d2b26; line-height: 1.45; }
.app-error__code {
  margin-top: 8px; color: #8a4b45; font-size: 0.78rem;
}
.app-error__details { margin-top: 10px; color: #6d2b26; }
.app-error__details summary { cursor: pointer; font-size: 0.85rem; }
.app-error__details pre {
  margin: 8px 0 0; white-space: pre-wrap; word-break: break-word;
  padding: 10px; border-radius: 6px; background: rgba(180, 35, 24, 0.08);
  color: inherit; font-size: 0.78rem;
}

/* Панель активных фильтров и сортировки */
.active-panel {
  display: flex; flex-direction: column; gap: 2px; padding: 6px 16px;
  margin-bottom: 16px; background: #f8fafc; border: 1px solid var(--border-color);
  border-radius: 8px; border-left: 4px solid var(--primary-color);
}
.active-section { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 2px 0; }
.section-label { font-weight: 600; color: var(--text-main); font-size: 0.9rem; white-space: nowrap; }

.active-badge {
  background-color: var(--primary-light); color: var(--text-main);
  border: 1px solid var(--border-color); border-radius: 20px;
  padding: 4px 10px; font-size: 0.85rem; cursor: pointer;
  transition: all 0.2s ease; display: inline-flex; align-items: center;
  gap: 6px; user-select: none; font-family: inherit; line-height: 1.3;
  appearance: none; -webkit-appearance: none;
}
.active-badge:hover { background-color: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.active-badge:focus-visible {
  outline: 3px solid rgba(30, 120, 120, 0.35);
  outline-offset: 2px;
  background-color: var(--primary-light);
  border-color: var(--primary-color);
}
.active-badge .bi-x { font-size: 0.9em; opacity: 0.7; }

/* Таблица и оверлей пустого состояния */
.table-responsive { border-radius: 8px; overflow-x: auto; position: relative; }
.table-responsive.table-empty { overflow-x: hidden !important; min-height: 550px; }

.empty-message-overlay {
  display: none; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  align-items: center; justify-content: center; z-index: 1; pointer-events: none;
  padding-top: 140px;
}
.table-empty .empty-message-overlay { display: flex; }

.empty-message-content {
  text-align: center; color: var(--text-muted); background: rgba(255,255,255,0.95);
  padding: 30px 40px; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  pointer-events: auto; border: 1px solid var(--border-color);
}

.table-empty thead { position: relative; z-index: 10; pointer-events: auto; background: transparent; }
.table-empty .th-row-title th { background-color: var(--primary-light); }
.table-empty .th-row-filters th { background-color: #f8f9fa; }

.table {
  margin-bottom: 0; width: 100%; border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--border-color); font-size: 14px; line-height: 1.5;
  --bs-table-hover-bg: transparent; border-radius: 8px 8px 0 0;
}
.mobile-controls-label-row { display: none; }

.th-row-title th {
  background-color: var(--primary-light); border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color); font-weight: 600; color: var(--text-main);
  vertical-align: middle; padding: 10px 8px; white-space: normal; overflow-wrap: break-word;
  min-width: 150px; max-width: 250px; box-sizing: border-box; transition: background-color 0.2s ease, color 0.2s ease;
}
.th-row-title th:last-child { border-right: none; }
.th-row-title th:hover { background-color: var(--primary-color) !important; color: #fff !important; }
.th-row-title th:hover .sortable-header { color: #fff !important; }
.th-row-title th:hover .sort-icon { color: rgba(255,255,255,0.85) !important; opacity: 1; }

.th-row-filters th {
  background-color: #f8f9fa; border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color); padding: 6px 8px; vertical-align: middle;
  min-width: 150px; max-width: 250px; white-space: normal; overflow-wrap: break-word; box-sizing: border-box;
}
.th-row-filters th:last-child { border-right: none; }

.table td {
  font-size: 14px; vertical-align: middle; padding: 10px 8px;
  border-bottom: 1px solid var(--border-color); border-right: 1px solid var(--border-color);
  white-space: normal; overflow-wrap: break-word; overflow: visible; min-width: 150px; max-width: 250px;
  position: relative; color: var(--text-main); transition: background-color 0.15s ease; box-sizing: border-box;
}
.table td:last-child { border-right: none; }

.table-hover tbody tr:hover td, .table-hover tbody tr:hover th { background-color: var(--primary-light) !important; }
.table-hover tbody tr:hover td:hover, .table-hover tbody tr:hover th:hover { background-color: var(--cell-hover-bg) !important; }

.sortable-header { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 5px; white-space: normal; word-break: break-word; color: inherit; }
.sortable-header:focus-visible {
  outline: 3px solid rgba(30, 120, 120, 0.35);
  outline-offset: 3px;
  border-radius: 4px;
}
.sort-icon { font-size: 0.8em; opacity: 0.5; color: inherit; }
.sort-icon.active { opacity: 1; color: var(--primary-color); }

.filter-input { width: 100%; border-radius: 5px; border: 1px solid var(--border-color); padding: 5px 8px; font-size: 0.9em; height: 32px; background: #fff; color: var(--text-main); }
select.filter-input {
  padding-right: 2rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235f6f6f' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 10px 10px;
}
select.filter-input option {
  background: #fff;
  color: var(--text-main);
}
.filter-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 0.2rem rgba(30, 120, 120, 0.25); outline: none; }
.filter-input:focus-visible,
.page-size-selector:focus-visible,
.page-jump-input:focus-visible {
  outline: 3px solid rgba(30, 120, 120, 0.25);
  outline-offset: 1px;
}
.filter-active { border-color: var(--primary-color) !important; background-color: var(--primary-light) !important; }

.page-size-control { margin-left: 0; }
.page-size-label { display: inline-flex; align-items: center; line-height: 1.1; }
.page-size-selector { width: auto !important; min-width: 70px; height: 32px; font-size: 0.9em; border-color: var(--border-color); color: var(--text-main); }

/* Пагинация: скруглённые квадратные кнопки с границей */
.pagination-custom { gap: 6px; display: flex; flex-wrap: wrap; margin-left: 0 !important; }
.pagination-custom .page-item { margin: 0 !important; }
.pagination-custom .page-link {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  min-width: 38px; height: 38px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: var(--text-main);
  transition: all 0.2s ease;
}
.pagination-custom .page-item.active .page-link {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}
.pagination-custom .page-item:not(.active):not(.disabled) .page-link:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}
.pagination-custom .page-item.disabled .page-link {
  background: transparent; color: var(--text-muted);
  cursor: default; pointer-events: none; opacity: 0.6;
}
.pagination-custom .page-link i { font-size: 0.9em; }
.pagination-custom .page-link:focus-visible,
.page-jump-btn:focus-visible,
.header-actions .btn:focus-visible,
.mobile-section-toggle:focus-visible,
.btn-dict:focus-visible,
.dict-item:focus-visible {
  outline: 3px solid rgba(30, 120, 120, 0.35);
  outline-offset: 2px;
  box-shadow: none;
}

/* Форма перехода на страницу */
.page-jump-form { display: flex; align-items: center; gap: 6px; margin-left: 15px; color: var(--text-muted); }
.page-jump-input {
  width: 60px; height: 38px; text-align: center; font-size: 0.9em;
  border-radius: 8px; border: 1px solid var(--border-color); color: var(--text-main);
  background: #fff; transition: border-color 0.2s; box-shadow: none;
}
.page-jump-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 0.15rem rgba(30, 120, 120, 0.2); }
.page-jump-btn {
  height: 38px; min-width: 38px; padding: 0 10px; font-size: 0.9em;
  border-radius: 8px; border: 1px solid var(--border-color); background: #fff;
  color: var(--primary-color); display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; cursor: pointer;
}
.page-jump-btn:hover { background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-color); }

.status-bar { background-color: #f8f9fa; padding: 8px 15px; border-top: 1px solid var(--border-color); font-size: 0.85em; color: var(--text-muted); }

.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.92); display: none; justify-content: center; align-items: center; z-index: 9999; flex-direction: column; gap: 15px; }
.spinner { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-text { color: var(--text-main); font-size: 0.9em; }

.page-jump-input.is-invalid { border-color: #dc3545 !important; box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important; }
.empty-value { color: var(--text-muted); }
.text-muted, .status-bar { color: var(--text-muted) !important; }

@media (max-width: 1200px) { .container-fluid { padding: 0 15px; } }
@media (max-width: 992px) { .container-fluid { padding: 0 10px; } .table th, .table td { padding: 8px; } }
@media (max-width: 768px) {
  body { padding-top: 0; }
  .container-fluid { padding: 0; }
  .main-content { margin-top: 0; }
  .card {
    min-height: 100vh;
    margin-bottom: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .card-header-plain {
    padding: 12px 10px;
    border-radius: 0 !important;
  }
  .card-body { padding: 10px; }
  .header-wrapper {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .header-info { width: 100%; }
  .page-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 1.05rem;
    line-height: 1.25;
    color: var(--text-main) !important;
    margin-bottom: 6px !important;
  }
  .header-meta {
    display: grid;
    gap: 3px;
    line-height: 1.3;
    font-size: 0.82rem;
    color: var(--text-muted) !important;
  }
  .meta-item {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: baseline;
  }
  .meta-item--branch {
    display: block;
    overflow-wrap: break-word;
    white-space: normal;
  }
  .meta-separator { display: none; }
  .header-meta b {
    color: inherit;
    font-weight: 600;
  }
  .header-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    justify-content: stretch;
    margin-top: 8px;
    gap: 8px !important;
  }
  .header-actions .btn {
    display: flex;
    width: 100%;
    min-height: 38px;
    justify-content: center;
    align-items: center;
    white-space: normal;
    line-height: 1.15;
  }
  .header-actions > .btn:first-child:nth-last-child(2) {
    grid-column: 1 / -1;
  }
  .header-actions > .page-size-control {
    grid-column: 1 / -1;
    justify-content: space-between;
    align-items: center !important;
    min-height: 38px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
  }
  .page-size-label {
    min-height: 34px;
    color: var(--text-muted) !important;
  }
  .page-size-selector {
    min-width: 76px;
    height: 34px;
  }
  .active-panel {
    padding: 8px 10px;
    margin-bottom: 10px;
    border-radius: 8px;
  }
  .active-section {
    align-items: flex-start;
    gap: 6px;
  }
  .section-label {
    width: 100%;
    font-size: 0.82rem;
  }
  .active-badge {
    max-width: 100%;
    border-radius: 8px;
    padding: 5px 8px;
    white-space: normal;
  }

  .table-responsive {
    overflow: visible;
    border: 0;
    border-radius: 0;
    margin: 0;
  }
  .table-responsive.table-empty {
    min-height: 0;
    overflow: visible !important;
  }
  .table {
    display: block;
    border: 0;
    background: transparent;
    font-size: 13px;
  }
  .table thead,
  .table tbody,
  .table tr {
    display: block;
  }
  .mobile-controls-label-row {
    display: block !important;
    margin: 0 0 6px;
  }
  .mobile-controls-label-row th,
  .mobile-controls-label-row td {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
  }
  .mobile-filter-label-row {
    margin-top: 10px;
  }
  .mobile-sort-label-row th,
  .mobile-filter-label-row th {
    padding: 0;
  }
  .mobile-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    color: var(--text-muted);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
  }
  .mobile-section-toggle span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  .mobile-section-toggle-icon {
    flex: 0 0 auto;
    color: var(--primary-color);
    transition: transform 0.2s ease;
  }
  .mobile-section-toggle[aria-expanded="true"] .mobile-section-toggle-icon {
    transform: rotate(180deg);
  }
  .mobile-data-label-row {
    margin: 10px 0 6px;
  }

  .th-row-title {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
    gap: 6px;
    overflow-x: visible;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
  }
  .th-row-title.is-collapsed {
    display: none !important;
  }
  .th-row-title th {
    display: flex;
    min-width: 0;
    max-width: none;
    width: auto !important;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--primary-light);
    color: var(--text-main);
    white-space: normal;
  }
  .th-row-title th.sort-cell-empty { display: none; }
  .th-row-title th:last-child { border-right: 1px solid var(--border-color); }
  .th-row-title th:hover { color: var(--primary-color) !important; background: var(--primary-light) !important; }
  .th-row-title th:hover .sortable-header { color: var(--primary-color) !important; }
  .th-row-title th:hover .sort-icon { color: var(--primary-color) !important; }
  .sortable-header {
    width: 100%;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    font-size: 0.82rem;
    color: var(--text-main);
  }
  .sort-icon { color: var(--primary-color); }

  .th-row-filters {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
  }
  .th-row-filters.is-collapsed {
    display: none !important;
  }
  .th-row-filters th {
    display: grid;
    grid-template-columns: minmax(108px, 38%) minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: none;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .th-row-filters th.filter-cell-empty { display: none; }
  .th-row-filters th::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
  }
  .filter-wrapper { min-width: 0; }
  .filter-input {
    max-width: 100%;
    height: 36px;
    font-size: 0.9rem;
  }
  .btn-dict {
    width: 34px;
    height: 36px;
  }
  .dict-dropdown {
    left: auto;
    right: 0;
    width: min(320px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
  }

  .table tbody tr {
    margin-bottom: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
  }
  .table tbody tr.mobile-data-label-row {
    margin: 10px 0 6px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .table tbody tr:hover td { background: transparent !important; }
  .table td {
    display: grid;
    grid-template-columns: minmax(108px, 38%) minmax(0, 1fr);
    gap: 10px;
    min-width: 0;
    max-width: none;
    width: 100%;
    padding: 9px 10px;
    border-right: 0;
    border-bottom: 1px solid #dde5e4;
    font-size: 0.9rem;
    line-height: 1.35;
  }
  .table td:last-child { border-bottom: 0; }
  .table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.25;
  }
  .table tbody tr.mobile-data-label-row td {
    display: flex;
    width: 100%;
    padding: 0 2px;
    border: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
  }
  .table tbody tr.mobile-data-label-row td::before {
    content: none;
  }
  .table td .badge {
    justify-self: start;
    white-space: normal;
  }

  .empty-message-overlay {
    position: static;
    display: none;
    padding: 0;
    margin-top: 10px;
  }
  .table-empty .empty-message-overlay { display: flex; }
  .empty-message-content {
    width: 100%;
    padding: 24px 16px;
    box-shadow: none;
  }

  .status-bar {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
  }
  .status-bar > div {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
    text-align: center;
  }
  .status-bar .d-flex.align-items-center {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .pagination-custom { justify-content: center; }
  .pagination-custom .page-link {
    min-width: 34px;
    height: 34px;
    border-radius: 8px;
  }
  .page-jump-form {
    width: 100%;
    margin-left: 0;
    justify-content: center;
  }
  .page-jump-input,
  .page-jump-btn {
    height: 36px;
  }
}
@media (max-width: 576px) {
  .card-body { padding: 8px; }
  .header-actions { gap: 6px !important; }
  .header-actions .btn { font-size: 0.82rem; }
  .th-row-filters th,
  .table td {
    grid-template-columns: minmax(96px, 36%) minmax(0, 1fr);
  }
  .pagination-custom { flex-wrap: wrap; justify-content: center; }
  .page-jump-input { width: 60px; }
}
@media (max-width: 400px) {
  .card-header-plain { padding: 10px 8px; }
  .page-title { font-size: 1rem; }
  .page-size-selector { min-width: 60px; font-size: 0.8em; }
  .page-jump-input { width: 50px; font-size: 0.8em; }
  .th-row-filters th,
  .table td {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .th-row-filters th::before,
  .table td::before {
    font-size: 0.76rem;
  }
}

/* ===== Выпадающий словарь фильтров ===== */
.filter-wrapper { position: relative; display: flex; align-items: center; gap: 4px; width: 100%; }

.btn-dict {
    flex-shrink: 0; width: 28px; height: 32px; padding: 0; font-size: 16px; line-height: 1;
    appearance: none; -webkit-appearance: none;
    background: #fff; border: 1px solid var(--border-color); border-radius: 4px; cursor: pointer;
    color: var(--text-main);
    transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.btn-dict i { display: block; color: inherit; font-size: 1.05rem; line-height: 1; }
.btn-dict:hover { background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-color); }

.dict-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 1050;
    min-width: 220px; max-width: 280px; max-height: 280px;
    background: #fff; border: 1px solid var(--border-color); border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15); display: none;
    flex-direction: column; overflow: hidden;
}
.dict-dropdown.show { display: flex; }

.dict-search-wrap { padding: 6px; border-bottom: 1px solid #eee; background: #f8f9fa; }
.dict-search { border-radius: 4px; border-color: var(--border-color); }
.dict-search:focus { border-color: var(--primary-color); box-shadow: 0 0 0 0.2rem rgba(30, 120, 120, 0.15); }

.dict-list { flex: 1; overflow-y: auto; padding: 4px 0; max-height: 220px; }
.dict-list::-webkit-scrollbar { width: 6px; }
.dict-list::-webkit-scrollbar-track { background: #f1f1f1; }
.dict-list::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }

.dict-item {
    display: block; width: 100%; padding: 6px 10px; text-align: left;
    background: none; border: none; font-size: 0.9em; color: var(--text-main);
    cursor: pointer; transition: background 0.1s;
}
.dict-item:hover { background: var(--primary-light); color: var(--primary-color); }
.dict-item:focus-visible {
    background: var(--primary-light);
    color: var(--primary-color);
}

.dict-empty { padding: 10px; text-align: center; color: var(--text-muted); font-size: 0.85em; }
.dict-empty.dict-error { color: #b42318; }

/* Подсветка совпадений в словаре */
.dict-match {
    background-color: rgba(30, 120, 120, 0.25);
    color: var(--primary-color);
    font-weight: 600;
    border-radius: 2px;
    padding: 0 2px;
}

/* Активный элемент при навигации стрелками */
.dict-item-active {
    background-color: var(--primary-light) !important;
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.dict-more-hint {
    padding: 8px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8em;
    border-top: 1px solid var(--border-color);
    background: #f8f9fa;
}

@media (max-width: 768px) {
  .btn-dict {
    width: 34px;
    height: 36px;
    font-size: 1rem;
  }

  .dict-dropdown {
    left: auto;
    right: 0;
    width: min(320px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
  }
}
