/* ===========================================================
   TABLO EXTRAS — пункт управления (command center) + состояния
   v2.0  ·  расширение tablo.css (не дублирует существующее)
   Требует: tokens.css + tablo.css (подключены до этого файла)
   =========================================================== */

/* ── 1. GRID-12 — лейаут пункта управления ─────────────────── */

.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  align-items: start;
}

.col-3  { grid-column: span 3 }
.col-4  { grid-column: span 4 }
.col-6  { grid-column: span 6 }
.col-8  { grid-column: span 8 }
.col-12 { grid-column: span 12 }

@media (max-width: 1100px) {
  .grid-12 { grid-template-columns: 1fr }
  .col-3,.col-4,.col-6,.col-8,.col-12 { grid-column: span 1 }
}


/* ── 2. PANEL — плотная карта-панель ───────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-h {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-2);
  min-height: 42px;
  flex-shrink: 0;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.right-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}


/* ── 3. ALERT-ПОЛОСЫ — мониторинг / дрейф ──────────────────── */

.alert-lane {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Сброс старого .alert (был с цветным bg) — нейтральный хром + левая полоска */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12.5px;
  color: var(--ink-2);
  position: relative;
  overflow: hidden;
}

.alert::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.alert-crit::before { background: var(--cold) }
.alert-warn::before { background: var(--warm) }
.alert-ok::before   { background: var(--ok) }

.alert .alert-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.alert-crit .alert-icon { color: var(--cold) }
.alert-warn .alert-icon { color: var(--warm) }
.alert-ok   .alert-icon { color: var(--ok) }

.alert .alert-body  { flex: 1; min-width: 0 }
.alert .alert-title { font-weight: 600; color: var(--ink); font-size: 13px; line-height: 1.3 }
.alert .alert-sub   { color: var(--ink-3); font-size: 12px; margin-top: 2px }
.alert .alert-time  { font-size: 11px; color: var(--ink-4); flex-shrink: 0; margin-top: 2px }


/* ── 4. LIVE-ПЛИТКИ (tile / tile-row) ──────────────────────── */

.tile-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px 10px;
  box-shadow: var(--shadow);
  min-width: 120px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tile .tile-label {
  font-size: 11px;
  color: var(--ink-4);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .03em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile .tile-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.03em;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.tile .tile-sub {
  font-size: 11px;
  color: var(--ink-3);
}

/* место под спарклайн — live-dot переиспользуем из tablo.css */
.tile .spark {
  margin-top: 6px;
  height: 32px;
  width: 100%;
  overflow: hidden;
  line-height: 0;
}


/* ── 5. DENSITY TOGGLE (.dense) ────────────────────────────── */

.dense table td  { padding: 6px 10px }
.dense table th  { padding: 7px 10px }
.dense .stat     { padding: 10px 12px }
.dense .stat .num { font-size: 20px }
.dense .panel-h  { padding: 7px 12px; min-height: 36px }
.dense .tile     { padding: 8px 11px }
.dense .tile .tile-val { font-size: 18px }
.dense .card-h   { padding: 10px 14px }
.dense .card-b   { padding: 12px 14px }


/* ── 6. СОСТОЯНИЯ ──────────────────────────────────────────── */

/* 6a. skeleton (shimmer) */
@keyframes tablo-shimmer {
  0%   { background-position: -400px 0 }
  100% { background-position: 400px 0 }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--border-2) 25%,
    var(--border)   50%,
    var(--border-2) 75%
  );
  background-size: 800px 100%;
  animation: tablo-shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}

.skeleton * { visibility: hidden }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--border-2) }
}

/* 6b. empty-state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-3);
}

.empty-state .empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--ink-4);
  margin-bottom: 4px;
}

.empty-state .empty-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.empty-state .empty-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  max-width: 240px;
  line-height: 1.5;
}

.empty-state .btn { margin-top: 8px }

/* 6c. error-state (нейтральный, не кричащий) */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 20px;
  text-align: center;
  color: var(--ink-3);
}

.error-state .error-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--ink-4);
  margin-bottom: 4px;
}

.error-state .error-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.error-state .error-sub {
  font-size: 12px;
  color: var(--ink-4);
  max-width: 220px;
  line-height: 1.5;
}

.error-state .error-code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  margin-top: 2px;
}

/* 6d. loading-bar */
@keyframes tablo-loading-bar {
  0%   { left: -30%; width: 30% }
  50%  { left: 35%;  width: 40% }
  100% { left: 105%; width: 30% }
}

.loading-bar {
  position: relative;
  height: 3px;
  background: var(--border-2);
  border-radius: 99px;
  overflow: hidden;
}

.loading-bar::after {
  content: "";
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 99px;
  background: var(--ink);
  animation: tablo-loading-bar 1.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .loading-bar::after { animation: none; left: 0; width: 40%; opacity: .5 }
}


/* ── 7. ДОП. ВАРИАНТЫ ──────────────────────────────────────── */

/* 7a. stat-lg — крупный KPI */
.stat-lg {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.stat-lg .stat-label {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 10px;
}

.stat-lg .stat-num {
  font-size: 42px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.04em;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-lg .stat-delta {
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 7b. stat-mini */
.stat-mini {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat-mini .mini-label {
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 500;
  flex: 1;
}

.stat-mini .mini-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

/* 7c. card-flush — без внутреннего паддинга (под таблицу/чарт) */
.card-flush {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-flush table th:first-child,
.card-flush table td:first-child { padding-left: 16px }
.card-flush table th:last-child,
.card-flush table td:last-child  { padding-right: 16px }

/* 7d. seg — сегмент-контрол (крупнее .ftabs) */
.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
}

.seg-item {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 16px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}

.seg-item:hover { color: var(--ink-2); background: rgba(0,0,0,.03) }

.seg-item.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* 7e. badge-dot — цветная точка-статус */
.badge-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}

.badge-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ink-4);
}

.badge-dot.ok::before   { background: var(--ok) }
.badge-dot.hot::before  { background: var(--hot) }
.badge-dot.warm::before { background: var(--warm) }
.badge-dot.cold::before { background: var(--cold) }

/* 7f. trend-up / trend-down — стрелка + цвет */
.trend-up,
.trend-down,
.trend-neutral {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.trend-up::before      { content: "↑"; font-family: var(--font) }
.trend-down::before    { content: "↓"; font-family: var(--font) }
.trend-neutral::before { content: "→"; font-family: var(--font) }

.trend-up      { color: var(--ok) }
.trend-down    { color: var(--cold) }
.trend-neutral { color: var(--ink-4) }


/* ── 8. АДАПТИВ ────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .tile-row { gap: 8px }
  .tile { min-width: 100px }
}

@media (max-width: 860px) {
  .tile-row { flex-direction: column }
  .tile { min-width: 0 }
  .seg-item { padding: 6px 12px; font-size: 12.5px }
  .stat-lg .stat-num { font-size: 32px }
}

@media (max-width: 520px) {
  .alert { flex-wrap: wrap }
  .alert .alert-time { width: 100%; text-align: left }
}


/* ── 9. PREFERS-REDUCED-MOTION guard ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .skeleton     { animation: none; background: var(--border-2) }
  .loading-bar::after { animation: none }
}
