/* ===== CHZ Web App Styles ===== */

:root {
  --sidebar-width: 248px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #3b82f6;
  --sidebar-hover: #334155;
  --surface: #ffffff;
  --surface-border: #dbe4f0;
  --surface-muted: #64748b;
}

body {
  font-size: 14px;
  background: #f1f5f9;
}

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.login-logo {
  font-size: 3rem;
  color: #3b82f6;
  margin-bottom: 0.5rem;
}

/* ===== SIDEBAR ===== */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid #334155;
}

.sidebar-context-card {
  margin: 0.85rem 0.85rem 0.65rem;
  padding: 0.85rem;
  border: 1px solid #334155;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.35);
}

.sidebar-context-line {
  display: grid;
  gap: 0.15rem;
  margin-bottom: 0.55rem;
}

.sidebar-context-line:last-of-type {
  margin-bottom: 0;
}

.sidebar-context-label {
  color: #94a3b8;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 0.72rem 1rem;
  margin: 0 0.75rem 0.35rem;
  border-radius: 12px;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}

#sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

#sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid #334155;
}

/* ===== MAIN CONTENT ===== */
#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 1rem 1.25rem 1.25rem;
}

.section-toolbar {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  box-shadow: 0 6px 30px rgba(15, 23, 42, 0.05);
}

.section-eyebrow {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--surface-muted);
  margin-bottom: 0.35rem;
}

.section-toolbar {
  padding: 0.8rem 1rem;
  margin-bottom: 0.85rem;
}

.section-toolbar__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.section-title {
  margin: 0;
  color: #0f172a;
  font-size: 1.35rem;
  font-weight: 700;
}

.return-scan-list {
  display: grid;
  gap: 0.65rem;
}

.return-scan-item {
  padding: 0.65rem;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  background: #fff;
}

.return-scan-item--error {
  border-color: #f1aeb5;
  background: #fff5f5;
}

.section-description {
  color: var(--surface-muted);
  max-width: 900px;
  font-size: 0.88rem;
}

.section-tab-groups {
  display: grid;
  gap: 0.9rem;
}

.section-tab-group {
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
}

.section-tab-group__title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #334155;
}

.section-tab-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

.section-tab {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1e293b;
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  font-size: 0.88rem;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
}

.section-tab:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.section-tab.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.section-tab.is-disabled,
.section-tab:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: #f8fafc;
  color: #64748b;
}

.section-toolbar.section-toolbar--compact {
  padding: 0.7rem 0.9rem;
}

.section-toolbar.section-toolbar--compact .section-toolbar__head {
  margin-bottom: 0.5rem;
}

.section-toolbar.section-toolbar--compact .section-description {
  margin-top: 0.1rem;
}

.section-toolbar.section-toolbar--compact .section-tab-groups {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 1rem;
}

/* ===== STAT CARDS ===== */
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.25rem;
}

/* ===== DROPZONE ===== */
.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 10px;
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

/* ===== UPLOAD RESULTS ===== */
.upload-result {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-left: 4px solid #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.upload-result.accepted { border-left-color: #22c55e; }
.upload-result.accepted-partial { border-left-color: #0ea5e9; }
.upload-result.already-loaded { border-left-color: #64748b; }
.upload-result.needs-product { border-left-color: #f59e0b; }
.upload-result.error { border-left-color: #ef4444; }
.upload-result.uploading { border-left-color: #3b82f6; }

.upload-result__body {
  min-width: 0;
}

.upload-result__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.upload-result__status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.16rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #1e293b;
}

.upload-result.accepted .upload-result__status {
  background: #dcfce7;
  color: #166534;
}

.upload-result.accepted-partial .upload-result__status {
  background: #e0f2fe;
  color: #075985;
}

.upload-result.already-loaded .upload-result__status {
  background: #e5e7eb;
  color: #374151;
}

.upload-result.needs-product .upload-result__status {
  background: #fef3c7;
  color: #92400e;
}

.upload-result.error .upload-result__status {
  background: #fee2e2;
  color: #b91c1c;
}

.upload-meta {
  margin-top: 0.18rem;
}

.upload-batch-summary {
  background: #fff;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

.upload-batch-summary__title {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.45rem;
}

.upload-batch-summary__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem;
}

.upload-batch-summary__item {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  background: #f8fafc;
}

.upload-batch-summary__label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0.2rem;
}

/* ===== TABLES ===== */
.table th {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom-width: 1px;
}

.table td {
  vertical-align: middle;
}

tr.low-stock td {
  background: #fff5f5 !important;
  color: #b91c1c;
}

/* ===== TOASTS ===== */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast-msg {
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  pointer-events: all;
  animation: slideIn 0.25s ease;
}

.toast-msg.success { background: #16a34a; }
.toast-msg.error { background: #dc2626; }
.toast-msg.warning { background: #d97706; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== PRODUCT PICKER ===== */
#pick-product-list .list-group-item {
  cursor: pointer;
}
#pick-product-list .list-group-item.active {
  background: #3b82f6;
  border-color: #3b82f6;
}

/* ===== ISSUE PAGE ===== */
.issue-product-option {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  margin-bottom: 0.25rem;
  transition: background 0.15s;
}

.issue-product-option:hover {
  background: #f1f5f9;
}

.issue-product-option.selected {
  background: #eff6ff;
  border-color: #3b82f6;
}

.issue-last-issued {
  border: 1px solid #dbeafe;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.08);
}

.issue-last-issued__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.issue-last-issued__eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.issue-last-issued__details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.issue-detail-chip {
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: #f8fafc;
}

.issue-detail-chip__label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.2rem;
}

.issue-last-issued__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.issue-last-issued__actions .btn-lg {
  min-width: 210px;
}

.print-confirm-modal {
  border-radius: 20px;
  border: 1px solid #dbe4f0;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);
}

.print-confirm-modal .modal-body {
  padding: 1.6rem;
}

.print-confirm-modal__icon {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 1.9rem;
  margin-bottom: 1rem;
}

.print-confirm-modal__title {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
}

.print-confirm-modal__text {
  margin: 0 0 1rem;
  color: #475569;
}

.print-confirm-modal__details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.1rem;
}

.print-confirm-modal__chip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
}

.print-confirm-modal__chip span {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.2rem;
}

.print-confirm-modal__chip strong {
  color: #0f172a;
}

.print-confirm-modal__actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.print-confirm-modal__actions .btn {
  min-height: 64px;
  font-weight: 700;
}

.issue-print-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.83rem;
  background: #e2e8f0;
  color: #1e293b;
}

.issue-print-status-badge.is-issued {
  background: #dbeafe;
  color: #1d4ed8;
}

.issue-print-status-badge.is-printed {
  background: #dcfce7;
  color: #166534;
}

.issue-print-status-badge.is-not-printed {
  background: #fee2e2;
  color: #b91c1c;
}

.issue-print-status-badge.is-reprinted {
  background: #ede9fe;
  color: #6d28d9;
}

.issue-print-status-badge.is-returned {
  background: #e5e7eb;
  color: #374151;
}

.issue-history-file-link {
  font-weight: 600;
  color: #1d4ed8;
  text-decoration: none;
}

.issue-history-file-link:hover {
  text-decoration: underline;
}

.issue-history-menu {
  min-width: 230px;
}

.issue-history-menu .dropdown-item.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.table thead th.sortable-header {
  position: relative;
  cursor: pointer;
  user-select: none;
  padding-right: 1.55rem;
}

.table thead th.sortable-header::after {
  content: "↕";
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  color: #94a3b8;
}

.table thead th.sortable-header:hover {
  color: #1d4ed8;
}

.table thead th.sortable-header.is-sort-asc,
.table thead th.sortable-header.is-sort-desc {
  color: #1d4ed8;
}

.table thead th.sortable-header.is-sort-asc::after {
  content: "↑";
  color: #1d4ed8;
}

.table thead th.sortable-header.is-sort-desc::after {
  content: "↓";
  color: #1d4ed8;
}

.table thead th.is-sort-disabled {
  cursor: default;
}

.menu-note {
  padding: 0.4rem 1rem 0.1rem;
  color: #64748b;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.supply-dir-grid {
  display: grid;
  gap: 0.35rem;
}

.supply-dir-input {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 80px;
  gap: 0.5rem;
  align-items: center;
}

.supply-dir-input input {
  min-width: 0;
}

.source-hint-card {
  background: #fff;
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.source-hint-card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.source-hint-card__item {
  background: #f8fafc;
  border-radius: 12px;
  padding: 0.75rem;
}

.source-hint-card__item strong {
  display: block;
  margin-bottom: 0.35rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  #sidebar {
    transform: translateX(-220px);
    transition: transform 0.25s;
    width: 220px;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #main-content {
    margin-left: 0;
    padding: 1rem;
  }

  .stat-value { font-size: 1.5rem; }
  .section-toolbar.section-toolbar--compact .section-tab-groups {
    grid-template-columns: 1fr;
  }
  .print-confirm-modal__details,
  .print-confirm-modal__actions {
    grid-template-columns: 1fr;
  }
}

/* ===== BADGE STYLES ===== */
.badge-role-admin { background: #dc2626; }
.badge-role-chz_manager { background: #2563eb; }
.badge-role-packer { background: #16a34a; }

/* ===== PROGRESS BAR IN UPLOAD ===== */
.upload-progress {
  height: 4px;
  border-radius: 2px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 4px;
}
.upload-progress-bar {
  height: 100%;
  background: #3b82f6;
  transition: width 0.3s;
}

/* ===== BOX DISTRIBUTION GRID IN SUPPLY VIEW ===== */
.dist-city-cell {
  min-width: 140px;
}
.dist-box-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 2px;
  font-size: 11px;
  line-height: 1.3;
}
.dist-box-chip {
  background: #e2e8f0;
  border-radius: 4px;
  padding: 2px 5px;
  text-align: center;
  white-space: nowrap;
}
.dist-box-chip.is-extra {
  background: #fef9c3;
  color: #854d0e;
}
.dist-remain-chip {
  border-radius: 4px;
  padding: 3px 6px;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.dist-remain-chip.is-deficit  { background: #fee2e2; color: #991b1b; } /* не хватает */
.dist-remain-chip.is-exact    { background: #dcfce7; color: #166534; } /* точно      */
.dist-remain-chip.is-excess   { background: #fef3c7; color: #92400e; } /* лишнее     */
.dist-remain-chip.is-empty    { background: #f1f5f9; color: #94a3b8; } /* нет данных */
.dist-empty-slot {
  /* пустое место в 2-колоночной сетке */
}

/* Sticky header row for supply view table */
.supply-sticky-thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 3;
  box-shadow: 0 1px 0 #dee2e6;
}

/* Worker stats 4-badges row */
.worker-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
}
.worker-stat-badge .ws-label { color: #64748b; }
.worker-stat-badge .ws-val   { font-weight: 700; color: #1e293b; }
.worker-stat-badge .ws-pct   { font-size: 11px; color: #94a3b8; }
