* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html,
body {
  margin: 0;
  background: #f5f5f7;
  color: #222;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

header {
  background: #1f2933;
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.clock-display {
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #fff;
  color: #000;
  width: fit-content;
  min-width: 0;
  align-self: center;
  margin: 0 auto;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 20px;
}

.nav-menu {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.nav-toggle {
  display: none;
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 16px;
  cursor: pointer;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.cards-toolbar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.cards-toolbar .button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}


.search-with-camera {
  position: relative;
  width: 100%;
}

.search-with-camera input {
  padding-right: 52px;
}

.search-with-camera .workspace-search-input {
  padding-right: 52px;
}

.camera-scan-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.camera-scan-btn svg {
  width: 22px;
  height: 22px;
  fill: #111827;
}

.camera-scan-btn:hover,
.camera-scan-btn:focus-visible {
  background: rgba(17, 24, 39, 0.08);
  outline: none;
}

.camera-scan-btn--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.camera-scan-btn--disabled:hover,
.camera-scan-btn--disabled:focus-visible {
  background: transparent;
}

.cards-subtabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}

.subtab-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.subtab-btn.active {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

.cards-tab-panel.hidden {
  display: none;
}

.nav-btn {
  border: none;
  padding: 17px 16px;
  border-radius: 10px;
  background: #656971;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  height: 50px;
}

.nav-btn.active {
  background: #10b981;
}

.nav-btn-multiline {
  display: inline-block;
  line-height: 1.1;
  text-align: center;
}

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 25px 16px;
  min-height: 44px;
  border-radius: 10px;
  font-size: 15px;
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 0;
  min-width: 200px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  display: none;
  z-index: 50;
}

.nav-dropdown-menu.open {
  display: block;
}

.nav-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #111827;
  text-decoration: none;
}

.nav-dropdown-item:hover,
.nav-dropdown-item:focus {
  background: #f3f4f6;
}

.status-banner {
  margin: 0;
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  background: #e0f2fe;
  color: #075985;
}

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

.status-banner.status-info {
  background: #e0f2fe;
  color: #075985;
}

.workspace-search-row {
  display: grid;
  grid-template-columns: auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.workspace-search-label {
  font-weight: 600;
  white-space: nowrap;
}

.workspace-search-input {
  width: 100%;
  font-size: 16px;
  padding: 14px 12px;
  min-height: 56px;
}

.workspace-search-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.workspace-search-btn {
  padding: 14px 18px;
  font-size: 16px;
}

#workspace-results .wo-card {
  border-color: #10b981;
}

.workspace-stop-content {
  max-width: 520px;
}

.workspace-stop-body {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.workspace-stop-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 200px;
}

.workspace-stop-fields input {
  width: 100%;
  font-size: 16px;
  padding: 6px 8px;
}

.workspace-stop-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 200px;
}

.workspace-stop-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-stop-btn {
  padding: 14px 18px;
  font-size: 16px;
}

.workspace-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(60px, 1fr));
  gap: 8px;
}

.workspace-keypad button {
  padding: 12px 8px;
  font-size: 16px;
  cursor: pointer;
  min-height: 44px;
}

.workspace-stop-total {
  margin: 6px 0 0;
  font-size: 14px;
  color: #374151;
}

.workspace-stop-actions {
  justify-content: center;
  gap: 14px;
}

.workspace-stop-action-btn {
  padding: 14px 20px;
  font-size: 16px;
}

.hidden {
  display: none !important;
}

main {
  padding: 16px 12px 24px;
  max-width: 1200px;
  width: min(1200px, 100%);
  margin: 0 auto;
}

body.page-card-mode main,
body.page-directory-mode main {
  max-width: none;
  width: 100%;
}

@media (min-width: 1024px) {
  main {
    max-width: none;
    width: 100%;
  }
}

#dashboard {
  overflow: hidden;
}

.card-page {
  display: none;
  margin: 0 auto 16px;
  max-width: 1200px;
}

.card-page:not(.hidden) {
  display: block;
}

.card-page .card-modal-content {
  max-width: none;
  width: 100%;
  max-height: none;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.card-page .modal-body {
  max-height: none;
}

.card-page .modal-actions {
  justify-content: flex-start;
}

section {
  display: none;
}

section.active {
  display: block;
}

.dashboard-pager-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-pages {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.dashboard-page {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease-in-out, visibility 0s linear 0.35s;
}

.dashboard-page table {
  width: 100%;
}

.dashboard-page.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.35s ease-in-out, visibility 0s;
}

.dashboard-page.no-transition {
  transition: none !important;
}

.dashboard-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 18px;
  user-select: none;
  padding-bottom: 4px;
}

.dashboard-dot {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  color: #9ca3af;
  line-height: 1;
}

.dashboard-dot.active {
  color: #111827;
  font-weight: 700;
}

@keyframes dash-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

h2 {
  margin-top: 0;
  font-size: 18px;
  margin-bottom: 12px;
}

h3 {
  margin-top: 0;
  font-size: 16px;
  margin-bottom: 8px;
}

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

.flex-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 13px;
  margin-bottom: 2px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 14px;
}

.combo-field {
  position: relative;
  display: flex;
  align-items: center;
}

.executor-combobox {
  position: relative;
  display: flex;
  align-items: center;
}

.executor-combobox.executor-combo::after {
  content: none;
}

.executor-combobox input {
  padding-right: 48px;
}

.executor-arrow {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  min-width: 40px;
  height: 100%;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid #d1d5db;
}

.executor-arrow:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.executor-combo::after {
  content: '\25BE';
  position: absolute;
  right: 10px;
  color: #6b7280;
  font-size: 12px;
  pointer-events: none;
}

.executor-combo input {
  padding-right: 32px;
}

.combo-suggestions {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  max-height: 220px;
  overflow-y: auto;
  z-index: 5;
  padding: 4px 0;
}

.executor-combobox .executor-suggestions {
  top: 100%;
  width: 100%;
  max-height: 200px;
  z-index: 1000;
}

.combo-suggestions.open {
  display: block;
}

@media (min-width: 769px) {
  .executor-suggestions {
    display: none !important;
  }
}

.combo-option {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
  width: 100%;
  background: #fff;
  border: none;
  text-align: left;
  color: #111827;
  font-size: 14px;
}

.combo-option:last-child {
  border-bottom: none;
}

.combo-option:hover,
.combo-option:focus {
  background: #f8fafc;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-small {
  border-radius: 6px;
  border: none;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-primary {
  background: #10b981;
  color: #fff;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.clip-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef2ff;
  color: #1f2937;
  border: 1px solid #cbd5e1;
}

.clip-count {
  font-weight: 700;
}

.inline-clip {
  padding: 4px 8px;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-small {
  background: #9ca3af;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
}

#production-today{
  padding: 5px 10px;
}

.barcode-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.barcode-icon {
  display: block;
  width: 18px;
  height: 14px;
  background: repeating-linear-gradient(
    90deg,
    currentColor 0,
    currentColor 2px,
    transparent 2px,
    transparent 4px
  );
  border-radius: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.table-wrapper table {
  min-width: 640px;
}

th,
td {
  border: 1px solid #e5e7eb;
  padding: 6px 8px;
  text-align: left;
}

thead {
  background: #cdcdcf;
}


tbody tr:nth-child(even) {
  background: #f3f4f6;
}

.nk-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  line-height: 1.3;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.status-not-started {
  background: #e5e7eb;
  color: #374151;
}

.status-in-progress {
  background: #bfdbfe;
  color: #1d4ed8;
}

.status-paused {
  background: #fef3c7;
  color: #92400e;
}

.status-done {
  background: #34d399;
  color: #064e3b;
}

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

.stat-block {
  background: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  min-width: 120px;
}

.stat-block span {
  display: block;
  font-size: 11px;
  color: #6b7280;
}

.stat-block strong {
  font-size: 18px;
}

.table-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.card-info-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}

.card-display-grid {
  margin: 8px 0 12px;
}

.card-display-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-display-field .field-label {
  color: #4b5563;
  font-size: 13px;
}

.card-display-field .field-value {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  word-break: break-word;
  white-space: pre-wrap;
}

.card-display-field .field-value.multiline {
  white-space: pre-line;
}

.card-display-field-full {
  grid-column: 1 / -1;
}

.card-info-collapse-block {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  margin: 8px 0 12px;
}

.card-info-collapse-block .card-main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-info-collapse-block .card-main-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
}

.card-info-collapse-block .card-main-summary {
  display: block;
  color: #374151;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 160px;
}

.card-info-collapse-block .card-main-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.card-info-collapse-block.is-collapsed {
  padding: 10px 12px;
}

.card-info-collapse-block.is-collapsed .card-main-collapse-body {
  display: none;
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.directory-modal-content .table-actions {
  flex-wrap: nowrap;
  align-items: center;
}

.directory-panel h3 {
  margin-top: 0;
}

.card-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: start;
}

.card-meta-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card-meta-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-meta-responsible .card-meta-grid {
  align-items: stretch;
}

.card-main-collapse-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-main-header {
  display: none;
  align-items: center;
  gap: 12px;
}

.card-main-header h3 {
  margin: 0;
}

.card-main-summary {
  display: none;
}

.card-main-toggle {
  display: none;
}

.card-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.route-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.route-form-grid .flex-col {
  margin: 0;
}

#route-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#route-table-wrapper {
  flex: 1 1 auto;
  overflow: visible;
}

.card-section {
  display: block;
}

.card-section-menu {
  display: none;
}

#production-editor-toggle {
  padding: 16px 12px;
}

.products-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#tab-products.mki-mode .products-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  column-gap: 16px;
  row-gap: 12px;
}

#tab-products.mki-mode #field-batch-size,
#tab-products.mki-mode #field-item-serials {
  grid-column: 1;
}

#tab-products.mki-mode #field-sample-qty,
#tab-products.mki-mode #field-sample-serials {
  grid-column: 2;
}

.serials-table-wrapper {
  width: 100%;
}

.serials-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.serials-table td {
  padding: 6px 8px;
  vertical-align: middle;
}

.serials-index-cell {
  width: 36px;
  text-align: right;
  color: #6b7280;
  white-space: nowrap;
}

.serials-input-cell input {
  width: 100%;
}

/* === MKI: вкладка "Изделия" — симметричная сетка 2×2 === */
#card-modal.is-mki #tab-products .mki-products-grid,
body.is-mki #tab-products .mki-products-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 18px 24px;
  align-items: start;
}

#card-modal.is-mki #tab-products .mki-products-cell,
body.is-mki #tab-products .mki-products-cell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* Мобильная адаптация */
@media (max-width: 900px) {
  #card-modal.is-mki #tab-products .mki-products-grid,
  body.is-mki #tab-products .mki-products-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
}

.route-add-panel {
  position: sticky;
  bottom: 0;
  background: #fff;
  /* border-top: 1px solid #e5e7eb; */
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 1025px) {
  .card-modal-content {
    height: 92vh;
    max-height: 92vh;
  }

  .card-modal-content .modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    padding-right: 12px;
  }

  #card-modal .card-section-main {
    margin-bottom: 0;
  }

  .card-main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .card-main-summary {
    color: #374151;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 160px;
  }

  .card-main-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
  }

  .card-main-collapse-block {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    background: #fff;
  }

  .card-main-collapse-block.is-collapsed {
    padding: 10px 12px;
  }

  .card-main-collapse-block.is-collapsed .card-main-summary {
    display: block;
  }

  .card-main-collapse-block.is-collapsed .card-main-collapse-body {
    display: none;
  }

  #route-editor {
    flex: 1 1 auto;
    gap: 12px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .card-section-operations {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }

  #route-table-wrapper {
    flex: 1 1 auto;
    overflow-y: auto;
  }

  #route-table-wrapper th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f3f4f6; /* Ensure header is opaque */
    box-shadow: 0 1px 0 #e5e7eb; /* Optional: keeps border visibility */
  }

  .card-section-add {
    flex: 0 0 auto;
  }

  .route-add-panel {
    position: static;
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
  }
}

.card-mobile-menu {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  position: relative;
}

.card-menu-toggle {
  white-space: nowrap;
  padding: 6px 10px;
  font-size: 14px;
}

.card-menu-active {
  font-weight: 700;
  color: #111827;
}

.card-section-menu {
  position: absolute;
  inset: calc(100% + 6px) 0 auto 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  padding: 10px;
  z-index: 10;
  display: none;
  flex-direction: column;
  gap: 6px;
}

.card-section-menu.open {
  display: flex;
}

.card-section-menu-title {
  font-weight: 700;
  color: #374151;
}

.card-section-menu-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

.card-section-menu-item {
  text-align: left;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.card-section-menu-item:hover,
.card-section-menu-item:focus-visible {
  background: #eef2ff;
  outline: none;
}

.btn-link {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  color: #2563eb;
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
}

.barcode-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1400;
}

.barcode-modal-content {
  background: #fff;
  padding: 16px 20px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  max-width: 480px;
  width: min(480px, calc(100% - 24px));
  text-align: center;
  overflow: hidden;
}

.barcode-viewport {
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
}

.barcode-svg {
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.barcode-svg svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.barcode-error {
  color: #b91c1c;
  font-size: 14px;
  text-align: center;
}

.barcode-modal-header {
  margin-bottom: 10px;
}

.barcode-modal-hint {
  font-size: 12px;
  color: #6b7280;
  margin: 4px 0 0;
}

.barcode-user-label {
  margin-top: 6px;
  font-size: 14px;
  color: #111827;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.18);
  max-width: 960px;
  width: 95%;
  max-height: 92vh;
  overflow: hidden;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}

#access-level-modal .modal-content {
  max-height: 90vh;
}

.modal.page-mode {
  position: static;
  inset: auto;
  background: transparent;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  box-shadow: none;
}

.modal.page-mode .modal-content {
  max-width: none;
  width: calc(100vw - 24px);
  max-height: none;
  box-shadow: none;
  margin: 0 auto;
}

.modal.page-mode .card-modal-content,
.modal.page-mode .directory-modal-content {
  min-height: calc(100vh - 110px);
  width: calc(100vw - 24px);
  max-width: none;
  max-height: none;
}

body.page-card-mode #cards,
body.page-directory-mode #cards {
  display: none;
}

.card-modal-content {
  max-width: 1280px;
  width: min(1280px, 98vw);
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.confirm-modal-content {
  max-width: 520px;
}

.confirm-modal-content .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-modal-content .modal-body {
  flex: 1 1 auto;
  overflow: auto;
  padding-right: 4px;
}

.card-modal-content .modal-actions {
  justify-content: flex-end;
}

.directory-modal-content {
  max-width: 1100px;
  width: min(1100px, 96vw);
}

.attachments-content {
  max-width: 720px;
}

.info-modal-content {
  max-width: 460px;
  text-align: center;
}

.info-modal-content .modal-body {
  font-size: 16px;
}

.attachments-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.log-content {
  max-width: 1100px;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.log-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.log-card-header {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 16px;
  align-items: center;
}

.log-barcode-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px dashed #d1d5db;
  padding: 8px;
  border-radius: 8px;
  background: #f9fafb;
}

.log-barcode-number {
  font-weight: 600;
  letter-spacing: 1px;
}

.log-card-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 12px;
  font-size: 13px;
}

.log-section h4 {
  margin: 0 0 8px;
}

.log-section {
  border-top: 1px solid #e5e7eb;
  padding-top: 10px;
}

.log-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.hint {
  color: #6b7280;
  font-size: 12px;
  margin: 6px 0 0;
}

.log-section th,
.log-section td {
  border: 1px solid #e5e7eb;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.log-section thead {
  background: #d3d4d7;
}

.log-summary-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.log-initial-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 6px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}

.hidden-input {
  display: none;
}

.icon-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
}

.executor-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.executor-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.executor-row .combo-field {
  flex: 1 1 auto;
}

.executor-main-input {
  flex: 1;
  padding: 6px 8px;
}

.executor-name {
  font-weight: 600;
}

.additional-executor-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.executor-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  background: #e5e7eb;
  font-size: 12px;
}

.executor-history-main {
  font-weight: 600;
}

.executor-history-extras {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.executor-history-line {
  font-size: 12px;
  color: #374151;
}

.attachments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}

.attachments-table th,
.attachments-table td {
  border: 1px solid #e5e7eb;
  padding: 6px 8px;
  text-align: left;
}

.attachments-table thead {
  background: #f3f4f6;
}

.upload-hint {
  font-size: 12px;
  color: #6b7280;
}

.modal-header {
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

.modal-header h2, .modal-header h3 {
  margin: 0;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow: hidden;
}

#access-level-modal .modal-body {
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.delete-confirm-hint {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

.card-modal-actions {
  justify-content: space-between;
  align-items: center;
}

.modal-actions-left,
.modal-actions-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inset-card {
  box-shadow: none;
  border: 1px solid #e5e7eb;
  margin: 0;
}

footer {
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  padding: 12px 8px 20px;
}

.wo-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #fff;
}

.wo-card summary {
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid #e5e7eb;
}

.wo-card summary::-webkit-details-marker {
  display: none;
}

.wo-card table {
  margin: 0;
  border: 0;
}

#workorders .operations-table-wrapper .table-actions button {
  padding: 4px 8px;
  font-size: 12px;
  min-height: 32px;
  min-width: 32px;
}

#workorders .operations-table-wrapper .table-actions .btn-primary,
#workorders .operations-table-wrapper .table-actions .btn-secondary,
#workorders .operations-table-wrapper .table-actions .btn-danger {
  min-height: 32px;
}

#workorders .operations-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.summary-text {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.summary-sub {
  color: #6b7280;
  font-size: 12px;
}

.summary-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.summary-inline-actions .btn-small,
.summary-inline-actions .clip-btn {
  min-width: auto;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.status-pill { 
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
}

.status-pill-missing-executor {
  background: #fef9c3;
  color: #92400e;
  border-color: #facc15;
}

.status-pill-not-started {
  background: #f3f4f6;
  color: #374151;
}

.status-pill-in-progress {
  background: #d1fae5;
  color: #065f46;
  border-color: #10b981;
}

.status-pill-paused {
  background: #fef3c7;
  color: #92400e;
  border-color: #facc15;
}

.status-pill-mixed {
  background: linear-gradient(90deg, #fef3c7 0%, #fef3c7 50%, #d1fae5 50%, #d1fae5 100%);
  color: #065f46;
  border-color: #10b981;
}

.status-pill-done {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #10b981;
  background: #fff;
  color: #10b981;
  font-weight: 700;
}

.comment-input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  resize: vertical;
  min-height: 32px;
  line-height: 1.35;
  overflow: hidden;
}

.comment-readonly {
  min-height: 20px;
  padding: 4px 2px;
  color: #374151;
}

.approval-icon-col,
.approval-icon-cell {
  text-align: center;
  width: 56px;
}

.approval-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-weight: 600;
}

.approval-status-approved {
  color: #16a34a;
  background: #dcfce7;
}

.approval-status-rejected {
  color: #dc2626;
  background: #fee2e2;
}

.approval-status-pending {
  color: #6b7280;
  background: #e5e7eb;
}

.approvals-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.approval-thread {
  max-height: min(260px, 35vh);
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  background: #f9fafb;
}

.approval-thread-entry {
  padding: 8px 0;
  border-bottom: 1px dashed #e5e7eb;
}

.approval-thread-entry:last-child {
  border-bottom: none;
}

.approval-thread-header {
  font-weight: 600;
  font-size: 13px;
}

.approval-thread-meta {
  font-size: 12px;
  color: #6b7280;
}

.approval-thread-comment {
  margin-top: 6px;
  font-size: 13px;
  white-space: pre-wrap;
}

.btn-link {
  text-align: left;
 }

.barcode-link {
  text-align: left;
 }
 
.char-counter {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
  text-align: right;
}

.modal-readonly .modal-body {
  background: #f9fafb;
}

.op-qty-row td {
  background: #f9fafb;
  font-size: 12px;
}

.qty-row-content {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.qty-row-content label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.qty-row-content input.qty-input {
  width: 90px;
  padding: 4px 6px;
  font-size: 12px;
}

.qty-row-content .qty-total {
  font-weight: 700;
}

.qty-row-content.readonly .qty-chip {
  background: #e5e7eb;
  padding: 4px 8px;
  border-radius: 6px;
}

.executor-input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
}

.summary-barcode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#workorders-table-wrapper .wo-card,
#archive-table-wrapper .wo-card {
  margin: 0;
  border-radius: 0;
}

#workorders-table-wrapper .wo-card + .wo-card,
#archive-table-wrapper .wo-card + .wo-card {
  border-top: 1px solid #e5e7eb;
}

#workorders-table-wrapper .wo-card:first-child,
#archive-table-wrapper .wo-card:first-child {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

#workorders-table-wrapper .wo-card:last-child,
#archive-table-wrapper .wo-card:last-child {
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  margin-bottom: 12px;
}

.dash-comment-line {
  font-size: 12px;
  margin-bottom: 2px;
}

.dash-qty-line {
  font-size: 12px;
  margin-bottom: 2px;
  white-space: nowrap;
}

.dash-comment-op {
  font-weight: 600;
}

/* Дашборд – отображение операций */
.dash-op {
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
}

.dash-op-paused {
  background: #fef3c7;
  color: #92400e;
}

.dash-op-overdue {
  background: #fee2e2;
  color: #991b1b;
}

.dash-card-completed {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 500;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-modal {
  background: #ffffff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 360px;
  width: 100%;
}

.auth-modal h2 {
  margin-top: 0;
  margin-bottom: 16px;
}

.auth-modal form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-actions button {
  flex: 1 1 120px;
}

.auth-modal input[type="password"] {
  padding: 10px 12px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 14px;
}

.auth-modal button[type="submit"] {
  padding: 10px 12px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.auth-modal button[type="submit"]:hover {
  background: #1d4ed8;
}

.auth-error {
  color: #b91c1c;
  min-height: 20px;
  font-size: 13px;
}

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1200;
}

.help-modal {
  background: #ffffff;
  width: min(960px, 100%);
  height: min(90vh, 900px);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
}

.help-modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.help-close {
  border: none;
  background: #e5e7eb;
  color: #111827;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.help-close:hover {
  background: #d1d5db;
}

.help-close:active {
  transform: scale(0.98);
}

.help-modal-body {
  flex: 1;
  min-height: 0;
  background: #f8fafc;
}

.help-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #f8fafc;
}

.barcode-scanner-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
}

.barcode-scanner-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.barcode-scanner-modal__content {
  position: relative;
  background: #0b1221;
  color: #e5e7eb;
  width: min(520px, 92vw);
  height: min(80vh, 640px);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.barcode-scanner-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.barcode-scanner-video-wrapper {
  flex: 1 1 auto;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.barcode-scanner-video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.barcode-scanner-hint {
  margin: 0;
  font-weight: 600;
  text-align: center;
}

.barcode-scanner-status {
  margin: 0;
  font-size: 14px;
  color: #cbd5e1;
  text-align: center;
  min-height: 20px;
}

.toast-container {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1400;
  pointer-events: none;
}

.toast {
  background: rgba(17, 24, 39, 0.92);
  color: #f8fafc;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 640px) {
  .help-modal {
    height: min(92vh, 760px);
  }

  .help-modal-header h2 {
    font-size: 17px;
  }
}

.password-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.password-row input {
  flex: 1 1 200px;
}

.form-error {
  color: #b91c1c;
  font-size: 14px;
}

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

.security-table th,
.security-table td {
  border: 1px solid #e5e7eb;
  padding: 8px;
  text-align: left;
}

.security-table th {
  background: #f3f4f6;
}

@media (max-width: 640px) {
  .auth-modal {
    max-width: 92vw;
  }

  .auth-actions {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .auth-actions button {
    flex: 1 1 0;
    padding: 10px 8px;
    font-size: 14px;
  }
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.permission-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fafafa;
}

.permission-card h4 {
  margin: 0 0 8px 0;
}

.executor-highlight {
  background: #ecfdf3;
  border: 2px solid #a7f3d0;
  transform: scale(1.02);
}

.executor-highlight .action-buttons button {
  transform: scale(1.05);
}

.center-highlight {
  background: #ecfdf3;
  border-left: 3px solid #22c55e;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: center;
  background: #4c9bbe;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  align-content: center;
  font-size: 15px;
  min-height: 40px;
  border: none;
  cursor: pointer;
}

.user-badge .user-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.user-badge .unread-count {
  display: none;
  min-width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.user-badge.has-unread .unread-count {
  display: inline-flex;
  animation: unreadPulse 1.2s ease-in-out infinite;
}

/* === Chat layout === */
.chat-layout {
  display: flex;
  gap: 16px;
  min-height: 320px;
  height: calc(100vh - 360px);
  max-height: calc(100vh - 360px);
}

.chat-users {
  flex: 0 0 260px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.chat-users-header {
  font-weight: 600;
  color: #0f172a;
}

.chat-users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  max-height: none;
  overflow-y: auto;
}

.chat-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease;
}

.chat-user-row:hover {
  background: #f8fafc;
}

.chat-user-row.active {
  background: #e0f2fe;
  border-color: #bae6fd;
}

.chat-user-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.chat-user-name.unread {
  font-weight: 700;
}

.chat-user-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.chat-user-status.online {
  background: #22c55e;
}

.chat-user-status.offline {
  background: #ef4444;
}

.chat-user-status.unknown {
  background: #94a3b8;
}

.chat-user-icons {
  display: inline-flex;
  gap: 6px;
  font-size: 14px;
}

.chat-thread {
  flex: 1 1 auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.chat-log {
  flex: 0 0 320px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.chat-log-header {
  font-weight: 600;
  color: #0f172a;
}

.chat-log-list {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-action-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
}

.user-action-time {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.user-action-text {
  font-size: 13px;
  color: #0f172a;
  line-height: 1.35;
}

.chat-thread-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-thread-title {
  font-weight: 600;
}

.chat-thread-status {
  font-size: 12px;
  color: #64748b;
}

.chat-card-title-stack h2,
.chat-card-title-stack h3 {
  margin: 0;
}

.chat-card-title-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.webpush-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}

.webpush-status {
  font-size: 12px;
  color: #64748b;
}

.webpush-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chat-messages {
  flex: 1 1 auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  min-height: 0;
}

.chat-scroll-loader {
  font-size: 12px;
  color: #64748b;
  text-align: center;
}

.chat-empty {
  text-align: center;
  color: #94a3b8;
  margin-top: 12px;
}

.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
}

.chat-msg-meta .chat-msg-time {
  margin-bottom: 0;
}

.chat-msg-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-retry-btn {
  background: transparent;
  border: none;
  color: #dc2626;
  font-size: 12px;
  cursor: pointer;
  margin-top: 6px;
  padding: 0;
}

@media (max-width: 900px) {
  .chat-layout {
    flex-direction: column;
  }

  .chat-users {
    flex: 1 1 auto;
  }

  .chat-users-list {
    max-height: 240px;
  }
}

@keyframes unreadPulse {
  0% {
    opacity: 0.6;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.6;
    transform: scale(0.95);
  }
}

.chat-panel {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  height: 320px;
  overflow-y: auto;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.chat-msg {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.chat-msg.me {
  align-self: flex-end;
  background: #e0f2fe;
  border-color: #bae6fd;
}

.chat-msg.other {
  align-self: flex-start;
}

.chat-msg-time {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
}

.tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #cbd5f5;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 14px;
  background: #fff;
}

.tab-pill.active {
  background: #4c9bbe;
  color: #fff;
  border-color: #4c9bbe;
}

.tab-pill-btn {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 2px 4px;
}

.tab-pill-close {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  opacity: 0.7;
  padding: 2px 4px;
}

.tab-pill-close:hover {
  opacity: 1;
}

.chat-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 12px;
}

.chat-compose textarea {
  flex: 1 1 auto;
}

.chat-compose button {
  flex: 0 0 auto;
}

.btn-logout {
  background: #e37575;
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  min-height: 40px;
  font-size: 15px;
}

.btn-logout:hover {
  background: #dc2626;
}

/* Readonly tab helpers */
.tab-readonly .view-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.tab-readonly input.view-disabled,
.tab-readonly select.view-disabled,
.tab-readonly textarea.view-disabled {
  background-color: #f3f4f6;
}

@media (max-width: 1024px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-menu {
    width: 100%;
    margin-left: 0;
  }

  .user-panel {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .header-left h1 {
    font-size: 18px;
  }

  .header-left {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .clock-display {
    display: none;
  }

  .user-panel {
    margin-left: auto;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }

  .nav-menu {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    display: none;
    gap: 6px;
    margin-left: 0;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-menu .nav-btn {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
  }

  main {
    padding: 12px 10px 20px;
  }

  .card {
    padding: 14px;
  }

  .card-meta-grid,
  .directory-grid,
  .route-form-grid {
    grid-template-columns: 1fr;
  }

  .directory-modal-content {
    width: 100%;
    max-width: 100%;
  }

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

  .workspace-search-row {
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
  }

  .workspace-search-actions {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }

  .workspace-search-btn {
    flex: 1 1 45%;
  }

  table {
    font-size: 12px;
  }

  .table-wrapper table {
    min-width: 520px;
  }

  .combo-field input {
    flex: 1 1 auto;
  }

  #card-modal .card-section {
    display: none;
  }

  #card-modal .card-section.active {
    display: block;
  }

  .card-mobile-menu {
    display: flex;
  }
}

@media (max-width: 600px) {
  header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      'brand user toggle'
      'nav nav nav';
    column-gap: 6px;
    row-gap: 6px;
    align-items: center;
  }

  .header-left {
    grid-area: brand;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    min-width: 0;
  }

  .header-left h1 {
    font-size: 13px;
    line-height: 1.15;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    max-width: 220px;
    margin: 0;
  }

  .user-panel {
    grid-area: user;
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 4px;
    justify-content: flex-end;
    align-items: center;
    margin-left: 0;
    width: auto;
  }

  .user-badge {
    width: auto;
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
  }

  .btn-logout {
    padding: 6px 8px;
    font-size: 12px;
    width: auto;
  }

  .nav-toggle {
    grid-area: toggle;
    justify-self: end;
  }

  .nav-menu {
    grid-area: nav;
  }

  .summary-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .summary-inline-actions {
    flex-wrap: nowrap;
    gap: 4px;
  }

  .summary-inline-actions .btn-small,
  .summary-inline-actions .clip-btn {
    width: auto;
    min-width: 0;
    padding: 3px 6px;
    font-size: 11px;
    min-height: 28px;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .stat-block {
    min-width: 0;
    padding: 6px 4px;
    text-align: center;
  }

  .stat-block span {
    font-size: 10px;
  }

  .stat-block strong {
    font-size: 16px;
  }

  .executor-main-input,
  .additional-executor-input {
    flex: 1 1 auto;
    min-width: 12ch;
  }
}

.password-field {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex: 1 1 auto;
}

.password-visibility {
  min-width: 44px;
  border: 1px solid #d1d5db;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 16px;
}

.password-row {
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.password-hint {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.password-row .password-hint.inline-hint {
  margin: 0;
  white-space: nowrap;
}

.directory-modal-content .modal-body {
  overflow-x: hidden;
}

.directory-modal-content .table-wrapper {
  overflow-x: hidden;
}

.directory-modal-content .table-wrapper table {
  min-width: 0;
  width: 100%;
}

.directory-modal-content .flex {
  gap: 10px;
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  h1 {
    font-size: 18px;
  }

  h2 {
    font-size: 16px;
  }

  h3 {
    font-size: 15px;
  }

  .user-panel {
    width: auto;
    justify-items: end;
  }

  .user-badge {
    width: auto;
    text-align: right;
  }

  .btn-primary,
  .btn-secondary,
  .btn-danger,
  .btn-small {
    width: 100%;
  }

  .summary-inline-actions .btn-small,
  .summary-inline-actions .clip-btn {
    width: auto;
  }

  .user-panel .btn-logout {
    width: auto;
  }

  .workspace-search-actions {
    flex-direction: column;
  }

  .workspace-search-btn {
    width: 100%;
  }
}

/* === Мобильный режим операций === */
#mobile-operations-view {
  position: fixed;
  inset: 0;
  background: #f3f4f6;
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mobile-operations-view.hidden {
  display: none;
}

.mobile-ops-header {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-ops-header-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.mobile-ops-back {
  min-width: 44px;
  min-height: 44px;
  padding: 10px 14px;
}

.mobile-ops-title {
  flex: 1 1 auto;
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.mobile-ops-subtitle {
  font-size: 14px;
  color: #4b5563;
}

.mobile-ops-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: stretch;
}

.mobile-ops-actions .status-pill {
  flex-shrink: 0;
}

.mobile-ops-actions .btn-small {
  min-width: 0;
  flex: 1 1 auto;
}

@media (max-width: 250px) {
  .mobile-ops-actions {
    flex-wrap: wrap;
  }
}

.mobile-ops-indicator {
  position: sticky;
  top: 86px;
  background: #f9fafb;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  z-index: 1;
}

.mobile-ops-list {
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-op-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: visible;
}

.mobile-op-card .card-section-title {
  margin: 8px 0 4px;
}

.mobile-op-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.op-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
}

.op-card-header .op-title {
  flex: 1 1 auto;
  min-width: 0;
}

.op-card-header .op-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.op-card-header .op-status .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 360px) {
  .op-card-header .op-status .badge {
    font-size: 11px;
    padding: 3px 8px;
  }
}

.mobile-op-name {
  font-weight: 700;
  color: #111827;
  word-break: break-word;
}

.mobile-op-meta {
  font-size: 13px;
  color: #6b7280;
  margin-top: 4px;
}

.mobile-executor-block .executor-row,
.mobile-executor-block .executor-cell {
  width: 100%;
}

.mobile-executor-block .executor-row {
  align-items: center;
}

.mobile-plan-time {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.mobile-qty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.mobile-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.mobile-op-comment textarea {
  width: 100%;
  min-height: 60px;
}

@media (min-width: 769px) {
  #mobile-operations-view { display: none !important; }
}

.imdx-missing-list {
  margin: 6px 0 0 20px;
  padding: 0;
  list-style: disc;
}

.imdx-missing-list:empty::before {
  content: 'Все элементы найдены';
  color: #666;
  list-style: none;
  margin-left: -20px;
}

/* Folder-style Tabs */
.tabs-wrapper {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.tabs-header {
  display: flex;
  flex-wrap: wrap;
  /* gap: 2px; Removed gap to allow margin-right to work as in sample */
}

.tab-btn {
  background: linear-gradient(to bottom, #fff 0%, #f4f4f4 100%);
  border: 1px solid #ccc;
  border-bottom: none;
  padding: 10px 25px;
  margin-right: 6px;
  border-radius: 6px 6px 0 0;
  position: relative;
  top: 1px;
  cursor: pointer;
  color: #555;
  font-size: 15px;
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

.tab-btn:hover {
  background: #fff;
}

.tab-btn.active {
  background: #fff;
  border-top: 3px solid #10b981;
  z-index: 2;
  font-weight: 600;
  color: #000;
  padding-bottom: 11px;
  /* margin-bottom: -1px; handled by top: 1px and padding */
}

.tabs-content {
  background: #fff;
  border: 1px solid #ccc;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  padding: 12px;
  min-height: 0;
  border-radius: 0 4px 4px 4px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

#tab-operations.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Top Controls */
.card-top-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.card-status-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .tabs-header {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .tab-btn {
    flex: 1 1 auto; /* Grow to fill width */
    text-align: center;
    margin-right: 2px;
    margin-bottom: 2px;
    padding: 8px 12px;
    font-size: 14px;
  }
  
  .tabs-content {
    padding: 10px;
  }
  
  .card-top-controls {
    justify-content: flex-start;
  }
}

/* Ensure no horizontal scroll in tab content */
.tab-pane {
  overflow-x: hidden;
}

/* Adjust existing grid/flex layouts inside tabs to wrap */
.card-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.card-meta-col {
  flex: 1 1 280px; /* Allow wrapping */
  min-width: 0; /* Prevent flex item from overflowing */
}

/* Ensure inputs don't overflow */
input, textarea, select {
  max-width: 100%;
}

/* Hide old mobile menu if it still exists in CSS */
.card-mobile-menu {
  display: none !important;
}

.card-top-controls {
  margin: 0;
  display: flex;
  align-items: center;
}
/* принудительно убираем линию над "Добавить операцию" */
.route-add-panel {
  border-top: none !important;
}

.route-samples-hint-text {
  font-size: 12px;
  color: #777;
  margin-top: 4px;
}

.is-mki .route-samples-hint-text {
  display: none !important;
}

.is-mki #route-form.route-form-grid {
  grid-template-columns: minmax(120px, 0.8fr) minmax(240px, 1.1fr) minmax(240px, 1.1fr) minmax(170px, 0.9fr) minmax(140px, 0.85fr) auto;
  align-items: center;
  grid-auto-flow: column;
}

@media (max-width: 900px) {
  .is-mki #route-form.route-form-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (max-width: 768px) {
  .is-mki #route-form.route-form-grid {
    grid-template-columns: 1fr;
  }
}

.is-mki .route-qty-col {
  gap: 8px;
}

.is-mki #route-form.route-form-grid .flex-col {
  align-self: stretch;
}

.is-mki #route-form.route-form-grid input,
.is-mki #route-form.route-form-grid .combo-field input {
  height: 36px;
}

.is-mki #route-form.route-form-grid label {
  white-space: nowrap;
}

.is-mki #route-form.route-form-grid .route-submit-col {
  align-self: center;
}

/* MKI only: компактная галочка "Образцы" */
.is-mki .mki-samples-toggle__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.is-mki .mki-samples-toggle__label input[type="checkbox"]{
  width: 14px !important;
  height: 14px !important;
  margin: 0;
  padding: 0;
  accent-color: #1e88e5;
  transform: none !important;
}

.is-mki .mki-qty-block__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:6px;
}

.is-mki .mki-qty-block__samples{
  display:inline-flex;
  align-items:center;
  gap:8px;
  cursor:pointer;
  user-select:none;
  white-space:nowrap;
}

.is-mki .mki-qty-block__samples input[type="checkbox"]{
  width:14px;
  height:14px;
  margin:0;
  padding:0;
  transform:none;
}

.route-qty-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.route-qty-label {
  font-size: 13px;
  color: #444;
}

/* MKI only: ячейка количества операций с маленьким чекбоксом */
.is-mki .mki-op-qty-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.is-mki .mki-op-qty-cell__value {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.is-mki .mki-op-qty-cell__samples {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-size: 13px;
}

.is-mki .mki-op-qty-cell__samples input[type="checkbox"]{
  width: 16px !important;
  height: 16px !important;
  margin: 0;
  transform: none !important;
}

.op-type-tag {
  display: block;
  margin-top: 4px;
  color: #7c3aed;
  font-weight: 600;
}

.mk-cell {
  line-height: 1.2;
}

.mk-qr {
  font-size: 0.8em;
  opacity: 0.75;
}

@media print {
  .op-type-tag {
    display: none !important;
  }
}

/* "Удалить" — компактная серая иконка */
.btn-delete {
  background: #9ca3af;
  color: #fff;
  padding: 4px;
  min-width: 28px;
  min-height: 28px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-delete:hover {
  filter: brightness(0.95);
}

/* Красная подсветка ТОЛЬКО для "Согласование" */
.btn-small.approval-dialog-btn.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-small.approval-dialog-btn.btn-danger:hover {
  filter: brightness(0.95);
}

/* Производство */
.production-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.production-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.production-toolbar__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.production-shifts-toolbar-row {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.production-shifts-toolbar-row .production-toolbar__controls {
  margin-left: auto;
}

/* /production/shifts: toolbar всегда полностью видим */
#production-shifts .production-toolbar {
  overflow: visible;
}

#production-shifts .production-toolbar__controls {
  overflow: visible;
  height: auto;
  max-height: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.production-shifts-queue-search {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
  min-width: 220px;
  width: unset;
}

.production-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  align-items: start;

  /* Общий вертикальный скролл для таблицы и сайдбара */
  height: calc(100vh - 220px);
  overflow-y: auto;

  /* важно для grid + overflow */
  min-height: 0;
}

.production-table-wrapper {
  overflow-x: auto;
  overflow-y: visible;

  /* важно для grid + overflow */
  min-height: 0;
}

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

.production-table th,
.production-table td {
  border: 1px solid #ddd;
  padding: 8px;
  vertical-align: top;
}

.production-table th.production-area {
  width: 180px;
  background: #f7f7f7;
}

.production-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.production-day-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}

.production-day-title {
  display: block;
  text-transform: uppercase;
  font-size: 12px;
  color: #555;
}

.production-day-date {
  display: block;
  font-size: 13px;
}

.production-day-shift {
  border: 1px solid #aebfff;
  background: linear-gradient(180deg, #f5f7ff 0%, #e4eaff 100%);
  color: #1f3b8f;
  cursor: pointer;
  padding: 6px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.production-day.weekend,
.production-table td.weekend {
  background: #ffecec;
}

.production-table th.production-day.production-today,
.production-table td.production-cell.production-today {
  background-color: #f2edff !important;
}

/* TODAY column borders for better visibility */
.production-table th.production-day.production-today,
.production-table td.production-cell.production-today {
  box-shadow:
    inset 1px 0 0 rgba(120, 80, 200, 0.18),
    inset -1px 0 0 rgba(120, 80, 200, 0.18);
}

th.production-day.production-today {
  font-weight: 600;
}

.production-cell {
  min-width: 140px;
  cursor: pointer;
  position: relative;
}

.production-cell.selected {
  outline: 2px solid #7ac48f;
  background: #e9f7ed;
}

/* Selected day column (green outline like selected cell) */
.production-table th.production-day.day-selected,
.production-table td.production-cell.day-selected {
  outline: 2px solid #7ac48f;
  outline-offset: -2px;
}

.production-assignment {
  display: inline-block;
  background: #eef2ff;
  padding: 4px 6px;
  border-radius: 4px;
  margin: 2px 4px 2px 0;
  font-size: 13px;
}

.production-assignment.selected {
  background: #cde9d5;
}

.production-empty {
  color: #888;
}

.production-sidebar {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 16px;
  max-height: calc(100% - 32px);
  overflow: auto;
  align-self: start;

  /* важно для grid + overflow */
  min-height: 0;
}

.production-sidebar-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.production-shift-group {
  display: inline-flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.production-sidebar .checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.production-sidebar .checkbox-inline input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.production-sidebar .checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.production-sidebar .checkbox-inline input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.production-shift-btn {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.production-shift-btn.active {
  border-color: #4f46e5;
  background: #eef2ff;
}

.production-shift-time {
  font-size: 11px;
  color: #6b7280;
  font-weight: 400;
  width: 80px;
}

.production-employee-list {
  max-height: 260px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  padding: 6px;
  border-radius: 4px;
  display: grid;
  gap: 6px;
}

.production-employee {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
}

.production-employee.active {
  border-color: #10b981;
  background: #ecfdf3;
}

.production-time-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.production-sidebar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Production schedule: визуальный фильтр */
.production-assignment.filtered-out {
  display: none;
}

#production-filter.active {
  filter: brightness(0.95);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.12);
}

.production-context-menu {
  position: absolute;
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.production-context-menu.open {
  display: flex;
}

.production-context-menu button {
  border: none;
  background: transparent;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.production-context-menu button:hover {
  background: #f3f4f6;
}

.production-empty-page {
  min-height: 200px;
}

.production-shifts-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.production-shifts-queue {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.production-shifts-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.production-shifts-queue h3 {
  margin: 0;
  font-size: 16px;
}

.production-shifts-queue-toggle {
  font-size: 12px;
  font-weight: 600;
  gap: 4px;
}

.production-shifts-queue-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.production-shifts-queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.production-shifts-card-btn {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.production-shifts-card-btn.active {
  border-color: #4f46e5;
  background: #eef2ff;
}

.production-shifts-card-title {
  font-weight: 600;
}

.production-shifts-table-wrapper {
  overflow-x: auto;
}

.production-shifts-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 680px;
}

.production-shifts-table th,
.production-shifts-table td {
  border: 1px solid #ddd;
  padding: 8px;
  vertical-align: top;
}

.production-shifts-area {
  width: 200px;
  background: #f7f7f7;
}

.production-shifts-shift-btn {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.production-shifts-shift-btn.active {
  border-color: #4f46e5;
  background: #eef2ff;
}

.production-shift-meta {
  font-size: 12px;
  color: #555;
  margin-bottom: 6px;
}

.production-shift-ops {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.production-shift-task {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
}

.production-shift-task-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.production-shift-task-name {
  font-weight: 600;
}

.production-shift-task-card {
  font-size: 12px;
  color: #6b7280;
}

.production-shift-remove {
  border: none;
  background: transparent;
  color: #ef4444;
  cursor: pointer;
  font-size: 14px;
}

.production-shift-plan-content {
  max-width: 640px;
}

.production-shift-plan-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.production-shift-plan-label {
  font-size: 12px;
  text-transform: uppercase;
  color: #6b7280;
  letter-spacing: 0.04em;
}

.production-shift-plan-ops {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.production-shift-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.production-shift-label {
  font-weight: 600;
}

.area-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.area-reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.area-reorder button {
  width: 20px;
  height: 18px;
  padding: 0;
  font-size: 12px;
  line-height: 16px;
}

.area-reorder button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#production-editor-toggle.active {
  background-color: #2563eb;
  color: #fff;
}

/* Режим отдельной страницы МК (workorders/archive) */
body.page-wo-mode main {
  display: block;
}

body.page-wo-mode #page-root {
  display: block;
  padding: 16px 12px 24px;
  max-width: 1200px;
  width: min(1200px, 100%);
  margin: 0 auto;
}

@media (min-width: 1024px) {
  body.page-wo-mode #page-root {
    max-width: none;
    width: 100%;
  }
}

/* /production/shifts: просмотр карты в левой колонке */
.production-shifts-cardview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.production-shifts-cardview-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.production-shifts-opslist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  padding-right: 4px;
}

.production-shifts-op {
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.production-shifts-op.planned {
  border-color: rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.12);
}

.production-shift-board-queue .production-shifts-op.in-shift {
  background: #fff;
}

.production-shift-board-queue .production-shifts-op.out-of-shift {
  background: #f3f4f6;
}

.production-shifts-op-name {
  font-weight: 600;
}

.production-shifts-op-meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
}

/* /production/shifts: подсветка операций выбранной/открытой карты в календаре */
.production-shift-task.focus {
  background: rgba(16, 185, 129, 0.12); /* мягкий светло-зелёный */
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: 8px;
}

/* /production/shifts: ячейка календаря для абсолютных меток */
.production-shifts-cell {
  position: relative;
}

/* /production/shifts: процент загрузки (как по стилю "Люди") */
.production-shifts-load {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 12px;
  line-height: 12px;
  font-weight: 500;
  opacity: 0.75;
  pointer-events: none;
}

/* /production/shifts: доска смен */
.production-shift-board-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.production-shift-board-table-wrapper {
  overflow-x: auto;
}

.production-shift-board-queue {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.production-shift-board-queue h3 {
  margin: 0;
  font-size: 16px;
}

.production-shift-board-queue-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.production-shift-board-queue-card {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
}

.production-shift-board-queue-title {
  font-weight: 600;
}

.production-shift-board-queue-ops {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.production-shift-board-op {
  padding: 4px 6px;
  border-radius: 4px;
  background: #f8fafc;
}

.production-shift-board-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
}

.production-shift-board-table th,
.production-shift-board-table td {
  border: 1px solid #ddd;
  padding: 8px;
  vertical-align: top;
}

.production-shift-board-area {
  width: 200px;
  background: #f7f7f7;
}

.production-shift-board-head {
  background: #fff;
  position: relative;
  min-width: 220px;
}

.production-shift-board-head.shift-open {
  outline: 2px solid rgba(16, 185, 129, 0.7);
  outline-offset: -2px;
}

.production-shift-board-head.selected .production-shift-board-header {
  background: rgba(59, 130, 246, 0.08);
  border-radius: 8px;
}

.production-shift-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.production-shifts-nav {
  border: 1px solid #aebfff;
  background: linear-gradient(180deg, #f5f7ff 0%, #e4eaff 100%);
  color: #1f3b8f;
  cursor: pointer;
  padding: 6px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.production-shift-board-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
  text-align: center;
}

.production-shift-board-date {
  font-size: 12px;
  text-transform: uppercase;
  color: #555;
}

.production-shift-board-label {
  font-weight: 600;
}

.production-shift-board-time {
  font-size: 12px;
  color: #6b7280;
}

.production-shift-board-status {
  font-size: 12px;
  color: #6b7280;
}

.production-shift-board-status.status-not-started {
  color: #6b7280;
}

.production-shift-board-status.status-in-progress {
  color: #2563eb;
}

.production-shift-board-status.status-completed {
  color: #b45309;
}

.production-shift-board-status.status-fixed {
  color: #7f1d1d;
}

.production-shift-board-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.production-shift-board-cell {
  min-width: 220px;
}

.production-shift-board-cell.shift-open {
  outline: 2px solid rgba(16, 185, 129, 0.5);
  outline-offset: -2px;
}

.production-shift-board-meta {
  font-size: 12px;
  color: #555;
  margin-bottom: 6px;
}

.production-shift-board-employees {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  margin-bottom: 6px;
}

.production-shift-board-card {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
  margin-bottom: 6px;
}

.production-shift-board-card-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.production-shift-board-card ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.production-shift-log-content {
  max-width: 720px;
}

.production-shift-log-meta {
  font-weight: 600;
  margin-bottom: 10px;
}

.production-shift-log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
}

.production-shift-log-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 12px;
}

.production-shift-log-controls .input {
  width: 280px;
  max-width: 45%;
}

.production-shift-log-section {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  background: #fafafa;
}

.production-shift-log-section-title {
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.production-shift-log-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.production-shift-log-entry {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.production-shift-log-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.production-shift-log-entry .production-shift-log-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.production-shift-log-entry .production-shift-log-icon {
  width: 18px;
  text-align: center;
}

.production-shift-log-agg-list {
  margin: 6px 0 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.production-shift-plan-part {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin-top: 12px;
  padding-top: 12px;
}

.production-shift-plan-part .row {
  font-size: 13px;
  margin-bottom: 4px;
}

.production-shift-task-minutes {
  color: #6b7280;
  font-size: 12px;
}

.production-shift-plan-context {
  margin-top: 6px;
  font-size: 13px;
  color: #8a93a6;
}

.production-shift-plan-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.production-shift-plan-left,
.production-shift-plan-right {
  min-width: 0;
}

.production-shift-plan-left-header {
  display: grid;
  grid-template-columns: 1fr 110px 100px;
  gap: 10px;
  padding: 8px 10px;
  font-size: 13px;
  color: #8a93a6;
  border: 1px solid #e6e9f0;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: #fafbff;
}

.production-shift-plan-ops {
  border: 1px solid #e6e9f0;
  border-radius: 0 0 10px 10px;
  overflow: hidden;
  max-height: 340px;
  overflow-y: auto;
  background: #fff;
}

.psp-op-row {
  display: grid;
  grid-template-columns: 1fr 110px 100px;
  gap: 10px;
  padding: 10px 10px;
  border-top: 1px solid #eef1f6;
  cursor: pointer;
  user-select: none;
}

.psp-op-row:first-child {
  border-top: none;
}

.psp-op-row:hover {
  background: #f6f8ff;
}

.psp-op-row.selected {
  background: #eaf2ff;
}

.psp-op-name {
  min-width: 0;
  font-weight: 600;
  color: #1f2430;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.psp-op-remain {
  color: #1f2430;
  white-space: nowrap;
}

.psp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.psp-badge.planned {
  background: #4caf50;
  color: #fff;
}

.psp-badge.partial {
  background: #f59e0b;
  color: #fff;
}

.psp-badge.not {
  background: #d1d5db;
  color: #374151;
}

.production-shift-plan-part {
  border: 1px solid #e6e9f0;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.psp-right-title {
  font-size: 16px;
  font-weight: 700;
  color: #1f2430;
  margin-bottom: 8px;
}

.psp-right-meta {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.45;
  margin-bottom: 10px;
}

.psp-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}

.psp-stepper-btn {
  width: 34px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid #e6e9f0;
  background: #f3f4f6;
  cursor: pointer;
}

.psp-stepper-input {
  width: 86px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid #e6e9f0;
  padding: 0 10px;
}

.psp-fill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #e6e9f0;
  background: #f3f4f6;
  cursor: pointer;
  font-weight: 600;
}

.psp-fill-note {
  margin-top: 6px;
  font-size: 13px;
  color: #6b7280;
}

.psp-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.psp-th {
  text-align: left;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  font-size: 13px;
  color: #8a93a6;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.psp-th:hover {
  color: #6b7280;
}

.psp-th .psp-sort {
  font-size: 12px;
  color: #9aa3b2;
}

.psp-th.active {
  color: #374151;
  font-weight: 700;
}

/* Bigger modal for shift plan */
#production-shift-plan-modal .modal-content {
  width: 92vw;
  max-width: 1320px;
  border-radius: 12px;
}

#production-shift-plan-modal .modal-body {
  max-height: 78vh;
  overflow: auto;
}

/* Operations → Allowed areas */
.op-areas-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.op-areas-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.op-area-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.10);
  line-height: 1.2;
}

.op-areas-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.op-areas-picker {
  max-width: 260px;
}

.op-areas-picker.hidden {
  display: none;
}

/* make + / - compact inside areas */
.op-area-add-toggle,
.op-area-remove {
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 20px;
  border-radius: 6px;
}

th.th-sortable {
  cursor: pointer;
  user-select: none;
}

th.th-sortable.active {
  font-weight: 700;
}

th .th-sort-ind {
  font-size: 12px;
  opacity: 0.9;
}

/* ===== Premium SPA Loading ===== */
.top-progress {
  position: fixed;
  left: 0;
  top: 0;
  height: 3px;
  width: 0%;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.85);
  transition: width 180ms ease;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}
.top-progress.is-hidden {
  display: none;
}

/* Skeleton */
.skel {
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
}
.skel::after {
  content: '';
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
  animation: skel-shimmer 1.1s infinite;
}
@keyframes skel-shimmer {
  0% {
    left: -40%;
  }
  100% {
    left: 110%;
  }
}

.skel-row {
  height: 14px;
  margin: 10px 0;
}
.skel-row.h20 {
  height: 20px;
}
.skel-row.h28 {
  height: 28px;
}
.skel-row.h36 {
  height: 36px;
}
.skel-row.w25 {
  width: 25%;
}
.skel-row.w40 {
  width: 40%;
}
.skel-row.w55 {
  width: 55%;
}
.skel-row.w70 {
  width: 70%;
}
.skel-row.w90 {
  width: 90%;
}

.skel-block {
  height: 120px;
}
.skel-table {
  height: 280px;
  border-radius: 14px;
}

/* ===== Premium Skeleton Overlay (НЕ затирает DOM страницы) ===== */
.spa-skeleton-host {
  position: relative; /* overlay позиционируется внутри секции */
}

.spa-skeleton-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  padding: 14px;
  background: rgba(0,0,0,0.08);
  backdrop-filter: blur(1px);
}
