*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222536;
  --border: #2e3148;
  --accent: #5b6ef5;
  --accent-hover: #7080ff;
  --danger: #e05252;
  --success: #3ecf8e;
  --warning: #f5a623;
  --text: #e2e4f0;
  --text-muted: #6b7194;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo { font-weight: 700; font-size: 18px; letter-spacing: 1px; color: var(--accent); }

nav { display: flex; gap: 4px; }
nav button {
  background: none; border: none; color: var(--text-muted);
  padding: 6px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; transition: all .15s;
}
nav button:hover { color: var(--text); background: var(--surface2); }
nav button.active { color: var(--accent); background: rgba(91,110,245,.15); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }

.toolbar { display: flex; gap: 12px; margin-bottom: 20px; }
.toolbar input[type=text] {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 8px 14px; border-radius: var(--radius);
  font-size: 14px; outline: none; transition: border-color .15s;
}
.toolbar input[type=text]:focus { border-color: var(--accent); }

button { cursor: pointer; font-size: 13px; border: none; border-radius: 8px; transition: all .15s; }

.btn-primary { background: var(--accent); color: #fff; padding: 8px 18px; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--surface2); color: var(--text); padding: 8px 18px; }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-secondary:disabled { opacity: .4; cursor: not-allowed; }
.btn-icon { background: none; color: var(--text-muted); padding: 4px 7px; font-size: 14px; }
.btn-icon:hover { color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); }
.btn-icon.accent { color: var(--accent); }
.btn-icon.accent:hover { color: var(--accent-hover); }
.btn-del { background: none; color: var(--text-muted); padding: 6px 9px; }
.btn-del:hover { color: var(--danger); background: rgba(224,82,82,.1); }
.btn-refresh { background: none; color: var(--text-muted); padding: 4px 8px; font-size: 16px; }
.btn-refresh:hover { color: var(--text); }

.empty { text-align: center; padding: 80px 20px; color: var(--text-muted); }

/* PROJECT GRID */
.project-grid { display: flex; flex-direction: column; gap: 10px; }

.project-card {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s;
}
.project-card:hover { border-color: rgba(91,110,245,.4); }

/* Thumbnail */
.proj-thumb {
  width: 120px;
  height: 120px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
}
.proj-thumb img { width: 100%; height: 100%; object-fit: cover; }
.no-thumb {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Body */
.proj-body { padding: 14px 16px; min-width: 0; }

.proj-name-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.proj-name { font-weight: 700; font-size: 16px; }
.proj-name-input {
  font-weight: 700; font-size: 16px; background: var(--surface2);
  border: 1px solid var(--accent); color: var(--text); border-radius: 6px;
  padding: 2px 8px; outline: none; width: 260px;
}

.proj-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tag {
  background: rgba(91,110,245,.15); color: var(--accent);
  padding: 2px 8px; border-radius: 4px; font-size: 11px;
}

/* Meta row: stock + barcode */
.proj-meta-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted); margin-bottom: 10px;
}
.meta-item { cursor: pointer; }
.meta-item b { color: var(--text); font-weight: 600; }
.meta-sep { color: var(--border); }
.meta-input {
  background: var(--surface2); border: 1px solid var(--accent); color: var(--text);
  border-radius: 6px; padding: 1px 8px; font-size: 12px; outline: none; width: 110px;
}
.btn-print-barcode {
  background: var(--surface2); color: var(--text); padding: 3px 10px;
  border-radius: 6px; font-size: 11px; font-weight: 600;
}
.btn-print-barcode:hover:not(:disabled) { background: var(--border); }
.btn-print-barcode:disabled { opacity: .4; cursor: not-allowed; }

/* Barcode modal */
.modal-divider { height: 1px; background: var(--border); margin: 18px 0; }
.barcode-code-actions { margin-top: -4px; margin-bottom: 4px; }
.barcode-file-section { display: flex; flex-direction: column; gap: 10px; }
.barcode-file-title { font-size: 12px; color: var(--text-muted); }
.barcode-file-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface2); border-radius: 8px; padding: 8px 12px; font-size: 13px;
}
.barcode-file-row a { color: var(--accent); }
.btn-file-label { align-self: flex-start; cursor: pointer; }

/* Marketplace links */
.proj-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.link-badge {
  background: rgba(62,207,142,.12); color: var(--success);
  padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 600;
  text-decoration: none; transition: background .15s;
}
.link-badge:hover { background: rgba(62,207,142,.22); }
.btn-links {
  background: none; color: var(--accent); font-size: 11px;
  padding: 2px 6px; border-radius: 12px; border: 1px dashed var(--border);
}
.btn-links:hover { color: var(--accent-hover); border-color: var(--accent); }

.links-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 220px; overflow-y: auto; }
.link-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border-radius: 8px; padding: 8px 10px; font-size: 12px;
}
.link-label { font-weight: 700; flex-shrink: 0; }
.link-url {
  flex: 1; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-decoration: none;
}
.link-url:hover { text-decoration: underline; }

/* File rows inside project */
.proj-files { display: flex; flex-direction: column; gap: 5px; }
.proj-file-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-muted);
}
.file-orig {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.file-target {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  flex-shrink: 0; text-transform: uppercase;
}
.file-target.p1s { background: rgba(91,110,245,.2); color: #8fa0ff; }
.file-target.a1  { background: rgba(62,207,142,.15); color: var(--success); }
.file-target.generic { background: var(--surface2); color: var(--text-muted); }
.file-size { flex-shrink: 0; }

.file-rename-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--accent);
  color: var(--text); border-radius: 6px; padding: 1px 8px;
  font-size: 12px; outline: none; min-width: 0;
}

.btn-add-file {
  background: none; color: var(--accent); font-size: 12px;
  padding: 4px 0; text-align: left; margin-top: 4px;
}
.btn-add-file:hover { color: var(--accent-hover); }

/* Actions column */
.proj-actions {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px 14px;
  border-left: 1px solid var(--border);
  min-width: 48px;
}

/* DROP ZONE */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  margin: 10px 0;
  font-size: 13px;
}
.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  background: rgba(91,110,245,.07);
  color: var(--text);
}

/* UPLOAD PROGRESS */
.upload-progress {
  background: var(--surface2); border-radius: var(--radius);
  padding: 10px 14px; position: relative; overflow: hidden;
  font-size: 12px; color: var(--text-muted);
}
.upload-progress .bar {
  position: absolute; inset: 0; background: rgba(91,110,245,.25); transition: width .3s;
}
.upload-progress span { position: relative; }

/* PRINTER GRID */
.printer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.printer-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.printer-card.online  { border-color: var(--success); }
.printer-card.printing { border-color: var(--accent); }
.printer-card.error   { border-color: var(--danger); }

.printer-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.printer-name { font-weight: 700; font-size: 16px; }
.printer-model { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.status-badge {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--surface2); color: var(--text-muted);
}
.status-badge.online   { background: rgba(62,207,142,.15); color: var(--success); }
.status-badge.printing { background: rgba(91,110,245,.15); color: var(--accent); }
.status-badge.error    { background: rgba(224,82,82,.15);  color: var(--danger); }

.temps { display: flex; gap: 20px; margin-bottom: 12px; }
.temp-item { display: flex; flex-direction: column; gap: 2px; }
.temp-label { font-size: 11px; color: var(--text-muted); }
.temp-val { font-size: 15px; font-weight: 600; }

.progress-block { margin-top: 10px; }
.progress-bar-wrap { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width .5s; }
.progress-label { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); }

/* MODAL */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; width: 440px; max-width: 95vw;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-file { color: var(--text-muted); margin-bottom: 16px; font-size: 13px; }
.hint { color: var(--text-muted); font-size: 12px; margin-bottom: 16px; line-height: 1.5; }

.modal label {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px; font-size: 12px; color: var(--text-muted);
}
.modal label input[type=text],
.modal label input[type=password],
.modal label input[type=date],
.modal label input[type=datetime-local],
.modal label select,
.modal label textarea {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 12px; border-radius: 8px;
  font-size: 14px; outline: none; transition: border-color .15s;
  font-family: inherit;
}
.modal label input:focus, .modal label select:focus, .modal label textarea:focus { border-color: var(--accent); }
.modal-textarea { resize: vertical; }

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

.modal-wide { width: 720px; max-height: 88vh; overflow-y: auto; }
.modal-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.modal-col { min-width: 0; }
@media (max-width: 760px) { .modal-cols { grid-template-columns: 1fr; } }

/* TOAST */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: 10px; font-weight: 600;
  z-index: 200; background: var(--surface2); border: 1px solid var(--border);
  max-width: 320px; pointer-events: none;
}
.toast.success { background: rgba(62,207,142,.15); border-color: var(--success); color: var(--success); }
.toast.error   { background: rgba(224,82,82,.15);  border-color: var(--danger);  color: var(--danger); }

/* AUTH SCREENS */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: 360px; max-width: 100%; display: flex; flex-direction: column; gap: 4px;
}
.auth-box .logo { margin-bottom: 8px; }
.auth-box h2 { font-size: 17px; margin-bottom: 14px; }
.auth-box label {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px; font-size: 12px; color: var(--text-muted);
}
.auth-box input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 9px 12px; border-radius: 8px;
  font-size: 14px; outline: none; transition: border-color .15s;
}
.auth-box input:focus { border-color: var(--accent); }
.auth-box .btn-primary { margin-top: 6px; width: 100%; padding: 10px; }
.auth-error { color: var(--danger); font-size: 12px; margin-bottom: 10px; }

/* HEADER USER */
.header-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); margin-left: auto; }
.role-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase;
  background: var(--surface2); color: var(--text-muted);
}
.role-badge.role-admin { background: rgba(224,82,82,.15); color: var(--danger); }
.role-badge.role-manager { background: rgba(91,110,245,.15); color: var(--accent); }
.role-badge.role-warehouse { background: rgba(62,207,142,.15); color: var(--success); }

/* KANBAN */
.new-column-input { max-width: 260px; flex: none; }
.kanban-board { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.kanban-column {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; width: 280px; flex-shrink: 0;
}
.kanban-col-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.kanban-col-title { font-weight: 700; font-size: 14px; flex: 1; cursor: pointer; }
.kanban-col-count {
  background: var(--surface2); color: var(--text-muted); font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 10px;
}
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 20px; }
.kanban-card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; cursor: grab; transition: border-color .15s;
}
.kanban-card:hover { border-color: rgba(91,110,245,.4); }
.kanban-card-title { font-size: 13px; margin-bottom: 6px; }
.kanban-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); }
.priority-badge { font-weight: 700; padding: 1px 7px; border-radius: 4px; }
.priority-badge.priority-low { background: rgba(107,113,148,.2); color: var(--text-muted); }
.priority-badge.priority-medium { background: rgba(245,166,35,.15); color: var(--warning); }
.priority-badge.priority-high { background: rgba(224,82,82,.15); color: var(--danger); }
.kanban-assignee { background: var(--surface); padding: 1px 7px; border-radius: 4px; }
.type-badge { background: rgba(91,110,245,.15); color: var(--accent); padding: 1px 7px; border-radius: 4px; font-weight: 600; }

.kanban-timer {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
  font-size: 14px; font-weight: 700; color: var(--text);
}
.kanban-timer.overdue { color: var(--danger); }
.modal-timer {
  margin: -8px 0 18px; padding: 10px 14px; border-top: none;
  background: var(--surface2); border-radius: 8px; font-size: 18px; text-align: center;
}

/* Юр. лица × маркетплейсы (card modal) */
.entity-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; margin-bottom: 4px; }
.entity-block { background: var(--surface2); border-radius: 8px; }
.entity-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; cursor: pointer; font-size: 12px;
}
.entity-row:hover { background: var(--border); border-radius: 8px; }
.entity-name { font-weight: 700; white-space: nowrap; }
.entity-mps { display: flex; gap: 6px; flex-wrap: wrap; }
.mp-badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 10px;
  background: var(--surface); color: var(--text-muted); text-decoration: none;
}
.mp-badge:not(.empty) { color: var(--accent); }
.mp-badge.verified { background: rgba(62,207,142,.15); color: var(--success); }
.entity-edit { padding: 10px 12px 12px; }
.entity-mp-field {
  display: flex; flex-direction: column; gap: 4px; margin-top: 8px; margin-bottom: 0;
  font-size: 11px; color: var(--text-muted);
}
.mp-field-row { display: flex; align-items: center; gap: 8px; }
.mp-input {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 5px 8px; border-radius: 6px; font-size: 12px; outline: none;
}
.mp-input:focus { border-color: var(--accent); }
.modal label.mp-verified {
  display: inline-flex; flex-direction: row; align-items: center; gap: 2px;
  margin-bottom: 0; font-size: 11px; white-space: nowrap; color: var(--text-muted);
}
.entity-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

.competitor-add-row { display: flex; gap: 6px; margin-bottom: 4px; }
.competitor-add-row .mp-input { background: var(--surface2); }

/* USERS */
.users-list { display: flex; flex-direction: column; gap: 8px; max-width: 480px; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px;
}
.user-name { flex: 1; font-weight: 600; }
