/* ══════════════════════════════════════════════════════════════════
   万花筒 · 栅格整行卡片 + 整行联立结果卡片样式(kaleidoscope.css)
   定位(2026-11-10 andy 定):
   - 每个万花筒卡片独立占满一整行(.kls-card);
   - 联立结果卡(.kls-coupled-card)也是独立占满一整行的卡片,紧跟在该卡片下方,
     仅在点击执行/展开时才展示,自带「收起隐藏」按钮随时折叠关闭。
   ══════════════════════════════════════════════════════════════════ */

.kls-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.kls-search {
  flex: 1;
  max-width: 440px;
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

.kls-search:focus {
  outline: 2px solid #2563eb;
  outline-offset: 0;
}

.kls-count {
  color: #64748b;
  font-size: 13px;
}

/* ── 12 列栅格行容器:每个卡片单元占满 12 列整行 ── */
.kls-row-stack {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.kls-unit {
  grid-column: span 12;
  display: flex;
  flex-direction: column;
}

/* ── 主功能卡片(整行横置:左侧标题描述 + 中部内联参数 + 右侧执行与显隐按钮) ── */
.kls-card {
  position: relative;
  background: #fff;
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  padding: 14px 20px;
  transition: all .16s ease;
  display: grid;
  grid-template-columns: minmax(280px, 1.3fr) auto auto;
  gap: 18px;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
}

@media (max-width: 960px) {
  .kls-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.kls-card:hover {
  border-color: #60a5fa;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .07);
}

/* 当联立卡展开时,上方主卡底部与下方联立卡形成上下联立桥接 */
.kls-unit.is-open .kls-card {
  border-color: #2563eb;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: linear-gradient(90deg, #f8fbff 0%, #ffffff 100%);
}

.kls-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kls-card-name {
  font-weight: 700;
  font-size: 15.5px;
  color: #0f172a;
}

.kls-group-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 12px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  white-space: nowrap;
}

.kls-target-tag {
  font-size: 11.5px;
  color: #64748b;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.kls-card-desc {
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
  margin-top: 4px;
}

/* ── 中部内联参数区 ── */
.kls-card-params {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 12px;
  align-items: center;
}

.kls-param-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #334155;
  font-weight: 600;
}

.kls-param-input {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  width: 110px;
  background: #fff;
  color: #0f172a;
}

/* ── 右侧操作按钮组 ── */
.kls-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

.kls-toggle-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.kls-toggle-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* ── 紧随主卡下一行的整行联立结果卡片 (.kls-coupled-card) ── */
@keyframes klsSlideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kls-coupled-card {
  display: none;
  background: #ffffff;
  border: 1.5px solid #2563eb;
  border-top: 2px dashed #93c5fd;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  padding: 18px 22px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .07);
  animation: klsSlideDown .18s ease-out;
  box-sizing: border-box;
  width: 100%;
}

.kls-unit.is-open .kls-coupled-card {
  display: block;
}

.kls-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.kls-result-title {
  font-weight: 700;
  font-size: 15px;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 10px;
}

.kls-meta {
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
}

.kls-state {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.kls-state.exec-ok   { background: #dcfce7; color: #15803d; }
.kls-state.exec-no   { background: #fef3c7; color: #b45309; }
.kls-state.pending   { background: #f1f5f9; color: #64748b; }

/* ══════════════ 专属图表与可视化组件样式 ══════════════ */

.kls-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kls-kpi-tile {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
}

.kls-kpi-label {
  font-size: 11.5px;
  color: #64748b;
  margin-bottom: 3px;
}

.kls-kpi-val {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.kls-kpi-sub {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.kls-officer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.kls-officer-box {
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  padding: 14px 16px;
  background: #fcfdff;
}

.kls-officer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.kls-officer-name {
  font-weight: 700;
  font-size: 14px;
  color: #0f172a;
}

.kls-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
}

.kls-pill.idle    { background: #e0f2fe; color: #0369a1; }
.kls-pill.running { background: #dcfce7; color: #15803d; }
.kls-pill.paused  { background: #f1f5f9; color: #475569; }
.kls-pill.stalled { background: #fee2e2; color: #b91c1c; }

.kls-bar-wrap {
  margin: 8px 0;
}

.kls-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #334155;
  margin-bottom: 4px;
}

.kls-bar-track {
  height: 9px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
}

.kls-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  transition: width .3s ease;
}

.kls-bar-fill.green {
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

.kls-bar-fill.amber {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

.kls-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.kls-tl-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #2563eb;
  border-radius: 8px;
  padding: 9px 12px;
}

.kls-tl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 5px;
}

.kls-tool-chip {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  padding: 2px 7px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  margin: 2px 4px 2px 0;
}

.kls-block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.kls-block-cell {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 7px 9px;
}

.kls-block-cell.done {
  background: #f0fdf4;
  border-color: #86efac;
}

.kls-block-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
  margin-bottom: 4px;
}

.kls-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.kls-check-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
}

.kls-check-card.ok   { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.kls-check-card.warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }

.kls-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.kls-table th {
  text-align: left;
  padding: 8px 10px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  border-bottom: 1px solid #cbd5e1;
}

.kls-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.kls-raw-toggle {
  margin-top: 12px;
  border-top: 1px dashed #e2e8f0;
  padding-top: 8px;
}

.kls-raw-summary {
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  user-select: none;
}

.kls-result-pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 6px;
}
