/* Отдел кадров. Знакомые элементы, воздух, одно главное действие на экране.
   Своя черта — карточка как «личное дело»: ярлычок с ролью на корешке.
   Все цвета — переменные: встраиваемый блок получает их от системы-хозяина. */

:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --text: #18212b;
  --muted: #5d6876;
  --accent: #24507a;
  --accent-text: #ffffff;
  --border: #d8dee5;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --note-bg: #fff4e0;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --avatar-s: 46%;
  --avatar-l: 86%;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161b;
    --surface: #1a2027;
    --text: #e6eaee;
    --muted: #98a2ae;
    --accent: #8db4da;
    --accent-text: #0e1a26;
    --border: #2a323c;
    --danger: #f2b8b5;
    --danger-bg: #3a1f1d;
    --note-bg: #33291a;
    --avatar-s: 30%;
    --avatar-l: 30%;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12161b;
  --surface: #1a2027;
  --text: #e6eaee;
  --muted: #98a2ae;
  --accent: #8db4da;
  --accent-text: #0e1a26;
  --border: #2a323c;
  --danger: #f2b8b5;
  --danger-bg: #3a1f1d;
  --note-bg: #33291a;
  --avatar-s: 30%;
  --avatar-l: 30%;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 24px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.boot { padding: 48px 16px; text-align: center; color: var(--muted); }

/* Каркас */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--text); text-decoration: none; white-space: nowrap; }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab-active { color: var(--text); background: var(--bg); }
.me { margin-left: auto; display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.me-name { color: var(--text); text-decoration: none; }
.me form { margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.link-button:hover { color: var(--text); }

.content { max-width: 760px; margin: 0 auto; padding: 32px 24px 64px; }

.shell-embed { padding: 16px 16px 32px; }
.shell-embed .tabs { margin-bottom: 16px; }
.shell-embed .tab-active { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.shell-embed .content { padding: 0; max-width: none; }
.scope-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}
.scope-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* Заголовок раздела */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }

/* Кнопки и поля */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.08); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
input, select {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:disabled, select:disabled { background: var(--bg); color: var(--muted); }
.form-error { color: var(--danger); min-height: 0; font-size: 14px; }
.form-error:empty { display: none; }

/* Списки */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); text-decoration: none; min-height: 64px; }
a.row:hover { background: var(--bg); }
.row-muted { opacity: 0.6; }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.row-note { color: var(--muted); font-size: 13px; }
.list-editable > li { display: flex; align-items: center; }
.list-editable .row { flex: 1; }
.icon-button {
  width: 40px; height: 40px; margin-right: 8px;
  border: 0; border-radius: 8px; background: none; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.icon-button:hover { background: var(--bg); color: var(--danger); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* Ярлычок роли — маленький корешок папки */
.role-tab {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px 2px;
  border: 1px solid var(--border);
  border-bottom-color: transparent;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  background: linear-gradient(var(--surface), var(--bg));
  white-space: nowrap;
}

.avatar {
  --hue: 210;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: hsl(var(--hue) var(--avatar-s) var(--avatar-l));
  color: hsl(var(--hue) 45% 28%);
  font-weight: 600;
  font-size: 14px;
}
:root[data-theme="dark"] .avatar { color: hsl(var(--hue) 60% 85%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--hue) 60% 85%); } }
.avatar-large { width: 64px; height: 64px; font-size: 22px; }

/* Карточка — «личное дело» */
.back { display: inline-block; margin-bottom: 16px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }
.file-head { position: relative; margin-top: 18px; margin-bottom: 16px; }
.file-tab {
  position: absolute;
  top: -27px;
  left: 20px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}
.file-head-body {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.file-head-body .muted { margin-top: 2px; }

.section { margin-top: 24px; }
.card-form { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.section > .muted { margin-bottom: 12px; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; border-radius: var(--radius); background: var(--note-bg);
}
.banner-danger { background: var(--danger-bg); color: var(--danger); }

.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row select:first-child { flex: 2; }
.add-row select { flex: 1; }

.history-box summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.history { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 14px; }
.history-meta { color: var(--muted); font-size: 13px; }

/* Окна */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  color: var(--text);
}
.dialog::backdrop { background: rgb(10 15 20 / 0.45); }
.dialog form, .dialog { display: flex; flex-direction: column; gap: 16px; }
.dialog:not([open]) { display: none; }
.dialog h2 { margin: 0; font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.password-row { display: flex; gap: 8px; align-items: center; }
.password {
  flex: 1; padding: 10px 12px; border-radius: 8px; background: var(--bg);
  font: 16px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.04em; user-select: all; word-break: break-all;
}

/* Сообщения и уведомления */
.invite { max-width: 400px; margin: 64px auto; padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.invite h1 { margin: 0; font-size: 24px; }
.invite-form { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.invite-form .btn { align-self: flex-start; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.message { max-width: 420px; margin: 64px auto; padding: 0 16px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 10; width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgb(0 0 0 / 0.18); }
.toast-error { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; }
  .tabs { order: 3; width: 100%; }
  .content { padding: 24px 16px 48px; }
  .grid { grid-template-columns: 1fr; }
  .page-head { flex-wrap: wrap; }
  .row-note, .role-tab { display: none; }
  .add-row { flex-wrap: wrap; }
  .add-row select:first-child { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
