/* 鲸选RPA 管理后台 · 通用组件：卡片、表格、提示、弹窗 */

/* ---------- 卡片 ---------- */

.card {
  --card-px: 20px;
  min-width: 0;
  padding: 20px var(--card-px);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-surface);
}
@media (min-width: 640px) {
  .card { --card-px: 24px; padding: 20px var(--card-px) 24px; }
}

.card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-height: 32px;
  margin-bottom: 16px;
}
.card-title > div:first-child { min-width: 0; }
.card-title h2 { font-size: 16px; font-weight: 600; line-height: 1.4; }
.card-title .subtle { font-size: 13px; }
.card-title p.subtle { margin-top: 2px; }
.card-title-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }

.card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.grid { display: grid; gap: 20px; }
@media (min-width: 1024px) {
  .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
}

/* 带说明气泡的信息按钮（纯 CSS，悬停和键盘聚焦都能看到） */
.info-tip {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
}
.info-tip:hover:not(:disabled) { background: var(--muted); color: var(--foreground); }
.info-tip .icon { width: 16px; height: 16px; }
.info-tip .tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: -8px;
  z-index: 20;
  width: max-content;
  max-width: min(280px, 70vw);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--foreground);
  color: #ffffff;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s, visibility 0.15s;
}
.info-tip:hover .tooltip, .info-tip:focus-visible .tooltip { opacity: 1; visibility: visible; }
/* 手机端改为相对整行标题定位，气泡不会伸出屏幕右侧 */
@media (max-width: 639px) {
  .card-title-main:has(> .info-tip) { position: relative; }
  .card-title-main > .info-tip { position: static; }
  .card-title-main > .info-tip .tooltip { left: 0; max-width: 100%; }
}

/* ---------- 分段切换 / 页签 ---------- */

.segmented, .card-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--muted);
}
.segmented button, .card-tabs button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-foreground);
  font-weight: 500;
}
.segmented button:hover:not(:disabled), .card-tabs button:hover:not(:disabled) { background: rgb(255 255 255 / 0.65); color: var(--foreground); }
.segmented button.active, .segmented button[aria-pressed="true"],
.card-tabs button.active {
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgb(20 41 60 / 0.1), 0 0 0 1px rgb(20 41 60 / 0.05);
}
.card-tabs { margin-bottom: 16px; }

/* ---------- 工具栏 ---------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.toolbar > input { flex: 1 1 240px; max-width: 380px; }
.toolbar > select { flex: 0 1 auto; width: auto; min-width: 150px; max-width: 220px; }
.toolbar-spacer { flex: 1 1 0; min-width: 0; }
.mapping-filters { display: contents; }
.mapping-filters select { flex: 0 1 auto; width: auto; min-width: 150px; max-width: 220px; }

/* 日志与平台列表的创建日期筛选（由原逻辑动态插入） */
#list-date-controls { margin-top: -4px; }
#list-date-controls label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--muted-foreground);
  font-weight: 400;
  white-space: nowrap;
}
#list-date-controls input { width: 168px; }
#list-date-controls small { color: var(--muted-foreground); font-size: 12px; }

/* ---------- 表格 ---------- */

.table-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap[aria-busy="true"]:not(.background-refresh) tbody { opacity: 0.6; transition: opacity 0.2s; }
/* 轮询刷新时不遮挡列表，只在可视区右下角给出提示。 */
#generic .table-wrap.background-refresh::after {
  content: "正在更新";
  position: sticky;
  left: calc(100% - 96px);
  bottom: 8px;
  z-index: 8;
  display: block;
  width: max-content;
  margin: -36px 12px 8px auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.96);
  box-shadow: var(--shadow-popover);
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.5;
}

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th {
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--foreground);
  line-height: 1.5;
  vertical-align: middle;
  transition: background-color 0.12s;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fafd; }
td small { display: block; margin-top: 2px; color: var(--muted-foreground); font-size: 12px; }
td .badge + small, td .badge + br + small { margin-top: 4px; }
th input[type="checkbox"], td input[type="checkbox"] { display: inline-grid; }

/* 卡片内的表格左右贴边，首末列与卡片内容对齐。 */
.list-card > .table-wrap, .home-recent .table-wrap, .statistics-detail-card .table-wrap,
.card > .table-wrap.bleed {
  width: calc(100% + 2 * var(--card-px));
  margin-inline: calc(-1 * var(--card-px));
}
.list-card > .table-wrap th:first-child, .list-card > .table-wrap td:first-child,
.home-recent .table-wrap th:first-child, .home-recent .table-wrap td:first-child,
.statistics-detail-card .table-wrap th:first-child, .statistics-detail-card .table-wrap td:first-child { padding-left: var(--card-px); }
.list-card > .table-wrap th:last-child, .list-card > .table-wrap td:last-child,
.home-recent .table-wrap th:last-child, .home-recent .table-wrap td:last-child,
.statistics-detail-card .table-wrap th:last-child, .statistics-detail-card .table-wrap td:last-child { padding-right: var(--card-px); }

.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-actions button, td > button:not(.link) { height: var(--control-height-sm); padding: 0 10px; font-size: 13px; }
.row-actions button:not(.secondary):not(.danger):not(.link):not(.business-send-toggle),
td > button:not(.secondary):not(.danger):not(.link) { background: var(--primary-soft); color: var(--primary); }
.row-actions button:not(.secondary):not(.danger):not(.link):not(.business-send-toggle):hover:not(:disabled),
td > button:not(.secondary):not(.danger):not(.link):hover:not(:disabled) { background: var(--primary-soft-hover); }
.row-actions button.secondary, td > button.secondary { background: transparent; }
.row-actions button.secondary:hover:not(:disabled), td > button.secondary:hover:not(:disabled) { background: var(--muted); }
td > button.link { font-size: 14px; }

/* 通用列表（任务中心另有专用样式）：宽屏为表格，短文本不换行、放不下时横向滚动；
   窄屏每行改为记录卡，列名取自 shell.js 写入的 data-label。 */
@media (min-width: 1024px) {
  body:not([data-page="tasks"]) #generic tbody td:not(.content-preview):not([colspan]) { white-space: nowrap; }
  body:not([data-page="tasks"]) #generic tbody td.content-preview { min-width: 180px; max-width: 320px; }
  /* 操作按钮多时最多排两行；操作列固定在右侧，列多需要横向滚动时也始终可见 */
  body:not([data-page="tasks"]) #generic tbody td > .row-actions { width: max-content; max-width: 360px; }
  body:not([data-page="tasks"]) #generic table:has(tbody td:last-child > .row-actions:not(:empty)) :is(th, td):last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background: var(--card);
  }
  body:not([data-page="tasks"]) #generic table:has(tbody td:last-child > .row-actions:not(:empty)) tbody tr:hover > td:last-child { background: #f8fafd; }
  /* 只有固定列下面确实压着未显示的列时才出现分隔阴影；表格放得下时不画线 */
  @supports (animation-timeline: scroll()) {
    body:not([data-page="tasks"]) #generic .table-wrap { scroll-timeline: --generic-table-x x; }
    body:not([data-page="tasks"]) #generic table:has(tbody td:last-child > .row-actions:not(:empty)) :is(th, td):last-child {
      animation: sticky-column-edge linear both;
      animation-timeline: --generic-table-x;
    }
  }
}
@keyframes sticky-column-edge {
  0%, 96% { box-shadow: inset 1px 0 0 var(--border), -10px 0 12px -10px rgb(20 41 60 / 0.22); }
  100% { box-shadow: inset 1px 0 0 transparent, -10px 0 12px -10px transparent; }
}
@media (max-width: 1023px) {
  body:not([data-page="tasks"]) #generic .table-wrap table,
  body:not([data-page="tasks"]) #generic .table-wrap thead,
  body:not([data-page="tasks"]) #generic .table-wrap tbody { display: block; }
  body:not([data-page="tasks"]) #generic thead tr { display: flex; align-items: center; padding: 10px var(--card-px); border-bottom: 1px solid var(--border); background: rgb(239 243 248 / 0.5); }
  body:not([data-page="tasks"]) #generic thead th { display: none; }
  body:not([data-page="tasks"]) #generic thead th:has(> input[type="checkbox"]) { display: inline-flex; align-items: center; gap: 10px; height: auto; padding: 0; border: 0; background: transparent; font-size: 13px; }
  body:not([data-page="tasks"]) #generic thead th:has(> input[type="checkbox"])::after { content: "全选"; }
  body:not([data-page="tasks"]) #generic thead:not(:has(input[type="checkbox"])) { display: none; }
  body:not([data-page="tasks"]) #generic thead:not(:has(input[type="checkbox"])) + tbody { border-top: 1px solid var(--border); }
  /* 列表为空时“全选”没有可选对象，卡片模式下不显示这一栏。 */
  body:not([data-page="tasks"]) #generic .table-wrap:not(:has(tbody tr)) thead { display: none; }

  body:not([data-page="tasks"]) #generic tbody tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 6px;
    padding: 14px var(--card-px);
    border-bottom: 1px solid var(--border-soft);
    transition: background-color 0.12s;
  }
  body:not([data-page="tasks"]) #generic tbody tr:last-child { border-bottom: 0; }
  body:not([data-page="tasks"]) #generic tbody tr:hover { background: #f8fafd; }
  /* 列名浮动在左侧留白里：flow-root 让单元格包住换行的长列名。 */
  body:not([data-page="tasks"]) #generic tbody td {
    display: flow-root;
    grid-column: 2;
    min-width: 0;
    max-width: none;
    padding: 0 0 0 96px;
    border: 0;
    background: transparent;
    overflow-wrap: anywhere;
  }
  /* keep-all：超长列名（如"发送机器人/发送池"）在斜杠处换行，而不是从字中间断开。 */
  body:not([data-page="tasks"]) #generic tbody td::before { content: attr(data-label); float: left; width: 84px; margin-left: -96px; padding-top: 1px; color: var(--muted-foreground); font-size: 13px; line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; }
  /* 勾选框在左列，首个数据列作为记录标题，末尾的操作列不加列名。 */
  body:not([data-page="tasks"]) #generic tbody td:first-child:has(> input[type="checkbox"]) { grid-column: 1; grid-row: 1; padding: 2px 12px 0 0; }
  body:not([data-page="tasks"]) #generic tbody td:first-child:not(:has(> input[type="checkbox"])):not([colspan]),
  body:not([data-page="tasks"]) #generic tbody td:first-child:has(> input[type="checkbox"]) + td { grid-row: 1; padding-left: 0; font-size: 15px; font-weight: 600; }
  /* 卡密与服务、群映射的第一列是分类（类型 / 来源设备），用第二列（名称 / 来源群）作标题。 */
  body:is([data-page="licenses"], [data-page="routing"]) #generic tbody td:first-child:not(:has(> input[type="checkbox"])):not([colspan]) { grid-row: auto; padding-left: 96px; font-size: 14px; font-weight: 400; }
  body:is([data-page="licenses"], [data-page="routing"]) #generic tbody td:first-child:not(:has(> input[type="checkbox"])):not([colspan]) + td { order: -1; padding-left: 0; font-size: 15px; font-weight: 600; }
  body:not([data-page="tasks"]) #generic tbody td:last-child:not(:first-child):has(button) { padding-left: 0; margin-top: 4px; }
  /* 当前没有可用操作时，不留一个空的"操作"列名 */
  body:not([data-page="tasks"]) #generic tbody td:last-child:not(:first-child):is(:empty, :has(> .row-actions:empty)) { display: none; }
  body:not([data-page="tasks"]) #generic tbody tr:has(> td[colspan]) { display: block; padding: 0; }
  body:not([data-page="tasks"]) #generic tbody td[colspan] { padding: 10px var(--card-px); }
  body:not([data-page="tasks"]) #generic tbody tr.customer-service-section td { background: rgb(239 243 248 / 0.5); }
  body:not([data-page="tasks"]) #generic tbody td:first-child:has(> input[type="checkbox"])::before,
  body:not([data-page="tasks"]) #generic tbody td:first-child:not(:has(> input[type="checkbox"]))::before,
  body:not([data-page="tasks"]) #generic tbody td:first-child:has(> input[type="checkbox"]) + td::before,
  body:not([data-page="tasks"]) #generic tbody td:last-child:not(:first-child):has(button)::before,
  body:not([data-page="tasks"]) #generic tbody td[colspan]::before { content: none; }
  body:is([data-page="licenses"], [data-page="routing"]) #generic tbody td:first-child:not(:has(> input[type="checkbox"])):not([colspan])::before { content: attr(data-label); }
  body:is([data-page="licenses"], [data-page="routing"]) #generic tbody td:first-child:not(:has(> input[type="checkbox"])):not([colspan]) + td::before { content: none; }
}

/* ---------- 空状态 ---------- */

.empty, td.empty {
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  text-wrap: balance;
}
/* app.js toggles #empty-state with an inline display:block, so the layout must not depend on flex. */
.empty {
  display: block;
  padding: 40px 24px;
  border-radius: var(--radius);
  background: rgb(239 243 248 / 0.6);
}
.empty::before, td.empty::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border-radius: var(--radius);
  background: var(--card) var(--icon-inbox) center / 20px no-repeat;
  box-shadow: 0 0 0 1px var(--border);
}
td.empty { padding: 40px 24px !important; background: rgb(239 243 248 / 0.45); }
tbody tr:hover td.empty { background: rgb(239 243 248 / 0.45); }
.list-card > .empty { margin-top: 4px; }

.chart-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 240px;
  padding: 32px 24px;
  border-radius: var(--radius);
  background: rgb(239 243 248 / 0.6);
  text-align: center;
}
.chart-empty .chart-empty-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted-foreground);
  box-shadow: 0 0 0 1px var(--border);
}
.chart-empty .chart-empty-icon .icon { width: 20px; height: 20px; }
.chart-empty b { font-size: 14px; font-weight: 600; }
.chart-empty p { max-width: 320px; color: var(--muted-foreground); font-size: 14px; }

/* ---------- 提示条 ---------- */

.health-notices {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-xl);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgb(29 111 184 / 0.12);
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.6;
}
.health-notices > div:not(.health-actions) { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.health-notices b { color: var(--primary); font-weight: 600; }
.health-notices span { color: var(--muted-foreground); text-wrap: pretty; }
.health-notices.warning { background: #fdf5ea; box-shadow: inset 0 0 0 1px rgb(180 83 9 / 0.16); }
.health-notices.warning b { color: var(--warning); }
.health-actions { display: flex; flex: none; flex-wrap: wrap; gap: 8px; }
.notice-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgb(29 111 184 / 0.1);
  color: var(--primary);
}
.health-notices.warning .notice-icon { background: rgb(180 83 9 / 0.12); color: var(--warning); }
@media (max-width: 639px) {
  .health-notices { flex-wrap: wrap; align-items: flex-start; }
  .health-actions { width: 100%; padding-left: 50px; }
}

.inline-notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #fdf5ea;
  box-shadow: inset 0 0 0 1px rgb(180 83 9 / 0.16);
  color: var(--warning);
  font-size: 14px;
}

/* ---------- 分页 ---------- */

.mapping-pagination, .statistics-daily-pagination, .dispatch-pagination, .dispatch-history-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 16px;
  color: var(--muted-foreground);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.mapping-pagination > div, .statistics-daily-pagination > div, .dispatch-pagination > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mapping-pagination button, .statistics-daily-pagination button, .dispatch-pagination button, .dispatch-history-pagination button { height: var(--control-height-sm); padding: 0 12px; font-size: 13px; }
.mapping-pagination select { width: auto; height: var(--control-height-sm); }

/* ---------- 折叠详情 ---------- */

details > summary { cursor: pointer; }
details.business-secondary, details.task-detail-history {
  border-radius: var(--radius);
  background: var(--muted);
}
details.business-secondary > summary, details.task-detail-history > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
  list-style: none;
}
details.business-secondary > summary::-webkit-details-marker, details.task-detail-history > summary::-webkit-details-marker { display: none; }
details.business-secondary > summary::before, details.task-detail-history > summary::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--icon-chevron-down) center / contain no-repeat;
  transform: rotate(-90deg);
  transition: transform 0.15s;
}
details[open].business-secondary > summary::before, details[open].task-detail-history > summary::before { transform: none; }
details.business-secondary > :not(summary), details.task-detail-history > :not(summary) { margin: 0 14px 12px; }

/* ---------- 轻提示与全局错误 ---------- */

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 1000;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--foreground);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.55;
  box-shadow: 0 12px 32px -8px rgb(20 41 60 / 0.45);
  transform: translateX(-50%);
  animation: toast-in 0.2s ease-out;
}
.toast.error { background: var(--destructive); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
/* 登录后有侧栏时，居中到右侧内容区，避免压住侧栏边缘。 */
@media (min-width: 768px) {
  body:has(#app-shell:not([hidden])) .toast {
    left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
    max-width: min(520px, calc(100vw - var(--sidebar-width) - 32px));
  }
}

.client-error {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: min(440px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--destructive);
  font-size: 14px;
  box-shadow: var(--shadow-popover), inset 3px 0 0 var(--destructive);
}

/* ---------- 弹窗 ---------- */

dialog {
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  max-height: min(880px, calc(100dvh - 32px));
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-dialog);
}
dialog[open] { display: flex; flex-direction: column; animation: pop-in 0.16s ease-out; }
dialog::backdrop { background: rgb(15 32 48 / 0.45); animation: fade-in 0.16s ease-out; }
dialog > form { display: flex; flex: 1; flex-direction: column; min-height: 0; }

.dialog-header, dialog > .card-title, dialog > form > .card-title {
  display: flex;
  flex: none;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  min-height: 0;
  margin: 0;
  padding: 16px 20px 16px 24px;
  border-bottom: 1px solid var(--border);
}
.dialog-header h2, dialog > .card-title h2, dialog > form > .card-title h2 { flex: 1; min-width: 0; font-size: 17px; }

.dialog-close, #editor-close, #business-detail-close {
  flex: none;
  height: 32px;
  padding: 0 10px 0 8px;
  border-color: transparent;
  background: transparent;
  color: var(--muted-foreground);
}
.dialog-close::before, #editor-close::before, #business-detail-close::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--icon-x) center / contain no-repeat;
  mask: var(--icon-x) center / contain no-repeat;
}
.dialog-close:hover:not(:disabled), #editor-close:hover:not(:disabled), #business-detail-close:hover:not(:disabled) { border-color: transparent; background: var(--muted); color: var(--foreground); }

.editor-dialog { width: min(640px, calc(100vw - 32px)); }
.editor-scroll { display: flex; flex: 1; flex-direction: column; gap: 16px; min-height: 0; padding: 20px 24px 24px; overflow-y: auto; }
.editor-fields { display: grid; gap: 16px; }
.editor-actions {
  display: flex;
  flex: none;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: #fafbfd;
}
.editor-actions button { min-width: 88px; }
.editor-static-note {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 400;
}
.result-box {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgb(19 120 74 / 0.08);
  color: var(--foreground);
  font-size: 13px;
  line-height: 1.7;
  word-break: break-all;
  white-space: pre-wrap;
}
.result-box code { background: var(--card); }

.confirm-dialog { width: min(440px, calc(100vw - 32px)); }
.confirm-dialog form { align-items: flex-start; gap: 6px; padding: 24px; }
.confirm-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgb(180 83 9 / 0.1);
  color: var(--warning);
}
.confirm-icon .icon { width: 20px; height: 20px; }
#confirm-title { font-size: 17px; }
#confirm-message {
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
  word-break: break-word;
}
.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; width: 100%; margin-top: 18px; }
.confirm-dialog-actions button { min-width: 80px; }
/* 删除、撤销、停用等操作：图标与确认按钮改用警示红（data-tone 由 shell.js 按确认文案标记）。 */
.confirm-dialog[data-tone="danger"] .confirm-icon { background: var(--destructive-soft); color: var(--destructive); }
.confirm-dialog[data-tone="danger"] .confirm-dialog-actions [value="confirm"],
.confirm-dialog form > .row-actions button.danger { border-color: transparent; background: var(--destructive); color: var(--primary-foreground); }
.confirm-dialog[data-tone="danger"] .confirm-dialog-actions [value="confirm"]:hover:not(:disabled),
.confirm-dialog form > .row-actions button.danger:hover:not(:disabled) { background: var(--destructive-hover); }
/* 模块自带的确认框（如删除群分组）：标题 + 说明段落 + .row-actions */
.confirm-dialog form > h2 { margin-bottom: 4px; font-size: 17px; }
.confirm-dialog form > p { color: var(--muted-foreground); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.confirm-dialog form > p[role="alert"] { color: var(--destructive); font-size: 13px; }
.confirm-dialog form > p:empty { display: none; }
.confirm-dialog form > .row-actions { justify-content: flex-end; gap: 8px; width: 100%; margin-top: 18px; }
.confirm-dialog form > .row-actions button { height: var(--control-height); min-width: 80px; padding: 0 14px; font-size: 14px; }
.confirm-dialog form > .row-actions button.secondary { background: var(--card); }

/* ---------- 业务详情弹窗（任务详情 / 操作详情 / 群映射详情） ---------- */

.business-detail-dialog { width: min(920px, calc(100vw - 32px)); }
.business-detail-header-actions, .business-detail-header-actions-inner { display: flex; flex: none; flex-wrap: wrap; gap: 8px; }
.business-detail-header-actions:empty { display: none; }
.business-detail-header-actions button { height: 32px; padding: 0 12px; font-size: 13px; }
.business-detail-header-actions .task-pause-button { border-color: var(--input); background: var(--card); color: var(--foreground); }
.business-detail-header-actions .task-pause-button:hover:not(:disabled) { border-color: var(--input-hover); background: var(--muted); }
.business-detail-header-actions .task-pause-button:active:not(:disabled) { background: var(--secondary); }
#business-detail-content { flex: 1; min-height: 0; padding: 20px 24px 24px; overflow-y: auto; }
#business-detail-content > p.subtle, #business-detail-content > p[role="alert"] { font-size: 14px; }
#business-detail-content > p[role="alert"] { color: var(--destructive); }
#business-detail-content h3 { margin: 24px 0 10px; font-size: 15px; }
#business-detail-content > details.business-secondary { margin-top: 20px; }

.task-detail-icon { flex: none; width: 16px; height: 16px; }

/* 字段表：两列、标签居左，与派发详情一致 */
.business-detail-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; margin: 0; }
.business-detail-fields > div { display: flex; align-items: flex-start; gap: 12px; min-width: 0; padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.business-detail-fields dt { flex: none; width: 112px; color: var(--muted-foreground); font-size: 13px; line-height: 22px; }
.business-detail-fields dd { flex: 1; min-width: 0; margin: 0; font-size: 14px; line-height: 22px; overflow-wrap: anywhere; }

.task-business-detail { display: flex; flex-direction: column; gap: 20px; }
.task-detail-info > .task-info-row { gap: 10px; }
.task-detail-info > .task-info-row > .task-detail-icon { margin-top: 3px; color: var(--placeholder); }
.task-detail-info dt { width: 104px; }
.task-info-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: rgb(180 83 9 / 0.1);
  color: var(--warning);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  vertical-align: middle;
}
.task-info-status::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.task-info-status.ok { background: rgb(19 120 74 / 0.1); color: var(--success); }
.task-info-status.error { background: rgb(191 58 58 / 0.1); color: var(--destructive); }

/* 任务操作说明：图标 + 两条可否操作的原因 + 状态 */
.business-detail-actions { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--muted); }
.business-detail-operation-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow-surface);
}
.business-detail-operation-icon .task-detail-icon { width: 18px; height: 18px; }
.business-detail-operation-copy { flex: 1; min-width: 0; }
.business-detail-operation-copy strong { display: block; font-size: 14px; font-weight: 600; line-height: 1.5; }
.business-detail-operation-copy .detail-action-reason { margin-top: 2px; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.business-status-chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.business-status-chip .task-detail-icon { width: 14px; height: 14px; }
.business-status-chip.ok { background: rgb(19 120 74 / 0.1); color: var(--success); }
.business-status-chip.warn { background: rgb(180 83 9 / 0.1); color: var(--warning); }

#business-detail-content .task-business-detail section > h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.task-business-detail section > h3 > .task-detail-icon { color: var(--muted-foreground); }
.business-detail-preview {
  max-height: 280px;
  margin: 0;
  padding: 12px 14px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbfd;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* 执行时间线：标题一行，时间与说明在下方 */
.business-timeline { margin: 0; padding: 0; list-style: none; }
.task-detail-timeline > li {
  position: relative;
  display: grid;
  grid-template-columns: 28px auto minmax(0, 1fr);
  column-gap: 12px;
  padding-bottom: 16px;
}
.task-detail-timeline > li:last-child { padding-bottom: 0; }
.task-detail-timeline > li:not(:last-child)::before { content: ""; position: absolute; top: 32px; bottom: 4px; left: 14px; width: 1px; background: var(--border); }
.task-event-icon { display: grid; grid-row: 1; grid-column: 1; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.task-event-icon .task-detail-icon { width: 15px; height: 15px; }
.task-event-check .task-event-icon { background: rgb(19 120 74 / 0.1); color: var(--success); }
.task-event-pause .task-event-icon { background: rgb(180 83 9 / 0.1); color: var(--warning); }
.task-event-clock .task-event-icon { background: var(--muted); color: var(--muted-foreground); }
.task-detail-timeline strong { grid-row: 1; grid-column: 2 / 4; font-size: 14px; font-weight: 600; line-height: 28px; }
.task-detail-timeline time { grid-row: 2; grid-column: 2; color: var(--muted-foreground); font-size: 13px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.task-detail-timeline span { grid-row: 2; grid-column: 3; min-width: 0; color: var(--muted-foreground); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }

/* 更多历史记录（折叠） */
.task-history-fields { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; line-height: 1.6; }
.task-history-fields dt { color: var(--muted-foreground); }
.task-history-fields dd { margin: 0; overflow-wrap: anywhere; }
#business-detail-content details > h3 { margin: 16px 14px 6px; font-size: 14px; }
#business-detail-content details > p.subtle { font-size: 13px; }
.business-timeline:not(.task-detail-timeline) > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; line-height: 1.6; }
.business-timeline:not(.task-detail-timeline) > li:last-child { border-bottom: 0; }
.business-timeline:not(.task-detail-timeline) :is(time, span) { color: var(--muted-foreground); }
.business-timeline:not(.task-detail-timeline) time { font-variant-numeric: tabular-nums; }
details.task-detail-history details.business-secondary { background: var(--card); }

/* 操作详情的字段变更表、群映射详情的目标群表 */
.business-diff-wrap, .mapping-detail-targets .table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.business-diff th, .mapping-detail-targets th { background: #fafbfd; }
.business-diff td { min-width: 140px; vertical-align: top; overflow-wrap: anywhere; }
.business-diff td:first-child { min-width: 112px; color: var(--muted-foreground); }
.mapping-detail-targets { margin-top: 20px; }
.mapping-detail-targets .toolbar { margin-bottom: 12px; }

@media (max-width: 639px) {
  dialog { width: 100vw; max-height: calc(100dvh - 24px); margin: auto 0 0; border-radius: 16px 16px 0 0; }
  /* 各弹窗的桌面宽度写在类名上，手机端统一铺满成底部弹层 */
  dialog[class] { width: 100vw; }
  .dialog-header, dialog > .card-title, dialog > form > .card-title { padding: 14px 16px; }
  .editor-scroll, #business-detail-content { padding: 16px; }
  .editor-actions { padding: 12px 16px; }
  .editor-actions button { flex: 1; }
  .confirm-dialog { width: 100vw; }
  .confirm-dialog-actions button, .confirm-dialog form > .row-actions button { flex: 1; }
  dialog > .business-detail-header { flex-wrap: wrap; }
  .business-detail-header-actions { order: 3; width: 100%; }
  .business-detail-header-actions-inner { flex: 1; }
  .business-detail-header-actions button { flex: 1; height: var(--control-height); }
  .business-detail-fields { grid-template-columns: minmax(0, 1fr); }
  .business-detail-fields dt { width: 96px; }
  .task-history-fields { grid-template-columns: 96px minmax(0, 1fr); }
  .business-detail-actions { flex-wrap: wrap; }
  .business-detail-operation-copy { flex-basis: calc(100% - 44px); }
  .business-detail-actions .business-status-chip { margin-left: 44px; }
  .task-detail-timeline > li { grid-template-columns: 28px minmax(0, 1fr); }
  .task-detail-timeline strong { grid-column: 2; }
  .task-detail-timeline span { grid-row: 3; grid-column: 2; }
}
