* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  padding: 20px;
}
#app {
  max-width: 1200px;
  margin: 0 auto;
}
.hidden {
  display: none !important;
}
#loginForm {
  max-width: 400px;
  margin: 80px auto;
  background: #fff;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
#loginForm h2 {
  text-align: center;
  margin-bottom: 20px;
}
.error-msg {
  color: #e74c3c;
  margin-top: 10px;
  text-align: center;
}

/* Dashboard */
#dashboard {
  background: #fff;
  border-radius: 12px;
  padding: 20px 30px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: center;
}
.dashboard-content {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
}
.sidebar {
  flex: 1 1 250px;
  min-width: 200px;
}
.main {
  flex: 3 1 600px;
}
.card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  border: 1px solid #e9ecef;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.tag-list, .link-list {
  list-style: none;
  padding: 0;
}
.tag-list li, .link-list li {
  padding: 8px 12px;
  background: #fff;
  margin-bottom: 6px;
  border-radius: 4px;
  border-left: 4px solid #3498db;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tag-list li > span {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.tag-list li > div {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
}
.tag-list li:hover, .link-list li:hover {
  background: #eef5ff;
}
.tag-list li.active {
  background: #d4e6ff;
  border-left-color: #e67e22;
}
.link-list li {
  border-left-color: #2ecc71;
}
.link-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.link-url {
  font-size: 12px;
  color: #555;
  word-break: break-all;
}
.tag-email {
  font-size: 12px;
  color: #777;
}

/* Кнопки */
.btn {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.2s;
  white-space: nowrap;
}
.btn-primary { background: #3498db; color: #fff; }
.btn-primary:hover { background: #2980b9; }
.btn-success { background: #2ecc71; color: #fff; }
.btn-success:hover { background: #27ae60; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-warning:hover { background: #e67e22; }
.btn-secondary { background: #95a5a6; color: #fff; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-sm { padding: 4px 8px; font-size: 12px; }

/* Модалки */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 30px;
  max-width: 800px;
  width: 95%;
  max-height: 90%;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  cursor: pointer;
}
.form-group {
  margin-bottom: 15px;
}
.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.qr-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}
.flex {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.text-center { text-align: center; }
.muted { color: #999; }

/* Статусы */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}
.status-ok {
  background: #d4edda;
  color: #155724;
}
.status-error {
  background: #f8d7da;
  color: #721c24;
}
.status-unknown {
  background: #e2e3e5;
  color: #383d41;
}
.link-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.mt-10 { margin-top: 10px; }

/* Редактор шаблона */
#templateEditor, #stubEditor {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  min-height: 300px;
  width: 100%;
  padding: 10px;
}

/* Alarm над тегом */
.alarm-badge-top {
  background: #dc3545;
  color: #fff;
  font-weight: bold;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  display: inline-block;
  margin-bottom: 2px;
}

/* Чекбоксы */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-group input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0;
  width: auto;
}
.checkbox-group label {
  margin: 0;
  white-space: nowrap;
  cursor: pointer;
}

/* Управление пользователями */
#usersList {
  max-height: 300px;
  overflow-y: auto;
}
#usersList div:hover {
  background: #f8f9fa;
}

/* Справка */
#helpModal .modal-content h4 {
  margin-top: 15px;
  margin-bottom: 5px;
}
#helpModal .modal-content ol {
  padding-left: 20px;
}
#helpModal .modal-content hr {
  margin: 15px 0;
}
/* Выпадающие меню */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-btn {
  cursor: pointer;
}
.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: #fff;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  border-radius: 4px;
  padding: 8px;
  z-index: 1000;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.dropdown.open .dropdown-content {
  display: flex;
}
.dropdown-content .btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  padding: 6px 12px;
  margin: 0;
}

#helpBtn {
  margin-left: auto;
}
#qrCodeContainer canvas,
#qrCodeContainer svg {
  max-width: 100%;
  height: auto;
}
/* Стили для редактора QR */
.qr-controls {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
}
.qr-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px 20px;
  align-items: center;
  margin-bottom: 10px;
}
.qr-row:last-child {
  margin-bottom: 0;
}
.qr-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.qr-control-group label {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
}
.qr-control-group input[type="color"] {
  width: 40px;
  height: 32px;
  padding: 2px;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  background: #fff;
}
.qr-control-group select {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
}
.qr-control-file input[type="file"] {
  font-size: 13px;
  padding: 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
.qr-control-checkbox {
  display: flex;
  align-items: center;
  gap: 5px;
}
.qr-control-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.qr-control-checkbox label {
  cursor: pointer;
  font-size: 14px;
}
@media (max-width: 600px) {
  .qr-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .qr-control-group {
    justify-content: space-between;
  }
}
#checkAllBtn {
  min-width: 220px; /* или точное значение, например 200px, подберите под свой макет */
  text-align: center;
  white-space: nowrap; /* текст не переносится */
  transition: background 0.3s ease; /* плавное изменение фона */
  font-size: 0.9em;
}
#helpBtn {
  background: #17a2b8;
  color: #fff;
  border-color: #17a2b8;
}
#helpBtn:hover {
  background: #138496;
  border-color: #117a8b;
}