/* ==========================================================================
   Control Tower (ЛК) — тёмная тема, sidebar layout, виджеты
   ========================================================================== */

[data-theme="lk"] {
  --color-text: #F2F2F2;
  --color-text-muted: #A8A8A8;
  --color-bg: #1c1d1d;
  --color-bg-alt: #2A2B2B;
  --color-border: #3a3b3b;
  --color-cta: var(--bulls-red);
  --lk-sidebar-w: 240px;
  --lk-header-h: 60px;
  --lk-card-bg: #232424;
  --lk-card-hover: #2c2d2d;
  --lk-accent: #FF7A7A;
}

[data-theme="lk"] body {
  background: var(--color-bg);
  color: var(--color-text);
}

.lk-shell {
  display: grid;
  grid-template-columns: var(--lk-sidebar-w) 1fr;
  min-height: 100vh;
}

.lk-sidebar {
  background: #161717;
  border-right: 1px solid var(--color-border);
  padding: 20px 0;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.lk-sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 20px 24px;
  border-bottom: 1px solid var(--color-border);
}
.lk-sidebar__brand img { height: 36px; background: #fff; border-radius: 6px; padding: 4px 6px; }
.lk-sidebar__brand .label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--color-text-muted); display: block; }
.lk-sidebar__brand .label-2 { font-weight: 600; font-size: 13px; color: #fff; }

.lk-sidebar__nav { padding: 16px 0; }
.lk-sidebar__group { margin-bottom: 16px; }
.lk-sidebar__group-title { padding: 10px 20px 6px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #707070; }
.lk-sidebar__nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: #cfcfcf;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all var(--t-fast) var(--ease);
}
.lk-sidebar__nav a:hover { background: rgba(255,255,255,.04); color: #fff; }
.lk-sidebar__nav a.is-active { background: rgba(255,122,122,.06); color: var(--lk-accent); border-left-color: var(--lk-accent); font-weight: 600; }
.lk-sidebar__nav a svg { width: 16px; height: 16px; }
.lk-sidebar__nav a .badge { margin-left: auto; font-family: var(--font-mono); font-size: 10px; padding: 1px 7px; border-radius: 8px; background: var(--bulls-darkred); color: #fff; }

.lk-main { display: flex; flex-direction: column; min-height: 100vh; }

.lk-topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--lk-header-h);
  padding: 0 24px;
  background: rgba(28,29,29,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 10;
}
.lk-topbar__title { font-weight: 600; font-size: 18px; }
.lk-topbar__actions { display: flex; align-items: center; gap: 10px; }
.lk-topbar__user { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--color-border); }
.lk-topbar__user .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bulls-darkred); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 13px; }
.lk-topbar__user .info { line-height: 1.3; font-size: 13px; }
.lk-topbar__user .info .name { color: #fff; font-weight: 500; display: block; }
.lk-topbar__user .info .role { color: var(--color-text-muted); font-size: 11px; }

.lk-content { padding: 28px; flex: 1; }

.lk-card {
  background: var(--lk-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  padding: 24px;
  transition: all var(--t-fast) var(--ease);
}
.lk-card--ai { border-color: rgba(70,30,100,.4); background: linear-gradient(135deg,#232424,#2a1a3a); }
.lk-card__title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.lk-card__title h3 { color: #fff; margin: 0; font-size: 16px; }

.lk-bento {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
}
.lk-bento .col-2 { grid-column: span 2; }
.lk-bento .col-3 { grid-column: span 3; }
.lk-bento .col-4 { grid-column: span 4; }
.lk-bento .col-6 { grid-column: span 6; }
.lk-bento .row-2 { grid-row: span 2; }
@media (max-width: 1100px) {
  .lk-bento { grid-template-columns: repeat(2,1fr); }
  .lk-bento .col-2,.lk-bento .col-3,.lk-bento .col-4,.lk-bento .col-6 { grid-column: span 2; }
}
@media (max-width: 700px) {
  .lk-shell { grid-template-columns: 1fr; }
  .lk-sidebar { position: relative; height: auto; }
  .lk-bento { grid-template-columns: 1fr; }
  .lk-bento .col-2,.lk-bento .col-3,.lk-bento .col-4,.lk-bento .col-6 { grid-column: span 1; }
}

.lk-stat { display: flex; flex-direction: column; gap: 4px; }
.lk-stat__label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); }
.lk-stat__value { font-family: var(--font-mono); font-weight: 600; font-size: 36px; color: #fff; line-height: 1; }
.lk-stat__delta { font-family: var(--font-mono); font-size: 12px; }
.lk-stat__delta--up { color: #5be39c; }
.lk-stat__delta--down { color: #ff8b8b; }

.lk-list { display: grid; gap: 8px; }
.lk-list__row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.02);
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease);
  font-size: 14px;
}
.lk-list__row:hover { background: rgba(255,255,255,.04); border-color: var(--color-border); }
.lk-list__pill { font-family: var(--font-mono); font-size: 10px; padding: 3px 9px; border-radius: var(--r-pill); text-transform: uppercase; letter-spacing: .04em; }
.lk-list__pill--ok { background: rgba(91,227,156,.1); color: #5be39c; }
.lk-list__pill--warn { background: rgba(255,179,71,.1); color: #ffb347; }
.lk-list__pill--crit { background: rgba(255,107,107,.1); color: #ff6b6b; }
.lk-list__pill--info { background: rgba(149,121,255,.1); color: #c9a8ff; }
.lk-list__meta { color: var(--color-text-muted); font-size: 12px; font-family: var(--font-mono); }

.lk-bar {
  height: 120px; display: flex; align-items: end; gap: 6px;
}
.lk-bar__col { flex: 1; background: linear-gradient(180deg, var(--bulls-darkred), #6e0000); border-radius: 4px 4px 0 0; min-height: 10%; position: relative; transition: filter var(--t-fast); }
.lk-bar__col:hover { filter: brightness(1.2); }
.lk-bar__col[data-ai="1"] { background: linear-gradient(180deg, var(--bulls-purple), #2a1640); }
.lk-bar__legend { display: flex; justify-content: space-between; margin-top: 8px; font-family: var(--font-mono); font-size: 10px; color: var(--color-text-muted); }

.lk-map {
  position: relative;
  background: linear-gradient(135deg,#1a1b1c,#222425);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  height: 320px;
  overflow: hidden;
}
.lk-map__pin {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bulls-red);
  box-shadow: 0 0 0 4px rgba(255,0,0,.18);
  animation: pulse 2.4s var(--ease) infinite;
}
.lk-map__pin--ai { background: #c9a8ff; box-shadow: 0 0 0 4px rgba(201,168,255,.2); }
.lk-map__pin--warn { background: #ffb347; box-shadow: 0 0 0 4px rgba(255,179,71,.2); }
.lk-map__route {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,122,122,.4), transparent);
  transform-origin: 0 0;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255,0,0,.18); }
  50% { box-shadow: 0 0 0 12px rgba(255,0,0,0); }
}

.lk-ai-launcher {
  position: fixed;
  right: 20px; bottom: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bulls-purple);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(70,30,100,.4);
  z-index: 30;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.lk-ai-launcher:hover { transform: scale(1.05); }
.lk-ai-launcher::after {
  content: "⌘K";
  position: absolute; top: -8px; right: -8px;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  background: #fff;
  color: var(--bulls-purple);
  border-radius: 6px;
  font-weight: 600;
}

.lk-chat {
  position: fixed;
  right: 20px; bottom: 90px;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: var(--lk-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
  display: none;
  flex-direction: column;
  max-height: 480px;
  z-index: 25;
}
.lk-chat.is-open { display: flex; }
.lk-chat__header { padding: 14px 16px; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
.lk-chat__title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: #fff; }
.lk-chat__title::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5be39c; box-shadow: 0 0 0 4px rgba(91,227,156,.18); }
.lk-chat__close { width: 24px; height: 24px; border-radius: 6px; background: rgba(255,255,255,.06); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.lk-chat__body { flex: 1; overflow-y: auto; padding: 14px 16px; display: grid; gap: 10px; }
.lk-msg { padding: 10px 14px; border-radius: var(--r-md); font-size: 14px; line-height: 1.5; max-width: 90%; }
.lk-msg--agent { background: rgba(70,30,100,.16); color: #ddd; align-self: flex-start; border: 1px solid rgba(70,30,100,.3); }
.lk-msg--user { background: var(--bulls-darkred); color: #fff; align-self: flex-end; }
.lk-msg__action {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 10px;
  font-family: var(--font-mono); font-size: 11px;
  background: #fff;
  color: var(--bulls-purple);
  border-radius: var(--r-sm);
  font-weight: 600;
}
.lk-chat__input { padding: 12px 14px; border-top: 1px solid var(--color-border); display: flex; gap: 8px; }
.lk-chat__input input { flex: 1; background: rgba(255,255,255,.06); color: #fff; border: 1px solid var(--color-border); padding: 8px 12px; border-radius: var(--r-sm); font: inherit; font-size: 13px; }
.lk-chat__input button { background: var(--bulls-purple); color: #fff; padding: 8px 14px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; }
