/* ===== Иконки ===== */
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-fill { fill: currentColor; stroke: none; }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 50px; padding: 0 24px; border-radius: 14px;
  font-weight: 650; font-size: 16px; line-height: 1; white-space: nowrap;
  transition: background .15s, color .15s, transform .1s, box-shadow .15s, border-color .15s;
  user-select: none; text-decoration: none !important;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.btn-primary {
  background: var(--primary); color: var(--primary-contrast);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 32%, transparent);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--primary-press); }
.btn-soft { background: var(--bg-soft); color: var(--text); }
.btn-soft:hover:not(:disabled) { background: var(--bg-soft-2); }
.btn-outline { border: 1.5px solid var(--border-strong); color: var(--text); background: transparent; }
.btn-outline:hover:not(:disabled) { background: var(--bg-soft); }
.btn-ghost { color: var(--primary); padding: 0 12px; }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-light { background: #fff; color: #1b2352; }
.btn-light:hover:not(:disabled) { background: #eef0ff; }
.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; border-radius: 11px; gap: 8px; }
.btn-lg { height: 58px; padding: 0 32px; font-size: 17px; border-radius: 16px; }
.btn-icon { width: 50px; padding: 0; }
.btn-sm.btn-icon { width: 38px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center;
  color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-soft-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn .icon { width: 22px; height: 22px; }

.link-btn { color: var(--primary); font-weight: 650; display: inline-flex; align-items: center; gap: 8px; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ===== Поля ===== */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > label, .field-label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.input, .textarea, .select-native {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 14px;
  background: var(--bg-soft); border: 1.5px solid transparent; outline: none;
  transition: border-color .15s, background .15s;
}
.input:hover, .textarea:hover { background: var(--bg-soft-2); }
.input:focus, .textarea:focus, .select-native:focus { border-color: var(--primary); background: var(--bg-elev); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { height: auto; min-height: 112px; padding: 14px 16px; resize: vertical; line-height: 1.5; }
.input.invalid { border-color: var(--danger); }
.field-hint { font-size: 13px; color: var(--text-3); }
.field-error { font-size: 13px; color: var(--danger); font-weight: 600; }
.input-prefix { position: relative; }
.input-prefix .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-prefix .input { padding-left: 48px; }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 56px; }
.input-suffix > span { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; pointer-events: none; }

input[type="date"].input { min-width: 150px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--primary) var(--fill, 50%), var(--bg-soft-2) var(--fill, 50%));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary); box-shadow: var(--shadow-sm); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--primary); cursor: grab;
}

/* Фильтр-селект с подписью сверху, как в кабинете-образце */
.filter {
  position: relative; display: block; width: 100%; text-align: left;
  background: var(--bg-soft); border-radius: 14px; padding: 9px 44px 9px 16px; min-height: 56px;
  border: 1.5px solid transparent; transition: border-color .15s, background .15s;
}
.filter:hover { background: var(--bg-soft-2); }
.filter[aria-expanded="true"] { border-color: var(--primary); background: var(--bg-elev); }
.filter-label { display: block; font-size: 12.5px; color: var(--text-2); line-height: 1.2; }
.filter-value { display: block; font-size: 16px; font-weight: 500; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter > .icon { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); transition: transform .15s; }
.filter[aria-expanded="true"] > .chev { transform: translateY(-50%) rotate(180deg); }
.filter-compact { min-height: 48px; padding-top: 7px; padding-bottom: 7px; }

.toggle-block {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 0 16px; background: var(--bg-soft); border-radius: 14px;
  font-size: 16px; color: var(--text-2);
}

.switch { position: relative; display: inline-flex; align-items: center; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; width: 100%; height: 100%; }
.switch-track { position: relative; width: 100%; height: 100%; background: var(--border-strong); border-radius: 15px; transition: background .18s; }
.switch-track::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .18s var(--ease);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-sm { width: 44px; height: 26px; }
.switch-sm .switch-track::after { width: 20px; height: 20px; }
.switch-sm input:checked + .switch-track::after { transform: translateX(18px); }

/* ===== Поповеры и меню ===== */
.popover {
  position: fixed; z-index: var(--z-popover);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 8px;
  animation: pop-in .14s var(--ease);
  max-height: min(70vh, 440px); overflow: auto;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px; font-size: 15px; line-height: 1.3;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-soft); outline: none; }
.menu-item[aria-selected="true"] { background: var(--primary-soft); color: var(--primary-soft-text); font-weight: 600; }
.menu-check {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; flex: none; color: transparent;
}
.menu-check .icon { width: 14px; height: 14px; stroke-width: 3; }
.menu-item[aria-selected="true"] .menu-check { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--dot, var(--primary)); }

/* ===== Чипы, бейджи ===== */
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 18px; border: 1.5px solid var(--border); background: var(--bg-elev);
  font-size: 14px; font-weight: 600; color: var(--text-2); transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="true"] {
  color: var(--text); border-color: var(--chip-color, var(--primary));
  background: color-mix(in srgb, var(--chip-color, var(--primary)) 12%, transparent);
}
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 13px; font-size: 13px; font-weight: 650; white-space: nowrap;
  background: var(--bg-soft-2); color: var(--text-2);
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary-soft-text); }
.badge .dot { width: 7px; height: 7px; }

/* ===== Карточки ===== */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.card-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px;
  padding: 18px 20px 20px; min-height: 118px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  transition: transform .18s var(--ease), box-shadow .18s, border-color .18s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.kpi-label { color: var(--text-2); font-size: 16px; display: flex; align-items: center; gap: 8px; }
.kpi-value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-delta { margin-top: 6px; font-size: 13px; font-weight: 650; display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.kpi-delta .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-accent {
  background: var(--brand-gradient); border-color: transparent; color: #fff;
  box-shadow: 0 16px 36px color-mix(in srgb, var(--primary) 30%, transparent);
}
.kpi-accent:hover { border-color: transparent; box-shadow: 0 20px 44px color-mix(in srgb, var(--primary) 38%, transparent); }
.kpi-accent .kpi-label { color: rgba(255, 255, 255, .85); }
.kpi-accent .kpi-delta, .kpi-accent .kpi-delta.up, .kpi-accent .kpi-delta.down { color: rgba(255, 255, 255, .92); }
.kpi-accent::after {
  content: ''; position: absolute; right: -34px; top: -38px; width: 132px; height: 132px; border-radius: 50%;
  box-shadow: inset 22px 12px 0 0 rgba(255, 255, 255, .16); pointer-events: none;
}

/* ===== Таблицы ===== */
.table-card { border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--bg-elev); overflow: hidden; }
.table-scroll { overflow: auto; max-width: 100%; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 16px; }
.data th {
  position: sticky; top: 0; z-index: 2; text-align: left; font-weight: 500; font-size: 15.5px;
  color: var(--text-2); background: var(--bg-soft); padding: 16px 20px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data td { padding: 17px 20px; white-space: nowrap; background: var(--bg-elev); }
.data tbody tr:nth-child(even) td { background: var(--bg-stripe); }
.data tbody tr:hover td { background: color-mix(in srgb, var(--primary) 7%, var(--bg-elev)); }
.data tr.pinned td { font-weight: 700; background: var(--bg-elev) !important; border-bottom: 1px solid var(--border); }
.data tr.pinned.accent td { background: color-mix(in srgb, var(--primary) 6%, var(--bg-elev)) !important; }
.data .sticky-first { position: sticky; left: 0; z-index: 1; }
.data th.sticky-first { z-index: 3; }
.data .num { font-variant-numeric: tabular-nums; }
.data .cell-muted { color: var(--text-3); }
.th-btn { display: inline-flex; align-items: center; gap: 8px; color: inherit; font-weight: inherit; }
.th-btn .icon { width: 16px; height: 16px; color: var(--text-3); }
.th-btn[data-dir] .icon { color: var(--primary); }
.th-btn:hover { color: var(--text); }
.cell-actions { display: flex; align-items: center; gap: 2px; }
.cell-id { color: var(--text-2); }
.cell-title { display: flex; flex-direction: column; line-height: 1.3; }
.cell-title small { color: var(--text-3); font-size: 13px; font-weight: 400; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 14px; }

/* ===== Модальные окна ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal); background: var(--overlay);
  display: grid; place-items: center; padding: 20px; overflow: auto;
  animation: fade-in .16s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(100%, 560px); background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 24px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: calc(100vh - 40px);
  animation: modal-in .24s var(--ease);
}
.modal-lg { width: min(100%, 880px); }
.modal-sm { width: min(100%, 440px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 26px 6px; }
.modal-title { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.modal-body { padding: 12px 26px 8px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { padding: 18px 26px 24px; display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
body.modal-open { overflow: hidden; }

/* ===== Тосты ===== */
.toasts {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  z-index: var(--z-toast); pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto; background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg);
  animation: toast-in .24s var(--ease);
}
.toast.out { animation: toast-out .2s ease forwards; }
.toast .icon { width: 20px; height: 20px; }
.toast.success .icon { color: #4ade80; }
.toast.error .icon { color: #ff7a7f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ===== Вкладки ===== */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg-soft); border-radius: 14px; max-width: 100%; overflow-x: auto; }
.tab { height: 40px; padding: 0 18px; border-radius: 11px; font-weight: 600; color: var(--text-2); white-space: nowrap; transition: all .15s; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }

/* ===== Аккордеон ===== */
.acc-item { border: 1px solid var(--border); border-radius: 16px; background: var(--bg-elev); overflow: hidden; transition: border-color .15s; }
.acc-item + .acc-item { margin-top: 10px; }
.acc-item[data-open="true"] { border-color: var(--border-strong); }
.acc-btn {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 22px; font-size: 17px; font-weight: 650; text-align: left;
}
.acc-btn:hover { background: var(--bg-soft); }
.acc-chev { transition: transform .2s var(--ease); color: var(--text-3); }
.acc-item[data-open="true"] .acc-chev { transform: rotate(180deg); }
.acc-panel { display: none; padding: 0 22px 20px; color: var(--text-2); line-height: 1.65; }
.acc-item[data-open="true"] .acc-panel { display: block; animation: fade-in .2s; }
.acc-panel p + p, .acc-panel ul { margin-top: 10px; }
.acc-panel ul { list-style: disc; padding-left: 22px; }
.acc-panel li + li { margin-top: 6px; }

/* ===== Прочее ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--bg-soft-2) 37%, var(--bg-soft) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 10px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.empty { text-align: center; padding: 56px 24px; color: var(--text-2); }
.empty-icon { width: 68px; height: 68px; margin: 0 auto 16px; border-radius: 22px; background: var(--bg-soft); display: grid; place-items: center; color: var(--text-3); }
.empty h3 { color: var(--text); font-size: 18px; margin-bottom: 4px; }

.progress { height: 8px; border-radius: 4px; background: var(--bg-soft-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--brand-gradient); transition: width .5s var(--ease); }

.note { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--info-soft); font-size: 15px; line-height: 1.5; }
.note > .icon { color: var(--info); margin-top: 1px; }
.note.warning { background: var(--warning-soft); } .note.warning > .icon { color: var(--warning); }
.note.success { background: var(--success-soft); } .note.success > .icon { color: var(--success); }
.note.primary { background: var(--primary-soft); } .note.primary > .icon { color: var(--primary); }

.copy-field { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; background: var(--bg-soft); border-radius: 14px; min-width: 0; }
.copy-field code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 14px; }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-soft-text); display: grid; place-items: center; font-weight: 700; flex: none; }

.stars { display: flex; gap: 6px; }
.star-btn { color: var(--border-strong); transition: color .12s, transform .12s; }
.star-btn .icon { width: 38px; height: 38px; fill: currentColor; stroke: currentColor; }
.star-btn.on { color: #f5b301; }
.star-btn:hover { transform: scale(1.12); }

.link-cell { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 14px; color: var(--text-2); }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }

.support-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 30; width: 62px; height: 62px; border-radius: 50%;
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow-md);
  display: grid; place-items: center; color: var(--primary);
  transition: transform .18s var(--ease), box-shadow .18s;
}
.support-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: var(--shadow-lg); }
.support-fab .icon { width: 28px; height: 28px; }

.support-card { width: min(92vw, 340px); padding: 6px; }
.support-card h4 { font-size: 17px; font-weight: 700; padding: 12px 12px 4px; }
.support-card p { padding: 0 12px 10px; color: var(--text-2); font-size: 14px; }
.support-link { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; color: var(--text); font-weight: 600; }
.support-link:hover { background: var(--bg-soft); text-decoration: none; }
.support-link .icon-wrap { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.support-link small { display: block; font-weight: 400; color: var(--text-3); font-size: 13px; }

@media (max-width: 1280px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 16px 16px; min-height: 100px; }
  .kpi-label { font-size: 14px; }
  .kpi-value { font-size: 23px; }
  .btn { height: 48px; padding: 0 18px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 20px; padding-right: 20px; }
  .data th, .data td { padding-left: 14px; padding-right: 14px; }
  .support-fab { right: 16px; bottom: 16px; width: 54px; height: 54px; }
}
@media (max-width: 420px) { .kpi-value { font-size: 20px; } .kpi-label { font-size: 13px; } .kpi { padding: 12px 14px 14px; min-height: 92px; } .kpi-delta { font-size: 12px; } }
