/* ============================================================================
   xyppusher ART KIT / ui.css
   组件层 —— 浅色实心主题（无壁纸状态）。玻璃状态由 glass.css 覆盖。
   纯手写、零依赖；断点：>=1024 桌面侧栏 / <1024 收起侧栏文字 / <=720 手机底部 tab。
   依赖 tokens.css。
   ========================================================================== */

/* ---------------------------------------------------------------- 骨架 */
.app-view { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.product {
  font-size: 14.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.who {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 演练模式 / 环境提示黄条 */
.banner {
  flex: 0 0 auto;
  padding: 9px 16px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #7a4b04;
  background: var(--warn-soft);
  border-bottom: 1px solid var(--warn-line);
}
.banner strong { font-weight: 700; }

.shell {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  min-height: 0;
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  padding: 12px 10px;
  border-right: 1px solid var(--line);
  background: var(--surf);
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: calc(var(--topbar-h) + 0px);
  align-self: flex-start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
  transition: background .1s, color .1s;
}
.nav-item:hover { background: var(--glass-3); text-decoration: none; }
.nav-item svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.nav-item.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-weight: 650;
}
.nav-item.active svg { stroke-width: 1.8; }

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 20px 22px 40px;
}

/* ---------------------------------------------------------------- 页头 */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head h2 { font-size: var(--fs-lg); }
.page-head .sub { margin-top: 3px; font-size: var(--fs-sm); color: var(--ink-3); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 15px;
  font: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surf);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--glass-3); border-color: var(--ink-4); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
.btn:active { transform: translateY(.5px); }

.btn-primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-danger { color: var(--danger); border-color: var(--danger-line); background: var(--glass-2); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--glass-3); border-color: transparent; }

.btn-sm { min-height: 32px; padding: 0 10px; font-size: var(--fs-sm); border-radius: 6px; }
.btn-block { width: 100%; min-height: 44px; }

.btn[disabled], .btn[aria-busy="true"] {
  opacity: .6;
  cursor: not-allowed;
  pointer-events: none;
}
.btn[aria-busy="true"]::after {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 表单件 */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-2);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="email"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 11px;
  font: inherit;
  color: var(--ink);
  background: var(--surf);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:disabled, select:disabled, textarea:disabled {
  background: var(--glass-3);
  color: var(--ink-4);
  opacity: .75;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-note { margin-top: -6px; margin-bottom: 12px; font-size: 12px; color: var(--ink-3); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 9px;
  font-size: 13px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}
.check:hover { background: var(--glass-3); }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--brand); }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 14px; }
.card-head .card-note { font-size: 12px; color: var(--ink-3); }
.card-body { padding: 14px; }
.card-body.tight { padding: 0; }

/* 统计卡 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.stat .k { font-size: 12px; color: var(--ink-3); font-weight: 550; }
.stat .v {
  margin-top: 3px;
  font-size: var(--fs-num);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.stat .v small { font-size: var(--fs-sm); font-weight: 550; color: var(--ink-3); margin-left: 3px; }
.stat .x { margin-top: 3px; font-size: 11.5px; color: var(--ink-4); }
.stat.is-ok .v { color: var(--ok); }
.stat.is-bad .v { color: var(--danger); }
.stat.is-brand .v { color: var(--brand); }
/* 壁纸模式下把强调色压深一档，保证 4.5:1 */
body[data-wall="1"] .stat.is-brand .v { color: var(--brand-ink); }

/* ---------------------------------------------------------------- 徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 1.7;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-muted { color: var(--ink-3); background: var(--glass-3); border-color: var(--line); }
.badge-brand { color: var(--brand-dark); background: var(--brand-soft); border-color: var(--brand-line); }
.badge-ok { color: var(--ok); background: var(--ok-soft); border-color: #bbf7d0; }
.badge-warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.badge-bad { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }

.mono { font-family: var(--mono); font-size: var(--fs-sm); letter-spacing: -.01em; }
.dim { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.tr { text-align: right; }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: .02em;
  color: var(--ink-3);
  background: var(--glass-3);
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--glass-3); }
.table tr.is-fail td { background: var(--danger-soft); }
.table tr.is-fail:hover td { background: var(--danger-soft); filter: brightness(.97); }
.table td.num { font-variant-numeric: tabular-nums; }
.table .cell-strong { font-weight: 600; color: var(--ink); }
.table .cell-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
}
.empty strong {
  display: block;
  color: var(--ink-3);
  font-size: 13.5px;
  margin-bottom: 3px;
  font-weight: 600;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.pager-controls { display: flex; align-items: center; gap: 6px; }
.pager-page { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 筛选条 / tabs */
.filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--glass-3);
}
.filters .field { margin: 0; min-width: 132px; }
.filters .field.grow { flex: 1 1 190px; min-width: 170px; }
.filters .field > span { margin-bottom: 4px; font-size: var(--fs-xs); }
.filters .btn { min-height: var(--tap); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--glass-3);
  border-radius: 9px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  min-height: 34px;
  padding: 0 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--ink);
  background: var(--surf);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- 进度 */
.progress {
  height: 7px;
  border-radius: 999px;
  background: var(--glass-3);
  overflow: hidden;
  margin-top: 6px;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s ease;
}
.progress.is-ok > i { background: var(--ok); }
.progress.is-bad > i { background: var(--danger); }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, .45);
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surf);
  border-radius: 12px;
  box-shadow: 0 24px 60px -20px rgba(17, 24, 39, .45);
  overflow: hidden;
  animation: pop .14s ease-out;
}
@keyframes pop {
  from { transform: translateY(8px) scale(.99); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: var(--fs-md); }
.modal-x {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.modal-x:hover { background: var(--glass-3); color: var(--ink); }
.modal-body { padding: 16px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--glass-3);
}

/* ---------------------------------------------------------------- toast */
.toasts {
  position: fixed;
  z-index: 90;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surf);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-4);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: slide .16s ease-out;
  word-break: break-word;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slide {
  from { transform: translateX(10px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------------------------------------------------------------- 加载 */
.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 37%, #eef0f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  height: 14px;
}
body[data-wall="1"] .skeleton {
  background: linear-gradient(90deg, rgb(255 255 255 / .10) 25%,
              rgb(255 255 255 / .18) 37%, rgb(255 255 255 / .10) 63%);
  background-size: 400% 100%;
}
@keyframes shimmer {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}
.loading-line { padding: 28px 16px; text-align: center; color: var(--ink-4); font-size: 13px; }

/* ================================================================ 响应式 */
@media (max-width: 1024px) {
  :root { --sidebar-w: 62px; --topbar-h: 52px; }

  .nav-item { justify-content: center; padding: 0; }
  .nav-item span { display: none; }
  .main { padding: 16px 16px 34px; }
}

@media (max-width: 720px) {
  :root { --topbar-h: 50px; }

  .product { font-size: 13.5px; }
  .who { max-width: 76px; font-size: 12.5px; }

  /* 侧栏 → 底部 tab */
  .shell { flex-direction: column; }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 40;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .97);
    backdrop-filter: saturate(1.4) blur(8px);
    -webkit-backdrop-filter: saturate(1.4) blur(8px);
    overflow: visible;
  }
  .nav-item {
    flex: 1 1 0;
    min-width: 0;                 /* ★ 7 项时允许收缩，否则文字会被挤出屏幕 */
    flex-direction: column;
    gap: 2px;
    min-height: 48px;
    padding: 5px 1px;
    font-size: 10px;
    font-weight: 550;
    border-radius: 8px;
  }
  .nav-item span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav-item svg { width: 18px; height: 18px; }
  .nav-item.active { background: transparent; color: var(--brand); }

  .main { padding: 12px 12px calc(72px + env(safe-area-inset-bottom)); }

  .page-head { margin-bottom: 12px; }
  .page-head h2 { font-size: 16.5px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .stat { padding: 10px 11px; }
  .stat .v { font-size: 19px; }

  .banner { padding: 8px 12px; font-size: 12px; }

  /* 表格 → 卡片 */
  .table-wrap.cards { overflow-x: visible; }
  .table.cards thead { display: none; }
  .table.cards, .table.cards tbody, .table.cards tr, .table.cards td { display: block; width: 100%; }
  .table.cards tr {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }
  .table.cards tr:last-child { border-bottom: 0; }
  .table.cards td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border: 0;
    font-size: 13px;
    text-align: right;
    word-break: break-word;
  }
  .table.cards td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--ink-4);
    text-align: left;
    white-space: nowrap;
  }
  .table.cards td.cell-hide { display: none; }
  .table.cards td.cell-actions {
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
  }
  .table.cards td.cell-actions::before { content: ""; display: none; }
  .table.cards tr.is-fail td { background: transparent; }
  .table.cards tr.is-fail { background: var(--danger-soft); }

  .filters { padding: 10px 12px; gap: 8px; }
  .filters .field, .filters .field.grow { flex: 1 1 100%; min-width: 0; }
  .filters .btn { flex: 1 1 auto; }

  .form-grid { grid-template-columns: minmax(0, 1fr); }

  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none;
    border-radius: 14px 14px 0 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
  }
  .modal-body { overflow-y: auto; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }

  .toasts {
    right: 10px;
    left: 10px;
    bottom: calc(64px + env(safe-area-inset-bottom));
    max-width: none;
  }

  .card + .card { margin-top: 12px; }

  /* 手指目标：小按钮在手机上提到 40px，操作区平铺 */
  .btn-sm { min-height: 40px; padding: 0 12px; font-size: 13px; }
  .table.cards td.cell-actions .btn-sm { flex: 1 1 0; }
  .pager { padding: 10px 12px; }
  .pager-controls { width: 100%; justify-content: space-between; }
  .pager-controls .btn { min-height: 40px; }
  .modal-x { width: 40px; height: 40px; font-size: 20px; }
}

@media (max-width: 400px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .v { font-size: 17.5px; }
  .who { max-width: 62px; }
}
