/* ==========================================================================
   SD Platform — дизайн-система / design system
   Одна таблица стилей на приложение менеджера, админку и страницу входа.
   ========================================================================== */

/* --------------------------------------------------------------- 1. Токены */
:root {
  /* Тёплая нейтральная база + нефритовый акцент */
  --bg:         #F5F4F0;
  --bg-tint:    #EFEDE7;
  --surface:    #FFFFFF;
  --surface-2:  #FAF9F6;
  --surface-3:  #F2F0EA;
  --line:       #E5E1D8;
  --line-2:     #D3CEC2;

  --ink:        #1B1A17;
  --ink-2:      #6A6459;
  --ink-3:      #9B9488;

  --brand:      #0E8F63;
  --brand-2:    #16B37C;
  --brand-ink:  #FFFFFF;
  --brand-soft: rgba(14, 143, 99, .10);
  --brand-line: rgba(14, 143, 99, .30);

  --amber:      #B8790A;  --amber-soft: rgba(184, 121, 10, .12);
  --rose:       #CC3B52;  --rose-soft:  rgba(204, 59, 82, .11);
  --sky:        #2C6FE4;  --sky-soft:   rgba(44, 111, 228, .11);
  --slate:      #7C7669;  --slate-soft: rgba(124, 118, 105, .12);

  --shadow-1: 0 1px 2px rgba(27, 26, 23, .06);
  --shadow-2: 0 4px 16px rgba(27, 26, 23, .08);
  --shadow-3: 0 22px 50px rgba(27, 26, 23, .16);

  --r-lg: 18px;
  --r:    13px;
  --r-sm: 9px;

  --ease:   cubic-bezier(.4, 0, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --topbar-h: 62px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg:         #121211;
  --bg-tint:    #171716;
  --surface:    #1B1B19;
  --surface-2:  #212120;
  --surface-3:  #282827;
  --line:       #2E2E2C;
  --line-2:     #403F3C;

  --ink:        #EFEDE8;
  --ink-2:      #A8A298;
  --ink-3:      #7A746B;

  --brand:      #2FCF95;
  --brand-2:    #52E0AC;
  --brand-ink:  #08150F;
  --brand-soft: rgba(47, 207, 149, .13);
  --brand-line: rgba(47, 207, 149, .32);

  --amber:      #E3A53A;  --amber-soft: rgba(227, 165, 58, .14);
  --rose:       #FF6C80;  --rose-soft:  rgba(255, 108, 128, .14);
  --sky:        #6699FF;  --sky-soft:   rgba(102, 153, 255, .14);
  --slate:      #989184;  --slate-soft: rgba(152, 145, 132, .14);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 6px 20px rgba(0, 0, 0, .5);
  --shadow-3: 0 26px 60px rgba(0, 0, 0, .7);

  color-scheme: dark;
}

/* ----------------------------------------------------------------- 2. База */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .4s var(--ease), color .4s var(--ease);
}

h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.02em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }

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

::selection { background: var(--brand-soft); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 3px solid transparent;
  border-radius: 9px;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

.muted   { color: var(--ink-2); }
.faint   { color: var(--ink-3); }
.mono    { font-family: var(--mono); font-size: .92em; }
.nowrap  { white-space: nowrap; }
.hidden  { display: none !important; }
.grow    { flex: 1; }
.center  { text-align: center; }
.stack   { display: grid; gap: 14px; }
.row     { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-end { display: flex; align-items: center; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------ 3. Анимации */
@keyframes rise   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideX { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
@keyframes pop    { 0% { transform: scale(.94); opacity: 0; } 60% { transform: scale(1.02); } 100% { transform: scale(1); opacity: 1; } }
@keyframes spinner{ to { transform: rotate(360deg); } }
@keyframes shimmer{ from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes pulse  { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(1.45); } }
@keyframes sweep  { to { transform: translateX(100%); } }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
@keyframes bob    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.anim-rise { animation: rise .5s var(--ease) both; }
.anim-fade { animation: fade .4s var(--ease) both; }

/* --------------------------------------------------------------- 4. Шапка */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--topbar-h);
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.brand:hover { text-decoration: none; }

.brandmark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: var(--brand-ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -.02em;
  box-shadow: 0 4px 12px var(--brand-soft);
}

.brandmark.admin {
  background: linear-gradient(140deg, #1B1A17, #3A3730);
  color: var(--brand);
}

.brand-name { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.brand > .brand-name { font-size: 15.5px; }
.brand-tag  { font-size: 10.5px; color: var(--ink-3); margin-top: -1px; }

/* Вкладки верхнего уровня со скользящим индикатором */
.tabs { position: relative; display: flex; gap: 2px; }

.tab {
  position: relative;
  padding: 9px 14px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  cursor: pointer;
  transition: color .22s var(--ease), background .22s var(--ease);
}

.tab:hover { color: var(--ink); background: var(--surface-3); }
.tab.active { color: var(--ink); }

.tab.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
  animation: fade .3s var(--ease);
}

.tab .badge-n {
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--surface-3);
  font-size: 10.5px;
  font-weight: 700;
}

.tab.active .badge-n { background: var(--brand-soft); color: var(--brand); }

/* Управляющие кнопки в шапке */
.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: all .22s var(--ease);
}

.icon-btn:hover { border-color: var(--line-2); color: var(--ink); transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }

.lang-pick {
  position: relative;
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.lang-pick .thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: calc((100% - 6px) / 3);
  height: calc(100% - 6px);
  border-radius: 6px;
  background: var(--brand);
  transition: transform .38s var(--spring);
}

.lang-pick button {
  position: relative;
  z-index: 1;
  width: 34px;
  padding: 5px 0;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  cursor: pointer;
  transition: color .28s var(--ease);
}

.lang-pick button.active { color: var(--brand-ink); }

/* Меню пользователя */
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 11px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 40px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: all .22s var(--ease);
}

.user-chip:hover { border-color: var(--line-2); transform: translateY(-1px); }

.avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: var(--brand-ink);
  font-size: 10.5px;
  font-weight: 800;
}

.avatar.lg { width: 54px; height: 54px; border-radius: 16px; font-size: 19px; }
.avatar.md { width: 36px; height: 36px; border-radius: 11px; font-size: 13px; }

.user-name { font-size: 12.5px; font-weight: 620; }
.user-role { font-size: 10px; color: var(--ink-3); margin-top: -2px; }

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 208px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: pop .22s var(--spring);
}

.menu button, .menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s var(--ease);
}

.menu button:hover, .menu a:hover { background: var(--surface-3); text-decoration: none; }
.menu .sep { height: 1px; margin: 5px 4px; background: var(--line); }
.menu .danger { color: var(--rose); }

/* ------------------------------------------------------------- 5. Каркас */
.shell { max-width: 1180px; margin: 0 auto; padding: 26px 22px 80px; }
.shell.wide { max-width: 1400px; }

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

.page-head p { margin: 6px 0 0; color: var(--ink-2); font-size: 13.5px; }

.view { display: none; }
.view.active { display: block; animation: fade .35s var(--ease); }

/* ---------------------------------------------------------------- 6. Карты */
.card {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color .28s var(--ease), box-shadow .28s var(--ease),
              transform .28s var(--ease), background .4s var(--ease);
}

.card + .card { margin-top: 16px; }
.card.pad-0 { padding: 0; overflow: hidden; }

.card-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
}

.card-head h2 { flex: 1; }

.card-ico {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
}

.card-ico svg { width: 16px; height: 16px; }

/* ------------------------------------------------------- 7. KPI-плитки */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  grid-auto-rows: 1fr;          /* все плитки одной высоты */
  gap: 14px;
}

/* Фиксированное число колонок — чтобы ряды не оставались недозаполненными */
.kpis.k3 { grid-template-columns: repeat(3, 1fr); }
.kpis.k4 { grid-template-columns: repeat(4, 1fr); }
.kpis.k5 { grid-template-columns: repeat(5, 1fr); }

.kpi {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  animation: rise .5s var(--ease) both;
  transition: transform .3s var(--spring), box-shadow .3s var(--ease);
}

.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }

.kpi::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--kc, var(--brand));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .55s var(--ease);
}

.kpi.in::after { transform: scaleX(1); }

.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-lab { color: var(--ink-2); font-size: 11.5px; font-weight: 620; letter-spacing: .02em; line-height: 1.35; }

.kpi-val {
  margin-top: auto;             /* значения выравниваются по нижнему краю плитки */
  padding-top: 10px;
  color: var(--kc, var(--ink));
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  line-height: 1.1;
}

.kpi-val.no-data { color: var(--ink-3); font-size: 26px; }
.kpi-sub { margin-top: 2px; color: var(--ink-3); font-size: 11.5px; }

.kpi-dot { flex-shrink: 0; width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--kc, var(--brand)); }

/* ------------------------------------------------------- 8. Кнопки, поля */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 620;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .2s var(--spring), background .22s var(--ease),
              border-color .22s var(--ease), opacity .2s var(--ease);
}

.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--brand-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn.ghost { border-color: var(--line); background: var(--surface); color: var(--ink); }
.btn.ghost:hover { border-color: var(--line-2); background: var(--surface-3); }

.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--surface-3); color: var(--ink); }

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

.btn.solid-danger { background: var(--rose); color: #fff; }
.btn.solid-danger:hover { background: var(--rose); filter: brightness(1.08); }

.btn.sm { padding: 7px 12px; font-size: 12.5px; }
.btn.block { width: 100%; }

.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: .28;
  transform: scale(0);
  animation: ripple .6s var(--ease);
  pointer-events: none;
}

.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field > .lab {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: .015em;
}

.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}

.input::placeholder { color: var(--ink-3); }
textarea.input { min-height: 78px; resize: vertical; }

.input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.input.bad { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* Соседние панели тянутся до высоты самой длинной */
.grid-2.even, .grid-3.even { align-items: stretch; }
.grid-2.even > .card, .grid-3.even > .card { display: flex; flex-direction: column; margin-top: 0; }

.switch {
  position: relative;
  flex-shrink: 0;
  width: 38px; height: 21px;
  border: none;
  border-radius: 20px;
  background: var(--line-2);
  cursor: pointer;
  transition: background .3s var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: transform .34s var(--spring);
}

.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(17px); }

/* ---------------------------------------------------------- 9. Индикаторы */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 30px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}

.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill.low   { background: var(--brand-soft); color: var(--brand); }
.pill.attn  { background: var(--amber-soft); color: var(--amber); }
.pill.high  { background: var(--rose-soft);  color: var(--rose);  }
.pill.new   { background: var(--slate-soft); color: var(--slate); }
.pill.info  { background: var(--sky-soft);   color: var(--sky);   }
.pill.high .dot { animation: pulse 1.6s var(--ease) infinite; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
}

/* Кольцо балла */
.ring { position: relative; flex-shrink: 0; }
.ring svg { display: block; transform: rotate(-90deg); }
.ring .bg { fill: none; stroke: var(--surface-3); }
.ring .fg { fill: none; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }

.ring .txt {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 720;
  letter-spacing: -.03em;
}

/* Полоса прогресса */
.bar { height: 6px; overflow: hidden; border-radius: 20px; background: var(--surface-3); }
.bar > i { display: block; height: 100%; width: 0; border-radius: 20px; background: var(--brand); transition: width .7s var(--spring); }

/* ------------------------------------------------------------ 10. Скелеты */
.sk {
  border-radius: var(--r);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s linear infinite;
}

.sk.row-sk { height: 76px; }
.sk-grid { display: grid; gap: 12px; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner .7s linear infinite;
}

/* ------------------------------------------------------------- 11. Пустое */
/* Прокрутка длинных списков внутри карточки, а не всей страницы */
.scroll-area {
  min-height: 0;
  max-height: var(--sa, 340px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* полоса всегда занимает место: список не «прыгает» при появлении прокрутки */
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
  padding-right: 4px;
  margin-right: -8px;
}

.scroll-area > :last-child { margin-bottom: 0; }

/* Мягкое затемнение у нижнего края, пока список прокручен не до конца */
.scroll-fade {
  position: sticky;
  bottom: 0;
  z-index: 2;
  height: 30px;
  margin-top: -30px;
  background: linear-gradient(180deg, transparent, var(--surface));
  opacity: 0;
  transition: opacity .22s var(--ease);
  pointer-events: none;
}

.scroll-area.more > .scroll-fade { opacity: 1; }

/* В карточке-колонке область занимает всё свободное место */
.card > .scroll-area { flex: 1; }

.scroll-area::-webkit-scrollbar { width: 7px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }

.scroll-area::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--line-2);
  background-clip: content-box;
}

.scroll-area::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* Чип-фильтр: единый вид для всех списков */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 580;
  white-space: nowrap;
  cursor: pointer;
  transition: all .24s var(--ease);
}

.chip:hover { border-color: var(--line-2); color: var(--ink); transform: translateY(-1px); }

.chip.on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 650;
}

.chip .n {
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--surface-3);
  font-size: 10.5px;
  font-weight: 700;
}

.chip.on .n { background: var(--brand); color: var(--brand-ink); }

/* Активное состояние кнопки-иконки (переключатель вида списка) */
.icon-btn.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* Поле поиска с иконкой слева */
.search { position: relative; flex: 1; min-width: 240px; }

.search > .ico {
  position: absolute;
  top: 50%; left: 12px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  transform: translateY(-50%);
  transition: color .22s var(--ease);
  pointer-events: none;
}

.search:focus-within > .ico { color: var(--brand); }
.search > .input { padding-left: 37px; }

.empty {
  padding: 56px 24px;
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: center;
}

.empty .ico {
  display: grid;
  place-items: center;
  width: 58px; height: 58px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: var(--surface-3);
  color: var(--ink-3);
  animation: bob 3.2s var(--ease) infinite;
}

.empty .ico svg { width: 26px; height: 26px; }
.empty h3 { margin-bottom: 5px; color: var(--ink); }

/* ------------------------------------------------- 12. Карточки клиентов */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  grid-auto-rows: 1fr;          /* карточки в ряду одной высоты */
  gap: 14px;
}

.client-card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 15px;
  height: 100%;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  text-align: left;
  cursor: pointer;
  animation: rise .45s var(--ease) both;
  transition: transform .28s var(--spring), box-shadow .28s var(--ease), border-color .28s var(--ease);
}

.client-card:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: var(--shadow-2); }

.client-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--cc, var(--slate));
  transform: scaleY(.25);
  transform-origin: center;
  transition: transform .4s var(--spring);
}

.client-card:hover::before { transform: scaleY(1); }

.cc-body { flex: 1; min-width: 0; }

.cc-name {
  display: block;
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 660;
  letter-spacing: -.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-meta {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: nowrap;            /* метки всегда в одну строку */
  min-height: 23px;
  margin-top: 10px;
}

/* Компактный маркер нарушенного регламента */
.warn-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 22px; height: 22px;
  border: 1px solid var(--rose);
  border-radius: 7px;
  background: var(--rose-soft);
  color: var(--rose);
  cursor: help;
}

/* ---------------------------------------------------------- 13. Таблицы */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }

table.data { width: 100%; min-width: 640px; border-collapse: collapse; }

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 720;
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
}

table.data thead th.sortable { cursor: pointer; transition: color .2s var(--ease); }
table.data thead th.sortable:hover { color: var(--brand); }
table.data thead th .caret { margin-left: 5px; animation: pop .3s var(--spring); display: inline-block; }

table.data tbody td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}

table.data tbody tr { animation: slideX .4s var(--ease) both; transition: background .2s var(--ease); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }

.cell-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-title { display: block; font-weight: 620; }
.cell-sub { display: block; color: var(--ink-3); font-size: 11.5px; }

/* ------------------------------------------------------ 14. Детали клиента */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.hero::before {
  content: "";
  position: absolute;
  top: -55%; right: -6%;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--brand-soft) 0%, transparent 70%);
  pointer-events: none;
}

.hero-main { position: relative; flex: 1; min-width: 220px; display: flex; align-items: center; gap: 16px; }
.hero-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-sub { margin-top: 5px; color: var(--ink-2); font-size: 12.5px; }

.subtabs {
  display: flex;
  gap: 3px;
  margin: 18px 0 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  overflow-x: auto;
}

.subtab {
  flex-shrink: 0;
  padding: 8px 15px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 580;
  cursor: pointer;
  transition: all .25s var(--ease);
}

.subtab:hover { color: var(--ink); }
.subtab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.kv-list { display: grid; gap: 1px; }

.kv {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  transition: padding-left .22s var(--ease);
}

.kv:last-child { border-bottom: none; }
.kv:hover { padding-left: 5px; }
.kv .k { color: var(--ink-2); }
.kv .v { font-weight: 560; }

/* Журнал звонков */
.banner {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid;
  border-radius: var(--r);
  font-size: 12.8px;
  line-height: 1.55;
  animation: rise .45s var(--ease) both;
}

.banner .b-ico { flex-shrink: 0; display: grid; place-items: center; width: 20px; height: 20px; }
.banner .b-ico svg { width: 17px; height: 17px; }

.banner.ok   { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand); }
.banner.warn { border-color: var(--amber);      background: var(--amber-soft); color: var(--amber); }
.banner.bad  { border-color: var(--rose);       background: var(--rose-soft);  color: var(--rose);  }

.banner.bad::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .16), transparent);
  transform: translateX(-100%);
  animation: sweep 2.8s var(--ease) infinite;
}

.weeks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.week {
  display: grid;
  place-items: center;
  width: 31px; height: 27px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 720;
  animation: pop .35s var(--spring) both;
  transition: transform .22s var(--spring);
}

.week:hover { transform: translateY(-3px) scale(1.09); }
.week.done    { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand); }
.week.missed  { border-color: var(--rose);  background: var(--rose-soft);  color: var(--rose);  }
.week.current { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }

.entry {
  position: relative;
  margin-bottom: 10px;
  padding: 14px 16px 14px 19px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  animation: rise .42s var(--ease) both;
  transition: transform .25s var(--ease), border-color .25s var(--ease);
}

.entry::before {
  content: "";
  position: absolute;
  top: 14px; bottom: 14px; left: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--ec, var(--brand));
  opacity: .55;
  transition: opacity .25s var(--ease);
}

.entry:hover { transform: translateX(3px); border-color: var(--line-2); }
.entry:hover::before { opacity: 1; }

.entry-head { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; color: var(--ink-3); font-size: 11.5px; font-weight: 600; }
.entry-body { font-size: 13px; line-height: 1.55; }
.entry-extra { margin-top: 6px; color: var(--ink-2); font-size: 12px; }
.entry-actions { position: absolute; top: 10px; right: 10px; opacity: 0; transition: opacity .22s var(--ease); }
.entry:hover .entry-actions { opacity: 1; }

/* Ответы анкеты */
.answers { display: grid; gap: 6px; margin-top: 11px; }

.answer { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; line-height: 1.55; }

.answer .mk {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 18px; height: 18px;
  margin-top: 1px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
}

.answer.v2 .mk { background: var(--brand-soft); color: var(--brand); }
.answer.v1 .mk { background: var(--amber-soft); color: var(--amber); }
.answer.v0 .mk { background: var(--rose-soft);  color: var(--rose);  }
.answer.vt .mk { background: var(--sky-soft);   color: var(--sky);   }

/* ------------------------------------------------------- 15. Анкета-опрос */
.q-item {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  animation: rise .4s var(--ease) both;
}

.q-item:last-child { border-bottom: none; }

.q-head { display: flex; gap: 11px; margin-bottom: 11px; font-size: 13.5px; line-height: 1.5; }

.q-n {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 23px; height: 23px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 720;
  transition: all .3s var(--spring);
}

.q-item.done .q-n { border-color: transparent; background: var(--brand); color: var(--brand-ink); transform: scale(1.05); }

.opts { display: flex; gap: 8px; padding-left: 34px; flex-wrap: wrap; }

.opt {
  flex: 1;
  min-width: 92px;
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 620;
  cursor: pointer;
  transition: all .24s var(--ease);
}

.opt:hover { border-color: var(--line-2); transform: translateY(-2px); }
.opt:active { transform: scale(.97); }
.opt.on { animation: pop .35s var(--spring); }
.opt.on.v2 { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.opt.on.v1 { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }
.opt.on.v0 { border-color: var(--rose);  background: var(--rose-soft);  color: var(--rose);  }

.q-free { padding-left: 34px; }

/* Прогресс анкеты прилипает к низу окна, чтобы всегда быть на виду */
.q-progress-sticky {
  position: sticky;
  bottom: -20px;
  z-index: 3;
  margin: 16px -22px -20px;
  padding: 13px 22px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* --------------------------------------------------- 16. Модальные окна */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 19, 16, .48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .22s var(--ease);
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: min(88vh, 900px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: pop .28s var(--spring);
}

.modal.lg { max-width: 820px; }
.modal.sm { max-width: 420px; }

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 { flex: 1; }
.modal-body { flex: 1; overflow-y: auto; padding: 20px 22px; }

.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 15px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ------------------------------------------------------------ 17. Тосты */
.toasts {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 370px;
}

.toast {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow-3);
  animation: pop .3s var(--spring);
}

.toast.out { animation: fade .25s var(--ease) reverse forwards; }

.toast .t-ico {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
}

.toast .t-ico svg { width: 14px; height: 14px; }
.toast.err .t-ico { background: var(--rose-soft); color: var(--rose); }
.toast.warn .t-ico { background: var(--amber-soft); color: var(--amber); }

.toast .t-bar {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--brand);
  transform-origin: left;
  animation: countdown 3.4s linear forwards;
}

.toast.err .t-bar { background: var(--rose); }
.toast.warn .t-bar { background: var(--amber); }

@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------------------------------------------------------- 18. Админка */
.admin-shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }

.rail {
  flex-shrink: 0;
  width: 226px;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.rail-label {
  margin: 16px 10px 8px;
  color: var(--ink-3);
  font-size: 9.5px;
  font-weight: 760;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.rail-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  text-align: left;
  cursor: pointer;
  transition: all .22s var(--ease);
}

.rail-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.rail-btn:hover { background: var(--surface-3); color: var(--ink); transform: translateX(2px); }
.rail-btn.active { background: var(--brand-soft); color: var(--brand); font-weight: 640; }
.rail-btn .n { margin-left: auto; color: var(--ink-3); font-size: 11px; font-weight: 700; }

.admin-main { flex: 1; min-width: 0; padding: 26px 28px 80px; }

/* Конструктор анкет */
.builder { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }

.form-list { display: grid; gap: 8px; }

.form-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: all .24s var(--ease);
}

.form-item:hover { border-color: var(--line-2); transform: translateX(2px); }
.form-item.active { border-color: var(--brand); background: var(--brand-soft); }
.form-item .fi-name {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-item .fi-meta { display: block; margin-top: 2px; color: var(--ink-3); font-size: 11px; }

.q-editor {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  animation: rise .35s var(--ease) both;
  transition: border-color .22s var(--ease), background .22s var(--ease);
}

.q-editor:hover { border-color: var(--line-2); }
.q-editor.off { opacity: .55; }

.q-handle {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 720;
}

.q-editor-body { flex: 1; min-width: 0; }
.q-editor-text { font-size: 13px; line-height: 1.5; }
.q-editor-meta { display: flex; align-items: center; gap: 7px; margin-top: 7px; flex-wrap: wrap; }
.q-editor-tools { display: flex; gap: 4px; flex-shrink: 0; }

.mini-btn {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
  transition: all .2s var(--ease);
}

.mini-btn svg { width: 14px; height: 14px; }
.mini-btn:hover { border-color: var(--line-2); color: var(--ink); transform: translateY(-1px); }
.mini-btn.danger:hover { border-color: var(--rose); color: var(--rose); }
.mini-btn[disabled] { opacity: .35; pointer-events: none; }

.lang-tabs { display: flex; gap: 4px; margin-bottom: 10px; }

.lang-tab {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  transition: all .2s var(--ease);
}

.lang-tab.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* --------------------------------------------------------- 19. Вход */
.auth-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(1000px 520px at 12% -10%, var(--brand-soft), transparent 60%),
    radial-gradient(760px 420px at 108% 108%, var(--sky-soft), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 396px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: pop .45s var(--spring);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 50px; height: 50px;
  margin-bottom: 20px;
  border-radius: 16px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: var(--brand-ink);
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 8px 22px var(--brand-soft);
}

.auth-hint {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.7;
}

.auth-error {
  margin-bottom: 14px;
  padding: 11px 14px;
  border: 1px solid var(--rose);
  border-radius: var(--r-sm);
  background: var(--rose-soft);
  color: var(--rose);
  font-size: 12.5px;
  animation: pop .3s var(--spring);
}

.auth-top { position: absolute; top: 18px; right: 18px; display: flex; gap: 8px; }

/* --------------------------------------------------- 20. Адаптивность */
@media (max-width: 1100px) {
  .kpis.k5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1000px) {
  .builder { grid-template-columns: 1fr; }
  .kpis.k4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .kpis.k3, .kpis.k4, .kpis.k5 { grid-template-columns: repeat(2, 1fr); }
  .grid-2.even { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .topbar { gap: 10px; padding: 0 14px; height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding-bottom: 8px; }
  .brand-tag { display: none; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .user-name, .user-role { display: none; }
  .user-chip { padding: 4px; }

  .shell { padding: 18px 14px 70px; }
  .admin-main { padding: 18px 14px 70px; }
  .admin-shell { flex-direction: column; }
  .rail { width: 100%; display: flex; gap: 6px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .rail-label { display: none; }
  .rail-btn { width: auto; white-space: nowrap; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .opts { padding-left: 0; }
  .q-free { padding-left: 0; }
  .q-progress-sticky { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .toasts { left: 14px; right: 14px; max-width: none; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
