/* ===== Cosmic brandbook ===== */
:root {
  --cosmic: #23212C;
  --cosmic-2: #2C2A38;
  --cosmic-3: #37344A;
  --lavender: #D2C3F6;
  --lavender-dim: #9F8FD1;
  --turquoise: #99E1D9;
  --turquoise-dim: #5FB3AA;

  --bg: #1B1A22;
  --surface: #2A2836;
  --surface-2: #34313F;
  --line: #46435A;
  --text: #F5F4FA;
  --text-dim: #C4C0D6;
  /* APCA Lc >= 60 на всех трёх фонах (--bg/--surface/--surface-2); было #928EA6 = Lc 37-41 */
  --text-mute: #BDB9D1;

  --ok: #7FD1A8;
  --warn: #F0C674;
  --danger: #F08A8A;
  /* текстовый вариант danger: на подложке rgba(240,138,138,.16) исходный даёт Lc 44-49 */
  --danger-text: #FFB3B3;
  --info: #8FB8F0;

  --r: 14px;
  --r-sm: 9px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(210, 195, 246, 0.08), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(153, 225, 217, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1400px; margin: 0 auto; padding: 22px 26px 80px; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-dot {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--lavender), var(--turquoise));
  box-shadow: 0 6px 20px rgba(210, 195, 246, 0.25);
}
.brand-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.brand-sub { font-size: 12px; color: var(--text-mute); font-weight: 500; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===== Пользователь / выход ===== */
.user-badge { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); margin-right: 6px; }
.user-badge .u-name { font-weight: 700; color: var(--text); }
.user-badge button { font-family: inherit; background: transparent; border: none; color: var(--text-mute); font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; }
.user-badge button:hover { color: var(--text); }

/* ===== Вход по PIN ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(210, 195, 246, 0.1), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(153, 225, 217, 0.08), transparent 55%),
    var(--bg);
}
.login-box {
  width: 100%; max-width: 320px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 32px 28px; box-shadow: var(--shadow); text-align: center;
  animation: pop 0.25s var(--ease);
}
.login-dot {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--lavender), var(--turquoise));
  box-shadow: 0 6px 20px rgba(210, 195, 246, 0.25);
}
.login-title { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-mute); margin-bottom: 20px; }
.login-box input {
  width: 100%; font-family: inherit; font-size: 24px; letter-spacing: 12px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-sm); padding: 12px; margin-bottom: 14px;
}
.login-box input:focus { outline: none; border-color: var(--lavender-dim); }
.login-box .btn { width: 100%; padding: 12px; font-size: 14px; }
.login-error { color: var(--danger); font-size: 12.5px; font-weight: 600; margin-top: 12px; }

/* ===== Buttons ===== */
.btn {
  font-family: inherit; font-size: 13px; font-weight: 600;
  border: none; border-radius: var(--r-sm); padding: 10px 16px;
  cursor: pointer; transition: transform 0.15s var(--ease), background 0.2s, box-shadow 0.2s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--lavender), var(--turquoise));
  color: #1B1A22;
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(210, 195, 246, 0.3); }
.btn-ghost {
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: rgba(240, 138, 138, 0.14); color: var(--danger); border: 1px solid rgba(240, 138, 138, 0.3); }
.btn-danger:hover { background: rgba(240, 138, 138, 0.22); }

/* ===== Summary ===== */
.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 18px; position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--lavender));
}
.stat-label { font-size: 12px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.stat-value small { font-size: 15px; font-weight: 600; color: var(--text-dim); }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.stat.accent-lav { --accent: var(--lavender); }
.stat.accent-turq { --accent: var(--turquoise); }
.stat.accent-warn { --accent: var(--warn); }
.stat.accent-danger { --accent: var(--danger); }

.progress-bar { height: 7px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--lavender), var(--turquoise)); transition: width 0.5s var(--ease); }

/* ===== Controls ===== */
.controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.search-wrap { flex: 1; min-width: 220px; }
.search {
  /* 16px обязательно: при меньшем значении iOS Safari зумит страницу на фокусе */
  width: 100%; font-family: inherit; font-size: 16px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-sm); padding: 11px 15px; transition: border 0.2s;
}
.search::placeholder { color: var(--text-mute); }
.search:focus { outline: none; border-color: var(--lavender-dim); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 20px; padding: 7px 13px; cursor: pointer; transition: all 0.15s;
}
.chip:hover { border-color: var(--lavender-dim); color: var(--text); }
.chip.active { background: var(--lavender); color: #1B1A22; border-color: var(--lavender); }
.chip .count { opacity: 0.7; margin-left: 4px; }
.task-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 5px;
  border-radius: 50%; background: var(--warn); color: #1B1A22;
  font-size: 10px; font-weight: 800; line-height: 1;
}
.chip .task-badge { margin-left: 4px; }

.view-toggle { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; }
.vt-btn {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-mute);
  background: transparent; border: none; padding: 7px 14px; border-radius: 7px; cursor: pointer; transition: all 0.15s;
}
.vt-btn.active { background: var(--surface-2); color: var(--text); }

/* ===== Board (kanban) ===== */
.board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.column {
  flex: 0 0 300px; background: rgba(44, 42, 56, 0.5); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px; min-height: 120px;
}
.column.drag-over { border-color: var(--turquoise); background: rgba(153, 225, 217, 0.06); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.col-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.col-dot { width: 9px; height: 9px; border-radius: 50%; }
.col-count { font-size: 12px; color: var(--text-mute); font-weight: 700; background: var(--surface); padding: 2px 8px; border-radius: 10px; }
.col-body { display: flex; flex-direction: column; gap: 10px; }

/* ===== Card ===== */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 13px 14px; cursor: pointer; transition: transform 0.15s var(--ease), border 0.2s, box-shadow 0.2s;
  border-left: 3px solid var(--card-accent, var(--line));
}
.card:hover { transform: translateY(-2px); border-color: var(--lavender-dim); box-shadow: var(--shadow); }
.card.dragging { opacity: 0.4; }
.card-title { font-size: 14px; font-weight: 700; line-height: 1.3; margin-bottom: 8px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; color: var(--text-dim); }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-dim); }
.tag.money { background: rgba(153, 225, 217, 0.14); color: var(--turquoise); }
.tag.resp { background: rgba(143, 184, 240, 0.14); color: var(--info); }
.tag.tag-sent { background: rgba(127, 209, 168, 0.14); color: var(--ok); }
.tag.due { background: rgba(240, 198, 116, 0.14); color: var(--warn); }
.tag.overdue { background: rgba(240, 138, 138, 0.16); color: var(--danger-text); }
.tag.prio-high { background: rgba(240, 138, 138, 0.16); color: var(--danger); }
.card-progress { margin-top: 10px; }
.card-progress .progress-bar { height: 5px; margin-top: 0; }
.card-progress-label { font-size: 10.5px; color: var(--text-mute); margin-top: 5px; display: flex; justify-content: space-between; }
.card-links { display: flex; gap: 6px; margin-top: 9px; }
.card-links a { font-size: 11px; color: var(--lavender); text-decoration: none; padding: 3px 8px; border-radius: 6px; background: rgba(210,195,246,0.1); }
.card-links a:hover { background: rgba(210,195,246,0.2); }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
thead th {
  text-align: left; padding: 13px 14px; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-mute); border-bottom: 1px solid var(--line); white-space: nowrap;
  cursor: pointer; user-select: none;
}
thead th:hover { color: var(--text-dim); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background 0.12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tfoot .totals-row td {
  padding: 12px 14px; font-weight: 700; color: var(--text);
  border-top: 2px solid var(--line); background: var(--surface-2);
}
.t-name { font-weight: 700; line-height: 1.15; }
.t-name-tag {
  display: block; font-size: 9px; font-weight: 700; color: var(--ok);
  line-height: 1; margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.03em;
}
.status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.status-badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.mini-bar { width: 70px; height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--lavender), var(--turquoise)); }

.empty { text-align: center; padding: 60px 20px; color: var(--text-mute); }

/* [hidden] должен всегда скрывать элемент, даже если ниже стоит display:flex */
[hidden] { display: none !important; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 14, 20, 0.7); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 100; overflow-y: auto;
}
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  width: 100%; max-width: 640px; box-shadow: var(--shadow); animation: pop 0.25s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 14px; }
.modal-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.modal-close { background: var(--surface-2); border: none; color: var(--text-dim); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 18px; flex-shrink: 0; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 0 24px 24px; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-mute); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select, .field textarea {
  width: 100%; font-family: inherit; font-size: 14px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text); border-radius: var(--r-sm); padding: 10px 12px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--lavender-dim); }
.field textarea { resize: vertical; min-height: 60px; }
.field .inline-check {
  display: flex; align-items: center; gap: 7px; margin-top: 8px;
  font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: normal;
  color: var(--text-dim); cursor: pointer;
}
.field .inline-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--turquoise); cursor: pointer; margin: 0; flex-shrink: 0; }
.field .inline-check input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.85; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.section-title { font-size: 13px; font-weight: 700; color: var(--lavender); margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.section-title.ho-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.checklist { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--surface-2); border-radius: var(--r-sm); cursor: pointer; transition: background 0.15s; }
.check-item:hover { background: var(--cosmic-3); }
.check-item input { width: 18px; height: 18px; accent-color: var(--turquoise); cursor: pointer; flex-shrink: 0; }
.check-item span { font-size: 13.5px; }
.check-item.done span { color: var(--text-mute); text-decoration: line-through; }

.handover { display: flex; flex-direction: column; gap: 4px; }
.handover-stage { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.handover-head { padding: 11px 13px; background: var(--surface-2); font-size: 13px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.handover-head:hover { background: var(--cosmic-3); }
.handover-head .hprog { font-size: 11px; font-weight: 600; color: var(--turquoise); }
.handover-items { padding: 6px; display: none; flex-direction: column; gap: 4px; }
.handover-stage.open .handover-items { display: flex; }
.handover-items .check-item { background: transparent; }
.handover-items .check-item:hover { background: var(--surface-2); }
.ho-head-right { display: flex; align-items: center; gap: 8px; }
.ho-stage-del { background: transparent; border: none; color: var(--text-mute); font-size: 16px; line-height: 1; cursor: pointer; padding: 2px 4px; }
.ho-stage-del:hover { color: var(--danger); }
.handover-item-row { display: flex; align-items: center; gap: 4px; }
.handover-item-row .check-item { flex: 1; }
.ho-item-del { background: transparent; border: none; color: var(--text-mute); font-size: 16px; line-height: 1; cursor: pointer; padding: 2px 6px; flex-shrink: 0; }
.ho-item-del:hover { color: var(--danger); }
.ho-item-add-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; padding: 0 2px; }
.ho-item-add-row textarea {
  flex: 1; min-width: 180px; font-family: inherit; font-size: 12.5px; resize: vertical;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 6px 9px;
}
.ho-item-add-row textarea:focus { outline: none; border-color: var(--lavender-dim); }
.ho-stage-add-row { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; align-items: flex-start; }
.ho-stage-add-row textarea { width: 100%; resize: vertical; font-family: inherit; font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; }
.ho-stage-add-row textarea:focus { outline: none; border-color: var(--lavender-dim); }

.modal-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.modal-links a { font-size: 12.5px; color: var(--lavender); text-decoration: none; padding: 7px 12px; border-radius: 8px; background: rgba(210,195,246,0.1); font-weight: 600; }
.modal-links a:hover { background: rgba(210,195,246,0.2); }

/* ===== Задачи проекта ===== */
.tasks-list { display: flex; flex-direction: column; gap: 8px; }
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 11px; background: var(--surface-2); border-radius: var(--r-sm); }
.task-row.done { opacity: 0.6; }
.task-check input { width: 18px; height: 18px; accent-color: var(--turquoise); cursor: pointer; margin-top: 2px; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; font-weight: 600; }
.task-desc { margin-top: 4px; }
.task-desc-details summary { font-size: 11.5px; font-weight: 600; color: var(--text-mute); cursor: pointer; list-style: none; }
.task-desc-details summary::-webkit-details-marker { display: none; }
.task-desc-details summary:hover { color: var(--lavender); }
.task-desc-details[open] summary { margin-bottom: 6px; }
.task-desc-text { font-size: 12.5px; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border-radius: var(--r-sm); padding: 7px 10px; }
.task-desc-details .task-desc-toggle { margin-top: 5px; }
.task-desc-toggle { background: none; border: 0; padding: 2px 0; font-size: 11.5px; font-weight: 600; color: var(--text-mute); cursor: pointer; margin-top: 3px; }
.task-desc-toggle:hover { color: var(--lavender); }
.task-desc-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.task-desc-edit textarea { width: 100%; resize: vertical; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; font: inherit; font-size: 12.5px; }
.task-desc-edit .btn { align-self: flex-start; }
.task-add-desc { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.task-add-desc textarea { width: 100%; resize: vertical; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; font: inherit; font-size: 12.5px; }
.task-author { font-size: 11px; font-weight: 700; color: var(--lavender-dim); }
.task-resp-select {
  font-family: inherit; font-size: 11px; font-weight: 700; color: var(--lavender-dim);
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 0 2px; margin-left: 1px; cursor: pointer;
}
.task-resp-select:hover, .task-resp-select:focus { border-color: var(--line); background: var(--surface); outline: none; }
.task-resp-select option { color: var(--text); background: var(--surface-2); font-weight: 600; }
.task-completer { font-size: 11px; font-weight: 700; color: var(--ok); }
.task-row.done .task-title { color: var(--text-mute); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 7px; }
.task-field { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.task-field input { font-family: inherit; font-size: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 4px 6px; }
.task-field input[type="number"] { width: 56px; }
.task-field input[type="date"] { width: 128px; }
.task-done-at { font-size: 11px; color: var(--ok); font-weight: 600; }
.task-sent { font-size: 11px; color: var(--info); font-weight: 600; }
.task-comment { width: 100%; margin-top: 7px; font-family: inherit; font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 6px 9px; }
.task-comment::placeholder { color: var(--text-mute); }
.task-comment:focus { outline: none; border-color: var(--lavender-dim); }
.task-row.done .task-comment { border-color: var(--ok); }
.task-del { background: transparent; border: none; color: var(--text-mute); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 4px; flex-shrink: 0; }
.task-del:hover { color: var(--danger); }
.task-comments { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.task-comment-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; background: var(--surface); border-radius: 8px; padding: 6px 8px; }
.task-comment-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.task-comment-text { font-size: 12.5px; color: var(--text-dim); word-break: break-word; }
.task-comment-meta { font-size: 10.5px; color: var(--text-mute); }
.task-comment-del { background: transparent; border: none; color: var(--text-mute); font-size: 15px; line-height: 1; cursor: pointer; padding: 0 4px; flex-shrink: 0; }
.task-comment-del:hover { color: var(--danger); }
.task-comment-add-row { display: flex; gap: 6px; }
.task-comment-add-row input {
  flex: 1; font-family: inherit; font-size: 12.5px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 9px;
}
.task-comment-add-row input:focus { outline: none; border-color: var(--lavender-dim); }
.task-comment-add-row .btn { padding: 6px 10px; font-size: 12px; }
.task-add-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.task-add-row input[type="text"] { flex: 1; min-width: 160px; }
.task-add-row input, .task-tg-row select {
  font-family: inherit; font-size: 13px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text); border-radius: var(--r-sm); padding: 9px 11px;
}
.task-add-row input:focus { outline: none; border-color: var(--lavender-dim); }
.task-tg-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.task-tg-row .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tg-hint { font-size: 12px; color: var(--text-mute); }

.modal-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ===== Плавающая кнопка «Сохранить» ===== */
/* position:fixed относительно окна — не зависит от прокрутки .modal-overlay, поэтому "плавает" вместе со скроллом */
.floating-save {
  position: fixed; right: 32px; bottom: 32px; z-index: 210;
  display: flex; align-items: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  border: none; border-radius: 999px; padding: 14px 22px; cursor: pointer;
  background: linear-gradient(135deg, var(--lavender), var(--turquoise)); color: #1B1A22;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);
  opacity: 0; transform: translateY(16px) scale(0.96); pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.floating-save.show { opacity: 1; transform: none; pointer-events: auto; }
.floating-save:active { transform: translateY(1px); }
@media (max-width: 560px) {
  .floating-save { right: 16px; bottom: 16px; left: 16px; justify-content: center; }
}

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--cosmic-3); border: 1px solid var(--lavender-dim); color: var(--text);
  padding: 12px 20px; border-radius: 10px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); z-index: 200;
  animation: toastIn 0.3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 560px) {
  .app { padding: 16px 14px 60px; }
  .field-row { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 22px; }
}

/* ===== Доступность ===== */

/* На узких экранах любое поле < 16px заставляет iOS Safari зумить форму */
@media (max-width: 640px) {
  .field input, .field select, .field textarea,
  .task-field input, .task-add-row input, .task-tg-row select,
  .ho-stage-add-row textarea, .ho-item-add-row textarea,
  .task-comment-add-row input,
  .login-box input { font-size: 16px; }
}

/* Видимый фокус с клавиатуры. :focus-visible срабатывает только при навигации
   Tab'ом, поэтому обводка не появляется при клике мышью. */
:where(button, a[href], input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Поля выше гасят обводку в :focus — возвращаем её для клавиатуры */
.search:focus-visible,
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
.task-add-row input:focus-visible, .login-box input:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
  border-color: var(--lavender-dim);
}

/* Часть людей от движения на экране физически укачивает */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ===== Дашборд «Сопровождение» ===== */
.support-mode > .summary, .support-mode > .controls { display: none; }
.btn-ghost.active { background: var(--lavender); color: #1B1A22; border-color: var(--lavender); }
.sup-project { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 14px; }
.sup-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.sup-name { font-family: inherit; font-size: 15px; font-weight: 800; color: var(--text); background: transparent; border: none; padding: 0; cursor: pointer; text-align: left; }
.sup-name:hover { color: var(--lavender); text-decoration: underline; }
.sup-days { font-size: 12px; color: var(--text-mute); }
.sup-count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--warn); }
.sup-tasks { display: flex; flex-direction: column; gap: 6px; }
.sup-task { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; background: var(--surface-2); border-radius: var(--r-sm); }
.sup-task.done { opacity: 0.6; }
.sup-task.done .task-title { color: var(--text-mute); text-decoration: line-through; }
.sup-task-main { flex: 1; min-width: 0; }
.sup-task-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; font-size: 11px; color: var(--text-mute); font-weight: 600; }
.sup-over { color: var(--danger-text); font-weight: 700; }
.sup-done { margin-top: 10px; }
.sup-done summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text-mute); margin-bottom: 6px; }
.sup-done .sup-task { margin-top: 6px; }
.sup-done-day { margin-top: 10px; }
.sup-done-day:first-child { margin-top: 0; }
.sup-done-date { font-size: 11px; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 5px; }
.sup-month { margin-top: 16px; }
.sup-month:first-child { margin-top: 0; }
.sup-month-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--text); padding-bottom: 6px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.sup-month-count { font-size: 12px; font-weight: 600; color: var(--text-mute); background: var(--surface-2, rgba(255,255,255,.06)); border-radius: 999px; padding: 2px 10px; }
.sup-project .task-add-row input { background: var(--surface-2); }


/* ===== Сопровождение: карточка запроса и режим ?support ===== */
.support-only #supportBtn, .support-only #importBtn, .support-only #exportBtn, .support-only #addBtn,
.support-only .controls, .support-only #summary { display: none !important; }
.sup-task-open { background: none; border: 0; padding: 0; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.sup-task-open:hover { color: var(--lavender); text-decoration: underline; }
.tm-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.tm-title { font-size: 17px; font-weight: 800; }
.tm-sub { font-size: 13px; color: var(--text-mute); margin-top: 4px; }
.tm-thread { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; padding: 4px 2px; }
.tm-msg { max-width: 82%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.tm-msg.from-staff { align-self: flex-end; background: rgba(139, 122, 255, 0.18); }
.tm-msg-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--text-mute); font-weight: 600; margin-bottom: 3px; }
.tm-split { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 10.5px; font-weight: 600; color: var(--text-mute); cursor: pointer; white-space: nowrap; }
.tm-split:hover { color: var(--lavender); border-color: var(--lavender-dim); }
.tm-msg-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.tm-add { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.tm-add textarea { width: 100%; resize: vertical; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; font: inherit; }
.tm-actions { display: flex; justify-content: space-between; align-items: center; }
.login-box #loginName { font-size: 16px; letter-spacing: normal; }
#taskModalBody { padding: 22px; }
.tm-head-btns { display: flex; gap: 8px; flex-shrink: 0; }
.tm-del:hover { color: var(--danger); border-color: var(--danger); }

/* ===== Доступы (ссылка/логин/пароль по сервисам) ===== */
.accesses-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.access-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--surface-2); border-radius: var(--r-sm); }
.access-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.access-top { display: flex; align-items: center; gap: 8px; }
.access-link { font-size: 13px; font-weight: 600; word-break: break-all; }
.access-link.empty { color: var(--text-mute); font-weight: 400; }
.access-eye { background: none; border: 0; padding: 2px 4px; font-size: 13px; cursor: pointer; opacity: 0.7; line-height: 1; }
.access-eye:hover { opacity: 1; }
.access-creds { display: flex; gap: 14px; font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.access-creds[hidden] { display: none; }
.access-add-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--r-sm); margin-top: 4px; }
.access-add-form input { flex: 1; min-width: 140px; }

/* ===== Публичная страница клиента (?client=<токен>) ===== */
.client-view { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; }
.cv-card { width: 100%; max-width: 1280px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px 26px; box-shadow: var(--shadow); }
.cv-layout { display: flex; gap: 40px; align-items: flex-start; }
.cv-main { flex: 1 1 0; min-width: 0; }
.cv-timeline { width: 440px; flex: 0 0 440px; border-left: 1px solid var(--line); padding-left: 32px; }
@media (max-width: 980px) {
  .cv-layout { flex-direction: column; }
  .cv-timeline { width: 100%; flex-basis: auto; border-left: none; border-top: 1px solid var(--line); padding-left: 0; padding-top: 20px; }
}
.cv-tl-list { display: flex; flex-direction: column; gap: 14px; max-height: 78vh; overflow-y: auto; }
.cv-tl-item { font-size: 13.5px; }
.cv-tl-date { color: var(--text-mute); font-size: 11.5px; font-weight: 600; }
.cv-tl-sub { color: var(--turquoise-dim); font-weight: 600; }
.cv-tl-text { color: var(--text-dim); margin-top: 3px; line-height: 1.4; }
.cv-timeline .empty { padding: 8px 0; font-size: 13px; line-height: 1.5; }
.cv-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cv-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.cv-status { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: color-mix(in srgb, var(--st-color) 22%, transparent); color: var(--st-color); border: 1px solid color-mix(in srgb, var(--st-color) 45%, transparent); white-space: nowrap; }
.cv-dates { font-size: 13px; color: var(--text-mute); margin-top: 8px; }
.cv-progress { margin-top: 18px; }
.cv-progress-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 700; color: var(--lavender); margin-bottom: 8px; }
.cv-progress-head span:last-child { font-size: 12px; font-weight: 600; color: var(--text-mute); }
.cv-progress-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.cv-progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--turquoise-dim), var(--lavender)); transition: width 0.3s var(--ease); }
.cv-stage { background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px; margin-top: 10px; }
.cv-stage-done { opacity: 0.6; }
.cv-stage-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; }
.cv-stage-count { color: var(--text-mute); font-weight: 600; }
.cv-stage-items { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.cv-item { display: flex; gap: 8px; font-size: 13px; color: var(--text-dim); }
.cv-item.done { color: var(--text-mute); text-decoration: line-through; }
.cv-check { flex-shrink: 0; }
.cv-tasks { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cv-task { background: var(--surface-2); border-radius: var(--r-sm); padding: 9px 12px; font-size: 13px; }
.cv-task-due { color: var(--text-mute); font-size: 11.5px; font-weight: 600; }

/* ===== Ссылка для клиента (в модалке проекта) ===== */
.client-link-row { display: flex; gap: 8px; align-items: center; }
.client-link-row input { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-mute); }
.sup-part { margin-top: 14px; }
.sup-part:first-of-type { margin-top: 10px; }
.sup-part-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.sup-task.pending-delete .sup-task-open { text-decoration: line-through; color: var(--text-mute); }
.sup-task.pending-delete { opacity: .55; }
.sup-pending-tag { color: var(--danger, #E08080); font-weight: 600; }
.sup-pending-block { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); }
.sup-pending-head { font-size: 11px; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.tm-pending-banner { margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; background: rgba(224,128,128,.12); border: 1px solid rgba(224,128,128,.35); color: var(--text-dim); font-size: 12.5px; }
.tm-msg.from-note { align-self: flex-end; background: rgba(240, 198, 116, 0.16); }
.tm-note-tag { font-weight: 700; color: var(--warn, #F0C674); text-transform: uppercase; font-size: 10px; letter-spacing: .03em; }
#tmComment.tm-comment-required { outline: 2px solid var(--danger); outline-offset: 1px; }
.lead-closed td { color: var(--text-mute); }
.lead-closed td:nth-child(2) { text-decoration: line-through; }
.sales-date-cell { cursor: pointer; }
.sales-date-cell:hover { background: var(--surface-2); text-decoration: underline dotted; }
.date-overridden { color: var(--lavender-dim); font-weight: 600; }
.date-overridden::after { content: " ✎"; font-size: 10px; opacity: .7; }
.sales-date-input { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12.5px; font-family: inherit; }
