:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #1d2733;
  --muted: #66717e;
  --line: #dbe1e7;
  --accent: #2f7d5b;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ea;
  --progress: #b97a10;
  --progress-soft: #fbf0d9;
  --danger: #c2412d;
  --danger-soft: #fbe6e2;
  --focus: #2c6fd1;
  --control-h: 40px;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2366717e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(29, 39, 51, .06), 0 4px 16px rgba(29, 39, 51, .06);
  font-family: "Onest", -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a20;
    --surface: #1d242c;
    --surface-2: #232b34;
    --ink: #e6ebf0;
    --muted: #93a0ad;
    --line: #313b46;
    --accent: #4fb386;
    --accent-ink: #0f1a14;
    --accent-soft: #1f3a2e;
    --progress: #e0a83e;
    --progress-soft: #3a2f17;
    --danger: #ef7a66;
    --danger-soft: #42231e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2393a0ad' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- каркас */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: var(--radius-s);
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
.nav .count { font-size: 12px; font-variant-numeric: tabular-nums; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.side .me button { margin-top: 6px; }

.main { padding: 28px 40px 80px; max-width: 1080px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 28px; line-height: 1.15; margin: 0; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 4px 0 0; }

/* ---------- кнопки и поля */
/* единая высота для всех кнопок и полей */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 16px; line-height: 1;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius-s);
  cursor: pointer; font-size: 15px; font-weight: 500; white-space: nowrap; text-decoration: none;
  -webkit-appearance: none; appearance: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.link { height: auto; border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; line-height: 1.5; }
.btn:disabled { opacity: .5; cursor: default; }

label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background-color: var(--surface); font-size: 15px; color: var(--ink); margin: 0;
}
input[type=text], input[type=password], input[type=date], input[type=search], select {
  height: var(--control-h); padding-top: 0; padding-bottom: 0; line-height: normal;
}
input[type=date] { -webkit-appearance: none; appearance: none; display: flex; align-items: center; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
/* свой вид списков, чтобы Safari и Chrome рисовали их одинаково */
select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  padding-right: 36px;
  background-image: var(--chevron);
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- блоки */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 16px 18px; }

.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; min-width: 160px; }

/* ---------- задачи */
.tasks { list-style: none; margin: 0; padding: 0; }
.task {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  padding: 11px 18px; border-top: 1px solid var(--line);
}
.tasks > .task:first-child { border-top: 0; }
.task:hover { background: var(--surface-2); }
.task .title { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; font-weight: 500; line-height: 1.4; }
.task .title:hover { text-decoration: underline; text-underline-offset: 3px; }
.task.is-done .title { color: var(--muted); text-decoration: line-through; }
.task .meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; font-size: 13px; color: var(--muted); }
.task .meta .late { color: var(--danger); font-weight: 600; }
.task .right { display: flex; gap: 8px; align-items: center; }

/* переключатель статуса — круг слева */
.check {
  width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface); cursor: pointer; padding: 0;
  display: grid; place-items: center;
}
.check:hover { border-color: var(--accent); }
.check.progress { border-color: var(--progress); background: linear-gradient(90deg, var(--progress) 50%, transparent 50%); }
.check.done { border-color: var(--accent); background: var(--accent); }
.check.done::after { content: ""; width: 6px; height: 10px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }

.status-select { width: auto; min-width: 150px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.new { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.progress { background: var(--progress-soft); color: var(--progress); }
.pill.done { background: var(--accent-soft); color: var(--accent); }

/* главная деталь: метка «висит» */
.stale {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--danger-soft); color: var(--danger);
}
.stale::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.empty { padding: 28px 18px; color: var(--muted); text-align: center; }

/* ---------- режим созвона */
.review-person { margin-bottom: 26px; }
.review-person .who { display: flex; align-items: baseline; gap: 14px; margin: 0 2px 8px; flex-wrap: wrap; }
.review-person .who h2 { font-size: 22px; }
.review-person .nums { display: flex; gap: 14px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.review-person .nums b { color: var(--ink); }
.review-person .nums .bad b { color: var(--danger); }

/* ---------- встречи */
.meetings { list-style: none; margin: 0; padding: 0; }
.meetings li a { display: grid; grid-template-columns: 110px 1fr auto; gap: 14px; padding: 13px 18px; border-top: 1px solid var(--line); text-decoration: none; }
.meetings li:first-child a { border-top: 0; }
.meetings li a:hover { background: var(--surface-2); }
.meetings .date { color: var(--muted); font-variant-numeric: tabular-nums; }
.progressbar { width: 90px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; align-self: center; border: 1px solid var(--line); }
.progressbar i { display: block; height: 100%; background: var(--accent); }
.prose ul { margin: 0; padding-left: 20px; }
.prose li + li { margin-top: 4px; }

/* ---------- импорт */
.import-table { width: 100%; border-collapse: collapse; }
.import-table td, .import-table th { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; text-align: left; font-weight: 400; }
.import-table th { color: var(--muted); font-size: 13px; border-top: 0; }
.import-table td:first-child { width: 170px; }
.import-table td:nth-child(3) { width: 160px; }
.import-table .unmatched select { border-color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); }
pre.sample { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; font-size: 13px; white-space: pre-wrap; margin: 8px 0 0; font-family: inherit; }

/* ---------- окно задачи */
dialog {
  border: 0; padding: 0; border-radius: var(--radius-m); background: var(--surface); color: var(--ink);
  width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(15, 20, 26, .45); }
.dlg-head { display: flex; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.dlg-body { padding: 8px 20px 20px; display: grid; gap: 14px; }
.dlg-close { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.feed li { font-size: 14px; }
.feed .by { font-weight: 600; }
.feed .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.feed .log { color: var(--muted); font-size: 13px; }
.feed .text { white-space: pre-wrap; margin-top: 2px; }

/* ---------- вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth form { width: min(380px, 100%); display: grid; gap: 14px; padding: 28px; }
.auth h1 { font-size: 24px; }

.error { color: var(--danger); font-size: 14px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: var(--radius-s);
  font-size: 14px; box-shadow: var(--shadow); z-index: 50;
}

/* ---------- телефон */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .brand { padding: 4px 8px; flex: 1 0 100%; }
  .brand small { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 9px; }
  .nav .count { margin-left: 6px; }
  .side .me { margin: 0; padding: 6px 8px; border: 0; flex: 1 0 100%; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
  .side .me button { margin: 0; }
  .main { padding: 20px 16px 60px; }
  h1 { font-size: 24px; }
  .task { padding: 11px 14px; grid-template-columns: auto 1fr; }
  .task .right { grid-column: 2; }
  .grid2 { grid-template-columns: 1fr; }
  .meetings li a { grid-template-columns: 1fr auto; }
  .meetings .date { grid-column: 1 / -1; }
  .import-table, .import-table tbody, .import-table tr, .import-table td { display: block; width: 100% !important; }
  .import-table thead { display: none; }
  .import-table tr { border-top: 1px solid var(--line); padding: 8px 0; }
  .import-table td { border: 0; padding: 4px 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- «Не выполнено» в видах руководителя */
.pill.notdone { background: var(--danger-soft); color: var(--danger); }
.check.notdone { border-color: var(--danger); background: var(--danger-soft); }
.check.notdone::after { content: "×"; color: var(--danger); font-size: 16px; font-weight: 700; line-height: 1; }

/* ---------- экран исполнителя: задача + три кнопки */
.my-task {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--line);
}
.tasks > .my-task:first-child { border-top: 0; }
.my-text .title { font-weight: 500; line-height: 1.4; background: none; border: 0; padding: 0; text-align: left; font-size: 15px; }
button.title { cursor: pointer; }
button.title:hover { text-decoration: underline; text-underline-offset: 3px; }
.my-text .desc { font-size: 14px; color: var(--muted); white-space: pre-wrap; margin-top: 2px; }
.my-text .meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; font-size: 13px; color: var(--muted); }
.my-text .meta .late { color: var(--danger); font-weight: 600; }
.my-task.is-done .title { color: var(--muted); text-decoration: line-through; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.seg-btn {
  height: var(--control-h); padding: 0 14px; border: 0; background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn:hover { background: var(--surface-2); color: var(--ink); }
.seg-btn.progress[aria-pressed="true"] { background: var(--progress-soft); color: var(--progress); font-weight: 600; }
.seg-btn.done[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg-btn.notdone[aria-pressed="true"] { background: var(--danger-soft); color: var(--danger); font-weight: 600; }

/* у исполнителя нет меню — боковая панель только с именем */
.me-links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.side .me .me-links button { margin-top: 0; }
.app.is-member .main { max-width: 960px; }

@media (max-width: 760px) {
  .my-task { grid-template-columns: 1fr; gap: 10px; padding: 14px; }
  .seg { display: flex; }
  .seg-btn { flex: 1; padding: 0 6px; font-size: 13px; }
}

/* исполнитель: вместо боковой панели — верхняя строка */
.app.is-member { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
.app.is-member .side {
  position: static; height: auto; flex-direction: row; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 24px; border-right: 0; border-bottom: 1px solid var(--line);
}
.app.is-member .brand { padding: 0; flex: initial; }
.app.is-member .brand small { display: none; }
.app.is-member .side .me { margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 18px; flex: initial; }
.app.is-member .me-links { margin-top: 0; }
.app.is-member .main { margin: 0 auto; padding-top: 28px; }
@media (max-width: 760px) {
  .app.is-member .side { flex-wrap: wrap; padding: 12px 16px; }
  .app.is-member .side .me { gap: 14px; }
  .app.is-member .main { padding-top: 20px; }
}

/* ---------- экран «Созвон»: карточки людей */
.person-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.person-tile {
  display: grid; gap: 6px; text-align: left; cursor: pointer;
  padding: 16px 18px; border-radius: var(--radius-m);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.person-tile:hover { border-color: var(--muted); }
.person-tile[aria-pressed="true"] { border: 2px solid var(--accent); padding: 15px 17px; background: var(--accent-soft); }
.pt-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.pt-open { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pt-open small { font-size: 14px; font-weight: 500; color: var(--muted); }
.pt-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.pt-stats .s-progress { color: var(--progress); font-weight: 600; }
.pt-stats .s-notdone { color: var(--danger); font-weight: 600; }
@media (max-width: 760px) {
  .person-tiles { grid-template-columns: 1fr 1fr; }
  .pt-open { font-size: 24px; }
}
.panel-head:has(.btn) { align-items: center; padding-top: 10px; padding-bottom: 10px; }

/* ---------- открытые вопросы */
.person-tile.is-questions .pt-stats { color: var(--muted); }
.q-add { border-top: 1px solid var(--line); flex-wrap: nowrap; }
.q-add input { flex: 1; }
.prose li.solved { color: var(--muted); text-decoration: line-through; }
.prose li.solved .hint { text-decoration: none; display: inline-block; }
.task .title:is(div) { cursor: default; }
@media (max-width: 760px) { .q-add { flex-wrap: wrap; } .q-add .btn { width: 100%; } }

/* ---------- экран «Созвон»: группы задач */
.review-main > .panel + .panel { margin-top: 18px; }


/* ---------- фон: бледные картинки из игры «Хома Дома» за интерфейсом */
:root { --bg-art-opacity: .16; }
@media (prefers-color-scheme: dark) { :root { --bg-art-opacity: .13; } }
body { isolation: isolate; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--bg-url, none) center / cover no-repeat;
  opacity: var(--bg-art-opacity);
}
body[data-bg="login"] { --bg-art-opacity: .3; }
@media (prefers-color-scheme: dark) { body[data-bg="login"] { --bg-art-opacity: .22; } }

/* ---------- Хома: над формой входа и в пустых состояниях */
.auth form { position: relative; padding-top: 58px; margin-top: 52px; }
.homa-badge {
  position: absolute; top: -52px; left: 50%; transform: translateX(-50%);
  width: 104px; height: 104px; border-radius: 50%;
  border: 4px solid var(--surface); box-shadow: var(--shadow); background: var(--surface);
}
.empty.happy { padding: 36px 18px 40px; }
.homa-big { width: 120px; height: 120px; border-radius: 50%; display: block; margin: 0 auto 14px; }
.happy-title { font-size: 17px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }

/* ---------- Хома реагирует на смену статуса */
.homa-pop {
  position: fixed; left: 50%; top: 50%; z-index: 60; transform: translate(-50%, -50%);
  width: min(300px, calc(100vw - 32px)); padding: 26px 22px 22px; text-align: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow), 0 20px 60px rgba(0,0,0,.35);
  animation: pop-in .35s cubic-bezier(.2,1.4,.4,1) both;
}
.homa-pop.out { animation: pop-out .25s ease forwards; }
.homa-stage { position: relative; width: 140px; height: 150px; margin: 0 auto 10px; display: grid; place-items: end center; }
.homa-face { width: 120px; height: 120px; border-radius: 50%; display: block; }
.homa-title { font-size: 18px; font-weight: 700; color: var(--ink); }
.homa-text { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* радуется: подпрыгивает */
.homa-pop.happy .homa-face { animation: hop .55s ease-in-out .15s 3; }
.homa-pop.happy { border-color: var(--accent); }

/* грустит: серее, клонится, тучка с дождём и слезинка */
.homa-pop.sad .homa-face { filter: saturate(.45) brightness(.85); animation: droop 1.8s ease-in-out infinite; transform-origin: 50% 100%; }
.homa-pop.sad .homa-title { color: var(--muted); }
.rain { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 96px; height: 60px; z-index: 2; }
.cloud { position: absolute; top: 0; left: 8px; width: 80px; height: 26px; border-radius: 20px; background: #9aa6b4; box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #9aa6b4; border-radius: 50%; }
.cloud::before { width: 34px; height: 34px; left: 12px; top: -16px; }
.cloud::after { width: 26px; height: 26px; left: 40px; top: -11px; }
.rain i {
  position: absolute; top: 26px; left: calc(18px + var(--i) * 14px); width: 3px; height: 10px; border-radius: 3px;
  background: #4cc9f0; opacity: 0; animation: drop 0.9s linear calc(var(--i) * .17s) infinite;
}
.tear {
  position: absolute; left: 50%; bottom: 46px; margin-left: 20px; width: 9px; height: 13px; z-index: 2;
  background: #4cc9f0; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: tear 1.6s ease-in .3s infinite;
}
.fireworks { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 59; pointer-events: none; }

@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes pop-out { to { opacity: 0; transform: translate(-50%, -46%) scale(.95); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-26px) rotate(-6deg); } 60% { transform: translateY(-20px) rotate(6deg); } }
@keyframes droop { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(3px); } }
@keyframes drop { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(70px); } }
@keyframes tear { 0% { opacity: 0; transform: translateY(0) scale(.6); } 25% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: translateY(26px); } }
@media (prefers-reduced-motion: reduce) {
  .homa-pop, .homa-pop .homa-face, .rain i, .tear { animation: none !important; }
  .rain i { opacity: .8; }
}
