/* ═══════════════════════════════════════════════════════════════
   KP Foundation Shell — v1.1.1.527
   Канонічна база для всіх модулів і сторінок.
   Завантажується глобально через registerModules(['site'])
   Не перевизначати без крайньої потреби.
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────
   PAGE SHELL
───────────────────────────────────────── */
.kp-page {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 14px 64px;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .kp-page {
    padding: 24px 20px 80px;
  }
}

@media (min-width: 1024px) {
  .kp-page {
    padding: 28px 24px 96px;
  }
}

/* Width variants */
.kp-page--narrow  { max-width: 680px; }
.kp-page--wide    { max-width: 1280px; }
.kp-page--full    { max-width: none; }

/* ─────────────────────────────────────────
   PAGE HEAD (hero-like header)
───────────────────────────────────────── */
.kp-page-head {
  margin-bottom: 20px;
}

.kp-page-head__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.kp-page-head__eyebrow {
  font-family: var(--k-font-mono, monospace);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--k-primary);
  margin-bottom: 5px;
}

.kp-page-head__title {
  font-family: var(--k-font-mono, monospace);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--k-text-primary);
  margin: 0 0 4px;
  line-height: 1.2;
}

@media (min-width: 768px) {
  .kp-page-head__title { font-size: 1.5rem; }
}

.kp-page-head__sub {
  font-size: 0.8rem;
  color: var(--k-text-muted);
  margin: 0;
  line-height: 1.5;
}

.kp-page-head__acts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ─────────────────────────────────────────
   LAYOUT SYSTEM
───────────────────────────────────────── */
/* Single column (default) */
.kp-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Sidebar layout — stacks on mobile, 2-col on md+ */
.kp-layout--sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

@media (min-width: 768px) {
  .kp-layout--sidebar {
    grid-template-columns: 1fr 260px;
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .kp-layout--sidebar {
    grid-template-columns: 1fr 280px;
  }
}

/* Sidebar left variant */
.kp-layout--sidebar-left {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

@media (min-width: 768px) {
  .kp-layout--sidebar-left {
    grid-template-columns: 240px 1fr;
  }
}

.kp-layout__main { min-width: 0; }

.kp-layout__side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Sticky sidebar on desktop */
@media (min-width: 768px) {
  .kp-layout__side--sticky {
    position: sticky;
    top: calc(var(--k-header-height, 60px) + 12px);
    max-height: calc(100vh - var(--k-header-height, 60px) - 24px);
    overflow-y: auto;
    scrollbar-width: none;
  }
  .kp-layout__side--sticky::-webkit-scrollbar { display: none; }
}

/* Hide sidebar on mobile if it's just decorative */
@media (max-width: 767px) {
  .kp-layout__side--hide-mobile { display: none; }
}

/* ─────────────────────────────────────────
   CARD
───────────────────────────────────────── */
.kp-card {
  background: var(--k-bg-card);
  border: 1px solid var(--k-border-default);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}

.kp-card--sm   { border-radius: 12px; }
.kp-card--lg   { border-radius: 20px; }
.kp-card--flat { border: none; background: transparent; }

/* Card accent top line */
.kp-card--accent::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--k-primary), transparent);
  opacity: 0.5;
}

.kp-card__head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--k-border-default);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.kp-card__eyebrow {
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--k-primary);
  display: block;
  margin-bottom: 4px;
}

.kp-card__title {
  font-family: var(--k-font-mono, monospace);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--k-text-primary);
  margin: 0;
}

.kp-card__sub {
  font-size: 0.7rem;
  color: var(--k-text-muted);
  margin: 3px 0 0;
}

.kp-card__acts {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.kp-card__body {
  padding: 14px 16px;
}

.kp-card__body--flush { padding: 0; }

.kp-card__foot {
  padding: 12px 16px;
  border-top: 1px solid var(--k-border-default);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─────────────────────────────────────────
   SECTION
───────────────────────────────────────── */
.kp-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kp-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kp-section__title {
  font-family: var(--k-font-mono, monospace);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--k-text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kp-section__action {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--k-primary);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 7px;
  transition: background 0.12s;
  white-space: nowrap;
}

.kp-section__action:hover {
  background: var(--k-primary-soft);
}

.kp-section__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─────────────────────────────────────────
   EYEBROW (meta label above titles)
───────────────────────────────────────── */
.kp-eyebrow {
  font-family: var(--k-font-mono, monospace);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--k-primary);
  display: block;
}

/* ─────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────── */
.kp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.kp-empty__ico {
  font-size: 2.4rem;
  opacity: 0.3;
  margin-bottom: 12px;
  line-height: 1;
}

.kp-empty__title {
  font-family: var(--k-font-mono, monospace);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--k-text-primary);
  margin-bottom: 5px;
}

.kp-empty__sub {
  font-size: 0.74rem;
  color: var(--k-text-muted);
  line-height: 1.6;
  max-width: 280px;
  margin: 0 0 14px;
}

/* ─────────────────────────────────────────
   TOPBAR (filters / actions bar)
───────────────────────────────────────── */
.kp-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--k-border-default);
}

.kp-topbar--between {
  justify-content: space-between;
}

.kp-topbar__left,
.kp-topbar__right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ─────────────────────────────────────────
   TABS (canonical)
───────────────────────────────────────── */
.kp-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--k-border-default);
  padding: 0 2px;
}

.kp-tabs::-webkit-scrollbar { display: none; }

.kp-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 14px;
  font-family: var(--k-font-sans, sans-serif);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--k-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  white-space: nowrap;
  transition: color 0.13s, border-color 0.13s;
  flex-shrink: 0;
}

.kp-tab:hover { color: var(--k-text-secondary); }

.kp-tab.is-active,
.kp-tab[aria-selected="true"] {
  color: var(--k-primary);
  border-bottom-color: var(--k-primary);
}

.kp-tab__badge {
  font-family: var(--k-font-mono, monospace);
  font-size: 0.6rem;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  background: var(--k-primary-soft);
  color: var(--k-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kp-tab.is-active .kp-tab__badge {
  background: var(--k-primary);
  color: var(--k-bg-primary);
}

/* ─────────────────────────────────────────
   PILLS / CHIPS
───────────────────────────────────────── */
.kp-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid var(--k-border-default);
  background: var(--k-bg-elevated);
  color: var(--k-text-secondary);
  cursor: default;
  white-space: nowrap;
  transition: all 0.13s;
}

.kp-chip--active,
.kp-chip.is-active {
  background: var(--k-primary-soft);
  border-color: var(--k-accent-border, var(--k-border-strong));
  color: var(--k-primary);
}

.kp-chip--btn {
  cursor: pointer;
}

.kp-chip--btn:hover {
  border-color: var(--k-border-strong);
  color: var(--k-text-primary);
}

/* ─────────────────────────────────────────
   STAT PILL (числова мітка)
───────────────────────────────────────── */
.kp-stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 14px;
  background: var(--k-bg-elevated);
  border: 1px solid var(--k-border-default);
  border-radius: 12px;
  text-align: center;
  min-width: 60px;
}

.kp-stat-pill__val {
  font-family: var(--k-font-mono, monospace);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--k-text-primary);
  display: block;
  line-height: 1;
}

.kp-stat-pill__lbl {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--k-text-muted);
  margin-top: 4px;
  display: block;
}

.kp-stat-pill--accent .kp-stat-pill__val { color: var(--k-primary); }

/* ─────────────────────────────────────────
   ALERT / FLASH
───────────────────────────────────────── */
.kp-alert {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.kp-alert--ok {
  background: var(--k-green-soft, rgba(125,154,120,.09));
  border: 1px solid rgba(125,154,120,.2);
  color: var(--k-green, #7d9a78);
}

.kp-alert--err {
  background: var(--k-red-soft, rgba(176,107,90,.08));
  border: 1px solid var(--k-red-glow, rgba(176,107,90,.18));
  color: var(--k-red, #b06b5a);
}

.kp-alert--warn {
  background: var(--k-yellow-soft, rgba(196,169,122,.09));
  border: 1px solid rgba(196,169,122,.2);
  color: var(--k-yellow, #c4a97a);
}

.kp-alert--info {
  background: var(--k-primary-soft);
  border: 1px solid var(--k-accent-border, var(--k-border-strong));
  color: var(--k-primary);
}

/* ─────────────────────────────────────────
   FORM FIELDS
───────────────────────────────────────── */
.kp-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.kp-field__label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--k-text-secondary);
}

.kp-field__hint {
  font-size: 0.65rem;
  color: var(--k-text-muted);
  line-height: 1.5;
}

.kp-field__error {
  font-size: 0.68rem;
  color: var(--k-red, #b06b5a);
  font-weight: 600;
}

.kp-input {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--k-border-default);
  background: var(--k-bg-input);
  color: var(--k-text-primary);
  font-family: var(--k-font-sans, sans-serif);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.kp-input::placeholder { color: var(--k-text-muted); }

.kp-input:focus {
  border-color: var(--k-border-strong);
  background: var(--k-bg-elevated);
  box-shadow: 0 0 0 3px var(--k-primary-soft);
}

.kp-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.kp-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}

.kp-select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237483a2' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 12px;
  cursor: pointer;
}

/* ─────────────────────────────────────────
   BUTTONS (canonical — override kp-btn)
───────────────────────────────────────── */
.kp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 10px;
  font-family: var(--k-font-sans, sans-serif);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--k-border-default);
  background: var(--k-bg-elevated);
  color: var(--k-text-secondary);
  transition: all 0.14s;
  white-space: nowrap;
  line-height: 1;
}

.kp-btn:hover {
  background: var(--k-bg-hover);
  color: var(--k-text-primary);
  border-color: var(--k-border-strong);
}

.kp-btn:disabled,
.kp-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.kp-btn--primary {
  background: var(--k-primary);
  border-color: var(--k-primary);
  color: #fff;
  box-shadow: 0 3px 12px var(--k-primary-glow);
}

.kp-btn--primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 5px 18px var(--k-primary-glow);
  transform: translateY(-1px);
  color: #fff;
}

.kp-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--k-text-muted);
}

.kp-btn--ghost:hover {
  background: var(--k-bg-hover);
  border-color: var(--k-border-default);
  color: var(--k-text-primary);
}

.kp-btn--danger {
  background: var(--k-red-soft, rgba(176,107,90,.09));
  border-color: var(--k-red-glow, rgba(176,107,90,.2));
  color: var(--k-red, #b06b5a);
}

.kp-btn--danger:hover {
  background: var(--k-red, #b06b5a);
  color: #fff;
}

.kp-btn--sm {
  padding: 6px 12px;
  font-size: 0.72rem;
  border-radius: 8px;
}

.kp-btn--icon {
  padding: 7px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.kp-btn--icon.kp-btn--sm {
  width: 28px;
  height: 28px;
  padding: 5px;
  border-radius: 7px;
}

/* ─────────────────────────────────────────
   AVATAR
───────────────────────────────────────── */
.kp-ava {
  border-radius: 12px;
  background: var(--k-bg-elevated);
  border: 1px solid var(--k-border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  overflow: hidden;
  flex-shrink: 0;
}

.kp-ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.kp-ava--xs { width: 24px; height: 24px; border-radius: 7px; }
.kp-ava--sm { width: 32px; height: 32px; border-radius: 9px; }
.kp-ava--md { width: 40px; height: 40px; border-radius: 11px; }
.kp-ava--lg { width: 52px; height: 52px; border-radius: 14px; }
.kp-ava--xl { width: 64px; height: 64px; border-radius: 16px; }
.kp-ava--circle { border-radius: 50%; }

/* ─────────────────────────────────────────
   BADGE / DOT
───────────────────────────────────────── */
.kp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  font-family: var(--k-font-mono, monospace);
  font-size: 0.6rem;
  font-weight: 800;
  background: var(--k-primary);
  color: var(--k-bg-primary);
}

.kp-badge--muted {
  background: var(--k-bg-hover);
  color: var(--k-text-muted);
}

.kp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--k-primary);
  display: inline-block;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────
   DIVIDER
───────────────────────────────────────── */
.kp-divider {
  height: 1px;
  background: var(--k-border-default);
  margin: 12px 0;
}

.kp-divider--label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.65rem;
  color: var(--k-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kp-divider--label::before,
.kp-divider--label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--k-border-default);
}

/* ─────────────────────────────────────────
   LIST ROW (generic row item)
───────────────────────────────────────── */
.kp-row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--k-border-default);
  transition: background 0.12s;
}

.kp-row-item:last-child { border-bottom: none; }
.kp-row-item:hover { background: var(--k-bg-hover); }

.kp-row-item__body { flex: 1; min-width: 0; }
.kp-row-item__title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--k-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kp-row-item__sub {
  font-size: 0.68rem;
  color: var(--k-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kp-row-item__acts {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────
   SKELETON LOADER
───────────────────────────────────────── */
.kp-skeleton {
  background: linear-gradient(
    90deg,
    var(--k-bg-elevated) 25%,
    var(--k-bg-hover) 50%,
    var(--k-bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: kp-skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
  color: transparent;
  user-select: none;
  pointer-events: none;
}

@keyframes kp-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─────────────────────────────────────────
   TOOLTIP (CSS-only)
───────────────────────────────────────── */
[data-tip] {
  position: relative;
  cursor: help;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--k-bg-hover);
  color: var(--k-text-secondary);
  border: 1px solid var(--k-border-default);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: var(--k-z-tooltip, 700);
  max-width: 240px;
  white-space: normal;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

[data-tip]:hover::after { opacity: 1; }

/* ─────────────────────────────────────────
   UTILITY
───────────────────────────────────────── */
.kp-sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.kp-truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.kp-flex   { display: flex; align-items: center; gap: 8px; }
.kp-flex-wrap { flex-wrap: wrap; }
.kp-between { justify-content: space-between; }
.kp-grow  { flex: 1; min-width: 0; }

/* ─────────────────────────────────────────
   LIGHT THEME OVERRIDES (auto from tokens)
───────────────────────────────────────── */
/* All colors come from --k-* tokens which already handle light/dark.
   No manual overrides needed here. */
