/* 网维中心 · 差异 / 日志 / 浮层 / 断点（4/4）
   断点：<1024 折顶栏、<640 表格变两行卡片、≥1200 放宽外边距、≥1440 放松固定列。 */
/* ------------------------------------------------------ 14. 差异与日志 */
.diff { display: flex; flex-direction: column; gap: var(--sp-3); }
.diff__block { border-radius: var(--r-2); padding: var(--sp-3); }
.diff__block--before { background: var(--danger-wash); }
.diff__block--after { background: var(--success-wash); }
.diff__label { display: flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-caption); font-weight: 500; }
.diff__block--before .diff__label { color: var(--danger-ink); }
.diff__block--after .diff__label { color: var(--success-ink); }
.diff__pre {
  margin: var(--sp-2) 0 0; font-family: var(--font-mono); font-size: var(--fs-cell);
  line-height: var(--lh-cell); color: var(--ink); white-space: pre-wrap; word-break: break-all; max-width: 100%;
}

.logs { display: flex; flex-direction: column; padding: var(--sp-2) 0; }
.logline {
  display: grid; grid-template-columns: 72px 56px minmax(0, 1fr); gap: var(--sp-3);
  min-height: 24px; padding: 2px var(--sp-4); align-items: baseline;
}
.logline:hover { background: var(--row-hover); }
.logline__t { font-family: var(--font-mono); font-size: var(--fs-cell); color: var(--muted); }
.logline__lv { font-size: var(--fs-caption); font-weight: 500; }
.logline__lv--error { color: var(--danger-ink); }
.logline__lv--warn { color: var(--warning-ink); }
.logline__lv--info { color: var(--muted); }
.logline__msg { font-family: var(--font-mono); font-size: var(--fs-cell); line-height: var(--lh-cell); word-break: break-word; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.logpre {
  margin: 0; padding: var(--sp-4); background: var(--raised); border-radius: var(--r-2);
  font-family: var(--font-mono); font-size: var(--fs-cell); line-height: var(--lh-cell);
  white-space: pre-wrap; word-break: break-all; max-height: 60vh; overflow: auto;
}

/* 键值清单（环境区、影响面） */
.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--sp-2) var(--sp-4); font-size: var(--fs-body); }
.kv dt { color: var(--muted); font-size: var(--fs-caption); line-height: var(--lh-body); }
.kv dd { margin: 0; }
.kv--loose { grid-template-columns: 112px minmax(0, 1fr); }

/* --------------------------------------------------------- 15. 模态与 Toast */
dialog.modal {
  width: min(560px, calc(100vw - var(--sp-6))); max-height: calc(100dvh - var(--sp-8));
  padding: 0; border: 1px solid var(--border); border-radius: var(--r-3);
  background: var(--surface); color: var(--ink); overflow: auto;
}
dialog.modal[open] { animation: modalin var(--mo-modal) var(--ease); }
.modal--wide { width: min(720px, calc(100vw - var(--sp-6))); }
dialog.modal::backdrop { background: var(--scrim); }
@keyframes modalin { from { opacity: 0; } to { opacity: 1; } }
.modal__head {
  display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: var(--fs-section); line-height: var(--lh-section); }
.modal__body { display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-4); }
.modal__foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  padding: var(--sp-4); border-top: 1px solid var(--border);
}
.modal__foot .btn:first-child { margin-right: 0; }
.modal__foot-spacer { margin-left: auto; }
.impact { display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--fs-body); }
.impact__row { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: var(--sp-3); }
.impact__key { font-size: var(--fs-caption); color: var(--muted); line-height: var(--lh-body); }

.toasts {
  position: fixed; left: 50%; bottom: var(--sp-6); z-index: 50;
  display: flex; flex-direction: column; gap: var(--sp-2); align-items: center;
  transform: translateX(-50%); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-2); max-width: min(480px, calc(100vw - var(--sp-8)));
  padding: var(--sp-2) var(--sp-4); background: var(--ink); color: var(--bg);
  border-radius: var(--r-2); font-size: var(--fs-body);
  animation: toastin var(--mo-panel) var(--ease);
}
.toast--bad { background: var(--danger); color: #ffffff; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 登录页 */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-6); }
.login__card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: var(--sp-6); }
.login__title { font-size: var(--fs-title); line-height: var(--lh-title); }
.login__hint { font-size: var(--fs-caption); color: var(--muted); }

/* --------------------------------------------------- 15b. 补充件 */
.modal__close { margin-left: auto; }
.panel__body--row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--sp-4); }
.panel__body--stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.grow { flex: 1 1 320px; }
.sel--sm { min-height: 32px; font-size: var(--fs-cell); }
.list { margin: 0; padding-left: var(--sp-5); font-size: var(--fs-body); line-height: var(--lh-body); }
.list .mono { line-height: var(--lh-body); }
.check .field__hint { display: block; }
.table__sub { display: block; font-size: var(--fs-caption); color: var(--muted); }
.table td .status + .status { margin-left: var(--sp-2); }

/* 列表顺序用 CSS 计数器，不依赖后端算序号 */
.md__list { counter-reset: prog; }
.md__item { counter-increment: prog; }
.md__seq::before { content: counter(prog); }
/* 表格行号（模拟器「顺序」列） */
.table--count { counter-reset: row; }
.table--count tbody tr { counter-increment: row; }
.table--count tbody td:first-child::before { content: counter(row); }

/* ------------------------------------------- 16. 断点：平板折顶栏、手机换布局 */
@media (max-width: 1023px) {
  :root { --gutter: var(--sp-4); --shell-top: 0px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar-m) minmax(0, 1fr); }
  .topbar { height: var(--topbar-m); padding: 0 var(--sp-4); }
  .sidebar { display: none; }
  .canvas { padding: var(--sp-4) var(--sp-4) var(--sp-8); }
  .table th { position: static; }
  /* 触控目标 ≥44（DESIGN §5.5） */
  .btn { height: 44px; padding: 0 var(--sp-4); }
  .btn--sm { height: 36px; }
  .iconbtn { width: 44px; height: 44px; }
  .inp, .sel, .area { min-height: 44px; }
  .seg label { height: 44px; }
  .nav__item { height: 44px; }
  .md { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 639px) {
  .topbar { gap: var(--sp-2); }
  .search input { width: 100%; min-width: 0; }
  .search { flex: 1 1 auto; min-width: 0; }
  .brand__scope { display: none; }
  .page__title { font-size: var(--fs-section); line-height: var(--lh-section); }
  .page__actions { margin-left: 0; width: 100%; }
  .statrow { gap: var(--sp-3) var(--sp-4); }
  .stat + .stat { padding-left: var(--sp-4); }
  .stat__n { font-size: var(--fs-metric); line-height: var(--lh-metric); }
  .mrow { flex-wrap: wrap; row-gap: 2px; padding: var(--sp-3) var(--sp-4); }
  .mrow__name { width: auto; }
  .mrow__zone, .mrow__seen { width: auto; }
  .mrow__reason { flex: 1 1 100%; }
  .group__head { flex-wrap: wrap; row-gap: 2px; }
  .group__state { margin-left: 0; flex: 1 1 100%; font-size: var(--fs-cell); color: var(--muted); }
  .logline { grid-template-columns: 64px 44px minmax(0, 1fr); gap: var(--sp-2); padding: 2px var(--sp-3); }
  .kv, .kv--loose { grid-template-columns: minmax(0, 1fr); gap: var(--sp-1); }
  .kv dt { margin-top: var(--sp-2); }
  .impact__row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toolbar { gap: var(--sp-2); }

  /* 表格 <640 变两行卡片：字段一个不丢，不出横向滚动条（DESIGN §5.5 / §12-D5） */
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tr { padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--border); }
  .table--cards td {
    height: auto; min-height: 0; padding: 2px 0; border: 0; display: flex;
    align-items: baseline; gap: var(--sp-2); font-size: var(--fs-body); line-height: var(--lh-body);
  }
  .table--cards td::before {
    content: attr(data-label); flex: none; width: 72px;
    font-size: var(--fs-caption); line-height: var(--lh-body); color: var(--muted);
  }
  .table--cards td[data-label=""]::before { display: none; }
  .table--cards td.cell-main { font-size: var(--fs-lead); line-height: var(--lh-lead); }
  .table--cards td.cell-main::before { display: none; }
  .table--cards td.cell-sub { color: var(--muted); font-size: var(--fs-caption); }
  .table--cards td.cell-sub::before { display: none; }
  .table--cards td.col-action { width: 100%; text-align: left; justify-content: flex-start; }
  .cell-actions { justify-content: flex-start; }
  .table--cards td.col-check { width: auto; padding: 0; }

  /* 两行卡片：第一行 状态 + 机名 + 时间，第二行 门店 / 分区（DESIGN §12-D5） */
  .table--mrow thead { display: none; }
  .table--mrow, .table--mrow tbody { display: block; width: 100%; }
  .table--mrow tr {
    display: grid; align-items: center;
    grid-template-columns: 24px auto minmax(0, 1fr) auto;
    grid-template-areas: "chk st name seen" ". res res res" ". meta meta meta" ". act act act";
    column-gap: var(--sp-2); row-gap: 2px;
    padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  }
  .table--mrow tr:last-child { border-bottom: 0; }
  .table--mrow td { display: block; height: auto; padding: 0; border: 0; font-size: var(--fs-body); }
  .table--mrow td::before { content: none; }
  .table--mrow td.col-check { grid-area: chk; align-self: start; padding-top: var(--sp-1); }
  .table--mrow td[data-label="状态"] { grid-area: st; }
  .table--mrow td.cell-main { grid-area: name; font-size: var(--fs-lead); line-height: var(--lh-lead); font-weight: 500; }
  .table--mrow td.cell-meta { grid-area: meta; font-size: var(--fs-caption); color: var(--muted); }
  .table--mrow td.cell-seen { grid-area: seen; font-size: var(--fs-caption); color: var(--muted); }
  .table--mrow td.cell-result { grid-area: res; font-size: var(--fs-cell); }
  .table--mrow td.cell-extra { display: none; }
  .table--mrow td.col-action { grid-area: act; text-align: right; }
  .table--mrow .status { font-size: var(--fs-caption); }

  /* 手机底部 Tab */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar__item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 48px; font-size: var(--fs-caption); color: var(--muted);
  }
  .tabbar__item[aria-current="page"] { color: var(--ink); }
  .tabbar__item:hover { text-decoration: none; }
  .tabbar details { display: contents; }
  .tabbar summary { list-style: none; cursor: pointer; }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar__more {
    position: fixed; left: 0; right: 0; bottom: calc(48px + env(safe-area-inset-bottom)); z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border); padding: var(--sp-2);
    display: flex; flex-direction: column;
  }
  .tabbar__more a { padding: var(--sp-3); border-radius: var(--r-2); color: var(--ink); font-size: var(--fs-body); }
  .tabbar__more a:hover { background: var(--raised); text-decoration: none; }
  .shell { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* 宽屏（≥1200）：画布外边距放宽一档，仍然是全页一条左沿（DESIGN §5.3） */
@media (min-width: 1200px) {
  :root { --gutter: var(--sp-8); }
  .canvas { padding-top: var(--sp-7); }
}

/* 超大屏（≥1440）：看板的机器行固定列放宽，避免机名一长就把原因挤没 */
@media (min-width: 1440px) {
  .mrow__name { width: 112px; }
  .mrow__zone { width: 80px; }
  .mrow__seen { width: 104px; }
}

/* 触控设备：不看屏宽，只要输入是手指就给 44px 热区（DESIGN §5.5 的判据是输入方式，
   不是窗口宽度——平板接鼠标和手机接鼠标都要按实际情况走这一档） */
@media (pointer: coarse) {
  .btn { min-height: 44px; padding: 0 var(--sp-4); }
  .btn--sm { min-height: 44px; }
  .iconbtn { width: 44px; height: 44px; }
  .inp, .sel, .area { min-height: 44px; }
  .nav__item { height: 44px; }
  .usermenu > summary { height: 44px; }
  .seg label { height: 44px; }
  .md__item { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
}

/* 动效降级：保留颜色变化，去掉位移与闪烁（DESIGN §10.4） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .spin { animation: none; border-top-color: var(--accent); }
  .rowflash { animation: none; }
}

@media print {
  .topbar, .sidebar, .tabbar, .toasts { display: none; }
  .canvas { padding: 0; }
}
