<template>
  <div class="app-container warning-disposal-page" v-loading="loading">
    <el-card shadow="never" class="page-card header-card">
      <div class="page-header">
        <div>
          <div class="page-title">预警信息处置</div>
          <div class="page-subtitle">支持预警解除、预警升级、预警督办、添加领导批示和预警退回，形成发现问题到处置问题的闭环管理</div>
        </div>
        <el-button type="primary" icon="Refresh" @click="loadList">刷新</el-button>
      </div>
    </el-card>

    <div class="action-grid">
      <el-card shadow="hover" class="action-card resolve">
        <div class="action-title">预警解除</div>
        <div class="action-desc">现场处置核查无误后解除预警，形成处置闭环。</div>
      </el-card>
      <el-card shadow="hover" class="action-card upgrade">
        <div class="action-title">预警升级</div>
        <div class="action-desc">结合地理位置、人口密度、建筑密度等因素调整预警级别。</div>
      </el-card>
      <el-card shadow="hover" class="action-card supervise">
        <div class="action-title">预警督办</div>
        <div class="action-desc">通过督办人员、督办意见、通知方式和通知内容进行提醒。</div>
      </el-card>
      <el-card shadow="hover" class="action-card instruction">
        <div class="action-title">添加领导批示</div>
        <div class="action-desc">向相关领导发送预警信息并记录领导批示指导意见。</div>
      </el-card>
      <el-card shadow="hover" class="action-card return">
        <div class="action-title">预警退回</div>
        <div class="action-desc">现场仍有异常时退回处置单位重新复核和处置。</div>
      </el-card>
    </div>

    <el-card shadow="never" class="page-card">
      <el-form :model="queryParams" :inline="true">
        <el-form-item label="预警名称">
          <el-input v-model="queryParams.warningName" placeholder="请输入预警名称" clearable style="width: 220px" @keyup.enter="handleQuery" />
        </el-form-item>
        <el-form-item label="预警编号">
          <el-input v-model="queryParams.warningNo" placeholder="请输入预警编号" clearable style="width: 180px" />
        </el-form-item>
        <el-form-item label="预警类型">
          <el-select v-model="queryParams.warningType" clearable placeholder="请选择预警类型" style="width: 180px">
            <el-option
              v-for="item in warningTypeOptions"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="预警级别">
          <el-select v-model="queryParams.warningLevel" clearable placeholder="请选择预警级别" style="width: 180px">
            <el-option
              v-for="item in warningLevelOptions"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="queryParams.status" clearable placeholder="请选择状态" style="width: 180px">
            <el-option label="已发布" value="RELEASED" />
            <el-option label="待处理" value="PENDING" />
            <el-option label="处理中" value="PROCESSING" />
            <el-option label="已处理" value="HANDLED" />
            <el-option label="已解除" value="CLOSED" />
            <el-option label="已退回" value="RETURNED" />
          </el-select>
        </el-form-item>
        <el-form-item label="处置人">
          <el-input v-model="queryParams.handler" placeholder="请输入处置人" clearable style="width: 180px" />
        </el-form-item>
        <el-form-item label="设备编码">
          <el-input v-model="queryParams.deviceCode" placeholder="请输入设备编码" clearable style="width: 180px" />
        </el-form-item>
        <el-form-item label="发布时间">
          <el-date-picker
            v-model="queryParams.dateRange"
            type="datetimerange"
            value-format="YYYY-MM-DD HH:mm:ss"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            style="width: 360px"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <el-card shadow="never" class="page-card">
      <el-table :data="warningList">
        <el-table-column label="序号" width="70" align="center">
          <template #default="scope">
            {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column label="预警名称" prop="warningName" min-width="180" show-overflow-tooltip />
        <el-table-column label="预警编号" prop="warningNo" width="170" />
        <el-table-column label="预警类型" prop="warningTypeText" width="120" />
        <el-table-column label="预警级别" width="110" align="center">
          <template #default="scope">
            <el-tag :type="getLevelTagType(scope.row.warningLevel)">
              {{ scope.row.warningLevelText }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="处置人" prop="handler" width="120" />
        <el-table-column label="设备名称" prop="deviceName" min-width="140" show-overflow-tooltip />
        <el-table-column label="设备编码" prop="deviceCode" width="160" show-overflow-tooltip />
        <el-table-column label="发布人" prop="publisher" width="120" />
        <el-table-column label="报警位置" prop="location" min-width="180" show-overflow-tooltip />
        <el-table-column label="权属单位" prop="ownershipUnit" width="160" show-overflow-tooltip />
        <el-table-column label="状态" width="120" align="center">
          <template #default="scope">
            <el-tag :type="getStatusTagType(scope.row.status)">
              {{ getStatusText(scope.row.status) }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="发布时间" prop="publishTime" width="180" />
        <el-table-column label="操作" fixed="right" width="360" align="center">
          <template #default="scope">
            <el-button link type="primary" @click="openDetail(scope.row)">详情</el-button>
            <el-button link type="success" @click="openResolve(scope.row)">解除</el-button>
            <el-button link type="warning" @click="openUpgrade(scope.row)">升级</el-button>
            <el-button link type="primary" @click="openSupervision(scope.row)">督办</el-button>
            <el-button link type="info" @click="openInstruction(scope.row)">批示</el-button>
            <el-button link type="danger" @click="openReturn(scope.row)">退回</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="loadList"
      />
    </el-card>

    <el-drawer v-model="detailVisible" title="预警详情" size="820px" append-to-body>
      <template v-if="detailData.basicInfo">
        <el-descriptions :column="2" border>
          <el-descriptions-item label="预警名称">{{ detailBasic.warningName || "-" }}</el-descriptions-item>
          <el-descriptions-item label="预警编号">{{ detailBasic.warningNo || "-" }}</el-descriptions-item>
          <el-descriptions-item label="预警专项">{{ detailBasic.warningSpecial || "-" }}</el-descriptions-item>
          <el-descriptions-item label="预警类型">{{ detailBasic.warningTypeText || "-" }}</el-descriptions-item>
          <el-descriptions-item label="预警级别">{{ detailBasic.warningLevelText || "-" }}</el-descriptions-item>
          <el-descriptions-item label="状态">{{ getStatusText(detailBasic.status) }}</el-descriptions-item>
          <el-descriptions-item label="处置人">{{ detailBasic.handler || "-" }}</el-descriptions-item>
          <el-descriptions-item label="设备名称">{{ detailBasic.deviceName || "-" }}</el-descriptions-item>
          <el-descriptions-item label="设备编码">{{ detailBasic.deviceCode || "-" }}</el-descriptions-item>
          <el-descriptions-item label="发布人">{{ detailBasic.publisher || "-" }}</el-descriptions-item>
          <el-descriptions-item label="报警位置" :span="2">{{ detailBasic.location || "-" }}</el-descriptions-item>
          <el-descriptions-item label="权属单位">{{ detailBasic.ownershipUnit || "-" }}</el-descriptions-item>
          <el-descriptions-item label="发布时间">{{ detailBasic.publishTime || "-" }}</el-descriptions-item>
          <el-descriptions-item label="预警内容" :span="2">{{ detailBasic.warningContent || "-" }}</el-descriptions-item>
        </el-descriptions>

        <el-divider content-position="left">处置记录</el-divider>
        <el-timeline v-if="(detailData.disposalHistory || []).length">
          <el-timeline-item
            v-for="(item, index) in detailData.disposalHistory"
            :key="index"
            :timestamp="item.createTime || item.disposalTime || '-'"
          >
            {{ item.disposalContent || item.content || "-" }}
          </el-timeline-item>
        </el-timeline>
        <el-empty v-else description="暂无处置记录" />
      </template>
    </el-drawer>

    <el-dialog v-model="resolveVisible" title="预警解除" width="520px" append-to-body>
      <el-form label-width="100px">
        <el-form-item label="预警名称">
          <el-input :model-value="currentRow?.warningName || '-'" disabled />
        </el-form-item>
        <el-form-item label="核查说明">
          <el-input v-model="resolveForm.disposalContent" type="textarea" :rows="4" placeholder="请输入预警解除说明" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="resolveVisible = false">取 消</el-button>
        <el-button type="primary" :loading="submitLoading" @click="submitResolve">确 定</el-button>
      </template>
    </el-dialog>

    <el-dialog v-model="upgradeVisible" title="预警升级" width="560px" append-to-body>
      <el-form label-width="100px">
        <el-form-item label="预警名称">
          <el-input :model-value="currentRow?.warningName || '-'" disabled />
        </el-form-item>
        <el-form-item label="新预警级别">
          <el-select v-model="upgradeForm.newLevel" placeholder="请选择新预警级别" style="width: 100%">
            <el-option
              v-for="item in warningLevelOptions"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="升级说明">
          <el-input v-model="upgradeForm.disposalContent" type="textarea" :rows="4" placeholder="请输入预警升级说明" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="upgradeVisible = false">取 消</el-button>
        <el-button type="primary" :loading="submitLoading" @click="submitUpgrade">确 定</el-button>
      </template>
    </el-dialog>

    <el-dialog v-model="supervisionVisible" title="预警督办" width="620px" append-to-body>
      <el-form label-width="100px">
        <el-form-item label="督办人员">
          <el-input v-model="supervisionForm.supervisionUser" placeholder="请输入督办人员" />
        </el-form-item>
        <el-form-item label="督办意见">
          <el-input v-model="supervisionForm.supervisionContent" type="textarea" :rows="3" placeholder="请输入督办意见" />
        </el-form-item>
        <el-form-item label="通知方式">
          <el-select v-model="supervisionForm.notificationType" placeholder="请选择通知方式" style="width: 100%">
            <el-option label="短信" value="短信" />
            <el-option label="电话" value="电话" />
            <el-option label="系统通知" value="系统通知" />
            <el-option label="邮件" value="邮件" />
          </el-select>
        </el-form-item>
        <el-form-item label="通知内容">
          <el-input v-model="supervisionForm.notificationContent" type="textarea" :rows="3" placeholder="请输入通知内容" />
        </el-form-item>
        <el-form-item label="附件地址">
          <el-input v-model="supervisionForm.attachmentUrl" placeholder="请输入附件地址" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="supervisionVisible = false">取 消</el-button>
        <el-button type="primary" :loading="submitLoading" @click="submitSupervision">确 定</el-button>
      </template>
    </el-dialog>

    <el-dialog v-model="instructionVisible" title="添加领导批示" width="620px" append-to-body>
      <el-form label-width="100px">
        <el-form-item label="领导姓名">
          <el-input v-model="instructionForm.leaderName" placeholder="请输入领导姓名" />
        </el-form-item>
        <el-form-item label="批示内容">
          <el-input v-model="instructionForm.instructionContent" type="textarea" :rows="4" placeholder="请输入领导批示内容" />
        </el-form-item>
        <el-form-item label="短信接收人">
          <el-input v-model="instructionForm.smsReceivers" placeholder="请输入短信接收人，多个用逗号分隔" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="instructionVisible = false">取 消</el-button>
        <el-button type="primary" :loading="submitLoading" @click="submitInstruction">确 定</el-button>
      </template>
    </el-dialog>

    <el-dialog v-model="returnVisible" title="预警退回" width="520px" append-to-body>
      <el-form label-width="100px">
        <el-form-item label="预警名称">
          <el-input :model-value="currentRow?.warningName || '-'" disabled />
        </el-form-item>
        <el-form-item label="退回说明">
          <el-input v-model="returnForm.disposalContent" type="textarea" :rows="4" placeholder="请输入退回重办说明" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="returnVisible = false">取 消</el-button>
        <el-button type="primary" :loading="submitLoading" @click="submitReturn">确 定</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { computed, onMounted, reactive, ref } from "vue";
import { ElMessage } from "element-plus";
import {
  getAlertTypeDictionaryData,
  getWarningDetailData,
  getdbyjlistData,
  instructionWarningData,
  resolveWarningData,
  returnWarningData,
  supervisionWarningData,
  upgradeWarningData
} from "@/api/smxyjldczxt/yjxxfb/yjfb.js";

const loading = ref(false);
const submitLoading = ref(false);
const warningList = ref([]);
const total = ref(0);
const warningTypeOptions = ref([]);
const warningLevelOptions = ref([]);
const currentRow = ref(null);
const detailVisible = ref(false);
const detailData = ref({});

const resolveVisible = ref(false);
const upgradeVisible = ref(false);
const supervisionVisible = ref(false);
const instructionVisible = ref(false);
const returnVisible = ref(false);

const queryParams = reactive({
  pageNum: 1,
  pageSize: 10,
  warningName: "",
  warningNo: "",
  warningType: "",
  warningLevel: "",
  status: "",
  handler: "",
  deviceCode: "",
  dateRange: []
});

const resolveForm = reactive({
  disposalContent: ""
});

const upgradeForm = reactive({
  newLevel: "",
  disposalContent: ""
});

const supervisionForm = reactive({
  supervisionUser: "",
  supervisionContent: "",
  notificationType: "",
  notificationContent: "",
  attachmentUrl: ""
});

const instructionForm = reactive({
  leaderName: "",
  instructionContent: "",
  smsReceivers: ""
});

const returnForm = reactive({
  disposalContent: ""
});

const warningTypeLabelMap = computed(() => {
  return warningTypeOptions.value.reduce((acc, item) => {
    acc[item.dictValue] = item.dictLabel;
    return acc;
  }, {});
});

const warningLevelLabelMap = computed(() => {
  return warningLevelOptions.value.reduce((acc, item) => {
    acc[item.dictValue] = item.dictLabel;
    return acc;
  }, {});
});

const detailBasic = computed(() => {
  const basic = detailData.value.basicInfo || {};
  const warningType = basic.warningType || basic.warning_type || "";
  const warningLevel = basic.warningLevel || basic.warning_level || "";
  return {
    warningName: basic.warningName || basic.warning_name || "",
    warningNo: basic.warningNo || basic.warning_no || "",
    warningSpecial: basic.warningSpecial || basic.warning_special || "",
    warningTypeText: warningTypeLabelMap.value[warningType] || warningType || "-",
    warningLevelText: warningLevelLabelMap.value[warningLevel] || warningLevel || "-",
    status: basic.status || "",
    handler: basic.handler || "",
    deviceCode: basic.deviceCode || basic.device_code || "",
    deviceName: basic.deviceName || basic.device_name || "",
    publisher: basic.publisher || "",
    location: basic.location || "",
    ownershipUnit: basic.ownershipUnit || basic.ownership_unit || "",
    publishTime: basic.publishTime || basic.publish_time || "",
    warningContent: basic.warningContent || basic.warning_content || ""
  };
});

function getLevelTagType(level) {
  return {
    "1": "danger",
    "2": "warning",
    "3": "success",
    "4": "info"
  }[level] || "info";
}

function getStatusText(status) {
  return {
    DRAFT: "草稿",
    RELEASED: "已发布",
    PENDING: "待处理",
    PROCESSING: "处理中",
    HANDLED: "已处理",
    CLOSED: "已解除",
    RETURNED: "已退回"
  }[status] || status || "-";
}

function getStatusTagType(status) {
  return {
    DRAFT: "info",
    RELEASED: "success",
    PENDING: "warning",
    PROCESSING: "warning",
    HANDLED: "success",
    CLOSED: "",
    RETURNED: "danger"
  }[status] || "";
}

function normalizeWarningRow(item) {
  const warningType = item.warningType || item.warning_type || "";
  const warningLevel = item.warningLevel || item.warning_level || "";
  return {
    warningId: item.warningId || item.warning_id,
    warningName: item.warningName || item.warning_name || "",
    warningNo: item.warningNo || item.warning_no || "",
    warningType,
    warningTypeText: warningTypeLabelMap.value[warningType] || warningType || "-",
    warningLevel,
    warningLevelText: warningLevelLabelMap.value[warningLevel] || warningLevel || "-",
    handler: item.handler || "",
    deviceCode: item.deviceCode || item.device_code || "",
    deviceName: item.deviceName || item.device_name || "",
    publisher: item.publisher || "",
    location: item.location || "",
    ownershipUnit: item.ownershipUnit || item.ownership_unit || "",
    publishTime: item.publishTime || item.publish_time || "",
    status: item.status || ""
  };
}

function resetActionForms() {
  resolveForm.disposalContent = "";
  upgradeForm.newLevel = "";
  upgradeForm.disposalContent = "";
  supervisionForm.supervisionUser = "";
  supervisionForm.supervisionContent = "";
  supervisionForm.notificationType = "";
  supervisionForm.notificationContent = "";
  supervisionForm.attachmentUrl = "";
  instructionForm.leaderName = "";
  instructionForm.instructionContent = "";
  instructionForm.smsReceivers = "";
  returnForm.disposalContent = "";
}

async function loadDicts() {
  const [typeRes, levelRes] = await Promise.all([
    getAlertTypeDictionaryData({ dictType: "warning_type" }),
    getAlertTypeDictionaryData({ dictType: "warning_level" })
  ]);
  warningTypeOptions.value = typeRes.rows || [];
  warningLevelOptions.value = levelRes.rows || [];
}

async function loadList() {
  loading.value = true;
  try {
    const res = await getdbyjlistData({
      pageNum: queryParams.pageNum,
      pageSize: queryParams.pageSize,
      warningName: queryParams.warningName || undefined,
      warningNo: queryParams.warningNo || undefined,
      warningType: queryParams.warningType || undefined,
      warningLevel: queryParams.warningLevel || undefined,
      status: queryParams.status || undefined,
      handler: queryParams.handler || undefined,
      deviceCode: queryParams.deviceCode || undefined,
      startTime: queryParams.dateRange?.[0] || undefined,
      endTime: queryParams.dateRange?.[1] || undefined
    });
    warningList.value = (res.data?.records || []).map(normalizeWarningRow);
    total.value = res.data?.total || 0;
  } finally {
    loading.value = false;
  }
}

function handleQuery() {
  queryParams.pageNum = 1;
  loadList();
}

function resetQuery() {
  queryParams.pageNum = 1;
  queryParams.pageSize = 10;
  queryParams.warningName = "";
  queryParams.warningNo = "";
  queryParams.warningType = "";
  queryParams.warningLevel = "";
  queryParams.status = "";
  queryParams.handler = "";
  queryParams.deviceCode = "";
  queryParams.dateRange = [];
  loadList();
}

async function openDetail(row) {
  const res = await getWarningDetailData(row.warningId);
  detailData.value = res.data || {};
  detailVisible.value = true;
}

function openResolve(row) {
  currentRow.value = row;
  resetActionForms();
  resolveVisible.value = true;
}

function openUpgrade(row) {
  currentRow.value = row;
  resetActionForms();
  upgradeForm.newLevel = row.warningLevel;
  upgradeVisible.value = true;
}

function openSupervision(row) {
  currentRow.value = row;
  resetActionForms();
  supervisionVisible.value = true;
}

function openInstruction(row) {
  currentRow.value = row;
  resetActionForms();
  instructionVisible.value = true;
}

function openReturn(row) {
  currentRow.value = row;
  resetActionForms();
  returnVisible.value = true;
}

async function submitResolve() {
  if (!resolveForm.disposalContent) {
    ElMessage.warning("请输入解除说明");
    return;
  }
  submitLoading.value = true;
  try {
    const res = await resolveWarningData({
      warningId: currentRow.value.warningId,
      disposalContent: resolveForm.disposalContent
    });
    if (res.code !== 200) {
      ElMessage.error(res.msg || "解除失败");
      return;
    }
    ElMessage.success("解除成功");
    resolveVisible.value = false;
    loadList();
  } finally {
    submitLoading.value = false;
  }
}

async function submitUpgrade() {
  if (!upgradeForm.newLevel) {
    ElMessage.warning("请选择新预警级别");
    return;
  }
  if (!upgradeForm.disposalContent) {
    ElMessage.warning("请输入升级说明");
    return;
  }
  submitLoading.value = true;
  try {
    const res = await upgradeWarningData({
      warningId: currentRow.value.warningId,
      newLevel: upgradeForm.newLevel,
      disposalContent: upgradeForm.disposalContent
    });
    if (res.code !== 200) {
      ElMessage.error(res.msg || "升级失败");
      return;
    }
    ElMessage.success("升级成功");
    upgradeVisible.value = false;
    loadList();
  } finally {
    submitLoading.value = false;
  }
}

async function submitSupervision() {
  if (!supervisionForm.supervisionUser || !supervisionForm.supervisionContent || !supervisionForm.notificationType) {
    ElMessage.warning("请完善督办信息");
    return;
  }
  submitLoading.value = true;
  try {
    const res = await supervisionWarningData({
      warningId: currentRow.value.warningId,
      supervisionUser: supervisionForm.supervisionUser,
      supervisionContent: supervisionForm.supervisionContent,
      notificationType: supervisionForm.notificationType,
      notificationContent: supervisionForm.notificationContent,
      attachmentUrl: supervisionForm.attachmentUrl
    });
    if (res.code !== 200) {
      ElMessage.error(res.msg || "督办失败");
      return;
    }
    ElMessage.success("督办成功");
    supervisionVisible.value = false;
    loadList();
  } finally {
    submitLoading.value = false;
  }
}

async function submitInstruction() {
  if (!instructionForm.leaderName || !instructionForm.instructionContent) {
    ElMessage.warning("请完善领导批示信息");
    return;
  }
  submitLoading.value = true;
  try {
    const res = await instructionWarningData({
      warningId: currentRow.value.warningId,
      leaderName: instructionForm.leaderName,
      instructionContent: instructionForm.instructionContent,
      smsReceivers: instructionForm.smsReceivers
    });
    if (res.code !== 200) {
      ElMessage.error(res.msg || "批示失败");
      return;
    }
    ElMessage.success("添加批示成功");
    instructionVisible.value = false;
    loadList();
  } finally {
    submitLoading.value = false;
  }
}

async function submitReturn() {
  if (!returnForm.disposalContent) {
    ElMessage.warning("请输入退回说明");
    return;
  }
  submitLoading.value = true;
  try {
    const res = await returnWarningData({
      warningId: currentRow.value.warningId,
      disposalContent: returnForm.disposalContent
    });
    if (res.code !== 200) {
      ElMessage.error(res.msg || "退回失败");
      return;
    }
    ElMessage.success("退回成功");
    returnVisible.value = false;
    loadList();
  } finally {
    submitLoading.value = false;
  }
}

onMounted(async () => {
  await loadDicts();
  await loadList();
});
</script>

<style scoped>
.warning-disposal-page {
  background: #f5f7fb;
}

.page-card {
  border-radius: 16px;
  margin-bottom: 16px;
}

.header-card {
  background: linear-gradient(135deg, #eff6ff, #f8fbff);
  border: 1px solid #dbeafe;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: #1e3a8a;
}

.page-subtitle {
  margin-top: 8px;
  font-size: 13px;
  color: #64748b;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.action-card {
  border: none;
  color: #fff;
}

.action-card :deep(.el-card__body) {
  padding: 18px;
}

.action-card.resolve {
  background: linear-gradient(135deg, #059669, #34d399);
}

.action-card.upgrade {
  background: linear-gradient(135deg, #d97706, #f7b955);
}

.action-card.supervise {
  background: linear-gradient(135deg, #2563eb, #5b93ff);
}

.action-card.instruction {
  background: linear-gradient(135deg, #7c3aed, #9d72ff);
}

.action-card.return {
  background: linear-gradient(135deg, #dc2626, #f87171);
}

.action-title {
  font-size: 16px;
  font-weight: 700;
}

.action-desc {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.7;
  opacity: 0.95;
}

@media (max-width: 1400px) {
  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .action-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
</style>
