/* Тема интерфейса (NIPI-013): светлое оформление по мотивам EnDocs — белые скруглённые карточки,
   светлая навигация с иконками, подчёркнутые вкладки, статусы-«пилюли». Цвета бренда сохранены. */
:root {
  --primary: #264796;
  --primary-dark: #1b3570;
  --primary-soft: #eaf0fb;
  --accent: #00abca;
  --bg: #f3f5fa;
  --surface: #ffffff;
  --text: #1f2a44;
  --muted: #7a8499;
  --border: #e7ebf2;
  --success: #27a86b;
  --warning: #f2a516;
  --danger: #e5484d;
  --violet: #8b5cf6;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(31, 42, 68, .06);
  --shadow-hover: 0 8px 28px rgba(31, 42, 68, .10);
}

body { background: var(--bg); color: var(--text); font-family: "Segoe UI", Inter, system-ui, -apple-system, Roboto, Arial, sans-serif; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Боковая панель ---------- */
.sidebar { background: var(--surface); color: var(--text); border-right: 1px solid var(--border); width: 256px; padding: 18px 12px; gap: 18px; }
.sidebar .brand { padding: 0 8px; }
.sidebar .brand-title { color: var(--primary); }
.sidebar .brand-sub { color: var(--muted); opacity: 1; }
.sidebar .brand-logo { box-shadow: 0 2px 8px rgba(38, 71, 150, .18); }
.nav { gap: 2px; overflow-y: auto; }
.nav-section { margin: 14px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: #a3abbd; }
.nav-section:first-child { margin-top: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; color: #4a556e; padding: 9px 12px; border-radius: 10px; font-weight: 500; font-size: 14px; }
.nav a .icon { color: #8d97ad; }
.nav a:hover { background: #f4f6fb; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.nav a.active .icon { color: var(--primary); }
.nav-divider { background: var(--border); margin: 12px 8px; }
.sidebar-footer { color: #a3abbd; }
.sidebar-footer a { color: inherit; }
.sidebar-footer a:hover { color: var(--primary); }

/* ---------- Верхняя панель ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 28px; gap: 20px; position: sticky; top: 0; z-index: 30; }
.topbar h2 { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 120px; }
.topbar-search { position: relative; flex: 1; max-width: 560px; margin-left: auto; }
.topbar-search > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar-search input { width: 100%; padding: 10px 14px 10px 38px; border-radius: 12px; border: 1px solid transparent; background: var(--bg); }
.topbar-search input:focus { background: #fff; border-color: var(--primary); outline: 3px solid rgba(38, 71, 150, .12); }
.topbar-panel { position: absolute; top: calc(100% + 8px); background: #fff; border-radius: 14px; box-shadow: 0 16px 40px rgba(31, 42, 68, .16);
  border: 1px solid var(--border); z-index: 40; max-height: 70vh; overflow-y: auto; }
.search-panel { left: 0; right: 0; padding: 8px; }
.search-group { padding: 6px 6px 2px; font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.search-item { display: block; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: var(--text); }
.search-item:hover, .search-item.focused { background: var(--primary-soft); }
.search-item small { display: block; color: var(--muted); font-size: 12px; }
.search-empty { padding: 14px; color: var(--muted); text-align: center; }
.topbar-bell { position: relative; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px;
  border: none; background: transparent; color: #5b6680; cursor: pointer; }
.icon-btn:hover { background: var(--bg); color: var(--primary); }
.icon-btn .icon { width: 20px; height: 20px; }
.bell-count { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.bell-panel { right: 0; width: 360px; padding: 8px; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 8px; font-weight: 700; }
.bell-item { display: flex; gap: 10px; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.bell-item:hover { background: var(--bg); }
.bell-item.unread { background: #f6f8ff; }
.bell-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.bell-item.read .dot { background: transparent; }
.bell-item small { display: block; color: var(--muted); }
.userbox { gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0; }

/* ---------- Карточки, кнопки, формы ---------- */
.content { padding: 24px 28px; gap: 20px; }
.card { border: none; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card-title { font-size: 17px; font-weight: 700; }
.btn { border-radius: 10px; padding: 9px 16px; font-weight: 600; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #1f8f5a; }
.btn-ghost { background: #fff; border-color: var(--border); }
.btn-sm { padding: 6px 12px; border-radius: 8px; }
input, select, textarea { border-radius: 10px; border-color: #dfe4ec; }
.modal-dialog { border-radius: 18px; padding: 24px 26px; }
.toast { border-radius: 12px; }

/* Таблицы */
th { background: #f8f9fc; color: #8a93a8; font-size: 11.5px; letter-spacing: .5px; border-bottom: 1px solid var(--border); }
th:first-child { border-top-left-radius: 10px; }
th:last-child { border-top-right-radius: 10px; }
td { border-bottom: 1px solid #eef1f6; }
tbody tr:hover td { background: #fafbfe; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
th.sorted-asc::after { content: ' ▲'; font-size: 9px; }
th.sorted-desc::after { content: ' ▼'; font-size: 9px; }

/* Статусы-«пилюли» */
.badge { border-radius: 999px; padding: 4px 10px; font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill .icon { width: 15px; height: 15px; }
.pill-violet { background: #f1ebff; color: #6d3fe0; }
.pill-green { background: #e5f7ee; color: #1d8a55; }
.pill-red { background: #fdecec; color: #c9363b; }
.pill-orange { background: #fff4df; color: #b57400; }
.pill-blue { background: var(--primary-soft); color: var(--primary); }
.pill-gray { background: #eef1f6; color: #5b6680; }

/* Вкладки с подчёркиванием */
.tabs-line { display: flex; gap: 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs-line button, .tabs-line a { background: none; border: none; padding: 10px 0; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs-line .active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs-line .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; background: #eef1f6; font-size: 11px; color: #5b6680; }
.tabs-line .active .count { background: var(--primary-soft); color: var(--primary); }

/* Переключатель вида (Таблица / Канбан / Календарь) */
.segmented { display: inline-flex; background: #f1f3f8; border-radius: 12px; padding: 4px; gap: 2px; }
.segmented button { display: inline-flex; align-items: center; gap: 7px; border: none; background: none; padding: 7px 14px; border-radius: 9px;
  font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; }
.segmented button.active { background: #fff; color: var(--text); box-shadow: 0 2px 6px rgba(31, 42, 68, .08); }

/* Существующие элементы: статистика и быстрые действия в новом стиле */
.stat { border-left: none; }
.quick-action { border: none; }
.quick-action:hover { box-shadow: var(--shadow-hover); }
.welcome { background: linear-gradient(120deg, #e6f6f9 0%, #eaf0fb 100%); }

/* Вход */
.login-view { background: radial-gradient(1200px 600px at 10% 10%, #dff3f8 0%, transparent 60%),
  radial-gradient(1000px 600px at 90% 90%, #e7ecfb 0%, transparent 60%), var(--bg); }
.login-card { border-radius: 22px; box-shadow: 0 24px 60px rgba(31, 42, 68, .14); }

@media (max-width: 900px) {
  .sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .nav-section { display: none; }
  .nav a span { white-space: nowrap; }
  .topbar { flex-wrap: wrap; padding: 10px 14px; position: static; }
  .topbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .userbox-text { display: none; }
  .bell-panel { width: min(360px, 92vw); }
}

/* Страница сотрудника (NIPI-013) */
.user-page { display: flex; flex-direction: column; gap: 18px; }
.user-page-head { display: flex; align-items: center; gap: 16px; }
.user-page-head h3 { font-size: 20px; }
.user-page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.user-page-main, .user-page-side { display: flex; flex-direction: column; gap: 18px; }
.user-page-actions { display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.extra-depts { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.extra-depts-head { display: flex; justify-content: space-between; }
.extra-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.extra-item { font-weight: 400; }
.extra-item.is-primary { opacity: .55; }
.extra-item.is-primary::after { content: 'основное'; font-size: 11px; color: var(--primary); margin-left: 6px; }
.dept-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.dept-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 500; }
.dept-chip button { border: none; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.role-info { margin-top: 10px; }
.role-perms { margin: 6px 0 8px; padding-left: 18px; font-size: 13.5px; }
.role-perms li { margin: 3px 0; }
.user-link { color: var(--text); text-decoration: none; }
.user-link:hover { color: var(--primary); }
@media (max-width: 1000px) { .user-page-grid { grid-template-columns: 1fr; } }
