/* Корпоративная тема трекера задач. Самодостаточна, без внешних зависимостей. */

:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --border: #d8dde4;
  --text: #202634;
  --muted: #69707d;
  --accent: #2f5da8;
  --accent-hover: #274e8d;
  --accent-soft: #e8eef7;
  --danger: #b3392f;
  --danger-soft: #f7e9e8;
  --ok: #2e7d4f;
  --ok-soft: #e7f2ec;
  --warn: #9a6700;
  --warn-soft: #f8efdc;
  --sidebar-bg: #222937;
  --sidebar-text: #c7cdd8;
  --sidebar-active: #2f5da8;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 34, 0.05), 0 4px 18px rgba(20, 24, 34, 0.06);
  --font: "Inter", "Roboto", -apple-system, "Segoe UI", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #151922;
  --panel: #1d232e;
  --border: #323a48;
  --text: #e3e7ee;
  --muted: #8b93a3;
  --accent: #5d8cd4;
  --accent-hover: #6f9ade;
  --accent-soft: #26334a;
  --danger: #d06157;
  --danger-soft: #3a2624;
  --ok: #5aa87e;
  --ok-soft: #22332a;
  --warn: #cfa14a;
  --warn-soft: #37301f;
  --sidebar-bg: #10141c;
  --sidebar-text: #a7aebc;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 20px; margin: 0; font-weight: 600; }
h2 { font-size: 14px; margin: 0 0 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.muted { color: var(--muted); font-weight: 400; }

/* --- Каркас --- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-logo { max-height: 32px; max-width: 140px; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.brand-name { color: #fff; font-weight: 600; }

.nav { display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; flex: 1; }

.nav a {
  color: var(--sidebar-text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-weight: 500;
}

.nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: #fff; }

.nav-section {
  margin: 14px 12px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.35);
}

.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.user-name { color: #fff; font-weight: 500; }
.user-role { font-size: 12px; color: rgba(255, 255, 255, 0.45); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-spacer { flex: 1; }
.topbar-user { color: var(--muted); }
.inline-form { display: inline; }

.content { padding: 24px; max-width: 1200px; width: 100%; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* --- Карточки и таблицы --- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}

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

.table-wrap { padding: 0; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--accent-soft); }

.task-link { font-weight: 500; }
.row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }

/* --- Кнопки --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--accent); border-color: transparent; }

.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 10px; font-size: 15px; line-height: 1; }

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* --- Система SVG-иконок (mask + currentColor, без эмодзи) --- */

.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  vertical-align: -3px;
}

.icon-xs { width: 11px; height: 11px; vertical-align: -1px; }

.icon-menu { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 4.2h12M2 8h12M2 11.8h12' stroke='black' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E"); }

.icon-bell { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.6a4.3 4.3 0 0 0-4.3 4.3v2.5L2.3 10.8a.75.75 0 0 0 .63 1.15h10.14a.75.75 0 0 0 .63-1.15l-1.4-2.4V5.9A4.3 4.3 0 0 0 8 1.6z' fill='black'/%3E%3Cpath d='M6.3 13.2a1.75 1.75 0 0 0 3.4 0z' fill='black'/%3E%3C/svg%3E"); }

.icon-sun { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='3.1' fill='black'/%3E%3Cpath d='M8 1.2v1.9M8 12.9v1.9M1.2 8h1.9M12.9 8h1.9M3.2 3.2l1.35 1.35M11.45 11.45l1.35 1.35M12.8 3.2l-1.35 1.35M4.55 11.45L3.2 12.8' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); }

.icon-moon { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M13.6 9.8A6.2 6.2 0 0 1 6.2 2.4a6.2 6.2 0 1 0 7.4 7.4z' fill='black'/%3E%3C/svg%3E"); }

.icon-x { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 3.5l9 9m0-9l-9 9' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); }

.icon-chev-l { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M10 3L5 8l5 5' stroke='black' stroke-width='1.9' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

.icon-chev-r { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3l5 5-5 5' stroke='black' stroke-width='1.9' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* --- Бейджи статусов и приоритетов --- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-new { background: var(--accent-soft); color: var(--accent); }
.badge-in_progress { background: var(--warn-soft); color: var(--warn); }
.badge-done { background: var(--ok-soft); color: var(--ok); }
.badge-closed { background: var(--border); color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--danger-soft); color: var(--danger); }

.prio { font-weight: 600; font-size: 13px; white-space: nowrap; }
.prio-low { color: var(--muted); }
.prio-normal { color: var(--text); }
.prio-high { color: var(--warn); }
.prio-critical { color: var(--danger); }

/* --- Формы --- */

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label, .form-row legend { font-weight: 500; font-size: 13px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 18px;
}

input[type="text"], input[type="password"], input[type="email"],
input[type="date"], input[type="file"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[readonly] { color: var(--muted); }
textarea { resize: vertical; }

fieldset.form-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }

.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-weight: 500; cursor: pointer; }
.check input { width: auto; }

.form-actions { display: flex; gap: 10px; margin-top: 16px; }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid transparent;
  font-weight: 500;
}

.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }

/* --- Конструктор динамических полей --- */

.cf-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1.2fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}

#tpl-fields .cf-row { grid-template-columns: 1.2fr 1fr 1.2fr 1fr auto; }

/* --- Автодополнение --- */

.autocomplete { position: relative; }

.ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(20, 24, 34, 0.18);
  max-height: 260px;
  overflow-y: auto;
}

.ac-item { padding: 9px 12px; cursor: pointer; }
.ac-item:hover, .ac-item.hover { background: var(--accent-soft); }
.ac-item small { display: block; color: var(--muted); }
.ac-empty { padding: 9px 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 500;
}

.chip button {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  line-height: 1;
}

/* --- Карточка задачи --- */

.task-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

.task-desc { white-space: pre-wrap; line-height: 1.55; margin-bottom: 8px; }

.fields-list { margin: 0; }
.fields-list div { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.fields-list div:last-child { border-bottom: none; }
.fields-list dt { width: 40%; color: var(--muted); }
.fields-list dd { margin: 0; flex: 1; }

.prop { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.prop:last-child { border-bottom: none; }
.prop > span:first-child { color: var(--muted); }
.prop > span:last-child { text-align: right; }

.status-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.status-form { display: inline; }

.files-list, .comments, .history { list-style: none; margin: 0 0 12px; padding: 0; }
.files-list li { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.files-list li:last-child { border-bottom: none; }

.comments li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comments li:last-child { border-bottom: none; }
.comment-head { margin-bottom: 4px; }
.comment-body { white-space: pre-wrap; line-height: 1.5; }
.comment-form textarea { margin-bottom: 8px; }

.history li { padding: 8px 0; border-bottom: 1px dashed var(--border); line-height: 1.45; }
.history li:last-child { border-bottom: none; }

.attach-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.attach-form input[type="file"] { flex: 1; min-width: 200px; }

/* --- Страница входа --- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card { width: 100%; max-width: 380px; padding: 28px; }

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand h1 { font-size: 18px; }
.auth-note { margin-top: 16px; font-size: 12px; }

/* --- Страница ошибки --- */

.error-card { max-width: 420px; margin: 60px auto; text-align: center; padding: 40px; }
.error-code { font-size: 48px; font-weight: 700; color: var(--muted); }
.error-message { margin: 12px 0 24px; }

/* --- Настройки --- */

.settings-form .card { margin-bottom: 18px; }
.logo-preview { max-height: 48px; }
.save-tpl input[type="text"] { max-width: 320px; margin-top: 8px; }

/* --- Вкладки (список / календарь) --- */

.page-head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.tab { padding: 7px 14px; color: var(--muted); font-weight: 500; }
.tab:hover { text-decoration: none; color: var(--accent); }
.tab.active { background: var(--accent); color: #fff; }
.tab + .tab { border-left: 1px solid var(--border); }

/* --- Календарь задач --- */

.cal-card { padding: 14px; }

.cal-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-title { font-size: 16px; font-weight: 600; flex: 1; text-align: center; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cal-head {
  margin-bottom: 4px;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.cal-wknd { color: var(--danger); opacity: 0.7; }

.cal-week { margin-bottom: 4px; }

.cal-day {
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.cal-day.out { opacity: 0.45; background: var(--bg); }

.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.today .cal-date { color: var(--accent); font-weight: 700; }

.cal-date { font-size: 12px; color: var(--muted); }

.cal-tasks { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }

.cal-task {
  display: block;
  font-size: 11.5px;
  line-height: 1.3;
  padding: 2px 6px 2px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--text);
  border-left: 3px solid var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-task:hover { text-decoration: none; filter: brightness(0.96); }
.cal-task.p-low { border-left-color: var(--muted); }
.cal-task.p-normal { border-left-color: var(--accent); }
.cal-task.p-high { border-left-color: var(--warn); background: var(--warn-soft); }
.cal-task.p-critical { border-left-color: var(--danger); background: var(--danger-soft); }
.cal-task.done { opacity: 0.55; text-decoration: line-through; }

.cal-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.cal-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: -1px;
}

.dot.p-low { background: var(--muted); }
.dot.p-normal { background: var(--accent); }
.dot.p-high { background: var(--warn); }
.dot.p-critical { background: var(--danger); }

.undated-list { list-style: none; margin: 0; padding: 0; }
.undated-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.undated-list li:last-child { border-bottom: none; }

/* --- Редактор оформления --- */

.style-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }

#custom-css {
  font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  tab-size: 2;
}

.hint summary { cursor: pointer; font-weight: 500; color: var(--accent); margin-bottom: 8px; }

.hint-pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
  overflow-x: auto;
}

.preview-widgets > * { margin-bottom: 14px; }

/* --- Уведомления --- */

.notif-wrap { position: relative; }

.notif-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 28px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(20, 24, 34, 0.25);
  z-index: 60;
  overflow: hidden;
}

.notif-head {
  padding: 10px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.notif-list { max-height: 380px; overflow-y: auto; }

.notif-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--accent-soft); text-decoration: none; }
.notif-item.unread { border-left: 3px solid var(--accent); background: var(--accent-soft); }

.notif-msg { font-size: 13px; line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 3px; }
.notif-empty { padding: 18px 14px; color: var(--muted); text-align: center; }

/* --- Мобильное меню --- */

.menu-btn { display: none; font-size: 18px; }

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.5);
  z-index: 45;
}

#sidebar-overlay.visible { display: block; }

/* ============================================================
   Полировка: анимации, спиннеры, улучшенные поля и списки
   ============================================================ */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes progressGrow {
  0% { width: 0; }
  60% { width: 70%; }
  100% { width: 88%; }
}

/* Плавная смена темы. */
body, .card, .sidebar, .topbar, .table td, .table th,
input, select, textarea, .btn, .badge, .cal-day, .notif-dropdown {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.15s ease;
}

/* Появление контента. */
.card { animation: fadeUp 0.3s ease both; }
.alert { animation: slideDown 0.25s ease both; }
.table tbody tr { animation: fadeUp 0.3s ease both; }
.table tbody tr:nth-child(1) { animation-delay: 0.02s; }
.table tbody tr:nth-child(2) { animation-delay: 0.05s; }
.table tbody tr:nth-child(3) { animation-delay: 0.08s; }
.table tbody tr:nth-child(4) { animation-delay: 0.11s; }
.table tbody tr:nth-child(5) { animation-delay: 0.14s; }
.table tbody tr:nth-child(6) { animation-delay: 0.17s; }
.table tbody tr:nth-child(7) { animation-delay: 0.2s; }
.table tbody tr:nth-child(n+8) { animation-delay: 0.23s; }

/* Кнопки: живой отклик. */
.btn {
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(20, 24, 34, 0.12); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-ghost:hover, .btn-icon:hover { box-shadow: none; }

/* Спиннеры. */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -3px;
}

.spinner-sm { width: 12px; height: 12px; border-width: 2px; }

.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 15px;
  height: 15px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn-primary.loading::after, .btn-danger.loading::after { border-color: #fff; border-right-color: transparent; }

/* Прогресс-бар навигации. */
.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 0 2px 2px 0;
}
.page-progress.active { opacity: 1; animation: progressGrow 1.4s ease-out forwards; }

/* Поля ввода: мягкий фокус и наведение. */
input[type="text"], input[type="password"], input[type="email"],
input[type="date"], select, textarea {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.25s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
::placeholder { color: var(--muted); opacity: 0.7; }

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Селекты с собственной стрелкой. */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2369707d' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Файловый input. */
input[type="file"] { border-style: dashed; cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 500;
  padding: 6px 12px;
  margin-right: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

/* Аватары. */
.avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}

.avatar-sm { width: 26px; height: 26px; font-size: 10px; margin-right: 8px; vertical-align: middle; }
.topbar-user { display: inline-flex; align-items: center; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; }

/* Комментарии-«пузыри». */
.comments li.comment { display: flex; gap: 10px; border-bottom: none; padding: 8px 0; }
.comment-content {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-top-left-radius: 3px;
  padding: 9px 13px;
  animation: fadeUp 0.3s ease both;
}
.comment-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }

/* История — таймлайн. */
.history { position: relative; padding-left: 20px; }
.history::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}
.history li { position: relative; border-bottom: none; padding: 6px 0 10px; }
.history li::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.history li:first-child::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* Файлы. */
.files-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-radius: var(--radius); padding: 7px 6px; transition: background-color 0.15s ease; }
.files-list li:hover { background: var(--accent-soft); }
.files-list li::before {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.6 7.2l-4.4 4.4a2.6 2.6 0 0 1-3.7-3.7l5.3-5.3a1.9 1.9 0 0 1 2.7 2.7L6.3 10.5a1 1 0 0 1-1.4-1.4l4.4-4.4' stroke='black' stroke-width='1.3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.6 7.2l-4.4 4.4a2.6 2.6 0 0 1-3.7-3.7l5.3-5.3a1.9 1.9 0 0 1 2.7 2.7L6.3 10.5a1 1 0 0 1-1.4-1.4l4.4-4.4' stroke='black' stroke-width='1.3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Свойства задачи. */
.prop { transition: background-color 0.15s ease; border-radius: 4px; }
.prop:hover { background: var(--bg); }

/* Пустые состояния. */
.card.empty::before {
  content: "";
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  background: var(--muted);
  opacity: 0.5;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 4A1.5 1.5 0 0 1 3 2.5h3l1.5 2H13A1.5 1.5 0 0 1 14.5 6v6A1.5 1.5 0 0 1 13 13.5H3A1.5 1.5 0 0 1 1.5 12V4z' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 4A1.5 1.5 0 0 1 3 2.5h3l1.5 2H13A1.5 1.5 0 0 1 14.5 6v6A1.5 1.5 0 0 1 13 13.5H3A1.5 1.5 0 0 1 1.5 12V4z' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Выпадающие списки и автодополнение. */
.ac-list, .notif-dropdown { animation: slideDown 0.16s ease both; }
.ac-item { transition: background-color 0.12s ease; }

/* Календарь. */
.cal-day { transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.cal-day:hover { border-color: var(--accent); }
.cal-task { transition: transform 0.12s ease, filter 0.12s ease; }
.cal-task:hover { transform: translateX(2px); }

/* Навигация. */
.nav a { transition: background-color 0.15s ease, color 0.15s ease, padding-left 0.18s ease; }
.nav a:hover { padding-left: 16px; }

/* Сортируемые заголовки таблицы. */
.table th a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--accent); text-decoration: none; }
.table th a.sorted { color: var(--accent); }
.sort-icon { font-size: 9px; }

/* --- Красивые карточки и общий облик --- */

h1 { font-size: 22px; letter-spacing: -0.015em; }

.card {
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, background-color 0.25s ease, border-color 0.25s ease;
}

.card > h2:first-child {
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.card > h2:first-child::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 44px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.table-wrap.card { padding: 0; }

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg), color-mix(in srgb, var(--sidebar-bg) 72%, #000));
}

.nav a.active {
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.45), 0 2px 10px rgba(0, 0, 0, 0.25);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  backdrop-filter: blur(10px) saturate(1.4);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  background: color-mix(in srgb, var(--panel) 86%, transparent);
}

.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent));
  border-color: var(--accent);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--accent) 40%, transparent);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent), var(--accent-hover));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent);
}

.badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 6px;
  vertical-align: 1.5px;
}

.table thead th {
  background: color-mix(in srgb, var(--bg) 55%, var(--panel));
}

.status-form .btn::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3l5 5-5 5' stroke='black' stroke-width='2.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3l5 5-5 5' stroke='black' stroke-width='2.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.chip button { display: inline-flex; align-items: center; }

/* --- Конструктор темы --- */

.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }

.preset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.preset:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }

.preset-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 18px;
  margin: 16px 0;
}

.picker label { font-size: 12.5px; font-weight: 500; display: block; margin-bottom: 6px; }
.picker-ctl { display: flex; align-items: center; gap: 10px; }
.picker-hex { font-size: 12px; color: var(--muted); }

input[type="color"] {
  width: 46px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
input[type="color"]:hover { border-color: var(--accent); transform: scale(1.04); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: calc(var(--radius) - 3px); }

input[type="range"] { accent-color: var(--accent); width: 100%; cursor: pointer; }

/* Уважение к reduce-motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Адаптивность: десктоп → планшет → смартфон --- */

@media (max-width: 1000px) {
  .task-grid { grid-template-columns: 1fr; }
  .cf-row, #tpl-fields .cf-row { grid-template-columns: 1fr 1fr; }
  .style-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -260px;
    width: 248px;
    z-index: 50;
    transition: left 0.25s ease;
    box-shadow: none;
  }

  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35); }

  .main { width: 100%; }
  .content { padding: 14px; }
  .topbar { padding: 8px 14px; }
  .topbar-user { display: none; }
  .page-head h1 { font-size: 18px; }
}

@media (max-width: 680px) {
  /* Таблицы превращаются в карточки. */
  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tr {
    display: block;
    border-bottom: 2px solid var(--border);
    padding: 8px 0;
  }
  .table tr:last-child { border-bottom: none; }
  .table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    border: none;
    padding: 4px 14px;
    text-align: right;
  }
  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    flex-shrink: 0;
    text-align: left;
  }
  .table td:not([data-label])::before { content: none; }
  .table td.row-actions { justify-content: flex-end; }

  /* Компактный календарь: точки вместо подписей. */
  .cal-day { min-height: 52px; padding: 3px; }
  .cal-tasks { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .cal-task {
    width: 9px;
    height: 9px;
    padding: 0;
    border-radius: 50%;
    border-left: none;
    background: var(--accent);
    font-size: 0;
  }
  .cal-task.p-low { background: var(--muted); }
  .cal-task.p-high { background: var(--warn); }
  .cal-task.p-critical { background: var(--danger); }
  .cal-task.done { opacity: 0.4; }

  .cf-row, #tpl-fields .cf-row { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
  .page-head-actions { width: 100%; justify-content: space-between; }
  .attach-form input[type="file"] { min-width: 0; }
}
