* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7488;
  --border: #e3e7ef;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --orange: #ea580c;
  --orange-bg: #fff7ed;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --yellow: #ca8a04;
  --yellow-bg: #fefce8;
  --blue-bg: #eff6ff;
  --sidebar: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}
/* ---------- Темы ---------- */
:root[data-theme="emerald"] { --primary: #059669; --primary-dark: #047857; --blue-bg: #ecfdf5; --sidebar: #064e3b; }
:root[data-theme="violet"] { --primary: #7c3aed; --primary-dark: #6d28d9; --blue-bg: #f5f3ff; --sidebar: #2e1065; }
:root[data-theme="sunset"] { --primary: #ea580c; --primary-dark: #c2410c; --blue-bg: #fff7ed; --sidebar: #3b1d0d; }
:root[data-theme="rose"] { --primary: #e11d48; --primary-dark: #be123c; --blue-bg: #fff1f2; --sidebar: #4c0519; }
:root[data-theme="teal"] { --primary: #0d9488; --primary-dark: #0f766e; --blue-bg: #f0fdfa; --sidebar: #042f2e; }
:root[data-theme="graphite"] { --primary: #64748b; --primary-dark: #475569; --blue-bg: #eef2f7; --sidebar: #1e293b; }
:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0e0a1f; --card: #191233; --text: #ece9f8; --muted: #9d94bd; --border: #2c2250;
  --primary: #8b5cf6; --primary-dark: #7c3aed; --blue-bg: #251b47; --sidebar: #0a0618;
  --red-bg: #3b1214; --orange-bg: #3b2412; --green-bg: #0f2e1c; --yellow-bg: #332a10;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
:root[data-theme="forest"] {
  color-scheme: dark;
  --bg: #08120d; --card: #101f16; --text: #e4efe8; --muted: #8aa896; --border: #1e3629;
  --primary: #10b981; --primary-dark: #059669; --blue-bg: #123527; --sidebar: #050d09;
  --red-bg: #3b1214; --orange-bg: #3b2412; --green-bg: #0f2e1c; --yellow-bg: #332a10;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220; --card: #131c2e; --text: #e6eaf2; --muted: #8b94a7; --border: #243044;
  --primary: #3b82f6; --primary-dark: #2563eb; --blue-bg: #1e293b; --sidebar: #060b16;
  --red-bg: #3b1214; --orange-bg: #3b2412; --green-bg: #0f2e1c; --yellow-bg: #332a10;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
:root[data-mode="dark"] .detail-desc, :root[data-mode="dark"] .tabs,
:root[data-mode="dark"] .tg-code, :root[data-mode="dark"] .modal-close,
:root[data-mode="dark"] .asg-chip, :root[data-mode="dark"] .badge.s-new,
:root[data-mode="dark"] .badge.p-low { background: var(--blue-bg); }
:root[data-mode="dark"] .badge.s-new, :root[data-mode="dark"] .badge.p-low,
:root[data-mode="dark"] .asg-chip { color: var(--muted); }
:root[data-mode="dark"] .assignee-item:hover, :root[data-mode="dark"] table.data tr.clickable:hover { background: var(--blue-bg); }
:root[data-mode="dark"] .task-card.overdue-card { background: #2a1416; }
:root[data-mode="dark"] .dr-box, :root[data-mode="dark"] .review-box { background: #332a10; border-color: #665420; }
:root[data-mode="dark"] .radio-card.checked { background: var(--blue-bg); }
:root[data-mode="dark"] .form-row label { color: var(--text); }
:root[data-mode="dark"] .modal-close { color: #e6eaf2; }
:root[data-mode="dark"] .login-screen { background: linear-gradient(135deg, #0b1220, #000); }
:root[data-mode="dark"] .cal-cell.other { background: transparent; }
:root[data-mode="dark"] input, :root[data-mode="dark"] textarea, :root[data-mode="dark"] select { background-color: var(--blue-bg); color: var(--text); }
:root[data-mode="dark"] input::placeholder, :root[data-mode="dark"] textarea::placeholder { color: #6b7488; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
.hidden { display: none !important; }

/* ---------- Вход ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #111827);
}
.login-card {
  background: var(--card); border-radius: 16px; padding: 40px; width: 360px; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.login-logo { font-size: 40px; margin-bottom: 8px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--primary); }
.login-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- Каркас ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--sidebar); color: #d1d5db; display: flex; flex-direction: column;
  padding: 20px 12px; position: fixed; top: 0; bottom: 0; left: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 9px; padding: 2px 12px 24px; }
.logo-bolt { width: 22px; height: 22px; filter: drop-shadow(0 0 8px rgba(250, 204, 21, .5)); }
.logo-text {
  font-size: 20px; font-weight: 800; letter-spacing: .18em;
  background: linear-gradient(90deg, #ffffff 20%, #93c5fd);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 11px; text-align: left; background: none; border: none;
  color: #cbd2dd; padding: 11px 12px; border-radius: 10px; font-size: 14.5px; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: background .12s, color .12s;
}
.nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; transition: opacity .12s; }
.nav-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-btn:hover svg { opacity: 1; }
.nav-btn.active {
  background: var(--primary); color: #fff; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .28);
}
.nav-btn.active svg { opacity: 1; }
.login-brand {
  font-size: 30px !important; font-weight: 800; letter-spacing: .2em; margin-bottom: 4px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav-bottom { display: flex; flex-direction: column; margin-bottom: 8px; }
.nav-more { display: none; }  /* «Ещё» — только для нижней панели телефона */
.notif-badge {
  display: inline-block; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}
.notif-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--blue-bg); margin: 0 -10px; padding: 10px; border-radius: 8px; border-bottom: none; margin-bottom: 4px; }
.nav-btn.dragging { opacity: .4; }
.sidebar nav .nav-btn { position: relative; }
.sidebar nav .nav-btn::after {
  content: '≡'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 15px; opacity: 0; transition: opacity .15s; cursor: grab;
}
.sidebar nav .nav-btn:hover::after { opacity: .45; }
.sidebar nav .nav-btn:active::after { cursor: grabbing; }
.sidebar-user { border-top: 1px solid rgba(255, 255, 255, .1); padding: 14px 12px 0; }
.user-name { color: #fff; font-weight: 600; font-size: 14px; }
.user-role { font-size: 12.5px; color: #9ca3af; margin-bottom: 10px; }
.main { flex: 1; margin-left: 230px; padding: 28px 32px; max-width: 1200px; }

/* ---------- Общие элементы ---------- */
h2.page-title { font-size: 22px; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 9px;
  border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-success { background: var(--green-bg); color: var(--green); }
.btn-ghost { background: rgba(255, 255, 255, .1); color: #d1d5db; border: none; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.p-urgent { background: var(--red-bg); color: var(--red); }
.badge.p-high { background: var(--orange-bg); color: var(--orange); }
.badge.p-medium { background: var(--blue-bg); color: var(--primary); }
.badge.p-low { background: #f1f5f9; color: var(--muted); }
.badge.s-new { background: #f1f5f9; color: var(--muted); }
.badge.s-in_progress { background: var(--blue-bg); color: var(--primary); }
.badge.s-review { background: var(--yellow-bg); color: var(--yellow); }
.badge.s-done { background: var(--green-bg); color: var(--green); }
.badge.s-returned { background: var(--orange-bg); color: var(--orange); }
.badge.overdue { background: var(--red); color: #fff; }

.light { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.light.red { background: var(--red); box-shadow: 0 0 6px rgba(220, 38, 38, .5); }
.light.yellow { background: #eab308; }
.light.green { background: var(--green); }

/* ---------- Дашборд ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { padding: 16px 18px; }
.kpi .kpi-num { font-size: 28px; font-weight: 800; }
.kpi .kpi-label { font-size: 13px; color: var(--muted); }
.quote-banner {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; margin-bottom: 16px;
  font-size: 14px; border-left: 4px solid var(--primary); font-style: italic;
}
.quick-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.dep-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; align-items: start; }
.dep-stack { display: flex; flex-direction: column; gap: 8px; }
.dep-label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 0 8px; }
.traffic-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.traffic-card { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; font-size: 14px; }
.traffic-card:hover { border-color: var(--primary); }
.kpi.clickable { cursor: pointer; transition: border-color .1s; }
.kpi.clickable:hover { border-color: var(--primary); }
.kpi.red .kpi-num { color: var(--red); }
.kpi.yellow .kpi-num { color: var(--yellow); }
.kpi.green .kpi-num { color: var(--green); }

.section-title { font-size: 16px; font-weight: 700; margin: 24px 0 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover { background: #f8fafc; }
.num-red { color: var(--red); font-weight: 700; }
.num-green { color: var(--green); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Задачи ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
/* «+ Новая задача» и «Голосом» — рядом, отдельной строкой под фильтрами */
.toolbar-actions { display: flex; flex-direction: row; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: -8px; }
.toolbar-actions .btn { justify-content: center; min-height: 42px; }
.task-search { flex: 1 1 170px; min-width: 170px; max-width: 320px; }
.tabs { display: flex; gap: 4px; background: #e9edf3; padding: 4px; border-radius: 10px; }
.tab { border: none; background: none; padding: 7px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; font-family: inherit; }
.tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.spacer { flex: 1; }
select.filter, input.filter { font-size: 13.5px; }

.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card { padding: 14px 18px; cursor: pointer; display: flex; align-items: center; gap: 14px; transition: border-color .1s; }
.task-card:hover { border-color: var(--primary); }
.task-card.overdue-card { border-left: 4px solid var(--red); background: #fffafa; }
.task-card.soon-card { border-left: 4px solid #eab308; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.task-title a, .detail-desc a, .comment a, .note-text a, .review-box a { color: var(--primary); text-decoration: underline; }
/* длинные ссылки и слова не вылезают за рамки карточек */
.note-text, .detail-desc, .comment, .task-title, .review-box, .subtask-row, .asg-row, .notif-item, .quote-banner { overflow-wrap: anywhere; min-width: 0; }
.note-cat { overflow: hidden; }
.task-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.asg-chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.asg-chip { font-size: 11.5px; padding: 2px 8px; border-radius: 12px; background: #f1f5f9; color: var(--muted); }
.asg-chip.s-done { background: var(--green-bg); color: var(--green); }
.asg-chip.s-review { background: var(--yellow-bg); color: var(--yellow); }
.asg-chip.s-in_progress { background: var(--blue-bg); color: var(--primary); }
.asg-chip.s-returned { background: var(--orange-bg); color: var(--orange); }
.asg-chip.chip-overdue { background: var(--red); color: #fff; }

.week-empty { color: var(--muted); font-size: 13px; padding: 10px 14px; background: var(--card); border: 1px dashed var(--border); border-radius: 10px; }
.day-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.day-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.day-divider.past span { color: var(--red); }
.day-divider.today span { color: var(--primary); }

.meeting-card { padding: 14px 18px; display: flex; align-items: flex-start; gap: 14px; border-left: 4px solid #7c3aed; }

/* ---------- Голосовой ввод и темы ---------- */
.mic-btn {
  border: 1px solid var(--border); background: var(--card); border-radius: 9px; cursor: pointer;
  font-size: 15px; padding: 6px 10px; flex-shrink: 0;
}
.mic-btn:hover { border-color: var(--primary); }
.mic-btn.recording { background: var(--red); border-color: var(--red); animation: pulse-rec 1s infinite; }
@keyframes pulse-rec { 50% { opacity: .6; } }
.with-mic { display: flex; gap: 6px; align-items: flex-start; }
.with-mic input, .with-mic textarea { flex: 1; }
.collapse-btn { font-size: 11px; width: 18px; }
.theme-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.theme-swatch {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--card); cursor: pointer; font-size: 13.5px;
  font-weight: 600; color: var(--text); font-family: inherit;
}
.theme-swatch.active { border-color: var(--primary); background: var(--blue-bg); }
.theme-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.custom-colors { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.custom-color-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; }
.custom-color-item input[type=color] { width: 26px; height: 26px; border: none; padding: 0; background: none; cursor: pointer; }
.parent-search {
  width: 100%; padding: 8px 12px; margin-bottom: 6px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 13.5px; font-family: inherit; outline: none; background: var(--card); color: var(--text);
}
.parent-search:focus { border-color: var(--primary); }

/* ---------- Заметки ---------- */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.note-cat { padding: 14px 16px; }
.note-cat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.note-cat-head h4 { font-size: 15px; flex: 1; }
.note-count { font-size: 12px; background: var(--blue-bg); color: var(--primary); border-radius: 12px; padding: 1px 8px; font-weight: 700; }
.note-row { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.note-row:last-of-type { border-bottom: none; }
.note-row input[type=checkbox] { margin-top: 3px; }
.note-text { flex: 1; }
.note-row.done .note-text { text-decoration: line-through; color: var(--muted); }
.note-btn { border: none; background: none; cursor: pointer; font-size: 13px; opacity: .55; padding: 1px 3px; }
.note-btn:hover { opacity: 1; }
.note-add { display: flex; gap: 6px; margin-top: 8px; }
.note-add input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; font-family: inherit; outline: none; }
.note-add input:focus { border-color: var(--primary); }

/* ---------- Календарь ---------- */
.cal-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.cal-header h3 { font-size: 17px; min-width: 170px; text-align: center; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0; text-transform: uppercase; }
.cal-cell { background: var(--card); border: 1px solid var(--border); border-radius: 8px; min-height: 76px; padding: 6px; font-size: 12px; }
.cal-count { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 7px; margin: 0 3px 3px 0; background: var(--blue-bg); color: var(--primary); }
.cal-count.overdue { background: var(--red); color: #fff; }
.cal-ico { display: none; }  /* значок вместо слова — только на телефоне */
.cal-count.done { background: var(--green-bg); color: var(--green); }
.cal-count.meeting { background: #f3e8ff; color: #7c3aed; }
.cal-count.recur { background: #e0f2fe; color: #0369a1; }
.day-time.recur-time { background: #e0f2fe; color: #0369a1; }
.day-time {
  display: inline-block; min-width: 64px; text-align: center; font-weight: 700; font-size: 13px;
  background: var(--blue-bg); color: var(--primary); border-radius: 8px; padding: 4px 8px; flex-shrink: 0;
}
.day-time.late { background: var(--red); color: #fff; }
.day-time.meeting-time { background: #f3e8ff; color: #7c3aed; }
.cal-cell.other { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--primary); border-width: 2px; }
.cal-cell.clickable-day { cursor: pointer; }
.cal-cell.clickable-day:hover { border-color: var(--primary); }
.cal-day-num { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.cal-task { padding: 2px 6px; border-radius: 5px; margin-bottom: 3px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--blue-bg); color: var(--primary); }
.cal-task.done { background: var(--green-bg); color: var(--green); text-decoration: line-through; }
.cal-task.overdue { background: var(--red); color: #fff; }
.cal-task.review { background: var(--yellow-bg); color: var(--yellow); }
.cal-task.meeting { background: #f3e8ff; color: #7c3aed; font-weight: 600; }

/* ---------- Команда ---------- */
.tree-node { padding: 10px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.tree-node:last-child { border-bottom: none; }
.tree-indent-1 { padding-left: 40px; }
.tree-indent-2 { padding-left: 66px; }
.tree-indent-3 { padding-left: 92px; }
.tree-indent-4 { padding-left: 118px; }
.tree-name { font-weight: 600; }
.tree-login { color: var(--muted); font-size: 12.5px; }
.inactive { opacity: .45; }

/* ---------- Модальные окна ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .55); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 640px; padding: 26px 28px; box-shadow: 0 24px 80px rgba(0, 0, 0, .35); }
.modal h3 { font-size: 19px; margin-bottom: 16px; }
.modal-close { float: right; border: none; background: #f1f5f9; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.form-row input[type=text], .form-row input[type=password], .form-row input[type=datetime-local],
.form-row textarea, .form-row select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; font-family: inherit; outline: none; background-color: var(--card);
}
.form-row textarea { resize: vertical; min-height: 70px; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.radio-row { display: flex; gap: 10px; }
.radio-card { flex: 1; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 13.5px; }
.radio-card input { margin-right: 6px; }
.radio-card.checked { border-color: var(--primary); background: var(--blue-bg); }
.assignee-list { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; padding: 6px; }
.assignee-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.assignee-item:hover { background: #f8fafc; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- Карточка задачи ---------- */
.task-detail-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.detail-desc { background: #f8fafc; border-radius: 10px; padding: 12px 14px; margin: 12px 0; font-size: 14px; white-space: pre-wrap; }
.detail-meta { font-size: 13px; color: var(--muted); display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 6px; }
.asg-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.asg-row:last-child { border-bottom: none; }
.subtask-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 6px; cursor: pointer; font-size: 13.5px; }
.subtask-row:hover { border-color: var(--primary); }
.comment { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.comment:last-child { border-bottom: none; }
.comment-head { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.comment-head b { color: var(--text); }
.activity-item { font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; font-family: inherit; outline: none; }
.dr-box { background: var(--yellow-bg); border: 1px solid #fde68a; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-size: 13.5px; }

.review-box { background: var(--yellow-bg); border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; font-size: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff; padding: 12px 20px;
  border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
}

/* ---------- Настройки ---------- */
.settings-card { padding: 20px 22px; margin-bottom: 16px; max-width: 640px; }
.settings-card h4 { font-size: 15.5px; margin-bottom: 6px; }
.tg-code { font-size: 20px; font-weight: 800; letter-spacing: .05em; background: #f1f5f9; padding: 8px 16px; border-radius: 8px; display: inline-block; margin: 8px 0; }

/* ---------- Свой календарь PULSE ---------- */
.dtp { display: inline-flex; min-width: 170px; }
.dtp-view { cursor: pointer; width: 100%; }
.dtp-pop {
  position: fixed; z-index: 300; width: 306px; background: var(--card);
  border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
}
.dtp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14.5px; }
.dtp-nav {
  border: 1px solid var(--border); background: var(--card); color: var(--text); width: 30px; height: 30px;
  border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
}
.dtp-nav:hover { border-color: var(--primary); color: var(--primary); }
.dtp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.dtp-dow { text-align: center; font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 3px 0; }
.dtp-day {
  border: none; background: none; color: var(--text); font-family: inherit; font-size: 13px;
  height: 32px; border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.dtp-day:hover { background: var(--blue-bg); color: var(--primary); }
.dtp-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); }
.dtp-day.sel { background: var(--primary); color: #fff; font-weight: 700; }
.dtp-foot { display: flex; align-items: center; gap: 4px; margin-top: 12px; font-size: 14px; }
.dtp-foot select { padding: 6px 22px 6px 8px; font-size: 13.5px; background-position: right 6px center; }
.dtp-foot .btn { padding: 5px 9px; white-space: nowrap; flex-shrink: 0; }

/* ---------- Единый стиль контролов: селекты, поля, даты ---------- */
:root { color-scheme: light; }
* { accent-color: var(--primary); }
input[type="text"], input[type="password"], input[type="date"], input[type="datetime-local"], textarea, select {
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236b7488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="date"], input[type="datetime-local"], .day-time, .kpi-num, .cal-day-num, table.data td { font-variant-numeric: tabular-nums; }
::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; }
::-webkit-calendar-picker-indicator:hover { opacity: 1; }
:root[data-mode="dark"] ::-webkit-calendar-picker-indicator { filter: invert(1); }
select.filter, input.filter { padding-top: 9px; padding-bottom: 9px; }

/* ---------- Планшеты и всё, чем пользуются пальцем ---------- */
@media (max-width: 1024px) {
  .btn { min-height: 42px; }
  .btn-sm { padding: 9px 13px; font-size: 13.5px; min-height: 40px; }
  .note-btn { font-size: 17px; padding: 8px 10px; min-width: 40px; min-height: 40px; opacity: .8; }
  .tab { min-height: 44px; padding: 11px 14px; }
  .theme-swatch { min-height: 44px; }
  /* 16px обязательны: при меньшем шрифте iOS зумит страницу на каждом поле */
  select, input, textarea,
  .form-row input[type=text], .form-row input[type=password], .form-row textarea, .form-row select,
  select.filter, input.filter, .note-add input, .comment-form input, .dtp-foot select,
  .login-card input, .parent-search { font-size: 16px; min-height: 44px; }
  textarea, .form-row textarea { min-height: 84px; }
  .dtp-day { height: 40px; font-size: 14px; }
  .dtp-nav { width: 40px; height: 40px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 20px; }
  .assignee-item { padding: 11px 10px; }
  /* широкие таблицы прокручиваются внутри себя, а не растягивают страницу */
  table.data { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-cell { min-width: 0; overflow: hidden; }
  /* min-width:0 — иначе широкая таблица распирает колонку контента за экран */
  .main { max-width: calc(100vw - 230px); min-width: 0; }
}

@media (max-width: 800px) {
  /* мобильный режим: меню становится нижней панелью, как в приложениях */
  .app { flex-direction: column; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: 100%;
    flex-direction: row; align-items: center; padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    z-index: 40; box-shadow: 0 -4px 16px rgba(0, 0, 0, .25);
  }
  .sidebar-logo, .sidebar-user { display: none; }
  .sidebar nav { flex-direction: row; flex: 1; gap: 0; justify-content: space-around; }
  .nav-bottom { flex-direction: row; margin-bottom: 0; }
  .sidebar nav .nav-btn::after { display: none; }
  /* нижняя панель: все разделы в два ряда по 5 — ничего не спрятано, кнопки крупные */
  .sidebar { flex-wrap: wrap; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .sidebar nav, .nav-bottom { display: contents; }
  .nav-more { display: none !important; }
  .nav-btn {
    flex: 0 0 20%; max-width: 20%; min-width: 0; min-height: 60px;
    padding: 8px 2px; border-radius: 12px; flex-direction: column; justify-content: center;
    align-items: center; gap: 4px; text-align: center;
  }
  .nav-btn svg { width: 23px; height: 23px; }
  .nav-btn span { display: block; font-size: 10px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .notif-badge { position: absolute; top: 4px; right: 50%; margin-right: -22px; margin-left: 0; font-size: 10px; padding: 0 5px; }
  .nav-btn { position: relative; }

  /* пальцу нужно минимум 40 px: увеличиваем все мелкие кнопки */
  .note-btn { font-size: 17px; padding: 8px 10px; min-width: 40px; min-height: 40px; opacity: .8; }
  .btn-sm { padding: 9px 13px; font-size: 13.5px; min-height: 40px; }
  .btn { min-height: 42px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .assignee-item { padding: 11px 10px; }
  .tab { min-height: 44px; padding: 11px 14px; font-size: 13.5px; }
  .tabs { flex-wrap: wrap; gap: 4px; }
  select.filter, .filter { min-height: 44px; font-size: 14px; }
  input, textarea, select { font-size: 16px; }   /* меньше 16px — iOS зумит страницу при фокусе */

  /* таблицы (рейтинг, команда) прокручиваются пальцем, а не ломают страницу */
  table.data { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  table.data th, table.data td { padding: 10px 10px; }

  /* модальные окна — как шторка снизу, во весь экран */
  .modal-overlay { align-items: flex-end; padding: 0; overflow: hidden; }
  .modal { width: 100%; max-width: 100%; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
           border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; }
  .radio-row { flex-direction: column; }            /* «Общая / Индивидуальная / Себе» — в столбик */
  .radio-card { width: 100%; min-height: 52px; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dep-cols { grid-template-columns: 1fr; }
  .quick-chips .btn { flex: 0 0 auto; }
  .main { margin-left: 0; padding: 16px 12px 156px; max-width: 100vw; overflow-x: hidden; }
  .card { overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  /* календарь целиком влезает в экран: колонки могут сжиматься, счётчики переносятся */
  .cal-grid { gap: 2px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-cell { min-height: 58px; padding: 2px; font-size: 10px; min-width: 0; overflow: hidden; }
  .cal-day-num { font-size: 11px; margin-bottom: 2px; }
  .cal-count { font-size: 11px; padding: 1px 5px; margin: 0 1px 2px 0; max-width: 100%; white-space: nowrap; }
  .cal-word { display: none; }        /* на телефоне вместо «2 собрания» — «2 🤝» */
  .cal-ico { display: inline; }
  .cal-dow { font-size: 10px; padding: 2px 0; }
  .card:has(.cal-grid) { overflow-x: hidden; }
  .spacer { display: none; }          /* иначе кнопки уезжают за правый край экрана */
  .toolbar, .cal-header { justify-content: flex-start; flex-wrap: wrap; }
  table.data { font-size: 12.5px; }
  table.data th, table.data td { padding: 8px 8px; }
  .modal { padding: 18px 16px; }
  .modal-overlay { padding: 12px 8px; }
  .toolbar { gap: 8px; }
  .notes-grid { grid-template-columns: 1fr; }
}

/* Справка */
.help-sec { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; max-width: 760px; }
.help-sec summary { cursor: pointer; padding: 13px 16px; font-weight: 600; font-size: 14.5px; list-style: none; display: flex; align-items: center; gap: 4px; user-select: none; }
.help-sec summary::before { content: '▸'; color: var(--muted); margin-right: 6px; transition: transform .15s; }
.help-sec[open] summary::before { transform: rotate(90deg); }
.help-sec summary::-webkit-details-marker { display: none; }
.help-body { padding: 0 18px 14px; font-size: 14px; line-height: 1.65; }
.help-body p { margin: 6px 0; }
.help-body ol, .help-body ul { margin: 6px 0; padding-left: 20px; }
.help-body li { margin-bottom: 7px; }
.help-boss-title { margin: 22px 0 10px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Итоги собрания */
.meeting-summary {
  margin-top: 8px; padding: 8px 11px; font-size: 13px; line-height: 1.55;
  background: var(--blue-bg); border-left: 3px solid var(--primary); border-radius: 8px;
  overflow-wrap: anywhere;
}

/* Выходные и праздники в календаре — видно на любом устройстве */
/* выходные и праздники — в цвет левой колонки, чтобы читалось как единая система */
.cal-cell.dayoff { background: var(--sidebar); border-color: var(--sidebar); }
.cal-cell.dayoff .cal-day-num { color: #ffffff; }
.cal-holiday {
  font-size: 9.5px; line-height: 1.15; font-weight: 600; color: #cbd2dd;
  margin-bottom: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cal-cell.dayoff.today { border-color: var(--primary); }
.dtp-day.dtp-off { color: var(--sidebar); font-weight: 700; }
:root[data-mode="dark"] .dtp-day.dtp-off { color: #93a3bd; }

/* Свои выпадающие списки вместо системных — единый стиль на всех устройствах */
.sel-wrap { position: relative; display: block; }
.sel-wrap select {
  position: absolute; opacity: 0; pointer-events: none;
  width: 100%; height: 100%; left: 0; top: 0; margin: 0;
}
.sel-btn {
  width: 100%; text-align: left; font-family: inherit; font-size: 14.5px; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 34px 10px 12px; cursor: pointer; position: relative;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 42px;
}
.sel-btn::after {
  content: ''; position: absolute; right: 12px; top: 50%; width: 9px; height: 9px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
}
.sel-btn:hover { border-color: var(--primary); }
.sel-btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 1px; }
.sel-btn.filter { font-size: 13.5px; padding: 8px 30px 8px 11px; min-height: 38px; }
.sel-btn:disabled { opacity: .55; cursor: not-allowed; }

.sel-pop {
  position: fixed; z-index: 400; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 16px 48px rgba(0, 0, 0, .22); padding: 6px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sel-search {
  width: 100%; margin-bottom: 6px; padding: 9px 11px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); outline: none;
}
.sel-list { display: flex; flex-direction: column; gap: 1px; }
.sel-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; font-family: inherit; font-size: 14.5px; color: var(--text);
  padding: 10px 10px; border-radius: 8px; cursor: pointer; min-height: 42px; line-height: 1.25;
}
.sel-opt:hover { background: var(--blue-bg); color: var(--primary); }
.sel-opt.sel { background: var(--blue-bg); color: var(--primary); font-weight: 600; }
.sel-check { width: 14px; flex-shrink: 0; color: var(--primary); font-size: 13px; }
