/* QST GaN 芯片工程师助手 · H5/PWA 样式
   移动优先；品牌色 #1890ff（仙湖品牌色）。零依赖，纯 CSS。 */

:root {
  --brand: #1890ff;
  --brand-dark: #0f6fcc;
  --brand-soft: #e8f3ff;
  --bg: #f2f4f8;
  --card: #ffffff;
  --text: #1f2329;
  --text-2: #5a6472;
  --text-3: #8a94a6;
  --line: #e6e9ef;
  --ok: #1fa971;
  --warn: #d98b00;
  --err: #d8443c;
  --radius: 12px;
  --appbar-h: 52px;
  --tabbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--appbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--brand);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--appbar-h) + env(safe-area-inset-top));
}
.appbar .brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.appbar .logo { height: 34px; width: auto; display: block; flex: 0 0 auto; }
.appbar .brand {
  font-size: 15px; font-weight: 500;
  border-left: 1px solid rgba(255, 255, 255, .32);
  padding-left: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar .status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.appbar .dot { width: 7px; height: 7px; border-radius: 50%; background: #ffd666; }
.appbar .status.on .dot { background: #b7f0d0; }
.appbar .status.off .dot { background: #ffb3ad; }

/* ---------- 主区 ---------- */
main {
  padding: 12px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  max-width: 720px;
  margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 500; }
.card h3 { margin: 14px 0 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.muted { color: var(--text-3); font-size: 12px; }
.hint { color: var(--text-3); font-size: 12px; margin-top: 8px; }

/* ---------- 表单 ---------- */
label { display: block; font-size: 12px; color: var(--text-2); margin: 10px 0 4px; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); background: #fff; }
textarea { min-height: 84px; resize: vertical; }

button {
  font-family: inherit;
  font-size: 15px;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
button:active { background: var(--brand-dark); }
button:disabled { background: #b9c4d2; cursor: not-allowed; }
button.ghost { background: var(--brand-soft); color: var(--brand); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.btn-block { width: 100%; margin-top: 12px; }

/* ---------- 列表 ---------- */
.list { margin: 0; padding: 0; list-style: none; }
.list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.list li:last-child { border-bottom: none; }
.item-title { font-weight: 500; font-size: 15px; }
.item-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.tag.gray { background: #f0f2f5; color: var(--text-2); }
.tag.ok { background: #e6f7ef; color: var(--ok); }
.tag.warn { background: #fff6e6; color: var(--warn); }
.tag.err { background: #fdeceb; color: var(--err); }

/* ---------- 结果表 ---------- */
table.kv { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.kv th, table.kv td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.kv th { color: var(--text-2); font-weight: 400; width: 42%; }
table.kv td { font-variant-numeric: tabular-nums; }

.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.result-grid .metric {
  background: #f7f9fc;
  border-radius: 10px;
  padding: 10px;
}
.result-grid .metric .k { font-size: 11px; color: var(--text-3); }
.result-grid .metric .v { font-size: 17px; font-weight: 500; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.result-grid .metric .u { font-size: 11px; color: var(--text-3); margin-left: 2px; }

.bullets { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.bullets li { margin-bottom: 4px; }
.refs { font-size: 12px; color: var(--text-2); }

/* ---------- 规格书按钮（T-397-H5：详情内直达官网 PDF） ---------- */
.pdf-btn {
  display: block;
  margin: 12px 0 4px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.pdf-btn:active { background: var(--brand-dark); }
a.src-link {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

/* ---------- 计算子页签 ---------- */
.segmented {
  display: flex;
  gap: 4px;
  background: #eceff4;
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.segmented button {
  flex: 1 0 auto;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.segmented button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ---------- 底部 tab ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  border-radius: 0;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.tabbar button.on { color: var(--brand); }
.tabbar .ico { font-size: 17px; line-height: 1; }

/* ---------- 弹层 ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15,23,35,.45);
  display: none;
  align-items: flex-end;
}
.sheet.open { display: flex; }
.sheet-inner {
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(24px); } to { transform: none; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 500; }
.sheet-head button { background: transparent; color: var(--text-3); font-size: 20px; padding: 0 6px; }

/* ---------- 任务卡 ---------- */
.task {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
}
.task-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.task-id { font-size: 12px; color: var(--text-3); font-family: ui-monospace, Menlo, Consolas, monospace; }
.bar { height: 6px; background: #eceff4; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .25s ease; }

.empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 24px 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 24px);
  transform: translateX(-50%);
  background: rgba(31,35,41,.92);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 20px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  max-width: 80vw;
}
.toast.show { opacity: 1; }
