:root {
  --bg: #0b0b0d;
  --surface: #17171a;
  --surface-2: #202023;
  --border: #2c2c30;
  --text: #f2f0f0;
  --text-muted: #9a9a9e;
  --red: #e2222f;
  --red-hover: #ff2e3d;
  --red-dim: rgba(226, 34, 47, 0.14);
  --green: #34c266;
  --amber: #e0a53a;
  --gray: #6f6f74;
  --header-gradient-start: #131315;
  --overlay-weak: rgba(255, 255, 255, 0.04);
  --overlay-medium: rgba(255, 255, 255, 0.08);
  --overlay-border: rgba(255, 255, 255, 0.09);
}

:root[data-theme="light"] {
  --bg: #f3f3f5;
  --surface: #ffffff;
  --surface-2: #ececef;
  --border: #dcdce0;
  --text: #1a1a1d;
  --text-muted: #6a6a70;
  --red: #e2222f;
  --red-hover: #c81f2a;
  --red-dim: rgba(226, 34, 47, 0.12);
  --green: #1f9a52;
  --amber: #a8710a;
  --gray: #6f6f74;
  --header-gradient-start: #ffffff;
  --overlay-weak: rgba(0, 0, 0, 0.035);
  --overlay-medium: rgba(0, 0, 0, 0.05);
  --overlay-border: rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* Barely visible wings emblem behind the whole app on desktop screens only.
   It shows through the gaps between cards; clicks pass straight through. */
@media (min-width: 769px) {
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: url("bg-wings.png") center 55% / min(70vw, 1100px) auto no-repeat;
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
  }
  #app { position: relative; z-index: 1; }
}

.state-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

#main.hidden { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  max-width: calc(100% - 32px);
  background: var(--surface-2);
  border: 1px solid var(--red);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
}

.header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--header-gradient-start) 0%, var(--bg) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--red-dim);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }

.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.brand-version {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.65;
}

.brand-meta { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.brand-credit {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.65;
}
.brand-credit::before { content: "·"; margin-right: 5px; }

.brand-datetime {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.icon-toolbar {
  display: flex;
  gap: 6px;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.icon-tab-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tab-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.icon-tab-btn svg { width: 18px; height: 18px; }

.icon-tab-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.profile-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--red);
}

.header-name { font-weight: 700; font-size: 15px; }
.header-position { color: var(--text-muted); font-size: 12px; margin-top: 1px; }

.tab-content {
  padding: 4px 16px 28px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin: 4px 2px 12px;
}

.section-subtitle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 20px 2px 12px;
}

.stat-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-section-header .section-subtitle { margin: 0 0 12px; }

.dashboard-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin: 24px 0 20px;
}

.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  min-width: 0;
}

.dashboard-card .chart-wrap { margin: 0; }

#events-card, #movements-card, #completeness-card { margin-top: 18px; }

.movements-date-field { display: flex; align-items: center; gap: 8px; margin: 0; }
.movements-date-field input { width: 130px; margin-bottom: 0; }

.movements-list { max-height: 320px; overflow-y: auto; padding-right: 4px; }
.movements-list .document-item-name { font-size: 13px; }
.movements-clickable-item { cursor: pointer; }
.movements-clickable-item:hover { background: var(--overlay-weak); }

#personnel-report-btn,
#vshdr-report-btn {
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#personnel-report-btn svg,
#vshdr-report-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.chart-type-toggle {
  display: flex;
  gap: 4px;
  margin: 14px 0 8px;
}

.chart-type-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chart-type-btn svg { width: 14px; height: 14px; }

.chart-type-btn:hover { border-color: var(--red); color: var(--red-hover); }

.chart-type-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 14px;
  padding: 16px;
}

.stat-card .icon-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

.stat-value-input {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  width: 100%;
  padding: 0;
  margin-bottom: 0;
  border: none;
  border-bottom: 2px solid var(--red);
  border-radius: 0;
  background: transparent;
  color: var(--text);
}

.stat-value-input:focus { outline: none; box-shadow: none; }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-sub {
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-muted);
  cursor: help;
}

.stat-sub.has-vacancies { color: var(--amber); font-weight: 600; }

.field { margin-bottom: 14px; }
.field:last-of-type { margin-bottom: 16px; }
.field .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.field span:not(.label) { font-size: 15px; font-weight: 500; }

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 15px;
  margin-bottom: 8px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%239a9a9e'><path d='M5.5 7.5l4.5 5 4.5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 34px;
}

select option {
  background: var(--surface-2);
  color: var(--text);
}

input::placeholder { color: var(--gray); }

input:focus, select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim);
}

.btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover { background: var(--red-hover); }
.btn:active { transform: scale(0.98); }

.list { display: flex; flex-direction: column; gap: 10px; }

.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 12px;
  padding: 14px 16px;
}

.list-item-title { font-weight: 700; margin-bottom: 4px; font-size: 15px; }
.list-item-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: center;
}

.location-select {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  text-align: center;
  text-align-last: center;
}

.status-planned, .status-new { background: var(--surface-2); color: var(--text-muted); }
.status-completed, .status-done { background: rgba(52, 194, 102, 0.14); color: var(--green); }
.status-cancelled { background: var(--red-dim); color: var(--red-hover); }
.status-in_progress { background: rgba(224, 165, 58, 0.14); color: var(--amber); }

.list-item-actions { display: flex; gap: 8px; margin-top: 10px; }

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-sm:hover { border-color: var(--red); color: var(--red-hover); }

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 0;
  font-size: 14px;
}

.admin-filters-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
}

.property-unit-menu {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
}

.property-unit-menu-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.property-unit-menu-btn:hover { border-color: var(--red); color: var(--text); }

.property-unit-menu-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.admin-filters-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-filters-fields .field {
  flex: 1 1 170px;
  min-width: 150px;
  margin-bottom: 0;
}

.filters-sidebar {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  align-self: flex-start;
}

.filters-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.filters-sidebar-header .icon-btn {
  font-size: 17px;
  color: var(--text-muted);
}

.filters-sidebar-header span { display: inline-flex; align-items: center; gap: 6px; }

.filters-sidebar-header-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.admin-main {
  flex: 1 1 auto;
  min-width: 0;
}

.admin-main-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-main-toolbar .btn,
.admin-main-toolbar .btn-sm {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-main-toolbar .btn {
  width: auto;
  padding: 0 18px;
}

.admin-main-toolbar .btn-sm {
  padding: 0 12px;
}

.bulk-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text);
}

.bulk-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: transparent;
  color: var(--red-hover);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.bulk-icon-btn:hover { background: var(--red); color: #fff; }
.bulk-icon-btn svg { width: 16px; height: 16px; }

.data-table input[type="checkbox"] {
  appearance: auto;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  margin: 0;
  cursor: pointer;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 200px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
  table-layout: fixed;
}

.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--overlay-border);
  overflow: hidden;
}

.data-table th {
  position: relative;
}

.cell-clickable {
  cursor: pointer;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.col-resizer:hover, .col-resizer.resizing {
  background: var(--red);
  opacity: 0.6;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.data-table tbody tr:nth-child(even) td { background: var(--overlay-weak); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--overlay-medium); }
.data-table tbody tr.row-leader td { font-weight: 700; }

.sticky-col-fio {
  position: sticky;
  left: var(--fio-sticky-left, 76px);
  z-index: 1;
  background: var(--surface);
  box-shadow: 2px 0 4px -2px var(--overlay-border);
}

.data-table tbody tr:nth-child(even) td.sticky-col-fio,
.data-table tbody tr:hover td.sticky-col-fio {
  background: var(--surface-2);
}

.data-table thead th.sticky-col-fio { z-index: 2; }

@media (max-width: 700px) {
  .data-table { white-space: normal; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100% !important;
  }
  .data-table tbody tr {
    margin-bottom: 10px;
    border: 1px solid var(--overlay-border);
    border-radius: 10px;
    overflow: hidden;
  }
  .data-table tbody tr:nth-child(even) td { background: none; }
  .data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--overlay-border);
    text-align: right;
    white-space: normal;
    word-break: break-word;
  }
  .data-table tr:last-child td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
  }
  .data-table td[data-col="full_name"] {
    font-size: 15px;
    font-weight: 700;
  }
  .sticky-col-fio {
    position: static;
    box-shadow: none;
  }
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 6px;
}

.icon-btn:hover { color: var(--red-hover); }

.icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.icon-btn:disabled:hover { color: var(--text-muted); }

.data-table input[type="checkbox"]:disabled { opacity: 0.3; cursor: not-allowed; }

.data-table thead th[draggable="true"] { cursor: grab; }
.data-table thead th[draggable="true"]:active { cursor: grabbing; }

.icon-btn svg { width: 14px; height: 14px; vertical-align: middle; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 900;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-card-sm { max-width: 360px; }
.modal-card-dossier { max-width: 720px; }

.restore-backup-warning {
  color: var(--red-hover, var(--red));
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 14px;
}

.modal-header h3 { margin: 0; font-size: 16px; }
.modal-header-actions { display: flex; align-items: center; gap: 10px; }

.dossier-profile {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.dossier-profile-name { font-size: 19px; font-weight: 700; }
.dossier-profile-position { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.dossier-profile-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.dossier-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.dossier-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.dossier-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.dossier-tab-btn:hover { color: var(--text); }
.dossier-tab-btn.active { color: var(--text); border-bottom-color: var(--red); }

.dossier-panel-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

.dossier-toggle-empty-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.dossier-toggle-empty-btn:hover { color: var(--text); }

.dossier-group { margin-bottom: 16px; }
.dossier-group:last-child { margin-bottom: 0; }
.dossier-group + .dossier-group { border-top: 1px solid var(--overlay-border); padding-top: 14px; }

.dossier-group h5 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.dossier-section { margin-bottom: 22px; }
.dossier-section:last-child { margin-bottom: 0; }

.dossier-section h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.dossier-subsection {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.dossier-subsection:last-child { margin-bottom: 0; }

.dossier-subsection h5 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--red-hover);
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--red);
}

.dossier-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

/* Паспорт: серия/номер и дата выдачи стоят друг под другом в узкой колонке,
   освобождая место для часто многострочного "Кем выдан". */
#dossier-passport-fields {
  grid-template-columns: minmax(170px, 1fr) minmax(220px, 2fr) minmax(170px, 1fr);
}
#dossier-passport-fields [data-field="passport_series_number"] { grid-column: 1; grid-row: 1; }
#dossier-passport-fields [data-field="passport_issued_date"] { grid-column: 1; grid-row: 2; }
#dossier-passport-fields [data-field="passport_issued_by"] { grid-column: 2; grid-row: 1 / span 2; }
#dossier-passport-fields [data-field="passport_department_code"] { grid-column: 3; grid-row: 1; }
#dossier-passport-fields [data-field="registration_address"] { grid-column: 3; grid-row: 2; }

.dossier-field .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.dossier-field .value { font-size: 14px; font-weight: 500; word-break: break-word; }

.dossier-upload-row { margin-bottom: 12px; }
.dossier-upload-row .btn-sm { width: auto; }

.document-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.document-item-info { min-width: 0; }

.document-item-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.vacation-overdue { background: var(--red-dim); color: var(--red-hover); font-weight: 600; }
.weapon-duplicate { color: var(--red-hover); font-weight: 600; }

.cell-highlight-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid;
  font-weight: 600;
}

.import-preview-summary {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.import-preview-stat {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.import-preview-stat strong { display: block; font-size: 22px; }
.import-preview-stat span { font-size: 12px; color: var(--text-muted); }

.import-preview-warnings {
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 10px 12px;
}

.import-preview-warnings-title { font-weight: 700; color: var(--red); margin-bottom: 6px; font-size: 13px; }
.import-preview-warning-item { font-size: 13px; padding: 3px 0; }

.instructions-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }

.instructions-list { display: flex; flex-direction: column; gap: 10px; flex: 1 1 500px; max-width: 760px; }

.changelog-panel {
  flex: 2 1 400px;
  max-width: 900px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.changelog-list { display: flex; flex-direction: column; gap: 8px; max-height: 78vh; overflow-y: auto; padding-right: 6px; }

.changelog-entry {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 12px;
}

.changelog-entry summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  list-style: none;
}
.changelog-entry summary::-webkit-details-marker { display: none; }
.changelog-entry summary::before { content: "▸ "; }
.changelog-entry[open] summary::before { content: "▾ "; }

.changelog-entry ul { margin: 0; padding: 0 0 12px; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.changelog-entry li { font-size: 13px; line-height: 1.5; }

.changelog-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 5px;
  margin-right: 6px;
  vertical-align: 1px;
}

.changelog-tag-add { background: rgba(52, 194, 102, 0.16); color: #34c266; }
.changelog-tag-change { background: rgba(74, 158, 255, 0.16); color: #4a9eff; }
.changelog-tag-fix { background: var(--red-dim); color: var(--red); }

.instructions-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 16px;
}

.instructions-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  padding: 12px 0;
  font-weight: 700;
  font-size: 15px;
  list-style: none;
  color: var(--text);
}
.instructions-item summary::-webkit-details-marker { display: none; }
.instructions-item-title::before { content: "▸ "; color: var(--text-muted); }
.instructions-item[open] .instructions-item-title::before { content: "▾ "; }

.instructions-item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.instructions-body { padding: 0 0 16px; color: var(--text); font-size: 14px; line-height: 1.6; }
.instructions-body ul { margin: 0; padding-left: 20px; }
.instructions-body li { margin-bottom: 8px; }
.instructions-body p { margin: 0 0 10px; }

.ins-icon {
  width: 15px;
  height: 15px;
  vertical-align: -3px;
  margin-right: 4px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.ins-btn {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.ins-btn .ins-icon { margin-right: 5px; color: inherit; }

.ins-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.document-item-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Settings: one full-width backup strip, then two grid rows. */
.settings-layout { display: flex; flex-direction: column; gap: 12px; }
.settings-block { width: auto; padding: 12px 14px; min-width: 0; }
.settings-block .filters-sidebar-header { margin-bottom: 12px; gap: 10px; }
.settings-block .filters-sidebar-header > span { min-width: 0; }
.settings-block .filters-sidebar-header .btn-sm { white-space: nowrap; flex-shrink: 0; }
.settings-row { display: grid; gap: 12px; align-items: start; }
.settings-row-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.settings-row-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-row > .settings-block { height: 100%; }

.settings-subtitle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.settings-inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings-strip-tools { display: flex; align-items: center; gap: 14px; }

.backup-strip-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
}
.backup-strip-col { padding: 0 16px; min-width: 0; }
.backup-strip-col:first-child { padding-left: 0; }
.backup-strip-col:last-child { padding-right: 0; }
.backup-strip-col + .backup-strip-col { border-left: 1px solid var(--border); }
/* The list takes the height the other two columns set, then scrolls. */
.backup-strip-list { display: flex; flex-direction: column; }
.backup-strip-list #backups-list {
  flex: 1 1 auto;
  height: 0;
  min-height: 140px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}
.backup-strip-list #backups-list::-webkit-scrollbar { width: 8px; }
.backup-strip-list #backups-list::-webkit-scrollbar-track { background: transparent; }
.backup-strip-list #backups-list::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

@media (max-width: 900px) {
  .settings-row-wide, .settings-row-three, .backup-strip-grid { grid-template-columns: minmax(0, 1fr); }
  .backup-strip-col { padding: 0; }
  .backup-strip-col + .backup-strip-col { border-left: none; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
  .backup-strip-list #backups-list { height: auto; max-height: 260px; }
  .settings-strip-tools .disk-usage-inline { display: none; }
}

.settings-block-locations .locations-list { max-height: 260px; }

.settings-block-sessions #sessions-list {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.field-compact { margin-bottom: 10px; }
.field-compact:last-of-type { margin-bottom: 10px; }

.settings-actions-row { display: flex; align-items: center; gap: 14px; }

.notify-settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-bottom: 10px;
}
.notify-settings-table th, .notify-settings-table td {
  padding: 5px 4px;
  text-align: left;
  border-bottom: 1px solid var(--overlay-border);
}
.notify-settings-table thead th {
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 700;
}
.notify-settings-table tbody tr:last-child td { border-bottom: none; }
.notify-cell-muted { color: var(--gray); }
.notify-cell-inline { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.notify-setting-number {
  width: 42px;
  padding: 3px 4px;
  margin-bottom: 0;
  text-align: center;
  font-size: 11px;
}
.notify-setting-select { width: 56px; padding: 3px 16px 3px 6px; margin-bottom: 0; font-size: 11px; }

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.toggle-thumb svg {
  width: 11px;
  height: 11px;
  color: var(--red);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.toggle-switch input:checked + .toggle-track { background: var(--red); border-color: var(--red); }
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle-switch input:checked + .toggle-track .toggle-thumb svg { opacity: 1; }

.list-compact { gap: 6px; }
.list-compact .document-item { padding: 8px 10px; }

.locations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 360px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
  margin-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.locations-list::-webkit-scrollbar {
  width: 8px;
}

.locations-list::-webkit-scrollbar-track {
  background: transparent;
}

.locations-list::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

.location-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
}

.location-color-input {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.location-name-input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 4px 8px;
  font-size: 13px;
}

.location-item-actions { display: flex; gap: 0; flex-shrink: 0; }
.location-item-actions .icon-btn { padding: 2px 5px; font-size: 13px; }

.location-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

.location-add-row .location-color-input { width: 28px; height: 28px; }

#new-location-name {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 13px;
}

.weekday-picker { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }

#tab-settings .weekday-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
#tab-settings .weekday-btn { width: auto; height: 30px; font-size: 11px; padding: 0; }

#tab-settings .section-title { margin-bottom: 8px; }

.disk-usage-widget { display: flex; flex-direction: column; gap: 6px; }

.disk-usage-label { font-size: 13px; color: var(--text); }

.disk-usage-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.disk-usage-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--green);
  transition: width 0.3s ease;
}

.disk-usage-fill.disk-usage-warn { background: var(--amber); }
.disk-usage-fill.disk-usage-crit { background: var(--red); }

.disk-usage-caption { font-size: 12px; color: var(--text-muted); }

/* Compact disk gauge in the backup strip header. */
.disk-usage-inline { flex-direction: row; align-items: center; gap: 8px; }
.disk-usage-inline .disk-usage-label { font-size: 12px; color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.disk-usage-inline .disk-usage-bar { width: 110px; height: 6px; }
.disk-usage-inline .disk-usage-caption { white-space: nowrap; font-weight: 400; text-transform: none; letter-spacing: 0; }

.weekday-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.weekday-btn:hover { border-color: var(--red); }

.weekday-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-toolbar .section-title { margin: 0; }
.history-toolbar-actions { display: flex; gap: 8px; }

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.history-filters #history-search { flex: 1 1 220px; margin-bottom: 0; }
.history-filters #history-action-filter { flex: 0 1 220px; margin-bottom: 0; }

#history-date-filter-panel, #history-retention-panel { width: 220px; left: auto; right: 0; }
.history-date-filter-panel .field { margin-bottom: 10px; }
.history-date-filter-panel .btn-sm { width: 100%; }
#history-date-filter-btn.active { color: var(--red); border-color: var(--red); }

.history-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.history-item-field { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.history-item-diff { font-size: 14px; word-break: break-word; }
.history-old { color: var(--text-muted); text-decoration: line-through; }
.history-new { color: var(--red); font-weight: 600; }
.history-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.columns-menu-wrap { position: relative; display: inline-flex; align-items: center; }

.columns-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.columns-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.columns-menu-list { display: flex; flex-direction: column; gap: 2px; }

.columns-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
}

.columns-menu-item:hover { background: var(--surface-2); }
.columns-menu-item input { width: auto; margin: 0; }
.columns-menu-item-all { font-weight: 700; }
.columns-menu-divider { height: 1px; background: var(--border); margin: 6px 0 8px; }

.context-menu {
  position: fixed;
  z-index: 960;
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.context-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.context-menu-item:hover { background: var(--surface-2); }
.context-menu-item-danger { color: var(--red); }

.context-menu-separator { height: 1px; background: var(--border); margin: 6px 4px; }

.context-menu-list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }

.context-menu-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 4px 10px 6px;
}

.context-menu-label svg { width: 13px; height: 13px; flex-shrink: 0; }

.context-menu-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 10px 6px;
}

.context-menu-color {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  padding: 0;
}

.context-menu-color-clear {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.toolbar-icon-btn:hover { border-color: var(--red); color: var(--red-hover); }

.chart-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 2px 20px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 130px) 1fr 34px;
  align-items: center;
  gap: 10px;
}

.bar-label {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 5px 0 0 5px;
  transition: width 0.3s ease;
}

.bar-value {
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  color: var(--text-muted);
}

.bar-row-clickable {
  cursor: pointer;
  border-radius: 6px;
  margin: 0 -6px;
  padding: 0 6px;
  transition: background 0.12s ease;
}
.bar-row-clickable:hover { background: var(--surface-2); }
.bar-row-clickable:hover .bar-label { color: var(--red-hover); }

.toolbar-icon-btn svg { width: 16px; height: 16px; }

.donut-chart-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

.donut-chart-svg {
  width: 100%;
  max-width: 370px;
  height: auto;
}

.donut-leader-line {
  stroke-width: 1.2;
  opacity: 0.6;
}

.donut-label {
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--text);
}

.donut-label-value {
  font-weight: 400;
  fill: var(--text-muted);
}

.donut-segment-clickable, .donut-label-clickable {
  cursor: pointer;
}
.donut-segment-clickable:hover { opacity: 0.75; }
.donut-label-clickable:hover { fill: var(--red-hover); }
.donut-label-clickable:hover .donut-label-value { fill: var(--red-hover); }

/* ---------- Задачи ---------- */
.tasks-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tasks-kpis { margin-bottom: 14px; }
.task-kpi-danger { color: var(--red); }
.task-kpi-warn { color: var(--amber); }
.tasks-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tasks-filters .tasks-chips { margin-top: 0; flex: 1 1 320px; }
.tasks-assignee-filter { width: auto; min-width: 200px; margin: 0; padding: 7px 34px 7px 10px; font-size: 13px; }
.tasks-cancelled-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.tasks-cancelled-toggle input, .task-notify input, .task-assignee-option input { width: auto; margin: 0; padding: 0; box-shadow: none; }
.tasks-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.tasks-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  min-height: 120px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.tasks-col-drop { border-color: var(--red); background: var(--red-dim); }
.tasks-col-header { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; margin: 2px 4px 10px; }
.tasks-col-count { font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--overlay-medium); border-radius: 999px; padding: 1px 8px; }
.tasks-col-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 18px 0; }
.task-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.task-card:hover { border-color: var(--text-muted); }
.task-card[draggable="true"] { cursor: grab; }
.task-card-dragging { opacity: 0.45; }
.task-card-overdue { border-left: 3px solid var(--red); }
.task-card-today { border-left: 3px solid var(--amber); }
.task-card-closed { opacity: 0.7; }
.task-card-closed .task-card-title { text-decoration: line-through; }
.task-card-title { font-weight: 600; font-size: 14px; line-height: 1.35; margin-bottom: 4px; word-break: break-word; }
.task-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-card-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); min-width: 0; }
.task-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--overlay-medium);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}
.task-card-group-icon svg { width: 15px; height: 15px; vertical-align: -3px; }
.task-due { margin-left: auto; white-space: nowrap; }
.task-due-overdue { color: var(--red); font-weight: 600; }
.task-due-today { color: var(--amber); font-weight: 600; }
.task-due-done { color: var(--green); }
.task-hint { font-size: 12px; color: var(--text-muted); margin: 4px 0 10px; }

.task-modal-card { max-width: 560px; }
#task-description {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
  outline: none;
}
#task-description:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
#task-assign-block { margin-bottom: 14px; }
#task-assign-block > .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.task-mode-seg { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; margin-bottom: 8px; }
.task-mode-seg button {
  flex: 1;
  padding: 8px 6px;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.task-mode-seg button + button { border-left: 1px solid var(--border); }
.task-mode-seg button.active { background: var(--red); color: #fff; }
.task-assignee-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; }
.task-assignee-option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.task-assignee-option:last-child { border-bottom: none; }
.task-assignee-unit { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.task-edit-assignee { font-size: 14px; }
.task-group-members { border: 1px solid var(--border); border-radius: 9px; margin-bottom: 14px; }
.task-group-member { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.task-group-member:last-child { border-bottom: none; }
.task-group-member select { width: auto; margin: 0 0 0 auto; padding: 6px 30px 6px 8px; font-size: 13px; }
.task-due-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-due-row input { width: auto; flex: 1 1 150px; margin: 0; }
.task-notify { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.task-modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.task-actions-spacer { flex: 1; }
.task-delete-btn { color: var(--red); }
.task-save-btn { background: var(--red); border-color: var(--red); color: #fff; }
.task-save-btn:hover { background: var(--red-hover); color: #fff; }
.task-my-item.task-card-overdue, .task-my-item.task-card-today { border-left-width: 3px; }

@media (max-width: 700px) {
  .tasks-board { grid-template-columns: 1fr; }
  .tasks-assignee-filter { flex: 1 1 100%; }
}

/* ---------- Ближайшие события ---------- */
.events-range { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.events-range button {
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
}
.events-range button + button { border-left: 1px solid var(--border); }
.events-range button.active { background: var(--red); color: #fff; }
.events-list { max-height: 360px; overflow-y: auto; }
.events-day {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 12px 0 6px;
}
.events-day:first-child { margin-top: 2px; }
.event-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; cursor: pointer; }
.event-row:hover { background: var(--overlay-weak); }
.event-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--overlay-medium);
  color: var(--text-muted);
}
.event-icon svg { width: 16px; height: 16px; }
.event-birthday .event-icon { color: #f472b6; background: rgba(244, 114, 182, 0.14); }
.event-contract_end .event-icon { color: var(--red); background: var(--red-dim); }
.event-vacation_end .event-icon { color: #4a9eff; background: rgba(74, 158, 255, 0.14); }
.event-task_due .event-icon { color: var(--amber); background: rgba(224, 165, 58, 0.14); }
.event-main { min-width: 0; }
.event-title { font-size: 14px; font-weight: 600; }
.event-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Образец ВШДР ---------- */
.vshdr-template-info { font-size: 14px; margin-bottom: 10px; }
.backup-password-status { font-size: 14px; margin-bottom: 10px; color: var(--green); }
.backup-password-status.is-off { color: var(--amber); }
.backup-password-hint { font-size: 11px; color: var(--text-muted); margin: 10px 0 0; line-height: 1.4; }
.vshdr-template-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.vshdr-preview-card { max-width: 620px; }
.vshdr-summary { font-size: 14px; margin: 0 0 12px; }
.vshdr-section { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.vshdr-section ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; max-height: 160px; overflow-y: auto; }
.vshdr-section-title { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.vshdr-section-danger { border-color: var(--red); }
.vshdr-section-danger .vshdr-section-title { color: var(--red); }
.vshdr-section-warn { border-color: var(--amber); }
.vshdr-section-warn .vshdr-section-title { color: var(--amber); }
#holdings-body { max-height: 55vh; overflow-y: auto; }
.holdings-weapon { font-size: 13px; margin-top: 6px; }
.holdings-meta { color: var(--text-muted); font-size: 12px; }
.holdings-maybe { color: var(--amber); font-size: 11px; font-weight: 600; cursor: help; }
.holdings-hint { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; }
.vshdr-section-ok .vshdr-section-title { color: var(--green); }
.vshdr-section-muted .vshdr-section-title { color: var(--text-muted); }

/* ---------- Повторяющиеся задачи ---------- */
.tasks-header-actions { display: flex; gap: 6px; }
.task-recurring { color: var(--text-muted); font-weight: 400; }
.task-repeat-inline { display: flex; align-items: center; gap: 6px; font-size: 14px; flex-wrap: wrap; }
.task-repeat-inline input { width: 70px; margin: 0; padding: 7px 8px; }
#task-repeat, #task-repeat-weekday { width: auto; flex: 1 1 160px; margin: 0; }
#task-repeat-due-wrap { margin-top: 8px; }
.task-template-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-template-row:last-child { border-bottom: none; }
.task-template-main { flex: 1; min-width: 0; }
.task-template-main .task-hint { margin: 2px 0 0; }
.task-template-paused .task-template-main { opacity: 0.6; }

/* Табель */
.timesheet-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.timesheet-toolbar .section-title { margin: 0; }
.timesheet-month { display: flex; align-items: center; gap: 6px; }
.timesheet-title { font-weight: 700; min-width: 128px; text-align: center; }
.timesheet-unit { width: auto; min-width: 180px; margin: 0; }
.timesheet-spacer { flex: 1; }
.timesheet-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.timesheet-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.timesheet-code {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 18px; padding: 0 3px;
  border-radius: 4px; color: #fff; font-size: 10px; font-weight: 700;
}
.timesheet-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.timesheet-table { border-collapse: separate; border-spacing: 2px; font-size: 11px; min-width: 100%; }
.timesheet-table th { font-weight: 600; color: var(--text-muted); text-align: center; padding: 4px 0; }
.timesheet-table th.is-weekend { opacity: 0.55; }
.timesheet-table th.is-today { color: var(--red); }
.timesheet-wd { font-size: 9px; font-weight: 400; }
.timesheet-name {
  position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left !important;
  min-width: 190px; max-width: 230px; padding: 4px 10px 4px 8px !important; color: var(--text) !important;
}
.timesheet-name > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.timesheet-meta { font-size: 10px; font-weight: 400; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timesheet-cell {
  position: relative; min-width: 24px; height: 26px; border-radius: 4px; text-align: center;
  background: var(--surface-2); color: #fff; font-weight: 700; cursor: pointer;
}
.timesheet-cell:not(.has-loc) { color: var(--text-muted); }
.timesheet-cell.is-future { background: transparent; border: 1px dashed var(--border); cursor: default; }
.timesheet-cell[data-ts-emp]:hover { outline: 2px solid var(--text); outline-offset: -2px; }
.timesheet-cell.is-today { box-shadow: inset 0 0 0 2px var(--red); }
.timesheet-cell.is-manual::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: #fff;
}
.timesheet-total { min-width: 52px; text-align: center; font-weight: 700; color: var(--text); }
.timesheet-hint { font-size: 12px; color: var(--text-muted); margin: 10px 2px 0; line-height: 1.4; }
.timesheet-menu .context-menu-item { display: flex; align-items: center; gap: 8px; }
@media (max-width: 700px) {
  .timesheet-name { min-width: 118px; max-width: 132px; }
  .timesheet-meta { display: none; }
}

/* Document templates */
.doc-template-unknown { font-size: 12px; color: var(--amber); margin-top: 2px; }
.doc-fields-help { margin-top: 10px; font-size: 13px; }
.doc-fields-help summary { cursor: pointer; color: var(--text-muted); }
.doc-fields-help p { font-size: 12px; color: var(--text-muted); line-height: 1.4; margin: 8px 0; }
.doc-fields-list { display: flex; flex-wrap: wrap; gap: 4px; }
.doc-field-chip {
  font-size: 12px; padding: 3px 7px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text);
}
.doc-field-chip:hover { border-color: var(--red); }
.doc-picker-list { display: flex; flex-direction: column; gap: 6px; }
.doc-picker-item {
  text-align: left; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text); font-size: 14px;
}
.doc-picker-item:hover { border-color: var(--red); }

/* Archive of departed people */
.dossier-departed-banner {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--amber);
  border-radius: 10px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 600;
}
.archive-hint { font-size: 12px; color: var(--text-muted); margin: 0 0 10px; line-height: 1.4; }
#depart-reason-other { margin-top: 6px; }

/* ---------- v2.44: навигация, панель сотрудников, личное дело ---------- */

/* Summary: the date range under "Последние перемещения" wraps onto its own
   line on phones instead of pushing the whole page sideways. */
@media (max-width: 700px) {
  #movements-card .stat-section-header { flex-wrap: wrap; }
  .movements-date-field { width: 100%; margin-bottom: 12px; }
  .movements-date-field input { flex: 1 1 0; min-width: 0; width: auto; }

  /* Three summary numbers in one row (four in the new interface: 2 x 2). */
  #tab-dashboard .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  html[data-ui="modern"] #tab-dashboard .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tab-dashboard .stat-card { padding: 12px 10px 12px 12px; border-radius: 12px; }
  #tab-dashboard .stat-value { font-size: 22px; }
  #tab-dashboard .stat-label { font-size: 11px; }
}

/* Classic header on wide screens: tab names next to the icons. The width
   leaves room for a full "Фамилия Имя Отчество" on the right. */
@media (min-width: 1500px) {
  html:not([data-ui="modern"]) .icon-toolbar .icon-tab-btn {
    width: auto;
    padding: 0 12px 0 10px;
    gap: 7px;
  }
  html:not([data-ui="modern"]) .icon-toolbar .icon-tab-btn::after {
    content: attr(data-label);
    font-size: 13px;
    font-weight: 600;
  }
}

/* "Ещё" sheet rising from the phone bottom bar, which stays on top of it
   (z-index 800), so tapping "Ещё" again closes it. */
.more-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 790;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
}
.more-sheet {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 12px calc(80px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
}
.more-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.more-sheet-item svg { width: 22px; height: 22px; }
.more-sheet-item.active { border-color: var(--red); color: var(--red); }

/* Employees: one row of controls, filters folded behind "Фильтры". */
.admin-controls { padding: 12px; }
.admin-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.admin-search {
  flex: 1 1 240px;
  min-width: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: text;
  transition: border-color 0.15s ease;
}
.admin-search:focus-within { border-color: var(--red); }
.admin-search svg { width: 16px; height: 16px; flex-shrink: 0; }
.admin-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  font-size: 14px;
}
.toolbar-btn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.toolbar-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.toolbar-btn .toolbar-btn-caret { width: 13px; height: 13px; opacity: 0.7; }
.toolbar-btn:hover { border-color: var(--red); }
.toolbar-btn.active,
.toolbar-btn[aria-expanded="true"] { border-color: var(--red); color: var(--red-hover); }
.toolbar-btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.toolbar-btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.toolbar-btn-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.toolbar-menu-wrap { position: relative; }
.toolbar-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 230px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.toolbar-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.toolbar-menu-item:hover { background: var(--overlay-medium); }
.toolbar-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-muted); }
.admin-controls .columns-menu { left: auto; right: 0; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.active-filter-chip span { color: var(--text-muted); font-size: 15px; line-height: 1; }
.active-filter-chip:hover { border-color: var(--red); }
.active-filter-reset {
  padding: 5px 6px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.active-filter-reset:hover { color: var(--red-hover); }
.admin-controls .admin-filters-fields { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.admin-controls:not(.filters-open) .admin-filters-fields { display: none; }
.admin-filters-actions { flex: 1 1 100%; display: flex; justify-content: flex-end; }
@media (max-width: 700px) {
  .admin-search { flex-basis: 100%; }
  .admin-controls-row > .toolbar-btn,
  .admin-controls-row > .toolbar-menu-wrap { flex: 1 1 0; }
  .admin-controls-row .toolbar-menu-wrap > .toolbar-btn { width: 100%; }
  .admin-controls-row .toolbar-btn { padding: 0 8px; }
  .admin-controls-row .toolbar-btn:not(.toolbar-btn-primary) .toolbar-btn-label,
  .admin-controls-row .toolbar-btn-caret { display: none; }
  /* "Ещё" sits near the right edge: open its menu leftwards. */
  .admin-controls .toolbar-menu-wrap + .toolbar-menu-wrap .toolbar-menu { left: auto; right: 0; }
}

/* Dialogs opened from the employee card sit above it: same overlay level,
   but they come earlier in the page. */
#depart-modal,
#doc-picker-modal,
#bulk-vacation-modal,
#task-modal { z-index: 910; }

/* Employee card header: initials in the location's color, the name once,
   one line of role, key facts as badges, quick actions below. */
.dossier-profile {
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 0;
  border-bottom: none;
}
.dossier-avatar {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  border: 2px solid var(--avatar-color, var(--border));
  background: var(--surface-2);
  background: color-mix(in srgb, var(--avatar-color, var(--border)) 16%, var(--surface-2));
}
.dossier-profile-main { flex: 1; min-width: 0; }
.dossier-call-sign { color: var(--text-muted); font-weight: 500; }
.dossier-profile .dossier-profile-badges { justify-content: flex-start; margin-top: 10px; }
.dossier-badge.is-warn { color: var(--amber); border-color: rgba(224, 165, 58, 0.45); }
.dossier-badge.is-danger { color: var(--red); border-color: rgba(226, 34, 47, 0.45); }
.dossier-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.dossier-qa-btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.dossier-qa-btn svg { width: 15px; height: 15px; color: var(--text-muted); }
.dossier-qa-btn:hover { border-color: var(--red); }

/* Phones: the card takes the whole screen. */
@media (max-width: 700px) {
  #dossier-modal { padding: 0; }
  #dossier-modal .modal-card-dossier {
    max-width: none;
    max-height: none;
    height: 100%;
    border: none;
    border-radius: 0;
  }
  .dossier-avatar { width: 52px; height: 52px; font-size: 18px; }
  .dossier-profile-name { font-size: 17px; }
  .dossier-qa-btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
}

/* ---------- Новый интерфейс ----------
   Everything below applies only under html[data-ui="modern"] (toggled per
   device from the header). Elements marked .modern-only are hidden in the
   classic interface, which stays exactly as it was. */

html:not([data-ui="modern"]) .modern-only { display: none !important; }

html[data-ui="modern"] #ui-mode-toggle-btn { color: var(--red); border-color: var(--red); }

/* Dashboard KPI: week-over-week deltas and a quieter card edge. */
html[data-ui="modern"] .stat-card { border-left-width: 1px; }
.stat-delta { font-size: 12px; margin-top: 6px; min-height: 16px; color: var(--text-muted); }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* Team overview: location split bar, attention banner, quick filter chips. */
.emp-overview { margin-bottom: 14px; }
.emp-overview-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--overlay-medium);
}
.emp-overview-bar span { height: 100%; }
.emp-overview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.emp-overview-legend b { color: var(--text); font-weight: 700; }
.emp-overview-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.emp-attention {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(224, 165, 58, 0.35);
  background: rgba(224, 165, 58, 0.1);
  color: var(--amber);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.emp-attention svg { width: 16px; height: 16px; flex-shrink: 0; }
.emp-attention.active { border-color: var(--amber); }
.emp-chips {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.emp-chips::-webkit-scrollbar { display: none; }
.emp-chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.emp-chip:hover { color: var(--text); }
.emp-chip.active { background: var(--red); border-color: var(--red); color: #fff; }
.emp-chip-filters { margin-left: auto; }

/* Employee cards (phones) and the shared avatar/row look. */
.emp-cards {
  display: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}
.emp-card,
.quick-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
}
.emp-card { border-bottom: 1px solid var(--border); }
.emp-card:last-child { border-bottom: none; }
.emp-card:hover,
.emp-card.row-dossier-active { background: var(--overlay-medium); }
.emp-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--overlay-medium);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.emp-card-main { flex: 1; min-width: 0; }
.emp-card-name,
.emp-card-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-card-name { font-weight: 600; font-size: 14px; }
.emp-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.emp-card-sub.warn { color: var(--amber); }
.emp-card-sub.danger { color: var(--red); }

html[data-ui="modern"] #employees-table tbody tr.row-dossier-active td { background: var(--red-dim) !important; }

/* Employee card as a right-hand drawer: the overlay stops catching clicks,
   so the table behind stays usable and another row can be opened directly. */
html[data-ui="modern"] #dossier-modal {
  background: transparent;
  pointer-events: none;
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
}
html[data-ui="modern"] #dossier-modal .modal-card-dossier {
  pointer-events: auto;
  width: 100%;
  max-width: 480px;
  max-height: none;
  height: 100%;
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.35);
}
html[data-ui="modern"] #dossier-modal:not(.hidden) .modal-card-dossier { animation: drawer-in 0.22s ease-out; }
html[data-ui="modern"] #dossier-modal.drawer-closing .modal-card-dossier { animation: drawer-out 0.15s ease-in forwards; }
@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes drawer-out {
  from { transform: none; opacity: 1; }
  to { transform: translateX(40px); opacity: 0; }
}
@media (min-width: 1280px) {
  html[data-ui="modern"] body.dossier-drawer-open .main-area { margin-right: 480px; }
}

/* Ctrl+K quick search palette. */
.quick-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
}
.quick-search-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
}
.quick-search-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 16px;
  padding: 14px 16px;
  outline: none;
}
.quick-search-results { max-height: 50vh; overflow-y: auto; }
.quick-search-item.active { background: var(--overlay-medium); }
.quick-search-empty { padding: 16px; color: var(--text-muted); font-size: 13px; }
.quick-search-hint {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* Desktop: navigation moves to a labelled left rail; filters are always
   shown, so the "Фильтры" chip is only needed on phones. */
@media (min-width: 769px) {
  html[data-ui="modern"] .icon-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 76px;
    z-index: 800;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 8px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  html[data-ui="modern"] .icon-toolbar .icon-tab-btn {
    width: 60px;
    height: 56px;
    flex-direction: column;
    gap: 4px;
    border: none;
    background: none;
  }
  html[data-ui="modern"] .icon-toolbar .icon-tab-btn::after {
    content: attr(data-label);
    max-width: 58px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  html[data-ui="modern"] .icon-toolbar .icon-tab-btn:hover { background: var(--overlay-weak); color: var(--text); }
  html[data-ui="modern"] .icon-toolbar .icon-tab-btn.active { background: var(--red-dim); color: var(--red); }
  html[data-ui="modern"] .icon-toolbar .tab-badge { top: 4px; right: 6px; }
  html[data-ui="modern"] .main-area { margin-left: 76px; }
  html[data-ui="modern"] #more-tab-btn { display: none !important; }
}

/* Phones: bottom tab bar, cards instead of the wide table, filters folded
   behind the "Фильтры" chip (search stays visible). */
@media (max-width: 768px) {
  html[data-ui="modern"] .icon-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 800;
    justify-content: space-around;
    gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  html[data-ui="modern"] .icon-toolbar .icon-tab-btn {
    flex: 1 1 0;
    min-width: 0;
    height: 48px;
    flex-direction: column;
    gap: 3px;
    border: none;
    background: none;
  }
  html[data-ui="modern"] .icon-toolbar .icon-tab-btn::after {
    content: attr(data-label);
    max-width: 100%;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  html[data-ui="modern"] .icon-toolbar .icon-tab-btn.active { color: var(--red); }
  html[data-ui="modern"] .icon-toolbar .icon-tab-btn.in-more { display: none; }
  html[data-ui="modern"] .icon-toolbar .tab-badge { top: 0; right: calc(50% - 20px); }
  html[data-ui="modern"] #main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  html[data-ui="modern"] .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

  html[data-ui="modern"] #tab-admin .table-wrap,
  html[data-ui="modern"] #tab-admin #bulk-actions-bar { display: none !important; }
  html[data-ui="modern"] .emp-cards { display: block; }
  html[data-ui="modern"] #tab-admin .admin-filters-bar { padding: 10px; }
  /* Cards have no columns to pick. */
  html[data-ui="modern"] #tab-admin .columns-menu-wrap { display: none; }
}

@media print {
  body * { visibility: hidden; }
  #tab-admin, #tab-admin .table-wrap, #tab-admin .table-wrap * { visibility: visible; }
  #tab-admin { position: absolute; left: 0; top: 0; width: 100%; margin: 0; padding: 0; }
  #tab-admin .admin-filters-bar,
  #tab-admin .admin-main-toolbar,
  #tab-admin #bulk-actions-bar { display: none; }
  #tab-admin .section-title { visibility: visible; color: #000; }
  #tab-admin .table-wrap { max-height: none; overflow: visible; }
  #tab-admin .data-table { width: 100%; border-collapse: collapse; color: #000; background: #fff; }
  #tab-admin .data-table th, #tab-admin .data-table td {
    border: 1px solid #999;
    color: #000;
    background: #fff;
    padding: 4px 6px;
    font-size: 11px;
  }
  #tab-admin .data-table th:first-child, #tab-admin .data-table td:first-child,
  #tab-admin .data-table th:last-child, #tab-admin .data-table td:last-child { display: none; }
  #tab-admin .col-resizer { display: none; }
  #tab-admin .sticky-col-fio { position: static; box-shadow: none; background: #fff; }
}
