/* 设备台账 — shared styles (owner pages and the colleagues' page). Layout rule: things side by side are
   the same width and height (grid with minmax(0, 1fr), stretch), and long text is cut with "…". */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── page frame ── */
.app { min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }
.app.no-tabbar { padding-bottom: calc(var(--safe-bottom) + 32px); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(243, 245, 248, 0.92);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  padding-top: var(--safe-top);
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar-inner {
  max-width: var(--content-max); margin: 0 auto; height: 56px;
  display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap); align-items: center; gap: 8px;
  padding: 0 calc(var(--gutter) - 8px);
}
.topbar-title { margin: 0; text-align: center; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { max-width: var(--content-max); margin: 0 auto; padding: 8px var(--gutter) 0; }
.page-head { padding: 8px 0 16px; }
.page-head h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }
.section { margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 8px; }
.section-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-3); letter-spacing: 0.02em; }
.section-head .link { font-size: 14px; }
.stack { display: grid; gap: var(--gap); }

/* ── icon buttons, buttons ── */
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: var(--r-pill); border: 0; background: transparent;
  display: inline-grid; place-items: center; color: var(--accent-ink); cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out), background var(--dur-1);
}
.icon-btn:active { transform: scale(0.92); background: var(--surface-3); }
.icon-btn svg { width: 24px; height: 24px; }

.btn {
  position: relative; min-height: var(--tap); padding: 10px 18px; border-radius: var(--r-m);
  border: 1px solid transparent; background: var(--surface-3); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; line-height: 1.2; cursor: pointer; text-align: center;
  transition: transform var(--dur-1) var(--ease-out), background var(--dur-1), box-shadow var(--dur-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px rgba(30, 91, 214, 0.24); }
.btn-primary:active { background: var(--accent-ink); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-tonal { background: var(--accent-soft); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--accent-ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-lg { min-height: 52px; font-size: 16px; border-radius: var(--r-l); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: var(--r-s); }
.btn-block { display: flex; width: 100%; }
.btn.is-busy { color: transparent; }
.btn.is-busy svg { opacity: 0; }
.spinner {
  position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite;
}
.btn.is-busy .spinner { color: var(--text-2); }
.btn-primary.is-busy .spinner { color: var(--on-accent); }
.spinner-inline { display: block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent); border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Two or three buttons side by side: always the same size. */
.btn-row { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.btn-row > .btn { width: 100%; height: 100%; }

/* ── cards and lists ── */
.card { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); padding: var(--card-pad); }
.card-flat { box-shadow: none; border: 1px solid var(--line); }
.list { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); overflow: hidden; }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px var(--card-pad); color: inherit; background: var(--surface); width: 100%;
  border: 0; text-align: left; cursor: pointer; transition: background var(--dur-1);
}
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row:active { background: var(--surface-2); }
.row.is-static { cursor: default; }
.row.is-static:active { background: var(--surface); }
.row-main { min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { margin-top: 2px; color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { display: flex; align-items: center; gap: 6px; color: var(--text-3); }
.row-end svg { width: 18px; height: 18px; }
.row-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.row-icon svg { width: 22px; height: 22px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* Key–value rows (device details). */
.kv { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 12px; padding: 12px var(--card-pad); align-items: baseline; }
.kv + .kv { box-shadow: inset 0 1px 0 var(--line); }
.kv dt { color: var(--text-3); font-size: 14px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ── thumbnails ── */
.thumb {
  width: var(--thumb); height: var(--thumb); border-radius: 12px; object-fit: cover; background: var(--surface-3);
  display: grid; place-items: center; color: var(--text-3); overflow: hidden; flex: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 26px; height: 26px; }
.cat-laptop { background: var(--cat-laptop-soft); color: var(--cat-laptop); }
.cat-desktop, .cat-display { background: var(--cat-desktop-soft); color: var(--cat-desktop); }
.cat-tablet, .cat-phone { background: var(--cat-tablet-soft); color: var(--cat-tablet); }
.cat-pencil { background: var(--cat-pencil-soft); color: var(--cat-pencil); }
.cat-accessory, .cat-other { background: var(--cat-other-soft); color: var(--cat-other); }

/* ── chips / badges ── */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip + .chip { margin-left: 6px; }
.chip-ok { background: var(--positive-soft); color: var(--positive); }
.chip-warn { background: var(--warning-soft); color: var(--warning); }
.chip-bad { background: var(--danger-soft); color: var(--danger); }
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); }

/* ── stat tiles: one row, equal width and height; they double as filters ── */
.tiles { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 8px; align-items: stretch; }
.tile {
  height: 100%; min-height: 72px; border: 1px solid transparent; border-radius: var(--r-m); background: var(--surface);
  box-shadow: var(--shadow-1); padding: 10px 6px; display: grid; align-content: center; justify-items: center; gap: 2px;
  cursor: pointer; transition: transform var(--dur-1) var(--ease-out), border-color var(--dur-1), background var(--dur-1);
}
.tile:active { transform: scale(0.97); }
.tile-value { font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile.is-static { cursor: default; }
.tile.is-static:active { transform: none; }
.tile.is-active { border-color: var(--accent); background: var(--accent-soft); }
.tile.is-active .tile-label { color: var(--accent-ink); }

/* ── banners ── */
.banner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px var(--card-pad); border-radius: var(--r-l); background: var(--accent-soft); color: var(--accent-ink); width: 100%;
  border: 0; text-align: left; cursor: pointer;
}
.banner + .banner { margin-top: 10px; }
.banner svg { width: 22px; height: 22px; }
.banner-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-sub { font-size: 13px; opacity: 0.9; }
.banner-warn { background: var(--warning-soft); color: var(--warning); }
.banner-ok { background: var(--positive-soft); color: var(--positive); }

/* ── progress ── */
.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width var(--dur-2) var(--ease-out); }
.progress.is-done > span { background: var(--positive); }

/* ── form fields ── */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 14px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 13px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: var(--r-s); border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 16px; line-height: 1.4; appearance: none; -webkit-appearance: none;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.textarea { min-height: 120px; resize: vertical; }
.textarea.is-short { min-height: 64px; }
.select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E6A7C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row > .field + .field { margin-top: 0; }
.search {
  position: relative;
}
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 38px; border-radius: var(--r-m); border-color: var(--line); background: var(--surface); }
.error-text { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

/* ── bottom tab bar ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.94); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom);
}
.tabbar-inner { max-width: var(--content-max); margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); height: var(--tabbar-h); }
.tab {
  display: grid; justify-items: center; align-content: center; gap: 3px; color: var(--text-3); font-size: 11px; font-weight: 600;
  border: 0; background: transparent; cursor: pointer; position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab.is-active { color: var(--accent); }
.tab-dot { position: absolute; top: 9px; left: calc(50% + 8px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-pill); background: var(--danger); color: #FFFFFF; font-size: 10px; line-height: 16px; text-align: center; }

/* ── bottom sheet / dialog ── */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 35, 0.42); display: grid; align-items: end; justify-items: center;
  opacity: 0; transition: opacity var(--dur-2) var(--ease-out);
}
.overlay.is-open { opacity: 1; }
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100dvh - var(--safe-top) - 24px); overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-3);
  padding: 8px var(--gutter) calc(var(--safe-bottom) + 20px);
  transform: translateY(24px); transition: transform var(--dur-2) var(--ease-out);
}
.overlay.is-open .sheet { transform: none; }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 12px; }
.sheet-title { margin: 0 0 4px; font-size: 19px; font-weight: 700; }
.sheet-sub { margin: 0 0 16px; color: var(--text-2); }
.sheet-actions { margin-top: 20px; }
@media (min-width: 600px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 22px; padding-bottom: 20px; }
}

/* ── toast ── */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); z-index: 60; display: grid; justify-items: center; pointer-events: none; padding: 0 var(--gutter); }
.toast {
  max-width: 480px; padding: 12px 16px; border-radius: var(--r-m); background: #1C2533; color: #FFFFFF; box-shadow: var(--shadow-3);
  font-size: 14px; opacity: 0; transform: translateY(8px); transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-out);
}
.toast.is-shown { opacity: 1; transform: none; }
.toast.is-error { background: var(--danger); }

/* ── photos ── */
.hero-photo {
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: var(--r-l); overflow: hidden; background: var(--surface-3);
  display: grid; place-items: center; color: var(--text-3); border: 0; padding: 0; cursor: zoom-in;
}
/* contain: the whole picture, label included, is what matters. Absolute, so the box's aspect ratio decides the size. */
.hero-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.hero-photo svg { width: 48px; height: 48px; }
.photo-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.photo-cell { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-3); border: 0; padding: 0; cursor: pointer; }
.photo-cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-cell .chip { position: absolute; left: 6px; bottom: 6px; height: 20px; font-size: 11px; padding: 0 6px; }
.viewer {
  position: fixed; inset: 0; z-index: 70; background: rgba(8, 12, 18, 0.94); display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  padding: var(--safe-top) 0 var(--safe-bottom);
}
.viewer-bar { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 12px; }
.viewer-bar .icon-btn { color: #FFFFFF; }
.viewer-stage { display: grid; place-items: center; min-height: 0; padding: 0 8px; }
.viewer-img { width: 100%; height: 100%; object-fit: contain; }
.viewer-actions { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 10px; padding: 12px var(--gutter) 16px; }

/* ── timeline ── */
.timeline { list-style: none; margin: 0; padding: 4px var(--card-pad); }
.timeline li { position: relative; padding: 10px 0 10px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 17px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 30px; bottom: -10px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline-date { font-size: 13px; color: var(--text-3); }

/* ── capture card (录入, colleague page) ── */
.capture {
  display: grid; gap: 10px; justify-items: center; text-align: center; padding: 28px var(--card-pad);
  border: 2px dashed var(--line-strong); border-radius: var(--r-l); background: var(--surface);
}
.capture-icon svg { width: 40px; height: 40px; color: var(--accent); }
.capture .btn-row { width: 100%; }
.capture p { margin: 0; color: var(--text-2); }
.preview { width: 100%; max-height: 52dvh; object-fit: contain; border-radius: var(--r-m); background: var(--surface-3); }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ── upload queue ── */
.queue-row { grid-template-columns: var(--thumb) minmax(0, 1fr) auto; cursor: default; }
.queue-row:active { background: var(--surface); }

/* ── empty states ── */
.empty { text-align: center; padding: 36px 20px; color: var(--text-2); }
.empty-icon svg { width: 44px; height: 44px; color: var(--text-3); margin: 0 auto 10px; }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; }
.empty p { margin: 0 auto; max-width: 30em; }

/* ── skeleton ── */
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--r-l); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── login ── */
.login { min-height: 100dvh; display: grid; align-content: center; padding: 24px var(--gutter) calc(var(--safe-bottom) + 24px); max-width: 420px; margin: 0 auto; }
.login-mark { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: #FFFFFF; display: grid; place-items: center; margin: 0 auto 16px; box-shadow: 0 10px 24px rgba(30, 91, 214, 0.3); }
.login-mark svg { width: 34px; height: 34px; }
.login h1 { text-align: center; margin: 0 0 6px; font-size: 26px; }
.login p { text-align: center; margin: 0 0 24px; color: var(--text-2); }

/* ── colleague page ── */
.collect-head { padding: calc(var(--safe-top) + 20px) 0 8px; }
.collect-head h1 { margin: 0; font-size: 24px; line-height: 1.25; }
.collect-head p { margin: 6px 0 0; color: var(--text-2); }
.device-card { display: grid; gap: 12px; }
.device-card-top { display: grid; grid-template-columns: var(--thumb) minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.device-card .row-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 8px 0; }
.result-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--positive-soft); color: var(--positive); }
.result-icon svg { width: 30px; height: 30px; }
.result-icon.is-warn { background: var(--warning-soft); color: var(--warning); }
.result-icon.is-bad { background: var(--danger-soft); color: var(--danger); }
.result h3 { margin: 4px 0 0; font-size: 18px; }
.result p { margin: 0; color: var(--text-2); }
.flag-text { margin: 0; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; align-items: start; color: var(--text-2); }
.steps b { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* 待贴标签: a device whose asset label has not come yet */
.waiting-label { color: var(--warning); font-weight: 600; }

/* Long links wrap instead of widening the sheet */
.link-text { word-break: break-all; overflow-wrap: anywhere; }
.hero-photo.is-empty { aspect-ratio: 3 / 1; cursor: pointer; }

/* 正在更新到新版本… (public/js/update.js) */
.update-screen {
  position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; align-content: center; justify-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 24px) var(--gutter) calc(var(--safe-bottom) + 24px); text-align: center;
}
.update-screen h2 { margin: 8px 0 0; font-size: 20px; }
.update-screen p { margin: 0; color: var(--text-2); }

/* Device life stepper: six equal columns, dots joined by a line */
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: start; }
.step { position: relative; display: grid; justify-items: center; gap: 6px; text-align: center; }
.step::before { content: ""; position: absolute; top: 11px; right: 50%; width: 100%; height: 2px; background: var(--line-strong); z-index: 0; }
.step:first-child::before { display: none; }
.step.is-done::before, .step.is-current::before { background: var(--accent); }
.step-dot { position: relative; z-index: 1; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); display: grid; place-items: center; color: var(--on-accent); }
.step-dot svg { width: 14px; height: 14px; }
.step.is-done .step-dot { background: var(--accent); border-color: var(--accent); }
.step.is-current .step-dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step-label { font-size: 11px; line-height: 1.3; color: var(--text-3); padding: 0 2px; }
.step.is-done .step-label { color: var(--text-2); }
.step.is-current .step-label { color: var(--accent-ink); font-weight: 600; }
.next-step { display: grid; gap: 12px; }
.next-step .row-title { white-space: normal; }
.side-links { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
