/* ============================================
 * TPA Laser Welding Line AI Quality Dashboard
 * Common Stylesheet - Dark tech theme
 * Design baseline: 1920 x 1080 (landscape) at 100vw
 * ============================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep: #04101f;
  --bg-base: #07192f;
  --bg-card: rgba(13, 33, 60, 0.78);
  --bg-card-solid: #0d233d;
  --bg-card-hover: rgba(20, 50, 90, 0.85);
  --bg-row: rgba(11, 28, 52, 0.55);
  --bg-row-alt: rgba(18, 42, 76, 0.4);

  --line: rgba(45, 220, 255, 0.18);
  --line-strong: rgba(45, 220, 255, 0.45);

  --c-cyan: #2ddfff;
  --c-cyan-soft: #66e7ff;
  --c-blue: #3889ff;
  --c-green: #5cf39e;
  --c-red: #ff5e6c;
  --c-yellow: #ffd54a;
  --c-purple: #b08cff;
  --c-orange: #ff9d4d;

  --text-1: #e6f6ff;
  --text-2: #a3bcd6;
  --text-3: #6885a3;
  --text-4: #44617d;

  --shadow-card: 0 0 0.12rem rgba(45, 220, 255, 0.08), inset 0 0 0.04rem rgba(45, 220, 255, 0.2);

  --radius: 0.06rem;
  --gap: 0.16rem;
}

html {
  font-size: calc(min(100vw / 19.2, 100vh / 10.8));  /* 按宽高共同缩放，自适应不同分辨率 */
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;        /* 锁定整页：滚轮只滚内容区，不滚整个浏览器 */
}

body {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  margin: 0;
  font-size: 0.16rem;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(56, 137, 255, 0.10) 0%, transparent 40%),
    radial-gradient(ellipse at 100% 100%, rgba(176, 140, 255, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #06192f 0%, #04101f 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  overflow: hidden;        /* 锁定整页，只允许内部模块滚动 */
}

::selection { background: rgba(45, 220, 255, 0.35); }
::-webkit-scrollbar { width: 0.08rem; height: 0.08rem; }
::-webkit-scrollbar-thumb { background: rgba(45, 220, 255, 0.25); border-radius: 0.04rem; }
::-webkit-scrollbar-track { background: transparent; }

/* ============== Header ============== */
.app-header {
  height: 0.72rem;
  display: flex;
  align-items: center;
  padding: 0 0.24rem;
  background:
    linear-gradient(90deg, rgba(13, 33, 60, 0.92) 0%, rgba(7, 25, 47, 0.6) 100%);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.app-header::after {
  content: "";
  position: absolute; left: 0; bottom: -0.01rem; right: 0; height: 0.02rem;
  background: linear-gradient(90deg, transparent, var(--c-cyan), transparent);
  opacity: 0.5;
}
.brand {
  display: flex; align-items: center; gap: 0.12rem;
  font-size: 0.18rem; font-weight: 600; color: var(--text-1);
  letter-spacing: 0.04rem;
}
.brand-logo {
  height: 0.44rem;
  line-height: 0.44rem;
  display: block;
  font-size: 0.28rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.04rem;
  text-shadow: 0 0 0.12rem rgba(45, 220, 255, 0.35);
}
img.brand-logo {
  height: 0.42rem;
  width: auto;
  font-size: 0;
  line-height: normal;
  text-shadow: none;
  display: block;
}

.header-spacer { flex: 1; }
.header-info {
  display: flex; align-items: center; gap: 0.1rem;
  font-size: 0.13rem; color: var(--text-2);
}
.header-info .pill {
  padding: 0.03rem 0.08rem; border-radius: 0.2rem;
  background: rgba(45, 220, 255, 0.08); border: 1px solid var(--line);
}
/* 当前登录账号 pill：可点击退出 */
.header-info .pill.user-pill {
  color: #eafcff; border-color: rgba(45, 220, 255, 0.45);
  transition: background 0.2s, border-color 0.2s;
}
.header-info .pill.user-pill:hover {
  background: rgba(45, 220, 255, 0.18); border-color: rgba(45, 220, 255, 0.75);
}
.header-info .pill.user-pill .op-user { max-width: 2.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.header-info .pill.live { color: var(--c-green); border-color: rgba(92, 243, 158, 0.4); background: rgba(92, 243, 158, 0.08); }
.header-info .pill.live::before { content: "●"; margin-right: 0.04rem; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.header-title {
  flex: 1;
  text-align: center;
  font-size: 0.20rem;
  font-weight: 600;
  letter-spacing: 0.01rem;
  color: var(--text-1);
  text-shadow: 0 0 0.1rem rgba(45, 220, 255, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-spacer { display: none; }

/* ============== Main Layout ============== */
.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;         /* 内容溢出由 .content 内部滚动，不波及整页 */
}

.sidebar {
  width: 2.4rem;
  background:
    linear-gradient(180deg, rgba(11, 28, 52, 0.88) 0%, rgba(4, 16, 31, 0.92) 100%);
  border-right: 1px solid var(--line);
  padding: 0.2rem 0.12rem;
  display: flex; flex-direction: column; gap: 0.08rem;
  flex-shrink: 0;
}
.side-group { display: flex; flex-direction: column; gap: 0.04rem; }
.side-group + .side-group {
  border-top: 1px solid rgba(45, 223, 255, 0.16);
  padding-top: 0.1rem;
  margin-top: 0.06rem;
}
.menu-item {
  display: flex; align-items: center; gap: 0.08rem;
  padding: 0.11rem 0.14rem;
  font-size: 0.14rem; color: var(--text-2);
  white-space: nowrap;
  border-radius: 0.04rem;
  cursor: pointer;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.2s ease;
  position: relative;
}
.menu-item:hover {
  background: rgba(45, 220, 255, 0.06);
  color: var(--text-1);
}
.menu-item.active {
  background: linear-gradient(90deg, rgba(45, 220, 255, 0.18) 0%, transparent 100%);
  color: var(--c-cyan);
  border-left-color: var(--c-cyan);
  font-weight: 600;
}
.menu-item.active::after {
  content: "";
  position: absolute; right: 0.12rem;
  width: 0.05rem; height: 0.05rem;
  background: var(--c-cyan); border-radius: 50%;
  box-shadow: 0 0 0.08rem var(--c-cyan);
}
.menu-icon {
  width: 0.2rem; height: 0.2rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.18rem;
}

.side-foot {
  margin-top: auto;
  padding: 0.12rem;
  border-top: 1px solid var(--line);
  font-size: 0.11rem;
  color: var(--text-3);
  line-height: 1.5;
}
.side-foot .ver { color: var(--c-cyan); }

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;          /* 内容超高时在本区域内滚动，header/sidebar 保持固定 */
  overflow-x: hidden;        /* 禁止横向整页滚动 */
  padding: 0.14rem 0.18rem;
  display: flex; flex-direction: column; gap: 0.14rem;
}
.content.board-content {
  padding: 0.12rem 0.16rem;
  gap: 0.12rem;
}

/* ============== Card / Panel ============== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
}
.card::before, .card::after {
  content: "";
  position: absolute; width: 0.14rem; height: 0.14rem;
  border: 2px solid var(--c-cyan);
}
.card::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.card::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.card-title {
  display: flex; align-items: center;
  padding: 0.12rem 0.2rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.16rem; font-weight: 600; color: var(--text-1);
}
.card-title::before {
  content: "";
  display: inline-block;
  width: 0.04rem; height: 0.16rem;
  margin-right: 0.1rem;
  background: linear-gradient(180deg, var(--c-cyan), var(--c-blue));
  border-radius: 0.02rem;
}
.card-title .ct-meta {
  margin-left: auto;
  font-size: 0.12rem; color: var(--text-3);
}
.card-title .ct-actions { margin-left: auto; display: flex; gap: 0.06rem; }
.card-body { padding: 0.18rem; }

/* 可滚动卡片：让卡片体在剩余空间内独立滚动（鼠标滚轮生效） */
.card.scroll-card { display: flex; flex-direction: column; min-height: 0; }
.card.scroll-card > .card-body { flex: 1; min-height: 0; }

/* ============== Charts container ============== */
.chart {
  width: 100%;
  height: 100%;
}
.chart-2up { display: grid; grid-template-columns: 1fr 1fr; gap: 0.18rem; }
.chart-3up { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.18rem; }

/* ============== Grids ============== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.18rem; }
.grid-12-8 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 0.18rem; }
.grid-7-5 { display: grid; grid-template-columns: 7fr 5fr; gap: 0.18rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.18rem; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 0.18rem; }

/* ============== KPI ============== */
.kpi {
  display: flex; flex-direction: column;
  padding: 0.16rem 0.2rem;
  background: linear-gradient(180deg, rgba(13, 33, 60, 0.6) 0%, rgba(8, 22, 42, 0.6) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.kpi-label { font-size: 0.13rem; color: var(--text-3); margin-bottom: 0.08rem; }
.kpi-value { font-size: 0.36rem; font-weight: 700; color: var(--c-cyan); letter-spacing: 0.02rem; line-height: 1.1; }
.kpi-value .unit { font-size: 0.16rem; color: var(--text-3); margin-left: 0.04rem; font-weight: 500; }
.kpi-value.pass { color: var(--c-green); }
.kpi-value.ng { color: var(--c-red); }
.kpi-value.warn { color: var(--c-yellow); }
.kpi-sub { font-size: 0.12rem; color: var(--text-3); margin-top: 0.06rem; }
.kpi-sub b { color: var(--text-1); font-weight: 600; }

/* ============== Tag / Pills ============== */
.tag {
  display: inline-block;
  padding: 0.03rem 0.1rem;
  border-radius: 0.04rem;
  font-size: 0.12rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}
.tag.pass { background: rgba(92, 243, 158, 0.12); color: var(--c-green); border: 1px solid rgba(92, 243, 158, 0.4); }
.tag.ng   { background: rgba(255, 94, 108, 0.12); color: var(--c-red);   border: 1px solid rgba(255, 94, 108, 0.4); }
.tag.warn { background: rgba(255, 213, 74, 0.12); color: var(--c-yellow); border: 1px solid rgba(255, 213, 74, 0.4); }
.tag.info { background: rgba(45, 223, 255, 0.10); color: var(--c-cyan);  border: 1px solid rgba(45, 223, 255, 0.4); }

/* ============== Table ============== */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.12rem;
}
.tbl thead th {
  background: linear-gradient(180deg, rgba(56, 137, 255, 0.18) 0%, rgba(45, 223, 255, 0.05) 100%);
  color: var(--text-1);
  font-weight: 600;
  padding: 0.1rem 0.08rem;
  text-align: left;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.12rem;
}
.tbl tbody td {
  padding: 0.08rem 0.08rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.12rem;
}
.tbl tbody tr:nth-child(odd) td { background: var(--bg-row); }
.tbl tbody tr:nth-child(even) td { background: var(--bg-row-alt); }
.tbl tbody tr:hover td { background: rgba(45, 223, 255, 0.08); color: var(--text-1); }
.tbl .mono { font-family: "SF Mono", Consolas, "Roboto Mono", monospace; }

.tbl-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.1rem 0.04rem;
  margin-bottom: 0.12rem;
}
.tbl-bar .tbl-meta { font-size: 0.13rem; color: var(--text-3); }
.tbl-bar .tbl-meta b { color: var(--c-cyan); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.06rem 0.16rem;
  font-size: 0.13rem;
  font-weight: 500;
  border-radius: 0.04rem;
  cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(45, 223, 255, 0.08);
  color: var(--text-1);
  transition: all 0.2s;
  text-decoration: none;
  user-select: none;
}
.btn:hover { background: rgba(45, 223, 255, 0.18); border-color: var(--c-cyan); color: var(--c-cyan); }
.btn.primary { background: linear-gradient(135deg, #2ddfff 0%, #3889ff 100%); color: #002133; border-color: transparent; font-weight: 600; }
.btn.primary:hover { box-shadow: 0 0 0.12rem rgba(45, 223, 255, 0.4); }
.btn.danger { background: rgba(255, 94, 108, 0.1); border-color: rgba(255, 94, 108, 0.5); color: var(--c-red); }
.btn.danger:hover { background: rgba(255, 94, 108, 0.22); }
.btn.warn { background: rgba(255, 213, 74, 0.1); border-color: rgba(255, 213, 74, 0.5); color: var(--c-yellow); }
.btn.warn:hover { background: rgba(255, 213, 74, 0.22); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { color: var(--c-cyan); border-color: var(--line-strong); }
.btn.lg { padding: 0.08rem 0.2rem; font-size: 0.14rem; }

/* ============== Form ============== */
.form-row {
  display: flex; align-items: center; gap: 0.12rem;
  padding: 0.08rem 0;
  flex-wrap: wrap;
}
.form-row .label {
  font-size: 0.13rem; color: var(--text-2);
  min-width: 0.8rem;
}
.form-row .field {
  display: flex; align-items: center; gap: 0.08rem;
}
.input, .select {
  background: rgba(4, 16, 31, 0.6);
  border: 1px solid var(--line);
  color: var(--text-1);
  padding: 0.06rem 0.12rem;
  border-radius: 0.04rem;
  font-size: 0.13rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
  min-width: 1.2rem;
  height: 0.32rem;
  box-sizing: border-box;
}
.input:focus, .select:focus {
  border-color: var(--c-cyan);
  background: rgba(4, 16, 31, 0.85);
  box-shadow: 0 0 0.08rem rgba(45, 223, 255, 0.3);
}
.input.wide, .select.wide { min-width: 1.6rem; }
.input::placeholder { color: var(--text-3); }

/* ============== Filter bar (horizontal) ============== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.08rem 0.14rem;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 33, 60, 0.4);
  flex-wrap: wrap;
}
.filter-bar .form-row {
  display: flex;
  align-items: center;
  gap: 0.06rem;
  padding: 0;
  flex-wrap: wrap;
}
.filter-bar .label {
  font-size: 0.13rem;
  color: var(--text-2);
  min-width: auto;
  white-space: nowrap;
}
.filter-bar .select {
  min-width: 1.2rem;
  padding: 0.06rem 0.1rem;
}
.filter-bar .field {
  display: flex;
  align-items: center;
  gap: 0.06rem;
}
.filter-bar .btn {
  padding: 0.06rem 0.12rem;
}
.filter-bar .spacer {
  flex: 1;
}

/* ============== Pagination ============== */
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 0.08rem;
  padding: 0.14rem 0.04rem 0.04rem;
  font-size: 0.13rem; color: var(--text-3);
}
.pager .pg {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 0.28rem; height: 0.28rem;
  padding: 0 0.08rem;
  border: 1px solid var(--line);
  border-radius: 0.04rem;
  background: rgba(13, 33, 60, 0.6);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.pager .pg:hover { color: var(--c-cyan); border-color: var(--line-strong); }
.pager .pg.active { background: linear-gradient(135deg, #2ddfff 0%, #3889ff 100%); color: #002133; border-color: transparent; font-weight: 600; }

/* ============== Misc ============== */
.flex { display: flex; }
.flex-1 { flex: 1; }
.between { justify-content: space-between; }
.center { justify-content: center; align-items: center; }
.aic { align-items: center; }
.gap-4 { gap: 0.04rem; }
.gap-8 { gap: 0.08rem; }
.gap-12 { gap: 0.12rem; }
.gap-16 { gap: 0.16rem; }
.muted { color: var(--text-3); }
.cyan { color: var(--c-cyan); }
.green { color: var(--c-green); }
.red { color: var(--c-red); }
.yellow { color: var(--c-yellow); }
.purple { color: var(--c-purple); }

.divider { height: 1px; background: var(--line); margin: 0.12rem 0; }

/* ============== Toast ============== */
.toast-host { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 9999; pointer-events: none; }
.toast {
  background: rgba(13, 33, 60, 0.95);
  border: 1px solid var(--c-cyan);
  color: var(--c-cyan);
  padding: 0.1rem 0.2rem;
  border-radius: 0.04rem;
  font-size: 0.14rem;
  margin-bottom: 0.08rem;
  box-shadow: 0 0 0.16rem rgba(45, 223, 255, 0.4);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-0.1rem); } to { opacity: 1; transform: translateY(0); } }

/* ============== Modal ============== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(4, 16, 31, 0.7);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-mask.open { display: flex; }
.modal {
  width: 5.4rem;
  background: var(--bg-card-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 0 0.4rem rgba(0, 0, 0, 0.5), 0 0 0.16rem rgba(45, 223, 255, 0.2);
  overflow: hidden;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  padding: 0.16rem 0.24rem;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.16rem; font-weight: 600;
}
.modal-head .x { cursor: pointer; color: var(--text-3); font-size: 0.2rem; padding: 0 0.04rem; }
.modal-head .x:hover { color: var(--c-red); }
.modal-body { padding: 0.24rem; font-size: 0.14rem; }
.modal-foot { padding: 0.16rem 0.24rem; border-top: 1px solid var(--line); display: flex; gap: 0.12rem; justify-content: flex-end; }

/* ============== Loading shimmer ============== */
.shimmer { background: linear-gradient(90deg, rgba(45,223,255,0.04) 0%, rgba(45,223,255,0.16) 50%, rgba(45,223,255,0.04) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============== Status dot ============== */
.dot { display: inline-block; width: 0.08rem; height: 0.08rem; border-radius: 50%; vertical-align: middle; margin-right: 0.06rem; }
.dot.green { background: var(--c-green); box-shadow: 0 0 0.08rem var(--c-green); }
.dot.red   { background: var(--c-red); box-shadow: 0 0 0.08rem var(--c-red); }
.dot.yellow { background: var(--c-yellow); box-shadow: 0 0 0.08rem var(--c-yellow); }
.dot.gray  { background: var(--text-4); }

.st-ctrlrow { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.12rem; }
.st-ctrl { display: inline-flex; align-items: center; gap: 0.1rem; font-size: 0.13rem; }
.st-lbl { color: var(--text-2); }
