/* Tracker — дашборд. Мобильный первый: половина ценности — посмотреть с телефона. */
:root {
  --bg: #f6f7f9; --card: #fff; --text: #1c1f24; --muted: #6b7280; --line: #e3e6ea;
  --accent: #2456d6; --accent-ink: #fff; --danger: #c62828; --warn: #b26a00; --ok: #1b7f3b;
  --fresh-0: #e8f5e9; --fresh-1: #f1f3f5; --fresh-2: #fff3e0; --fresh-3: #fdecea;
  --radius: 10px; --gap: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161a; --card: #1e2126; --text: #e7e9ee; --muted: #9aa3ae; --line: #2c3038;
    --fresh-0: #17331f; --fresh-1: #23262c; --fresh-2: #3a2a10; --fresh-3: #3d1c1a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; flex-wrap: wrap; row-gap: 4px; }
.brand { font-weight: 700; color: var(--text); font-size: 17px; }
/* На 320px пункты не помещаются в строку — переносятся; длинное имя человека обрезается многоточием. */
.nav { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.nav a.me { max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a.active { font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--line); color: var(--muted); vertical-align: middle; }
.badge-test { background: #ffe082; color: #5d4000; }

.app { padding: 12px 16px 60px; max-width: 1100px; margin: 0 auto; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 7px 12px; cursor: pointer; }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 7px 12px; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.alerts { display: grid; gap: 8px; margin-bottom: 14px; }
.alert { border-radius: var(--radius); padding: 10px 12px; background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--warn); }
.alert.danger { border-left-color: var(--danger); }
.alert.ok { border-left-color: var(--ok); }
.alert h3 { font-size: 14px; margin-bottom: 4px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert li { margin: 2px 0; }

.group { margin-bottom: 18px; }
.group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.group-head h2 { font-size: 17px; }
.group-head .meta { color: var(--muted); font-size: 13px; }
.group-head .btn-sm { margin-left: auto; }

.cards { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1040px) { .cards { grid-template-columns: repeat(3, 1fr); } }
/* Длинные пути и адреса в тексте не распирают карточку шире экрана (на 320px было 518px). */
.cards > * { min-width: 0; }
.card { overflow-wrap: anywhere; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; display: grid; gap: 6px; }
.card.fresh-0 { background: var(--fresh-0); }
.card.fresh-1 { background: var(--fresh-1); }
.card.fresh-2 { background: var(--fresh-2); }
.card.fresh-3 { background: var(--fresh-3); }
.card.closed { opacity: .65; }
.card .title { font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.card .title .pri { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px;
  padding: 0 5px; flex: none; margin-top: 2px; }
.card .proj { font-size: 12px; color: var(--muted); }
.card .next { font-size: 14px; }
.card .next b { color: var(--muted); font-weight: 500; }
.card .next.empty { color: var(--warn); }
.card .flags { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; align-items: flex-start; align-content: flex-start; }
.flag { padding: 1px 7px; border-radius: 999px; background: var(--line); }
.flag.overdue { background: var(--danger); color: #fff; }
.flag.recheck { background: var(--warn); color: #fff; }
.flag.waiting { background: #fff3e0; color: #7a4a00; }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.card select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: var(--card); }
.card .edit-next { display: none; gap: 6px; }
.card.editing .edit-next { display: flex; }
.card.editing .next, .card.editing .actions { display: none; }
.card .edit-next input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

.project-card .stats { font-size: 13px; color: var(--muted); }
.project-card .loc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dialog { border: 0; border-radius: 14px; padding: 0; max-width: 560px; width: calc(100% - 24px);
  background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.form { padding: 18px; display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form label small { font-weight: normal; }
.form input, .form select, .form textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  background: var(--bg); color: var(--text); font-size: 15px; width: 100%; }
.form .row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.form .row:has(> :nth-child(3)) { grid-template-columns: 1fr 1fr 1fr; }
.form .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-error { color: var(--danger); font-size: 14px; margin: 0; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login-card form { display: grid; gap: 10px; }
.login-card input { border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 16px;
  background: var(--bg); color: var(--text); }

.review h2 { font-size: 18px; margin-top: 18px; }
.empty { color: var(--muted); padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #222; color: #fff;
  padding: 10px 14px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); z-index: 20; }
.toast.error { background: var(--danger); }

/* ---- паспорта ---- */
.passports { max-width: 860px; }
.passport-card { display: block; text-decoration: none; color: inherit; margin-bottom: var(--gap); }
.note-form textarea { width: 100%; min-height: 9rem; font-size: 1rem; }
.notes { list-style: none; padding: 0; }
.notes li { border-left: 3px solid #d9a400; padding: 4px 10px; margin: 8px 0; }
.notes li.merged { border-left-color: #999; opacity: .75; }
.passport-md h2, .passport-md h3 { margin-top: 1.4em; }
.passport-md .tbl { overflow-x: auto; }
.passport-md table { border-collapse: collapse; font-size: .92em; }
.passport-md th, .passport-md td { border: 1px solid #8884; padding: 4px 8px; text-align: left; vertical-align: top; }
.passport-md code { font-size: .9em; background: #8882; padding: 0 3px; border-radius: 3px; }

/* Профиль и приглашение (несколько людей, миграция 003) */
.profile { max-width: 720px; }
.profile h1 { font-size: 22px; margin: 8px 0 12px; }
.profile h2 { font-size: 17px; margin: 22px 0 8px; }
.secret-box { border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin: 16px 0; background: var(--card); overflow-wrap: anywhere; }
.secret-box ol { padding-left: 20px; }
.secret { width: 100%; box-sizing: border-box; font-family: ui-monospace, monospace; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg, transparent); color: inherit; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; }

/* Люди на доске и страница «Люди» (этап 4) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.who-wrap select { border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px;
  background: var(--card); max-width: 100%; }
.card .people-line { font-size: 13px; color: var(--muted); }
.card .people-line b { color: var(--text); font-weight: 600; }
.form .participants { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 8px; margin: 0;
  font-size: 13px; color: var(--muted); }
.form .participants legend { padding: 0 4px; }
.form .participants .checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.form .participants .check { display: inline-flex; grid-template-columns: none; color: var(--text); font-size: 14px; }
.form .participants input { width: auto; }
.people .person { margin: 12px 0; }
.people .facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; font-size: 14px; }
.people .facts dt { color: var(--muted); }
.people .facts dd { margin: 0; min-width: 0; }
.people .morning-form label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); min-width: 0; }
.people .morning-form label > span { white-space: nowrap; }
.people .morning-form select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: var(--card); max-width: 100%; }
.warn-text { color: var(--warn); }
.notice { border-left: 4px solid var(--accent); background: var(--card); padding: 8px 12px; border-radius: 6px; }

/* Этап 5: «только смотрит», кому открыт проект, журнал, завести человека */
.card .view-only { font-size: 12px; color: var(--muted); }
.form .members-fields { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 10px; margin: 0;
  font-size: 13px; color: var(--muted); }
.form .members-fields legend { padding: 0 4px; }
.form .member-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  color: var(--text); font-size: 14px; margin-top: 6px; }
.form .member-row select { width: auto; padding: 5px 8px; }
.history { max-width: 860px; }
.history .toolbar select { border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px;
  background: var(--card); max-width: 100%; }
.history .h-day { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }
.history .h-day::first-letter { text-transform: uppercase; }
.history .h-row { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
.history .h-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.add-person { margin-top: 20px; }
.add-person .form-grid { display: grid; gap: 10px; }
.add-person label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.add-person input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg);
  color: var(--text); font-size: 15px; width: 100%; }
