:root {
  --bg: #f1f5f9;
  --container-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --primary: #4361ee;
  --primary-light: #eef0ff;
  --danger: #e63946;
  --success: #2a9d8f;
  --border: #e2e8f0;
  --shadow: 0 4px 12px rgba(0,0,0,0.05);
  --radius: 12px;
  --whatsapp: #25D366;
  --telegram: #0088cc;
  --website: #0ea5e9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --container-bg: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --primary: #818cf8;
    --primary-light: #2e3a5c;
    --border: #334155;
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 2rem 1rem;
  transition: background 0.3s, color 0.3s;
}

.container {
  max-width: 960px;  /* немного расширил для карточек */
  margin: 0 auto;
  background: var(--container-bg);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: fadeInUp 0.5s ease;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
a:hover { text-decoration: underline; }

h1 { font-size: 1.8rem; margin-bottom: 1.5rem; }
h3 { margin: 1.5rem 0 0.5rem; color: var(--primary); }

.btn {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 0.95rem;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  margin: 0.25rem;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.1);
  text-decoration: none;
}
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.85rem; white-space: nowrap; }

.btn-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-telegram { background: var(--telegram); color: #fff; }
.btn-website { background: var(--website); color: #fff; }
.btn-social { background: var(--primary); color: #fff; }

/* ====== Сетка карточек сотрудников ====== */
.employee-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.employee-card {
  background: var(--container-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}
.employee-card:hover {
  transform: translateY(-3px);
}

.employee-card-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.employee-name {
  font-size: 1.2rem;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.employee-position {
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.employee-email,
.employee-org {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.employee-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.8rem;
}

/* Адаптация карточек на маленьких экранах — один столбец */
@media (max-width: 600px) {
  .employee-cards {
    grid-template-columns: 1fr;
  }
  body { padding: 1rem 0.5rem; }
  .container { padding: 1.25rem; border-radius: 12px; }
  h1 { font-size: 1.5rem; }
}

/* ====== Остальные стили (карточка просмотра, формы и т.д.) ====== */
.card {
  background: var(--container-bg);
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  margin: 1.5rem 0;
  transition: transform 0.3s;
}
.animated-card { animation: fadeInUp 0.6s ease; }
.photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--primary-light);
  margin-bottom: 1rem;
}
.placeholder-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--primary-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1rem;
}
.org-logo img {
  max-height: 60px;
  margin-bottom: 0.5rem;
}
.org-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.card h2 {
  font-size: 1.6rem;
  margin-bottom: 0.3rem;
}
.position {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 1.2rem;
}
.info {
  text-align: left;
  margin: 1.5rem 0;
}
.info .field {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 100px;
}
.social-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.2rem;
}
.qr-section {
  margin: 2rem 0 1rem;
  text-align: center;
}
#qrcode { display: inline-block; margin: 1rem auto; }
.share-link {
  display: block;
  background: var(--primary-light);
  padding: 0.8rem;
  border-radius: 8px;
  word-break: break-all;
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--text);
}
.admin-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Формы */
.form-group { margin-bottom: 1.2rem; }
label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: 0.2s;
  background: var(--container-bg);
  color: var(--text);
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,0.2);
}
input[type="file"] { padding: 0.5rem 0; }

/* Анимации */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Шапка с аватаркой */
.header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 0 1rem 0;
  position: relative;
}
.user-menu {
  position: relative;
  display: inline-block;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--primary-light);
  transition: box-shadow 0.2s;
}
.user-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
}
.user-avatar:hover,
.user-avatar-placeholder:hover {
  box-shadow: 0 0 0 3px rgba(67,97,238,0.3);
}
.dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--container-bg);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  min-width: 180px;
  z-index: 1000;
  overflow: hidden;
}
.dropdown.show {
  display: block;
  animation: fadeInUp 0.2s ease;
}
.dropdown a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s;
}
.dropdown a:hover {
  background: var(--primary-light);
  text-decoration: none;
}
.dropdown .divider {
  height: 1px;
  background: var(--border);
}

.success-msg {
  background: #d4edda;
  color: #155724;
  padding: 0.8rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.error {
  background: #f8d7da;
  color: #721c24;
  padding: 0.8rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
/* Дерево отделов */
.dept-node {
  margin-bottom: 0.5rem;
}
.dept-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dept-children {
  margin-top: 0.3rem;
}
.dept-employees {
  list-style: none;
  padding-left: 1.5rem;
  margin: 0.3rem 0;
  font-size: 0.9rem;
}