* { box-sizing: border-box; }

:root {
  font-family: "华文中宋", "STZhongsong", serif;
  color: #1b1b1b;
  background: #ffffff;
  color-scheme: light;
  font-synthesis: none;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f4f4f4;
  --border: #e4e4e4;
  --border-strong: #cfcfcf;
  --text: #1b1b1b;
  --muted: #6d6d6d;
  --faint: #9b9b9b;
  --accent: #141414;
  --danger: #b3261e;
}

html, body { background: #ffffff; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
}

button, input, select, summary { font: inherit; }
button, summary { cursor: pointer; }

button {
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
button:hover { background: var(--surface-3); }
button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: 0.55; cursor: default; }

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.primary:hover { background: #333333; border-color: #333333; }
.wide { width: 100%; }

input, select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
  font-size: 16px;
  outline: none;
}
input::placeholder { font-size: 14px; color: var(--faint); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
input[aria-invalid="true"] { border-color: var(--danger); }
input[type="search"] { height: 38px; font-size: 15px; }

label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

/* 登录 / 改密 */
.auth-view {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 30;
}
.auth-card {
  width: 380px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 30px 26px;
  display: grid;
  gap: 15px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.06);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 21px; letter-spacing: 1px; margin: 0; font-weight: 650; }
.auth-sub { margin: -6px 0 4px; font-size: 12px; color: var(--muted); }
.auth-actions { display: flex; justify-content: flex-end; gap: 9px; }
.auth-hint { margin: 2px 0 0; font-size: 11px; color: var(--faint); line-height: 1.6; }
.link-button {
  border: 0;
  background: none;
  padding: 4px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  justify-self: center;
}
.link-button:hover { background: none; color: var(--text); }

.form-error { margin: 0; min-height: 16px; font-size: 12px; color: var(--danger); line-height: 1.5; }

/* 应用骨架 */
#app-view { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: #ffffff; }

header {
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  padding: 8px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
}
.title { display: flex; align-items: center; gap: 12px; flex: none; }
.title h1 { font-size: 17px; letter-spacing: 1px; margin: 0; font-weight: 650; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; min-width: 0; }
.header-actions input[type="search"] { width: 230px; height: 34px; font-size: 13px; }
.header-actions button {
  font-size: 12px;
  padding: 6px 9px;
  white-space: nowrap;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.header-actions button:hover { background: var(--surface-3); color: var(--text); }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; margin: 0 4px; }
.who #current-user { color: var(--text); font-weight: 600; }
.role-badge {
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  letter-spacing: 1px;
}
.role-badge.admin { background: var(--accent); border-color: var(--accent); color: #ffffff; }

/* 录入区 */
main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 14px;
  width: 100%;
  margin: 0 auto;
  background: #ffffff;
}
.entry { flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; overflow: hidden; }
.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 17px 0;
  gap: 12px;
}
.entry-head > div:first-child { display: flex; align-items: center; gap: 12px; }
h2 { font-size: 13px; font-weight: 600; margin: 0; letter-spacing: 1px; }
.entry-head h2 { color: var(--text); }
.badge {
  font: 12px "华文中宋", "STZhongsong", serif;
  color: var(--muted);
  border-left: 1px solid var(--border-strong);
  padding-left: 12px;
  white-space: nowrap;
}
.stamp { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; }
.stamp > span { font-size: 11px; color: var(--muted); }
.stamp time {
  font: 700 30px/1.2 "华文中宋", "STZhongsong", serif;
  color: var(--text);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.stamp time.waiting { font-size: 22px; font-weight: 400; color: var(--faint); }

.fields {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 0.9fr 0.8fr 1fr;
  gap: 12px;
  padding: 16px 17px 12px;
}
.fields .f-remarks { grid-column: 1 / -1; }
#callsign { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
#callsign::placeholder { font-size: 15px; font-weight: 400; }

.entry-tips {
  padding: 0 17px 10px;
  font-size: 11px;
  color: var(--faint);
  line-height: 1.6;
}
.entry-foot {
  padding: 0 17px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.entry-foot > span { font-size: 11px; color: var(--muted); line-height: 1.5; }
.entry-buttons { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
#add-temp { font-size: 12px; padding: 7px 10px; background: var(--surface-2); white-space: nowrap; }
#save-record { font-size: 12px; padding: 7px 12px; white-space: nowrap; }
.key-hints {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 2px;
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}
.key-hint { display: inline-flex; align-items: center; gap: 4px; }
.key-hints kbd {
  font-family: "华文中宋", "STZhongsong", serif;
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}

.pending-drafts {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 17px 0;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}
.pending-drafts > span { font-size: 11px; color: var(--muted); }
.pending-drafts > button {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--surface-2);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 列表 */
.records-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 17px 1px 12px;
  flex: none;
}
.records-toolbar h2 { font-size: 12px; color: var(--muted); }
.records-toolbar h2 span { color: var(--text); font: 600 17px "华文中宋", "STZhongsong", serif; margin-left: 8px; }
.records-toolbar > span { font-size: 10px; color: var(--faint); }

.log { flex: 1; min-height: 80px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface); }
.table-scroll { overflow: auto; min-height: 0; flex: 1; scrollbar-color: #cfcfcf #f7f7f7; scrollbar-width: thin; }
table { width: 100%; min-width: 1180px; border-collapse: collapse; text-align: left; table-layout: fixed; }
.col-no { width: 4%; }
.col-time { width: 11%; }
.col-call { width: 9%; }
.col-mode { width: 6%; }
.col-freq { width: 7%; }
.col-rst { width: 5%; }
.col-rig { width: 10%; }
.col-ant { width: 8%; }
.col-power { width: 5%; }
.col-qth { width: 7%; }
.col-remarks { width: 9%; }
.col-operator { width: 7%; }
.col-actions { width: 12%; }

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  padding: 11px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tbody tr:nth-child(even) { background: #fcfcfc; }
tbody tr:hover { background: #f5f5f5; }
tbody tr:first-child { background: #f7f7f7; }
td:nth-child(1) { font: 11px "华文中宋", "STZhongsong", serif; color: var(--faint); }
td:nth-child(2) { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
td:nth-child(3) { font: 700 18px "华文中宋", "STZhongsong", serif; }
td:nth-child(12) { color: var(--muted); }
td:last-child { padding-left: 0; padding-right: 6px; }
td button { font-size: 10px; background: none; border: 0; padding: 5px 4px; color: var(--muted); }
td button:hover { color: var(--text); background: var(--surface-3); }

.empty { padding: 35px 15px; text-align: center; }
.empty h3 { font-size: 14px; font-weight: 400; color: var(--muted); margin: 0 0 10px; }
.empty p { font-size: 12px; color: var(--faint); margin: 0; }
.log-bottom {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 11px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 10px;
  color: var(--muted);
  flex: none;
}

/* 型号联想 */
.model-suggestions {
  position: fixed;
  z-index: 60;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.12);
  padding: 4px;
  scrollbar-width: thin;
  font-family: "华文中宋", "STZhongsong", serif;
}
.model-suggestions [role="option"] {
  padding: 9px 10px;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.model-suggestions [role="option"]:hover,
.model-suggestions [aria-selected="true"] {
  background: var(--surface-3);
}
.model-suggestions small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

/* 提示 */
#toast {
  display: none;
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  padding: 11px 17px;
  border-radius: 6px;
  max-width: 90vw;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
  z-index: 40;
}

/* 对话框 */
dialog {
  width: 520px;
  max-width: 94vw;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.28); }
dialog h2 { font-size: 17px; margin: 0 0 10px; }
dialog > form > p, dialog p { color: var(--muted); font-size: 12px; margin: 10px 0 16px; }
dialog label { display: block; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.dialog-note { font-size: 11px; color: var(--faint); line-height: 1.6; margin: 6px 0 0; }

.edit-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.edit-fields .f-remarks { grid-column: 1 / -1; }

.history-list { border: 1px solid var(--border); border-radius: 6px; max-height: 340px; overflow: auto; }
.history-row { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: 0; }
.history-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.history-actor { font-weight: 600; }
.history-time { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.history-action {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}
.history-diff { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.history-diff .from { color: var(--faint); }
.history-diff .to { color: var(--text); font-weight: 600; }
.history-empty { padding: 22px 14px; text-align: center; font-size: 12px; color: var(--faint); }

.accounts-list { border: 1px solid var(--border); border-radius: 6px; max-height: 220px; overflow: auto; }
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.account-row:last-child { border-bottom: 0; }
.account-main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.account-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-meta { font-size: 10px; color: var(--faint); white-space: nowrap; }
.account-row button { font-size: 11px; padding: 4px 8px; }

.create-user { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.create-user h3 { font-size: 13px; margin: 0 0 12px; }
.create-grid { display: grid; grid-template-columns: 1.6fr 0.8fr; gap: 10px; }
.create-user .primary { margin-top: 12px; }

/* 响应式 */
@media (max-width: 1100px) {
  .fields { grid-template-columns: repeat(3, 1fr); }
  .fields .f-remarks { grid-column: 1 / -1; }
  .create-grid { grid-template-columns: 1fr 1fr; }
  .header-actions input[type="search"] { width: 170px; }
}

@media (max-width: 900px) {
  header { padding: 8px 14px; }
  .header-actions { width: 100%; margin-left: 0; }
  .header-actions input[type="search"] { flex: 1 1 160px; width: auto; }
  .header-actions .who { margin-left: auto; }
}

@media (max-width: 740px) {
  .who .role-badge { display: none; }
  main { padding: 12px 12px 10px; }
  .fields { grid-template-columns: 1fr 1fr; gap: 10px; padding: 13px; }
  .fields .f-remarks { grid-column: 1 / -1; }
  .entry-head { padding: 11px 13px 0; }
  .stamp > span { display: none; }
  .stamp time { font-size: 22px; }
  .stamp time.waiting { font-size: 17px; }
  .entry-foot { flex-wrap: wrap; padding: 0 13px 10px; }
  .entry-buttons { margin-left: auto; }
  .key-hints { display: none; }
  .pending-drafts { margin-left: 13px; margin-right: 13px; }
  .entry-tips { padding: 0 13px 9px; font-size: 10px; }
  .edit-fields { grid-template-columns: 1fr 1fr; }
  .create-grid { grid-template-columns: 1fr; }
}

@media (max-height: 640px) and (min-width: 741px) {
  header { min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
  .header-actions input[type="search"] { height: 30px; }
  .header-actions button { padding: 4px 8px; }
  main { padding-top: 12px; padding-bottom: 10px; }
  .entry-head { padding-top: 9px; }
  .stamp time { font-size: 24px; }
  .fields { padding-top: 10px; padding-bottom: 10px; }
  .fields label > span { margin-bottom: 5px; }
  input { height: 38px; }
  .records-toolbar { padding-top: 12px; padding-bottom: 9px; }
  td { padding-top: 9px; padding-bottom: 9px; }
}
