/*
  Мотивация — оформление в стиле kasanie CRM (все экраны).
  Источник токенов: kasanie CRM app/globals.css и ui-foundations.css.
  Правила вне @layer перебивают Tailwind v4 без !important.
*/

/* Medeo Sans 1.0.0-rc.3, SIL OFL 1.1 (fonts/medeo/LICENSE.txt) — те же файлы, что в kasanie CRM. */
@font-face {
  font-family: "Medeo Sans";
  src: url("./fonts/medeo/MedeoSansVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Medeo Sans";
  src: url("./fonts/medeo/MedeoSansVariable-Italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* ── Палитра и шрифт: перекрашиваем переменные Tailwind ──────────────────── */
:root {
  --font-sans: "Medeo Sans", "Segoe UI", Arial, sans-serif;

  --color-slate-50: #f6f8fb;
  --color-slate-100: #f2f5fa;
  --color-slate-200: #e7ebf2;
  --color-slate-300: #dce3ee;
  --color-slate-400: #8794aa;
  --color-slate-500: #66758d;
  --color-slate-600: #4f5f78;
  --color-slate-700: #34445e;
  --color-slate-900: #233047;
  --color-slate-950: #233047;

  --color-indigo-50: #edf3ff;
  --color-indigo-100: #dfe9ff;
  --color-indigo-200: #c4d6ff;
  --color-indigo-300: #9dbaff;
  --color-indigo-400: #6f97f5;
  --color-indigo-500: #3268e8;
  --color-indigo-600: #2f62d5;
  --color-indigo-700: #2853b8;

  --color-rose-600: #bd4449;
  --color-rose-700: #a53a3f;

  --mz-sidebar: #192337;
  --mz-sidebar-fg: #c3ccdc;
  --mz-sidebar-muted: #99a7bf;
  --mz-sidebar-hover: #293b5a;
  --mz-sidebar-active: #2a3e62;
  --mz-sidebar-border: #2c374c;
  --mz-primary: #3268e8;
  --mz-border: #e7ebf2;
  --mz-fg: #233047;
  --mz-sidebar-w: 232px;
}

html,
body,
button,
input,
select,
textarea {
  font-family: var(--font-sans);
}
html,
body {
  color: var(--mz-fg);
  -webkit-font-smoothing: antialiased;
}

/* ── Вес и форма: спокойнее, как в CRM ─────────────────────────────────── */
.font-black { font-weight: 650; letter-spacing: -0.01em; }
.font-bold { font-weight: 600; }
.font-semibold { font-weight: 500; }
.tracking-tight { letter-spacing: -0.01em; }
.uppercase.tracking-wide { letter-spacing: 0.04em; }

.rounded-3xl { border-radius: 12px; }
.rounded-2xl { border-radius: 8px; }
.rounded-xl { border-radius: 8px; }
.shadow-sm { box-shadow: none; }

/* карточки: белые, с тонкой рамкой вместо тени */
.rounded-3xl.bg-white {
  border: 1px solid var(--mz-border);
}

button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 2px solid var(--mz-primary);
  outline-offset: 2px;
}

/* ── Боковая панель: тёмно-синяя, как в CRM ─────────────────────────────── */
aside.fixed {
  width: var(--mz-sidebar-w);
  padding: 22px 12px;
  background: var(--mz-sidebar);
  border-right: 0;
  color: var(--mz-sidebar-fg);
  overflow-y: auto;
}
aside.fixed > div:first-child {
  margin: 0 4px 24px;
  gap: 10px;
}
aside.fixed > div:first-child > div:first-child {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 11px;
  background: var(--mz-primary);
}
aside.fixed > div:first-child > div:first-child svg {
  width: 19px;
  height: 19px;
}
aside.fixed > div:first-child .font-black {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
aside.fixed > div:first-child .text-xs {
  color: var(--mz-sidebar-muted);
}
aside.fixed nav {
  display: grid;
  gap: 4px;
}
aside.fixed nav > * + * {
  margin-top: 0;
}
aside.fixed nav a {
  height: 44px;
  padding: 0 12px;
  gap: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--mz-sidebar-fg);
  background: transparent;
}
aside.fixed nav a:hover {
  color: #fff;
  background: var(--mz-sidebar-hover);
}
aside.fixed nav a.bg-slate-950,
aside.fixed nav a[aria-current="page"] {
  color: #fff;
  background: var(--mz-sidebar-active);
}
aside.fixed nav a svg {
  width: 18px;
  height: 18px;
}

@media (min-width: 1024px) {
  .lg\:pl-72 { padding-left: var(--mz-sidebar-w); }
}
/* шесть показателей дашборда — 3×2 вместо 5+1 */
@media (min-width: 1280px) {
  .xl\:grid-cols-5:has(> :nth-child(6)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ── Верхняя панель: заголовок раздела, как в CRM ───────────────────────── */
header.sticky {
  background: #fff;
  border-bottom: 1px solid var(--mz-border);
  backdrop-filter: none;
  padding-top: 14px;
  padding-bottom: 14px;
}
header.sticky > div > div:first-child {
  min-width: 0;
}
/* роль («Администратор»/«Продавец») не дублируем.
   До ui.js блок имени — первый ребёнок строки, после — внутри .mz-left. */
header.sticky > div > div:first-child:not(.mz-left) > div,
header.sticky .mz-left > div > div {
  display: none;
}
header.sticky > div > .mz-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
header.sticky .mz-left > div {
  min-width: 0;
}
/* заголовок раздела, вставляет ui.js */
.mz-page-title {
  display: block;
  font-size: 22px;
  line-height: 28px;
  font-weight: 650;
  letter-spacing: -0.5px;
  color: var(--mz-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* имя пользователя — второй строкой, приглушённо */
header.sticky h1 {
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  color: var(--color-slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header.sticky h1:empty {
  display: none;
}
header.sticky button {
  border-color: var(--mz-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  color: #647b9b;
}

/* ── Сотрудники: без стрелок сортировки и без горизонтальной прокрутки ─── */
main table[data-mz="employees"] {
  min-width: 0;
}
main table[data-mz="employees"] td.mz-td-actions button:nth-child(-n + 2) {
  display: none;
}

/* ── Категории: панель «Без % / Все», поиск, «поставить всем» (ui.js) ──── */
main .space-y-5:has(#mz-cat-bar) > [data-mz-collapse] {
  display: none; /* жёлтый список заменён вкладкой «Без %» */
}
main table tr.mz-hide {
  display: none !important;
}
#mz-cat-bar {
  display: grid;
  gap: 10px;
}
#mz-cat-bar .mz-cat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
#mz-cat-bar .mz-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--color-slate-100);
}
#mz-cat-bar .mz-seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-slate-600);
}
#mz-cat-bar .mz-seg button b {
  font-weight: 600;
  font-size: 12px;
  padding: 0 7px;
  border-radius: 999px;
  background: #fff;
  color: var(--color-slate-600);
}
#mz-cat-bar .mz-seg button[data-tab="zero"] b {
  background: #fde8e8;
  color: #b42318;
}
#mz-cat-bar .mz-seg button[aria-pressed="true"] {
  background: #fff;
  color: var(--color-slate-950);
  box-shadow: 0 1px 2px rgb(16 24 40 / 0.08);
}
#mz-cat-bar .mz-cat-search {
  flex: 1 1 220px;
  max-width: 360px;
}
#mz-cat-bar input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--mz-border, #e7ebf2);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  outline: none;
}
#mz-cat-bar input:focus {
  border-color: var(--mz-primary, #3268e8);
  box-shadow: 0 0 0 3px rgb(50 104 232 / 0.15);
}
#mz-cat-bar .mz-cat-bulk:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-slate-600);
}
#mz-cat-bar .mz-cat-bulk input {
  width: 84px;
}
#mz-cat-bar .mz-cat-apply {
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--mz-primary, #3268e8);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}
#mz-cat-bar .mz-cat-apply:disabled {
  opacity: 0.5;
}
#mz-cat-bar .mz-cat-hint {
  font-size: 13px;
  color: var(--color-slate-500);
}
#mz-cat-bar .mz-cat-empty {
  padding: 16px;
  border: 1px dashed var(--mz-border, #e7ebf2);
  border-radius: 12px;
  text-align: center;
  color: var(--color-slate-500);
}
@media (max-width: 767px) {
  #mz-cat-bar .mz-cat-bulk:not([hidden]) {
    flex-wrap: nowrap;
  }
  #mz-cat-bar .mz-cat-bulk > span:first-child {
    flex: 1;
    min-width: 0;
  }
  #mz-cat-bar .mz-cat-bulk input {
    width: 64px;
  }
  #mz-cat-bar .mz-cat-hint {
    display: none;
  }
  #mz-cat-bar .mz-cat-search {
    max-width: none;
  }
}
/* поле процента узкое, строки плотнее */
@media (min-width: 768px) {
  main table[data-mz="categories"] td {
    padding-top: 6px;
    padding-bottom: 6px;
  }
  main table[data-mz="categories"] td:nth-child(2) {
    width: 140px;
  }
  main table[data-mz="categories"] td:last-child {
    width: 80px;
  }
  main table[data-mz="categories"] input {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* ── Неразобранные продажи: товар, награда и «Забрать» (ui.js → data-*) ─── */
main [data-mz-claim] {
  background: #fff;
  border: 1px solid var(--mz-border);
  border-radius: 12px;
}
main [data-mz-claim] > [data-mz-title]::before {
  content: attr(data-mz-title);
  display: block;
  margin-bottom: 2px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  color: var(--mz-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
main [data-mz-claim] > [data-mz-reward]::after {
  content: attr(data-mz-reward);
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 700;
  color: #0f7a4d;
  background: #e3f6ec;
}
main [data-mz-claim][data-mz-tone="zero"] > [data-mz-reward]::after {
  color: var(--color-slate-600);
  background: var(--color-slate-100);
  font-weight: 500;
  font-size: 13px;
}
main [data-mz-claim][data-mz-tone="return"] > [data-mz-reward]::after {
  color: #a53a3f;
  background: #fbeaea;
}
/* продавец: карточка «товар / сумма / награда — [Забрать]» */
main [data-mz-claim="seller"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px 12px;
  padding: 12px 14px;
}
main [data-mz-claim="seller"] > div {
  min-width: 0;
  color: var(--color-slate-600);
}
main [data-mz-claim="seller"] > div > b {
  color: var(--mz-fg);
}
main [data-mz-claim="seller"] > button {
  min-height: 44px;
  padding: 0 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  background: #16a34a;
}
main [data-mz-claim="seller"] > button:hover {
  background: #15803d;
}
main [data-mz-claim="seller"][data-mz-tone="win"] > button {
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.28);
}
main [data-mz-claim="seller"][data-mz-tone="zero"] > button,
main [data-mz-claim="seller"][data-mz-tone="return"] > button {
  background: var(--color-slate-700);
  box-shadow: none;
}
@media (prefers-reduced-motion: no-preference) {
  main [data-mz-claim="seller"][data-mz-tone="win"] > button:active {
    transform: scale(0.97);
  }
}

/* ── Раздел «Настройки» (settings.js) ────────────────────────────────────── */
.mz-moved { display: none; }
.mz-visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
aside.fixed nav a.mz-nav-settings { margin-top: 12px; position: relative; }
aside.fixed nav a.mz-nav-settings::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: -8px;
  border-top: 1px solid var(--mz-sidebar-border);
}
aside.fixed nav a.mz-nav-settings.mz-active { color: #fff; background: var(--mz-sidebar-active); }
aside.fixed nav a.mz-dim-active.bg-slate-950 { background: transparent; color: var(--mz-sidebar-fg); }
body.mz-settings-open main > :not(#mz-settings) { display: none; }

#mz-settings { display: grid; gap: 16px; max-width: 760px; }
.mz-s-card {
  display: grid; gap: 10px; padding: 16px;
  background: #fff; border: 1px solid var(--mz-border); border-radius: 12px;
}
.mz-s-card h3 { font-size: 18px; line-height: 24px; font-weight: 650; color: var(--mz-fg); }
.mz-s-muted { font-size: 14px; line-height: 20px; color: var(--color-slate-500); }
.mz-s-muted b { color: var(--mz-fg); font-weight: 600; }
.mz-s-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.mz-s-head > div { display: grid; gap: 4px; }
.mz-s-badge {
  flex: none; padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.mz-s-badge[data-tone="ok"] { background: #e6f6ee; color: #11724a; }
.mz-s-badge[data-tone="bad"] { background: #fbeaea; color: #a53a3f; }
.mz-s-badge[data-tone="warn"] { background: #fff4dc; color: #92400e; }
.mz-s-badge[data-tone="muted"] { background: var(--color-slate-100); color: var(--color-slate-600); }
.mz-s-error {
  padding: 10px 12px; border-radius: 8px; font-size: 14px; line-height: 20px;
  background: #fbeaea; color: #a53a3f;
}
.mz-s-form { display: grid; gap: 10px; }
.mz-s-field { display: grid; gap: 4px; font-size: 13px; font-weight: 500; color: var(--color-slate-600); }
.mz-s-field input {
  min-height: 44px; padding: 10px 12px; font-size: 16px; color: var(--mz-fg);
  background: #fff; border: 1px solid var(--color-slate-300); border-radius: 8px; outline: none;
}
.mz-s-field input:focus { border-color: var(--mz-primary); box-shadow: 0 0 0 3px var(--color-indigo-100); }
.mz-s-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mz-s-primary, .mz-s-secondary {
  min-height: 44px; padding: 0 16px; border-radius: 8px;
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.mz-s-primary { background: var(--mz-primary); color: #fff; border: 0; }
.mz-s-primary:hover { background: #2f62d5; }
.mz-s-secondary { background: #fff; color: var(--mz-fg); border: 1px solid var(--color-slate-300); }
.mz-s-secondary:hover { background: var(--color-slate-50); }
.mz-s-primary:disabled, .mz-s-secondary:disabled { opacity: 0.55; cursor: not-allowed; }
.mz-s-result:empty { display: none; }
.mz-s-result { font-size: 14px; line-height: 20px; }
.mz-s-result[data-tone="ok"] { color: #11724a; }
.mz-s-result[data-tone="bad"] { color: #a53a3f; }
.mz-s-result[data-tone="muted"] { color: var(--color-slate-500); }
.mz-s-help summary { cursor: pointer; font-size: 14px; font-weight: 500; color: var(--mz-primary); }
.mz-s-help ol { margin: 8px 0 0; padding-left: 20px; font-size: 14px; line-height: 20px; color: var(--color-slate-600); list-style: decimal; }
.mz-s-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 10px; border-top: 1px solid var(--mz-border);
}
.mz-s-card h3 + .mz-s-row { border-top: 0; padding-top: 0; }
.mz-s-row b { font-size: 15px; font-weight: 600; color: var(--mz-fg); }
.mz-s-inline { display: flex; align-items: flex-end; gap: 8px; }
.mz-s-date input { min-height: 44px; font-size: 15px; }
@media (max-width: 767px) {
  #mz-settings { gap: 12px; }
  .mz-s-card { padding: 12px; }
  .mz-s-row { flex-direction: column; align-items: stretch; }
  .mz-s-inline { justify-content: space-between; }
  .mz-s-inline .mz-s-field { flex: 1; }
  .mz-s-actions > * { flex: 1; }
}

/* ── Длинные предупреждения: три строки, по нажатию — весь текст ────────── */
main [data-mz-collapse] {
  position: relative;
  max-height: calc(4 * 1.5em + 44px);
  overflow: hidden;
  cursor: pointer;
  line-height: 1.5em;
  padding-bottom: 36px;
}
main [data-mz-collapse]::before {
  content: "⚠ Не настроен процент мотивации";
  display: block;
  margin-bottom: 4px;
  font-weight: 650;
  font-size: 15px;
  color: #92400e;
}
main [data-mz-collapse]::after {
  content: "Показать все ▾";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44px;
  padding: 18px 16px 0;
  font-weight: 600;
  font-size: 13px;
  line-height: 20px;
  color: #92400e;
  background: linear-gradient(to bottom, rgba(255, 251, 235, 0) 0, #fffbeb 16px);
}
main [data-mz-collapse].mz-open {
  max-height: none;
}
main [data-mz-collapse].mz-open::after {
  content: "Свернуть ▴";
  background: none;
  padding-top: 0;
}

/* ── Кнопка меню и выезжающая панель (до 1024px) ─────────────────────────── */
.mz-burger {
  display: none;
}
.mz-overlay {
  display: none;
}

@media (max-width: 1023px) {
  header.sticky select {
    display: none;
  }
  header.sticky > div {
    flex-wrap: nowrap;
  }
  .mz-burger {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    margin-right: 4px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--mz-fg);
  }
  .mz-burger:hover {
    background: var(--color-slate-100);
  }

  aside.fixed {
    display: block;
    width: min(280px, 84vw);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  body.mz-nav-open aside.fixed {
    transform: none;
    box-shadow: 0 0 40px rgba(17, 25, 40, 0.35);
  }
  body.mz-nav-open .mz-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(17, 25, 40, 0.45);
  }
  body.mz-nav-open {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  aside.fixed {
    transition: none;
  }
}
