/* AFM 测试分析助手 — 统一视觉层
 *
 * 目标：安静的科研工作台。浅灰底、白色面板、深色文字、克制的青绿主色。
 * 只用原生 CSS，不引第三方框架：实验室服务器常年不联外网也能正常显示。
 *
 * 结构：
 *   1. 设计变量        2. 基础排版        3. 顶栏与导航
 *   4. 页面容器        5. 卡片与状态      6. 表单与按钮
 *   7. 表格            8. 登录/记录等页面  9. 响应式
 */

/* ---------------------------------------------------------- 1. 设计变量 */
:root {
  color-scheme: light;

  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #fafbfa;
  --surface-3: #f1f4f2;
  --line: #e3e8e5;
  --line-strong: #d3dad6;

  --text: #1b211f;
  --text-2: #46524d;
  --muted: #6d7a75;
  --faint: #96a29d;

  --teal: #0f766e;
  --teal-dark: #0b5c56;
  --teal-soft: #e7f3f0;
  --teal-line: #b9dcd6;

  --ok: #16794c;
  --ok-soft: #e8f5ee;
  --ok-line: #b7e0c9;
  --warn: #8a6100;
  --warn-soft: #fdf5e2;
  --warn-line: #ecd7a4;
  --bad: #a92f26;
  --bad-soft: #fceceb;
  --bad-line: #f0c3bf;
  --neutral: #5d6a65;
  --neutral-soft: #f1f4f2;

  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 14px;
  --shadow-1: 0 1px 2px rgba(20, 30, 26, .04);
  --shadow-2: 0 1px 3px rgba(20, 30, 26, .06), 0 8px 24px -16px rgba(20, 30, 26, .28);
  --ring: 0 0 0 3px rgba(15, 118, 110, .16);
  --topbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
          "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------------------------------------------------------- 2. 基础排版 */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding: 0 0 48px;
  font: 15px/1.7 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1 { font-size: 22px; line-height: 1.35; font-weight: 650; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 13px; font-weight: 650; color: var(--text-2); margin: 0 0 12px;
     letter-spacing: .02em; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; color: var(--text-2); }
.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.hint { color: var(--faint); font-size: 12.5px; line-height: 1.6; margin-top: 8px; }
.why { color: var(--faint); font-size: 12px; line-height: 1.55; margin-top: 5px;
       padding-left: 9px; border-left: 2px solid var(--surface-3); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------- 3. 顶栏与导航 */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1400px; margin: 0 auto; height: var(--topbar-h);
  padding: 0 22px; display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
  width: 27px; height: 27px; border-radius: 8px; flex: 0 0 27px;
  background: linear-gradient(160deg, var(--teal) 0%, #128d82 100%);
  color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center;
}
.brand-text { font-size: 14.5px; font-weight: 650; color: var(--text); white-space: nowrap; }
.brand-text span { font-size: 11.5px; color: var(--faint); font-weight: 400; margin-left: 6px; }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a {
  font-size: 13.5px; color: var(--muted); padding: 6px 12px; border-radius: 8px;
  text-decoration: none; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.on { background: var(--teal-soft); color: var(--teal-dark); font-weight: 600; }
.who {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.who .avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3);
  color: var(--text-2); font-size: 11.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.who a { color: var(--muted); }
.who a:hover { color: var(--teal); }

/* ---------------------------------------------------------- 4. 页面容器 */
.page { max-width: 1040px; margin: 0 auto; padding: 26px 22px 0; }
.page.narrow { max-width: 720px; }
.page.wide { max-width: 1400px; padding-left: 0; padding-right: 0; }
.page-head { margin-bottom: 18px; }
.page-head .sub { margin-bottom: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.foot {
  max-width: 1040px; margin: 28px auto 0; padding: 0 22px;
  color: var(--faint); font-size: 11.5px; text-align: center;
}

.foot-sep { margin: 0 6px; }
.foot a.icp { color: var(--faint); text-decoration: none; }
.foot a.icp:hover { color: #0f766e; text-decoration: underline; }

/* ---------------------------------------------------------- 5. 卡片与状态 */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 20px; margin-bottom: 14px;
  box-shadow: var(--shadow-1);
}
.card.flat { box-shadow: none; }
.card.tint { background: var(--surface-2); }
.card-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.card-head .right { margin-left: auto; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; line-height: 1.6; padding: 2px 9px; border-radius: 999px;
  background: var(--neutral-soft); color: var(--neutral); white-space: nowrap;
  border: 1px solid transparent;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.badge.teal { background: var(--teal-soft); color: var(--teal-dark); border-color: var(--teal-line); }
.badge.off { background: var(--neutral-soft); color: var(--muted); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: 0 0 7px; }
.dot.ok { background: var(--ok); }
.dot.warn { background: #c08a12; }
.dot.bad { background: var(--bad); }
.dot.neutral { background: var(--faint); }

/* 判定卡：颜色 + 文字双标识，不只靠颜色 */
.verdict {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 650;
}
.verdict .dot { width: 9px; height: 9px; flex-basis: 9px; }

.flash { padding: 10px 14px; border-radius: var(--r-md); font-size: 13.5px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-soft); color: #105e3a; border: 1px solid var(--ok-line); }
.flash.err { background: var(--bad-soft); color: #8c261f; border: 1px solid var(--bad-line); }
.flash.warn { background: var(--warn-soft); color: #6f4e03; border: 1px solid var(--warn-line); }
.flash.info { background: var(--teal-soft); color: var(--teal-dark); border: 1px solid var(--teal-line); }

/* ---------------------------------------------------------- 6. 表单与按钮 */
label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 6px; font-weight: 500; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface); transition: border-color .12s, box-shadow .12s;
}
input[type=text]:hover, input[type=password]:hover, select:hover, textarea:hover { border-color: #c2cbc6; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--teal); box-shadow: var(--ring);
}
textarea { resize: vertical; min-height: 58px; line-height: 1.6; }
input[type=file] {
  width: 100%; font-size: 13.5px; padding: 12px; color: var(--text-2);
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2); cursor: pointer;
}
input[type=file]:hover { border-color: var(--teal); background: #fbfefd; }
input[type=file]::file-selector-button {
  font: inherit; font-size: 13px; margin-right: 12px; padding: 6px 14px;
  border-radius: 7px; border: 1px solid var(--teal-line); background: #fff;
  color: var(--teal-dark); cursor: pointer;
}
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 550; line-height: 1;
  padding: 10px 20px; min-height: 38px; border-radius: var(--r-sm);
  border: 1px solid var(--teal); background: var(--teal); color: #fff;
  cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--teal-dark); border-color: var(--teal-dark); text-decoration: none; }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost, .btn.ghost {
  background: var(--surface); color: var(--teal-dark); border-color: var(--teal-line);
}
button.ghost:hover, .btn.ghost:hover { background: var(--teal-soft); }
button.quiet, .btn.quiet {
  background: transparent; color: var(--muted); border-color: var(--line-strong);
}
button.quiet:hover, .btn.quiet:hover { background: var(--surface-3); color: var(--text); }
button.sm, .btn.sm { font-size: 13px; padding: 6px 12px; min-height: 32px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ---------------------------------------------------------- 7. 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; vertical-align: top; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .02em;
  background: var(--surface-2); border-bottom-color: var(--line);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fcfdfc; }
td.num { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }

/* ---------------------------------------------------------- 8. 各页面局部 */
/* 登录 */
.auth-wrap { max-width: 392px; margin: 6vh auto 0; }
.auth-card { padding: 24px; }
.auth-card button { width: 100%; margin-top: 20px; }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head .brand-mark { width: 40px; height: 40px; border-radius: 11px;
  font-size: 12px; margin: 0 auto 12px; }
.auth-note { text-align: center; color: var(--faint); font-size: 12.5px; line-height: 1.7; margin-top: 18px; }

/* 模式选择卡 */
.modegrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(218px, 1fr)); gap: 9px;
}
.modecard {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 13px;
  cursor: pointer; background: var(--surface); transition: border-color .12s, background .12s, box-shadow .12s;
}
.modecard:hover { border-color: var(--teal-line); background: #fbfefd; }
.modecard.sel {
  border-color: var(--teal); background: #f6fcfb;
  box-shadow: inset 0 0 0 1px var(--teal);
}
.modecard b { font-size: 13.5px; font-weight: 600; }
.modecard p { margin: 4px 0 0; font-size: 12px; color: var(--faint); line-height: 1.55; }
.modecard:focus-visible { outline: none; box-shadow: var(--ring); }

/* 记录页统计 */
.statrow { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.statrow a { text-decoration: none; }
.statrow a:hover { text-decoration: none; }

/* 详情页小标题块 */
.section-title {
  font-size: 12px; font-weight: 650; color: var(--muted);
  letter-spacing: .04em; margin: 0 0 10px;
}

/* 空状态 */
.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
  padding: 28px 20px; text-align: center; color: var(--faint); font-size: 13px;
  background: var(--surface-2);
}

/* ---------------------------------------------------------- 9. 响应式 */
@media (max-width: 860px) {
  .page { padding: 20px 16px 0; }
  .topbar-in { padding: 0 14px; gap: 12px; }
  .brand-text span { display: none; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .foot { padding: 0 16px; }
}
@media (max-width: 620px) {
  body { font-size: 14.5px; }
  h1 { font-size: 19px; }
  /* 窄屏顶栏改成两行：第一行品牌 + 用户，第二行导航。
     用 grid 明确列位，避免 nav 占满一行把用户名挤到第三行。 */
  .topbar-in {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    align-items: center; height: auto; min-height: var(--topbar-h);
    padding: 8px 12px; gap: 6px 10px;
  }
  .brand { grid-column: 1; grid-row: 1; min-width: 0; }
  .who { grid-column: 2; grid-row: 1; margin-left: 0; justify-self: end; }
  .nav {
    grid-column: 1 / -1; grid-row: 2; width: 100%;
    margin-left: 0; overflow-x: auto; padding-bottom: 2px;
  }
  .nav a { white-space: nowrap; }
  .card { padding: 15px 14px; border-radius: var(--r-md); }
  .page { padding: 16px 12px 0; }
  .brand-text { font-size: 14px; }
  .table-wrap { margin: 0 -4px; }
}
@media print {
  .topbar, .foot, .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
