/* ECMIT design tokens (ecmit-landing/docs/ECMIT_DESIGN.md): копия значений, не изобретать палитру. */
:root {
  --canvas: #f8fafc; --surface: #ffffff; --surface-muted: #f1f5f9; --border: #dbe2e8;
  --text: #0f172a; --text-muted: #475569;
  --accent: #087f68; --accent-hover: #066653; --on-accent: #ffffff; --accent-soft: #e5f5ef;
  --danger: #b91c1c; --warning: #92400e;
  --danger-soft: #fdecec; --warning-soft: #fdf3e1;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .03);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --canvas: #090d12; --surface: #111821; --surface-muted: #18212b; --border: #2b3946;
  --text: #e8edf3; --text-muted: #9aa7b5;
  --accent: #59dfb7; --accent-hover: #78e8c7; --on-accent: #092019; --accent-soft: #153029;
  --danger: #f3a9b0; --warning: #e5b75e;
  --danger-soft: #35181c; --warning-soft: #2e2410;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font: 14px/1.5 Inter, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-icon { width: 36px; padding: 0; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; height: 42px; }

.input, .select {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 9px; font: inherit;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.input::placeholder { color: var(--text-muted); opacity: .8; }
.input:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.select { padding-right: 28px; }
.input-icon { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.input-icon svg { position: absolute; left: 10px; top: 9px; color: var(--text-muted); pointer-events: none; }
.input-icon .input { padding-left: 34px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.field .hint { font-size: 12px; font-weight: 400; }
.form-error { min-height: 20px; font-size: 13px; color: var(--danger); }
.notice { padding: 10px 12px; border-radius: 9px; background: var(--accent-soft); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Чипы ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border);
}
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.solid { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip.warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.chip button { all: unset; cursor: pointer; display: inline-flex; margin-right: -4px; opacity: .7; }
.chip button:hover { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.brand-mark { border-radius: 8px; display: block; }
.brand-mark.lg { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 16px; }

/* ---------- Каркас приложения ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; text-decoration: none; color: var(--text); }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-group { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 9px;
  color: var(--text-muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-muted); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.me-text { min-width: 0; line-height: 1.25; }
.me-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 12px; color: var(--text-muted); }
.foot-actions { display: flex; }

.content { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.page-head p { margin-top: 2px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .select { width: auto; min-width: 160px; }
.toolbar .spacer { flex: 1; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted);
  letter-spacing: .02em; background: var(--surface-muted); border-bottom: 1px solid var(--border); white-space: nowrap;
}
th:first-child { border-top-left-radius: 13px; } th:last-child { border-top-right-radius: 13px; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--surface-muted); }
tr.off td { opacity: .6; }
.person { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.person b { font-weight: 500; display: block; }
.person small { color: var(--text-muted); font-size: 12px; }
.empty { padding: 48px 16px; text-align: center; color: var(--text-muted); }
.count { color: var(--text-muted); font-size: 13px; }

/* ---------- Уровни доступа ---------- */
.lvl { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; }
.lvl-admin { background: var(--accent); color: var(--on-accent); }
.lvl-readwrite { background: var(--accent-soft); color: var(--accent); }
.lvl-readonly { background: var(--surface-muted); color: var(--text); border: 1px solid var(--border); }
.lvl-none { color: var(--text-muted); }
.svc-dots { display: flex; gap: 4px; flex-wrap: wrap; max-width: 280px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-muted); border: 1px solid var(--border); }
.seg button {
  all: unset; box-sizing: border-box; cursor: pointer; padding: 4px 10px; border-radius: 7px; font-size: 12px;
  font-weight: 500; color: var(--text-muted); white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button[aria-pressed="true"][data-level="admin"] { background: var(--accent); color: var(--on-accent); }
.seg button[aria-pressed="true"][data-level="readwrite"] { background: var(--accent-soft); color: var(--accent); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

/* Матрица */
.matrix th, .matrix td { padding: 8px 10px; }
.matrix td:first-child, .matrix th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix th:first-child { background: var(--surface-muted); }
.matrix tr.sel td:first-child, .matrix tr.sel td { background: var(--accent-soft); }
.cell-select { height: 28px; padding: 0 20px 0 8px; font-size: 12px; border-radius: 7px; width: 108px; font-weight: 500;
  border: 1px solid var(--border); background-color: var(--surface); color: var(--text); }
.cell-select[data-level="admin"] { background-color: var(--accent); color: var(--on-accent); border-color: transparent; }
.cell-select[data-level="readwrite"] { background-color: var(--accent-soft); color: var(--accent); border-color: transparent; }
.cell-select[data-level="none"] { color: var(--text-muted); }
.bulk { position: sticky; bottom: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding: 12px 16px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--accent); box-shadow: var(--shadow-lg); }
.bulk .select { width: auto; }

/* ---------- Списки (подразделения, должности, теги, ключи) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; }
.tree-ind { flex: none; }
.row-actions { display: flex; gap: 4px; }
.key-box { display: flex; gap: 8px; align-items: center; }
.key-box code { flex: 1; padding: 10px 12px; border-radius: 9px; background: var(--surface-muted);
  border: 1px solid var(--border); word-break: break-all; font-size: 13px; }
.kv { color: var(--text-muted); font-size: 12px; }
.kv b { color: var(--text); font-weight: 500; }

/* ---------- Панель сотрудника ---------- */
.overlay { position: fixed; inset: 0; background: rgba(9, 13, 18, .45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 50; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .2s ease; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 20px 32px; }
.section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: 0; }
.section h3 { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; }
.svc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; flex-wrap: wrap; }
.svc-row > span { font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; }
.inline-add .select { flex: 1; }
.member { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.member .grow { flex: 1; }

/* ---------- Диалоги ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 16px; padding: 0; width: min(460px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(9, 13, 18, .5); }
.dlg-head { padding: 20px 20px 4px; font-size: 17px; font-weight: 600; }
.dlg-sub { padding: 0 20px; color: var(--text-muted); }
.dlg-body { padding: 16px 20px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 20px; }

/* ---------- Уведомления ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--canvas); font-weight: 500;
  box-shadow: var(--shadow-lg); max-width: min(380px, calc(100vw - 32px)); animation: pop .16s ease; }
.toast.err { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast.err { color: #1a0a0c; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; }
.auth-card {
  width: min(400px, 100%); padding: 32px 28px 28px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-sm);
}
.auth-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; text-align: center; }
.auth-sub { text-align: center; margin: 4px 0 24px; }
.theme-toggle { position: absolute; top: 16px; right: 16px; }
.yandex-id { display: block; width: 260px; max-width: 100%; margin: 0 auto; line-height: 0; border-radius: 24px; }
.yandex-id img { display: block; width: 100%; height: auto; }
.ya-on-dark { display: none !important; }
:root[data-theme="dark"] .ya-on-light { display: none !important; }
:root[data-theme="dark"] .ya-on-dark { display: block !important; background: #fff; border-radius: 24px; } /* контурный вариант Яндекса рассчитан на белый фон */
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; font-size: 12px; color: var(--text-muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Мобильная версия ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .nav { order: 3; flex-direction: row; flex: 0 0 100%; overflow-x: auto; padding-bottom: 2px; }
  .nav a { flex: none; }
  .nav-group { display: none; }
  .sidebar-foot { margin-left: auto; border: 0; padding: 0; }
  .me-text { display: none; }
  .content { padding: 20px 16px 40px; }
  .page-head h1 { font-size: 20px; }
  .grid2 { grid-template-columns: 1fr; }
}
.inline-add .select { flex: 1 1 0; min-width: 0; }
.inline-add .select:nth-child(2) { flex: 0 0 132px; }

/* ---------- Работа: сегодня, задачи, проекты ---------- */
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-sub { font-size: 11px; color: var(--text-muted); }
.cap::first-letter { text-transform: uppercase; }
.crumbs { margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.dash { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.card-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card-body { padding: 0 16px 16px; }
.card-muted { background: var(--surface-muted); box-shadow: none; }
.group { padding-bottom: 6px; }
.group-label { padding: 6px 16px 2px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.group-label.danger { color: var(--danger); }
.group-label .count { font-weight: 500; }
.empty-inline { padding: 16px; color: var(--text-muted); }
.empty-inline.left { display: flex; gap: 12px; align-items: flex-start; }
.empty-inline.left p { margin-top: 4px; font-size: 13px; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); }
.group .task-list .task-row:first-child { border-top: 0; }
.card > .task-list > .task-row:first-child { border-top: 1px solid var(--border); }
.task-main { flex: 1; min-width: 0; cursor: pointer; border-radius: 6px; }
.task-main:hover .task-title { color: var(--accent); }
.task-title { font-weight: 500; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 4px; }
.task-row.is-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.kv.inline { display: inline-flex; align-items: center; gap: 4px; }
.kv.inline svg.i { width: 14px; height: 14px; }
.tick {
  all: unset; box-sizing: border-box; flex: none; width: 22px; height: 22px; border-radius: 7px; margin-top: 1px;
  border: 1.5px solid var(--border); display: grid; place-items: center; cursor: pointer; color: transparent;
  background: var(--surface);
}
.tick svg.i { width: 14px; height: 14px; stroke-width: 2.5; }
.tick:hover:not(:disabled) { border-color: var(--accent); }
.tick.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tick:disabled { cursor: default; opacity: .6; }
.tick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tick.static { border-color: transparent; background: var(--accent-soft); color: var(--accent); cursor: default; }
.tick.static svg.i { stroke-width: 2; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); }
.people .grow { flex: 1; min-width: 0; }
.people .title { font-weight: 500; }
.quick { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.quick .input { flex: 1 1 200px; min-width: 0; }
.quick input[type="date"], .quick .select { flex: 0 1 170px; width: auto; }
.quick.col { flex-direction: column; border: 0; padding: 12px 0 0; }
.quick.col > .input, .quick.col > div > .input { flex: none; width: 100%; }
.textarea { height: auto; min-height: 64px; padding: 8px 12px; line-height: 1.45; resize: vertical; font-family: inherit; }
.title-input { font-size: 16px; font-weight: 600; border-color: transparent; background: transparent; padding-left: 0; }
.title-input:hover:not(:disabled), .title-input:focus { border-color: var(--border); padding-left: 12px; background: var(--surface); }
.title-input:disabled { color: var(--text); opacity: 1; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-muted); overflow: hidden; margin: 4px 0 12px; border: 1px solid var(--border); }
.progress.pad { margin: 0 16px 10px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.check-list .grow { flex: 1; min-width: 0; }
.struck { text-decoration: line-through; color: var(--text-muted); }
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment .grow { flex: 1; min-width: 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.project-card { display: block; color: var(--text); text-decoration: none; padding-bottom: 14px; }
.project-card .card-head, .project-card > p, .project-card > .progress, .project-card > .task-meta { margin-left: 16px; margin-right: 16px; padding-left: 0; padding-right: 0; }
.project-card:hover { border-color: var(--accent); }
.project-card .progress { margin-top: 10px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notes { display: flex; flex-direction: column; }
.note { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.note:last-child { border-bottom: 0; }
.note-foot { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.note-foot .btn:first-of-type { margin-left: auto; }
.pick { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px; }
.pick-row { padding: 6px 0; }
.card-pad { padding: 16px; }
@media (max-width: 1100px) { .dash { grid-template-columns: minmax(0, 1fr); } }
.quick .field .input, .quick .field .select { flex: none; width: 100%; }
.section > .field { margin-top: 14px; }
.quick.split > .input:first-child { flex: 1 1 100%; }
.quick.split input[type="date"] { flex: 0 0 150px; }
.quick.split .select { flex: 1 1 160px; }
