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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f1f3f5;
  color: #1a1a1a;
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

h1 {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 12px;
}

h2 {
  font-size: 14px;
  font-weight: 500;
  color: #555;
}

.hint {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

.warn {
  font-size: 13px;
  color: #854F0B;
  background: #FAEEDA;
  padding: 10px;
  border-radius: 8px;
  margin-top: 8px;
}

.error {
  color: #A32D2D;
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

input[type="password"], input[type="number"] {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 10px;
  outline: none;
  background: #fafafa;
  font-family: inherit;
}

input:focus { border-color: #378ADD; background: #fff; }

button {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #e9ecef;
  color: #1a1a1a;
  font-family: inherit;
}

button:hover { background: #dee2e6; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button.primary { background: #378ADD; color: #fff; }
button.primary:hover { background: #185FA5; }

button.danger { background: #E24B4A; color: #fff; }
button.danger:hover { background: #A32D2D; }

button.link {
  background: transparent;
  color: #378ADD;
  width: auto;
  padding: 4px 8px;
  font-size: 13px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.topActions {
  display: flex;
  gap: 2px;
}

.status { text-align: center; padding: 24px 16px; }

.deviceName {
  font-size: 17px;
  font-weight: 500;
  color: #1a1a1a;
}

.deviceMac, .ip {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
  font-family: ui-monospace, Consolas, monospace;
}

.state {
  font-size: 22px;
  font-weight: 500;
  margin-top: 14px;
  padding: 6px 14px;
  border-radius: 6px;
  display: inline-block;
}

.state.blocked { color: #E24B4A; background: #FCEBEB; }
.state.granted { color: #1D9E75; background: #E1F5EE; }
.state.unknown { color: #888; background: #f1f1f1; }

.countdown {
  font-size: 38px;
  font-weight: 600;
  font-family: ui-monospace, Consolas, monospace;
  margin-top: 8px;
  color: #1a1a1a;
  letter-spacing: 1px;
}

.countdown.zero { color: #999; }

.metaLine {
  font-size: 11px;
  color: #aaa;
  margin-top: 6px;
}

/* "刚刚同步 / 数据 Ns 前" freshness hint under the countdown */
.syncAge {
  font-size: 10px;
  color: #8bc34a;
  margin-top: 3px;
  min-height: 12px;
}

.syncAge.stale {
  color: #ff9800;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fieldLabel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
}

.fieldLabel input {
  flex: 1;
  margin: 0;
  text-align: center;
}

#grantBtn { font-size: 16px; padding: 14px; }

.row2 {
  display: flex;
  gap: 8px;
}

.row2 button { flex: 1; }

.log {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.logHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.logbox {
  background: #fafafa;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #eee;
}

.logbox .err { color: #A32D2D; }
.logbox .ok { color: #1D9E75; }
.logbox .warn { color: #BA7517; }

/* --- ledger --- */

.ledgerSummary {
  background: #f7f9fb;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.ledgerUser {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.ledgerUser .luName { font-size: 15px; font-weight: 500; }
.ledgerUser .luStat { font-size: 13px; color: #555; }

.ledgerTotal {
  border-top: 1px solid #e3e8ee;
  margin-top: 6px;
  padding-top: 8px;
  font-size: 13px;
  color: #378ADD;
  font-weight: 500;
}

.ledgerListHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ledgerList { display: flex; flex-direction: column; }

.ledgerRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid #f0f0f0;
}

.ledgerRow .lrUser { font-size: 14px; font-weight: 500; min-width: 44px; }
.ledgerRow .lrTime { flex: 1; font-size: 12px; color: #888; font-family: ui-monospace, Consolas, monospace; }
.ledgerRow .lrMin { font-size: 14px; color: #1D9E75; font-weight: 500; }

.empty { text-align: center; color: #aaa; padding: 20px 0; font-size: 13px; }

/* --- device list --- */

.deviceList { display: flex; flex-direction: column; }

.deviceRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid #f0f0f0;
}

.deviceRow.current { background: #f0f6ff; margin: 0 -8px; padding: 12px 10px; border-radius: 8px; }

.deviceRow .dvMain { flex: 1; min-width: 0; }

.deviceRow .dvName {
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deviceRow .dvMeta {
  font-size: 12px;
  color: #888;
  font-family: ui-monospace, Consolas, monospace;
  margin-top: 2px;
}

button.small { width: auto; padding: 8px 14px; font-size: 13px; flex-shrink: 0; }

/* --- scoring config view ----------------------------------------------- */

.filterBar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 16px;
}

.filterChip {
  padding: 6px 14px;
  border: 1px solid #ccd2da;
  border-radius: 999px;
  background: #fff;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.filterChip.active { background: #378ADD; border-color: #378ADD; color: #fff; }

.scoreItemsList { padding: 0 16px; }

.scoreItemCard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.scoreItemCard.disabled { opacity: 0.5; }

.sicMain { display: flex; flex-direction: column; }
.sicName { font-size: 15px; color: #333; font-weight: 500; }
.sicMeta { font-size: 12px; color: #888; margin-top: 2px; font-family: ui-monospace, Consolas, monospace; }

.sicActions { display: flex; gap: 4px; flex-wrap: wrap; }
.sicActions button { font-size: 12px; padding: 6px 10px; }

.addItem {
  margin: 12px 16px;
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.addItem summary {
  font-size: 14px;
  color: #378ADD;
  cursor: pointer;
  padding: 6px 0;
  font-weight: 500;
}
.addItemForm { padding: 8px 0; }

.checkboxField { flex-direction: row !important; align-items: center; gap: 8px; }

button.dangerLink { color: #e03131; }

/* --- points management (积分管理) -------------------------------------- */

.topActions { overflow-x: auto; scrollbar-width: none; }
.topActions::-webkit-scrollbar { display: none; }
.topActions button { white-space: nowrap; }

.addItemForm label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #666;
  margin: 6px 0;
}
.addItemForm select,
.addItemForm input[type="text"],
.addItemForm input[type="number"] {
  width: 100%;
  padding: 10px;
  font-size: 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  outline: none;
  font-family: inherit;
}
.addItemForm select:focus,
.addItemForm input[type="text"]:focus,
.addItemForm input[type="number"]:focus { border-color: #378ADD; background: #fff; }
.addItemForm .checkboxField { flex-direction: row; align-items: center; gap: 8px; }

.scoreStats { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }

.statCard {
  background: #f7f9fb;
  border-radius: 10px;
  padding: 10px 14px;
}
.statHead { display: flex; justify-content: space-between; align-items: flex-end; }
.statName { font-size: 15px; font-weight: 600; }
.statBalBox { display: flex; flex-direction: column; align-items: flex-end; }
.statBalLabel { font-size: 10px; color: #99a; letter-spacing: 1px; }
.statBal { font-size: 20px; font-weight: 700; color: #378ADD; font-family: ui-monospace, Consolas, monospace; line-height: 1.2; }
.statSub {
  font-size: 12px;
  color: #777;
  margin-top: 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.statSub .up { color: #1D9E75; font-weight: 500; }
.statSub .down { color: #E24B4A; font-weight: 500; }

.scoreList { display: flex; flex-direction: column; }

.svRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 2px;
  border-bottom: 1px solid #f0f0f0;
}
.svRow.voided { opacity: 0.55; }

.svMain { flex: 1; min-width: 0; }

.svTop { display: flex; align-items: center; gap: 8px; }
.svUser {
  font-size: 12px;
  background: #e8f0fb;
  color: #185FA5;
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.svName {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.svDelta { font-size: 15px; font-weight: 600; white-space: nowrap; flex-shrink: 0; font-family: ui-monospace, Consolas, monospace; }
.svDelta.pos { color: #1D9E75; }
.svDelta.neg { color: #E24B4A; }
.svDelta.zero { color: #888; }

.svMeta { font-size: 11px; color: #999; margin-top: 2px; }

.svActs { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.svActs button { font-size: 12px; padding: 4px 8px; }

.svEdit { gap: 6px; }
.svEdit .svEditName { flex: 1; min-width: 0; }
.svEdit .svEditDelta { width: 84px; flex-shrink: 0; }
.svEdit input {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccd2da;
  border-radius: 8px;
  background: #fafafa;
  outline: none;
  font-family: inherit;
}
.svEdit input:focus { border-color: #378ADD; background: #fff; }
.svEditActs { display: flex; gap: 4px; flex-shrink: 0; }
.svEditActs button { width: auto; padding: 8px 12px; font-size: 13px; }

/* --- 积分管理页: 积分记录 / 识别样本 两个标签 --- */
.svTabs {
  display: flex;
  gap: 4px;
  margin: 4px 0 14px;
  border-bottom: 1px solid #e6e9ec;
}
.svTab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: #888;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.svTab.active { color: #378ADD; border-bottom-color: #378ADD; font-weight: 500; }
.svTabBadge {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  margin-left: 3px;
  border-radius: 8px;
  background: #E8A33D;
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

.fsIntro {
  font-size: 12px;
  color: #888;
  background: #f7f9fb;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  line-height: 1.6;
}
.fsSummary { font-size: 12px; color: #888; margin: 2px 0 10px; }

.fsGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.fsCard {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e6e9ec;
  border-radius: 10px;
  overflow: hidden;
}
.fsCard img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f1f3f5;
  display: block;
  /* v1.15: archived 112x112 faces land on disk upside-down because the
     aligner shares its target rotation with the camera buffer. The model
     still works (embeddings are self-consistent) so we only fix what the
     user sees - flip the rendered image without re-encoding. */
  transform: scaleY(-1);
}
.fsBody { padding: 6px 8px 8px; }
.fsName { font-size: 13px; font-weight: 500; color: #1a1a1a; }
.fsMeta { font-size: 11px; color: #999; margin-top: 1px; }
.fsTag {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10px;
  background: #FDF0DC;
  color: #B4761B;
}
.fsTag.done { background: #E3F3E8; color: #2F7A45; }
.fsActs { display: flex; gap: 4px; margin-top: 6px; }
.fsActs button {
  flex: 1;
  padding: 5px 0;
  border: 1px solid #ccd2da;
  border-radius: 6px;
  background: #fff;
  color: #555;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}
.fsActs button.ok { border-color: #8FCBA3; color: #2F7A45; background: #F3FAF5; }
.fsActs button.fix { border-color: #F0C48A; color: #B4761B; background: #FDF7EE; }
.fsActs button.del { border-color: #E8B4B4; color: #B44; background: #FDF3F3; }
.fsActs button:disabled { opacity: 0.5; cursor: default; }
.fsEmpty { color: #999; font-size: 13px; text-align: center; padding: 30px 0; }
