/* MMS V2 — main.css
   Стиль-референс: 3dtomo.ru (STYLE_REFERENCE.md) */

/* === Переменные === */
:root {
  /* --accent and --accent-hover set dynamically from SiteSettings via base.html */
  --accent: #DB212A;
  --accent-hover: #c11d25;
  --text: #212529;
  --text-secondary: #495057;
  --text-muted: rgba(0, 0, 0, 0.54);
  --bg: #FFFFFF;
  --bg-gray: #F8F9FA;
  --border: #DEE2E6;
  --border-input: #CED4DA;
  --dark: #343A40;
  --font: -apple-system, "system-ui", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans",
          sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  padding: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* === Layout === */
.container {
  max-width: var(--container-max-width, 1140px);
  margin: 0 auto;
  padding: 0 15px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -15px;
}

.col-md-2, .col-md-3, .col-md-7, .col-md-9, .col-md-12 {
  padding: 0 15px;
}
.col-md-2  { flex: 0 0 16.666%; max-width: 16.666%; }
.col-md-3  { flex: 0 0 25%; max-width: 25%; }
.col-md-7  { flex: 0 0 58.333%; max-width: 58.333%; }
.col-md-9  { flex: 0 0 75%; max-width: 75%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }

/* === Header === */
.site-header {
  padding: 16px 0 6px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
}

/* Online bar — под header */
.online-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: var(--container-max-width, 1140px);
  margin: 0 auto;
  padding: 4px 15px 0;
  font-size: 12px;
  color: var(--text-secondary);
}
.online-label { font-weight: 600; white-space: nowrap; }
.online-user { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.online-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  background: #e5e7eb;
  color: #4b5563;
  border-radius: 3px;
  padding: 1px 4px;
  min-width: 14px;
  text-align: center;
}
.online-badge-blocked {
  background: #fecaca;
  color: #dc2626;
}
.online-badge-warn {
  background: #fef3c7;
  color: #92400e;
}
/* Мгновенный tooltip */
.tip-wrap { position: relative; }
.tip-text {
  display: none;
  position: absolute;
  left: 0; top: 100%;
  margin-top: 4px;
  background: #1f2937;
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 4px;
  white-space: pre;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.tip-wrap:hover .tip-text { display: block; }
.site-header { margin-bottom: 24px; }

.header-container {
  max-width: var(--container-max-width, 1140px);
  margin: 0 auto;
  padding: 0 15px;
}

.site-header .row {
  align-items: center;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.logo:hover { text-decoration: none; }

.header-meta {
  text-align: right;
  font-size: 14px;
  color: var(--text-secondary);
}

.header-meta .user-name {
  margin-right: 12px;
  color: var(--text-secondary);
  text-decoration: none;
}
.header-meta .user-name:hover {
  text-decoration: underline;
}

/* === Page tabs (browser-like, in header) === */
.page-tabs-wrapper {
  display: flex;
  align-items: stretch;
  position: relative;
}
.page-tabs-arrow {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0;
  z-index: 1;
  user-select: none;
}
.page-tabs-arrow:hover {
  color: var(--text);
  background: var(--bg-gray);
}
.page-tabs-arrow.visible {
  display: flex;
}
.page-tabs {
  display: flex;
  gap: 0;
  overflow: hidden;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
  margin-bottom: -1px;
  flex: 1;
  /* Резервный «хвост» справа в скроллируемой области — чтобы активная
     последняя вкладка могла быть прокручена целиком в видимую зону. */
  padding-right: 40px;
}
.page-tabs:empty {
  display: none;
  border: none;
}
.page-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  font-size: 16px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  border-radius: 4px 4px 0 0;
  margin-bottom: -1px;
  cursor: pointer;
  /* Squeeze: неактивные сжимаются */
  flex: 0 1 auto;
  min-width: 100px;
  max-width: 220px;
  overflow: hidden;
}
.page-tab:hover {
  text-decoration: none;
  background: var(--bg-gray);
}
.page-tab.active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border) var(--border) transparent;
  font-weight: 600;
  /* Активная шире и не сжимается */
  min-width: 200px;
  max-width: 360px;
  flex-shrink: 0;
}
.page-tab-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.page-tab-close {
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  border-radius: 2px;
  margin-left: 2px;
  flex-shrink: 0;
  /* Скрыт у промежуточных вкладок, чтобы они были компактнее */
  display: none;
}
.page-tab-close:hover {
  color: var(--accent);
  background: rgba(0,0,0,0.05);
}
/* Крестик виден: у активной, у последней (самой правой), при hover */
.page-tab.active .page-tab-close,
.page-tab:last-child .page-tab-close,
.page-tab:hover .page-tab-close {
  display: inline-block;
}

/* === Navigation (left sidebar) === */
.sidebar-nav {
  background: var(--sidebar-bg);
}

.nav-pills {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-pills .nav-item {
  margin-bottom: 2px;
}

.nav-pills .nav-link {
  display: block;
  color: var(--accent);
  background: transparent;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-pills .nav-link:hover {
  background: var(--bg-gray);
  text-decoration: none;
}

.nav-pills .nav-link.active {
  color: #FFFFFF;
  background: var(--accent);
}

.nav-pills .nav-link.active:hover {
  background: var(--accent-hover);
}

/* Section labels in sidebar (non-clickable group headers) */
.nav-section-label {
  display: block;
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

/* Line-only separator (no text, for single-item sections) */
.nav-section-line {
  display: block;
  border-bottom: 1px solid var(--border);
  margin: 6px 16px;
}

.nav-pills .nav-sub {
  list-style: none;
  padding: 0 0 0 16px;
  margin: 0;
}

.nav-pills .nav-sub .nav-link {
  font-size: 14px;
  padding: 5px 16px;
}

/* Single nav links (no section header) — match sub-item indent */
.nav-pills .nav-link-single {
  margin-left: 16px;
  font-size: 14px;
  padding: 5px 16px;
}

/* === Tabs (серверные — ссылки, стиль подчёркивания) === */
.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.tab-list .tab-item a {
  display: block;
  color: var(--text-muted);
  background: transparent;
  padding: 8px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: color 0.15s;
}

.tab-list .tab-item a:hover {
  color: var(--text);
  text-decoration: none;
}

.tab-list .tab-item a.active {
  color: var(--accent);
  background: transparent;
  border-bottom-color: var(--accent);
}

.badge {
  display: inline-block;
  font-size: 12px;
  background: var(--bg-gray);
  color: var(--text);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 4px;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-weight: 700;
  font-size: 16px;
  padding: 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
  text-align: left;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 16px;
}

tr:hover {
  background: var(--bg-gray);
}

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 8px 18px;
  font-size: 16px;
  font-family: var(--font);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.5;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.9;
  text-decoration: none;
}

.btn-primary {
  color: #FFFFFF;
  background: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  color: #FFFFFF;
  background: var(--dark);
}

.btn-outline {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
}
.btn-outline:hover {
  color: #FFFFFF;
  background: var(--accent);
}

.btn-danger {
  color: #ef4444;
  background: transparent;
  border: 1px solid #ef4444;
}
.btn-danger:hover {
  color: #FFFFFF;
  background: #ef4444;
}

.btn-danger-filled {
  color: #FFFFFF;
  background: #ef4444;
  border: 1px solid #ef4444;
}
.btn-danger-filled:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-sm {
  font-size: 14px;
  padding: 4px 10px;
}

.btn-link-danger {
  color: #ef4444;
  font-size: 12px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.btn-link-danger:hover {
  text-decoration: underline;
}

/* === Forms === */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 400;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
input[type="tel"],
select,
textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--border-input);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 16px;
  font-family: var(--font);
  height: 38px;
  background: var(--bg);
  color: var(--text);
}

textarea {
  height: auto;
  min-height: 80px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(219, 33, 42, 0.15);
}

/* === Autocomplete navigate (single result → click = navigate) === */
.acs-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}
.acs-wrap input {
  width: 100%;
  box-sizing: border-box;
}
.acs-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: var(--bg);
  border: 1px solid var(--border-input);
  border-radius: 4px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
  margin-top: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.acs-suggestions.ac-hidden {
  display: none;
}
.acs-suggestion {
  display: block;
  padding: 8px 12px;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.acs-suggestion:last-child {
  border-bottom: none;
}
.acs-suggestion:hover {
  background: rgba(219, 33, 42, 0.08);
  color: var(--accent);
  text-decoration: none;
}

/* === Autocomplete multi-select === */
.ac-multi {
  width: 100%;
  background: transparent;
  box-sizing: border-box;
}
.ac-multi .ac-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.ac-multi .ac-tags:empty {
  display: none;
}
.ac-multi .ac-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  font-family: var(--font);
}
.ac-multi .ac-remove {
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  padding: 0 4px;
  font-size: 20px;
  line-height: 1;
}
.ac-multi .ac-remove:hover {
  color: #ffd;
}
.ac-multi .ac-input-wrap {
  position: relative;
}
.ac-multi .ac-search {
  width: 100%;
  border: 1px solid var(--border-input);
  border-radius: 4px;
  outline: none;
  padding: 6px 12px;
  font-size: 16px;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 38px;
  box-sizing: border-box;
}
.ac-multi .ac-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: var(--bg);
  border: 1px solid var(--border-input);
  border-radius: 4px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.ac-multi .ac-suggestions.ac-hidden {
  display: none;
}
.ac-multi .ac-suggestion {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 15px;
}
.ac-multi .ac-suggestion:hover {
  background: rgba(219, 33, 42, 0.08);
}

/* === Inline form: label + input в одной строке === */
.form-inline .form-group {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}
.form-inline .form-group label {
  flex: 0 0 160px;
  margin-bottom: 0;
  text-align: left;
  padding-top: 8px;
}
.form-inline .form-group > input,
.form-inline .form-group > select,
.form-inline .form-group > textarea,
.form-inline .form-group > .ac-multi,
.form-inline .form-group > .ac-single {
  flex: 1;
  width: auto;
  min-width: 0;
}

/* === Single FK autocomplete === */
.ac-single { position: relative; }
.ac-single-field { position: relative; display: flex; align-items: center; gap: 4px; }
.ac-single-text { flex: 1; min-width: 0; }
.ac-single-clear {
  flex-shrink: 0;
  border: none; background: var(--color-primary, #c62828); color: #fff;
  border-radius: 50%; width: 18px; height: 18px; line-height: 18px;
  font-size: 14px; cursor: pointer; padding: 0; text-align: center;
}
.ac-single-clear:hover { background: #8e1414; }
.ac-single .ac-suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: #fff; border: 1px solid var(--border-color, #ddd);
  border-radius: 4px; max-height: 220px; overflow-y: auto;
}
.ac-single .ac-suggestions.ac-hidden { display: none; }
.ac-single .ac-suggestion { padding: 6px 12px; cursor: pointer; font-size: 14px; }
.ac-single .ac-suggestion:hover { background: rgba(198,40,40,.08); }
/* errorlist под полем */
.form-inline .form-group .errorlist {
  flex: 0 0 100%;
  margin-left: 176px;
}
@media (max-width: 640px) {
  .form-inline .form-group {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .form-inline .form-group label {
    flex: none;
    padding-top: 0;
  }
  .form-inline .form-group .errorlist {
    margin-left: 0;
  }
}

/* === Alerts === */
.alert {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.errorlist {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  color: #991b1b;
  font-size: 14px;
}

/* === Dashboard Tiles === */
.dashboard-section {
  margin-bottom: 32px;
}

.dashboard-section h3 {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px;
}

.tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border-radius: 8px;
  background: var(--bg-gray);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  text-align: center;
  padding: 8px;
  transition: transform 0.15s, box-shadow 0.15s, color 0.15s;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: var(--accent);
  text-decoration: none;
}

.tile-grid-flow {
  align-items: flex-start;
}

.tile-spacer {
  width: 50px;
  height: 0;
}

/* Dashboard groups — flex flow, equal height in row */
.dashboard-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: stretch;
}

.dashboard-group {
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px 14px;
}

.dashboard-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.dashboard-group:not(:has(.tile)) {
  display: none;
}

.dashboard-group-admin {}

.tile .tile-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.tile .tile-label {
  line-height: 1.2;
}

/* Module tiles on settings page */
.module-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  grid-column: 1 / -1;
}
.module-tile {
  cursor: pointer;
  position: relative;
}
.module-tile input[type="checkbox"] {
  position: absolute;
  top: 4px;
  right: 4px;
}
.module-tile input:not(:checked) + .tile-icon {
  opacity: 0.3;
}
.module-tile input:not(:checked) ~ .tile-label {
  opacity: 0.5;
}
.module-standalone {
  align-self: flex-start;
  margin-top: 0;
}

/* === Login Page === */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-gray);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: var(--bg);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
  text-align: center;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-card .btn {
  width: 100%;
  padding: 10px;
  font-size: 16px;
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 24px 0;
  gap: 4px;
  flex-wrap: wrap;
}

.pagination a, .pagination > span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  text-decoration: none;
}

.pagination .active {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}
.pagination .active span { color: #FFFFFF; border: none; padding: 0; }

/* === Utilities === */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* === Modals === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg);
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* === Filter Bar === */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-gray);
  border-radius: 4px;
}

.filter-bar .form-group {
  margin-bottom: 0;
}

.filter-bar label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.filter-bar input, .filter-bar select {
  height: 34px;
  font-size: 14px;
}

/* === Status Badges === */
.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
}

/* Visual markers на карточке Enrollment (см. DEVELOPER_GUIDE 3.12) */
.badge-yellow {
  background: #fef3c7;
  color: #92400e;
}
.badge-blue {
  background: #dbeafe;
  color: #1e40af;
}
.badge-orange {
  background: #fed7aa;
  color: #9a3412;
}
.badge-red {
  background: #fee2e2;
  color: #991b1b;
}
.badge-green {
  background: #d1fae5;
  color: #065f46;
}

/* === Cards === */
.card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 16px;
}

.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.card-grid .card {
  flex: 1;
  min-width: 150px;
  margin-bottom: 0;
  text-align: center;
}

.card-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

/* === Page Header (title + actions) === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.page-header h2 {
  margin: 0;
  font-size: 20px;
}

.page-header .actions {
  display: flex;
  gap: 8px;
}

/* === Autocomplete === */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

.autocomplete-item:hover {
  background: var(--bg-gray);
}

/* === Inline formset rows === */
/* div-based formset (orders) */
div.formset-row {
  display: flex;
  gap: 8px;
  align-items: end;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

div.formset-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.formset-row .btn-remove {
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  font-size: 18px;
}
/* table-based formset (workplaces) */
tr.formset-row.wp-inactive { opacity: 0.4; }
tr.formset-row.wp-deleted { display: none; }

/* === Table Helpers === */
.table-actions {
  white-space: nowrap;
}

.table-actions a {
  margin-right: 8px;
  font-size: 14px;
}

tr.deleted { opacity: 0.5; text-decoration: line-through; }

/* === Sortable Table Headers === */
.sortable-header {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.sortable-header:hover {
  background: #eef1f4;
}

.sort-indicator {
  font-size: 12px;
  color: var(--accent);
  margin-left: 2px;
}

.sortable-header.sort-asc,
.sortable-header.sort-desc {
  color: var(--accent);
}

/* === Checkbox in table === */
th input[type="checkbox"],
td input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

/* === Header columns (flexible) === */
.col-header-left {
  flex: 0 0 auto;
  padding: 0 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.col-header-center {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0 15px;
}
.col-header-right {
  flex: 0 0 auto;
  padding: 0 15px;
}

/* === Navigation Toggle (hamburger) === */
.nav-toggle {
  display: none;
  cursor: pointer;
  font-size: 18px;
  user-select: none;
  line-height: 1;
  align-self: flex-end;
  transform: translateY(-7px);
}

/* === Sidebar Overlay === */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 499;
}

/* === Admin section separator (sidebar) === */
.nav-admin-section {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* ──────────────────────────────────────
   Layout: collapsed (default) + page-narrow
   ────────────────────────────────────── */
.nav-collapsed .container { max-width: var(--container-max-width, 1140px); }

/* Page-narrow: контейнер 1140px (dashboard, profile, docs и др.) */
.page-narrow .container { max-width: var(--container-max-width, 1140px); }

.nav-collapsed .nav-toggle {
  display: inline-block;
}

.nav-collapsed .sidebar-nav {
  display: none;
}

.nav-collapsed .main-content {
  flex: 0 0 100%;
  max-width: 100%;
}

/* Sidebar open state */
.nav-collapsed.sidebar-open .sidebar-nav {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 500;
  overflow-y: auto;
  padding: 16px;
  box-shadow: 4px 0 12px rgba(0,0,0,0.1);
}

.nav-collapsed.sidebar-open .sidebar-overlay {
  display: block;
}

/* === Settings Grid (responsive columns) === */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px 40px;
  max-width: 100%;
}
@media (min-width: 1200px) {
  .settings-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.settings-field {
  margin-bottom: 4px;
}

.settings-field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 400;
  color: var(--text);
}

/* Schedule table inputs: compact like time fields */
.settings-field table input[type="number"],
.settings-field table input[type="time"] {
  display: inline-block;
  width: auto;
}

/* Textarea and file fields span full width */
.settings-field--wide {
  grid-column: 1 / -1;
}

/* === Responsive === */
@media (max-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .col-md-2, .col-md-3, .col-md-7, .col-md-9 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .nav-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
  }
  .nav-pills .nav-sub {
    display: none;
  }
  .header-meta { text-align: left; margin-top: 8px; }
  .tile { width: 80px; height: 80px; }
}

/* === View-As badge / dropdown в header === */
.va-wrapper {
  position: relative;
  display: inline-block;
  margin: 0 8px;
  vertical-align: middle;
}
.va-badge {
  display: inline-block;
  font-size: 14px;
  line-height: 1.5;
  padding: 4px 10px;
  border-radius: 3px;
  background: #e5e7eb;
  color: #4b5563;
  font-weight: 600;
  white-space: nowrap;
}
.va-badge-super {
  cursor: pointer;
  background: #dbeafe;
  color: #1d4ed8;
  border: none;
  font-family: inherit;
}
.va-badge-super:hover { background: #bfdbfe; }
.va-arrow { font-size: 9px; }
.va-badge-active {
  background: #fef3c7;
  color: #92400e;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.va-exit {
  color: #92400e;
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.va-exit:hover { color: #dc2626; }

.va-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  min-width: 220px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  padding: 4px 0;
}
.va-open .va-dropdown { display: block; }
.va-section-label {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #9ca3af;
  letter-spacing: 0.5px;
}
.va-item {
  display: block;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text, #333);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.va-item:hover { background: #f3f4f6; }
.va-divider {
  height: 1px;
  background: var(--border, #e5e7eb);
  margin: 4px 0;
}

/* === Режим просмотра от имени группы === */
.view-as-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  background: #f59e0b;
  color: #fff;
  padding: 7px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.view-as-exit {
  color: #fff;
  text-decoration: underline;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 16px;
}
.view-as-exit:hover { opacity: .8; }
body.view-as-active {
  padding-top: 36px;
}
