:root {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --line: #2a2f3a;
  --text: #e6e9ef; --muted: #8d97a8; --accent: #4f8cff; --accent-soft: rgba(79,140,255,.14);
  --green: #3ecf8e; --amber: #f6b73c; --red: #f2585b; --violet: #a97bff;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.ellipsis { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: var(--mono); }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 26px; display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 6px 0 0; font-size: 20px; }
.login-card p { margin: 0 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.login-error { color: #f58285; font-size: 12.5px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4f8cff, #a97bff); font-weight: 700; color: #fff; letter-spacing: .5px;
}
.logo.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }

/* шапка */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px;
  padding: 9px 18px; background: rgba(15,17,21,.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-title { font-weight: 650; font-size: 13.5px; }
.brand-sub { color: var(--muted); font-size: 11px; }
.tabs { display: flex; gap: 3px; flex: 1; flex-wrap: wrap; }
.tab {
  background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 550; font-family: inherit;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(79,140,255,.3); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.stamp { color: var(--muted); font-size: 11px; font-family: var(--mono); }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 13px;
  font-family: inherit; font-weight: 550;
}
.btn:hover { border-color: #3b424f; background: #242935; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3f7cf0; }
.btn.danger { border-color: rgba(242,88,91,.45); color: #f58285; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }

main { padding: 16px 18px 60px; display: flex; flex-direction: column; gap: 14px; }

/* KPI-плитки */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 11px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; }
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 21px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 11px; margin-top: 2px; }
.kpi.accent .value { color: var(--accent); } .kpi.green .value { color: var(--green); }
.kpi.amber .value { color: var(--amber); } .kpi.violet .value { color: var(--violet); }
.kpi.red .value { color: var(--red); }

/* панели */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.panel-title { font-weight: 620; font-size: 14px; }
.panel-title .sub { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 8px; }
.panel-tools { margin-left: auto; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.panel-body { padding: 12px 13px; }
.panel-note { color: var(--muted); font-size: 11.5px; padding: 9px 13px; border-top: 1px solid var(--line); }

select, input[type=text], input[type=number], input[type=month], input[type=date], input[type=search],
input[type=email], input[type=password], textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 6px 9px; font-size: 13px; font-family: inherit; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
label.field { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }

/* таблицы */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
  position: sticky; top: 0; z-index: 5; background: var(--panel-2); color: var(--muted);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
tbody tr:hover { background: rgba(255,255,255,.025); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 650; background: var(--panel-2); border-top: 1px solid var(--line); border-bottom: 0; }
tr.group-row td { background: #202531; font-weight: 620; }
tr.done td { opacity: .62; }
.empty { padding: 26px 14px; text-align: center; color: var(--muted); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600;
  white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.pill.blue { background: rgba(79,140,255,.14); color: #8fb6ff; border-color: rgba(79,140,255,.3); }
.pill.green { background: rgba(62,207,142,.13); color: #6fdcae; border-color: rgba(62,207,142,.3); }
.pill.amber { background: rgba(246,183,60,.13); color: #f3c76d; border-color: rgba(246,183,60,.3); }
.pill.red { background: rgba(242,88,91,.13); color: #f58285; border-color: rgba(242,88,91,.3); }
.pill.violet { background: rgba(169,123,255,.14); color: #c0a0ff; border-color: rgba(169,123,255,.3); }

.edit { width: 72px; background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 3px 5px; color: var(--text); font-size: 12.5px; text-align: right;
  font-variant-numeric: tabular-nums; font-family: inherit; }
.edit:hover { border-color: var(--line); background: var(--panel-2); }
.edit:focus { border-color: var(--accent); background: var(--panel-2); }
.edit.wide { width: 108px; text-align: left; }
.edit.date { width: 116px; text-align: left; }

/* раскрытие пруфа */
details.proof { margin-top: 3px; }
details.proof > summary { cursor: pointer; color: var(--accent); font-size: 11.5px; list-style: none; }
details.proof > summary::-webkit-details-marker { display: none; }
details.proof > summary::before { content: '▸ '; }
details.proof[open] > summary::before { content: '▾ '; }
.proof-body { margin-top: 6px; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; color: var(--muted); }
.proof-body ul { margin: 4px 0 0 16px; padding: 0; }
.proof-body b { color: var(--text); }

/* модалка */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; width: min(620px, 100%); max-height: 86vh; overflow: auto; }
.modal-card h3 { margin: 0 0 12px; font-size: 15px; }
.modal-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; font-size: 12.5px; color: var(--muted); }
.modal-row > input, .modal-row > select, .modal-row > textarea { width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

.banner { margin: 12px 18px 0; padding: 10px 13px; border-radius: 9px; font-size: 12.5px;
  background: rgba(242,88,91,.12); border: 1px solid rgba(242,88,91,.35); color: #f7a9ab; }
.banner.warn { background: rgba(246,183,60,.1); border-color: rgba(246,183,60,.35); color: #f3c76d; }
.loader { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center;
  gap: 13px; background: rgba(15,17,21,.86); color: var(--muted); font-size: 13px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); padding: 9px 16px; border-radius: 9px;
  font-size: 13px; z-index: 90; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.err { border-color: rgba(242,88,91,.5); color: #f58285; }
pre.tabel { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; overflow-x: auto; white-space: pre; margin: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.set-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 11px; }
.set-item .t { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.set-item input, .set-item select { width: 100%; }

/* ---------- периметр сотрудников ---------- */
.scope-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.scope-item {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  cursor: pointer; font-size: 13px;
}
.scope-item:hover { border-color: #3b424f; }
.scope-item.on { border-color: rgba(79,140,255,.45); background: rgba(79,140,255,.07); }
.scope-item input { margin-top: 2px; }

/* ---------- календарь проектов ---------- */
.cal-wrap { position: relative; padding: 6px 0 2px; }
.cal-group { margin-bottom: 14px; }
.cal-company { font-weight: 620; font-size: 12.5px; padding: 4px 13px; color: var(--text); }
.cal-row { display: flex; align-items: center; gap: 10px; padding: 3px 13px; }
.cal-label { width: 270px; flex: none; font-size: 12.5px; }
.cal-track {
  position: relative; flex: 1; height: 22px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
}
.cal-track::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: var(--now, 50%);
  width: 1px; background: rgba(246,183,60,.7); z-index: 2;
}
.cal-bar {
  position: absolute; top: 3px; bottom: 3px; border-radius: 4px;
  background: rgba(169,123,255,.5); border: 1px solid rgba(169,123,255,.8);
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 6px; font-size: 10.5px; color: #fff; white-space: nowrap; overflow: hidden;
}
.cal-bar.tz { background: rgba(79,140,255,.5); border-color: rgba(79,140,255,.8); }
.cal-bar.tp { background: rgba(62,207,142,.45); border-color: rgba(62,207,142,.75); }
.cal-bar.overdue { background: rgba(242,88,91,.5); border-color: rgba(242,88,91,.85); }
.legend i.sw {
  display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px;
  background: rgba(169,123,255,.6); border: 1px solid rgba(169,123,255,.9);
}
.legend i.sw.tz { background: rgba(79,140,255,.6); border-color: rgba(79,140,255,.9); }
.legend i.sw.tp { background: rgba(62,207,142,.55); border-color: rgba(62,207,142,.85); }
.legend i.sw.overdue { background: rgba(242,88,91,.6); border-color: rgba(242,88,91,.9); }
.cal-bar.point { border-radius: 3px; }
.cal-outside {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; color: var(--muted); white-space: nowrap; pointer-events: none;
}
