* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f5f6f8;
  color: #1f2328;
  font-size: 14px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
.top h1 { font-size: 18px; margin: 0; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.btn-link {
  color: #2563eb;
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
}
.btn-link:hover { background: #dbeafe; }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 16px; font-size: 16px; }

form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #4b5563;
}
form input {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}
form input:focus { border-color: #3b82f6; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 20px;
}
.row-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
}

button {
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #1d4ed8; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: #4b5563;
  border: 1px solid #d1d5db;
}
button.ghost:hover:not(:disabled) { background: #f3f4f6; }
button.danger {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 4px 10px;
  font-size: 12px;
}
button.danger:hover:not(:disabled) { background: #fef2f2; }

.err { color: #b91c1c; min-height: 1em; margin: 8px 0 0; }
.muted { color: #6b7280; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #f0f1f3;
  vertical-align: middle;
}
th { color: #6b7280; font-weight: 500; background: #fafbfc; }
td.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; }

.secret {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.secret .value { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.secret .hint { font-size: 11px; color: #9ca3af; }

#login-view { max-width: 360px; margin: 80px auto; }
#login-view form { display: flex; flex-direction: column; gap: 12px; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-row img {
  height: 40px;
  width: 130px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f3f4f6;
  cursor: pointer;
  user-select: none;
}

#form-status { color: #6b7280; font-size: 13px; }

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; }

/* ---------- top-level navigation (shared across pages) ---------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  height: 52px;
}
.topnav .topnav-links { display: flex; gap: 4px; align-items: center; }
.topnav a {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  color: #4b5563;
  text-decoration: none;
  font-size: 14px;
  border-radius: 8px;
  transition: background-color .15s ease, color .15s ease;
}
.topnav a:hover { background: #f3f4f6; color: #111827; }
.topnav a.active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 500;
}
.topnav .topnav-right { display: flex; align-items: center; gap: 10px; }
.topnav button#topnav-logout {
  background: transparent;
  color: #4b5563;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
}
.topnav button#topnav-logout:hover {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* Make the page-title header (H1 + page-specific actions) blend with the body
   instead of looking like a second nav strip. */
.topnav + .top {
  background: transparent;
  border-bottom: 0;
  padding: 20px 24px 4px;
}
.topnav + .top h1 { font-size: 20px; font-weight: 600; }

/* ---------- edit-entry dialog ---------- */
dialog.edit-dialog {
  border: 0;
  border-radius: 10px;
  padding: 0;
  width: min(520px, 92vw);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
}
dialog.edit-dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog.edit-dialog .dlg-head {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 15px;
  font-weight: 500;
}
dialog.edit-dialog form { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
dialog.edit-dialog .dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
dialog.edit-dialog .err { margin: 4px 0 0; }
button.link-btn {
  background: transparent;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 4px 10px;
  font-size: 12px;
}
button.link-btn:hover:not(:disabled) { background: #eff6ff; }
